/* @comment -- "Page shell for the redesign: brand tokens, top bar, fixed narrative region, stage frame, chapter navigation" */
@font-face {
  font-family: "Monoska";
  src: url("../../fonts/Monoska.otf") format("opentype"), url("../../fonts/Monoska.ttf") format("truetype");
  font-display: swap;
}

:root {
  --bg: #07090a;
  --bg-2: #0d1113;
  --ink: #eef2f1;
  --dim: #93a4a8;
  --faint: #5d6c70;
  --lime: #33d49d;
  --cyan: #55899e;
  --line: rgba(134, 160, 170, 0.16);
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Monoska", ui-monospace, Menlo, monospace;
  --nav-h: 56px;
  --ease-out: cubic-bezier(.2, .7, .2, 1);
  --ease-frame: cubic-bezier(.45, 0, .2, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 var(--sans); -webkit-font-smoothing: antialiased;
}
body.is-loading * { transition: none !important; animation: none !important; }

.skip { position: absolute; left: 12px; top: -48px; z-index: 30; padding: 8px 12px; background: var(--ink); color: var(--bg); border-radius: 6px; }
.skip:focus { top: 12px; }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }

/* ---------- top bar ---------- */
.nav {
  position: fixed; inset: 0 0 auto; z-index: 20; height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between; padding: 0 28px;
  background: linear-gradient(var(--bg) 60%, transparent);
}
.nav-brand { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.logo {
  font-family: var(--display); font-size: 19px;
  background: linear-gradient(90deg, var(--lime), var(--cyan));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.nav-links { display: flex; gap: 22px; }
.nav-links a { color: var(--dim); text-decoration: none; font-size: 14px; font-weight: 500; }
.nav-links a:hover { color: var(--ink); }
.nav-cta { margin-left: 22px; padding: 7px 14px; border-radius: 999px; border: 1px solid rgba(51,212,157,.45); color: var(--lime); font-size: 13px; font-weight: 600; text-decoration: none; }
.nav-cta:hover { background: rgba(51,212,157,.1); }
.nav > .nav-links { margin-left: auto; }
.sound-toggle, .watch-story { margin-left: 22px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg-2); color: var(--ink); font: 500 13px var(--sans); cursor: pointer; white-space: nowrap; }
.sound-toggle:hover, .watch-story:hover { border-color: var(--cyan); }
.sound-toggle { margin-left: 12px; color: var(--dim); }
.sound-toggle[aria-pressed="true"] { color: var(--lime); border-color: rgba(51,212,157,.4); }
.watch-story[aria-pressed="true"] { color: var(--lime); border-color: rgba(51,212,157,.4); }
.watch-story[hidden], .sound-toggle[hidden] { display: none; }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--line); }
.progress i { position: absolute; inset: 0; background: var(--lime); opacity: .7; transform-origin: 0 50%; transform: scaleX(0); }

/* ---------- sticky viewport: narrative above, stage below ---------- */
.track { position: relative; }
.viewport {
  position: sticky; top: 0; height: 100svh; overflow: hidden;
  display: grid; grid-template-rows: var(--nav-h) auto minmax(0, 1fr);
  padding-bottom: 28px;
}
.narrative {
  grid-row: 2; width: min(820px, calc(100% - 32px)); margin: 0 auto;
  padding: 18px 0 32px; text-align: center;
}
.kicker { margin: 0 0 10px; font: 500 12px/1 var(--display); letter-spacing: .08em; text-transform: uppercase; color: var(--lime); }
.title { margin: 0; font-size: clamp(26px, 2.6vw, 36px); line-height: 1.15; font-weight: 600; letter-spacing: -.02em; text-wrap: balance; }
.body { margin: 10px auto 0; max-width: 60ch; color: var(--dim); font-size: 16px; text-wrap: pretty; }
.narrative > * { transition: opacity 320ms var(--ease-out), transform 320ms var(--ease-out); }
.narrative:not(.is-in) > * { opacity: 0; transform: translateY(6px); transition: none; }
.narrative.is-in .title { transition-delay: 40ms; }
.narrative.is-in .body { transition-delay: 90ms; }

.stage { grid-row: 3; position: relative; display: flex; flex-direction: column; align-items: center; min-height: 0; padding: 0 32px; }
.stage-frame {
  position: relative; flex: 1 1 auto; min-height: 0;
  width: min(1180px, 100%); max-height: 680px;
}
.caption { margin: 8px 0 0; width: min(1180px, 100%); text-align: right; font-size: 12px; color: var(--faint); }

/* Camera: arrival comes in from slightly back, action is flat and readable, settled pushes in a
   little toward where the scene's evidence sits. Origin at the top edge so the push never grows
   up into the narrative. */
.camera {
  position: absolute; inset: 0; --focus-x: 50%;
  transform-origin: var(--focus-x) 0%;
  transition: transform 900ms var(--ease-frame);
}
/* Flat on purpose: a perspective tilt doubled frame time on desktop (measured, 2026-09-24). */
.camera[data-phase="arrival"] { transform: translateY(14px) scale(.965); }
.camera[data-phase="settled"] { transform: scale(1.012); }
.camera[data-scene="editor"] { --focus-x: 62%; }
.camera[data-scene="github"] { --focus-x: 42%; }
.camera[data-scene="slack"] { --focus-x: 60%; }
.camera[data-scene="jira"] { --focus-x: 40%; }
.camera[data-scene="closing"] { --focus-x: 50%; }

/* Live-action cutaway over the stage at the start of some chapters (only when the clip exists). */
.cutaway { position: absolute; inset: 0; z-index: 6; border-radius: 10px; overflow: hidden; background: #000; opacity: 0; visibility: hidden; transition: opacity 360ms var(--ease-frame), visibility 0s 360ms; }
.cutaway.is-on { opacity: 1; visibility: visible; transition: opacity 360ms var(--ease-frame), visibility 0s; }
.cutaway-video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cutaway-caption { position: absolute; left: 16px; bottom: 14px; padding: 4px 10px; border-radius: 6px; background: rgba(0,0,0,.55); color: #fff; font-size: 13px; }
.cutaway-caption:empty { display: none; }
.camera.has-cutaway .app.is-active .pointer { opacity: 0; }

/* Match cut: the shared artifact travelling between apps, then a brief landing mark. */
.cut-chip {
  position: fixed; z-index: 40; pointer-events: none; white-space: nowrap;
  padding: 1px 5px; margin: -1px -5px; border-radius: 5px;
  background: rgba(51, 212, 157, .16); box-shadow: 0 0 0 1px rgba(51, 212, 157, .45), 0 8px 24px rgba(0,0,0,.35);
  transform-origin: 0 0; will-change: transform, opacity;
}
.is-cut-target { animation: cut-land 900ms var(--ease-out); border-radius: 4px; }
@keyframes cut-land { from { box-shadow: 0 0 0 2px rgba(51, 212, 157, .75); background-color: rgba(51, 212, 157, .18); } to { box-shadow: 0 0 0 2px rgba(51, 212, 157, 0); } }

/* App windows stack in the frame; only the active one is visible. */
.app {
  position: absolute; inset: 0;
  opacity: 0; visibility: hidden; transform: translateY(10px) scale(.995);
  transition: opacity 480ms var(--ease-frame), transform 560ms var(--ease-frame), visibility 0s 560ms;
}
.app.is-active { opacity: 1; visibility: visible; transform: none; transition: opacity 480ms var(--ease-frame) 80ms, transform 560ms var(--ease-frame) 80ms, visibility 0s; }

/* ---------- chapter navigation ---------- */
.chapters {
  position: absolute; left: 20px; top: 50%; transform: translateY(-50%); z-index: 5;
  display: flex; flex-direction: column; gap: 4px;
}
.chapter-btn {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 0; border-radius: 6px;
  background: none; color: var(--faint); font: 500 12px/1 var(--sans); cursor: pointer; text-align: left;
}
.chapter-num { font-family: var(--display); font-size: 11px; }
.chapter-label { opacity: 0; transform: translateX(-4px); transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out); white-space: nowrap; }
.chapters:hover .chapter-label, .chapters:focus-within .chapter-label, .chapter-btn[aria-current] .chapter-label { opacity: 1; transform: none; }
.chapter-btn:hover { color: var(--ink); }
.chapter-btn[aria-current] { color: var(--lime); }
.chapter-btn[aria-current] .chapter-label { color: var(--ink); }

.after { max-width: 720px; margin: 0 auto; padding: 96px 24px 120px; color: var(--dim); text-align: center; font-size: 14px; }
.after-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-bottom: 28px; }
.after-links a { padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: 15px; }
.after-links .after-primary { background: var(--lime); border-color: var(--lime); color: #04110c; font-weight: 600; }
.fallback { max-width: 720px; margin: 120px auto; padding: 0 24px; line-height: 1.7; }
.static-story { max-width: 740px; margin: 100px auto 0; padding: 24px; }
.static-story h2 { font-size: 32px; line-height: 1.2; }
.static-story p, .static-story li { color: var(--dim); }
.static-story .fallback { margin: 24px 0; }
.static-story li { margin-bottom: 16px; }
.static-story a { color: var(--lime); }
body:not(.js-ready) .track { display: none; }
body:not(.js-ready) [data-goto] { display: none; }
.js-ready .static-story { display: none; }

/* The current label shows beside the rail only when it clears the stage. */
@media (max-width: 1600px) {
  .chapter-btn[aria-current] .chapter-label { opacity: 0; }
  .chapters:hover .chapter-label, .chapters:focus-within .chapter-label { opacity: 1; }
  .chapters:hover, .chapters:focus-within { z-index: 30; background: rgba(7,9,10,.92); border-radius: 8px; }
}

/* Chapter rail needs room beside the stage. */
@media (max-width: 1360px) {
  .chapters { left: auto; right: auto; top: auto; bottom: 8px; left: 50%; transform: translateX(-50%); flex-direction: row; }
  .chapter-label { display: none; }
  .chapter-btn[aria-current] .chapter-label { display: inline; opacity: 1; }
  .viewport { padding-bottom: 44px; }
  .caption { position: absolute; right: 32px; bottom: -22px; width: auto; margin: 0; }
}

/* Short desktop viewports: compress the narrative so the stage keeps its content. */
@media (max-height: 780px) {
  .narrative { padding: 8px 0 22px; }
  .title { font-size: clamp(22px, 2.2vw, 28px); }
  .body { font-size: 15px; margin-top: 6px; }
  .kicker { margin-bottom: 8px; }
}

/* ---------- phone ---------- */
@media (max-width: 720px) {
  .camera[data-phase="arrival"] { transform: translateY(10px) scale(.98); }
  .camera[data-phase="settled"] { transform: none; }
  :root { --nav-h: 52px; }
  .nav { padding: 0 16px; }
  .nav-links { gap: 14px; }
  .nav-links a { font-size: 13px; }
  .nav-links a[data-goto], .nav-cta { display: none; }
  .watch-story { margin-left: 12px; padding: 6px 10px; font-size: 12px; }
  .nav-links { display: none; }
  .watch-story { margin-left: auto; }
  .sound-toggle { order: 1; margin-left: 8px; padding: 6px 10px; font-size: 12px; }
  .watch-story { order: 0; }
  .chapters { gap: 0; max-width: calc(100% - 16px); }
  .chapter-btn { padding: 6px 5px; gap: 0; }
  .chapter-btn .chapter-label, .chapter-btn[aria-current] .chapter-label { display: none; }
  .chapter-btn[aria-current] .chapter-num { padding: 2px 5px; border-radius: 4px; background: rgba(51,212,157,.14); }
  .narrative { width: calc(100% - 32px); padding: 12px 0 18px; text-align: left; }
  .title { font-size: 23px; }
  .body { font-size: 15px; margin-left: 0; }
  .stage { padding: 0 12px; }
  .stage-frame { max-height: none; }
  .viewport { padding-bottom: 66px; }
  .caption { left: 0; right: 0; bottom: -26px; text-align: center; }
  .chapters { bottom: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .camera, .camera[data-phase] { transform: none; transition: none; }
  .app, .app.is-active { transform: none; transition: opacity 200ms linear, visibility 0s; }
  .narrative > *, .narrative:not(.is-in) > * { transform: none; }
}

/* Story controls: two icon buttons next to the story, where the caption used to be. */
.story-controls { display: flex; gap: 6px; justify-content: flex-end; width: min(1180px, 100%); margin: 6px 0 0; }
.icon-btn { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border-radius: 50%; border: 1px solid var(--line); background: var(--bg-2); color: var(--dim); cursor: pointer; }
.icon-btn:hover { color: var(--ink); border-color: var(--cyan); }
.icon-btn[aria-pressed="true"] { color: var(--lime); border-color: rgba(51,212,157,.45); }
.icon-btn[hidden] { display: none; }
.icon-btn svg { display: block; }
@media (max-width: 1360px) {
  .story-controls { position: absolute; right: 32px; bottom: -36px; width: auto; margin: 0; z-index: 6; }
}
@media (max-width: 720px) {
  .story-controls { right: 12px; bottom: -40px; }
  .icon-btn { width: 28px; height: 28px; }
}
