/* Software-Defined Tempo storybook. Ottia Console design system, Gotham dark, IBM Plex, square corners.
   Layout: each scene is a full-bleed photo held by position: sticky; the story's beats scroll over it
   in one reading column, behind a dark gradient scrim. A thin top bar, a fixed mini player at the foot. */
:root {
  --surface-base: #0a0f16; --surface-raised: #0f1621; --surface-overlay: #15202e;
  --border-subtle: #1e2b3a; --border-strong: #2f4257;
  --ink-primary: #e6edf5; --ink-secondary: #b4c2d2; --ink-faint: #8495a8;
  --accent: #38bdf8; --accent-muted: #11384a;
  --signal-info: #60a5fa; --signal-warn: #fbbf24;
  --scrim-strong: rgba(10, 15, 22, 0.88); --scrim-mid: rgba(10, 15, 22, 0.6); --scrim-soft: rgba(10, 15, 22, 0.25);
  --shadow-overlay: 0 18px 44px -10px rgba(0, 0, 0, 0.82);
  --shadow-focus: 0 0 0 2px rgba(56, 189, 248, 0.6);
  --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --radius-sm: 2px; --radius-md: 4px;
  --gutter-l: max(16px, env(safe-area-inset-left, 0px)); --gutter-r: max(16px, env(safe-area-inset-right, 0px));
  --player-h: 64px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { background: var(--surface-base); scroll-behavior: smooth; }
body { margin: 0; background: var(--surface-base); color: var(--ink-primary); font: 400 16px/1.55 var(--font-sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
img { max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--accent); text-underline-offset: 3px; }
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.skip { position: absolute; left: 16px; top: -60px; z-index: 50; background: var(--accent); color: var(--surface-base); padding: 8px 12px; font-weight: 600; }
.skip:focus { top: calc(8px + env(safe-area-inset-top, 0px)); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.label { font: 500 11px/14px var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-secondary); }

/* ---------- top bar ---------- */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--surface-base); }
.topbar { position: fixed; z-index: 20; top: env(safe-area-inset-top, 0px); left: 0; right: 0; display: flex; align-items: center; gap: 12px; min-height: 48px; padding-left: var(--gutter-l); padding-right: var(--gutter-r); background: linear-gradient(to bottom, rgba(10,15,22,0.92), rgba(10,15,22,0)); }
.brand { display: inline-flex; align-items: baseline; gap: 8px; color: var(--ink-primary); text-decoration: none; padding: 4px 0; }
.brand .mark { color: var(--accent); font-size: 15px; line-height: 1; }
.brand .wm { font: 600 12px/1 var(--font-sans); letter-spacing: 0.16em; }
.brand .crumb { font: 400 11px/1 var(--font-mono); color: var(--ink-faint); letter-spacing: 0.04em; }
.topbar .spacer { flex: 1; }
.progress { position: fixed; z-index: 21; top: env(safe-area-inset-top, 0px); left: 0; height: 2px; width: 100%; transform-origin: 0 50%; transform: scaleX(0); background: var(--accent); }
.toc { position: relative; }
.toc summary { list-style: none; cursor: pointer; font: 500 12px/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-primary); border: 1px solid var(--border-strong); background: rgba(10,15,22,0.6); padding: 8px 10px; border-radius: var(--radius-md); }
.toc summary::-webkit-details-marker { display: none; }
.toc[open] summary { border-color: var(--accent); }
.toc ol { position: absolute; right: 0; top: calc(100% + 6px); margin: 0; padding: 4px 0; list-style: none; width: min(320px, calc(100vw - 32px)); background: var(--surface-overlay); border: 1px solid var(--border-strong); box-shadow: var(--shadow-overlay); max-height: 70vh; overflow-y: auto; }
.toc li a { display: grid; grid-template-columns: 3.4em 1fr; gap: 8px; padding: 9px 12px; color: var(--ink-primary); text-decoration: none; font-size: 14px; line-height: 1.35; }
.toc li a .mono { color: var(--ink-faint); font-size: 12px; }
.toc li a:hover, .toc li a[aria-current="true"] { background: var(--accent-muted); }

/* ---------- scenes ---------- */
.scene { position: relative; }
.bg { position: sticky; top: 0; height: 100vh; height: 100lvh; overflow: hidden; background: var(--surface-base); }
.bg img { width: 100%; height: 100%; object-fit: cover; display: block; transform: scale(1.02); transition: transform 14s ease-out; }
.scene.is-active .bg img { transform: scale(1.08); }
.bg::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(10,15,22,0.55) 0%, rgba(10,15,22,0) 22%, rgba(10,15,22,0) 70%, rgba(10,15,22,0.7) 100%),
    linear-gradient(90deg, var(--scrim-strong) 0%, var(--scrim-mid) 42%, var(--scrim-soft) 75%, rgba(10,15,22,0.1) 100%); }
.beats { position: relative; z-index: 1; margin-top: -100vh; margin-top: -100lvh; padding-left: var(--gutter-l); padding-right: var(--gutter-r); }
.beat { min-height: 50vh; min-height: 50svh; display: flex; flex-direction: column; justify-content: center; gap: 14px; max-width: 36rem; margin-left: clamp(0px, 7vw, 120px); padding-block: 7vh; text-shadow: 0 1px 2px rgba(0,0,0,0.6), 0 0 24px rgba(10,15,22,0.65); }
.beat:first-child { padding-top: 30vh; }
.beat:last-child { padding-bottom: 34vh; }
.reveal .beat { opacity: 0.18; transform: translateY(14px); transition: opacity 0.7s ease, transform 0.7s ease; }
.reveal .beat.in { opacity: 1; transform: none; }

.narr { margin: 0; font: 400 clamp(20px, 1.15vw + 14px, 28px)/1.5 var(--font-sans); letter-spacing: -0.003em; color: var(--ink-primary); text-wrap: pretty; }
.narr.short { font-weight: 500; font-size: clamp(24px, 1.6vw + 16px, 36px); line-height: 1.3; }
.exchange { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; border-left: 2px solid var(--accent); padding-left: 16px; }
.say { display: grid; gap: 3px; }
.who { font: 500 11px/14px var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.who .via { color: var(--ink-faint); letter-spacing: 0.08em; }
.line { font: 500 clamp(18px, 0.7vw + 14px, 22px)/1.45 var(--font-sans); color: var(--ink-primary); }
.say.helper .who { color: var(--ink-secondary); }
.say.helper .line { font-family: var(--font-mono); font-weight: 400; font-size: clamp(15px, 0.5vw + 12px, 18px); color: #cfe3f2; }
.tag { display: inline-flex; align-items: center; font: 400 10.5px/16px var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; padding: 0 6px; border: 1px solid; border-radius: var(--radius-sm); text-shadow: none; background: rgba(10,15,22,0.6); }
.tag.op { color: var(--signal-warn); border-color: var(--signal-warn); }
.tag.tech { color: var(--signal-info); border-color: var(--signal-info); }

.chapcard { gap: 10px; }
.chapcard .label { color: var(--accent); }
.chapcard h2 { margin: 0; font: 600 clamp(34px, 3.6vw + 18px, 64px)/1.05 var(--font-sans); letter-spacing: -0.02em; text-wrap: balance; }
.chapcard .meta { font: 400 12px/1 var(--font-mono); color: var(--ink-faint); letter-spacing: 0.04em; }

/* title scene */
.titlecard { gap: 18px; }
.titlecard h1 { margin: 0; font: 600 clamp(42px, 5.4vw + 18px, 96px)/0.98 var(--font-sans); letter-spacing: -0.03em; text-wrap: balance; }
.titlecard .sub { margin: 0; font: 400 clamp(19px, 1vw + 14px, 26px)/1.35 var(--font-sans); color: var(--ink-secondary); text-wrap: balance; }
.titlecard .hint { font: 400 12px/1.4 var(--font-mono); color: var(--ink-faint); letter-spacing: 0.04em; display: flex; align-items: center; gap: 8px; }
.titlecard .hint::after { content: ""; width: 1px; height: 28px; background: linear-gradient(var(--ink-faint), transparent); }
.fiction { margin: 0; font: 400 13px/1.55 var(--font-mono); color: var(--ink-secondary); max-width: 32rem; }
.fiction::before { content: "// "; color: var(--ink-faint); }
.btnrow { display: flex; flex-wrap: wrap; gap: 10px; }
.btn { display: inline-flex; align-items: center; gap: 8px; font: 500 14px/1 var(--font-sans); padding: 11px 16px; border-radius: var(--radius-md); border: 1px solid var(--border-strong); background: rgba(10,15,22,0.55); color: var(--ink-primary); text-decoration: none; cursor: pointer; text-shadow: none; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--surface-base); font-weight: 600; }
.btn svg { width: 16px; height: 16px; fill: currentColor; }

/* credits */
.credits { gap: 16px; }
.credits h2 { margin: 0; font: 600 clamp(28px, 2vw + 18px, 44px)/1.1 var(--font-sans); letter-spacing: -0.015em; }
.credits p { margin: 0; font-size: 17px; line-height: 1.55; color: var(--ink-primary); }
.credits dl { margin: 0; display: grid; gap: 10px; }
.credits dt { font: 500 11px/14px var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); }
.credits dd { margin: 0; font-size: 16px; line-height: 1.5; }
.credits .copy { font: 400 12px/1.5 var(--font-mono); color: var(--ink-faint); }
details.imgcredits summary { cursor: pointer; font: 500 12px/1.4 var(--font-mono); letter-spacing: 0.06em; color: var(--ink-secondary); text-transform: uppercase; }
details.imgcredits ul { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; font: 400 12px/1.45 var(--font-mono); color: var(--ink-secondary); max-height: 40vh; overflow-y: auto; text-shadow: none; }
details.imgcredits a { color: var(--ink-secondary); }

/* ---------- with JavaScript: one fixed stage, scenes crossfade ---------- */
.js .bg { position: fixed; inset: 0 0 auto 0; top: 0; height: 100vh; height: 100lvh; z-index: 0; opacity: 0; visibility: hidden;
  transition: opacity 1.2s ease, visibility 0s linear 1.2s; will-change: opacity; }
.js .scene.is-active .bg { z-index: 1; opacity: 1; visibility: visible; transition: opacity 1.2s ease, visibility 0s; }
.js .scene.leaving .bg { z-index: 0; opacity: 1; visibility: visible; transition: none; }
.js .bg img { transform: scale(1.0); transition: transform 0s linear 1.4s; }
.js .scene.is-active .bg img { transform: scale(1.07); transition: transform 18s cubic-bezier(0.25, 0.6, 0.35, 1); }
.js .beats { margin-top: 0; z-index: 2; }

/* following the audio: the spoken line lit, earlier lines dimmed, later lines not yet shown */
.say { transition: opacity 0.7s ease, transform 0.7s ease; }
.story.following .beat { opacity: 1; transform: none; transition: opacity 0.8s ease, transform 0.8s ease; }
.story.following .beat.f-future, .story.following .say.f-future { opacity: 0; transform: translateY(18px); }
.story.following .beat.f-past:not(.xbeat), .story.following .say.f-past { opacity: 0.3; }
.story.following .beat.f-now, .story.following .say.f-now { opacity: 1; transform: none; }
.followpill { position: fixed; z-index: 26; left: 50%; transform: translateX(-50%); bottom: calc(var(--player-h) + 14px + env(safe-area-inset-bottom, 0px));
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px 10px 12px; font: 600 13px/1 var(--font-sans); color: var(--surface-base);
  background: var(--accent); border: 1px solid var(--accent); border-radius: 999px; cursor: pointer; box-shadow: var(--shadow-overlay); }
.followpill svg { width: 14px; height: 14px; fill: currentColor; }
.followpill:focus-visible { outline: 2px solid var(--ink-primary); outline-offset: 3px; }

/* ---------- mini player ---------- */
.player { position: fixed; z-index: 25; left: 0; right: 0; bottom: 0; padding-bottom: env(safe-area-inset-bottom, 0px); background: rgba(15,22,33,0.94); border-top: 1px solid var(--border-strong); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.player .inner { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 4px 14px; min-height: var(--player-h); padding: 8px var(--gutter-r) 8px var(--gutter-l); max-width: 1100px; margin: 0 auto; }
.pbtn { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--accent); background: var(--accent); color: var(--surface-base); border-radius: var(--radius-md); cursor: pointer; padding: 0; }
.pbtn svg { width: 18px; height: 18px; fill: currentColor; }
.pmid { min-width: 0; display: grid; gap: 4px; }
.prow { display: flex; justify-content: space-between; gap: 12px; min-width: 0; }
.pnow { font: 500 13px/18px var(--font-sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pnow .label { margin-right: 6px; }
.ptime { font: 400 12px/18px var(--font-mono); color: var(--ink-secondary); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pseek { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; margin: 0; background: transparent; cursor: pointer; }
.pseek::-webkit-slider-runnable-track { height: 2px; background: linear-gradient(to right, var(--accent) var(--pct, 0%), var(--border-strong) var(--pct, 0%)); }
.pseek::-moz-range-track { height: 2px; background: var(--border-strong); }
.pseek::-moz-range-progress { height: 2px; background: var(--accent); }
.pseek::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; margin-top: -5px; background: var(--accent); border: 0; border-radius: 0; }
.pseek::-moz-range-thumb { width: 12px; height: 12px; background: var(--accent); border: 0; border-radius: 0; }
.pright { display: flex; gap: 8px; align-items: center; }
.psync { font: 500 12px/1.2 var(--font-sans); padding: 8px 10px; border: 1px solid var(--accent); background: var(--accent-muted); color: var(--ink-primary); border-radius: var(--radius-md); cursor: pointer; max-width: 210px; text-align: left; }
.pspeed { font: 400 12px/1 var(--font-mono); padding: 8px; border: 1px solid var(--border-strong); background: transparent; color: var(--ink-primary); border-radius: var(--radius-md); cursor: pointer; min-width: 48px; }
.has-player .beats { padding-bottom: var(--player-h); }
.has-player footer.end { padding-bottom: calc(var(--player-h) + 32px); }

html:not(.js) .player, html:not(.js) [data-start] { display: none; }
.startbtn { align-self: flex-start; display: inline-flex; align-items: center; gap: 14px; margin-top: 10px; padding: 18px 28px 18px 22px; font: 600 clamp(18px, 0.8vw + 14px, 22px)/1 var(--font-sans); letter-spacing: 0.01em; color: var(--surface-base); background: var(--accent); border: 1px solid var(--accent); border-radius: var(--radius-md); cursor: pointer; text-shadow: none; box-shadow: 0 10px 40px -8px rgba(56,189,248,0.55); }
.startbtn svg { width: 26px; height: 26px; fill: currentColor; }
.startbtn:hover { box-shadow: 0 14px 48px -6px rgba(56,189,248,0.7); }
.startbtn:focus-visible { outline: 2px solid var(--ink-primary); outline-offset: 3px; }

/* ---------- end of story ---------- */
footer.end { position: relative; z-index: 2; background: var(--surface-base); border-top: 1px solid var(--border-subtle); padding: 40px var(--gutter-r) 40px var(--gutter-l); }
footer.end .wrap { max-width: 1100px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 16px 32px; align-items: center; justify-content: space-between; }
footer.end p { margin: 0; color: var(--ink-secondary); font-size: 14px; }

@media (max-width: 720px) {
  .bg::after { background:
    linear-gradient(to bottom, rgba(10,15,22,0.55) 0%, rgba(10,15,22,0.35) 30%, rgba(10,15,22,0.45) 65%, rgba(10,15,22,0.85) 100%),
    linear-gradient(rgba(10,15,22,0.38), rgba(10,15,22,0.38)); }
  .beat { margin-left: 0; min-height: 54svh; }
  .player .inner { grid-template-columns: auto minmax(0, 1fr); }
  .pright { grid-column: 1 / -1; justify-content: space-between; }
  .pspeed { display: none; }
  .psync { max-width: none; flex: 1; }
  .pright:not(:has(.psync:not([hidden]))) { display: none; }
  :root { --player-h: 68px; }
  .brand .crumb { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .bg img, .scene.is-active .bg img { transform: none; transition: none; }
  .reveal .beat { opacity: 1; transform: none; transition: none; }
  .js .bg img, .js .scene.is-active .bg img { transform: none; transition: none; }
  .story.following .beat.f-future, .story.following .say.f-future { transform: none; }
  .say, .story.following .beat { transition: opacity 0.4s linear; }
}

/* ---------- landing (/tempo/) ---------- */
.hero { position: relative; min-height: 86vh; min-height: 86svh; display: flex; align-items: flex-end; overflow: hidden; }
.hero .bgimg { position: absolute; inset: 0; }
.hero .bgimg img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero .bgimg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(10,15,22,0.5) 0%, rgba(10,15,22,0.2) 35%, rgba(10,15,22,0.92) 100%), linear-gradient(90deg, rgba(10,15,22,0.75), rgba(10,15,22,0.1)); }
.hero .wrap { position: relative; width: 100%; max-width: 1100px; margin: 0 auto; padding: 120px var(--gutter-r) 56px var(--gutter-l); display: grid; gap: 18px; text-shadow: 0 1px 2px rgba(0,0,0,0.6), 0 0 24px rgba(10,15,22,0.6); }
.hero h1 { margin: 0; font: 600 clamp(44px, 6vw + 16px, 104px)/0.96 var(--font-sans); letter-spacing: -0.035em; max-width: 12ch; text-wrap: balance; }
.hero .sub { margin: 0; font: 400 clamp(19px, 1vw + 14px, 26px)/1.35 var(--font-sans); color: var(--ink-secondary); }
.hero .intro { margin: 0; max-width: 40rem; font-size: clamp(16px, 0.4vw + 14px, 18px); line-height: 1.6; color: var(--ink-primary); }
.stories { max-width: 1100px; margin: 0 auto; padding: 48px var(--gutter-r) 72px var(--gutter-l); display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 24px; }
.card { position: relative; display: grid; grid-template-rows: auto 1fr; background: var(--surface-raised); border: 1px solid var(--border-subtle); min-width: 0; }
.card:hover { border-color: var(--border-strong); }
.card .ph { position: relative; aspect-ratio: 16 / 10; overflow: hidden; max-width: 100%; }
.card .ph img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.8s ease; }
.card:hover .ph img { transform: scale(1.04); }
.card .body { padding: 22px 22px 24px; display: grid; gap: 12px; align-content: start; }
.card h2 { margin: 0; font: 600 clamp(26px, 1.2vw + 20px, 34px)/1.1 var(--font-sans); letter-spacing: -0.015em; }
.card h2 a { color: var(--ink-primary); text-decoration: none; }
.card h2 a::after { content: ""; position: absolute; inset: 0; }
.card p { margin: 0; color: var(--ink-secondary); line-height: 1.55; }
.card .meta { display: flex; flex-wrap: wrap; gap: 6px 16px; font: 400 12px/1.4 var(--font-mono); color: var(--ink-faint); letter-spacing: 0.03em; }
.card .btnrow { position: relative; z-index: 1; margin-top: 4px; }
.landfoot { border-top: 1px solid var(--border-subtle); }
.landfoot .wrap { max-width: 1100px; margin: 0 auto; padding: 28px var(--gutter-r) 40px var(--gutter-l); display: grid; gap: 10px; color: var(--ink-secondary); font-size: 14px; }
.landfoot .fiction { font-size: 12px; }
