/* 3DBC explainer. Colours live as custom properties so a later React port can
   swap them for the app's tokens without touching the geometry. */

:root {
  color-scheme: light dark;

  --bg: #fbfaf8;
  --bg-sunk: #f2efe9;
  --ink: #1c1a17;
  --ink-soft: #5d574e;
  --ink-faint: #948b7d;
  --rule: #ddd6ca;

  --c-obs: #1f6f8b;
  --c-cur: #9a7b3f;
  --c-fut: #b0472e;
  --c-target: #4d3a8c;
  --c-model: #8d8578;

  --stage-max: 760px;
  --ease: cubic-bezier(0.4, 0.05, 0.2, 1);
  --dur: 760ms;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16151a;
    --bg-sunk: #1e1d24;
    --ink: #eeeae4;
    --ink-soft: #b3ada4;
    --ink-faint: #7c7669;
    --rule: #34323c;

    --c-obs: #5fb6d4;
    --c-cur: #d8b160;
    --c-fut: #f08a6c;
    --c-target: #a48ce8;
    --c-model: #7a7488;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 Lato, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

code, pre { font-family: ui-monospace, "Cascadia Code", "SF Mono", Menlo, monospace; }

/* ------------------------------------------------------------------ masthead */

.masthead {
  max-width: 720px;
  margin: 0 auto;
  padding: 22vh 24px 16vh;
}

.eyebrow {
  margin: 0 0 12px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.masthead h1 {
  margin: 0 0 18px;
  font-size: clamp(38px, 7vw, 66px);
  line-height: 1.02;
  letter-spacing: -0.025em;
  font-weight: 700;
}

.standfirst {
  margin: 0;
  font-size: 19px;
  color: var(--ink-soft);
  max-width: 56ch;
}

.scroll-hint {
  margin-top: 56px;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.scroll-hint::after {
  content: "";
  display: block;
  width: 1px;
  height: 42px;
  margin-top: 10px;
  background: linear-gradient(var(--ink-faint), transparent);
}

/* ------------------------------------------------------------------- scrolly */

.scrolly {
  display: grid;
  grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
  gap: 40px;
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 24px;
  align-items: start;
}

.step {
  min-height: 92vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4vh 0;
  opacity: 0.24;
  transition: opacity 420ms var(--ease);
}

.step.is-active { opacity: 1; }

.step h2 {
  margin: 0 0 14px;
  font-size: 27px;
  line-height: 1.18;
  letter-spacing: -0.015em;
  font-weight: 700;
}

.step p { margin: 0 0 14px; color: var(--ink-soft); }
.step p b, .step p b span { color: var(--ink); font-weight: 700; }

.aside {
  border-left: 2px solid var(--rule);
  padding-left: 14px;
  font-size: 14.5px;
}

.formula {
  margin: 4px 0 16px;
  padding: 14px 16px;
  background: var(--bg-sunk);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.9;
  color: var(--ink);
  overflow-x: auto;
}

.badges {
  list-style: none;
  margin: 6px 0 18px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badges li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  background: var(--bg-sunk);
  border-radius: 8px;
  font-size: 13px;
}

.badges span {
  font-size: 10.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.badges b { font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------- stage */

.stage-wrap {
  position: sticky;
  top: var(--story-header-height, 72px);
  height: calc(100vh - var(--story-header-height, 72px));
  height: calc(100svh - var(--story-header-height, 72px));
  display: flex;
  align-items: center;
}

.stage { width: 100%; max-width: var(--stage-max); }

#stage {
  width: 100%;
  height: auto;
  overflow: visible;
}

.stage-caption {
  margin: 6px 4px 0;
  font-size: 12px;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
  min-height: 1.4em;
}

/* ------------------------------------------------------------- stage: chips */

.chip {
  transition: transform var(--dur) var(--ease), opacity 380ms var(--ease);
  transition-delay: calc(var(--i, 0) * 7ms);
}

.chip circle {
  transition: r 380ms var(--ease);
  stroke: var(--bg);
  stroke-width: 1;
}

.chip.s-obs circle { fill: var(--c-obs); }
.chip.s-cur circle { fill: var(--c-cur); }
.chip.s-fut circle { fill: var(--c-fut); }
.chip.is-focus circle { stroke: var(--ink); stroke-width: 2; }

@media (prefers-reduced-motion: reduce) {
  .chip { transition: opacity 1ms linear; transition-delay: 0ms; }
  #marks { transition: none !important; }
}

/* ------------------------------------------------------------- stage: marks */

#marks { transition: opacity 240ms linear; }

.axis { stroke: var(--rule); stroke-width: 1; }
.grid { stroke: var(--rule); stroke-width: 1; stroke-dasharray: 2 4; }
.frame { fill: none; stroke: var(--rule); stroke-width: 1; }

text { font-family: Lato, Arial, sans-serif; }
.tick { font-size: 10.5px; fill: var(--ink-faint); font-variant-numeric: tabular-nums; }
.axis-label { font-size: 11px; fill: var(--ink-faint); letter-spacing: 0.05em; }
.panel-title { font-size: 12px; fill: var(--ink-soft); letter-spacing: 0.03em; }
.callout { font-size: 13px; fill: var(--ink-soft); }
.rho { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.knob-label { font-size: 11.5px; font-variant-numeric: tabular-nums; }

/* Number cards: the frames that show the values as digits rather than position. */
.cell { fill: var(--bg-sunk); stroke: none; }
.cell-focus { fill: none; stroke: var(--ink); stroke-width: 1.5; }
rect.cell.cell-focus { fill: var(--bg-sunk); }
.cell-value { font-size: 11px; fill: var(--ink); font-variant-numeric: tabular-nums; }
.cell-index { font-size: 11px; fill: var(--ink-faint); }
.cell-value.dim { fill: var(--ink-soft); }
text.cell-value.s-obs { fill: var(--c-obs); }
text.cell-value.s-fut { fill: var(--c-fut); }
.cell-index.tracked { fill: var(--ink); font-weight: 700; }

.card { fill: var(--bg-sunk); stroke: var(--rule); stroke-width: 1; }
.card-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}
.card-glyph { font-size: 13px; font-weight: 700; }
.card-line { font-size: 12.5px; fill: var(--ink-soft); }
.card-line.s-fut-ink { fill: var(--ink); }

.strip { stroke: none; opacity: 0.85; transition: opacity 380ms var(--ease); }
.trace { fill: none; stroke-width: 1.5; }
.trace.faded { opacity: 0.35; stroke-dasharray: 3 3; }
.trace.ghosted { opacity: 0.2; stroke-width: 1.2; }
.curve { fill: none; stroke: var(--ink-faint); stroke-width: 1.5; }
.fit { stroke-width: 1.5; opacity: 0.6; }
.stem { stroke-width: 1; opacity: 0.5; }
.pick { stroke-width: 1; opacity: 0.5; }

.ghost { fill: none; stroke: var(--ink-faint); stroke-width: 1; }
.tie { stroke: var(--ink-faint); stroke-width: 1; stroke-dasharray: 2 3; opacity: 0.4; }
/* Thirty crossing move lines become spaghetti at any real weight; they are here
   to convey volume, and the tracked chip's line carries the individual story. */
.move { stroke: var(--c-fut); stroke-width: 0.8; opacity: 0.14; }
.move.focus { stroke: var(--ink); stroke-width: 1.5; opacity: 0.9; }
.diff { stroke: var(--c-target); stroke-width: 2.5; opacity: 0.75; }
.delta-arrow { stroke: var(--ink-faint); stroke-width: 1.2; marker-end: url(#arrow); }
#arrow path { fill: var(--ink-faint); }

.s-obs { color: var(--c-obs); }
.s-cur { color: var(--c-cur); }
.s-fut { color: var(--c-fut); }
.s-target { color: var(--c-target); }

text.s-obs, .knob-label.s-obs { fill: var(--c-obs); }
text.s-cur, .knob-label.s-cur { fill: var(--c-cur); }
text.s-fut, .knob-label.s-fut { fill: var(--c-fut); }
text.s-target, .knob-label.s-new { fill: var(--c-target); }
text.s-new { fill: var(--c-target); }

path.s-obs, line.s-obs { stroke: var(--c-obs); }
path.s-cur, line.s-cur { stroke: var(--c-cur); }
path.s-fut, line.s-fut { stroke: var(--c-fut); }
path.s-target, line.s-target { stroke: var(--c-target); }
path.s-model { fill: var(--c-model); }
path.strip.s-obs { fill: var(--c-obs); stroke: none; }
path.strip.s-cur { fill: var(--c-cur); stroke: none; }
path.strip.s-fut { fill: var(--c-fut); stroke: none; }

circle.knob.s-obs { fill: var(--c-obs); }
circle.knob.s-cur { fill: var(--c-cur); }
circle.knob.s-fut { fill: var(--c-fut); }
circle.knob.s-new { fill: var(--c-target); }
line.s-new { stroke: var(--c-target); }

/* ----------------------------------------------------------------- colophon */

.colophon {
  max-width: 720px;
  margin: 12vh auto 0;
  padding: 32px 24px 18vh;
  border-top: 1px solid var(--rule);
  color: var(--ink-soft);
  font-size: 14px;
}

.colophon h2 {
  margin: 0 0 18px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 700;
}

.colophon dl {
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 6px 16px;
  margin: 0 0 22px;
}

.colophon dt { color: var(--ink-faint); font-size: 12.5px; }
.colophon dd { margin: 0; font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; word-break: break-all; }

/* ------------------------------------------------------------------ narrow */

@media (max-width: 900px) {
  .scrolly { grid-template-columns: 1fr; gap: 0; }
  .stage-wrap {
    grid-row: 1;
    height: calc(56vh - var(--story-header-height, 72px));
    top: var(--story-header-height, 72px);
    background: var(--bg);
    z-index: 2;
    border-bottom: 1px solid var(--rule);
  }
  .prose { grid-row: 2; }
  .step { min-height: 78vh; }
  .masthead { padding: 14vh 24px 8vh; }
}
