/* style.css
   AFS demo. An engineering specimen — warm paper background,
   editorial serif for headlines, monospace for the technical bits.
   Mobile-first, light/dark aware. */

/* -----------------------------------------------------------------------
   Tokens
   ----------------------------------------------------------------------- */

:root {
  /* Typography */
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Hanken Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Spacing scale (eight-step rhythm, in rem) */
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 0.75rem;
  --s-4: 1rem;
  --s-5: 1.5rem;
  --s-6: 2rem;
  --s-7: 3rem;
  --s-8: 4rem;
  --s-9: 6rem;

  /* Colors — light */
  --bg: #f5f1e8;
  --bg-elevated: #fbf8ef;
  --fg: #14140e;
  --fg-dim: #6b665a;
  --fg-muted: #9a9587;
  --rule: #d6cfbc;
  --rule-soft: #e6e1d2;
  --accent: #0d3b8c;
  --accent-hover: #1247a8;
  --accent-fg: #fbf8ef;
  --accent-soft: rgba(13, 59, 140, 0.08);
  --status-ok: #1e7a4a;
  --status-warn: #b25e08;
  --status-error: #a83232;
  --subtitle-bg: rgba(20, 20, 14, 0.85);
  --subtitle-fg: #fbf8ef;

  /* Pre-aliases kept for backwards compatibility with app.js */
  --border: var(--rule);
  --accent-soft-bg: var(--accent-soft);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14130e;
    --bg-elevated: #1c1a14;
    --fg: #ebe5d3;
    --fg-dim: #95907f;
    --fg-muted: #5d594d;
    --rule: #2c2a22;
    --rule-soft: #1e1c16;
    --accent: #79a8ff;
    --accent-hover: #9bbeff;
    --accent-fg: #14130e;
    --accent-soft: rgba(121, 168, 255, 0.12);
    --status-ok: #4ac483;
    --status-warn: #e09446;
    --status-error: #d36868;
    --subtitle-bg: rgba(0, 0, 0, 0.85);
  }
}

/* -----------------------------------------------------------------------
   Reset + base
   ----------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; }

body {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 1rem;
  line-height: 1.55;
  background: var(--bg);
  color: var(--fg);
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body::before {
  /* Hairline left margin on wide viewports, doubling as a print-style
     "binding edge". Adds editorial structure without an explicit grid. */
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 1px;
  background: var(--rule);
  z-index: 1;
  pointer-events: none;
  opacity: 0;
}

@media (min-width: 980px) {
  body::before { opacity: 0.6; }
}

main {
  max-width: 1040px;
  margin: 0 auto;
  padding: var(--s-4) var(--s-4) var(--s-6);
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

::selection {
  background: var(--accent);
  color: var(--accent-fg);
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 150ms ease, color 150ms ease;
}

a:hover {
  border-bottom-color: currentColor;
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 1px;
}

/* -----------------------------------------------------------------------
   Header — single horizontal row: wordmark · tagline+lede · links
   ----------------------------------------------------------------------- */

header {
  max-width: 1040px;
  margin: 0 auto;
  padding: var(--s-4) var(--s-4) var(--s-3);
  border-bottom: 1px solid var(--rule);
}

.masthead {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.masthead-top {
  display: flex;
  align-items: baseline;
  gap: var(--s-5);
  flex-wrap: wrap;
}

.masthead-top .tagline {
  flex: 1 1 auto;
  min-width: 0;
}

.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: var(--s-2);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.25rem, 5vw, 3rem);
  line-height: 0.9;
  letter-spacing: -0.02em;
  font-variation-settings: "opsz" 144, "SOFT" 30;
  /* The wordmark is now an anchor that links home — kill the
     default underline + inherit color so it doesn't look like a
     regular link. */
  color: inherit;
  text-decoration: none;
}
.wordmark:hover .wordmark-letters {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 6px;
}

.wordmark-sigil {
  display: inline-block;
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 0.55em;
  line-height: 1;
  color: var(--accent);
  transform: translateY(-0.15em);
}

.wordmark-letters {
  font-feature-settings: "ss01" on;
}

.masthead-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.tagline {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1rem;
  line-height: 1.25;
  letter-spacing: -0.005em;
  color: var(--fg);
  margin: 0;
  font-variation-settings: "opsz" 36, "SOFT" 60;
}

.tagline em {
  font-style: italic;
  font-variation-settings: "opsz" 36, "SOFT" 100;
  color: var(--accent);
}

.lede {
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--fg-dim);
  margin: 0;
}

.lede em {
  font-style: italic;
  color: var(--fg);
}

.masthead-links {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--fg);
  margin: 0;
  white-space: nowrap;
}

.masthead-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  color: inherit;
  text-decoration: none;
  padding: 0.4em 0.85em;
  border: 1px solid var(--rule);
  border-radius: 999px;
  transition: border-color 150ms ease, color 150ms ease, background-color 150ms ease;
}

.masthead-links a:hover,
.masthead-links a:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
}

.masthead-links .gh-icon {
  width: 1.05em;
  height: 1.05em;
  flex: none;
}

/* -----------------------------------------------------------------------
   Tabs — plain text with accent underline on the active one
   ----------------------------------------------------------------------- */

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-5);
  padding: 0;
  margin: 0;
  border-bottom: 1px solid var(--rule);
}

.tab {
  padding: var(--s-2) 0;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: transparent;
  color: var(--fg-dim);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: -0.005em;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none; /* tabs are <a>s — kill the default underline */
  transition: color 120ms ease, border-color 120ms ease;
}

.tab:hover:not(.active) {
  color: var(--fg);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

@media (max-width: 520px) {
  .tabs {
    gap: var(--s-4);
  }
  .tab {
    font-size: 0.875rem;
  }
}

/* -----------------------------------------------------------------------
   Status — a quiet terminal line
   ----------------------------------------------------------------------- */

.status {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  padding: var(--s-2) var(--s-4);
  background: transparent;
  border: 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  color: var(--fg-dim);
}

.status-prompt {
  color: var(--accent);
  font-weight: 700;
}

.status-label {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-muted);
  font-size: 0.6875rem;
}

.status-divider {
  color: var(--fg-muted);
  opacity: 0.6;
}

.status-value {
  color: var(--fg);
  letter-spacing: 0.02em;
}

.status-value.ok {
  color: var(--status-ok);
  position: relative;
  padding-left: 0.85em;
}

.status-value.ok::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 0.5em;
  height: 0.5em;
  border-radius: 50%;
  background: var(--status-ok);
  animation: pulse-dot 1.5s ease-in-out infinite;
}

.status-value.warn {
  color: var(--status-warn);
  position: relative;
  padding-left: 0.85em;
}

.status-value.warn::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 0.5em;
  height: 0.5em;
  border-radius: 50%;
  background: var(--status-warn);
  animation: pulse-dot 0.8s ease-in-out infinite;
}

.status-value.error { color: var(--status-error); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: translateY(-50%) scale(1); }
  50% { opacity: 0.55; transform: translateY(-50%) scale(0.85); }
}

/* -----------------------------------------------------------------------
   Empty state — table of contents
   ----------------------------------------------------------------------- */

.empty-state {
  padding: var(--s-5) var(--s-4);
  display: grid;
  gap: var(--s-5);
}

.empty-state-prompt {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 1.5rem;
  line-height: 1.2;
  color: var(--fg-dim);
  margin: 0;
  font-variation-settings: "opsz" 60, "SOFT" 80;
}

.demo-index {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--rule);
}

.demo-index-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-1);
  padding: var(--s-4) 0;
  border-bottom: 1px solid var(--rule);
}

@media (min-width: 640px) {
  .demo-index-row {
    grid-template-columns: 240px 1fr;
    gap: var(--s-5);
    align-items: baseline;
  }
}

.demo-index-row dt {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.125rem;
  line-height: 1.3;
  color: var(--fg);
  font-variation-settings: "opsz" 30, "SOFT" 40;
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  margin: 0;
}

.demo-index-num {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  flex-shrink: 0;
}

.demo-index-row dd {
  margin: 0;
  color: var(--fg-dim);
  font-size: 0.9375rem;
  line-height: 1.55;
  max-width: 60ch;
}

/* -----------------------------------------------------------------------
   Player area — runtime container for each demo
   ----------------------------------------------------------------------- */

.player-area {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  min-height: 0;
}

.player-area video,
.player-area audio {
  width: 100%;
  max-width: 640px;
  max-height: 45vh;
  margin: 0 auto;
  background: #000;
  border-radius: 4px;
  object-fit: contain;
}

/* -----------------------------------------------------------------------
   Subtitles
   ----------------------------------------------------------------------- */

.subtitle-track {
  background: var(--subtitle-bg);
  color: var(--subtitle-fg);
  padding: var(--s-3) var(--s-4);
  border-radius: 4px;
  /* A nudge above the natural line-height — the body font's
     ascenders/descenders sit slightly outside the line-box, so a
     tight min-height would visibly expand when text appears. */
  min-height: 3.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 1.0625rem;
  line-height: 1.4;
  font-family: var(--font-body);
}

.subtitle-track-label {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: var(--s-1);
  text-align: center;
}

.subtitle-large {
  min-height: 4rem;
  font-size: 1.4375rem;
  padding: var(--s-5) var(--s-4);
  text-align: center;
}


.track-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--fg-dim);
}

/* -----------------------------------------------------------------------
   Demo explanation card
   ----------------------------------------------------------------------- */

.demo-explanation {
  padding: var(--s-4) var(--s-5);
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--fg-dim);
}

.demo-explanation strong {
  color: var(--fg);
  font-weight: 600;
}

/* -----------------------------------------------------------------------
   Stage — player + side QR
   ----------------------------------------------------------------------- */

.stage {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-5);
  align-items: start;
}

@media (min-width: 900px) {
  .stage {
    grid-template-columns: 1fr 260px;
    gap: var(--s-6);
  }
}

/* QR area: an inviting side panel asking the visitor to scan and try
   it on another device. The catchy heading and pitch are the hook;
   the QR code is the action. */
.qr-area {
  padding: var(--s-5);
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 4px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.qr-area::before {
  /* Subtle attention accent: a thin colored bar at the top of the
     panel that says "this is a thing to try". */
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
}

.qr-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin: var(--s-2) 0 var(--s-1);
}

.qr-heading {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.625rem;
  line-height: 1.15;
  letter-spacing: -0.015em;
  color: var(--fg);
  margin: 0 0 var(--s-2);
  font-variation-settings: "opsz" 60, "SOFT" 40;
}

.qr-pitch {
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--fg-dim);
  margin: 0 0 var(--s-4);
  max-width: 32ch;
  margin-left: auto;
  margin-right: auto;
}

#qr-code {
  display: inline-block;
  margin: 0 0 var(--s-2);
  background: #ffffff;
  padding: var(--s-3);
  border-radius: 4px;
  line-height: 0;
}

#qr-code svg, #qr-code img, #qr-code table {
  max-width: 100%;
  height: auto;
}

.qr-or {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin: var(--s-2) 0;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.qr-or::before,
.qr-or::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--rule);
}

.qr-link {
  display: inline-block;
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--rule);
  border-radius: 4px;
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 500;
  background: transparent;
  margin-bottom: var(--s-3);
  transition: background 150ms ease, border-color 150ms ease;
}

.qr-link:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.qr-help {
  color: var(--fg-muted);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  margin: 0;
  line-height: 1.5;
}

/* -----------------------------------------------------------------------
   Haptics demo
   ----------------------------------------------------------------------- */

/* Pseudo-haptic window shake — fires when a cannon event
   triggers, so desktop visitors get a visceral feedback in lieu
   of a real vibration motor. The animation moves the whole
   body for ~220 ms, mirroring the navigator.vibrate(200)
   duration on touch devices. */
@keyframes haptic-shake {
  0%, 100% { transform: translate3d(0, 0, 0); }
  12%      { transform: translate3d(-6px, 2px, 0); }
  25%      { transform: translate3d(7px, -2px, 0); }
  37%      { transform: translate3d(-5px, 3px, 0); }
  50%      { transform: translate3d(6px, -3px, 0); }
  62%      { transform: translate3d(-4px, 2px, 0); }
  75%      { transform: translate3d(3px, -2px, 0); }
  87%      { transform: translate3d(-2px, 1px, 0); }
}

.haptic-shake {
  animation: haptic-shake 220ms cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
  will-change: transform;
}

@media (prefers-reduced-motion: reduce) {
  .haptic-shake { animation: none; }
}

/* Inline variant: reserves layout space; the cannon video paints
   only during a fire event (see .showing rule below). */
.cannon-video.inline {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: #000;
  border: 1px solid var(--rule);
  border-radius: 4px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  /* Reserve the layout space but stay fully hidden until a cannon
     event fires. visibility:hidden keeps the poster frame from
     painting; .showing flips it on. */
  visibility: hidden;
}

.cannon-video.inline.showing {
  visibility: visible;
}

/* Fullscreen variant (mic mode): cover the entire viewport. */
.cannon-video.fullscreen {
  position: fixed;
  inset: 0;
  width: 100vw;
  max-width: none;
  height: 100vh;
  border-radius: 0;
  z-index: 99;
  display: none;
  background: #000;
  object-fit: cover;
  box-shadow: none;
}

.cannon-video.fullscreen.showing {
  display: block;
}

.cannon-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.haptics-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.haptics-stage.fullscreen {
  min-height: 70vh;
  align-items: center;
  justify-content: center;
}

.haptics-instructions {
  color: var(--fg-dim);
  font-size: 0.9375rem;
}

.karaoke-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.karaoke-instructions {
  color: var(--fg-dim);
  font-size: 0.9375rem;
}

/* The lyric line is the focal element of the karaoke demo. Big,
   italic display serif over the project's dim background; gives
   it choral weight without competing with the page chrome. The
   :empty pseudo prevents the box from collapsing to 0 height
   between phrases (which would make the audio controls jump up
   and down). */
.karaoke-lyrics {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  line-height: 1.3;
  text-align: center;
  color: var(--fg);
  min-height: 4.5em;
  padding: var(--s-5) var(--s-4);
  letter-spacing: -0.01em;
  font-variation-settings: "opsz" 90, "SOFT" 100;
}

.karaoke-lyrics:empty::before {
  content: " ";
  white-space: pre;
}


.mic-listening {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.5rem;
  color: var(--fg-dim);
  text-align: center;
  padding: var(--s-7) var(--s-4);
  letter-spacing: -0.01em;
  animation: pulse 1.6s ease-in-out infinite;
  font-variation-settings: "opsz" 60, "SOFT" 80;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1.0; }
}

.mic-instructions {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  margin-top: var(--s-3);
  color: var(--fg-dim);
  line-height: 1.5;
}

.mic-instructions code {
  background: var(--rule);
  padding: 0.1em 0.4em;
  border-radius: 3px;
  font-size: 0.875em;
  color: var(--fg);
}

/* -----------------------------------------------------------------------
   Per-demo AFS-source toggle (Mode 1 / Mode 2 / Mode 3)
   ----------------------------------------------------------------------- */

.afs-mode-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 4px;
  font-size: 0.875rem;
}

.afs-mode-label {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-right: var(--s-1);
}

.afs-mode-btn {
  padding: 4px var(--s-3);
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  color: var(--fg-dim);
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.afs-mode-btn:hover:not(.active) {
  color: var(--fg);
  border-color: var(--fg-muted);
}

.afs-mode-btn.active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

.afs-mode-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.afs-mode-detail {
  flex: 1 1 auto;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--fg-muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* -----------------------------------------------------------------------
   Shared transport (single play/pause for the dual-video demo)
   ----------------------------------------------------------------------- */

.shared-transport {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 4px;
}

.transport-btn {
  padding: var(--s-2) var(--s-4);
  border: 0;
  border-radius: 4px;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 500;
  background: var(--accent);
  color: var(--accent-fg);
  cursor: pointer;
  transition: opacity 150ms ease, background 150ms ease;
}

.transport-btn:hover { opacity: 0.9; }

.transport-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.transport-btn-secondary {
  background: transparent;
  color: var(--fg-dim);
  border: 1px solid var(--rule);
}

.transport-btn-secondary:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.transport-time {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--fg-dim);
  margin-left: auto;
  letter-spacing: 0.02em;
}

/* -----------------------------------------------------------------------
   Side-by-side video pair (desync-video demo)
   ----------------------------------------------------------------------- */

.video-pair {
  /* Stack vertically at every viewport size — the side-by-side
     desktop layout was harder to follow than the original-then-edited
     reading order this gives us. */
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-4);
}

.video-column {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.video-label {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-muted);
  text-align: center;
}

.video-column video {
  width: 100%;
  background: #000;
  border-radius: 4px;
}

.subtitle-row {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  margin-top: var(--s-2);
}

/* -----------------------------------------------------------------------
   Fullscreen container styling
   ----------------------------------------------------------------------- */

.player-area:fullscreen {
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-4);
}

/* -----------------------------------------------------------------------
   Footer — colophon block
   ----------------------------------------------------------------------- */

footer {
  max-width: 1040px;
  margin: var(--s-5) auto 0;
  padding: var(--s-4) var(--s-4) var(--s-3);
  border-top: 1px solid var(--rule);
  color: var(--fg-dim);
  font-size: 0.75rem;
  line-height: 1.5;
}

footer > p:first-child {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin: 0 0 var(--s-3);
}

.attributions {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--fg-dim);
}

.attributions a {
  color: inherit;
  border-bottom: 1px dotted currentColor;
}

.attributions a:hover {
  color: var(--accent);
  border-bottom-style: solid;
}

/* -----------------------------------------------------------------------
   Motion preferences
   ----------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

}

/* -----------------------------------------------------------------------
   Listen page — dedicated mic-only subtitle stage (listen.html)
   ----------------------------------------------------------------------- */

.listen-body {
  background: #0a0a0c;
  color: #f5f5f7;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  font-family: var(--font-body, system-ui, sans-serif);
  overflow: hidden;
}

.listen-stage {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  min-height: 100vh;
  min-height: 100svh;
  padding: 1.5rem 1.5rem 1rem;
  gap: 1rem;
  box-sizing: border-box;
}

.listen-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.listen-source-title {
  font-size: 0.875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(245, 245, 247, 0.6);
}

.listen-status {
  font-size: 0.875rem;
  letter-spacing: 0.04em;
  color: rgba(245, 245, 247, 0.45);
  transition: color 200ms ease;
}

.listen-stage[data-state="searching"] .listen-status,
.listen-stage[data-state="buffering"] .listen-status {
  color: rgba(255, 200, 100, 0.85);
}

.listen-stage[data-state="tentative"] .listen-status {
  color: rgba(140, 200, 255, 0.85);
}

.listen-stage[data-state="locked"] .listen-status {
  color: rgba(140, 230, 160, 0.95);
}

.listen-stage[data-state="error"] .listen-status {
  color: rgba(255, 140, 140, 0.95);
}

.listen-subtitle {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  /* Small bump over the natural line-height to absorb font ascender/
     descender overshoot — the original 4em was just barely too tight
     and the box visibly grew when the first cue appeared. */
  min-height: 4.75em;
}

.listen-subtitle-text {
  font-size: clamp(1.5rem, 5.5vw, 3rem);
  line-height: 1.25;
  font-weight: 500;
  color: #fafafa;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  max-width: 32em;
  white-space: pre-wrap;
  /* Avoid abrupt cue-change flashes when no subtitle is active */
  transition: opacity 120ms ease;
}

.listen-stage[data-state="ready"] .listen-subtitle-text,
.listen-stage[data-state="starting"] .listen-subtitle-text,
.listen-stage[data-state="searching"] .listen-subtitle-text,
.listen-stage[data-state="buffering"] .listen-subtitle-text {
  opacity: 0;
}

.listen-stage[data-state="tentative"] .listen-subtitle-text {
  /* Subtle "still confirming" cue without making the text hard to read */
  opacity: 0.85;
}

.listen-stage[data-state="locked"] .listen-subtitle-text {
  opacity: 1;
}

.listen-start {
  align-self: center;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 2rem;
  border-radius: 999px;
  border: 1px solid rgba(245, 245, 247, 0.15);
  background: rgba(245, 245, 247, 0.06);
  color: #f5f5f7;
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
  transition: background 200ms ease, border-color 200ms ease, transform 100ms ease;
}

.listen-start:hover:not(:disabled) {
  background: rgba(245, 245, 247, 0.12);
  border-color: rgba(245, 245, 247, 0.3);
}

.listen-start:active:not(:disabled) {
  transform: scale(0.98);
}

.listen-start:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.listen-start[hidden] {
  display: none;
}

.listen-start-mic {
  color: #ff5b5b;
  font-size: 1.5rem;
  animation: listen-mic-pulse 1.4s ease-in-out infinite;
}

@keyframes listen-mic-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

.listen-start-label {
  font-weight: 600;
  letter-spacing: 0.02em;
}

.listen-start-hint {
  font-size: 0.75rem;
  color: rgba(245, 245, 247, 0.55);
  letter-spacing: 0.02em;
}

.listen-foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
}

.listen-foot-link {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(235, 229, 211, 0.55);
  text-decoration: none;
  padding: var(--s-1) var(--s-2);
}
.listen-foot-link:hover {
  color: rgba(235, 229, 211, 0.9);
}

.listen-waveform {
  width: 100%;
  max-width: 36rem;
  height: 5rem;
  display: block;
}

/* On listen page the waveform should only show once we're listening */
.listen-stage[data-state="ready"] .listen-waveform,
.listen-stage[data-state="error"] .listen-waveform {
  opacity: 0;
}

/* -----------------------------------------------------------------------
   Listen page — cannons variant (listen-cannons.html)
   ----------------------------------------------------------------------- */

.listen-body-cannons {
  background: #000;
}

.listen-cannons-stage {
  position: fixed;
  inset: 0;
  display: grid;
  /* Single layer; the overlay and canvas stack via z-index. */
  background: #000;
  overflow: hidden;
}

.listen-cannons-canvas {
  grid-area: 1 / 1;
  position: relative;
  width: 100%;
  height: 100%;
}

.listen-cannons-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Start hidden + visibility:hidden so the poster frame never
     paints onto the black stage at load. Only the fireCannon
     trigger reveals it via .showing. */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 90ms ease-out;
  background: #000;
}

.listen-cannons-video.showing {
  opacity: 1;
  visibility: visible;
}

.listen-cannons-overlay {
  grid-area: 1 / 1;
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 1.25rem 1.25rem 1rem;
  pointer-events: none;
}

.listen-cannons-overlay > * {
  pointer-events: auto;
}

.listen-cannons-overlay .listen-header {
  color: rgba(245, 245, 247, 0.85);
}

.listen-cannons-overlay .listen-start {
  align-self: center;
  justify-self: center;
}

.listen-cannons-overlay .listen-foot {
  justify-self: center;
  opacity: 0.7;
}

.listen-cannons-stage[data-state="ready"] .listen-waveform,
.listen-cannons-stage[data-state="error"] .listen-waveform {
  opacity: 0;
}

/* Subtitle-sync tuner on the listen page. Compact, bottom of the
   stage, only revealed once matching starts. */
.listen-tune {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0.5rem auto 0;
  font-size: 0.875rem;
  color: rgba(245, 245, 247, 0.65);
}

.listen-tune-btn {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  border: 1px solid rgba(245, 245, 247, 0.2);
  background: rgba(245, 245, 247, 0.06);
  color: #f5f5f7;
  font-size: 1.25rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease, border-color 120ms ease;
}

.listen-tune-btn:hover {
  background: rgba(245, 245, 247, 0.12);
  border-color: rgba(245, 245, 247, 0.35);
}

.listen-tune-value {
  font-variant-numeric: tabular-nums;
  min-width: 7rem;
  text-align: center;
}

/* -----------------------------------------------------------------------
   listen.html: file-picker fallback
   Shown when listen.html is opened with no afs= / srt= URL params,
   or with only one of them (the missing file's row is shown so the
   user can supply it locally).
   ----------------------------------------------------------------------- */

/* HTML's `hidden` attribute defaults to `display: none`, but rules
   like `.listen-pick { display: flex }` below would otherwise win
   on specificity and keep the picker visible even when we ask for
   it to be hidden. Make `hidden` decisive on this page. */
.listen-stage [hidden] {
  display: none !important;
}

.listen-pick {
  background: rgba(245, 245, 247, 0.06);
  border: 1px solid rgba(245, 245, 247, 0.14);
  border-radius: 8px;
  padding: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  width: min(28rem, 100%);
  margin: var(--s-5) auto;
  color: #ebe5d3;
}

.listen-pick-heading {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.25rem;
  margin: 0;
  font-variation-settings: "opsz" 30, "SOFT" 40;
}

.listen-pick-lede {
  margin: 0;
  font-size: 0.875rem;
  color: rgba(235, 229, 211, 0.7);
  line-height: 1.5;
}
.listen-pick-lede a { color: inherit; text-decoration: underline; }

.listen-pick-field {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(235, 229, 211, 0.6);
}
.listen-pick-field input {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: #ebe5d3;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(245, 245, 247, 0.18);
  border-radius: 4px;
  padding: var(--s-2) var(--s-3);
}
.listen-pick-field input[type="file"] {
  cursor: pointer;
}
.listen-pick-field input[type="file"]::file-selector-button {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: var(--s-1) var(--s-3);
  margin-right: var(--s-3);
  background: rgba(245, 245, 247, 0.12);
  color: #ebe5d3;
  border: 1px solid rgba(245, 245, 247, 0.22);
  border-radius: 3px;
  cursor: pointer;
}
.listen-pick-field input[type="file"]::file-selector-button:hover {
  background: rgba(245, 245, 247, 0.2);
}

.listen-pick-status {
  margin: 0;
  font-size: 0.8125rem;
  color: rgba(235, 229, 211, 0.65);
  min-height: 1em;
}

/* -----------------------------------------------------------------------
   Generate page (demo/generate.html)
   Now uses the same masthead / tabs / stage chrome as the demo page;
   only the widgets inside .player-area are generator-specific.
   ----------------------------------------------------------------------- */

/* HTML's `hidden` attribute defaults to `display: none`, but rules
   like `.generate-drop { display: flex }` below would otherwise win
   on specificity and keep hidden sections visible. */
.player-area [hidden] {
  display: none !important;
}

/* Intro paragraph above the drop zone — explains what the tool does
   in one sentence. Lives inside the standard .player-area, so spacing
   uses the same scale as the demos. */
.generate-intro {
  color: var(--fg-dim);
  line-height: 1.55;
  margin: 0;
}
.generate-intro strong {
  color: var(--fg);
  font-weight: 600;
}
.generate-intro code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 0.05em 0.3em;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 3px;
}
.generate-intro-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--fg-muted);
  line-height: 1.5;
}
.generate-intro-note a {
  color: var(--accent);
}
.generate-intro-note code {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

/* Drop zone — dashed border, the project's sigil character at the
   top, click-through to the hidden <input type="file">. */
.generate-drop {
  border: 2px dashed var(--rule);
  border-radius: 6px;
  padding: var(--s-7) var(--s-5);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  align-items: center;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
  outline: none;
}
.generate-drop:hover,
.generate-drop:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.generate-drop.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.generate-drop.busy {
  pointer-events: none;
  opacity: 0.55;
}

.generate-drop-visual {
  font-family: var(--font-display);
  font-size: 3rem;
  line-height: 1;
  color: var(--accent);
  font-variation-settings: "opsz" 144;
}

.generate-drop-text {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}
.generate-drop-text strong {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.25rem;
  font-variation-settings: "opsz" 30;
}
.generate-drop-text span {
  color: var(--fg-dim);
  font-size: 0.9375rem;
}

/* Progress bar — single fill that grows from 0 to 100 % across the
   processing pipeline. Labels swap as we cross stage boundaries. */
.generate-progress {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.generate-progress-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-dim);
}
.generate-progress-bar {
  height: 6px;
  background: var(--rule-soft);
  border-radius: 3px;
  overflow: hidden;
}
.generate-progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 200ms ease;
}

/* Result block: metadata + the headline download button + a next-step
   tip pointing to listen.html. */
.generate-result {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  padding: var(--s-5);
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 6px;
}

.generate-result-heading {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.5rem;
  margin: 0;
  font-variation-settings: "opsz" 30, "SOFT" 40;
}

.generate-result-meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--s-2) var(--s-4);
  margin: 0;
  font-size: 0.9375rem;
}
.generate-result-meta dt {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
  align-self: center;
}
.generate-result-meta dd {
  margin: 0;
  color: var(--fg);
  word-break: break-all;
}
.generate-meta-mono {
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.generate-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-3) var(--s-5);
  background: var(--accent);
  color: var(--accent-fg);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  border-radius: 4px;
  width: max-content;
  transition: background 150ms ease;
}
.generate-download:hover {
  background: var(--accent-hover);
}

.generate-next {
  margin: 0;
  color: var(--fg-dim);
  font-size: 0.9375rem;
  line-height: 1.55;
}
.generate-next code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 0.05em 0.3em;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 3px;
}
.generate-listen-link {
  color: var(--accent);
}

.generate-error {
  padding: var(--s-4);
  background: rgba(168, 50, 50, 0.08);
  border-left: 3px solid var(--status-error);
  border-radius: 0 4px 4px 0;
  color: var(--status-error);
  font-size: 0.9375rem;
}

/* Small footnote-style paragraph below the generator widgets,
   inside the player-area. */
.generate-foot-note {
  color: var(--fg-muted);
  font-size: 0.8125rem;
  margin: 0;
  padding-top: var(--s-3);
  border-top: 1px solid var(--rule-soft);
}
.generate-foot-note code {
  font-family: var(--font-mono);
  font-size: 0.85em;
}
.generate-foot-note a {
  color: var(--fg-dim);
}
