/* App-page extras shared by Sipwell and Sprout:
   - .story: a phone that stays put while the steps scroll past, swapping real screenshots
   - .compare: drag between two screenshots (light and dark)
   - .ribbon: a line of words that slides as you scroll
   - scroll-linked motion for phones (only where the browser supports scroll timelines)
   Each page sets the --st-* colours. */

/* ---------------------------------------------------------------- Story */
.story { position: relative; max-width: 1240px; margin: 0 auto; padding: clamp(3rem, 7vw, 6rem) clamp(1.2rem, 5vw, 3rem) 0; }
.story-head { max-width: 40rem; margin-bottom: clamp(1rem, 4vw, 2rem); }
.story-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(2rem, 6vw, 6rem); }

.story-stage { position: sticky; top: 0; height: 100vh; height: 100svh; display: grid; place-items: center; }
.story-phone {
  --tilt: 0;
  position: relative; width: min(340px, 30vw); aspect-ratio: 600 / 1305; padding: 10px; border-radius: 56px;
  background: var(--st-frame); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .14), 0 50px 80px -40px rgba(0, 0, 0, .55);
  transform: perspective(1400px) rotateY(calc(var(--tilt) * 9deg)) rotateX(calc(var(--tilt) * -2deg));
  transition: transform .5s cubic-bezier(.2, .8, .2, 1);
}
.story-screen { position: relative; width: 100%; height: 100%; border-radius: 46px; overflow: hidden; background: var(--st-bg); }
.story-screen img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transform: translateY(6%) scale(1.04); filter: blur(6px);
  transition: opacity .55s ease, transform .75s cubic-bezier(.2, .8, .2, 1), filter .55s ease;
}
.story-screen img.on { opacity: 1; transform: none; filter: none; }
.story-screen img.was { opacity: 0; transform: translateY(-5%) scale(.97); filter: blur(4px); }
/* A card turning over: the old face spins away, the new one spins in. */
.story-screen img[data-enter="flip"].on { animation: flip-in .7s cubic-bezier(.2, .8, .2, 1) both; filter: none; }
.story-screen img.was.flipping { animation: flip-out .35s ease-in both; }
@keyframes flip-in { from { transform: perspective(900px) rotateY(-90deg); opacity: 1; } to { transform: none; opacity: 1; } }
@keyframes flip-out { from { transform: none; opacity: 1; filter: none; } to { transform: perspective(900px) rotateY(90deg); opacity: 1; filter: none; } }

.story-count {
  position: absolute; left: 50%; bottom: calc(50% - min(340px, 30vw) * 1.087 - 2.6rem); translate: -50% 0;
  display: flex; gap: 6px; align-items: center;
}
.story-count button { width: 8px; height: 8px; padding: 0; border-radius: 99px; background: color-mix(in srgb, var(--st-ink) 22%, transparent); transition: width .4s cubic-bezier(.3, 1.4, .5, 1), background .3s; }
.story-count button[aria-current="step"] { width: 26px; background: var(--st-accent); }

.story-steps { counter-reset: step; padding: 30vh 0 34vh; }
.story-step { min-height: 72vh; display: flex; flex-direction: column; justify-content: center; opacity: .28; transition: opacity .5s ease; }
.story-step.on { opacity: 1; }
.story-step .no { font-weight: 700; font-size: 14px; letter-spacing: .08em; color: var(--st-accent); }
.story-step h3 { font-weight: 700; font-size: clamp(1.9rem, 3.4vw, 2.9rem); line-height: 1.02; letter-spacing: -.04em; margin: .5rem 0 .8rem; color: var(--st-ink); }
.story-step p { font-size: 1.1rem; color: var(--st-soft); max-width: 26rem; }
.story-step .chips { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: 1rem; }
.story-step .chips span { padding: .35rem .75rem; border-radius: 99px; font-size: 14px; font-weight: 600; background: var(--st-hi); color: var(--st-hi-ink, var(--st-ink)); }
.story-step .chips span b { font-weight: 700; opacity: .65; margin-left: .25rem; }
.story-step blockquote { margin-top: 1rem; padding-left: 1rem; border-left: 3px solid var(--st-accent); font-style: italic; color: var(--st-ink); }

@media (max-width: 860px) {
  .story-grid { display: block; }
  .story-stage {
    top: 56px; height: auto; z-index: 2; padding: .6rem 0 2.2rem;
    background: linear-gradient(var(--st-bg) 82%, transparent);
  }
  .story-phone { width: min(200px, 48vw); border-radius: 36px; padding: 6px; }
  .story-screen { border-radius: 30px; }
  .story-count { position: static; translate: none; justify-content: center; margin-top: .9rem; }
  .story-steps { padding: 0 0 40vh; position: relative; z-index: 1; }
  .story-step { min-height: 56vh; justify-content: flex-start; padding-top: 0; text-align: center; align-items: center; }
  .story-step p { margin-inline: auto; }
  .story-step .chips { justify-content: center; }
  .story-step blockquote { border-left: 0; padding-left: 0; }
}

/* ---------------------------------------------------------------- Compare (light / dark) */
.compare {
  --x: 50%;
  position: relative; width: min(330px, 78vw); aspect-ratio: 600 / 1305; padding: 10px; border-radius: 54px;
  background: var(--st-frame); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .14), 0 50px 80px -40px rgba(0, 0, 0, .55);
  touch-action: pan-y; user-select: none;
}
.compare-screen { position: relative; height: 100%; border-radius: 44px; overflow: hidden; }
.compare-screen img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.compare-screen img + img { clip-path: inset(0 0 0 var(--x)); }
.compare-line { position: absolute; top: 10px; bottom: 10px; left: calc(10px + (100% - 20px) * var(--xn, .5)); width: 2px; translate: -1px 0; background: #fff; box-shadow: 0 0 12px rgba(0, 0, 0, .35); pointer-events: none; }
.compare-knob {
  position: absolute; top: 50%; left: 50%; translate: -50% -50%; width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center; background: #fff; color: #171a18; box-shadow: 0 8px 20px -6px rgba(0, 0, 0, .45);
}
.compare-knob svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.compare input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: ew-resize; margin: 0; }
.compare input:focus-visible + .compare-line .compare-knob { outline: 3px solid var(--st-accent); outline-offset: 3px; }
.compare-tags { position: absolute; bottom: -2.6rem; left: 14px; right: 14px; display: flex; justify-content: space-between; pointer-events: none; }
.compare-tags span { padding: .3rem .7rem; border-radius: 99px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.compare-tags .t-dark { background: #1d2624; color: #e9f3f0; }
.compare-tags .t-light { background: #fff; color: #171a18; box-shadow: 0 0 0 1px rgba(0, 0, 0, .08); }

/* ---------------------------------------------------------------- Ribbon */
.ribbon { overflow: hidden; padding: clamp(1.2rem, 3vw, 2rem) 0; border-block: 1.5px solid color-mix(in srgb, var(--st-ink) 12%, transparent); }
.ribbon-track { display: flex; gap: 2.2rem; width: max-content; white-space: nowrap; font-weight: 700; font-size: clamp(1.6rem, 4vw, 3.2rem); letter-spacing: -.04em; color: var(--st-ink); }
.ribbon-track span { display: inline-flex; align-items: baseline; gap: .6rem; }
.ribbon-track i { font-style: normal; color: var(--st-accent); font-size: .55em; letter-spacing: 0; }
.ribbon-track .dot { width: .35em; height: .35em; border-radius: 50%; background: var(--st-accent); align-self: center; opacity: .5; }

/* ---------------------------------------------------------------- Scroll-linked motion */
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    .phone-fan figure { animation: phone-rise linear both; animation-timeline: view(); animation-range: entry 0% cover 38%; }
    .phone-fan li:nth-child(2) figure { animation-range: entry 5% cover 30%; }
    .phone-fan li:nth-child(3) figure { animation-range: entry 10% cover 44%; }
    .phone-fan li:nth-child(4) figure { animation-range: entry 15% cover 48%; }
    @keyframes phone-rise { from { translate: 0 140px; scale: .88; opacity: 0; } to { translate: 0 0; scale: 1; opacity: 1; } }

    .ribbon-track { animation: ribbon linear both; animation-timeline: view(); animation-range: cover 0% cover 100%; }
    .ribbon-track.rev { animation-name: ribbon-rev; }
    @keyframes ribbon { from { translate: 6vw 0; } to { translate: calc(-100% + 94vw) 0; } }
    @keyframes ribbon-rev { from { translate: calc(-100% + 94vw) 0; } to { translate: 6vw 0; } }

    .compare { animation: compare-in linear both; animation-timeline: view(); animation-range: entry 0% cover 40%; }
    @keyframes compare-in { from { rotate: -6deg; translate: 0 100px; scale: .9; } to { rotate: 0deg; translate: 0 0; scale: 1; } }

    .scroll-sink { animation: sink linear both; animation-timeline: view(); animation-range: exit 0% exit 90%; }
    @keyframes sink { to { translate: 0 -70px; scale: .93; opacity: .25; } }
  }
}
@media (prefers-reduced-motion: reduce) {
  .story-screen img, .story-phone { transition: none; }
  .story-screen img[data-enter="flip"].on, .story-screen img.was.flipping { animation: none; }
}
