/* ============================================================
   video-race.css — 9:16 broadcast redesign
   Restyles the EXISTING markup emitted by video-race.js
   (.video-shell / .video-canvas / .video-intro / .video-stage /
    .video-kicker / .video-leader-badge / .video-chart /
    .video-race-svg / .video-line / .video-line-label /
    .video-match-panel / .video-delta-grid / .video-final /
    .video-shortcuts). No new DOM required.
   Target: 1080×1920, no scroll, no clipping.
   ============================================================ */

@import "./tokens.css";

body.video-mode {
  min-width: 0;
  overflow: hidden;
  background: var(--bg);
}
body.video-mode .dashboard-shell { width: 100%; min-height: 100svh; }

/* ---- Stage / letterbox ---- */
.video-shell {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--bg);
}

/* Fixed 1080×1920 stage — JS applies scale() to fit the viewport so all
   absolute-pixel tokens stay proportional regardless of screen size. */
.video-canvas {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;                 /* phases stack in one cell */
  width: 1080px;
  height: 1920px;
  aspect-ratio: 9 / 16;
  flex-shrink: 0;
  transform-origin: center center;
  transform: translate(-50%, -50%) scale(var(--video-scale, 1));
  overflow: hidden;
  background:
    radial-gradient(130% 80% at 50% -8%, var(--stage-1) 0%, var(--stage-2) 42%, var(--stage-3) 100%);
}
/* ambient grid + top glow */
.video-canvas::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.022) 1px, transparent 1px);
  background-size: 4.8% 2.7%;
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 42%, #000, transparent 78%);
          mask-image: radial-gradient(ellipse 80% 60% at 50% 42%, #000, transparent 78%);
  pointer-events: none;
}

/* phases share the single grid cell; visibility via opacity */
.video-intro, .video-stage, .video-final {
  grid-area: 1 / 1;
  transition: opacity 320ms ease;
}
.video-intro[data-visible="false"],
.video-stage[data-visible="false"],
.video-final[data-visible="false"] { opacity: 0; pointer-events: none; }
.video-intro[data-visible="true"],
.video-stage[data-visible="true"],
.video-final[data-visible="true"] { opacity: 1; }

/* ============================================================
   INTRO  —  ~1.3s high-impact hook
   ============================================================ */
.video-intro {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: var(--sp-3);
  padding: 0 9%;
  text-align: center;
}
.video-intro-hero {
  font-size: clamp(128px, 12.5svh, var(--fs-intro-hero));
  font-weight: var(--fw-black);
  line-height: .9;
  letter-spacing: var(--tracking-tight);
  background: linear-gradient(135deg, #A5AFFF, #C4B5FD 55%, #86E0FF);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
}
.video-intro p {
  margin: 0;
  font-size: clamp(42px, 4.4svh, var(--fs-intro-line));
  font-weight: var(--fw-bold);
  line-height: 1.06;
  letter-spacing: var(--tracking-tight);
  color: var(--text);
}
/* lead line ("4 AIs") — emphasize via the first span if present */
.video-intro p:first-of-type { /* keep flexible; JS controls copy */ }
.video-intro span {
  font-family: var(--font-mono);
  font-size: clamp(16px, 2.1svh, var(--fs-sub));
  font-weight: var(--fw-medium);
  color: var(--muted);
}

/* ============================================================
   CHART STAGE  —  chart is the hero (~58% of height)
   ============================================================ */
.video-stage {
  display: grid;
  grid-template-rows: auto auto 1040px auto;  /* header · leader · CHART · context */
  gap: var(--sp-4);
  padding: var(--safe-top) var(--safe-x) var(--safe-bottom);
}

.video-hook {
  text-align: center;
}

.video-kicker {
  justify-self: center;
  font-family: var(--font-mono);
  font-size: var(--fs-eyebrow);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--accent-soft);
  text-align: center;
}
.video-kicker > span:first-child { color: #5E5C55; }
.video-kicker-fif { color: var(--accent-soft); }
.video-kicker-a {
  display: inline-block;
  background: linear-gradient(135deg, var(--m-gpt) 0%, var(--m-gemini) 48%, var(--m-grok) 100%);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
}
.video-kicker-i { color: var(--accent-cyan); }
/* compact hook title sits with the kicker block; keep it small so the
   chart keeps the space. If your markup lacks an <h1>, add one or let
   the kicker carry the title. */
.video-stage h1 {
  margin: 8px auto 0;
  max-width: none;
  font-size: var(--fs-title);
  font-weight: var(--fw-heavy);
  letter-spacing: var(--tracking-tight);
  line-height: 1.02;
  text-align: center;
  color: var(--text);
}
.video-hook p {
  margin: 18px 0 0;
  font-family: var(--font-mono);
  font-size: var(--fs-sub);
  font-weight: var(--fw-medium);
  color: var(--muted);
}

/* Leader strip — compact broadcast lower-third */
.video-leader-badge {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 14px 28px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--panel-strong);
  color: var(--muted);
  font-size: var(--fs-leader);
  font-weight: var(--fw-bold);
}
.video-leader-badge > span:first-child {
  font-family: var(--font-mono);
  font-size: 24px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--subtle);
}
.video-leader-badge i {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--model-accent, var(--accent-soft));
  box-shadow: 0 0 22px var(--model-accent, var(--accent-soft));
}
.video-leader-badge strong { color: var(--text); }
.video-leader-badge b {
  color: var(--model-accent, var(--accent-cyan));
  font-family: var(--font-mono);
  font-size: var(--fs-leader);
  font-weight: var(--fw-heavy);
  font-variant-numeric: tabular-nums;
}
.video-leader-badge em {
  align-self: flex-end;
  padding-bottom: 6px;
  color: var(--subtle);
  font-family: var(--font-mono);
  font-size: 22px;
  font-style: normal;
}
.video-leader-badge.is-changing { animation: leader-pop 560ms ease; }

/* THE CHART */
.video-chart {
  min-height: 0;                 /* allow the 1fr row to shrink */
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(20,22,38,0.6), rgba(11,11,20,0.5));
  overflow: hidden;
}
.video-race-svg,
.video-chart-canvas { display: block; width: 100%; height: 100%; }
.race-chart-bg { fill: transparent; }
.race-y-tick line { stroke: var(--chart-grid); stroke-width: 1; }
.race-y-tick text,
.race-x-tick text {
  fill: rgba(255,255,255,0.32);
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: var(--fw-medium);
}
.race-axis { stroke: rgba(255,255,255,0.12); stroke-width: 1; }

.video-line {
  stroke-width: var(--chart-line-w);
  stroke-linejoin: round;
  stroke-linecap: round;
  filter: drop-shadow(0 0 10px currentColor);
}
.video-line-label line { stroke: var(--model-accent); stroke-width: 2; stroke-opacity: 0.5; }
.video-line-label circle { fill: var(--model-accent); stroke: #0B0B14; stroke-width: 4; }
.video-line-label text {
  fill: var(--text);
  font-family: var(--font-sans);
  font-size: 25px;
  font-weight: var(--fw-bold);
}
.video-line-label tspan + tspan {
  fill: var(--model-accent);
  font-family: var(--font-mono);
  font-weight: var(--fw-heavy);
  font-size: 30px;
}

/* Match context — secondary to the chart, single compact strip + chips */
.video-match-panel {
  display: grid;
  gap: var(--sp-3);
}
.video-match-panel > div:first-child,
.video-match-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  min-width: 0;
  text-align: center;
}
.video-match-panel strong {
  font-family: var(--font-mono);
  font-size: var(--fs-match-meta);
  font-weight: var(--fw-bold);
  color: var(--muted);
  letter-spacing: 0.04em;
}
.video-match-panel span {
  font-family: var(--font-mono);
  font-size: var(--fs-match);
  font-weight: var(--fw-heavy);
  color: var(--accent-cyan);
  font-variant-numeric: tabular-nums;
}
.video-match-panel span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.video-delta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-2);
  margin: 0;
}
.video-delta-grid div {
  min-width: 0;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--model-accent);
  border-radius: var(--radius);
  background: var(--panel);
}
.video-delta-grid div.is-highlight { animation: highlight-pulse 700ms ease; }
.video-delta-grid dt {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-dim);
  font-size: var(--fs-chip-name);
  font-weight: var(--fw-bold);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.video-delta-grid dt i {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--model-accent);
}
.video-delta-grid dd {
  margin: 6px 0 0;
  font-family: var(--font-mono);
  font-size: var(--fs-chip-val);
  font-weight: var(--fw-heavy);
  font-variant-numeric: tabular-nums;
  color: var(--neutral);
}
.video-delta-grid dd span {
  display: block;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 19px;
  font-weight: var(--fw-medium);
}

/* ============================================================
   FINAL  —  polished end card (full-bleed, staged reveal)
   ============================================================ */
.video-final {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: var(--sp-5);
  padding: 0 9%;
  text-align: center;
  background: none;
  border: none;
  box-shadow: none;
}

/* Stage 1 — always visible when final card is shown */
.video-final-s1 {
  display: grid;
  justify-items: center;
  gap: var(--sp-3);
  width: 100%;
}
.video-final-s1 small {
  color: var(--accent-soft);
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: var(--fw-bold);
  letter-spacing: .2em;
  text-transform: uppercase;
}
.video-final-leader-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin: 0;
  font-size: var(--fs-final-name);
  font-weight: var(--fw-heavy);
  letter-spacing: var(--tracking-tight);
  line-height: 1.04;
  color: var(--text);
}
.video-final-leader-line i {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent-soft);
  box-shadow: 0 0 36px currentColor;
}
.video-final-s1 b {
  color: var(--text-dim);
  font-size: 58px;
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-tight);
}
.video-final-score {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 14px;
}
.video-final-pts-num {
  font-family: var(--font-mono);
  font-size: var(--fs-final-pts);
  font-weight: var(--fw-black);
  letter-spacing: var(--tracking-tight);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  /* color set via JS to leader accent */
}
.video-final-pts-word {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 46px;
  font-weight: var(--fw-medium);
  padding-bottom: 10px;
  line-height: 1;
}

/* Stage 2 — CTA, fades in after ~1s */
.video-final-s2 {
  display: grid;
  justify-items: center;
  gap: var(--sp-3);
  width: 100%;
  transition: opacity 300ms ease;
}
.video-final-s2[data-visible="false"] { opacity: 0; pointer-events: none; }
.video-final-s2[data-visible="true"]  { opacity: 1; }
.video-final-cta-label {
  color: var(--text-dim);
  font-size: 42px;
  font-weight: var(--fw-medium);
}
.video-final-url {
  font-style: normal;
  padding: 22px 40px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, var(--accent), var(--accent-soft));
  box-shadow: var(--glow-accent);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 46px;
  font-weight: var(--fw-heavy);
}

/* Stage 3 — Touchline attribution, fades in ~300ms after CTA */
.video-final-s3 {
  display: grid;
  justify-items: center;
  gap: 18px;
  width: 100%;
  transition: opacity 300ms ease;
}
.video-final-s3[data-visible="false"] { opacity: 0; pointer-events: none; }
.video-final-s3[data-visible="true"]  { opacity: 1; }
.video-touchline-from {
  margin: 0;
  color: var(--subtle);
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: var(--fw-bold);
  letter-spacing: .18em;
  text-transform: uppercase;
}
.video-touchline-brand {
  display: flex;
  align-items: center;
  gap: 18px;
  justify-content: center;
}
.video-touchline-icon {
  width: 100px;
  height: 100px;
  flex: 0 0 auto;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}
.video-touchline-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  text-align: left;
}
.video-touchline-text strong {
  color: var(--text-dim);
  font-family: var(--font-sans);
  font-size: 36px;
  font-weight: var(--fw-bold);
}
.video-touchline-text span {
  color: var(--subtle);
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: var(--fw-medium);
}

.video-final button {
  min-height: 64px;
  padding: 0 26px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #F8FAFC;
  color: #09090E;
  cursor: pointer;
  font-weight: var(--fw-heavy);
}

/* ---- Navigation chrome ---- */
.video-back-link {
  position: absolute;
  left: var(--safe-x);
  bottom: 22px;
  color: var(--subtle);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: var(--fw-medium);
  text-decoration: none;
  z-index: 20;
  transition: color 160ms ease;
}
.video-back-link:hover,
.video-back-link:focus-visible {
  color: var(--muted);
}
.video-back-link:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.4);
  outline-offset: 3px;
  border-radius: 3px;
}

/* ---- Playback chrome (hide before exporting frames) ---- */
.video-shortcuts {
  position: absolute;
  right: var(--safe-x);
  bottom: 22px;
  display: flex;
  gap: 10px;
  color: var(--subtle);
  font-family: var(--font-mono);
  font-size: 13px;
  z-index: 20;
}

.video-progress {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.06);
  z-index: 18;
}
.video-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-cyan));
}

@keyframes leader-pop {
  0%, 100% { transform: scale(1); }
  45%      { transform: scale(1.05); border-color: rgba(248,250,252,0.5); }
}
@keyframes highlight-pulse {
  0%, 100% { background: var(--panel); }
  38%      { background: color-mix(in srgb, var(--model-accent) 22%, var(--panel)); }
}

@media (prefers-reduced-motion: reduce) {
  .video-intro, .video-stage, .video-final,
  .video-leader-badge, .video-delta-grid div, .video-line {
    animation: none !important;
    transition: none !important;
  }
}
