/* vizmaya story formats: recap@1.css. Source: packages/html-stories/formats. */
/*
 * Shared by every format stylesheet (book@1.css, board@1.css, deck@1.css
 * start with this). The runtime adds html.js and html.vz-on plus the
 * format's own class (html.book-on, html.board-on, html.deck-on) when it
 * takes the page over; without them, the same content reads as one column.
 *
 * Tokens the controls use, set from the page's vizmaya:theme by the runtime
 * (override any of them in your own :root): --vz-bg --vz-surface --vz-text
 * --vz-muted --vz-line --vz-accent. --vz-chrome-h is the site header's
 * height, which the site sets as --vizmaya-chrome-h.
 */
:where(:root) { --vz-chrome-h: var(--vizmaya-chrome-h, 64px) }
@media (max-width: 480px) { :where(:root) { --vz-chrome-h: var(--vizmaya-chrome-h, 56px) } }

/* A chart that drew nothing (no JS, or it failed) shows its data-alt text. */
:where(.chart:empty)::before { content: attr(data-alt); display: block; font-style: italic; font-size: 15px; line-height: 1.45; opacity: .75 }
html:not(.js) .chart { height: auto !important; aspect-ratio: auto !important }
html:not(.vz-on) .vz-only { display: none !important }

.vz-btn {
  appearance: none; -webkit-appearance: none; margin: 0; box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 40px; min-width: 40px; padding: 0 12px; border-radius: 20px; cursor: pointer;
  border: 1px solid var(--vz-line, rgba(127, 127, 127, .35)); background: var(--vz-surface, #111820); color: var(--vz-text, #e0ddd5);
  font: inherit; font-size: 14px; line-height: 1; white-space: nowrap;
}
.vz-btn:hover { border-color: var(--vz-muted, #5a6a70) }
.vz-btn:disabled { opacity: .35; cursor: default }
.vz-btn[hidden] { display: none }
.vz-btn:focus-visible, .vz-seg button:focus-visible { outline: 2px solid var(--vz-accent, #D85A30); outline-offset: 2px }
.vz-btn.vz-primary { background: var(--vz-accent, #D85A30); border-color: var(--vz-accent, #D85A30); color: var(--vz-bg, #0a0e14); font-weight: 600 }
.vz-i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round }

.vz-controls {
  position: relative; z-index: 5; flex: none; box-sizing: border-box;
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px;
  padding: 10px 16px 14px; font-size: 14px; color: var(--vz-muted, #5a6a70);
}
.vz-where { min-width: 132px; text-align: center; font-variant-numeric: tabular-nums; color: var(--vz-text, #e0ddd5); opacity: .8 }
.vz-sep { flex: 0 0 1px; height: 22px; background: var(--vz-line, rgba(127, 127, 127, .35)); margin: 0 4px }
.vz-hint {
  position: absolute; left: 50%; top: 18px; z-index: 11; transform: translate(-50%, -8px); opacity: 0; pointer-events: none;
  padding: 8px 14px; border-radius: 18px; font-size: 14px; white-space: nowrap;
  background: var(--vz-surface, #111820); color: var(--vz-text, #e0ddd5); border: 1px solid var(--vz-line, rgba(127, 127, 127, .35));
  transition: opacity .25s, transform .25s;
}
.vz-hint.vz-show { opacity: 1; transform: translate(-50%, 0) }
/* Labels that fold away on phones stay readable to screen readers. */
@media (max-width: 560px) {
  .vz-controls { gap: 6px; padding-left: 8px; padding-right: 8px }
  .vz-controls .vz-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap }
  .vz-where { min-width: 64px }
}
/* The one-page view keeps the controls at the bottom of the screen. */
html.js:not(.vz-on) .vz-controls {
  position: sticky; bottom: 0; padding-top: 24px;
  background: linear-gradient(transparent, var(--vz-bg, #0a0e14) 40%);
}
@media (prefers-reduced-motion: reduce) { .vz-hint { transition: none } }

/*
 * vizmaya recap format, v1. Pair with recap@1.js.
 *
 * html.recap-on: the race replay stays on screen beside the chapters (above
 * them on phones) while the page scrolls; the chapter being read is lit, the
 * rest dim. Otherwise (no JS, or "Read as one page"): the chapters as one
 * column, no replay.
 *
 * Tokens (set them in your own :root):
 *   --recap-rail-w     width of the chapter column on wide screens (default 44%)
 *   --recap-band-h     height of the replay above the chapters on phones (40svh)
 *   --recap-dim        opacity of the chapters you aren't reading (.32)
 *   --recap-cue        the mark beside the cue in charge (your accent)
 */
:where(:root) {
  --recap-rail-w: 44%;
  --recap-band-h: 40svh;
  --recap-dim: .32;
  --recap-cue: var(--vz-accent, #ff4346);
}

/* ── Without the runtime (or "Read as one page"): one column ───────────── */
html:not(.recap-on) .stage > .replay { display: none }
html:not(.recap-on) .stage > .chapters { max-width: 760px; margin: 0 auto; padding: 0 20px 64px }
html:not(.recap-on) .chapter + .chapter { margin-top: 56px }

/* ── The recap ───────────────────────────────────────────────────────── */
html.recap-on .stage {
  display: grid; grid-template-columns: minmax(0, 1fr) var(--recap-rail-w);
  grid-template-rows: auto 1fr; align-items: start;
  max-width: none; margin: 0; padding: 0;
}
html.recap-on .stage > .replay {
  grid-column: 1; grid-row: 1 / span 2; position: sticky; top: var(--vz-chrome-h); z-index: 2;
  height: calc(100svh - var(--vz-chrome-h)); min-height: 420px; overflow: hidden;
  background: #101216; border-right: 1px solid var(--vz-line, rgba(127, 127, 127, .25));
}
.vz-replay-frame { display: block; width: 100%; height: 100%; border: 0 }
html.recap-on .stage > .chapters { grid-column: 2; grid-row: 2; box-sizing: border-box; padding: 0 clamp(20px, 3.6vw, 56px) 46svh; min-width: 0 }
html.recap-on .chapter {
  box-sizing: border-box; min-height: 72svh; padding-top: 10svh;
  opacity: var(--recap-dim); transition: opacity .45s;
}
html.recap-on .chapter.vz-cur { opacity: 1 }
html.recap-on .chapter .vz-cue-on:not(.chapter) { box-shadow: -14px 0 0 -11px var(--recap-cue) }

/* Chapter nav: sticky at the top of the chapter column. */
.vz-recap-nav {
  display: flex; align-items: center; gap: 10px; box-sizing: border-box;
  padding: 10px clamp(20px, 3.6vw, 56px); font-size: 13px; color: var(--vz-muted, #8e8e99);
}
html.recap-on .vz-recap-nav {
  grid-column: 2; grid-row: 1; position: sticky; top: var(--vz-chrome-h); z-index: 3;
  background: linear-gradient(var(--vz-bg, #0b0d12) 70%, transparent);
}
.vz-recap-nav ol {
  display: flex; gap: 4px; margin: 0; padding: 2px; list-style: none; flex: 1; min-width: 0;
  overflow-x: auto; scrollbar-width: none;
}
.vz-recap-nav ol::-webkit-scrollbar { display: none }
.vz-recap-nav ol button {
  appearance: none; display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; border: 0; border-radius: 17px;
  background: transparent; color: inherit; font: inherit; white-space: nowrap; cursor: pointer;
}
.vz-recap-nav ol button:hover { color: var(--vz-text, #f5f5f5) }
.vz-recap-nav ol button[aria-current] { background: var(--vz-surface, #13161d); color: var(--vz-text, #f5f5f5); box-shadow: inset 0 -2px 0 var(--vz-accent, #ff4346) }
.vz-recap-nav ol button:focus-visible { outline: 2px solid var(--vz-accent, #ff4346); outline-offset: 2px }
.vz-recap-nav .vz-n { font-variant-numeric: tabular-nums; opacity: .7 }
.vz-recap-nav .vz-count { display: none; font-variant-numeric: tabular-nums; color: var(--vz-text, #f5f5f5) }
/* The one-page view keeps only the mode button. */
html:not(.recap-on) .vz-recap-nav { justify-content: flex-end; max-width: 760px; margin: 0 auto; padding: 12px 20px }
html:not(.recap-on) .vz-recap-nav ol, html:not(.recap-on) .vz-recap-nav .vz-count { display: none }

/* Narrow screens: replay band on top, chapters scroll under it. */
@media (max-width: 900px) {
  html.recap-on .stage { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto 1fr }
  html.recap-on .stage > .replay {
    grid-column: 1; grid-row: 1; height: var(--recap-band-h); min-height: 240px;
    border-right: 0; border-bottom: 1px solid var(--vz-line, rgba(127, 127, 127, .25));
  }
  html.recap-on .vz-recap-nav { grid-column: 1; grid-row: 2; top: calc(var(--vz-chrome-h) + max(var(--recap-band-h), 240px)); padding: 8px 16px }
  html.recap-on .vz-recap-nav ol { display: none }
  html.recap-on .vz-recap-nav .vz-count { display: inline; flex: 1 }
  html.recap-on .stage > .chapters { grid-column: 1; grid-row: 3; padding: 0 18px 40svh }
  html.recap-on .chapter { min-height: 52svh; padding-top: 5svh }
}
@media (max-width: 560px) {
  .vz-recap-nav .vz-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap }
}
@media (prefers-reduced-motion: reduce) { html.recap-on .chapter { transition: none } }
