/* === Article Page Header === */
.site-header {
  text-align: center;
  padding: 2rem 1rem 0;
}

.site-header h1 {
  font-size: 36px;
  font-weight: normal;
  font-family: Georgia, 'Times New Roman', serif;
  letter-spacing: -0.02em;
  line-height: 1.15;
  text-wrap: balance;
  margin-bottom: 0.35rem;
}

.site-header h1 a.masthead-home {
  color: inherit;
  text-decoration: none;
  text-decoration-line: none;
  text-underline-offset: unset;
  text-decoration-thickness: unset;
  display: inline-block;
}

.site-header h1 a.masthead-home:visited {
  color: inherit;
}

.site-header h1 a.masthead-home:hover,
.site-header h1 a.masthead-home:focus-visible {
  color: var(--text-muted);
  text-decoration: none;
  transform: translateY(-1px);
}

@media (prefers-reduced-motion: no-preference) {
  .site-header h1 a.masthead-home {
    transition:
      transform 0.2s ease,
      color 0.15s ease;
  }
}

@media (prefers-reduced-motion: reduce) {
  .site-header h1 a.masthead-home:hover,
  .site-header h1 a.masthead-home:focus-visible {
    transform: none;
  }
}

.full-width-rule {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 1rem 0;
}

/* === Article Container === */
.article-container {
  max-width: 984px;
  margin: 0 auto;
  padding: 1rem 2rem 4rem;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 648px) 1fr;
  gap: 2rem;
}

/* === Article Content === */
.article-container article {
  min-width: 0;
}

.article-title {
  font-size: 38px;
  font-weight: normal;
  font-family: Georgia, 'Times New Roman', serif;
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin-bottom: 0.45rem;
  text-wrap: balance;
}

.article-date {
  display: block;
  color: var(--text-muted);
  font-size: 0.9em;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  margin-bottom: 2rem;
}

.article-container article h2 {
  font-size: 1.5em;
  font-weight: bold;
  letter-spacing: -0.015em;
  margin-top: 2.5rem;
  margin-bottom: 0.8rem;
}

.article-container article h3 {
  font-size: 1.2em;
  font-weight: bold;
  margin-top: 2rem;
  margin-bottom: 0.6rem;
}

.article-container article p {
  margin-bottom: 1em;
}

.article-container article a {
  color: var(--accent-link);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in srgb, var(--accent-link) 40%, transparent);
}

@media (prefers-reduced-motion: no-preference) {
  .article-container article a {
    transition:
      color 0.15s ease,
      text-decoration-color 0.15s ease;
  }
}

.article-container article a:hover {
  text-decoration-color: var(--accent-link);
}

/* === Lists === */
.article-container article ul,
.article-container article ol {
  margin-bottom: 1em;
  padding-left: 1.5em;
}

.article-container article li {
  margin-bottom: 0.3em;
}

.compact-li {
  margin-bottom: 0.5em;
}

/* === Figures === */
figure {
  margin: 1.5em 0;
}

figure img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
}

.article-container article figure figcaption:not(.caption) {
  font-family: Georgia, 'Times New Roman', serif;
  font-style: italic;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  text-align: left;
  line-height: 1.35;
}

[data-theme="dark"] .article-container figure img {
  border-radius: 4px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.075),
    0 14px 42px rgba(0, 0, 0, 0.55);
  filter: brightness(0.96) contrast(1.03);
}

:root:not([data-theme="dark"]) .article-container figure img {
  box-shadow:
    0 0 0 1px var(--border-subtle),
    0 10px 28px rgba(0, 0, 0, 0.06);
}

.caption {
  font-size: 15px;
  line-height: 1.3em;
  color: var(--text-muted);
  margin-top: 0.5em;
  text-align: center;
}

/* === Code Blocks === */
pre[class*="language-"] {
  margin: 1.5em 0;
  border-radius: 6px;
  font-size: 0.9em;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] pre[class*="language-"] {
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.45);
}

code {
  font-family: 'Menlo', 'Consolas', 'Monaco', monospace;
  font-size: 0.9em;
}

:not(pre) > code {
  background: var(--code-bg);
  padding: 0.15em 0.35em;
  border-radius: 4px;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--border-subtle) 65%, transparent);
}

/* === Footnotes === */
.footnotes {
  margin-top: 3rem;
  font-size: 0.9em;
}

.footnotes hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin-bottom: 1rem;
}

.footnotes ol {
  padding-left: 1.5em;
}

.footnotes li {
  margin-bottom: 0.5em;
}

.article-container article sup a {
  text-decoration: none;
  color: var(--accent-link);
  font-weight: bold;
}

/* === Bibliography === */
.bibliography {
  margin-top: 3rem;
}

.bibliography ol {
  padding-left: 1.5em;
  font-size: 0.95em;
}

.bibliography li {
  margin-bottom: 0.5em;
}

/* === TOC Sidebar === */
.l-gutter {
  display: none;
}

@media (min-width: 1280px) {
  .l-gutter {
    display: block;
    position: sticky;
    top: 5.5rem;
    align-self: start;
    font-size: 13px;
    line-height: 1.8;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
  }

  .l-gutter .toc-heading {
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5em;
    font-size: 13px;
  }

  .l-gutter ul {
    list-style: none;
    padding: 0;
    margin: 0;
    min-width: 0;
  }

  .l-gutter li {
    margin-bottom: 0.15em;
    min-width: 0;
  }

  .l-gutter a {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
    text-decoration: none;
    transition:
      color 0.15s ease,
      text-decoration-color 0.15s ease;
  }

  .l-gutter a:hover {
    text-decoration: underline;
    color: var(--text);
  }

  .toc-anchor {
    font-style: italic;
  }

  .toc-h3 a {
    padding-left: 1.25em;
    box-sizing: border-box;
  }
}

/* === Responsive === */
@media (max-width: 1279px) {
  .article-container {
    display: block;
    max-width: 700px;
  }
}

@media (max-width: 600px) {
  .article-title {
    font-size: 28px;
  }

  .article-container {
    padding: 1rem;
  }
}

[data-theme="dark"] .katex {
  color: var(--text);
}
