/* The scrolling demo: one idea per screen on the left, a stage that stays put on the right.
   Rules followed (design/references.md): one typeface, flat backgrounds, only transform and opacity move,
   each thing moves once, reduced motion means a plain fade. */
:root {
  --paper: #f5f6f8;
  --ink: #14213d;
  --ink-soft: #55607a;
  --line: #d5dae3;
  --stage: #14213d;
  --stage-2: #1e2d4f;
  --stage-line: #31426b;
  --on-stage: #eef1f8;
  --on-stage-soft: #a9b4cf;
  --agent: #2bb8a3;
  --agent-ink: #0b7a6e;
  --other: #8d7cf0;
  --rule: #f0a92e;
  --rule-ink: #8a5600;
  --bad: #ff7d6e;
  --font: 'Bricolage Grotesque', 'Helvetica Neue', Arial, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font); font-size: 18px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
:focus-visible { outline: 3px solid var(--other); outline-offset: 3px; border-radius: 6px; }
button { font: inherit; color: inherit; }

.bar { position: fixed; top: 0; left: 0; right: 0; z-index: 30; display: flex; justify-content: space-between; align-items: center; padding: 14px clamp(16px, 4vw, 44px); pointer-events: none; }
.bar > * { pointer-events: auto; }
.brand { font-weight: 700; font-size: 1.1rem; letter-spacing: -0.02em; color: var(--ink); text-decoration: none; }
.sound { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 14px; font-size: 0.86rem; font-weight: 500; cursor: pointer; }
.sound[aria-pressed='true'] { background: var(--ink); color: #fff; border-color: var(--ink); }
.sound-ico { width: 14px; height: 14px; background: currentColor; clip-path: polygon(0 32%, 32% 32%, 68% 4%, 68% 96%, 32% 68%, 0 68%); }

.dots { position: fixed; left: clamp(8px, 1.6vw, 22px); top: 50%; transform: translateY(-50%); z-index: 20; display: flex; flex-direction: column; gap: 9px; }
.dots a { width: 9px; height: 9px; border-radius: 50%; background: var(--line); display: block; transition: transform 0.3s var(--ease), opacity 0.3s var(--ease); }
.dots a.on { background: var(--ink); transform: scale(1.5); }

.layout { display: grid; grid-template-columns: minmax(0, 0.82fr) minmax(0, 1fr); gap: clamp(20px, 4vw, 64px); max-width: 1400px; margin: 0 auto; padding: 0 clamp(20px, 5vw, 72px); }

/* ── The story ── */
.beat { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 96px 0; }
.beat > * { max-width: 560px; }
.beat h1 { font-size: clamp(2.3rem, 4.6vw, 4.1rem); line-height: 1.04; letter-spacing: -0.03em; font-weight: 600; margin: 0 0 0.45em; max-width: 680px; }
.beat h2 { font-size: clamp(1.8rem, 3.2vw, 2.9rem); line-height: 1.08; letter-spacing: -0.025em; font-weight: 600; margin: 0 0 0.45em; }
.beat p { margin: 0 0 1em; font-size: 1.16rem; color: var(--ink-soft); }
.beat .lede { font-size: 1.3rem; color: var(--ink); }
.kicker, .when { font-size: 0.98rem !important; font-weight: 600; color: var(--agent-ink) !important; margin-bottom: 0.7em !important; }
.punch { font-size: clamp(1.5rem, 2.6vw, 2.2rem) !important; font-weight: 600; color: var(--ink) !important; letter-spacing: -0.02em; }
.fine { font-size: 0.86rem !important; line-height: 1.45; color: var(--ink-soft); }
.start { display: flex; gap: 12px; flex-wrap: wrap; margin: 1.2em 0 1.4em; }
.btn { display: inline-block; border: 0; cursor: pointer; background: var(--ink); color: #fff; text-decoration: none; padding: 14px 24px; border-radius: 999px; font-weight: 600; font-size: 1rem; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.cue { font-size: 0.86rem !important; font-weight: 600; color: var(--ink-soft); margin-top: 2.2em !important; }
.cue::after { content: ''; display: block; width: 2px; height: 34px; background: var(--ink-soft); margin: 8px 0 0 18px; animation: cue 1.8s var(--ease) infinite; transform-origin: top; }
@keyframes cue { 0% { transform: scaleY(0); opacity: 1; } 70% { transform: scaleY(1); opacity: 1; } 100% { transform: scaleY(1); opacity: 0; } }
/* A beat's words arrive once. */
.beat:not(.hero) > * { opacity: 0; transform: translateY(32px); transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); }
.beat.seen > * { opacity: 1; transform: none; }
.beat.seen > :nth-child(2) { transition-delay: 0.06s; }
.beat.seen > :nth-child(3) { transition-delay: 0.12s; }
.beat.seen > :nth-child(4) { transition-delay: 0.18s; }

/* The rule switches */
.rules { display: grid; gap: 10px; margin: 0.4em 0 1em; }
.rule { display: flex; gap: 14px; align-items: center; text-align: left; width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 16px; padding: 14px 16px; cursor: pointer; }
.rule .sw { flex: none; width: 46px; height: 26px; border-radius: 999px; background: var(--rule); position: relative; }
.rule .sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transform: translateX(20px); transition: transform 0.3s var(--ease); }
.rule[aria-pressed='false'] .sw { background: var(--line); }
.rule[aria-pressed='false'] .sw::after { transform: none; }
.rule b { display: block; font-weight: 600; font-size: 1.02rem; line-height: 1.25; }
.rule span.then { display: block; font-size: 0.86rem; color: var(--ink-soft); margin-top: 3px; min-height: 1.2em; }
.rule[aria-pressed='false'] span.then { color: #b3261e; }

/* ── The stage ── */
.stage { position: sticky; top: 0; height: 100vh; padding: 64px 0 20px; display: flex; flex-direction: column; gap: 14px; justify-content: center; }
.now, .board, .form { background: var(--stage); color: var(--on-stage); border-radius: 24px; }
.now { padding: 18px 20px; min-height: 132px; max-height: 40vh; overflow: hidden; display: flex; flex-direction: column; flex: none; transition: opacity 0.4s var(--ease); }
.now.empty { display: none; }
.now-head { display: flex; align-items: center; gap: 10px; font-size: 0.86rem; font-weight: 600; color: var(--on-stage-soft); }
.now-meta { margin-left: auto; font-weight: 500; }
.now-ico { width: 26px; height: 26px; border-radius: 50%; background: var(--stage-2); flex: none; display: grid; place-items: center; }
.now-ico::after { content: ''; width: 12px; height: 12px; background: var(--on-stage); }
.now-ico.call::after { clip-path: polygon(18% 0, 42% 0, 50% 28%, 34% 40%, 60% 68%, 74% 52%, 100% 60%, 100% 84%, 82% 100%, 40% 84%, 0 30%); }
.now-ico.text::after { clip-path: polygon(0 8%, 100% 8%, 100% 74%, 46% 74%, 22% 100%, 22% 74%, 0 74%); }
.now-ico.rules::after { clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); background: var(--rule); }
.now-ico.live { background: var(--agent); animation: ring 1.2s var(--ease) infinite; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(43, 184, 163, 0.6); } 100% { box-shadow: 0 0 0 12px rgba(43, 184, 163, 0); } }
.now-body { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; flex: none; }
.say { max-width: 90%; padding: 8px 13px; border-radius: 16px; font-size: 0.94rem; line-height: 1.33; opacity: 0; transform: translateY(10px); transition: opacity 0.35s var(--ease), transform 0.35s var(--ease); }
.say.in { opacity: 1; transform: none; }
.say b { display: block; font-size: 0.72rem; font-weight: 600; opacity: 0.75; margin-bottom: 1px; }
.say.agent { background: #17463f; border-top-left-radius: 5px; align-self: flex-start; }
.say.agent b { color: var(--agent); }
.say.other { background: #2d2a5e; border-top-right-radius: 5px; align-self: flex-end; }
.say.other b { color: var(--other); }
.say.sys { background: transparent; border: 1px dashed var(--rule); color: var(--rule); font-weight: 500; align-self: center; text-align: center; font-size: 0.9rem; }
.callrow { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--stage-2); font-size: 0.98rem; opacity: 0; transform: translateY(10px); transition: opacity 0.35s var(--ease), transform 0.35s var(--ease); }
.callrow.in { opacity: 1; transform: none; }
.callrow small { margin-left: auto; color: var(--on-stage-soft); }
.callrow a { color: var(--agent); font-size: 0.84rem; }

.board { padding: 18px 20px; flex: 0 1 auto; display: flex; flex-direction: column; gap: 10px; position: relative; }
.label { font-size: 0.74rem; font-weight: 600; color: var(--on-stage-soft); display: block; margin-bottom: 7px; }
.board-row { min-height: 66px; }
.people, .claims, .offices, .chips { display: flex; gap: 10px; flex-wrap: wrap; }
.it { opacity: 0; transform: scale(0.82) translateY(8px); transition: opacity 0.45s var(--ease), transform 0.45s var(--ease); pointer-events: none; }
.it.on { opacity: 1; transform: none; }
.it.fresh { animation: pop 0.9s var(--ease); }
@keyframes pop { 0% { transform: scale(0.7); } 55% { transform: scale(1.08); } 100% { transform: none; } }
.it.gone { opacity: 0.28; }
.person { display: flex; align-items: center; gap: 10px; background: var(--stage-2); border-radius: 999px; padding: 6px 16px 6px 6px; }
.person .face { width: 40px; height: 40px; border-radius: 50%; background: var(--other); position: relative; overflow: hidden; flex: none; }
.person .face::before { content: ''; position: absolute; left: 50%; top: 9px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--stage); }
.person .face::after { content: ''; position: absolute; left: 50%; top: 26px; width: 30px; height: 24px; margin-left: -15px; border-radius: 50% 50% 0 0; background: var(--stage); }
.person.b .face { background: var(--rule); }
.person b { font-weight: 600; font-size: 1rem; display: block; line-height: 1.15; }
.person small { color: var(--on-stage-soft); font-size: 0.78rem; display: block; }
.person .badge { display: none; color: var(--agent); }
.person.badged .badge { display: block; }
.claim { background: var(--on-stage); color: var(--ink); border-radius: 12px; padding: 9px 13px; min-width: 132px; }
.claim b { display: block; font-weight: 600; font-size: 0.98rem; line-height: 1.15; }
.claim small { font-size: 0.76rem; color: var(--ink-soft); }
.office { border: 1.5px solid var(--stage-line); border-radius: 12px; padding: 8px 13px; font-size: 0.94rem; font-weight: 500; }
.office small { display: block; color: var(--on-stage-soft); font-size: 0.76rem; font-weight: 400; }
.tray { border-top: 1px solid var(--stage-line); padding-top: 12px; min-height: 84px; }
.chip { border-radius: 12px; padding: 8px 12px; background: var(--rule); color: #3a2500; font-size: 0.9rem; font-weight: 600; line-height: 1.2; position: relative; }
.chip small { display: block; font-weight: 500; font-size: 0.74rem; opacity: 0.85; }
.chip.done { background: var(--stage-2); color: var(--on-stage-soft); }
.chip.done b::before { content: '✓ '; color: var(--agent); }
.chip.cut { background: transparent; color: var(--bad); box-shadow: inset 0 0 0 1.5px var(--bad); }
.chip.cut b { text-decoration: line-through; }
.chip.cut.fresh { animation: cut 1.1s var(--ease); }
@keyframes cut { 0% { transform: none; } 18% { transform: translateX(-7px); } 36% { transform: translateX(6px); } 54% { transform: translateX(-4px); } 100% { transform: none; } }
.chip.gone, .office.gone, .person.gone { opacity: 0.3; }
.chip.gone b, .office.gone b { text-decoration: line-through; }
.tally { margin: 0; font-size: 0.86rem; color: var(--on-stage-soft); min-height: 1.3em; }
.tally b { color: var(--on-stage); font-weight: 600; }

/* The usual tool: replaces the board on its beat. */
.form { display: none; padding: 22px; background: #fff; color: var(--ink); border: 1px solid var(--line); }
.form-title { margin: 0 0 12px; font-weight: 600; color: var(--ink-soft); font-size: 0.86rem; }
.form dl { display: grid; grid-template-columns: 8.2em 1fr; gap: 8px 14px; margin: 0 0 16px; padding: 14px; border: 1px dashed var(--line); border-radius: 12px; background: var(--paper); font-size: 1rem; }
.form dt { color: var(--ink-soft); }
.form dd { margin: 0; }
.form .bad { color: #b3261e; font-weight: 600; }
.form .bad span { display: block; font-weight: 500; font-size: 0.84rem; }
.form .blob { color: var(--ink-soft); font-size: 0.9rem; }
.drip { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 0.98rem; }
.drip li { padding: 10px 12px; border-radius: 12px; background: var(--paper); }
.drip b { margin-right: 8px; }

/* The last screens need no stage. */
body[data-beat='0'] .now { display: none; }
.stage { transition: opacity 0.5s var(--ease); }

@media (max-width: 900px) {
  body { font-size: 17px; }
  .dots { display: none; }
  .layout { display: flex; flex-direction: column; padding: 0 16px; }
  .stage { order: -1; position: sticky; top: 0; height: auto; z-index: 5; padding: 54px 0 8px; background: var(--paper); gap: 8px; }
  .now { min-height: 118px; max-height: 26vh; padding: 12px 14px; border-radius: 16px; }
  .board { padding: 12px 14px; border-radius: 16px; gap: 8px; }
  .board-row { min-height: 0; }
  .offices-row, .tally { display: none; }
  .person { padding: 4px 12px 4px 4px; }
  .person .face { width: 30px; height: 30px; }
  .person .face::before { top: 6px; width: 10px; height: 10px; margin-left: -5px; }
  .person .face::after { top: 19px; width: 22px; }
  .claim { min-width: 0; padding: 6px 10px; }
  .claim small, .person small:not(.badge), .office small { display: none; }
  .tray { min-height: 0; padding-top: 8px; }
  .chip { padding: 6px 10px; font-size: 0.82rem; }
  .chip small { display: none; }
  .chip.cut small, .chip.gone small { display: block; }
  .say { font-size: 0.92rem; padding: 7px 11px; }
  .story { position: relative; z-index: 1; }
  .beat { min-height: 92vh; justify-content: flex-end; padding: 40px 0 10vh; }
  .beat h2 { font-size: 1.7rem; }
  .beat p { font-size: 1.05rem; }
  .beat.hero { justify-content: center; min-height: 100vh; }
  body[data-beat='0'] .stage { visibility: hidden; height: 0; padding: 0; overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .beat:not(.hero) > *, .it, .say, .callrow { transform: none !important; transition: opacity 0.4s linear; }
  .it.fresh, .chip.cut.fresh, .cue::after, .now-ico.live { animation: none; }
}
