@font-face {
  font-family: "Inter";
  src: url("../../pages/fonts/Inter-Variable.ttf");
  font-weight: 100 900;
}
@font-face {
  font-family: "Plex Mono";
  src: url("../../pages/fonts/IBMPlexMono-Regular.ttf");
}
@font-face {
  font-family: "Garamond";
  src: url("../../pages/fonts/EBGaramond-Variable.ttf");
  font-weight: 400 800;
}

:root {
  --black: #09090b;
  --ink: #fafafa;
  --film-muted: #a1a1aa;
  --film-border: #27272a;
  --white: #ffffff;
  --white-ink: #09090b;
  --white-border: #e4e4e7;
  --film-accent: oklch(0.62 0.21 264);
  --film-accent-soft: oklch(0.75 0.14 264);
  --grey: #52525b;
  --stage-width: 1280px;
  --stage-height: 720px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: #18181b;
  color: var(--ink);
  font: 14px/1.4 "Inter", sans-serif;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 16px;
  min-height: 100vh;
}

/* The film: a fixed 1280 by 720 layout, scaled to fit the window. */
.stage-frame {
  width: 100%;
  display: flex;
  justify-content: center;
}

.stage-scaler {
  width: calc(var(--stage-width) * var(--fit, 1));
  height: calc(var(--stage-height) * var(--fit, 1));
}

.stage {
  position: relative;
  width: var(--stage-width);
  height: var(--stage-height);
  overflow: hidden;
  background: var(--black);
  transform: scale(var(--fit, 1));
  transform-origin: 0 0;
}

/* The picture area. The browser window of beats 3 to 10 shrinks it. */
.viewport {
  position: absolute;
  overflow: hidden;
  background: var(--black);
}

.scene {
  position: absolute;
  inset: 0;
  display: none;
  overflow: hidden;
}

.scene.is-current { display: block; }

.mono { font-family: "Plex Mono", monospace; }

/* Corner label: same place in every beat. */
.corner-label {
  position: absolute;
  top: 18px;
  right: 22px;
  padding: 4px 10px;
  border: 1px solid var(--film-border);
  border-radius: 999px;
  font: 15px/1.3 "Plex Mono", monospace;
  color: var(--ink);
  background: rgb(9 9 11 / 0.6);
}

.on-light .corner-label {
  border-color: var(--white-border);
  color: var(--white-ink);
  background: rgb(255 255 255 / 0.7);
}

/* Beat 1: format badges. */
.scene-formats { background: var(--black); }

.badge-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(4, 180px);
  gap: 22px;
  align-content: center;
  justify-content: center;
}

.format-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 84px;
  border: 1px solid var(--film-border);
  border-radius: 12px;
  background: #18181b;
  font: 34px/1 "Plex Mono", monospace;
  color: var(--ink);
}

.format-badge:nth-child(1) { color: oklch(0.75 0.17 30); }
.format-badge:nth-child(2) { color: oklch(0.78 0.16 70); }
.format-badge:nth-child(3) { color: oklch(0.75 0.15 150); }
.format-badge:nth-child(4) { color: oklch(0.75 0.13 230); }
.format-badge:nth-child(5) { color: oklch(0.72 0.17 290); }
.format-badge:nth-child(6) { color: oklch(0.75 0.17 340); }
.format-badge:nth-child(7) { color: oklch(0.85 0.05 260); }

/* Beat 2: the first web page. */
.scene-first-page {
  background: var(--white);
  color: #000;
  font-family: "Garamond", serif;
}

.first-page {
  position: absolute;
  left: 90px;
  top: 70px;
  width: 640px;
  font-size: 22px;
  line-height: 1.35;
}

.first-page h1 {
  font-size: 44px;
  font-weight: 700;
  margin: 0 0 18px;
}

.first-page a { color: #0000ee; text-decoration: underline; }
.first-page p { margin: 0 0 14px; }

.year {
  position: absolute;
  right: 90px;
  top: 250px;
  font: 600 150px/1 "Inter", sans-serif;
  letter-spacing: -0.04em;
  color: var(--white-ink);
  font-variant-numeric: tabular-nums;
}

.year-caption {
  position: absolute;
  right: 94px;
  top: 410px;
  font: 18px/1.3 "Plex Mono", monospace;
  color: #71717a;
}

/* Beat 3: the bet. */
.scene-bet { background: var(--film-accent); }

.bet-line {
  position: absolute;
  left: 80px;
  right: 80px;
  top: 220px;
  font: 800 92px/1.02 "Inter", sans-serif;
  letter-spacing: -0.035em;
  color: var(--white);
}

.bet-label {
  position: absolute;
  left: 84px;
  top: 180px;
  padding: 3px 10px;
  border: 1px solid rgb(255 255 255 / 0.5);
  border-radius: 999px;
  font: 16px/1.3 "Plex Mono", monospace;
  color: var(--white);
}

/* Beat 4: titles. */
.scene-titles { background: var(--black); }

.title-words {
  position: absolute;
  left: 80px;
  right: 80px;
  top: 230px;
  font: 800 120px/1 "Inter", sans-serif;
  letter-spacing: -0.045em;
}

.title-words span { display: inline-block; margin-right: 0.22em; }

/* Beat 5: motion. */
.scene-motion { background: var(--white); color: var(--white-ink); }

.card-grid {
  position: absolute;
  left: 170px;
  top: 150px;
  display: grid;
  grid-template-columns: repeat(3, 280px);
  gap: 24px;
}

.motion-card {
  height: 170px;
  border: 1px solid var(--white-border);
  border-radius: 12px;
  background: var(--white);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 8px 24px rgb(0 0 0 / 0.06);
  padding: 18px;
}

.motion-card b { display: block; font-size: 17px; font-weight: 600; }
.motion-card i {
  display: block;
  margin-top: 10px;
  height: 10px;
  border-radius: 5px;
  background: #f4f4f5;
}
.motion-card i + i { width: 60%; }

.motion-curve {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Beat 6 and the shader tile of beat 9. */
.shader-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Beat 7 and 8: the voice. */
.scene-voice { background: var(--black); }

.waveform {
  position: absolute;
  left: 60px;
  right: 60px;
  top: 190px;
  height: 260px;
}

.waveform svg { position: absolute; inset: 0; width: 100%; height: 100%; }

/* Each bar is drawn once: grey until the playhead passes it. */
.waveform rect { fill: #3f3f46; }
.waveform rect.waveform-played { fill: oklch(0.75 0.14 264); }

.waveform-playhead {
  position: absolute;
  top: -30px;
  bottom: -30px;
  width: 2px;
  background: var(--ink);
}

/* Beat 9: more than a video. */
.scene-media { background: #f4f4f5; }

.media-page {
  position: absolute;
  left: 40px;
  top: 30px;
  width: 1120px;
  height: 450px;
  transform-origin: 50% 50%;
}

.media-page-outline {
  position: absolute;
  inset: -18px;
  border: 1px solid #d4d4d8;
  border-radius: 14px;
  background: var(--white);
  opacity: 0;
}

.media-tiles {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 16px;
}

.media-tile {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
}

.tile-name {
  position: absolute;
  left: 14px;
  bottom: 12px;
  font: 14px/1 "Plex Mono", monospace;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.55);
  color: var(--white);
}

.tile-slides { background: var(--white); border: 1px solid var(--white-border); color: var(--white-ink); padding: 28px 32px; }
.tile-slides h2 { margin: 0 0 12px; font-size: 34px; letter-spacing: -0.03em; }
.tile-slides li { font-size: 18px; color: #52525b; margin: 4px 0; }
.tile-vector { background: oklch(0.86 0.12 95); }
.tile-mixer { background: #18181b; }
.tile-mixer canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

.quote {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 150px;
  background: rgb(9 9 11 / 0.92);
  color: var(--ink);
  opacity: 0;
}

.quote blockquote {
  margin: 0;
  font: 500 52px/1.12 "Inter", sans-serif;
  letter-spacing: -0.03em;
}

.quote cite {
  margin-top: 26px;
  font: normal 20px/1 "Plex Mono", monospace;
  color: var(--film-muted);
}

/* Beat 10: the catch. */
.scene-catch { background: #3f3f46; }

.api-chip {
  position: absolute;
  padding: 10px 18px;
  border: 1px solid #71717a;
  border-radius: 12px;
  background: #27272a;
  font: 30px/1 "Plex Mono", monospace;
  color: var(--ink);
}

/* Beat 11 and 12: frames. */
.scene-frames { background: var(--white); color: var(--white-ink); }

.frame-strip {
  position: absolute;
  left: 0;
  top: 210px;
  display: flex;
  gap: 18px;
  /* The current thumb's centre is the stage's: (1280 - 300) / 2. */
  padding-left: 490px;
}

.frame-thumb {
  flex: none;
  width: 300px;
}

.frame-thumb-picture {
  height: 169px;
  border-radius: 8px;
  border: 1px solid var(--white-border);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 600 22px/1.1 "Inter", sans-serif;
  text-align: center;
  padding: 10px;
}

.frame-thumb-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font: 14px/1 "Plex Mono", monospace;
  color: #71717a;
}

.frame-counter {
  position: absolute;
  left: 0;
  right: 0;
  top: 470px;
  text-align: center;
  font: 600 72px/1 "Plex Mono", monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.frame-caption {
  position: absolute;
  left: 0;
  right: 0;
  top: 570px;
  text-align: center;
  font: 20px/1 "Plex Mono", monospace;
  color: #52525b;
  opacity: 0;
}

.frame-cursor {
  position: absolute;
  left: 486px;
  /* 4 px around the current thumb's picture (210 px down, 300 x 169). */
  top: 206px;
  width: 308px;
  height: 177px;
  border: 2px solid var(--film-accent);
  border-radius: 10px;
}

/* Beat 13: one page, four shapes. */
.scene-shapes { background: #f4f4f5; }

.shape-row {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 34px;
}

.shape {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.shape-name {
  font: 15px/1 "Plex Mono", monospace;
  color: #52525b;
}

.shape-page {
  container-type: size;
  position: relative;
  overflow: hidden;
  border: 1px solid #d4d4d8;
  border-radius: 8px;
  background: var(--black);
  color: var(--ink);
}

.shape-video { width: 420px; height: 236px; }
.shape-portrait { width: 150px; height: 267px; }
.shape-still { width: 236px; height: 236px; background: var(--film-accent); }
.shape-document { width: 189px; height: 267px; background: var(--white); color: var(--white-ink); }

.shape-card {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 8%;
  padding: 9%;
}

.shape-card h3 {
  margin: 0;
  font: 800 34px/0.98 "Inter", sans-serif;
  letter-spacing: -0.04em;
}

.shape-card p { margin: 6px 0 0; font-size: 11px; color: inherit; opacity: 0.7; }

.shape-card .shape-art {
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(from 40deg in oklch, oklch(0.75 0.17 30), oklch(0.75 0.15 150), oklch(0.72 0.17 290), oklch(0.75 0.17 30));
}

@container (max-width: 260px) {
  .shape-card { grid-template-columns: 1fr; align-content: center; gap: 12px; }
  .shape-card h3 { font-size: 24px; }
  .shape-card .shape-art { width: 60%; }
}

/* Beat 14: end card. */
.scene-end { background: var(--black); }

.end-line {
  position: absolute;
  left: 100px;
  right: 100px;
  top: 220px;
  font: 700 76px/1.05 "Inter", sans-serif;
  letter-spacing: -0.04em;
}

.end-address {
  position: absolute;
  left: 104px;
  top: 470px;
  font: 24px/1.3 "Plex Mono", monospace;
  color: var(--film-accent-soft);
}

.end-credit {
  position: absolute;
  left: 104px;
  top: 520px;
  font: 16px/1.3 "Plex Mono", monospace;
  color: var(--film-muted);
}

/* The browser window of beats 3 to 10, drawn over the picture. */
.window {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.window-outline { position: absolute; inset: 0; width: 100%; height: 100%; }

.window-bar {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  background: #18181b;
  border-bottom: 1px solid var(--film-border);
  border-radius: 12px 12px 0 0;
}

.window-dots { display: flex; gap: 7px; }
.window-dots i { width: 11px; height: 11px; border-radius: 50%; background: #3f3f46; }

.window-address {
  flex: 1;
  height: 26px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 7px;
  background: #27272a;
  font: 14px/1 "Plex Mono", monospace;
  color: var(--film-muted);
  overflow: hidden;
  white-space: nowrap;
}

/* The caption of the narration, and the transport bar in the film. */
.caption {
  position: absolute;
  left: 140px;
  right: 140px;
  bottom: 44px;
  text-align: center;
  font: 500 26px/1.3 "Inter", sans-serif;
  color: var(--white);
  text-shadow: 0 1px 2px rgb(0 0 0 / 0.9), 0 0 18px rgb(0 0 0 / 0.6);
}

.caption.caption-on-light {
  color: var(--white-ink);
  text-shadow: 0 0 2px rgb(255 255 255 / 0.9), 0 0 16px rgb(255 255 255 / 0.9);
}

.film-transport {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 14px;
  height: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font: 12px/1 "Plex Mono", monospace;
  color: var(--film-muted);
  font-variant-numeric: tabular-nums;
}

.film-track {
  position: relative;
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: rgb(255 255 255 / 0.2);
}

.film-track-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 2px;
  background: var(--ink);
}

/* A frame host captures the film alone. */
.film-only body { padding: 0; display: block; min-height: 0; }
.film-only .player,
.film-only .player-status,
.film-only .sandom-view,
.film-only .compare-divider { display: none; }

/* Sandom's rendering of the film lies over the browser's, at the stage's
   scaled size. In the comparison it shows right of the divider. */
.stage-scaler { position: relative; }
.sandom-view,
.compare-divider { position: absolute; }
.sandom-view { inset: 0; width: 100%; height: 100%; }
.sandom-view.comparing { cursor: ew-resize; }
.sandom-view[hidden],
.compare-divider[hidden] { display: none; }
.compare-divider {
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: #fafafa;
  pointer-events: none;
}

/* The player: Deck UI controls outside the film. Deck's tokens style
   them in their dark theme. */
.player,
.player-status {
  color-scheme: dark;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(1280px, 100%);
  box-sizing: border-box;
  font-family: var(--font-sans);
  color: var(--foreground);
}

.player {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
}

.player deck-slider { flex: 1; }
.player deck-separator { align-self: stretch; }
.player-status { min-height: 20px; padding: 0 12px; }
.player-status deck-progress { width: 240px; }
.player-status deck-progress[hidden] { display: none; }

.player output,
.player-status output {
  font: 13px/1 var(--font-mono);
  color: var(--muted-foreground);
  font-variant-numeric: tabular-nums;
}
.player output { min-width: 120px; text-align: right; }
.player-status output[hidden] { display: none; }
