/* Kafedrum — scroll-driven "How it works" explainer on the public main page. landing-stage.js reveals it and drives it.
   Removing this <link> and landing-stage.js restores the static three steps exactly.

   Idea   One memorable moment: the lecture is recorded as the app's own waveform (quiet ink, the newest stretch in the
          signal colour), then, step by step as the visitor scrolls, its lines fall out one after another as a
          transcript, settle into a summary and drop Practice questions. Everything around it stays quiet; the colours
          are the app's own theme tokens.
   Drive  The section is a scroll runway (about one screen per step); its grid stays pinned under the top bar. The text
          column shows one step at a time and swaps steps with a short rise; the panel is scrubbed by scroll:
          landing-stage.js sets --s0..--s3 on .ls (each step's progress, 0..1), panel items cascade by their --i, and
          every panel value is a pure function of those numbers, so scrolling back rewinds. */

/* The explainer replaces the hero preview cards and the static steps it retells. */
#landing-view.ls-on .wl-preview, #landing-view.ls-on #how > .wl-h2, #landing-view.ls-on #how > .wl-steps { display: none; }
#landing-view.ls-on .wl-hero { padding-bottom: 0; }
#landing-view.ls-on #how { padding-bottom: clamp(24px, 4vw, 48px); }

.ls { --s0: 0; --s1: 0; --s2: 0; --s3: 0; --ls-pin: 72px; height: calc(4 * var(--ls-story-leg, 85vh) + 100vh); }
.ls-title { margin-bottom: clamp(8px, 2vw, 24px); }
.ls-grid {
  position: sticky; top: var(--ls-pin); height: calc(100vh - var(--ls-pin) - 24px);
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: clamp(32px, 6vw, 96px); align-items: center;
}

/* ---------- the text: one step at a time, swapped as the visitor scrolls ---------- */
.ls-copy { display: grid; gap: 28px; max-width: 32rem; }
/* Four segments that fill with the scroll, so the visitor sees where they are and how much is left. */
.ls-progress { display: flex; gap: 6px; }
.ls-progress span {
  flex: 1; height: 3px; border-radius: 3px; background: var(--line-2) linear-gradient(var(--text), var(--text)) no-repeat;
  background-size: calc(var(--p) * 100%) 100%;
}
.ls-progress span:nth-child(1) { --p: var(--s0); }
.ls-progress span:nth-child(2) { --p: var(--s1); }
.ls-progress span:nth-child(3) { --p: var(--s2); }
.ls-progress span:nth-child(4) { --p: var(--s3); }
/* All steps share one cell; only the active one shows. A leaving step slides up, the arriving one rises and its lines
   follow one after another. Hidden steps stay in the accessibility tree, so a screen reader reads all four. */
.ls-steps { display: grid; margin: 0; padding: 0; list-style: none; }
.ls-step {
  grid-area: 1 / 1; display: grid; align-content: start; gap: 14px; pointer-events: none;
  opacity: 0; transform: translateY(24px); transition: opacity .35s var(--ease-out, ease), transform .45s var(--ease-out, ease);
}
.ls-step.is-past { transform: translateY(-24px); }
.ls-step.is-active { opacity: 1; transform: none; pointer-events: auto; transition-delay: .12s; }
.ls-step.is-active > *, .ls-step.is-active .ls-points li { animation: ls-rise .55s var(--ease-out, ease) both; }
.ls-step.is-active > h3 { animation-delay: .14s; }
.ls-step.is-active > p { animation-delay: .22s; }
.ls-step.is-active > .ls-points { animation: none; }
.ls-step.is-active .ls-points li:nth-child(1) { animation-delay: .3s; }
.ls-step.is-active .ls-points li:nth-child(2) { animation-delay: .38s; }
.ls-step.is-active .ls-points li:nth-child(3) { animation-delay: .46s; }
@keyframes ls-rise { from { opacity: 0; transform: translateY(14px); } }
.ls-step-num { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 999px; background: var(--text); color: var(--bg); box-shadow: 0 0 0 4px color-mix(in srgb, var(--signal) 45%, transparent); font: 700 15px/1 var(--display); font-variant-numeric: tabular-nums; }
.ls-step h3 { margin: 0; color: var(--text); font: 700 clamp(28px, 2.8vw, 40px)/1.1 var(--display); letter-spacing: -.03em; text-wrap: balance; }
.ls-step p { margin: 0; color: var(--muted); font: 400 18px/1.55 var(--display); }
.ls-points { display: grid; gap: 10px; margin: 6px 0 0; padding: 16px 0 0; border-top: 1px solid var(--line); list-style: none; }
.ls-points li { position: relative; padding-left: 22px; color: var(--text); font: 400 16px/1.45 var(--display); }
.ls-points li::before { content: ""; position: absolute; left: 2px; top: .66em; width: 8px; height: 2px; border-radius: 2px; background: var(--signal); }

/* ---------- the panel ---------- */
.ls-stage { height: 100%; display: grid; align-items: center; justify-items: center; }
.ls-device {
  position: relative; width: 100%; max-width: 520px; height: min(620px, 100%);
  display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden;
  border-radius: 28px; background: var(--panel); box-shadow: 0 0 0 1px var(--line), 0 40px 90px -48px rgba(0, 0, 0, .55);
}
:root[data-theme="light"] .ls-device { box-shadow: 0 0 0 1px var(--line), 0 40px 90px -48px rgba(54, 36, 18, .35); }
.ls-bar { display: flex; align-items: center; gap: 10px; padding: 18px 22px 12px; color: var(--text); font: 600 14px/1.2 var(--display); }
.ls-dot { width: 10px; height: 10px; flex: none; border-radius: 999px; background: var(--signal); }
.ls-device[data-scene="0"] .ls-dot { animation: ls-pulse 1.4s ease-in-out infinite; }
.ls-device:not([data-scene="0"]) .ls-dot { background: var(--good); }
@keyframes ls-pulse { 50% { opacity: .35; } }
.ls-status { display: none; }
.ls-device[data-scene="0"] .ls-status-0, .ls-device[data-scene="1"] .ls-status-1,
.ls-device[data-scene="2"] .ls-status-2, .ls-device[data-scene="3"] .ls-status-3 { display: inline; }
.ls-timer { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }

.ls-layers { position: relative; }
.ls-kicker { color: var(--subtle); font: 500 13px/1.4 var(--display); }

/* Step 1: the recording waveform. It fills the panel while recording, then squeezes to a band above the transcript and
   fades as the summary takes its place; older audio fades out to the left. The canvas is drawn by landing-stage.js. */
.ls-wave {
  position: absolute; inset: 0 0 auto; height: calc(100% - min(1, var(--s1) * 4) * 82%); opacity: calc(1 - var(--s2) * 8.5);
  -webkit-mask: linear-gradient(to right, transparent, #000 35%); mask: linear-gradient(to right, transparent, #000 35%);
}
.ls-wave canvas { display: block; width: 100%; height: 100%; }

/* Step 2: transcript lines fall into place one after another, a short drop so wrapped lines never overlap. */
.ls-lines {
  position: absolute; inset: 21% 22px auto; display: grid; gap: 12px; margin: 0; padding: 0; list-style: none;
  opacity: calc(1 - var(--s2) * 8.5); transform: translateY(calc(var(--s2) * -48px));
}
.ls-lines li {
  --k: clamp(0, (var(--s1) - .25) * 12 - var(--i) * 1.2, 1);
  color: var(--text); font: 400 15px/1.45 var(--display);
  opacity: var(--k); transform: translateY(calc((1 - var(--k)) * -10px));
}

/* Step 3: the waveform band and the transcript have left by 12 % of the step (they sit where the summary's first lines
   arrive, so they must never be under them); then the summary assembles from the top. */
.ls-summary {
  position: absolute; inset: 4px 22px auto; display: grid; gap: 10px;
  opacity: calc(1 - var(--s3) * .55); transform: translateY(calc(var(--s3) * -12px));
}
.ls-summary > * {
  --k: clamp(0, (var(--s2) - .12) * 9.5 - var(--i) * 1.4, 1);
  opacity: var(--k); transform: translateY(calc((1 - var(--k)) * -10px));
}
.ls-summary-title { color: var(--text); font: 700 26px/1.15 var(--display); letter-spacing: -.025em; }
.ls-row { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); color: var(--text); font: 500 16px/1.35 var(--display); }
.ls-formula { padding: 12px 14px; border-radius: var(--radius-md, 12px); background: var(--panel-2); color: var(--text); font: 500 16px/1.4 var(--display); font-variant-numeric: tabular-nums; }

/* Step 4: questions drop in under the dimmed summary. */
.ls-practice { position: absolute; inset: auto 16px 16px; display: grid; gap: 10px; }
.ls-practice > * {
  --k: clamp(0, var(--s3) * 6 - var(--i) * 1.4, 1);
  opacity: var(--k); transform: translateY(calc((1 - var(--k)) * -16px));
}
.ls-question { display: grid; gap: 6px; padding: 18px 20px; border-radius: 18px; background: var(--panel-3); color: var(--text); box-shadow: 0 20px 40px -24px rgba(0, 0, 0, .5); }
.ls-question strong { font: 700 18px/1.3 var(--display); letter-spacing: -.01em; }
.ls-question-next { background: var(--panel-2); box-shadow: none; }
.ls-question-next strong { color: var(--muted); font-weight: 600; font-size: 16px; }
.ls-verdict { display: flex; align-items: center; gap: 8px; padding: 0 6px; color: var(--warn); font: 600 14px/1.35 var(--display); }
.ls-verdict-dot { width: 8px; height: 8px; flex: none; border-radius: 999px; background: currentColor; }

/* ---------- phones and tablets: panel on top, the step's text under it, both pinned ---------- */
@media (max-width: 850px) {
  .ls { --ls-pin: 56px; height: calc(4 * var(--ls-story-leg, 80vh) + 100vh); }
  .ls-grid { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); align-items: start; gap: 18px; height: calc(100vh - var(--ls-pin) - 8px); padding-top: 8px; }
  .ls-stage { order: -1; height: auto; }
  .ls-device { height: min(42vh, 380px); max-width: none; border-radius: 22px; }
  .ls-copy { gap: 16px; max-width: none; }
  .ls-step { gap: 10px; }
  .ls-step-num { display: none; }
  .ls-step h3 { font-size: 26px; }
  .ls-step p { font-size: 16px; }
  .ls-points { gap: 6px; padding-top: 12px; }
  .ls-points li { font-size: 15px; }
  .ls-bar { padding: 14px 16px 8px; }
  .ls-lines { inset: 23% 16px auto; gap: 8px; }
  .ls-lines li { font-size: 14px; }
  .ls-summary { inset: 0 16px auto; gap: 6px; }
  .ls-summary-title { font-size: 21px; }
  .ls-row { padding: 7px 0; font-size: 14px; }
  .ls-formula { padding: 8px 10px; font-size: 14px; }
  .ls-practice { inset: auto 10px 10px; gap: 8px; }
  .ls-question { padding: 12px 14px; border-radius: 14px; }
  .ls-question strong { font-size: 16px; }
  .ls-question-next { display: none; }
}
@media (max-width: 850px) {
  .ls-lines li:nth-child(n+5) { display: none; }
  /* The short panel cannot hold the summary and the questions: the summary leaves first (no text under a card). */
  .ls-summary { opacity: calc(1 - var(--s3) * 8); }
  /* The rows sit 6px apart here: a shorter drop keeps an arriving row off the one above it. */
  .ls-summary > * { transform: translateY(calc((1 - var(--k)) * -5px)); }
  .ls-practice > * { --k: clamp(0, (var(--s3) - .14) * 7 - var(--i) * 1.4, 1); }
}
@media (max-width: 850px) and (max-height: 760px) {
  .ls-points { display: none; }
}
@media (max-width: 850px) and (max-height: 700px) {
  .ls-lines li:nth-child(n+4) { display: none; }
  .ls-summary .ls-row:last-child { display: none; }
}

/* Reduced motion: no movement, the steps simply cross-fade; the waveform is drawn once, still. */
@media (prefers-reduced-motion: reduce) {
  .ls-lines, .ls-lines li, .ls-summary, .ls-summary > *, .ls-practice > *, .ls-step, .ls-step.is-past { transform: none !important; }
  .ls-step.is-active > *, .ls-step.is-active .ls-points li { animation: none; }
  .ls-device[data-scene="0"] .ls-dot { animation: none; }
}

@media (prefers-reduced-motion: reduce) { .ls-step, .ls-device, .ls-lines, .ls-summary, .ls-practice { transition: none !important; } }
