/*
 * World Model Evaluation Lab - GitHub Pages design system.
 *
 * Typography:  IBM Plex Sans (body, headings) + IBM Plex Mono (code, tables).
 *              Loaded via Google Fonts in the layout head.
 * Palette:     same tokens as the hand-rolled SVG illustrations under
 *              docs/assets/, so charts and chrome stay visually consistent.
 * Scope:       applied to every page rendered with _layouts/default.html
 *              (Jekyll default in _config.yml).
 */

:root,
[data-theme="light"] {
  --ink: #1f2933;
  --ink-soft: #323f4b;
  --muted: #52606d;
  --muted-soft: #7b8794;
  --accent: #0f5fbf;
  --accent-strong: #0a4ba0;
  --accent-soft: #e6efff;
  --warn: #b34a00;
  --ok: #0e7a47;
  --danger: #c0392b;
  --surface: #f7f9fc;
  --surface-strong: #eef2f7;
  --border: #d8e0e8;
  --border-soft: #e4ebf2;
  --bg: #ffffff;
  --bg-elevated: #ffffff;
  --shadow-sm: 0 1px 2px rgba(15, 25, 35, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 25, 35, 0.06);
  --shadow-lg: 0 12px 32px rgba(15, 25, 35, 0.08);
  --nav-bg: rgba(255, 255, 255, 0.85);
  --nav-bg-solid: #ffffff;

  --font-sans: "IBM Plex Sans", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, "SF Mono",
    Menlo, Consolas, "Liberation Mono", monospace;

  --content-max: 56rem;
  --nav-height: 56px;
  --shell-max: 88rem;
  --toc-width: 16rem;
}

[data-theme="dark"] {
  --ink: #e6ebf2;
  --ink-soft: #cfd6df;
  --muted: #9aa3ad;
  --muted-soft: #6f7884;
  --accent: #5fa1ff;
  --accent-strong: #7eb4ff;
  --accent-soft: #14233b;
  --warn: #f0a060;
  --ok: #4dc787;
  --danger: #ef6a5a;
  --surface: #161c25;
  --surface-strong: #1d2530;
  --border: #2a3340;
  --border-soft: #232a35;
  --bg: #0f141c;
  --bg-elevated: #161c25;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
  --nav-bg: rgba(15, 20, 28, 0.85);
  --nav-bg-solid: #0f141c;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-weight: 400;
  font-feature-settings: "kern", "liga", "ss01";
  color: var(--ink);
  background: var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Skip link for keyboard users. */
#skip-to-content {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
#skip-to-content:focus {
  position: static;
  width: auto;
  height: auto;
  display: inline-block;
  margin: 0.5rem 1rem;
  padding: 0.4rem 0.8rem;
  background: var(--accent);
  color: white;
  border-radius: 4px;
  text-decoration: none;
}

/* =============================================================
 * Sticky slim site nav (replaces the old GitHub-Pages-style banner).
 * ============================================================= */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--nav-bg);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.site-nav-inner {
  max-width: var(--shell-max);
  margin: 0 auto;
  height: var(--nav-height);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.site-brand {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: -0.01em;
  border-bottom: none;
}
.site-brand:hover {
  color: var(--accent);
  border-bottom: none;
}
.brand-mark {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.18rem 0.5rem;
  border-radius: 4px;
  letter-spacing: 0.02em;
}
.brand-version {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.site-nav-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
}
.site-nav-links li { margin: 0; }
.site-nav-links li::marker { content: none; }
.site-nav-links a {
  display: inline-block;
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  font-size: 0.88rem;
  color: var(--muted);
  text-decoration: none;
  border-bottom: none;
  transition: background 0.15s, color 0.15s;
}
.site-nav-links a:hover,
.site-nav-links a:focus-visible {
  color: var(--ink);
  background: var(--surface);
  border-bottom: none;
  outline: none;
}

.site-nav-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.theme-toggle,
.site-nav-github {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.theme-toggle:hover,
.site-nav-github:hover,
.theme-toggle:focus-visible,
.site-nav-github:focus-visible {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--border);
  outline: none;
}
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* Mobile menu toggle (hidden on desktop). */
.site-nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  padding: 0 8px;
}
.site-nav-toggle span {
  display: block;
  height: 2px;
  width: 20px;
  background: var(--ink);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

@media (max-width: 880px) {
  .site-nav-links {
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.75rem 1rem 1rem;
    background: var(--nav-bg-solid);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s, transform 0.18s;
  }
  .site-nav.is-open .site-nav-links {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }
  .site-nav-links a {
    display: block;
    padding: 0.6rem 0.75rem;
  }
  .site-nav-toggle { display: inline-flex; }
}

/* =============================================================
 * Site shell + content area.
 * ============================================================= */
.site-shell {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 0 1.25rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2.5rem;
}

@media (min-width: 1180px) {
  .site-shell {
    grid-template-columns: minmax(0, 1fr) var(--toc-width);
    align-items: flex-start;
  }
}

.main-content {
  max-width: var(--content-max);
  margin: 0 auto;
  width: 100%;
  padding: 2.5rem 0 4rem;
}

@media (min-width: 1180px) {
  .main-content {
    margin: 0;
    padding: 2.5rem 1.5rem 4rem 0;
  }
}

/* =============================================================
 * Right-rail TOC (auto-built from page headings by interactive.js).
 * ============================================================= */
.site-toc {
  display: none;
}
@media (min-width: 1180px) {
  .site-toc {
    display: block;
    position: sticky;
    top: calc(var(--nav-height) + 1.5rem);
    align-self: flex-start;
    padding: 2.5rem 0 4rem;
  }
}
.site-toc-inner {
  border-left: 1px solid var(--border);
  padding: 0.25rem 0 0.25rem 1rem;
}
.site-toc-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-soft);
  margin-bottom: 0.6rem;
}
.site-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.5;
}
.site-toc-list li { margin: 0; }
.site-toc-list li::marker { content: none; }
.site-toc-list li.toc-h3 { padding-left: 0.9rem; }
.site-toc-list a {
  display: block;
  padding: 0.25rem 0;
  color: var(--muted);
  text-decoration: none;
  border-bottom: none;
  transition: color 0.15s;
}
.site-toc-list a:hover {
  color: var(--ink);
  border-bottom: none;
}
.site-toc-list a.is-active {
  color: var(--accent);
  font-weight: 500;
}

/* Typography. */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 2.25rem 0 0.75rem;
}

h1 {
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 0.5rem;
}

h2 {
  font-size: 1.45rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-soft);
  margin-top: 2.5rem;
}

h3 {
  font-size: 1.15rem;
}

h4 {
  font-size: 1rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

p {
  margin: 0.85rem 0;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s, color 0.15s;
}
a:hover {
  border-bottom-color: var(--accent);
}
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

strong {
  font-weight: 600;
  color: var(--ink-soft);
}

em {
  font-style: italic;
}

hr {
  border: none;
  border-top: 1px solid var(--border-soft);
  margin: 2.5rem 0;
}

/* Inline code. */
code, kbd, samp {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface-strong);
  color: var(--ink);
  padding: 0.1em 0.4em;
  border-radius: 3px;
}

/* Code blocks. */
pre {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  line-height: 1.55;
  margin: 1.25rem 0;
}
pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  color: inherit;
}

/* Blockquote: used for the thesis pull-quotes. */
blockquote {
  margin: 1.75rem 0;
  padding: 0.5rem 1.25rem;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--ink-soft);
  font-size: 1.02rem;
  border-radius: 0 4px 4px 0;
}
blockquote p {
  margin: 0.25rem 0;
}

/* Lists. */
ul, ol {
  padding-left: 1.5rem;
  margin: 0.75rem 0;
}
li + li {
  margin-top: 0.2rem;
}
li::marker {
  color: var(--muted-soft);
}

/* Tables. */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-variant-numeric: tabular-nums;
  font-size: 0.94rem;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  overflow: hidden;
}

thead {
  background: var(--surface);
}

th, td {
  padding: 0.55rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
}

th {
  font-weight: 600;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--surface);
}

/* Images: defaults. */
img {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
}

/* Standalone illustrations (local SVG). */
img[src*="github.io"][src$=".svg"],
img[src^="assets/"],
img[src^="/assets/"] {
  display: block;
  margin: 1.5rem auto;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 1.25rem;
  background: var(--bg-elevated);
}
[data-theme="dark"] img[src*="github.io"][src$=".svg"],
[data-theme="dark"] img[src^="assets/"],
[data-theme="dark"] img[src^="/assets/"] {
  /* Inline SVGs are authored on a light palette; tint them with a subtle
     surface tone in dark mode rather than inverting (inversion hurts the
     coloured policy lines in the sweep chart). */
  background: #f7f9fc;
}

/* Status badges (img.shields.io or GitHub actions badge). */
img[src*="shields.io"],
img[src*="badge.svg"] {
  display: inline-block;
  margin: 0 0.2rem 0.4rem 0;
  border: none;
  background: none;
  padding: 0;
  border-radius: 0;
  vertical-align: middle;
}

/* Footer. */
.site-footer {
  margin-top: 4rem;
  border-top: 1px solid var(--border-soft);
  background: var(--surface);
  padding: 1.5rem 1.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.site-footer-inner {
  max-width: var(--shell-max);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
}

.site-footer a {
  color: var(--muted);
  border-bottom: 1px solid transparent;
}
.site-footer a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.site-footer .footer-disclaimer { color: var(--muted); }

/* Responsive tightening. */
@media (max-width: 640px) {
  html {
    font-size: 15px;
  }
  .main-content {
    padding: 1.5rem 0 3rem;
  }
  .site-shell { padding: 0 1rem; }
  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.3rem; }
  table { font-size: 0.88rem; }
  th, td { padding: 0.4rem 0.6rem; }
}

/* Print: minimal black on white. */
@media print {
  body { color: #000; background: #fff; }
  .site-nav, .site-toc, .theme-toggle, .site-nav-github, .site-nav-toggle { display: none; }
  .release-banner, .whats-new { background: none; border: 1px solid #ccc; }
  a { color: #000; text-decoration: underline; }
  img { border: 1px solid #999; }
}

/* =============================================================
 * Hero block
 * ============================================================= */

.hero {
  margin: 0 0 3rem;
  padding: 2rem 0 2.5rem;
  border-bottom: 1px solid var(--border-soft);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2rem;
  align-items: center;
}

@media (min-width: 880px) {
  .hero {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  }
}

.hero-copy h1 {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
  margin: 0 0 1rem;
  color: var(--ink);
}
.hero-copy h1 .accent {
  color: var(--accent);
}

.hero-pitch {
  font-size: 1.15rem;
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 0 0 1.5rem;
  font-weight: 400;
}

.hero-quote {
  margin: 0 0 1.5rem;
  padding: 0.6rem 1rem;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  font-style: italic;
  font-size: 1rem;
  color: var(--ink-soft);
  border-radius: 0 4px 4px 0;
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.hero-cta .btn-primary,
.hero-cta .btn-ghost {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 500;
  border-radius: 5px;
  text-decoration: none;
  border-bottom: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.hero-cta .btn-primary {
  background: var(--accent);
  color: white;
  border: 1px solid var(--accent);
}
.hero-cta .btn-primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.hero-cta .btn-ghost {
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent);
}
.hero-cta .btn-ghost:hover {
  background: var(--accent-soft);
}

.hero-figure {
  margin: 0;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 1rem;
  background: var(--bg-elevated);
  box-shadow: 0 10px 30px -18px rgba(15, 95, 191, 0.35);
}
.hero-figure > svg,
.hero-figure > img[src] {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
  border: none;
  padding: 0;
  border-radius: 0;
  background: transparent;
}
.hero-figure figcaption {
  margin-top: 0.5rem;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
}

/* =============================================================
 * Stat strip
 * ============================================================= */

.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin: 0 0 3rem;
  padding: 0;
  list-style: none;
}

.stat-strip li {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  margin: 0;
}

.stat-value {
  display: block;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1.4rem;
  color: var(--accent);
  letter-spacing: -0.01em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
  letter-spacing: 0.01em;
}

/* =============================================================
 * Reveal-on-scroll
 * ============================================================= */

.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
  will-change: opacity, transform;
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* =============================================================
 * Inline SVG figure: horizon sweep with hover interactivity
 * ============================================================= */

.chart-container {
  position: relative;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 1.25rem;
  background: var(--bg-elevated);
  margin: 1.5rem 0;
  /* The inline horizon-sweep SVG is authored on a light palette; keep its
     canvas light in dark mode rather than inverting the strokes. */
}
[data-theme="dark"] .chart-container {
  background: #f7f9fc;
  color: var(--ink);
  /* Cancel the body's dark text color for the chart's text elements; the
     SVG draws on a light canvas so dark text remains legible. */
}
[data-theme="dark"] .chart-container * { color: #1f2933; }

.chart-container svg {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
  border: none;
  padding: 0;
  border-radius: 0;
  background: transparent;
}

.chart-container .figure-sweep .series-line {
  stroke-dasharray: 1800;
  stroke-dashoffset: 1800;
}

.chart-container.is-revealed .figure-sweep .series-line {
  animation: drawLine 1.6s ease-out forwards;
}

.chart-container.is-revealed .figure-sweep .latency-line {
  animation-delay: 0.25s;
  stroke-dashoffset: 1800;
}

@keyframes drawLine {
  from { stroke-dashoffset: 1800; }
  to   { stroke-dashoffset: 0; }
}

.chart-container .figure-sweep .data-slice {
  cursor: pointer;
}
.chart-container .figure-sweep .data-slice .point {
  transition: r 0.15s ease-out, stroke-width 0.15s ease-out;
}
.chart-container .figure-sweep .data-slice.is-active .success-point {
  r: 7;
  stroke-width: 2.5;
}
.chart-container .figure-sweep .data-slice.is-active .latency-point {
  r: 6;
  stroke-width: 2.5;
}

@media (prefers-reduced-motion: reduce) {
  .chart-container .figure-sweep .series-line {
    stroke-dasharray: 0;
    stroke-dashoffset: 0;
  }
  .chart-container.is-revealed .figure-sweep .series-line {
    animation: none;
  }
}

/* Sweep tooltip rendered by interactive.js. */
.sweep-tooltip {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  background: var(--ink);
  color: white;
  font-size: 0.82rem;
  font-family: var(--font-mono);
  padding: 0.55rem 0.75rem;
  border-radius: 5px;
  box-shadow: 0 6px 24px -8px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, calc(-100% - 12px));
  transition: opacity 0.12s ease-out;
  z-index: 5;
}

.sweep-tooltip.is-visible {
  opacity: 1;
}

.sweep-tooltip strong {
  display: block;
  color: white;
  margin-bottom: 0.35rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  letter-spacing: 0.01em;
}

.sweep-tooltip .row {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
}
.sweep-tooltip .row .k { color: var(--muted-soft); }
.sweep-tooltip .row .v { color: white; }
.sweep-tooltip .row .v.accent { color: var(--accent-light); }
.sweep-tooltip .row .v.warn   { color: var(--warn-light); }

/* =============================================================
 * Policy comparison cards (Three policies, side by side)
 * ============================================================= */

.policy-comparison {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
  padding: 0;
  list-style: none;
}

.policy-card {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 1.25rem 1.25rem 1rem;
  position: relative;
  overflow: hidden;
  transition: transform 0.18s ease-out, box-shadow 0.18s ease-out;
}

.policy-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--muted-soft);
}

.policy-card.policy-fail::before {
  background: var(--warn);
}

.policy-card.policy-success::before {
  background: #16a34a; /* a green that pairs with the blue accent */
}

.policy-card.policy-cpg::before {
  background: var(--accent);
}
.policy-card.policy-cpg .big-number {
  color: var(--accent);
}

.policy-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px -18px rgba(15, 95, 191, 0.25);
}

.policy-card header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  border-top: none;
  padding-top: 0;
  color: var(--ink);
}

.policy-card .policy-tagline {
  margin: 0.25rem 0 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.policy-card .big-number {
  font-family: var(--font-mono);
  font-size: 2.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--warn);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.policy-card.policy-success .big-number {
  color: #16a34a;
}

.policy-card .big-label {
  margin: 0.2rem 0 1rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.policy-card dl.card-stats {
  margin: 0;
  display: grid;
  gap: 0.5rem;
}

.policy-card dl.card-stats > div {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-soft);
}

.policy-card dl.card-stats dt {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.policy-card dl.card-stats dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* Wide figures (full-content-width images that should not get the standard
 * card border). Used for the three-up policy comparison SVG. */
.figure-wide {
  margin: 1.5rem 0;
  padding: 0;
  border: none;
  background: transparent;
}
.figure-wide > img {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: var(--bg-elevated);
  padding: 1rem;
}
[data-theme="dark"] .figure-wide > img {
  background: #f7f9fc;
}
.figure-wide figcaption {
  margin-top: 0.5rem;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
}

/* =============================================================
 * Metric links: tooltip-anchor pattern in the taxonomy summary table
 * ============================================================= */

.metric-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-variant-numeric: tabular-nums;
  font-size: 0.94rem;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  overflow: visible; /* allow popovers to escape the table bounds */
}

.metric-table thead { background: var(--surface); }
.metric-table th, .metric-table td {
  padding: 0.55rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
}
.metric-table th {
  font-weight: 600;
  color: var(--ink-soft);
  font-size: 0.92rem;
}
.metric-table tbody tr:last-child td { border-bottom: none; }

td.metric-cell {
  position: relative;
  overflow: visible;
}

a.metric-link {
  color: var(--ink);
  border-bottom: 1px dotted var(--muted-soft);
  cursor: help;
  font-weight: 500;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
a.metric-link:hover,
a.metric-link:focus-visible {
  color: var(--accent);
  border-bottom-color: var(--accent);
  border-bottom-style: solid;
}

/* Formula popover: visible only on hover/focus of its metric link. */
.formula-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 460px;
  max-width: calc(100vw - 2rem);
  z-index: 60;
  background: var(--bg-elevated);
  color: var(--ink);
  padding: 1rem 1.1rem 0.9rem;
  border: 1px solid var(--border-soft);
  border-top: 3px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 22px 44px -12px rgba(15, 95, 191, 0.25);
  font-size: 0.88rem;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease-out, transform 0.15s ease-out;
  transform: translateY(-4px);
}

.formula-popover.formula-popover-wide {
  width: 520px;
}

.metric-cell:hover .formula-popover,
.metric-cell:focus-within .formula-popover,
.formula-popover:hover {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.formula-popover .popover-reads {
  margin: 0 0 0.4rem;
  font-weight: 500;
  color: var(--ink);
}

.formula-popover .popover-note {
  margin: 0.4rem 0 0;
  font-size: 0.83rem;
  color: var(--muted);
}

.formula-popover code {
  font-size: 0.85em;
  background: var(--surface);
  padding: 0.05em 0.3em;
}

/* MathJax SVG inside the popover stays at its declared dimensions. */
.formula-popover mjx-container {
  overflow-x: auto;
  max-width: 100%;
}

/* When the popover would overflow off the right edge of a cell that is itself
 * near the right edge of the page, allow CSS containment to flip the anchor. */
.metric-table tr td.metric-cell:last-child .formula-popover {
  left: auto;
  right: 0;
}

@media (max-width: 720px) {
  .formula-popover,
  .formula-popover.formula-popover-wide {
    width: calc(100vw - 2rem);
    left: 0;
    right: auto;
  }
  td.metric-cell { white-space: normal; }
}

/* =============================================================
 * Page navigation (prev / next buttons)
 * ============================================================= */

.page-nav {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 1rem;
  margin: 3.5rem 0 0;
  padding-top: 2rem;
  border-top: 1px solid var(--border-soft);
}

.page-nav .nav-link {
  flex: 1 1 0;
  max-width: 50%;
  padding: 1rem 1.25rem;
  border-radius: 8px;
  text-decoration: none;
  border-bottom: 0;
  display: block;
  transition: background 0.15s, border-color 0.15s, transform 0.15s, color 0.15s;
}

.page-nav .nav-spacer {
  flex: 1 1 0;
  max-width: 50%;
}

.page-nav .nav-prev {
  text-align: left;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  color: var(--ink);
}
.page-nav .nav-prev:hover {
  border-color: var(--accent);
  background: var(--bg);
  transform: translateX(-2px);
}

.page-nav .nav-next {
  text-align: right;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
}
.page-nav .nav-next:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: white;
  transform: translateX(2px);
}

.page-nav .nav-direction {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.75;
  margin-bottom: 0.3rem;
  font-weight: 500;
  font-family: var(--font-sans);
}

.page-nav .nav-title {
  display: block;
  font-weight: 500;
  font-size: 1rem;
  line-height: 1.3;
}

@media (max-width: 640px) {
  .page-nav {
    flex-direction: column;
    gap: 0.6rem;
  }
  .page-nav .nav-link,
  .page-nav .nav-spacer {
    max-width: none;
  }
  .page-nav .nav-spacer {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .page-nav .nav-prev:hover,
  .page-nav .nav-next:hover {
    transform: none;
  }
}

/* =============================================================
 * Architecture: gentle fade-in once the SVG enters the viewport
 * ============================================================= */

img.figure-architecture-img {
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
  opacity: 0;
  transform: translateY(8px);
}
img.figure-architecture-img.is-visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  img.figure-architecture-img {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* =============================================================
 * Current-release banner (above the hero on the landing).
 * ============================================================= */
.release-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.55rem 0.85rem;
  margin: 1.5rem 0 1.25rem;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
  border-radius: 8px;
  font-size: 0.88rem;
  color: var(--ink-soft);
}
.release-banner .tag {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--bg-elevated);
  padding: 0.18rem 0.5rem;
  border-radius: 4px;
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
  letter-spacing: 0.02em;
}
.release-banner .release-banner-text { flex: 1; min-width: 14rem; }
.release-banner a {
  color: var(--accent);
  font-weight: 500;
  border-bottom: 1px solid transparent;
}
.release-banner a:hover { border-bottom-color: var(--accent); }

/* =============================================================
 * CPG verdict pills (used in the dedicated CPG page and the
 * landing's Acrobot scorecard summary).
 * ============================================================= */
.verdict-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.verdict-pill::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.verdict-pill.verdict-model-bottleneck {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border-color: color-mix(in srgb, var(--danger) 25%, transparent);
}
.verdict-pill.verdict-learned-outperforms {
  color: var(--ok);
  background: color-mix(in srgb, var(--ok) 12%, transparent);
  border-color: color-mix(in srgb, var(--ok) 25%, transparent);
}
.verdict-pill.verdict-planner-bottleneck {
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 14%, transparent);
  border-color: color-mix(in srgb, var(--warn) 28%, transparent);
}
.verdict-pill.verdict-as-good-as {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 22%, transparent);
}
.verdict-pill.verdict-inconclusive {
  color: var(--muted);
  background: var(--surface-strong);
  border-color: var(--border);
}

.verdict-legend {
  margin: 1.25rem 0 2rem;
}
.verdict-legend p {
  margin: 0.5rem 0;
  font-size: 0.92rem;
  color: var(--ink-soft);
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.verdict-legend p .verdict-pill {
  flex-shrink: 0;
}

/* =============================================================
 * Paper page (docs/paper.md): hero header + tables + PDF actions.
 * ============================================================= */
.paper-header {
  padding: 2.5rem 0 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}
.paper-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.5rem;
}
.paper-title {
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0 0 0.4rem;
  line-height: 1.15;
}
.paper-subtitle {
  font-size: 1.1rem;
  color: var(--ink-soft);
  margin: 0 0 0.9rem;
  line-height: 1.45;
  font-style: italic;
  max-width: 48rem;
}
.paper-author {
  font-size: 0.95rem;
  color: var(--muted);
  margin: 0 0 1.2rem;
}
.paper-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 0 0 0.8rem;
}
.paper-actions .btn-primary,
.paper-actions .btn-ghost {
  font-size: 0.92rem;
}
.paper-pdf-note {
  font-size: 0.82rem;
  color: var(--muted-soft);
  margin: 0;
  max-width: 48rem;
}
.paper-pdf-note code {
  font-size: 0.78rem;
}

/* Paper-page tables: keep them readable, hairline-style.
   The paper.md page uses raw <table class="paper-table"> rather
   than markdown tables so verdict pills can sit cleanly inside
   cells; this is the styling for those. */
.paper-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-elevated);
}
.paper-table thead { background: var(--surface); }
.paper-table th,
.paper-table td {
  padding: 0.55rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
}
.paper-table th {
  font-weight: 600;
  color: var(--ink-soft);
  font-size: 0.9rem;
}
.paper-table tbody tr:last-child td { border-bottom: none; }
.paper-table tbody tr:hover { background: var(--surface); }
.paper-table.paper-table-narrow { max-width: 32rem; }

@media (max-width: 640px) {
  .paper-title { font-size: 1.6rem; }
  .paper-subtitle { font-size: 1rem; }
  .paper-table { font-size: 0.86rem; }
  .paper-table th,
  .paper-table td { padding: 0.45rem 0.6rem; }
}

/* =============================================================
 * Reading paths grid (replaces the flat "Read more" list).
 * ============================================================= */
.reading-paths {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: 1fr;
  margin: 1.5rem 0 2rem;
}
@media (min-width: 760px) {
  .reading-paths { grid-template-columns: repeat(3, 1fr); }
}
.path-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: 12px;
  padding: 1.25rem 1.25rem 1.1rem;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.path-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  box-shadow: var(--shadow-md);
}
.path-card .path-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-soft);
  margin: 0 0 0.4rem;
}
.path-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
}
.path-card p.path-lead {
  margin: 0 0 0.9rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
}
.path-card ul.path-links {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.9rem;
}
.path-card ul.path-links li { margin: 0.15rem 0; }
.path-card ul.path-links li::marker { content: none; }
.path-card ul.path-links a {
  color: var(--accent);
  border-bottom: 1px solid transparent;
}
.path-card ul.path-links a:hover {
  border-bottom-color: var(--accent);
}
.path-card ul.path-links a::before {
  content: "\2192";
  margin-right: 0.4rem;
  color: var(--muted-soft);
  font-family: var(--font-mono);
}

/* =============================================================
 * Release timeline (replaces the flat bulleted releases list).
 * ============================================================= */
.release-timeline {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: 1fr;
  margin: 1.5rem 0 2rem;
}
@media (min-width: 760px) {
  .release-timeline { grid-template-columns: repeat(2, 1fr); }
}
.release-card {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s;
}
.release-card:hover {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.release-card.release-current {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  background: linear-gradient(180deg, var(--accent-soft), var(--bg-elevated) 80%);
}
.release-card .release-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}
.release-card .release-version {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--accent);
  border-bottom: none;
}
.release-card .release-version:hover {
  text-decoration: underline;
}
.release-card .release-meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted-soft);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.release-card .release-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.4;
}
.release-card .release-body {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.55;
}

/* =============================================================
 * "What's new" panel (compact summary of the current release).
 * ============================================================= */
.whats-new {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem 1.25rem;
  background: var(--surface);
  margin: 1.5rem 0 2rem;
}
.whats-new h3 {
  margin: 0 0 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}
.whats-new ul {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
  font-size: 0.92rem;
  color: var(--ink-soft);
}
.whats-new ul li { margin: 0.2rem 0; }

/* =============================================================
 * Stat-strip refinement (dark-mode aware).
 * Existing rules already use var(--surface) etc., so dark mode is
 * mostly automatic. Add subtle border so the strip stays visible
 * against the page background in both themes.
 * ============================================================= */
.stat-strip {
  border-color: var(--border);
}

/* Selection colour. */
::selection {
  background: color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--ink);
}

/* =============================================================
 * Chapter pattern: visual structure for landing & long pages.
 * Each chapter is a <section class="chapter"> with an eyebrow
 * ("Step 01"), a numbered title, and a subtle rule above it.
 * ============================================================= */
.chapter {
  padding: 3.5rem 0 0.5rem;
  margin-top: 1.5rem;
  position: relative;
  scroll-margin-top: calc(var(--nav-height) + 1rem);
}
.chapter + .chapter { margin-top: 0; }
.chapter::before {
  content: "";
  display: block;
  width: 4rem;
  height: 2px;
  background: var(--accent);
  margin-bottom: 1.5rem;
  border-radius: 2px;
  opacity: 0.55;
}
.chapter-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.4rem;
}
.chapter > h2.chapter-title,
.chapter-title {
  margin: 0 0 0.75rem;
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.chapter-lead {
  margin: 0 0 1.5rem;
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 42rem;
}
.chapter-sub {
  margin: 2.5rem 0 0.75rem;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--ink);
}

/* When the chapter sits inside .main-content, give it the same
   max-width as paragraphs but let figures and policy grids span
   wider. */
.chapter > p,
.chapter > .chapter-lead,
.chapter > ul,
.chapter > ol,
.chapter > pre,
.chapter > blockquote {
  max-width: 48rem;
}
.chapter > .policy-comparison,
.chapter > .figure-wide,
.chapter > .chart-container,
.chapter > .reading-paths,
.chapter > .release-timeline,
.chapter > section,
.chapter > figure,
.chapter > table {
  max-width: none;
}

@media (max-width: 640px) {
  .chapter { padding-top: 2.5rem; }
  .chapter > h2.chapter-title,
  .chapter-title { font-size: 1.4rem; }
  .chapter-lead { font-size: 0.98rem; }
}


