/* TMS Athletics — public landing page.
   Standalone from the app theme: the app recolors per team, the landing never does.
   Tokens and rules trace to DESIGN-BRIEF.md. */

@font-face {
  font-family: "Instrument Sans";
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  src: url("/static/brand/InstrumentSans-Variable.woff2") format("woff2");
}
/* Metric-matched fallback so the swap does not reflow the hero. */
@font-face {
  font-family: "Instrument-fallback";
  src: local("Helvetica Neue"), local("Arial");
  size-adjust: 100%;
  ascent-override: 95%;
  descent-override: 24%;
  line-gap-override: 0%;
}

:root {
  --bg: #fdfcfa;
  --surface: #ffffff;
  --ink: #1a1713;
  --ink-muted: #5c564d;
  --line: #eae6df;
  --line-soft: #f2efe9;
  --ember: #c2410c;
  --ember-hover: #9a3412;
  --grad-1: #f59e0b;
  --grad-2: #f97316;
  --grad-3: #ec4899;
  --good: #2f6f4e;
  --warn: #8a5108;
  --alert: #a8321f;

  --font: "Instrument Sans", "Instrument-fallback", system-ui, sans-serif;
  --text-hero: clamp(2.5rem, 1.7rem + 3.4vw, 4.25rem);
  --text-caption: clamp(1.5rem, 1.05rem + 2.1vw, 2.75rem);
  --text-h2: clamp(1.6rem, 1.2rem + 1.8vw, 2.5rem);
  --text-body: clamp(1rem, 0.96rem + 0.2vw, 1.125rem);

  --s1: 8px; --s2: 16px; --s3: 24px; --s4: 40px; --s5: 64px; --s6: 104px; --s7: 168px;
  --container: 1120px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --stage-shadow: 0 24px 80px rgb(26 23 19 / 0.10), 0 2px 8px rgb(26 23 19 / 0.04);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--text-body);
  line-height: 1.6;
  overflow-x: hidden;
}

h1, h2, h3 {
  margin: 0;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

p { margin: 0; }

a { color: var(--ember); }

:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 3px;
  border-radius: 4px;
}

.container {
  width: min(100% - 48px, var(--container));
  margin-inline: auto;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--surface);
  color: var(--ink);
  padding: 12px 18px;
  z-index: 100;
}
.skip-link:focus { left: 16px; top: 12px; }

/* ---------------- nav ---------------- */

.nav {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 18px max(24px, calc((100vw - var(--container)) / 2));
  background: color-mix(in oklab, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 240ms var(--ease), background 240ms var(--ease);
}
.nav[data-scrolled="true"] { border-bottom-color: var(--line); }

.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  font-weight: 700;
  font-size: 1.0625rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
  margin-right: auto;
}
.wordmark b {
  font-weight: 700;
  letter-spacing: 0.01em;
  padding: 2px 7px 3px;
  border-radius: 7px;
  background: var(--ink);
  color: var(--bg);
}
.wordmark span { font-weight: 500; color: var(--ink-muted); }

.nav-link {
  color: var(--ink-muted);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
}
.nav-link:hover { color: var(--ink); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 11px 22px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  /* Both stops clear 4.5:1 against white, so the label passes anywhere on the fill. */
  background-image: linear-gradient(180deg, var(--ember) 0%, #b03c0b 100%);
  color: #fff;
  transition: background-image 150ms var(--ease), transform 150ms var(--ease);
}
.btn:hover {
  background-image: linear-gradient(180deg, #b03c0b 0%, var(--ember-hover) 100%);
}
.btn:active { transform: translateY(1px); }
.btn-lg { font-size: 1.0625rem; padding: 15px 30px; }

/* ---------------- the Stage ---------------- */

.track { position: relative; }

.pin {
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr;
  align-content: center;
  gap: clamp(20px, 3vh, 38px);
  padding: calc(72px + var(--s4)) 0 var(--s5);
}

/* Headline slot: the hero line, then the per-scene captions, share this space.
   Fixed height so the frame below always gets the same room. */
.slot {
  position: relative;
  display: grid;
  place-items: center;
  text-align: center;
  height: clamp(150px, 23vh, 224px);
  padding-inline: 24px;
}
.slot > * { grid-area: 1 / 1; width: min(100%, 900px); }

.hero-line { font-size: var(--text-hero); }
.hero-sub {
  margin-top: 14px;
  color: var(--ink-muted);
  font-size: clamp(1rem, 0.9rem + 0.5vw, 1.25rem);
  max-width: 34ch;
  margin-inline: auto;
}

.caption {
  font-size: var(--text-caption);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.03em;
}
.caption small {
  display: block;
  margin-top: 10px;
  font-size: clamp(0.9375rem, 0.9rem + 0.25vw, 1.0625rem);
  font-weight: 500;
  letter-spacing: 0;
  color: var(--ink-muted);
}

.stage-wrap {
  position: relative;
  display: grid;
  place-items: center;
  padding-inline: 24px;
  min-height: 0;
}

.stage {
  position: relative;
  width: min(100%, var(--container));
  height: 100%;
  border-radius: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--stage-shadow);
  overflow: hidden;
}

/* The one gradient event: a warm wash living behind the frame's contents. */
.stage::before {
  content: "";
  position: absolute;
  inset: -20%;
  z-index: 0;
  background:
    radial-gradient(42% 46% at 18% 8%, color-mix(in oklab, var(--grad-1) 42%, transparent), transparent 70%),
    radial-gradient(40% 44% at 86% 12%, color-mix(in oklab, var(--grad-2) 34%, transparent), transparent 72%),
    radial-gradient(52% 56% at 68% 96%, color-mix(in oklab, var(--grad-3) 26%, transparent), transparent 72%);
  opacity: var(--wash, 0.55);
  transition: opacity 500ms var(--ease);
  pointer-events: none;
}
/* Film grain so the wash never bands. */
.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  opacity: 0.045;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.stage-bar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line-soft);
  background: color-mix(in oklab, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  font-size: 0.8125rem;
  color: var(--ink-muted);
  font-weight: 500;
}
.stage-bar .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--good);
}

.scenes { position: relative; z-index: 2; height: calc(100% - 46px); }

.scene {
  padding: clamp(18px, 2.6vh, 34px) clamp(20px, 3vw, 44px);
  height: 100%;
  overflow: hidden;
}

/* ---------------- scene 1: paste → roster ---------------- */

.paste {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(20px, 3vw, 48px);
  align-items: start;
  align-content: center;
  height: 100%;
}

.sheet, .roster { min-width: 0; }

.pane-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 12px;
}

.sheet-grid {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
  font-variant-numeric: tabular-nums;
  font-size: clamp(0.6875rem, 0.62rem + 0.3vw, 0.875rem);
}
.sheet-row {
  display: grid;
  grid-template-columns: 1.6fr 0.8fr 0.8fr 0.9fr;
  border-top: 1px solid var(--line-soft);
}
.sheet-row:first-child { border-top: 0; }
.sheet-row span {
  padding: 7px 10px;
  border-left: 1px solid var(--line-soft);
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sheet-row span:first-child { border-left: 0; color: var(--ink); }
.sheet-row.head span {
  background: #f6f4f0;
  color: var(--ink-muted);
  font-weight: 600;
}
.sheet-row.blank span { color: #b9b2a7; }

.roster-list { display: grid; gap: 9px; }

/* Units are named once at the top of the column, not on every card. */
.roster-head, .athlete {
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(3, clamp(52px, 5vw, 72px));
  align-items: center;
  gap: clamp(8px, 1vw, 16px);
}
.roster-head {
  padding: 0 15px 8px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.roster-head span { text-align: right; }

.athlete {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.athlete .who { min-width: 0; }
.athlete .name {
  font-weight: 600;
  font-size: 0.9375rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.athlete .meta { font-size: 0.8125rem; color: var(--ink-muted); }
.athlete .stat {
  text-align: right;
  font-size: 0.9375rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.athlete .stat.none { color: var(--ink-muted); font-weight: 500; }

/* ---------------- scene 2: leaderboard ---------------- */

.board { height: 100%; display: flex; flex-direction: column; justify-content: center; }
.board-list { display: grid; gap: 8px; }

.rank {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) minmax(90px, 2fr) 62px;
  align-items: center;
  gap: clamp(10px, 1.6vw, 22px);
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.rank .pos {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}
.rank .rname {
  min-width: 0;
  font-weight: 600;
  font-size: 0.9375rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rank .rname em {
  display: block;
  font-style: normal;
  font-weight: 400;
  font-size: 0.8125rem;
  color: var(--ink-muted);
}
.rank .bar {
  height: 8px;
  border-radius: 999px;
  background: var(--line-soft);
  overflow: hidden;
}
.rank .bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  width: var(--w);
  background: linear-gradient(90deg, var(--grad-1), var(--grad-2));
}
.rank .val {
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.rank:first-child .val { color: var(--ember); }

/* ---------------- scene 3: the personal best ---------------- */

.pr { height: 100%; display: grid; place-items: center; position: relative; }
/* The one celebratory moment on the page: warm light behind the best number. */
.pr::before {
  content: "";
  position: absolute;
  width: min(132%, 820px);
  aspect-ratio: 1.55;
  border-radius: 50%;
  background: radial-gradient(closest-side,
    color-mix(in oklab, var(--grad-1) 44%, transparent),
    color-mix(in oklab, var(--grad-2) 26%, transparent) 52%,
    color-mix(in oklab, var(--grad-3) 11%, transparent) 74%,
    transparent 88%);
  opacity: var(--glow, 0.5);
  transform: scale(var(--glow-scale, 1));
  pointer-events: none;
}
.pr-card {
  position: relative;
  width: min(100%, 460px);
  padding: clamp(22px, 3vh, 34px) clamp(24px, 3vw, 38px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  text-align: left;
}
.pr-who { font-size: 1.375rem; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; }
.pr-test { color: var(--ink-muted); font-size: 0.9375rem; }
.pr-figure {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 18px;
}
.pr-now {
  font-size: clamp(3rem, 2rem + 3vw, 4.5rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.pr-now u {
  text-decoration: none;
  font-size: 0.3em;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--ink-muted);
  margin-left: 5px;
}
.pr-delta {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--good);
  padding: 5px 11px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--good) 12%, var(--surface));
}
.pr-note {
  margin-top: 16px;
  font-size: 0.9375rem;
  color: var(--ink-muted);
  max-width: 40ch;
}

/* ---------------- scene 4: the season line ---------------- */

.trend { height: 100%; display: flex; flex-direction: column; justify-content: center; }
.chart { width: 100%; height: auto; max-height: 78%; display: block; margin-top: 8px; }
.chart .grid-lines line { stroke: var(--line-soft); stroke-width: 1; }
.chart .axis text, .chart .xlabels text {
  fill: var(--ink-muted);
  font-family: var(--font);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.chart .axis text { text-anchor: end; }
.chart .xlabels text { text-anchor: middle; }
.chart .line {
  fill: none;
  stroke: var(--ember);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chart .dots circle { fill: var(--surface); stroke: var(--ember); stroke-width: 3; }
.chart .dots circle:last-child { fill: var(--ember); }

/* ---------------- scene 5: the private action list ---------------- */

.actions-view {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(12px, 2vh, 18px);
}
.av-list { display: grid; gap: 10px; }

.act {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: clamp(12px, 1.5vw, 18px);
  align-items: start;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.flag {
  /* Fixed width so every card's text starts on the same line, whatever the
     label says. Ragged left edges across peer rows read as a layout bug. */
  min-width: 92px;
  text-align: center;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
  margin-top: 1px;
}
.flag.monitor { color: var(--warn); background: color-mix(in oklab, var(--warn) 13%, var(--surface)); }
.flag.attention { color: var(--alert); background: color-mix(in oklab, var(--alert) 12%, var(--surface)); }

.act-title { font-weight: 600; font-size: 0.9375rem; }
.act-evidence { margin-top: 3px; font-size: 0.875rem; color: var(--ink-muted); }
.act-next { margin-top: 7px; font-size: 0.875rem; color: var(--ink-muted); }
.act-next b {
  display: inline-block;
  margin-right: 7px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink);
}

.av-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 6px clamp(16px, 2.5vw, 32px);
  font-size: 0.8125rem;
  color: var(--ink-muted);
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}
.av-foot b {
  font-weight: 600;
  color: var(--ink);
  margin-right: 5px;
}
.av-private { flex: 1 1 22ch; }

/* ---------------- scene 6: the whole program ---------------- */

.teamview { height: 100%; display: flex; flex-direction: column; gap: clamp(12px, 2vh, 20px); }
.tv-stats {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(14px, 2.4vw, 32px);
  font-size: 0.9375rem;
  color: var(--ink-muted);
}
.tv-stats b {
  font-size: 1.125rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  margin-right: 4px;
}
.tv-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  align-content: start;
  min-height: 0;
}
.tile {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  font-size: 0.75rem;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
}
.tile b {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.tile.pb {
  border-color: color-mix(in oklab, var(--ember) 45%, var(--line));
  background: color-mix(in oklab, var(--grad-1) 9%, var(--surface));
}
.tile.pb b { color: var(--ember); }

/* ---------------- how it works ---------------- */

.how { padding: var(--s7) 0 var(--s6); }
.how h2 { font-size: var(--text-h2); max-width: 18ch; }
.steps {
  list-style: none;
  margin: var(--s5) 0 0;
  padding: 0;
  display: grid;
  gap: var(--s4);
  max-width: 62ch;
}
.steps li { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: var(--s3); }
.steps .num {
  font-size: 0.875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ember);
  padding-top: 3px;
}
.steps p { color: var(--ink-muted); }

/* ---------------- static (no-JS / reduced-motion) baseline ---------------- */
/* Everything above renders visible by default. JS opts into the pinned Stage. */

/* Without the Stage there is no frame to pin, so the acts flatten into a plain
   page: each caption followed by its own panel, in narrative order. The
   intermediate wrappers collapse with display:contents so one grid can order
   children that live in different parents. */
.track:not([data-stage="on"]) .slot,
.track:not([data-stage="on"]) .stage-wrap,
.track:not([data-stage="on"]) .stage,
.track:not([data-stage="on"]) .scenes { display: contents; }

.track:not([data-stage="on"]) .pin {
  display: grid;
  grid-template-rows: none;
  gap: var(--s5);
  padding: calc(72px + var(--s5)) max(24px, calc((100vw - var(--container)) / 2)) var(--s6);
}
.track:not([data-stage="on"]) .stage-bar { display: none; }
/* display:contents still generates the frame's pseudo-elements, and with no
   frame box to anchor to they would size against the whole track. */
.track:not([data-stage="on"]) .stage::before,
.track:not([data-stage="on"]) .stage::after { display: none; }

.track:not([data-stage="on"]) .slot > * {
  grid-area: auto;
  width: auto;
  text-align: center;
}
.track:not([data-stage="on"]) .caption { margin-top: var(--s4); }

.track:not([data-stage="on"]) .scene {
  position: static;
  height: auto;
  padding: clamp(20px, 3vw, 32px);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--stage-shadow);
}
.track:not([data-stage="on"]) .hero-line-wrap { order: 1; }
.track:not([data-stage="on"]) .slot > .caption:nth-child(2) { order: 2; }
.track:not([data-stage="on"]) .scenes > .scene:nth-child(1) { order: 3; }
.track:not([data-stage="on"]) .slot > .caption:nth-child(3) { order: 4; }
.track:not([data-stage="on"]) .scenes > .scene:nth-child(2) { order: 5; }
.track:not([data-stage="on"]) .slot > .caption:nth-child(4) { order: 6; }
.track:not([data-stage="on"]) .scenes > .scene:nth-child(3) { order: 7; }
.track:not([data-stage="on"]) .slot > .caption:nth-child(5) { order: 8; }
.track:not([data-stage="on"]) .scenes > .scene:nth-child(4) { order: 9; }
.track:not([data-stage="on"]) .slot > .caption:nth-child(6) { order: 10; }
.track:not([data-stage="on"]) .scenes > .scene:nth-child(5) { order: 11; }
.track:not([data-stage="on"]) .slot > .caption:nth-child(7) { order: 12; }
.track:not([data-stage="on"]) .scenes > .scene:nth-child(6) { order: 13; }

/* Panels that assume a tall frame need explicit room once unpinned. */
.track:not([data-stage="on"]) .board,
.track:not([data-stage="on"]) .trend,
.track:not([data-stage="on"]) .teamview,
.track:not([data-stage="on"]) .actions-view,
.track:not([data-stage="on"]) .pr { height: auto; }
.track:not([data-stage="on"]) .chart { max-height: none; }

/* ---------------- pinned Stage (JS on) ---------------- */

.track[data-stage="on"] { height: var(--track-height, 520vh); }
.track[data-stage="on"] .pin {
  position: sticky;
  top: 0;
  height: 100svh;
}
/* The outgoing line clears before the incoming one arrives: two headlines at
   half opacity in the same space is mush, not a dissolve. */
.track[data-stage="on"] .slot > * {
  opacity: 0;
  transition: opacity 200ms var(--ease), transform 380ms var(--ease);
  pointer-events: none;
}
.track[data-stage="on"] .slot > .is-on {
  opacity: 1;
  pointer-events: auto;
  transition-delay: 180ms, 120ms;
}
.track[data-stage="on"] .hero-line-wrap { transform: translateY(0) scale(1); }
.track[data-stage="on"] .hero-line-wrap:not(.is-on) { transform: translateY(-18px) scale(0.97); }
.track[data-stage="on"] .caption:not(.is-on) { transform: translateY(14px); }

.track[data-stage="on"] .stage {
  transform: scale(var(--stage-scale, 1)) translateY(var(--stage-rise, 0px));
  transform-origin: 50% 42%;
  will-change: transform;
}

.track[data-stage="on"] .scene {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms var(--ease);
}
/* Outgoing scene clears before the incoming one arrives — two dense panels at
   half opacity read as a printing error, not a dissolve. */
.track[data-stage="on"] .scene.is-on {
  opacity: 1;
  pointer-events: auto;
  transition-delay: 190ms;
}

/* Scroll-linked motion inside scene 1: --p runs 0 → 1 across the scene's window.
   The sheet starts centred in the frame and slides aside as the roster builds,
   so the frame is never half-empty. */
.track[data-stage="on"] .paste { --slide: clamp(0, calc(var(--p, 1) / 0.22), 1); }
.track[data-stage="on"] .sheet {
  transform: translateX(calc((1 - var(--slide, 0)) * 52%));
}
.track[data-stage="on"] .sheet-row {
  --pi: clamp(0, calc((var(--p, 1) - 0.30 - 0.03 * var(--i, 0)) / 0.45), 1);
  opacity: calc(1 - 0.6 * var(--pi));
}
.track[data-stage="on"] .sheet-grid {
  filter: blur(calc(clamp(0, calc((var(--p, 0) - 0.3) / 0.7), 1) * 1.2px));
}
.track[data-stage="on"] .roster { opacity: var(--slide, 0); }
.track[data-stage="on"] .athlete {
  --pi: clamp(0, calc((var(--p, 1) - 0.06 - 0.06 * var(--i, 0)) / 0.34), 1);
  opacity: var(--pi);
  transform: translateY(calc((1 - var(--pi)) * 14px));
}

/* Scene 2: rows slide out of arrival order into rank order, bars fill behind them. */
.track[data-stage="on"] .rank {
  --pi: clamp(0, calc((var(--p, 1) - 0.04 * var(--i, 0)) / 0.5), 1);
  opacity: clamp(0, calc(var(--pi) * 2.5), 1);
  transform: translateY(calc((1 - var(--pi)) * var(--dy, 0) * 52px));
}
.track[data-stage="on"] .rank .bar i {
  transform: scaleX(clamp(0, calc((var(--p, 1) - 0.22 - 0.05 * var(--i, 0)) / 0.45), 1));
  transform-origin: 0 50%;
}

/* Scene 3: the card settles while the wash swells behind it. */
.track[data-stage="on"] .pr-card {
  --pi: clamp(0, calc(var(--p, 1) / 0.4), 1);
  opacity: var(--pi);
  transform: translateY(calc((1 - var(--pi)) * 20px)) scale(calc(0.97 + 0.03 * var(--pi)));
}
.track[data-stage="on"] .pr-figure {
  opacity: clamp(0, calc((var(--p, 1) - 0.25) / 0.3), 1);
}
.track[data-stage="on"] .pr {
  --glow: clamp(0, calc((var(--p, 1) - 0.15) / 0.45), 1);
  --glow-scale: calc(0.72 + 0.28 * clamp(0, calc((var(--p, 1) - 0.15) / 0.45), 1));
}

/* Scene 4: the line draws itself as you scroll; the dots land behind it. */
.track[data-stage="on"] .chart .line {
  stroke-dasharray: 780;
  stroke-dashoffset: calc((1 - clamp(0, calc(var(--p, 1) / 0.7), 1)) * 780);
}
.track[data-stage="on"] .chart .dots circle {
  opacity: clamp(0, calc((var(--p, 1) - 0.12 - 0.16 * var(--i, 0)) / 0.14), 1);
}

/* Scene 5: the shortlist arrives one item at a time, the way it is read. */
.track[data-stage="on"] .act {
  --pi: clamp(0, calc((var(--p, 1) - 0.06 - 0.16 * var(--i, 0)) / 0.34), 1);
  opacity: var(--pi);
  transform: translateY(calc((1 - var(--pi)) * 12px));
}
.track[data-stage="on"] .av-foot {
  opacity: clamp(0, calc((var(--p, 1) - 0.5) / 0.3), 1);
}

/* Scene 6: the roster fills in, reading order, fast. */
.track[data-stage="on"] .tile {
  --pi: clamp(0, calc((var(--p, 1) - 0.011 * var(--i, 0)) / 0.28), 1);
  opacity: var(--pi);
  transform: translateY(calc((1 - var(--pi)) * 10px));
}
.track[data-stage="on"] .tv-stats {
  opacity: clamp(0, calc(var(--p, 1) / 0.25), 1);
}

/* ---------------- close-out ---------------- */

.close {
  padding: var(--s7) 0 var(--s6);
  text-align: center;
}
.close h2 { font-size: var(--text-h2); }
.close p {
  margin: var(--s3) auto 0;
  max-width: 46ch;
  color: var(--ink-muted);
}
.close .actions {
  margin-top: var(--s4);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
  align-items: center;
  justify-content: center;
}
.close .actions a.text {
  color: var(--ink-muted);
  font-weight: 500;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  padding-bottom: 2px;
}
.close .actions a.text:hover { color: var(--ink); border-bottom-color: var(--ink); }

.foot {
  border-top: 1px solid var(--line);
  padding: var(--s4) 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
  align-items: center;
  font-size: 0.875rem;
  color: var(--ink-muted);
}
.foot nav { margin-left: auto; display: flex; gap: var(--s3); }
.foot a { color: var(--ink-muted); text-decoration: none; }
.foot a:hover { color: var(--ink); }

/* ---------------- mobile recomposition ---------------- */

@media (max-width: 760px) {
  .nav { padding: 12px 20px; gap: 14px; }
  .nav .nav-link { display: none; }          /* signing in lives in the close-out and footer */
  .nav .btn { padding: 10px 16px; font-size: 0.875rem; }
  .container { width: calc(100% - 40px); }

  .track:not([data-stage="on"]) .pin { padding-inline: 20px; gap: var(--s4); }
  .stage { border-radius: 18px; }
  .scene { height: auto; }
  .paste { grid-template-columns: minmax(0, 1fr); gap: 18px; height: auto; }

  /* The raw sheet is context, not the point: phones get the outcome only,
     and the third test column goes with it. */
  .sheet { display: none; }
  .roster-head, .athlete { grid-template-columns: minmax(0, 1fr) repeat(2, 58px); }
  .roster-head span:last-child,
  .athlete .stat:last-child { display: none; }

  .rank { grid-template-columns: 22px minmax(0, 1fr) 54px; }
  .rank .bar { display: none; }          /* the numbers already carry the ranking */

  /* The flag stacks above the text rather than stealing a column; side by side
     it leaves a ~20-character measure, which is unreadable. */
  .act { grid-template-columns: minmax(0, 1fr); gap: 9px; }
  .flag { justify-self: start; min-width: 0; }
  .av-foot { flex-direction: column; }
  .tv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .steps li { grid-template-columns: 28px minmax(0, 1fr); gap: var(--s2); }

  .slot { height: auto; }
  .hero-sub { max-width: 30ch; }
  .close { padding: var(--s6) 0 var(--s5); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
