/* ─────────────────────────────────────────────────────────────
   TRACE project page — styled after https://eyerobot2.github.io/:
   plain white page, Open Sans throughout, an 800px reading column,
   a quiet gray sticky TOC, pill nav buttons, and Berkeley Blue
   used sparingly as the single accent.
   ───────────────────────────────────────────────────────────── */

/* ─── Tokens ─────────────────────────────────────────── */
:root {
  --bg:            #ffffff;
  --surface:       #ffffff;
  --surface-muted: #f4f5f5;
  --border:        #e6e6e6;
  --border-strong: #d6d6d6;
  --text:          #1f1f1f;
  --text-secondary: #333333;
  --text-tertiary:  #8a8a8a;
  /* UC Berkeley brand palette — brand.berkeley.edu/visual-identity/colors */
  --accent:       #002676;            /* Berkeley Blue — the single brand accent */
  --accent-mid:   #004AAE;            /* Blue Medium — hover / secondary accent */
  --accent-light: #edf2fc;            /* faint Berkeley-blue wash */
  --accent-rule:  #002676;

  --font-display: 'Open Sans', -apple-system, 'Avenir Next', Helvetica, Arial, sans-serif;
  --font-body:    'Open Sans', -apple-system, Helvetica, Arial, sans-serif;

  --space-xs:  4px;
  --space-sm:  8px;
  --space-md:  16px;
  --space-lg:  24px;
  --space-xl:  40px;
  --space-2xl: 64px;
  --space-3xl: 96px;

  --max-w: 800px;
  --radius-sm: 6px;
  --radius: 10px;
  --shadow-card: 0 4px 18px rgba(21, 23, 25, 0.06);
  --shadow-card-hover: 0 8px 24px rgba(21, 23, 25, 0.1);
}

/* ─── Reset ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ─── Page layout ────────────────────────────────────── */
.page-wrap {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--space-xl);
}

@media (max-width: 600px) {
  .page-wrap { padding: 0 var(--space-lg); }
}


/* ─── Header ─────────────────────────────────────────── */
header {
  padding: var(--space-xl) 0 var(--space-lg);
  border-bottom: none;
}

header h1 {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 4.5vw, 2.85rem);
  font-weight: 400;
  line-height: 1.18;
  letter-spacing: -0.01em;
  color: var(--text);
  max-width: 820px;
  margin-bottom: var(--space-sm);
}

header h1 strong { font-weight: 800; }


.authors {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 0;
  font-size: 0.92rem;
  font-weight: 400;
  color: var(--text-secondary);
  line-height: 1.8;
}

.authors a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.12s;
  white-space: nowrap;
}

.authors a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.authors sup {
  font-size: 0.6em;
  color: var(--accent);
  vertical-align: top;
  position: relative;
  top: 0.1em;
  line-height: 1;
  margin-left: 1px;
}

.author-sep {
  color: var(--border-strong);
  user-select: none;
  margin-right: 6px;
}

.affiliations {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  display: flex;
  flex-wrap: wrap;
  gap: 4px var(--space-xl);
  margin-top: var(--space-xs);
}

.affiliations span { display: flex; align-items: center; gap: 3px; }
.affiliations sup {
  font-size: 0.6em;
  color: var(--accent);
  line-height: 1;
  vertical-align: top;
  position: relative;
  top: 0.1em;
}

/* ─── Header action links ────────────────────────────── */
.header-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
}

.action-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
  color: var(--text);
  padding: 7px 16px 7px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  transition: background 0.12s, border-color 0.12s;
  white-space: nowrap;
}

.action-link:hover {
  background: var(--surface-muted);
  border-color: var(--text-tertiary);
}

.action-link svg { flex-shrink: 0; opacity: 0.7; }
.action-link:hover svg { opacity: 1; }

/* ─── Main body ──────────────────────────────────────── */
main { padding: var(--space-md) 0 var(--space-xl); }

/* ─── Section layout ─────────────────────────────────── */
.section {
  padding-top: var(--space-2xl);
  margin-bottom: var(--space-xl);
  scroll-margin-top: var(--space-lg);
  border-top: 1px solid var(--border);
  position: relative;
}

.section:first-child {
  padding-top: 0;
  border-top: none;
}

h2 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3.2vw, 2rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.025em;
  color: var(--text);
  margin-bottom: var(--space-lg);
  text-wrap: balance;
}

h3 {
  font-family: var(--font-display);
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: var(--space-md);
  margin-top: var(--space-xl);
}

/* ─── Body text ──────────────────────────────────────── */
p {
  font-size: 1.025rem;
  color: var(--text-secondary);
  line-height: 1.75;
  max-width: 72ch;
}

p + p { margin-top: var(--space-md); }

p strong { color: var(--text); font-weight: 600; }

/* Breathing room when a paragraph (incl. a fig-caption) sits directly above a
   figure / table / control. These containers only carry margin-bottom, so a
   preceding <p> would otherwise butt right up against them. */
p + .method-figure,
p + .challenge,
p + .diverge,
p + .seg-group,
p + .run-viewer,
p + .table-wrap { margin-top: var(--space-lg); }

/* ─── Method figure ──────────────────────────────────── */
.method-figure {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  margin-bottom: var(--space-xl);
}

.method-figure img { width: 100%; display: block; }

/* ─── Results table ──────────────────────────────────── */
.table-wrap { overflow-x: auto; margin-bottom: var(--space-md); }

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

thead tr { border-bottom: 1.5px solid var(--border-strong); }

th {
  padding: var(--space-sm) var(--space-md) var(--space-sm) 0;
  text-align: left;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

th:not(:first-child) { text-align: right; padding-right: 0; padding-left: var(--space-xl); }

td {
  padding: 11px var(--space-md) 11px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
  transition: background 0.12s;
}

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

td:not(:first-child) { text-align: right; padding-right: 0; padding-left: var(--space-xl); }

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

tr.method-row td { color: var(--text); }
tr.method-row td.best { font-weight: 600; color: var(--accent); }

tr.improvement-row td {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  padding-top: 4px;
  padding-bottom: 10px;
  border-bottom: none;
}

tr.section-break td {
  border-top: 1.5px solid var(--border-strong);
  padding-top: var(--space-md);
}

/* ─── Figure captions ────────────────────────────────── */
.fig-caption {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-tertiary);
  margin-top: var(--space-md);
  font-family: var(--font-display);
  max-width: 78ch;
}

.fig-caption a {
  color: var(--text-secondary);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
}

/* ─── Citation card ───────────────────────────────────── */
.cite-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.cite-head {
  background: var(--surface-muted);
  padding: var(--space-lg) var(--space-lg) var(--space-md);
}

.cite-head h2 { margin-bottom: var(--space-xs); }
.cite-head p { margin: 0; color: var(--text-secondary); }

.bibtex {
  background: #fafafa;
  color: var(--text-secondary);
  margin: 0;
  padding: var(--space-lg);
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.6;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ─── Footer ────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  padding: var(--space-lg) 0;
  margin-top: 0;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
  font-size: 0.82rem;
  color: var(--text-tertiary);
}

.footer-inner a {
  color: var(--text-tertiary);
  text-decoration: none;
  transition: color 0.12s;
}

.footer-inner a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ─── Segmented controls ─────────────────────────────── */
.seg-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.seg-label {
  font-size: 0.82rem;
  color: var(--text-tertiary);
  margin-right: var(--space-xs);
}

.seg-btn {
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s, color 0.14s;
}

.seg-btn:hover { border-color: var(--text-tertiary); background: var(--surface-muted); }

.seg-btn.active {
  background: var(--text);
  border-color: var(--text);
  color: var(--surface);
}

/* ─── Monochrome challenge ───────────────────────────── */
.challenge-stage {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: oklch(12% 0.01 240);
  box-shadow: var(--shadow-card);
  margin-bottom: var(--space-md);
}

.challenge-stage img {
  width: 100%;
  display: block;
  transition: opacity 0.35s ease;
}

/* ─── Run viewer (marquee) ───────────────────────────── */
.run-viewer { margin-bottom: var(--space-sm); }

.run-stage {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: oklch(12% 0.01 240);
  box-shadow: var(--shadow-card);
}

.run-stage img { width: 100%; display: block; }

.run-badge {
  position: absolute;
  top: var(--space-md);
  left: var(--space-md);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--surface);
  background: rgba(25, 25, 25, 0.85);
  border-radius: var(--radius-sm);
  padding: 5px 11px;
}

.run-controls {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-top: var(--space-md);
}

.run-play {
  flex-shrink: 0;
  font-family: var(--font-body);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--surface);
  background: var(--text);
  border: none;
  border-radius: var(--radius-sm);
  padding: 7px 16px;
  cursor: pointer;
  transition: background 0.14s;
  min-width: 92px;
}

.run-play:hover { background: var(--accent); }

.run-scrub {
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
}

.run-counter {
  flex-shrink: 0;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-tertiary);
}

.run-caption {
  font-size: 0.95rem;
  margin-top: var(--space-md);
  min-height: 2.6em;
}

/* ─── Divergence stepper ─────────────────────────────── */
.diverge-stage {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: oklch(22% 0.01 240);
  box-shadow: var(--shadow-card);
  margin-bottom: var(--space-md);
}

.diverge-stage img { width: 100%; display: block; }

.marker {
  position: absolute;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}

.marker.green { box-shadow: 0 0 0 3px oklch(80% 0.2 145); }
.marker.cyan  { box-shadow: 0 0 0 3px oklch(85% 0.16 210); }

.marker.show {
  opacity: 1;
  transform: scale(1);
  animation: marker-pulse 1.6s ease-out infinite;
}

@keyframes marker-pulse {
  0%   { box-shadow: 0 0 0 3px currentColor, 0 0 0 0 currentColor; }
  100% { box-shadow: 0 0 0 3px currentColor, 0 0 0 16px transparent; }
}

.marker.green.show { color: oklch(80% 0.2 145 / 0.6); }
.marker.cyan.show  { color: oklch(85% 0.16 210 / 0.6); }

.stepper { display: flex; flex-wrap: wrap; gap: var(--space-sm); margin-bottom: var(--space-md); }

.step-btn {
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s, color 0.14s;
}

.step-btn:hover { border-color: var(--text-tertiary); background: var(--surface-muted); }
.step-btn.active { background: var(--text); border-color: var(--text); color: var(--surface); }

.diverge-caption { font-size: 0.95rem; color: var(--text-secondary); min-height: 2.6em; }

/* ─── Interactive perception cards ───────────────────── */
.primitive-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-sm);
}

@media (max-width: 760px) {
  .primitive-cards { grid-template-columns: 1fr; max-width: 30rem; }
}

/* Keep all three primitive stages the same height so photos + the SVG placeholder align. */
.primitive-stage { aspect-ratio: 1 / 1; }
.primitive-stage img { width: 100%; height: 100%; object-fit: cover; }

.primitive-card {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  transition: border-color 0.2s, box-shadow 0.2s, opacity 0.2s, transform 0.2s;
}

.primitive-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light), var(--shadow-card-hover);
}

.primitive-card:not(.selected) { opacity: 0.55; }

.primitive-card:hover {
  opacity: 1;
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}

.primitive-stage { position: relative; overflow: hidden; }
.primitive-stage img { width: 100%; display: block; }

.primitive-card figcaption {
  display: block;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.55;
  padding: var(--space-md);
}

.primitive-card figcaption strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

/* Cluster Dilation jaws animation (cluster_dilation.png already shows the red target point) */
.dilation-jaw {
  position: absolute;
  left: 45%;
  top: 51%;
  width: 46px;
  height: 4px;
  margin: -2px 0 0 -23px;
  border-radius: 2px;
  background: oklch(85% 0.16 210);
  transform-origin: center;
  opacity: 0;
}

.primitive-card[data-primitive="dilation"].selected .jaw-a,
.primitive-card[data-primitive="dilation"]:hover .jaw-a { animation: jaw-cw 2s ease-in-out infinite; }
.primitive-card[data-primitive="dilation"].selected .jaw-b,
.primitive-card[data-primitive="dilation"]:hover .jaw-b { animation: jaw-ccw 2s ease-in-out infinite; }

@keyframes jaw-cw  { 0%{opacity:0;transform:rotate(0)} 20%{opacity:1} 80%{opacity:1;transform:rotate(180deg)} 100%{opacity:0;transform:rotate(180deg)} }
@keyframes jaw-ccw { 0%{opacity:0;transform:rotate(0)} 20%{opacity:1} 80%{opacity:1;transform:rotate(-180deg)} 100%{opacity:0;transform:rotate(-180deg)} }

/* ─── Bar chart ──────────────────────────────────────── */
.chart {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
  height: 240px;
  align-items: end;
  padding: 0 var(--space-sm);
  border-bottom: 1.5px solid var(--border-strong);
  margin-bottom: var(--space-sm);
}

.bar-group {
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 8px;
  height: 100%;
}

.bar {
  position: relative;
  width: 36%;
  max-width: 54px;
  border-radius: 3px 3px 0 0;
  height: 0;
  transition: height 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.bar .bar-val {
  position: absolute;
  top: -19px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  white-space: nowrap;
}

.bar-tier {
  text-align: center;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-top: var(--space-xs);
}

.chart-tiers {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
  padding: 0 var(--space-sm);
  margin-bottom: var(--space-md);
}

.chart-legend {
  display: flex;
  gap: var(--space-lg);
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.chart-legend span { display: inline-flex; align-items: center; gap: 7px; }

.swatch { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }

/* ─── Score badges ───────────────────────────────────── */
.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xl);
  margin-block: var(--space-lg) var(--space-sm);
}

.badge {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.badge-num {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.badge-num.accent { color: var(--accent); }

.muted { color: var(--text-tertiary); font-weight: 400; }

/* ─── Hero entrance (entrance-only; sections render static) ─── */
/* .reveal-pending is set in <head> only when motion is welcome, and is
   cleared by the motion module (or a safety timeout) so content always shows. */
.reveal-pending .hero-reveal { opacity: 0; }

/* ─── Section scroll reveal ──────────────────────────────
   Only armed when <html> carries .js-reveal, so a failed script leaves
   every section visible rather than blank. */
.js-reveal .reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

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

/* ─── Hero ───────────────────────────────────────────── */
.hero {
  padding: var(--space-2xl) 0 0;
  border-bottom: none;
}

.hero-kicker {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: var(--space-md);
}

.hero h1 {
  font-size: clamp(2.1rem, 5.4vw, 3.4rem);
  line-height: 1.06;
  letter-spacing: -0.035em;
  max-width: 20ch;
  margin-bottom: var(--space-lg);
  text-wrap: balance;
}

.hero-claim {
  font-size: clamp(1.05rem, 1.7vw, 1.22rem);
  line-height: 1.6;
  color: var(--text-secondary);
  max-width: 56ch;
  margin: var(--space-lg) 0 0;
  text-wrap: pretty;
}

.hero-stage {
  position: relative;
  margin-block: var(--space-xl);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: oklch(12% 0.01 240);
  box-shadow: var(--shadow-card);
}

.scroll-hint {
  text-align: center;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  color: var(--text-tertiary);
  margin-block: 0 var(--space-lg);
}

.hero-stage img,
.hero-stage video { width: 100%; display: block; }

.hero-meta {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border);
}

@media (max-width: 600px) {
  .hero { padding-top: var(--space-xl); }
}

/* ─── Headline result ────────────────────────────────── */
.result-hook {
  padding-top: var(--space-2xl);
  border-top: none;
}

.hook-line {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.4rem, 2.8vw, 2rem);
  line-height: 1.35;
  letter-spacing: -0.02em;
  color: var(--text);
  max-width: 44ch;
  text-wrap: balance;
}

.hook-line .stat {
  color: var(--accent);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stat-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-lg);
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border);
}

.stat-band dt {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stat-band div:first-child dt { color: var(--accent); }

.stat-band dd {
  margin: 6px 0 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--text-tertiary);
}

@media (max-width: 760px) {
  .stat-band { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-md) var(--space-lg); }
}

/* ─── Polish: responsive image aspect safety (prevents CLS) ─── */
/* Images carry width/height attributes; keep height fluid so the reserved
   aspect-ratio box scales with the column instead of locking to pixel height. */
.hero-stage img,
.hero-stage video,
.run-stage img,
.challenge-stage img,
.diverge-stage img,
.primitive-stage img,
.method-figure img { height: auto; }

/* ─── Polish: on-brand keyboard focus ─── */
.seg-btn:focus-visible,
.step-btn:focus-visible,
.run-play:focus-visible,
.action-link:focus-visible,
.run-scrub:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ─── Polish: comfortable touch targets on touch devices ─── */
@media (pointer: coarse) {
  .seg-btn,
  .step-btn,
  .run-play,
  .action-link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

/* ─── Polish: honor reduced motion across every looping/transform effect ─── */
@media (prefers-reduced-motion: reduce) {
  .marker.show { animation: none; }
  .dilation-jaw { animation: none !important; }
  .bar { transition: none; }
  .primitive-card:hover { transform: none; }
  .js-reveal .reveal { opacity: 1; transform: none; transition: none; }
}

/* ─── Sticky section TOC (wide screens only; lives in the left gutter) ─── */
.toc {
  position: fixed;
  top: 50%;
  left: max(16px, calc(50vw - 584px));
  transform: translateY(-50%);
  width: 144px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding-right: 16px;
  border-right: 1px solid var(--border);
  z-index: 10;
}

.toc a {
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.3;
  color: #aaaaaa;
  text-decoration: none;
  transition: color 0.14s;
}

.toc a:hover { color: #555555; }

.toc a.current {
  color: #292929;
  font-weight: 600;
}

@media (max-width: 1179px) { .toc { display: none; } }

@media (prefers-reduced-motion: reduce) { .toc a { transition: none; } }

/* ─── Action link: coming-soon state ─── */
.action-link.is-soon {
  color: var(--text-tertiary);
  border-color: var(--border);
  cursor: default;
}
.action-link.is-soon:hover {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-tertiary);
}
.action-link.is-soon svg { opacity: 0.45; }
.action-link.is-soon:hover svg { opacity: 0.45; }

.soon-tag {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  margin-left: 4px;
}

/* ─── Experimental-setup spec sheet ─────────────────────── */
.spec {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-md) var(--space-xl);
  margin: var(--space-lg) 0 var(--space-md);
}
.spec > div {
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border);
}
.spec dt {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 3px;
}
.spec dd { margin: 0; font-size: 0.95rem; line-height: 1.5; color: var(--text-secondary); }
.spec dd strong { color: var(--text); font-weight: 600; }

@media (max-width: 560px) { .spec { grid-template-columns: 1fr; } }

/* ─── Tier / numeric tables (centered columns, unlike the right-aligned results table) ─── */
.tier-table th,
.tier-table td { text-align: center; padding-left: var(--space-md); padding-right: var(--space-md); }
.tier-table th:first-child,
.tier-table td:first-child { text-align: left; padding-left: 0; }
.tier-table th:not(:first-child) { padding-right: var(--space-md); }
.tier-table .muted { font-size: 0.92em; }
