/* ==========================================================================
   TerraZero project site — Applied Intuition brand design system
   Type: Applied Sans (Display for title/headings, Text for body/labels),
   XCharter serif available for figure/quote surfaces. Color: Applied Blue
   #006CFA, ink #111, gray #767676. Motifs: black-square eyebrow marker,
   ~680px reading column, full-width figure bands, blue caption labels.
   ========================================================================== */

/* ----- Fonts (vendored, local) ------------------------------------------ */
@font-face {
  font-family: "Applied Sans Display";
  src: url("../fonts/AppliedSansDisplay-Bold.ttf") format("truetype");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Applied Sans Display";
  src: url("../fonts/AppliedSansDisplay-SemiBold.ttf") format("truetype");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Applied Sans Text";
  src: url("../fonts/AppliedSansText-Regular.ttf") format("truetype");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Applied Sans Text";
  src: url("../fonts/AppliedSansText-Italic.ttf") format("truetype");
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "Applied Sans Text";
  src: url("../fonts/AppliedSansText-SemiBold.ttf") format("truetype");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Applied Sans Text";
  src: url("../fonts/AppliedSansText-SemiBoldItalic.ttf") format("truetype");
  font-weight: 600; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "XCharter";
  src: url("../fonts/XCharter-Roman.otf") format("opentype");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "XCharter";
  src: url("../fonts/XCharter-Italic.otf") format("opentype");
  font-weight: 400; font-style: italic; font-display: swap;
}

/* ----- Design tokens ----------------------------------------------------- */
:root {
  /* brand color */
  --blue: #006CFA;
  --blue-dark: #0052bd;        /* AppliedBlue!70!black, approx */
  --blue-muted: #3d7fc4;       /* AppliedBlue!75!gray, approx */
  --blue-wash: #eef4ff;        /* light blue surface */
  --blue-wash-2: #e0ecff;
  --ink: #111111;
  --gray: #767676;
  --gray-line: #e4e4e4;
  --gray-soft: #f6f7f9;
  --white: #ffffff;

  /* terrabin figure palette (mirrors figure-scripts/data.py) */
  --terra-center: #006CFA;     /* lane centerlines */
  --terra-marking: #d9a300;    /* gold lane markings */
  --terra-sidewalk: #4a9d5b;   /* green sidewalks */
  --terra-crosswalk: #f2c200;  /* yellow crosswalks */

  /* type */
  --font-display: "Applied Sans Display", "Helvetica Neue", Arial, sans-serif;
  --font-sans: "Applied Sans Text", "Helvetica Neue", Arial, sans-serif;
  --font-serif: "XCharter", Georgia, "Times New Roman", serif;
  --font-mono: "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;

  /* type scale */
  --fs-eyebrow: 0.72rem;
  --fs-meta: 0.82rem;
  --fs-body: 1.0625rem;        /* ~17px reading */
  --fs-lead: 1.3rem;
  --fs-h3: 1.18rem;
  --fs-h2: 2.2rem;
  --fs-title: clamp(2.05rem, 5vw, 3.6rem);

  /* spacing */
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2.5rem;
  --space-5: 4rem;
  --space-6: 6rem;

  /* layout */
  --reading: 720px;
  --wide: 1280px;
  --header-h: 60px;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(17,17,17,.04), 0 8px 28px rgba(17,17,17,.07);
  --shadow-lift: 0 2px 6px rgba(17,17,17,.06), 0 18px 48px rgba(0,108,250,.10);
}

/* ----- Reset / base ------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
body {
  margin: 0;
  font-family: var(--font-serif);
  font-size: var(--fs-body);
  line-height: 1.62;
  color: var(--ink);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img, svg { max-width: 100%; height: auto; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
strong { font-weight: 600; }

/* ----- Layout primitives ------------------------------------------------- */
.reading { max-width: var(--reading); margin-inline: auto; padding-inline: 24px; }
.wide { max-width: var(--wide); margin-inline: auto; padding-inline: 24px; }
/* full-bleed band for large diagrams that earn the extra width */
.bleed { width: min(1680px, 96vw); margin-inline: auto; padding-inline: 24px; }

/* Figure-and-text two-column layout (magazine rhythm). The figure column is the
   wider one so diagrams stay legible; .split--rev flips text and figure sides. */
.split {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
  gap: clamp(1.5rem, 4vw, var(--space-5));
  align-items: center;
}
.split--rev { grid-template-columns: minmax(0, 1.18fr) minmax(0, 0.82fr); }
/* extra separation between a wide table and its adjacent title/text */
.split--airy { gap: clamp(2.5rem, 7vw, 6rem); }
.split--rev .split-text { order: 2; }
.split-text > :first-child { margin-top: 0; }
.split .figure, .split .table-wrap { margin: 0; }

/* left-aligned readable text column inside a .wide band, so section headers and
   prose share the same left edge as wide figures/tables (no centered indent) */
.prose { max-width: 72ch; }

/* multi-column text grids for parallel subsections */
.col-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(1.5rem, 3vw, var(--space-4));
}
.col-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1.5rem, 3vw, var(--space-4)) clamp(2rem, 5vw, var(--space-6));
  align-items: start;
}
.col-3 > div > :first-child, .col-3 h3:first-child,
.col-2 > div > :first-child, .col-2 h3:first-child { margin-top: 0; }

/* big stat callouts (the "fast" claim) */
.statline {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
  margin: var(--space-3) 0;
}
.statline .stat-num {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(2rem, 4vw, 3rem); line-height: 1; color: var(--blue);
  letter-spacing: -0.02em;
}
.statline .stat-cap {
  font-family: var(--font-sans); font-size: var(--fs-meta);
  color: var(--gray); margin-top: 0.35em;
}
.statline > div { border-top: 2px solid var(--ink); padding-top: 0.6rem; }

@media (max-width: 860px) {
  .split, .split--rev { grid-template-columns: 1fr; gap: var(--space-3); }
  .split--airy { gap: var(--space-4); }
  .split--rev .split-text { order: 0; }
  .col-3, .col-2 { grid-template-columns: 1fr; gap: var(--space-3); }
  .statline { grid-template-columns: 1fr 1fr; }
}
/* On very small screens a long inline formula cannot line-break and would
   overflow; cap it to the line width and let it scroll within itself instead. */
@media (max-width: 480px) {
  .katex { display: inline-block; max-width: 100%; overflow-x: auto; overflow-y: hidden; vertical-align: middle; }
}

section { padding-block: var(--space-6); }
section + section { border-top: 1px solid var(--gray-line); }
/* Content sections alternate tint automatically by position; the hero stays
   plain, so add/remove a section and the rhythm fixes itself. */
main > section:not(.hero):nth-of-type(odd) { background: var(--gray-soft); }

/* eyebrow + black square motif */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.86rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gray);
  display: flex;
  align-items: center;
  gap: 0.6em;
  margin: 0 0 var(--space-2);
}
.eyebrow::before {
  content: "";
  display: inline-block;
  width: 0.5em; height: 0.5em;
  background: var(--ink);
  flex: 0 0 auto;
}

/* ----- Typography -------------------------------------------------------- */
h1, h2, h3 { font-family: var(--font-display); color: var(--ink); line-height: 1.12; }
h2 {
  font-weight: 600;
  font-size: var(--fs-h2);
  letter-spacing: -0.01em;
  margin: 0 0 var(--space-3);
}
h3 {
  font-weight: 600;
  font-size: var(--fs-h3);
  letter-spacing: -0.005em;
  margin: var(--space-4) 0 var(--space-1);
}
p { margin: 0 0 var(--space-2); }
.lead {
  font-size: var(--fs-lead);
  line-height: 1.5;
  color: #2a2a2a;
}
.muted { color: var(--gray); }

/* editorial highlight: a soft marker swipe sitting under the lower half of the
   text, in the manner of a highlighter pen. used sparingly on the load-bearing
   claims so the core message reads at a glance. */
mark.hl {
  background: linear-gradient(transparent 56%, var(--blue-wash-2) 56%);
  color: inherit;
  padding: 0 0.05em;
}
.lead mark.hl { background: linear-gradient(transparent 60%, var(--blue-wash-2) 60%); }

/* math spans should sit inline cleanly */
.katex { font-size: 1.02em; }
/* overflow-x:auto scrolls only when an equation is genuinely too wide for the
   column; overflow-y:hidden stops KaTeX's few-pixel strut overhang from forcing
   a spurious per-equation vertical scrollbar (auto would otherwise be promoted). */
.eq-block { margin: var(--space-3) 0; overflow-x: auto; overflow-y: hidden; }
.eq-block .katex-display { margin: 0; }

/* ----- Header / nav ------------------------------------------------------ */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: rgba(255,255,255,.88);
  backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--gray-line);
}
.site-header .wide {
  height: 100%;
  display: flex; align-items: center; gap: var(--space-3);
}
.brand-mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  display: flex; align-items: center; gap: 0.55em;
  flex: 0 0 auto;
}
.brand-mark::before {
  content: ""; width: 1.15em; height: 1.15em; display: inline-block;
  background: var(--ink);
  -webkit-mask: url(../brand/icon.svg) center / contain no-repeat;
  mask: url(../brand/icon.svg) center / contain no-repeat;
}
.brand-mark:hover { text-decoration: none; }
.site-footer .brand-mark::before { background: #fff; }
.nav { margin-left: auto; display: flex; gap: var(--space-3); align-items: center; }
.nav a {
  font-family: var(--font-sans);
  font-size: var(--fs-meta);
  color: var(--gray);
  letter-spacing: 0.01em;
}
.nav a:hover { color: var(--ink); text-decoration: none; }
.nav a.active { color: var(--ink); font-weight: 600; }
.nav-toggle { display: none; }

/* ----- Hero -------------------------------------------------------------- */
.hero { padding-top: var(--space-5); padding-bottom: var(--space-4); }

.hero-intro { max-width: 60rem; }
.hero h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-title);
  letter-spacing: -0.02em;
  line-height: 1.04;
  color: var(--ink);
  margin: 0 0 var(--space-3);
  overflow-wrap: break-word;
  hyphens: auto;
}
.byline, .affil { overflow-wrap: break-word; }
.hero h1 .accent { color: var(--blue); }

/* the lead reads as a standfirst: larger serif on a tight measure, sitting
   close under the headline */
.hero .lead {
  max-width: 56ch;
  font-size: clamp(1.25rem, 2.2vw, 1.5rem);
  line-height: 1.45;
  color: #2a2a2a;
  margin-bottom: var(--space-4);
}

/* masthead metadata, set off from the lead by a thin editorial rule */
.hero-meta {
  border-top: 1px solid var(--gray-line);
  padding-top: var(--space-3);
}
.hero-meta > :first-child { margin-top: 0; }
.byline {
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  color: var(--gray);
  margin: var(--space-3) 0 var(--space-1);
  line-height: 1.7;
}
.byline .names { color: var(--ink); }
.affil { font-family: var(--font-mono); font-size: var(--fs-eyebrow); color: var(--gray); }

/* action buttons */
.actions { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: var(--space-3); }
.btn {
  font-family: var(--font-sans);
  font-size: var(--fs-meta);
  font-weight: 600;
  display: inline-flex; align-items: center; gap: 0.45em;
  padding: 0.6em 1.05em;
  border-radius: 8px;
  border: 1px solid var(--gray-line);
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .05s;
}
.btn:hover { border-color: var(--blue); color: var(--blue); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: var(--white); }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); color: var(--white); }
.btn svg { width: 1em; height: 1em; }

/* greyed-out actions for resources not available yet */
.btn-disabled {
  color: var(--gray); background: var(--gray-soft);
  border-color: var(--gray-line); cursor: not-allowed; opacity: 0.75;
  user-select: none;
}
.btn-disabled:hover { color: var(--gray); border-color: var(--gray-line); }
.foot-pending { color: var(--gray); cursor: not-allowed; }

/* ----- Figure bands / captions ------------------------------------------ */
.figure-band { padding-block: var(--space-5); }
.figure {
  margin: var(--space-3) 0;
  background: var(--white);
  border: 1px solid var(--gray-line);
  border-radius: var(--radius);
  overflow: hidden;
}
.figure-stage {
  padding: var(--space-3);
  display: flex; justify-content: center; align-items: center;
  background:
    linear-gradient(var(--gray-soft), var(--gray-soft));
}
.figure-stage svg, .figure-stage img { display: block; max-width: 100%; }
figcaption {
  font-family: var(--font-sans);
  font-size: var(--fs-meta);
  color: #333;
  line-height: 1.5;
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--gray-line);
}
figcaption .fig-label {
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--blue);
  margin-right: 0.5em;
}

/* ----- Cards ------------------------------------------------------------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-2);
  margin: var(--space-3) 0;
}
.card-grid.grid-2 { grid-template-columns: 1fr 1fr; }
.card {
  border: 1px solid var(--gray-line);
  border-radius: var(--radius);
  padding: var(--space-3);
  background: var(--white);
}
.card h3 { margin-top: 0; }
.card .stat {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2rem;
  color: var(--blue);
  line-height: 1;
}
.card .stat-label { font-family: var(--font-sans); font-size: var(--fs-meta); color: var(--gray); }

/* contribution triad: three columns on wide screens, each with a numbered
   top rule, magazine-feature style */
.contribs {
  display: grid; gap: var(--space-3); margin: var(--space-4) 0 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.contrib { border-top: 2px solid var(--blue); padding-top: var(--space-2); }
.contrib .num {
  font-family: var(--font-display); font-weight: 700; color: var(--blue);
  font-size: 1.6rem; line-height: 1; margin-bottom: 0.4rem;
}
.contrib h3 { margin-top: 0; }
@media (max-width: 860px) {
  .contribs { grid-template-columns: 1fr; gap: var(--space-3); }
}

/* placeholder / pending cards */
.placeholder {
  border: 1px dashed var(--gray-line);
  border-radius: var(--radius);
  padding: var(--space-4);
  text-align: center;
  color: var(--gray);
  font-family: var(--font-sans);
  background:
    repeating-linear-gradient(45deg, transparent, transparent 10px,
      rgba(0,108,250,.025) 10px, rgba(0,108,250,.025) 20px);
}
.placeholder .ph-icon { font-size: 1.6rem; color: var(--blue-muted); }
.placeholder .ph-title { color: var(--ink); font-weight: 600; margin: 0.4em 0 0.2em; }

/* Abstract beside the demo showcase. Three responsive configurations:
     • Widest  (≥1160px) — abstract | controls | video   (three columns)
     • Middle  (860–1159) — abstract | [controls / video] (controls stack over video)
     • Narrow  (≤859px)  — abstract / controls / video    (all stacked)
   This section runs wider with a slimmer page margin so the video reads large. */
#abstract .bleed { width: min(1880px, 98vw); padding-inline: 14px; }
.abstract-demos {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2.7fr);
  gap: clamp(1.5rem, 3vw, var(--space-5));
  align-items: start;
}
.abstract-col { border-right: 1px solid var(--gray-line); padding-right: clamp(1.5rem, 4vw, var(--space-5)); }
.abstract-col h2 { margin-top: 0; }
.abstract-col p:last-child { margin-bottom: 0; }

/* ----- Scenario video gallery ------------------------------------------- */
.gallery {
  display: grid;
  grid-template-columns: minmax(220px, 290px) minmax(0, 1fr);
  gap: clamp(1.25rem, 2vw, var(--space-3));
  align-items: start;
}
.gallery[hidden] { display: none; }

/* left rail: one labeled group per dimension. The groups spread to fill the
   full column height so the selector aligns top-and-bottom with the video. */
.gallery-rail { display: flex; flex-direction: column; gap: var(--space-3); justify-content: space-between; }
.opt-group { display: flex; flex-direction: column; gap: 0.5em; }
.opt-label {
  font-family: var(--font-sans); font-size: var(--fs-eyebrow); font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase; color: var(--gray);
}
.opt-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.opt-pill {
  border: 1px solid var(--gray-line); background: var(--gray-soft); cursor: pointer;
  font-family: var(--font-sans); font-size: var(--fs-meta); font-weight: 600;
  color: var(--ink); padding: 0.4em 0.85em; border-radius: 999px;
  transition: background .18s, color .18s, border-color .18s, opacity .18s;
}
.opt-pill:hover:not(.is-active):not(:disabled) { border-color: var(--blue-muted); color: var(--blue); }
.opt-pill.is-active {
  background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: var(--shadow);
}
.opt-pill:disabled { opacity: .38; cursor: not-allowed; }
/* ordinal group reads as a compact numeric set */
.opt-group[data-key="ordinal"] .opt-pill { min-width: 2.4em; text-align: center; }

/* right stage: the video and its caption stacked together. */
.gallery-stage { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.gallery-frame {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  border: 1px solid var(--gray-line); border-radius: var(--radius); overflow: hidden;
  background: radial-gradient(120% 120% at 50% 0%, rgba(0,108,250,.06), transparent 60%), #0d1117;
  box-shadow: var(--shadow);
}
/* contain (not cover) so the full 16:9 frame is always shown, never cropped */
.gallery-video { display: block; width: 100%; height: 100%; object-fit: contain; background: #0d1117; }
.gallery-caption {
  margin: 0; display: flex; flex-wrap: wrap; gap: 0.4em 0.9em;
  font-family: var(--font-sans); font-size: var(--fs-meta);
}
.cap-seg { display: inline-flex; align-items: baseline; gap: 0.4em; }
.cap-seg + .cap-seg { border-left: 1px solid var(--gray-line); padding-left: 0.9em; }
.cap-dim {
  font-size: var(--fs-eyebrow); font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--gray);
}
.cap-val { color: var(--ink); font-weight: 600; }

/* in-prep note under the demo */
.demo-footnote {
  margin: var(--space-3) 0 0; max-width: 72ch;
  font-family: var(--font-sans); font-size: var(--fs-meta); color: var(--gray);
}

/* ---- Configuration 2 + 3: controls stack ABOVE the video --------------- *
 * Below 1160px the rail no longer sits to the left of the video. It becomes a
 * full-width control band above the frame: the labelled groups flow left to
 * right and wrap, pairing up where they fit. A single hairline rule closes the
 * band off from the video so the controls read as a deliberate toolbar. */
@media (max-width: 1159px) {
  .gallery { grid-template-columns: 1fr; gap: var(--space-3); }
  .gallery-rail {
    flex-direction: row; flex-wrap: wrap; align-items: flex-start;
    gap: var(--space-3) var(--space-5); justify-content: flex-start;
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--gray-line);
  }
  .gallery-rail .opt-group { flex: 0 1 auto; }
  .gallery-frame { flex: none; min-height: 0; }
}

/* Configuration 2 (middle): abstract keeps its own column beside the stacked
   controls + video. The split tilts toward the demo so the video stays large. */
@media (min-width: 860px) and (max-width: 1159px) {
  .abstract-demos { grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.55fr); }
}

/* Configuration 3 (narrow): abstract, controls, and video stack in that order. */
@media (max-width: 859px) {
  #abstract .bleed { padding-inline: 24px; }
  .abstract-demos { grid-template-columns: 1fr; gap: var(--space-4); }
  .abstract-col {
    border-right: none; padding-right: 0;
    border-bottom: 1px solid var(--gray-line); padding-bottom: var(--space-4);
  }
}

/* ----- Integrations showcase -------------------------------------------- */
/* A single horizontal strip of tabs (the active one boxed) selects which
   integration shows in the stage below: a looping video beside its text. */
.intg { margin-top: var(--space-3); }
/* One big pill holding all options; a blue thumb (.intg-slider) slides behind
   the active option. The thumb's size/position is set in JS from the active
   button's geometry so it works for any label widths and wraps gracefully. */
.intg-tabs {
  position: relative; display: inline-flex; flex-wrap: wrap; gap: 4px;
  margin-bottom: var(--space-3); padding: 5px;
  background: var(--gray-soft); border: 1px solid var(--gray-line); border-radius: 999px;
}
.intg-slider {
  position: absolute; top: 0; left: 0; z-index: 0;
  border-radius: 999px; background: var(--blue); box-shadow: var(--shadow);
  transition: transform .28s cubic-bezier(.4, 0, .2, 1), width .28s cubic-bezier(.4, 0, .2, 1), height .28s;
}
.intg-tab {
  position: relative; z-index: 1; border: 0; background: transparent; cursor: pointer;
  font-family: var(--font-sans); font-size: var(--fs-meta); font-weight: 600;
  color: var(--ink); padding: 0.5em 1.1em; border-radius: 999px;
  transition: color .2s;
}
.intg-tab:hover:not(.is-active) { color: var(--blue); }
.intg-tab.is-active { color: #fff; }

.intg-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(0, 0.82fr);
  gap: clamp(1.5rem, 4vw, var(--space-5));
  align-items: center;
}
.intg-panel[hidden] { display: none; }
.intg-text > :first-child { margin-top: 0; }
.intg-media {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  border: 1px solid var(--gray-line); border-radius: var(--radius); overflow: hidden;
  background: radial-gradient(120% 120% at 50% 0%, rgba(0,108,250,.06), transparent 60%), #0d1117;
  box-shadow: var(--shadow);
}
.intg-video { display: block; width: 100%; height: 100%; object-fit: contain; background: #0d1117; }

@media (max-width: 860px) {
  .intg-panel { grid-template-columns: 1fr; gap: var(--space-3); }
}

.demos-col { display: flex; flex-direction: column; }
.demo-stage { flex: 1; display: flex; }
.demo-panel {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; flex: 1; min-height: clamp(420px, 58vh, 720px); padding: var(--space-4);
  border: 1px solid var(--gray-line); border-radius: var(--radius);
  background:
    radial-gradient(120% 120% at 50% 0%, rgba(0,108,250,.06), transparent 60%),
    var(--white);
  box-shadow: var(--shadow);
}
.demo-panel[hidden] { display: none; }
.demo-panel .ph-icon { font-size: 2.6rem; color: var(--blue); line-height: 1; }
.demo-panel .ph-title { font-family: var(--font-display); font-weight: 700; font-size: 1.3rem; color: var(--ink); margin: 0.5em 0 0.2em; }
.demo-panel .ph-sub { font-family: var(--font-sans); font-size: var(--fs-meta); color: var(--gray); max-width: 40ch; }
.demo-panel .ph-tag {
  font-family: var(--font-sans); font-size: var(--fs-eyebrow); letter-spacing: .08em;
  text-transform: uppercase; color: var(--blue); margin-top: var(--space-2);
  border: 1px solid var(--blue-muted); border-radius: 999px; padding: 0.3em 0.8em;
}

/* ----- Tables ------------------------------------------------------------ */
.table-wrap { overflow-x: auto; margin: var(--space-3) 0; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-sans);
  font-size: var(--fs-meta);
}
table.data caption {
  caption-side: bottom;
  text-align: left;
  color: #333;
  font-size: var(--fs-meta);
  line-height: 1.5;
  padding-top: var(--space-2);
}
table.data caption .fig-label { color: var(--blue); font-weight: 600; margin-right: 0.4em; }
table.data th, table.data td {
  padding: 0.55em 0.85em;
  text-align: right;
  border-bottom: 1px solid var(--gray-line);
  white-space: nowrap;
}
table.data th:first-child, table.data td:first-child { text-align: left; }
/* textual tables (descriptions, not numbers) read better left-aligned */
table.data.data--text th, table.data.data--text td { text-align: left; white-space: normal; }
table.data thead th {
  color: var(--ink);
  font-weight: 600;
  border-bottom: 2px solid var(--ink);
  user-select: none;
}
table.data thead th.sortable { cursor: pointer; }
table.data thead th.sortable:hover { color: var(--blue); }
table.data thead th .sort-ind { color: var(--blue); font-size: 0.85em; margin-left: 0.3em; }
table.data tbody tr:hover { background: var(--blue-wash); }
table.data tbody tr.is-best td { font-weight: 600; }
table.data .group-row th {
  text-align: left;
  background: var(--gray-soft);
  font-family: var(--font-mono);
  font-size: var(--fs-eyebrow);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gray);
}

/* a touch more breathing room beneath the dynamics-models table (Table 1) */
#tbl-dynamics { margin-bottom: var(--space-4); }

/* blank "to be filled" token */
.tbd {
  color: var(--blue-muted);
  font-style: italic;
  font-family: var(--font-sans);
  opacity: 0.75;
}
.tbd::after { content: "to be filled"; }
td .tbd { font-size: 0.92em; }

/* ----- Footer ------------------------------------------------------------ */
.site-footer {
  border-top: 1px solid var(--gray-line);
  background: var(--ink);
  color: #cfd3da;
  padding-block: var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--fs-meta);
}
.site-footer a { color: #fff; }
.site-footer .foot-grid { display: flex; flex-wrap: wrap; gap: var(--space-4); justify-content: space-between; }
.site-footer .copyright { color: var(--gray); margin-top: var(--space-3); font-family: var(--font-mono); font-size: var(--fs-eyebrow); }

/* ----- BibTeX block ------------------------------------------------------ */
.bibtex {
  position: relative;
  background: #0f1115; color: #e7e9ee;
  border-radius: var(--radius);
  padding: var(--space-3);
  font-family: var(--font-mono); font-size: 0.8rem; line-height: 1.55;
  overflow-x: auto;
}
.bibtex .copy-btn {
  position: absolute; top: 10px; right: 10px;
  font-family: var(--font-sans); font-size: 0.72rem; font-weight: 600;
  background: rgba(255,255,255,.08); color: #fff;
  border: 1px solid rgba(255,255,255,.18); border-radius: 6px;
  padding: 0.35em 0.7em; cursor: pointer;
}
.bibtex .copy-btn:hover { background: var(--blue); border-color: var(--blue); }

/* ----- Charts ------------------------------------------------------------ */
.chart-wrap { position: relative; width: 100%; }
.chart-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2) var(--space-3); margin-top: var(--space-2); font-family: var(--font-sans); font-size: var(--fs-meta); }
.chart-legend .key { display: inline-flex; align-items: center; gap: 0.4em; cursor: pointer; color: var(--gray); }
.chart-legend .key.on { color: var(--ink); }
.chart-legend .swatch { width: 0.85em; height: 0.85em; border-radius: 2px; display: inline-block; }
.chart-note {
  margin: var(--space-1) 0 0; text-align: center;
  font-family: var(--font-sans); font-size: var(--fs-eyebrow); color: var(--gray);
}
.chart-tooltip {
  position: absolute; pointer-events: none; opacity: 0;
  background: var(--ink); color: #fff;
  font-family: var(--font-sans); font-size: 0.78rem;
  padding: 0.45em 0.6em; border-radius: 6px; transform: translate(-50%, -120%);
  white-space: nowrap; transition: opacity .1s; z-index: 5;
}

/* ----- NPC gallery ------------------------------------------------------- */
.npc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-2); }
.npc-cell { border: 1px solid var(--gray-line); border-radius: var(--radius); overflow: hidden; background: var(--white); }
.npc-cell .npc-img { background: var(--gray-soft); padding: var(--space-2); display: flex; justify-content: center; }
.npc-cell .npc-cap { padding: 0.6em 0.85em; font-family: var(--font-sans); font-size: var(--fs-eyebrow); }
.npc-cell .npc-cap b { display: block; font-weight: 600; color: var(--ink); margin-bottom: 0.15em; }
.npc-cell .npc-cap span { color: var(--gray); }

/* ----- Scroll reveal (progressive enhancement: hidden only when JS is on) - */
.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity .5s ease, transform .5s ease; }
.js .reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .js .reveal { opacity: 1; transform: none; transition: none; }
}

/* ----- Responsive -------------------------------------------------------- */
@media (max-width: 820px) {
  :root { --header-h: 56px; }
  .nav {
    position: fixed; inset: var(--header-h) 0 auto 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--white); border-bottom: 1px solid var(--gray-line);
    padding: var(--space-2) 24px var(--space-3);
    transform: translateY(-130%); transition: transform .2s ease;
    box-shadow: var(--shadow);
  }
  .nav.open { transform: none; }
  .nav a { padding: 0.7em 0; border-bottom: 1px solid var(--gray-line); }
  .nav-toggle {
    display: inline-flex; margin-left: auto; flex-direction: column; gap: 4px;
    background: none; border: none; cursor: pointer; padding: 6px;
  }
  .nav-toggle span { width: 22px; height: 2px; background: var(--ink); display: block; }
  section { padding-block: var(--space-5); }
  .hero { padding-top: var(--space-4); }
  .card-grid.grid-2 { grid-template-columns: 1fr; }
}

/* ----- Terra Series: status badge ---------------------------------------- */
.series-status {
  display: inline-block;
  font-family: var(--font-sans); font-size: var(--fs-eyebrow); font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  padding: 0.25em 0.7em;
  border-radius: 999px;
  background: var(--blue); color: var(--white);
  margin-bottom: var(--space-1);
}
.series-status--prep {
  background: var(--gray-soft); color: var(--gray);
  border: 1px solid var(--gray-line);
}
.series-status--venue {
  background: #e8f0ff; color: #1a4ac4;
}

/* Inline venue badge after a tab title (conference publications only) */
.series-badge {
  display: inline-block; vertical-align: middle; margin-left: 0.5em;
  font-family: var(--font-sans); font-size: var(--fs-eyebrow); font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  padding: 0.2em 0.6em; border-radius: 999px;
  background: #e8f0ff; color: #1a4ac4;
}
/* Resource buttons under a tab's description */
.series-links { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: var(--space-2); }
.series-note {
  font-family: var(--font-sans); font-size: var(--fs-meta); font-weight: 600;
  color: var(--gray); margin-top: var(--space-2);
}

/* Full-width tab panel: text on top, then the media showcase below */
.intg-panel--wide { grid-template-columns: 1fr; align-items: start; }
.intg-showcase { display: flex; flex-direction: column; gap: var(--space-3); margin-top: var(--space-3); }
.intg-showcase .figure img { display: block; width: 100%; border-radius: var(--radius); }
/* a single video reads better contained than stretched the full panel width */
.intg-showcase .intg-media { width: 100%; max-width: 960px; margin-inline: auto; }
.threeup { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); }
.threeup-cell { min-width: 0; }
.threeup-vid {
  position: relative; border: 1px solid var(--gray-line); border-radius: var(--radius);
  overflow: hidden; background: #0d1117;
}
.threeup-vid video { display: block; width: 100%; height: auto; }
.threeup-cap { text-align: center; font-weight: 600; font-size: var(--fs-meta); margin: 0.4rem 0 0; }
.threeup-legend {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  background: rgba(255,255,255,.92); border: 1px solid var(--gray-line);
  border-radius: 6px; padding: 6px 9px; font-size: 12px;
  display: flex; flex-direction: column; gap: 5px;
}
.threeup-legend .row { display: flex; align-items: center; gap: 7px; }
.threeup-legend .sw { width: 16px; height: 11px; border: 1px solid #333; }
@media (max-width: 640px) { .threeup { grid-template-columns: 1fr; } }

/* ----- Results: editorial table lead sentence ---------------------------- */
.table-lead {
  font-family: var(--font-serif);
  font-size: 1.05rem; line-height: 1.55;
  color: var(--ink);
  margin: var(--space-2) 0 var(--space-2);
  max-width: 70ch;
}

/* ----- Contribution outcome line ----------------------------------------- */
.contrib-outcome {
  margin-top: var(--space-1);
  font-family: var(--font-sans); font-size: var(--fs-meta);
  color: var(--blue);
}

/* ----- Results statline: stat-note sub-label ----------------------------- */
.stat-note {
  display: block;
  font-size: var(--fs-eyebrow);
  color: var(--gray);
  margin-top: 0.2em;
}
