/* =============================================================================
   Sublinea · motion system v1 · "desembaçar + traço"
   One gesture, everywhere: a memory surfaces from fog, clears, then the marker
   passes over it. Scroll is time: things surface as you reach them and recede
   into fog as you leave them. Depth sets blur AND speed (farther = blurrier =
   slower).

   Rules this file follows (read before extending it):
   1. Content is visible by default. Every effect is additive. No support, no
      script, reduced motion or a non-scrolling canvas frame = the final, sharp,
      marked state.
   2. Every time-based or scroll-linked effect lives inside
      @media (prefers-reduced-motion: no-preference). States (hover colours,
      bands, focus rings) live outside, so reduced motion still gets instant,
      legible state changes.
   3. Property lanes, so effects compose without wrapper divs:
        translate  -> scroll-linked parallax only
        transform  -> time-based entrances, ambient float, hover and press
        filter + opacity -> fog (load and scroll; ordering rules in section 4)
        background-size -> the marker sweep (the one paint-bound exception;
                           small inline spans only, one or two at a time)
   4. Scroll-driven animations: always write the `animation` shorthand FIRST
      and `animation-timeline` / `animation-range` AFTER it (the shorthand
      resets the timeline to auto).
   5. A view() timeline binds to the nearest scroll container. Any ancestor
      with overflow: hidden/auto/scroll silently breaks it (and sticky). Use
      overflow: clip on decorative clippers (.lr-page, .h-close, .hm-mail,
      .hm-plan.pro).
   6. Canvas boards: CSS only. No IntersectionObserver is needed; production
      may add the optional "latch" mode (section 10) for one-shot reveals in
      browsers without scroll timelines.
   7. The Mac app (WKWebView, macOS 11+, WebKit as old as Safari 14) only uses
      sections 1, 2, 4 (.sb-gesture-load), 8, 12: no scroll timelines, no
      @property, no :focus-visible grouped with other selectors, literal
      values inside keyframes the app uses (sb-clear, sb-sweep, section 8).
   8. Load order: tokens.css, components.css, motion.css. components.css owns
      every component STATE (buttons, links, chips, fields, the code input,
      cards, wordmark, marks, static [data-depth] fog). This file owns
      ENTRANCES and SCROLL SCENES only. It defines no button, link, code or
      logo rules (director merge, 20/11), and reuses components.css's
      sb-sweep keyframe.
   ============================================================================= */


/* 1 · Tokens ----------------------------------------------------------------- */
/* Source of truth = system/tokens.css section 11. Every --sb-* below is an
   alias with a fallback, so motion.css also works standalone (canvas boards
   that only link site.css). Only --sb-ease-hand and --sb-dur-sheen are new;
   both are proposed for tokens.css. */

:root {
  /* Easing */
  --sb-ease-out: var(--ease-out, cubic-bezier(0.23, 1, 0.32, 1));      /* house curve (shipping value) */
  --sb-ease-defog: var(--ease-defog, cubic-bezier(0.16, 1, 0.3, 1));   /* focus pulls in fast, settles long */
  --sb-ease-in: var(--ease-in, cubic-bezier(0.55, 0, 1, 0.45));        /* exits only */
  --sb-ease-sweep: var(--ease-sweep, cubic-bezier(0.22, 0.8, 0.24, 1)); /* one-line marks, UI bands */
  --sb-ease-hand: var(--ease-hand, cubic-bezier(0.42, 0.06, 0.28, 1));  /* multi-line mark, steady hand, line after line */
  --sb-ease-inout: var(--ease-in-out, cubic-bezier(0.65, 0, 0.35, 1));  /* loops, rotator, float */

  /* Durations */
  --sb-dur-press: var(--dur-instant, 90ms);
  --sb-dur-fast: var(--dur-quick, 160ms);
  --sb-dur-base: var(--dur-base, 240ms);
  --sb-dur-step: var(--dur-calm, 420ms);        /* app step enters, hover band grows */
  --sb-dur-exit: var(--dur-exit, 180ms);
  --sb-dur-slow: var(--dur-slow, 700ms);        /* peek, rise on reveal (latch mode) */
  --sb-dur-clear: var(--dur-defog, 1600ms);     /* focal: a passage clears */
  --sb-dur-sweep: var(--dur-sweep, 1100ms);     /* focal: marker after the defog */
  --sb-dur-sweep-short: var(--dur-sweep-short, 650ms);
  --sb-dur-word: var(--dur-word, 2500ms);
  --sb-stagger: var(--stagger, 90ms);
  --sb-stagger-tight: var(--stagger-tight, 50ms);

  /* Distances */
  --sb-rise-sm: var(--rise-sm, 8px);
  --sb-rise: var(--rise, 18px);
  --sb-rise-lg: var(--rise-lg, 36px);
  --sb-lift: var(--lift, -2px);
  --sb-press: var(--press-scale, 0.97);
  --sb-nudge: var(--nudge, 3px);

  /* Fog: the depth scale (0 = now, sharp; 3 = far past). Same levels drive
     blur, opacity and parallax speed. */
  --sb-blur-clear: var(--blur-defog-start, 12px);
  --sb-blur-pass: var(--blur-pass, 2.5px);
  --sb-d1-blur: var(--depth-1-blur, 1.5px); --sb-d1-o: var(--depth-1-opacity, 0.78); --sb-d1-v: var(--depth-1-speed, -0.05);
  --sb-d2-blur: var(--depth-2-blur, 3px);   --sb-d2-o: var(--depth-2-opacity, 0.56); --sb-d2-v: var(--depth-2-speed, -0.11);
  --sb-d3-blur: var(--depth-3-blur, 5.5px); --sb-d3-o: var(--depth-3-opacity, 0.36); --sb-d3-v: var(--depth-3-speed, -0.18);

  /* Scroll ranges (view timelines) */
  --sb-range-reveal: cover 0% cover 30%;  /* sharp before it reaches the lower third */
  --sb-range-sweep: cover 20% cover 48%;  /* marker passes once its text is sharp */
  --sb-range-scene: cover 0% cover 100%;  /* parallax across a whole section */

  /* The four lights */
  --sb-butter: var(--butter-aura, #FBE7A1);
  --sb-rose: var(--rose-aura, #F6C9D6);
  --sb-sky: var(--sky-aura, #C7DDF4);
  --sb-peach: var(--peach-aura, #F8D3B0);
  --sb-mark-butter: var(--butter-mark, rgba(250, 222, 146, 0.95));
  --sb-mark-rose: var(--rose-mark, rgba(244, 190, 207, 0.95));
  --sb-mark-sky: var(--sky-mark, rgba(190, 216, 242, 0.95));
  --sb-mark-peach: var(--peach-mark, rgba(247, 203, 162, 0.95));
}

/* Phones and small tablets: parallax at half speed, no pinning, no ambient float */
@media (max-width: 899px) {
  :root { --sb-speed-scale: 0.5; }
}

/* 2 · Keyframes (shared) ---------------------------------------------------- */

/* The gesture, part 1: desembaçar */
@keyframes sb-clear {   /* literal: the app uses it (first found highlight) */
  0%   { filter: blur(12px); opacity: 0.28; }
  60%  { opacity: 0.94; }
  100% { filter: blur(0); opacity: 1; }
}
/* The gesture, part 2: o traço = components.css @keyframes sb-sweep
   (background-size 0% -> 100%). Marks are box-decoration-break: slice
   system-wide, so a multi-line mark sweeps line after line, like a hand. */
/* Arrive: lift out of the fog */
@keyframes sb-rise {
  from { transform: translate3d(0, var(--sb-rise, 18px), 0); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
@keyframes sb-rise-fog {
  from { transform: translate3d(0, var(--sb-rise, 18px), 0); opacity: 0; filter: blur(6px); }
  to   { transform: none; opacity: 1; filter: blur(0); }
}
/* Scroll-linked fog-in (no movement, pure focus pull) */
@keyframes sb-fog-in {
  from { filter: blur(var(--sb-blur-clear, 12px)); opacity: 0.25; }
  to   { filter: blur(0); opacity: 1; }
}
/* Recede: a memory going back into fog as you leave it */
@keyframes sb-recede {
  from { filter: blur(0); }
  to   { filter: blur(var(--sb-d2-blur, 3px)); }   /* goes back to depth 2 */
}
@keyframes sb-dim {
  from { opacity: 1; }
  to   { opacity: 0.56; }
}
/* Parallax on the `translate` lane. --sb-speed is the depth's fraction of
   scroll (negative = drifts up slower, i.e. farther away). A scene's scroll
   distance is about one viewport plus its height; 100vh is the CSS-only
   approximation. Rest position = scene centred in view. */
@keyframes sb-drift {
  from { translate: 0 calc(var(--sb-speed, 0) * var(--sb-speed-scale, 1) * 50vh); }
  to   { translate: 0 calc(var(--sb-speed, 0) * var(--sb-speed-scale, 1) * -50vh); }
}
/* Hero parallax: rest position = top of the page (scroll 0) */
@keyframes sb-drift-out {
  from { translate: 0 0; }
  to   { translate: 0 calc(var(--sb-speed, 0) * var(--sb-speed-scale, 1) * -100vh); }
}
/* Ambient float on the `transform` lane; slow, meditative */
@keyframes sb-float {
  0%   { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(var(--sb-fx, 10px), var(--sb-fy, -6px), 0); }
}
/* SVG thread drawing (needs pathLength="1") */
@keyframes sb-draw {
  from { stroke-dashoffset: 1; }
  to   { stroke-dashoffset: 0; }
}
/* Band grows from the left */
@keyframes sb-band {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}
/* Page progress */
@keyframes sb-progress {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}
/* Nav frost */
@keyframes sb-frost {
  from { opacity: 0; }
  to   { opacity: 1; }
}
/* Rotating e-reader word: surfaces, gets marked, holds, recedes (10s cycle) */
@keyframes sb-rot {
  0%       { opacity: 0; filter: blur(8px); background-size: 0% 100%; }
  5%       { opacity: 1; filter: blur(0); background-size: 0% 100%; }
  14%      { background-size: 100% 100%; }
  21%      { opacity: 1; filter: blur(0); background-size: 100% 100%; }
  25%, 100% { opacity: 0; filter: blur(8px); background-size: 100% 100%; }
}
/* A source that isn't ready yet: the slot arrives sharp (so its "soon" pill is
   crisp) but never gets the band; the word inside stays at depth 1 through
   .sb-rotate__word, so it never fully clears. */
@keyframes sb-rot-soon {
  0%        { opacity: 0; filter: blur(8px); }
  5%, 21%   { opacity: 1; filter: blur(0); }
  25%, 100% { opacity: 0; filter: blur(8px); }
}
@keyframes sb-rot-rest {
  0%   { opacity: 0; filter: blur(8px); background-size: 0% 100%; }
  40%  { opacity: 1; filter: blur(0); background-size: 0% 100%; }
  100% { opacity: 1; filter: blur(0); background-size: 100% 100%; }
}
/* The "now" ring travels back along the month axis as you scroll out of
   the hero (Nov -> Feb, the month the morning passage was marked).
   --sb-travel is set inline: -(index(now) - index(target)) / (months - 1) * 100% */
@keyframes sb-back-in-time {
  from { translate: 0 0; }
  to   { translate: var(--sb-travel, -90%) 0; }
}
/* "Today" ring on the month axis: one pulse, then still */
@keyframes sb-today {
  0%   { box-shadow: 0 0 0 0 rgba(251, 231, 161, 0.0); }
  40%  { box-shadow: 0 0 0 10px rgba(251, 231, 161, 0.95); }
  100% { box-shadow: 0 0 0 5px rgba(251, 231, 161, 0.9); }
}


/* 3 · Static depth + fog (no motion; safe everywhere) ------------------------ */

.sb-parallax[data-depth="1"], .sb-parallax[data-speed="1"] { --sb-speed: var(--sb-d1-v); }
.sb-parallax[data-depth="2"], .sb-parallax[data-speed="2"] { --sb-speed: var(--sb-d2-v); }
.sb-parallax[data-depth="3"], .sb-parallax[data-speed="3"] { --sb-speed: var(--sb-d3-v); }
/* a card that leads the page slightly (only the hero's morning card uses it) */
.sb-parallax[data-speed="lead"] { --sb-speed: 0.06; }
/* data-depth = fog (blur + opacity, components.css) AND speed.
   data-speed = speed only: aura spans, the hero card, the wall's columns. */

/* Line-by-line marker: .sb-mark is slice in components.css (decided 20/11);
   these are the non-.sb-mark elements that carry a band. */
.sb-sweep, .sb-rotate > span {
  -webkit-box-decoration-break: slice;
  box-decoration-break: slice;
}

/* Rotating word: grid-stacked, first word is the resting word (Kindle works today) */
.sb-rotate { display: inline-grid; vertical-align: bottom; justify-items: start; }
.sb-rotate > span { grid-area: 1 / 1; white-space: nowrap; opacity: 0; }
.sb-rotate > span:first-child { opacity: 1; }
/* Words 2-4 (sources not ready yet): the word stays at depth 1, a sharp
   "soon" pill sits after it, outside the reserved width.
   <span aria-hidden="true"><b class="sb-rotate__word">Apple Books</b><i class="sb-pill sb-pill--sm sb-rotate__soon">soon</i></span> */
.sb-rotate > span { position: relative; }
.sb-rotate__word { font-weight: inherit; filter: blur(1.5px); opacity: 0.72; }
.sb-rotate__soon { position: absolute; left: 100%; top: 0.18em; margin-left: 0.2em; font-style: normal; letter-spacing: 0; }
/* Phones: the word never rotates; "Kindle" is true today. No orphaned "Your". */
@media (max-width: 599px) {
  .sb-rotate { display: inline; }
  .sb-rotate > span:not(:first-child) { display: none; }
}

/* Coming soon: the future is still fogged. Heading, copy and pill stay sharp;
   the example content (aria-hidden) is mist that clears only on a peek. */
.sb-peek > * { filter: blur(var(--sb-d2-blur)); opacity: var(--sb-d2-o); }   /* the future sits at depth 2 */
@media (hover: hover) and (pointer: fine) {
  .sb-peek > *:hover { filter: blur(0); opacity: 1; }
}
@media (prefers-reduced-motion: no-preference) {
  .sb-peek > * { transition: filter var(--sb-dur-slow) var(--sb-ease-out), opacity var(--sb-dur-slow) var(--sb-ease-out); }
}

/* Page progress + nav frost are hidden/solid without scroll timelines */
.sb-progress { display: none; }
.sb-nav { position: relative; isolation: isolate; }
.sb-nav::before {
  content: ""; position: absolute; z-index: -1; left: -100vw; right: -100vw; top: 0; bottom: 0;
  background: rgba(251, 250, 247, 0.72);
  -webkit-backdrop-filter: blur(20px) saturate(140%); backdrop-filter: blur(20px) saturate(140%);
  box-shadow: inset 0 -1px 0 rgba(35, 38, 43, 0.06);
  opacity: 0; pointer-events: none;
}


/* 4 · Load-time gesture (hero, email web view, app "found" passage) ---------- */
/* Usage: <blockquote class="sb-gesture-load"><span class="lr-mark yellow">…</span></blockquote>
   Optional inline offsets: style="--sb-at: 500ms; --sb-sweep-at: 1300ms" */

@media (prefers-reduced-motion: no-preference) {
  .sb-gesture-load {
    animation: sb-clear var(--sb-dur-clear) var(--sb-ease-defog) var(--sb-at, 250ms) both;
  }
  .sb-gesture-load :is(.lr-mark, .sb-mark) {
    animation: sb-sweep var(--sb-dur-sweep) var(--sb-ease-hand) var(--sb-sweep-at, 1600ms) both;
  }

  /* Intro pieces: readable within ~250ms (they start at 0.35 opacity, never 0) */
  .sb-intro {
    animation: sb-intro var(--sb-dur-step) var(--sb-ease-out) var(--sb-at, 0ms) both;
  }
  .sb-arrive {
    animation: sb-rise var(--sb-dur-step) var(--sb-ease-out) var(--sb-at, 200ms) both;
  }
  .sb-arrive-fog {
    animation: sb-rise-fog 700ms var(--sb-ease-out) var(--sb-at, 200ms) both;
  }

  /* Rotating word: ONE cycle (10 s: Kindle, Apple Books, Kobo, Google Play
     Books), then rests on Kindle, marked. One cycle keeps WCAG 2.2.2 exposure
     short; reduced motion shows Kindle only. */
  .sb-rotate > span {
    animation: sb-rot-soon 10s var(--sb-ease-inout) 1 backwards;
  }
  .sb-rotate > span:nth-child(2) { animation-delay: 2.5s; }
  .sb-rotate > span:nth-child(3) { animation-delay: 5s; }
  .sb-rotate > span:nth-child(4) { animation-delay: 7.5s; }
  .sb-rotate > span:first-child {
    animation: sb-rot 10s var(--sb-ease-inout) 0s 1 backwards,
               sb-rot-rest 1100ms var(--sb-ease-out) 10s 1 forwards;
  }

  /* Month axis: "now" pulses once when the morning passage has been marked */
  .sb-now::before { animation: sb-today 900ms var(--sb-ease-out) 2800ms 1 both; }

  /* Ambient float for hero fog layers only (3 primes so they never sync) */
  .sb-float { animation: sb-float 19s var(--sb-ease-inout) infinite alternate both; will-change: transform; }
  .sb-float:nth-child(3n+2) { --sb-fx: -12px; --sb-fy: 5px; animation-duration: 23s; }
  .sb-float:nth-child(3n)   { --sb-fx: 8px;  --sb-fy: 8px; animation-duration: 29s; }
}
@keyframes sb-intro {
  from { opacity: 0.35; filter: blur(6px); transform: translate3d(0, 12px, 0); }
  to   { opacity: 1; filter: blur(0); transform: none; }
}


/* 5 · Scroll-driven layer (site + email web view; canvas Play mode) ---------- */

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {

    /* .sb-reveal: lift out of light fog as you reach it */
    .sb-reveal {
      animation: sb-rise-fog linear both;
      animation-timing-function: var(--sb-ease-out);
      animation-timeline: view();
      animation-range: var(--sb-range-reveal);
    }

    /* .sb-fog-in: pure focus pull, no movement (big headlines, quotes) */
    .sb-fog-in {
      animation: sb-fog-in linear both;
      animation-timing-function: var(--sb-ease-out);
      animation-timeline: view();
      animation-range: var(--sb-range-reveal);
    }

    /* .sb-sweep: the marker passes over a mark once its text is sharp */
    .sb-sweep {
      animation: sb-sweep linear both;
      animation-timing-function: var(--sb-ease-hand);
      animation-timeline: view();
      animation-range: var(--sb-range-sweep);
    }

    /* .sb-gesture: container clears, then its marks sweep (the full gesture on scroll) */
    .sb-gesture {
      view-timeline: --sb-g block;
      animation: sb-fog-in linear both;
      animation-timing-function: var(--sb-ease-out);
      animation-timeline: view();
      animation-range: cover 0% cover 25%;
    }
    .sb-gesture :is(.lr-mark, .sb-mark) {
      animation: sb-sweep linear both;
      animation-timing-function: var(--sb-ease-hand);
      animation-timeline: --sb-g;
      animation-range: cover 22% cover 50%;
    }

    /* .sb-stagger: siblings arrive one after another (cap: 4 steps) */
    .sb-stagger > * {
      animation: sb-rise-fog linear both;
      animation-timing-function: var(--sb-ease-out);
      animation-timeline: view();
      animation-range: cover calc(var(--sb-i, 0) * 3%) cover calc(28% + var(--sb-i, 0) * 3%);
    }
    .sb-stagger > :nth-child(2) { --sb-i: 1; }
    .sb-stagger > :nth-child(3) { --sb-i: 2; }
    .sb-stagger > :nth-child(4) { --sb-i: 3; }
    .sb-stagger > :nth-child(n+5) { --sb-i: 4; }

    /* .sb-scene + .sb-parallax[data-depth]: layers drift at depth speed
       across the scene (rest position = scene centred in view) */
    .sb-scene { view-timeline: --sb-scene block; }
    .sb-scene .sb-parallax {
      animation: sb-drift linear both;
      animation-timeline: --sb-scene;
      animation-range: var(--sb-range-scene);
    }

    /* Hero scene: rest position = top of page; drifts out as you leave */
    .sb-hero .sb-parallax {
      animation: sb-drift-out linear both;
      animation-timeline: scroll(root);
      animation-range: 0px 100vh;
    }
    /* The morning passage recedes into fog as another memory surfaces */
    .sb-hero .sb-recede {
      animation: sb-clear var(--sb-dur-clear) var(--sb-ease-defog) var(--sb-at, 250ms) both,
                 sb-recede linear forwards;
      animation-timeline: auto, scroll(root);
      animation-range: normal, 35vh 90vh;
    }
    .sb-hero .sb-dim-out {
      animation: sb-dim linear forwards;
      animation-timeline: scroll(root);
      animation-range: 35vh 90vh;
    }
    /* Foreground memory sharpens while the morning one recedes (budget: this
       one + .sb-recede = the hero's 2 animated blurs) */
    .sb-hero .sb-surface-up {
      animation: sb-surface-up linear both;
      animation-timeline: scroll(root);
      animation-range: 20vh 80vh;
    }

    /* The "now" ring walks back to the month the morning passage was marked */
    .sb-hero .sb-now-rail {
      animation: sb-back-in-time linear both;
      animation-timing-function: var(--sb-ease-inout);
      animation-timeline: scroll(root);
      animation-range: 10vh 85vh;
    }
    /* ...and that month's label gets its band as the ring arrives */
    .sb-hero .sb-month-mark {
      animation: sb-sweep linear both;
      animation-timing-function: var(--sb-ease-sweep);
      animation-timeline: scroll(root);
      animation-range: 78vh 92vh;
    }

    /* Thread between two passages draws as you read down the stage */
    .sb-draw path {
      stroke-dasharray: 1;
      animation: sb-draw linear both;
      animation-timeline: --sb-scene;
      animation-range: cover 25% cover 60%;
    }

    /* Page progress: a marker band drawing across the top while you read */
    .sb-progress {
      display: block; position: fixed; z-index: 60; left: 0; right: 0; top: 0; height: 3px;
      pointer-events: none; transform-origin: 0 50%;
      background: linear-gradient(90deg, var(--sb-butter), var(--sb-rose) 38%, var(--sb-sky) 70%, var(--sb-peach));
      animation: sb-progress linear both;
      animation-timeline: scroll(root);
    }

    /* Nav: sticky, frosts after the first 120px of scroll */
    .sb-nav { position: sticky; top: 0; z-index: 50; }
    .sb-nav::before {
      animation: sb-frost linear both;
      animation-timeline: scroll(root);
      animation-range: 40px 160px;
    }
  }
}
/* S4: the closing CTA's four-colour bloom (components.css .sb-btn::before)
   lights once, at half strength, as the section passes the centre. */
@keyframes sb-beckon {
  0%, 100% { opacity: 0; scale: 0.72 0.6; }
  50%      { opacity: 0.5; scale: 1 1; }
}
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .sb-beckon:not(:hover):not(:focus)::before {
      animation: sb-beckon linear both;
      animation-timeline: view();
      animation-range: cover 45% cover 60%;
    }
  }
}
@keyframes sb-surface-up {   /* depth 1 -> depth 0: a memory comes forward */
  from { filter: blur(var(--sb-d1-blur, 1.5px)); opacity: var(--sb-d1-o, 0.78); }
  to   { filter: blur(0); opacity: 1; }
}

/* Without scroll timelines the sticky nav (if used) is simply frosted */
@supports not (animation-timeline: view()) {
  .sb-nav::before { opacity: 1; }
}


/* 6 · Signature: "the email assembles" (How it works, desktop >= 1100px) ------
   Markup: <section class="sb-story"> <ol> <li class="sb-story-step">…×3 </ol>
           <div class="sb-story-stage"> mail sheet with .sb-story-body, each book block .sb-story-item </div>
   Step 1 (Your rhythm) = the sheet's header "From Sublinea · 8:00 AM" is sharp, body fogged.
   Step 1 active: card body fogged. Step 2: your library is read (half fog).
   Step 3: the passages clear and are marked, one after another.
   No support / phones / reduced motion: card is simply sharp and marked. */

@supports (timeline-scope: --sb-a) and (animation-timeline: view()) {
  @media (min-width: 1100px) and (prefers-reduced-motion: no-preference) {
    .sb-story { timeline-scope: --sb-st1, --sb-st2, --sb-st3; }
    .sb-story-step { padding-block: 18vh; }
    .sb-story-step:nth-child(1) { view-timeline: --sb-st1 block; }
    .sb-story-step:nth-child(2) { view-timeline: --sb-st2 block; }
    .sb-story-step:nth-child(3) { view-timeline: --sb-st3 block; }
    .sb-story-stage { position: sticky; top: 14vh; align-self: start; }

    .sb-story-body {
      animation: sb-story-read linear both, sb-story-clear linear forwards;
      animation-timeline: --sb-st2, --sb-st3;
      animation-range: cover 30% cover 50%, cover 30% cover 50%;
    }
    .sb-story-body :is(.lr-mark, .sb-mark) {
      animation: sb-sweep linear both;
      animation-timing-function: var(--sb-ease-hand);
      animation-timeline: --sb-st3;
      animation-range: cover calc(45% + var(--sb-i, 0) * 6%) cover calc(58% + var(--sb-i, 0) * 6%);
    }
    /* each .sb-story-item carries its order inline: style="--sb-i: 0|1|2" */

    /* Each step marks its own title as it becomes the current one */
    .sb-story-step h3 :is(.lr-mark, .sb-mark) {
      animation: sb-sweep linear both;
      animation-timeline: view();
      animation-range: cover 35% cover 48%;
    }
  }
}
@keyframes sb-story-read {
  from { filter: blur(10px); opacity: 0.35; }
  to   { filter: blur(4px); opacity: 0.75; }
}
@keyframes sb-story-clear {
  from { filter: blur(4px); opacity: 0.75; }
  to   { filter: blur(0); opacity: 1; }
}


/* 7 · Buttons, links, logo: owned by components.css (.sb-btn, .sb-btn--quiet,
   .sb-link, .sb-wordmark). Nothing here. The only scroll-linked button
   effect is .sb-beckon (section 5). */


/* 8 · App (WKWebView, macOS 11+) — class-toggled by the existing JS ---------- */
/* Literal values inside keyframes on purpose (old WebKit + var() in keyframes). */

/* The window opens on opacity + travel only: it carries backdrop-filter, so
   it never animates filter. Its body defogs instead (sb-win-defog). */
@keyframes sb-win-in {
  from { opacity: 0; transform: translate3d(0, 8px, 0) scale(0.985); }
  to   { opacity: 1; transform: none; }
}
@keyframes sb-win-defog {
  from { filter: blur(6px); }
  to   { filter: blur(0); }
}
@keyframes sb-step-in {
  from { opacity: 0; filter: blur(6px); transform: translate3d(24px, 0, 0); }
  to   { opacity: 1; filter: blur(0); transform: none; }
}
@keyframes sb-step-in-back {
  from { opacity: 0; filter: blur(6px); transform: translate3d(-24px, 0, 0); }
  to   { opacity: 1; filter: blur(0); transform: none; }
}
@keyframes sb-step-out {
  from { opacity: 1; filter: blur(0); transform: none; }
  to   { opacity: 0; filter: blur(6px); transform: translate3d(-16px, 0, 0); }
}
@keyframes sb-step-out-back {
  from { opacity: 1; filter: blur(0); transform: none; }
  to   { opacity: 0; filter: blur(6px); transform: translate3d(16px, 0, 0); }
}
@keyframes sb-value {
  from { opacity: 0; filter: blur(4px); }
  to   { opacity: 1; filter: blur(0); }
}
@keyframes sb-unlock {
  from { opacity: 0.35; filter: blur(4px); }
  to   { opacity: 1; filter: blur(0); }
}
/* The panel comes back after a sheet closes */
@keyframes sb-panel-clear {
  from { opacity: 0.4; filter: blur(4px); }
  to   { opacity: 1; filter: blur(0); }
}
@keyframes sb-panel-clear-rm {
  from { opacity: 0.4; }
  to   { opacity: 1; }
}
/* An ink check draws (needs pathLength="1" on the path) */
@keyframes sb-check-draw {
  from { stroke-dashoffset: 1; }
  to   { stroke-dashoffset: 0; }
}
/* Sheet content defogs while the sheet rises (sb-sheet-in, components.css) */
@keyframes sb-sheet-defog {
  from { filter: blur(6px); }
  to   { filter: blur(0); }
}
/* The panel behind a sheet recedes: opacity only, to whatever its
   [data-fogged] rule sets (.4, or .28 for "deep") */
@keyframes sb-recede-panel {
  from { opacity: 1; }
}
/* First review: older highlights step back one depth level as a new one
   arrives (sharp -> depth 1 -> depth 2 -> depth 3). Each animates FROM the
   level in front of it to the [data-depth] it rests at. */
@keyframes sb-step-back-1 { from { filter: blur(0); opacity: 1; transform: translate3d(0, -22px, 0); } }
@keyframes sb-step-back-2 { from { filter: blur(1.5px); opacity: 0.78; transform: translate3d(0, -22px, 0); } }
@keyframes sb-step-back-3 { from { filter: blur(3px); opacity: 0.56; transform: translate3d(0, -22px, 0); } }
@keyframes sb-noted {
  0%   { transform: scaleX(0); opacity: 1; }
  20%  { transform: scaleX(1); opacity: 1; }
  60%  { transform: scaleX(1); opacity: 1; }
  100% { transform: scaleX(1); opacity: 0; }
}
@keyframes sb-exhale {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}
@keyframes sb-fade-in { from { opacity: 0; } to { opacity: 1; } }
/* Reduced motion: the noted band shows, holds, then fades (never stays on) */
@keyframes sb-noted-rm {
  0%, 60% { opacity: 1; transform: none; }
  100%    { opacity: 0; transform: none; }
}

/* Field focus, the 6-digit code (typed, pasted, error, success) and the
   step segments are components.css (.sb-input, .sb-code, .sb-steps). */

/* "Noted" flash behind a saved row in the panel */
.sb-noted-host { position: relative; isolation: isolate; }
.sb-noted-host::after {
  content: ""; position: absolute; z-index: -1; left: -8px; right: -8px; top: 22%; height: 56%;
  border-radius: 8px; background: rgba(250, 222, 146, 0.6); opacity: 0; transform-origin: 0 50%; pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
  .sb-win-in { -webkit-animation: sb-win-in 520ms cubic-bezier(0.23, 1, 0.32, 1) both; animation: sb-win-in 520ms cubic-bezier(0.23, 1, 0.32, 1) both; }
  .sb-win-in > .sb-window__body { animation: sb-win-defog 520ms cubic-bezier(0.23, 1, 0.32, 1) both; }
  .sb-win-in--quick, .sb-win-in--quick > .sb-window__body { animation-duration: 280ms; }   /* panel: Operate mode */

  .sb-step-in  { animation: sb-step-in 420ms cubic-bezier(0.23, 1, 0.32, 1) 120ms both; }
  .sb-step-out { animation: sb-step-out 180ms cubic-bezier(0.55, 0, 1, 0.45) both; }
  [data-dir="back"] .sb-step-in  { animation-name: sb-step-in-back; }
  [data-dir="back"] .sb-step-out { animation-name: sb-step-out-back; }

  .sb-value  { animation: sb-value 240ms cubic-bezier(0.23, 1, 0.32, 1) both; }   /* re-add to replay */
  .sb-unlock { animation: sb-unlock 420ms cubic-bezier(0.23, 1, 0.32, 1) both; }
  .sb-unlock--late { animation-delay: 200ms; }   /* the delay exists only when motion is on */
  .sb-panel-clear { animation: sb-panel-clear 240ms cubic-bezier(0.23, 1, 0.32, 1) both; }
  .sb-check-draw path { stroke-dasharray: 1; animation: sb-check-draw 240ms cubic-bezier(0.22, 0.8, 0.24, 1) 560ms both; }

  .sb-sheet[data-entering] > .sb-sheet__body { animation: sb-sheet-defog 360ms cubic-bezier(0.23, 1, 0.32, 1) both; }
  .sb-behind[data-fogged] { animation: sb-recede-panel 360ms cubic-bezier(0.23, 1, 0.32, 1) both; }

  .sb-step-back-1 { animation: sb-step-back-1 420ms cubic-bezier(0.23, 1, 0.32, 1) 560ms both; }
  .sb-step-back-2 { animation: sb-step-back-2 420ms cubic-bezier(0.23, 1, 0.32, 1) 600ms both; }
  .sb-step-back-3 { animation: sb-step-back-3 420ms cubic-bezier(0.23, 1, 0.32, 1) 640ms both; }

  .sb-noted-host.sb-noted::after { animation: sb-noted 1500ms cubic-bezier(0.22, 0.8, 0.24, 1) both; }
  .sb-exhale { animation: sb-exhale 2400ms cubic-bezier(0.45, 0, 0.3, 1) 300ms 1 both; }
}
/* Reduced motion in the app: state changes stay legible as short cross-fades */
@media (prefers-reduced-motion: reduce) {
  .sb-step-out { animation: none; }
  .sb-step-in { animation: sb-fade-in 160ms linear both; }
  .sb-value, .sb-unlock { animation: sb-fade-in 160ms linear both; }
  .sb-panel-clear { animation: sb-panel-clear-rm 240ms linear both; }
  .sb-noted-host.sb-noted::after { animation: sb-noted-rm 1500ms linear both; }
  /* .sb-check-draw, .sb-step-back-*, the sheet defog: no animation, the resting frame shows */
}


/* 9 · Email "view in browser" page ----------------------------------------- */
/* The inbox version is STATIC (inline styles = final state). The web view adds
   these classes: first passage = .sb-gesture-load; later books = .sb-gesture;
   the closing "reading moment" = .sb-fog-in + .sb-rule. */
.sb-rule { transform-origin: 50% 50%; }
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .sb-rule {
      animation: sb-band linear both;
      animation-timing-function: var(--sb-ease-sweep);
      animation-timeline: view();
      animation-range: cover 5% cover 30%;
    }
  }
}


/* 10 · Optional production "latch" (one-shot, time-based, any browser) -------
   Only when JS is present: <html class="sb-latch"> and a 20-line
   IntersectionObserver adds .is-seen once (threshold 0.2, rootMargin
   "0px 0px -10% 0px") and pauses .sb-float layers off-screen (.is-off).
   Never used in canvas boards. Scroll-linked parallax stays scroll-linked. */
@supports not (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .sb-latch .sb-reveal:not(.is-seen),
    .sb-latch .sb-stagger:not(.is-seen) > * { opacity: 0; filter: blur(6px); transform: translate3d(0, 24px, 0); }
    .sb-latch .sb-fog-in:not(.is-seen),
    .sb-latch .sb-gesture:not(.is-seen) { opacity: 0.25; filter: blur(10px); }
    .sb-latch .sb-gesture:not(.is-seen) :is(.lr-mark, .sb-mark),
    .sb-latch .sb-sweep:not(.is-seen) { background-size: 0% 100%; }

    .sb-latch .sb-reveal.is-seen,
    .sb-latch .sb-stagger.is-seen > * { animation: sb-rise-fog var(--sb-dur-slow) var(--sb-ease-out) both; }
    .sb-latch .sb-stagger.is-seen > :nth-child(2) { animation-delay: 60ms; }
    .sb-latch .sb-stagger.is-seen > :nth-child(3) { animation-delay: 120ms; }
    .sb-latch .sb-stagger.is-seen > :nth-child(4) { animation-delay: 180ms; }
    .sb-latch .sb-stagger.is-seen > :nth-child(n+5) { animation-delay: 240ms; }
    .sb-latch .sb-fog-in.is-seen,
    .sb-latch .sb-gesture.is-seen { animation: sb-clear var(--sb-dur-clear) var(--sb-ease-out) both; }
    .sb-latch .sb-gesture.is-seen :is(.lr-mark, .sb-mark) { animation: sb-sweep var(--sb-dur-sweep) var(--sb-ease-hand) 900ms both; }
    .sb-latch .sb-sweep.is-seen { animation: sb-sweep var(--sb-dur-sweep) var(--sb-ease-hand) both; }
  }
}
.sb-latch .sb-float.is-off { animation-play-state: paused; }


/* 11 · Cross-page (production site only; inert in canvas) ------------------- */
@view-transition { navigation: auto; }
@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root) { animation: sb-vt-out 180ms cubic-bezier(0.55, 0, 1, 0.45) both; }
  ::view-transition-new(root) { animation: sb-vt-in 380ms cubic-bezier(0.23, 1, 0.32, 1) 60ms both; }
}
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
@keyframes sb-vt-out { to { opacity: 0; filter: blur(6px); } }
@keyframes sb-vt-in { from { opacity: 0; filter: blur(6px); } }


/* 12 · Budgets and guards --------------------------------------------------- */

/* Phones: no ambient float, no hero foreground sharpening (battery) */
@media (max-width: 599px) {
  .sb-rotate > span:first-child { animation: none !important; opacity: 1; filter: none; }
}
@media (max-width: 899px) {
  .sb-float { animation: none !important; will-change: auto; }
  .sb-hero .sb-surface-up { animation: none !important; }
}
/* Reduced transparency: fog stays (it is focus, not transparency), glass goes solid */
@media (prefers-reduced-transparency: reduce) {
  .sb-nav::before { background: #FBFAF7; -webkit-backdrop-filter: none; backdrop-filter: none; }
}
/* Print: everything sharp and marked */
@media print {
  .sb-fog, .sb-peek > * { filter: none !important; opacity: 1 !important; }
  .sb-progress, .sb-nav::before { display: none !important; }
}
