
/* Layout: one 16:9 "screen" (4:5 on phones) that plays ten scenes in order, like a short captioned film. */
:root {
  --night: #071a2e;   /* deep end at night */
  --deep: #0c2f52;
  --water: #1597c0;
  --foam: #e6f6fb;
  --lane: #e2463a;    /* lane rope red */
  --gold: #f2b632;    /* finish-touchpad yellow */
  --ok: #3ccf7a;
  --ink: #e9f1f8;
  --muted: #9fb6cc;
  --display: 'Barlow Condensed', 'Arial Narrow', system-ui, sans-serif;
  --body: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--night); color: var(--ink); font-family: var(--body); padding-block: 20px 28px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.wrap { max-width: 980px; margin: 0 auto; display: grid; gap: 14px; }
header.top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; }
header.top h1 { margin: 0; font-family: var(--display); font-weight: 800; text-transform: uppercase; letter-spacing: .02em; font-size: clamp(1.4rem, 4vw, 2rem); text-wrap: balance; }
header.top p { margin: 0; color: var(--muted); font-size: .95rem; }

/* ---------- the screen ---------- */
.screen { position: relative; width: 100%; max-width: 100%; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden;
  background: radial-gradient(120% 90% at 50% 110%, #0f4a72 0%, var(--deep) 45%, var(--night) 100%); box-shadow: 0 20px 60px rgba(0,0,0,.45); isolation: isolate; }
@media (max-width: 640px) { .screen { aspect-ratio: 2 / 3; } } /* taller on phones, so the text and the graphic both have room */
.screen::after { /* lane rope along the bottom */
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 8px; z-index: 3;
  background: repeating-linear-gradient(90deg, var(--lane) 0 22px, #fff 22px 36px, var(--water) 36px 58px, #fff 58px 72px); }
.ripples { position: absolute; inset: 0; z-index: 0; opacity: .18; pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent 0 38px, rgba(143,214,238,.6) 38px 40px); animation: drift 14s linear infinite; }
@keyframes drift { from { background-position: 0 0; } to { background-position: 0 80px; } }

.scene { position: absolute; inset: 0 0 8px; z-index: 1; display: grid; grid-template-columns: 1.05fr 1fr; align-items: center; gap: 4%;
  padding: 5% 6%; opacity: 0; visibility: hidden; transition: opacity .5s ease, visibility 0s linear .5s; }
.scene.on { opacity: 1; visibility: visible; transition: opacity .5s ease; }
@media (max-width: 640px) { .scene { grid-template-columns: 1fr; grid-template-rows: auto 1fr; align-items: start; padding: 7% 7% 6%; gap: 4%; } }
.copy { display: grid; gap: .55em; min-width: 0; }
.step { font-family: var(--display); font-weight: 700; text-transform: uppercase; letter-spacing: .16em; color: var(--gold); font-size: clamp(.8rem, 1.6vw, 1rem); }
.copy h2 { margin: 0; font-family: var(--display); font-weight: 800; text-transform: uppercase; line-height: 1.02; font-size: clamp(1.6rem, 4.4vw, 3rem); text-wrap: balance; }
.copy p { margin: 0; font-size: clamp(.92rem, 1.8vw, 1.2rem); line-height: 1.45; color: var(--foam); max-width: 34ch; }
.copy p b { color: #fff; }
.art { position: relative; height: 100%; min-height: 0; display: grid; place-items: center; }
.art svg { width: 100%; height: 100%; max-height: 100%; overflow: visible; }
/* On phones the graphic scales down to the room left under the text, so it is never cut off. (Its natural height used to push
   the row taller than the screen.) Desktop is unchanged. */
@media (max-width: 640px) { .art { height: 100%; } .art svg { position: absolute; inset: 0; } }

/* entrance motion: elements with .in play when their scene turns on */
.scene .in { opacity: 0; transform: translateY(14px); }
.scene.on .in { animation: rise .6s cubic-bezier(.2,.8,.2,1) forwards; }
.scene.on .in.d1 { animation-delay: .25s; } .scene.on .in.d2 { animation-delay: .6s; } .scene.on .in.d3 { animation-delay: 1.1s; } .scene.on .in.d4 { animation-delay: 1.8s; } .scene.on .in.d5 { animation-delay: 2.6s; }
@keyframes rise { to { opacity: 1; transform: none; } }

/* scene-specific motion */
.scene.on .strike { stroke-dasharray: 260; stroke-dashoffset: 260; animation: draw .7s ease 1.4s forwards; }
.scene.on .tick { stroke-dasharray: 80; stroke-dashoffset: 80; animation: draw .6s ease 2.1s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.scene.on .day { opacity: .15; animation: fill .25s ease forwards; }
@keyframes fill { to { opacity: 1; } }
.scene.on .shackle { animation: unlock .8s cubic-bezier(.3,1.4,.5,1) 2s forwards; transform-origin: 70% 100%; transform-box: fill-box; }
@keyframes unlock { to { transform: translateY(-14px) rotate(-28deg); } }
.scene.on .bar { transform-origin: left center; transform: scaleX(0); animation: grow 2.2s ease 1s forwards; }
@keyframes grow { to { transform: scaleX(1); } }
.scene.on .arrow { animation: bob 1.2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px); } }
.scene.on .swap1 { animation: out .3s ease 2.4s forwards; }
.scene.on .swap2 { opacity: 0; animation: fill .4s ease 2.6s forwards; }
@keyframes out { to { opacity: 0; } }
.scene.on .pulse { animation: pulse 1.6s ease-in-out 1s infinite; transform-origin: center; transform-box: fill-box; }
@keyframes pulse { 50% { transform: scale(1.06); } }

/* ---------- controls ---------- */
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.controls button { font: inherit; font-weight: 700; border: 1px solid rgba(255,255,255,.22); background: rgba(255,255,255,.06); color: var(--ink);
  border-radius: 999px; padding: 8px 16px; cursor: pointer; min-height: 40px; }
.controls button:hover { background: rgba(255,255,255,.12); }
.controls button:focus-visible, .dots button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.controls .play { background: var(--water); border-color: var(--water); color: #fff; min-width: 96px; }
.controls #sound[aria-pressed="true"] { background: var(--gold); color: var(--night); border-color: var(--gold); }
.track { flex: 1 1 200px; height: 6px; border-radius: 999px; background: rgba(255,255,255,.14); overflow: hidden; min-width: 120px; }
.track i { display: block; height: 100%; width: 0; background: var(--gold); }
.dots { display: flex; flex-wrap: wrap; gap: 6px; }
.dots button { width: 30px; height: 30px; border-radius: 50%; border: 1px solid rgba(255,255,255,.25); background: transparent; color: var(--muted);
  font: 600 .8rem var(--body); cursor: pointer; padding: 0; }
.dots button[aria-current="step"] { background: var(--gold); color: var(--night); border-color: var(--gold); }
.note { color: var(--muted); font-size: .88rem; line-height: 1.5; margin: 0; }
.note b { color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  .ripples, .scene.on .arrow, .scene.on .pulse { animation: none; }
  .scene .in, .scene.on .in { opacity: 1; transform: none; animation: none; }
  .scene.on .strike, .scene.on .tick, .scene.on .bar, .scene.on .shackle, .scene.on .day, .scene.on .swap1, .scene.on .swap2 { animation-duration: .01s; animation-delay: 0s; }
}

.note a { color: var(--gold); }
