code,
pre,
kbd,
samp {
  font-family: var(--font-mono);
  background-color: var(--code-bg-color);
  color: var(--code-color);
  padding: 0.05rem 0.2rem;
  border-radius: 0.25rem;
  font-size: 0.9rem;
}
code[class*="language-"],
pre[class*="language-"] {
  font-size: 0.9rem;
}
.article-date {
  white-space: nowrap;
  margin-right: 1rem;
  color: var(--body-color-secondary);
}
.article img {
  max-width: 100%;
  border-radius: 0.3em;
  height: auto;
}
.article blockquote {
  border-left: 0.5rem solid var(--link-color);
  margin-left: 0;
  padding-left: 1rem;
  margin-right: 2rem;
  font-style: italic;
}
.article li {
  margin-bottom: 0.5rem;
}
.article img + em {
  font-size: 0.8rem;
}
.article img ~ em {
  text-align: center;
  display: inline-block;
  width: 100%;
}
picture {
  text-align: center;
  width: 100%;
  display: block;
}
.article-tag-title {
  text-align: center;
  margin-bottom: 0;
}
.article-tags {
  font-size: 0.8rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1.5rem;
  list-style: none;
  color: var(--body-color-secondary);
}
.article-tags dd {
  margin-inline-start: 0;
  font-style: italic;
}

.text-center {
  text-align: center;
}
.article table {
  display: block;
  border-collapse: collapse;
}
.article tr,
.article thead,
.article tbody,
.article tfoot {
  display: block;
}
.article col,
.article colgroup {
  display: none;
}
.article td,
.article th {
  display: block;
  border: 1px solid var(--body-color-secondary);
  padding: 2px;
  font-size: 1rem;
}
.article th {
  text-align: left;
}
.article tr {
  margin-bottom: 10px;
  border: 1px solid var(--body-color-secondary);
}
.article caption {
  display: block;
}
.article pre {
  font-size: 0.9rem;
}
.form {
  display: grid;
  grid-template-columns: 1fr;
  max-width: 30rem;
  margin: 3rem auto 0 auto;
}
.form-element {
  margin-bottom: 1rem;
  padding: 0.5rem;
  border-radius: 4px;
  font-size: 1rem;
  line-height: 1.5rem;
  border: 1px solid var(--body-color-secondary);
}
.form-button {
  background-color: var(--link-color);
  border: 1px solid var(--link-color);
  color: #fff;
  text-align: center;
}
.news-box {
  background-color: var(--box-bg-color);
  border-radius: 0.5rem;
  padding: 1rem;
  font-size: 1rem;
  line-height: 1.1;
  margin-bottom: 0.25rem;
  margin-top: 2rem;
  margin-bottom: 2rem;
  border: 1px solid var(--box-border-color);
}
.news-content {
  margin: 0 auto;
  max-width: 30rem;
}
.news-heading {
  font-weight: bold;
  font-size: 1.13rem;
  margin-top: 0;
  margin-bottom: 0.2rem;
}
.news-box .form {
  margin-top: 1rem;
  margin-bottom: 0;
}
.news-box .form-button {
  margin-bottom: 0;
}
.promotion {
  background-color: var(--box-bg-color);
  border-radius: 0.5rem;
  margin: 2rem 0;
  border: 1px solid var(--promo-border);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.promotion-logo {
  margin-left: 1rem;
}
.promotion-img {
  width: 100%;
}
.promotion-title {
  font-size: 1.2rem;
  padding: 1rem 1rem 0.5rem 1rem;
  font-weight: bold;
}
.promotion-body {
  padding: 0 1rem;
  margin-top: 0;
  color: var(--promo-color);
}
.promotion-cta,
.promotion-cta:visited,
.promotion-cta:active {
  margin: 0 1rem 1rem 1rem;
  color: var(--promo-cta-color);
  display: inline-block;
  padding: 0.5rem;
  background-color: var(--link-color);
  border-radius: 0.25rem;
  cursor: pointer;
  text-decoration: none;
}
.series {
  background-color: var(--box-bg-color2);
  border-radius: 0.5rem;
  margin: 2rem 0;
  border: 1px solid var(--box-border-color);
}
.article .series-heading {
  font-size: 1.2rem;
  padding: 1rem 1rem 0rem 1rem;
  font-weight: bold;
  margin: 0;
}
.series-body {
  padding: 0rem 1rem;
  margin: 0;
  font-size: 0.9rem;
}
.series-list {
  font-size: 0.9rem;
  margin-top: 0.5rem;
  margin-bottom: 1rem;
  line-height: 1;
}
.series-list a {
  padding: 0.9rem;
  display: inline-block;
}

.video lite-youtube {
  border-radius: 0.3rem;
  max-width: 1280px;
  max-height: 720px;
  aspect-ratio: 16 / 9;
}
.video > iframe {
  width: 100%;
  height: 100%;
}
.footnotes,
.footnote-ref {
  font-size: 0.8rem;
}
.footnote-ref a,
.footnote-backref {
  text-decoration: none;
}
.figure {
  margin: 3rem 0 0 0;
}
.figure-caption {
  text-align: center;
  font-size: 0.8rem;
  font-style: italic;
  color: var(--body-color-secondary);
}

.header-anchor {
  font-size: 0.9rem;
}
.latest-articles-videos {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  margin-top: 1rem;
}

.website-built {
  font-size: 0.8rem;
  text-align: center;
}

.chat-toggle {
  position: fixed;
  bottom: 0.5rem;
  right: 0.5rem;
  z-index: 1001;
  width: 3.75rem;
  height: 3.75rem;
  border-radius: 50%;
  border: 1px solid var(--body-color-secondary);
  background-image: url("/images/af-chat-avatar.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  cursor: pointer;
  box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

@supports (background-image: url("/images/af-chat-avatar.webp")) {
  .chat-toggle {
    background-image: url("/images/af-chat-avatar.webp");
  }
}
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .chat-toggle {
    background-image: url("/images/af-chat-avatar@2x.png");
  }
}

@supports (background-image: url("/images/af-chat-avatar@2x.webp")) {
  @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .chat-toggle {
      background-image: url("/images/af-chat-avatar@2x.webp");
    }
  }
}

.chat-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 0.375rem 1rem rgba(0, 0, 0, 0.2);
}

.chat-toggle:active {
  transform: scale(0.95);
}

.chat-toggle .sr-only {
  position: absolute;
  width: 0.0625rem;
  height: 0.0625rem;
  padding: 0;
  margin: -0.0625rem;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.chat-container {
  position: fixed;
  bottom: 6rem;
  right: 1.25rem;
  width: 16rem;
  height: 25rem;
  border: 1px solid var(--body-color-secondary);
  background: var(--bg-color);
  z-index: 1000;
  border-radius: 0.5rem;
  box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.15);
  transform-origin: bottom right;
  transform: scale(0) translate(17.5rem, 23rem);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  display: flex;
  flex-direction: column;
}

.chat-container.show {
  transform: scale(1) translate(0, 0);
  opacity: 1;
}

.chat-container.hide {
  transform: scale(0) translate(17.5rem, 23rem);
  opacity: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.625rem;
  border-bottom: 1px solid var(--body-color-secondary);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 0;
  height: calc(100% - 4rem);
}

.chat-message {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  word-wrap: break-word;
  overflow-wrap: break-word;
  flex-shrink: 0;
}

.chat-message.user {
  align-self: flex-start;
}

.chat-message.bot {
  align-self: flex-end;
}

.chat-bubble {
  padding: 0.5rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.9rem;
  line-height: 1.3;
  position: relative;
  word-wrap: break-word;
  overflow-wrap: break-word;
  -webkit-hyphens: auto;
  hyphens: auto;
}

.chat-message.user .chat-bubble {
  background-color: var(--body-color-secondary);
  color: var(--bg-color);
  border-bottom-left-radius: 0.25rem;
}

.chat-message.bot .chat-bubble {
  background-color: var(--link-color);
  color: #fff;
  border-bottom-right-radius: 0.25rem;
}

/* Hide placeholder when actual image is present */
.lastfm-widget:has(.lastfm-img[src]:not([src=""])) .lastfm-placeholder {
  display: none;
}

@media (prefers-color-scheme: dark) {
  .chat-message.user .chat-bubble {
    background-color: #3a3a3a;
    color: var(--body-color);
  }
}

/* Loading animation for chat */
.chat-bubble.loading-bubble {
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-dots {
  display: inline-flex;
  gap: 0.2rem;
  color: inherit;
}

.loading-dots span {
  opacity: 0.4;
  animation: loading-dot 1.4s infinite both;
  font-size: 1rem;
  color: inherit;
  display: inline-block;
}

/* Ensure loading dots are visible in chat bubbles */
.chat-bubble.loading-bubble .loading-dots,
.chat-bubble.loading-bubble .loading-dots span {
  color: #fff;
}

.loading-dots span:nth-child(1) {
  animation-delay: 0s;
}

.loading-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes loading-dot {
  0%,
  60%,
  100% {
    opacity: 0.4;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-8px);
  }
}

.chat-input {
  flex: 1;
  height: 3rem;
  box-sizing: border-box;
  padding: 0.25rem 0.625rem;
  border: none;
  background-color: transparent;
  color: var(--body-color);
  outline: none;
  resize: none;
}

.chat-input-container {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.625rem;
}

.chat-send {
  margin-left: 0.5rem;
  height: 3rem;
  padding: 0 1rem;
  border: none;
  background-color: var(--link-color);
  color: #fff;
  border-radius: 0.25rem;
  cursor: pointer;
  flex-shrink: 0;
}

.chat-source-link {
  display: inline-block;
  margin-top: 0.5rem;
  color: #fff;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  font-size: 0.85rem;
  opacity: 0.9;
  word-break: break-all;
  line-height: 1.4;
}

.chat-source-link:visited {
  color: #fff;
  text-decoration: underline;
}

.chat-source-link:hover {
  opacity: 1;
  text-decoration-thickness: 2px;
}

@media (prefers-color-scheme: dark) {
  .series-heading,
  .series-body,
  .series-list {
    color: var(--promo-color);
  }
}

@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation: fade 0.3s ease both;
}

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Desktop */
@media screen and (min-width: 48rem) {
  .chat-toggle {
    bottom: 1.25rem;
    right: 1.25rem;
  }
  .chat-container {
    width: 18.75rem;
  }
  .header {
    padding-top: 0;
    position: sticky;
    display: grid;
    top: 0;
    -webkit-backdrop-filter: saturate(180%) blur(5px);
    backdrop-filter: saturate(180%) blur(5px);
    background: var(--header-bg-color);
    padding: 0.5rem;
    box-shadow: inset 0 -0.5px 0 0 var(--header-shadow);
    grid-template-columns: 1fr 5fr;
    z-index: 10;
  }
  h1 {
    font-size: 3rem;
    line-height: 3.2rem;
    min-height: 3.3rem;
  }
  h2 {
    font-size: 2.5rem;
    line-height: 2.6rem;
    min-height: 2.7rem;
  }
  h3 {
    font-size: 2rem;
    line-height: 2.1rem;
    min-height: 2.2rem;
  }
  .logo {
    width: 4rem;
    height: 4rem;
  }
  .avatar-wrapper {
    display: grid;
    grid-template-columns: min-content 2fr;
    gap: 1rem;
    margin: 0;
  }
  .header-titles {
    text-align: left;
  }
  .nav {
    display: flex;
    justify-content: flex-end;
    align-items: center;
  }
  .nav-links-header,
  .nav-links-footer {
    display: inline-block;
  }

  .main {
    padding-top: 2rem;
  }
  .article table {
    display: table;
  }
  .article tr {
    display: table-row;
  }
  .article thead {
    display: table-header-group;
  }
  .article tbody {
    display: table-row-group;
  }
  .article tfoot {
    display: table-footer-group;
  }
  .article col {
    display: table-column;
  }
  .article colgroup {
    display: table-column-group;
  }
  .article td,
  .article th {
    display: table-cell;
  }
  .article caption {
    display: table-caption;
  }
  .article-list-item picture {
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    flex-wrap: nowrap;
    align-items: center;
  }
  .article-list-item .article-title {
    margin-top: 0.25rem;
    line-height: 110%;
  }

  aside .article-description {
    font-size: 80%;
    line-height: 110%;
  }

  .news-box {
    padding: 3rem;
  }
  .lastfm-widget {
    max-width: 30rem;
  }
  .lastfm-placeholder,
  .lastfm-img {
    max-width: 174px;
    max-height: 174px;
  }

  .lastfm-title {
    font-size: 1rem;
  }
  .lastfm-widget {
    font-size: 1.3rem;
  }
  .latest-articles-videos {
    grid-template-columns: 2fr 320px;
    align-items: baseline;
    margin-top: 5rem;
  }
  .nav-links {
    font-size: 1rem;
  }
  .nav-links-footer {
    font-size: 0.8rem;
    line-height: 100%;
  }
  .nav-links li {
    display: inline-block;
    padding: 0.5rem 0.9rem;
    text-align: end;
  }
  .header-anchor {
    font-size: 1.2rem;
  }
}

@media screen and (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}