/* Scroll motion for the reading pages, CSS only. Two pins, both inside the 1.5-screen
   budget and both moving for their whole length:
   - the opening stage (240svh desktop = 1.4 screens, 200svh phone = 1 screen): the
     media pushes in while the copy drifts up, and the first scene slides over the
     last frame, as at the homepage opening;
   - the process strip on wide screens (220svh = 1.2 screens): the four steps travel
     sideways with the scroll.
   Everything here sits behind scroll-timeline support and every motion opt-out
   (system setting, .motion-off, .a11y-nomotion). Without them the stage is one
   still screen, the strip a static row, and every block is in place and visible.
   Only transform, opacity and clip-path animate. */

/* The headline rises into the stage on arrival (time-based, not scroll). */
@media (prefers-reduced-motion: no-preference) {
  .seo-document:not(.motion-off, .a11y-nomotion) .page-heading h1 { animation: title-rise 900ms cubic-bezier(.2, .7, .2, 1) both; }
}

@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    /* ---- Opening stage: runway, pin, cover. ---- */
    .seo-document:not(.motion-off, .a11y-nomotion) .service-hero[data-stage] { height: 240svh; overflow: visible; view-timeline: --stage block; }
    .seo-document:not(.motion-off, .a11y-nomotion) .stage-pin { position: sticky; top: 0; height: 100svh; min-height: 0; }
    /* The pinned stage sits a header-height lower at the top of the page; this keeps
       the copy where it was in the first screen and lets it rest above the fold later. */
    .seo-document:not(.motion-off, .a11y-nomotion) .stage-copy { padding-bottom: calc(var(--copy-lift) + var(--stage-header)); }
    /* Cover: whatever follows overlaps the last stage height and paints above it. */
    .seo-document:not(.motion-off, .a11y-nomotion) .service-hero[data-stage] + * { position: relative; z-index: 1; margin-top: -100svh; }
    /* The consent slot is that next element. Its stacking context must stay above the scenes
       after it (also z-index 1, later in the page), or they paint over the fixed strip. */
    .seo-document:not(.motion-off, .a11y-nomotion) .service-hero[data-stage] + [data-mobile-consent-slot] { z-index: 110; }

    .seo-document:not(.motion-off, .a11y-nomotion) .stage-media > :is(.hero-frame, .persona-loop) {
      animation: stage-push linear both; animation-timeline: --stage; animation-range: contain 0% contain 100%;
    }
    .seo-document:not(.motion-off, .a11y-nomotion) .stage-copy {
      animation: copy-drift linear both; animation-timeline: --stage; animation-range: contain 0% contain 100%;
    }
    .seo-document:not(.motion-off, .a11y-nomotion) .page-breadcrumb {
      animation: crumb-out linear both; animation-timeline: --stage; animation-range: contain 0% contain 40%;
    }
    /* Web: the site settles from full screen into a browser window on the far side. */
    .seo-document:not(.motion-off, .a11y-nomotion) [data-stage="web"] .stage-media > .hero-frame { animation-name: site-settle; transform-origin: 4% 50%; }
    /* Content: the room pushes in, the two reels pass at two speeds. */
    .seo-document:not(.motion-off, .a11y-nomotion) [data-stage="content"] .stage-media > .hero-frame { animation: none; }
    .seo-document:not(.motion-off, .a11y-nomotion) [data-stage="content"] .stage-media::before { animation: room-push linear both; animation-timeline: --stage; animation-range: contain 0% contain 100%; }
    .seo-document:not(.motion-off, .a11y-nomotion) [data-stage="content"] .reel { animation: reel-near linear both; animation-timeline: --stage; animation-range: contain 0% contain 100%; }
    .seo-document:not(.motion-off, .a11y-nomotion) [data-stage="content"] .reel:nth-child(2) { animation-name: reel-far; }
    /* Automation: the diagram builds itself from the scroll (automation-reveal.mjs). */
    .seo-document:not(.motion-off, .a11y-nomotion) [data-stage="automation"] .stage-media > .hero-frame { animation-name: panel-settle; }
    /* About: the two lines of the name part, the rules draw across. The first line moves
       toward the screen edge, so it travels only as far as the gutter allows (16px stays
       free); at a flat 6vw its first letter left the stage and was cut by the pin (QA
       24.11.2026: 5 to 28px, every desktop width). The second line takes up the difference,
       so the two still end 16vw apart. */
    .seo-document:not(.motion-off, .a11y-nomotion) [data-stage="about"] .page-heading h1 { --name-out: min(6vw, calc(var(--page-gutter) - 16px)); }
    .seo-document:not(.motion-off, .a11y-nomotion) [data-stage="about"] .page-heading h1 > span { animation: name-apart linear both; animation-timeline: --stage; animation-range: contain 0% contain 100%; }
    .seo-document:not(.motion-off, .a11y-nomotion) [data-stage="about"] .page-heading h1 > span + span { animation-name: name-apart-far; }
    .seo-document:not(.motion-off, .a11y-nomotion) .stage-type i { animation: rule-draw linear both; animation-timeline: --stage; animation-range: contain 0% contain 70%; }
    .seo-document:not(.motion-off, .a11y-nomotion) .stage-type i:nth-child(2) { animation-range: contain 10% contain 80%; }
    .seo-document:not(.motion-off, .a11y-nomotion) .stage-type i:nth-child(3) { animation-range: contain 20% contain 90%; }

    /* ---- Scene entrances: each block rises into place as it enters. ---- */
    .seo-document:not(.motion-off, .a11y-nomotion) :is([data-band] > h2, .track-pin > h2, .stage-head h2) {
      animation: scene-title linear both; animation-timeline: view(); animation-range: entry 0% cover 30%;
    }
    .seo-document:not(.motion-off, .a11y-nomotion) :is(.band-copy > p, .proof-caption, .stage-head a, .page-proof dl, .proof-label, .faq-card, .more-card, .page-body li, .page-actions, .page-contact .band-copy > a) {
      animation: block-rise linear both; animation-timeline: view(); animation-range: entry 0% cover 24%;
    }
    /* Neighbours in a row start a beat later, so a row reads in RTL order. */
    .seo-document:not(.motion-off, .a11y-nomotion) :is(.faq-card, .more-card):nth-child(even) { animation-range: entry 6% cover 30%; }
    .seo-document:not(.motion-off, .a11y-nomotion) .more-card:nth-child(3) { animation-range: entry 10% cover 34%; }
    .seo-document:not(.motion-off, .a11y-nomotion) .more-card:nth-child(4) { animation-range: entry 14% cover 38%; }
    .seo-document:not(.motion-off, .a11y-nomotion) .more-thumb img { animation: thumb-settle linear both; animation-timeline: view(); animation-range: entry 0% cover 50%; }
    /* The amber tick draws before the heading rises. */
    .seo-document:not(.motion-off, .a11y-nomotion) :is([data-band] > h2, .track-pin > h2, .stage-head h2)::before {
      transform-origin: right center; animation: tick-draw linear both; animation-timeline: view(); animation-range: entry 0% cover 22%;
    }
  }
}

/* Phones: the stage is one screen of cover, no extra runway. "About" has no media
   to hold the screen: its type stage is only as tall as the type, unpinned. */
@media (prefers-reduced-motion: no-preference) and (max-width: 720px) {
  @supports (animation-timeline: view()) {
    .seo-document:not(.motion-off, .a11y-nomotion) .service-hero[data-stage] { height: 200svh; }
    /* Once the first scene has covered the copy plate, the plate drops out of the stage,
       so the hidden hero buttons stop counting as "on screen" and the sticky WhatsApp
       button can return (cta-reveal.mjs watches geometry, not paint order). */
    .seo-document:not(.motion-off, .a11y-nomotion) .stage-copy { animation-name: copy-sink; }
    .seo-document:not(.motion-off, .a11y-nomotion) .service-hero[data-stage="about"] { height: auto; }
    .seo-document:not(.motion-off, .a11y-nomotion) [data-stage="about"] .stage-pin { position: relative; height: auto; }
    .seo-document:not(.motion-off, .a11y-nomotion) [data-stage="about"] .stage-copy { padding-bottom: var(--copy-lift); }
    .seo-document:not(.motion-off, .a11y-nomotion) [data-stage="about"] :is(.stage-copy, .page-breadcrumb, .page-heading h1 > span, .stage-type i) { animation: none; }
    .seo-document:not(.motion-off, .a11y-nomotion) .service-hero[data-stage="about"] + * { margin-top: 0; }
  }
}

/* Wide screens: the process strip pins and travels. */
@media (prefers-reduced-motion: no-preference) and (min-width: 960px) {
  @supports (animation-timeline: view()) {
    .seo-document:not(.motion-off, .a11y-nomotion) .band-steps {
      --step-w: min(38vw, 600px); --step-gap: 5vw;
      height: 220svh; padding: 0; view-timeline: --track block;
    }
    .seo-document:not(.motion-off, .a11y-nomotion) .track-pin {
      position: sticky; top: 0; height: 100svh; overflow: clip;
      align-content: center; gap: clamp(32px, 6svh, 64px); padding: 0 var(--page-gutter);
    }
    .seo-document:not(.motion-off, .a11y-nomotion) .band-steps ol {
      display: flex; gap: var(--step-gap); width: max-content;
      --track-shift: calc(4 * var(--step-w) + 3 * var(--step-gap) - 100vw + 2 * var(--page-gutter));
      animation: track-travel linear both; animation-timeline: --track; animation-range: contain 0% contain 100%;
    }
    .seo-document:not(.motion-off, .a11y-nomotion) .band-steps li { flex: 0 0 var(--step-w); max-width: none; padding-top: 28px; animation: none; }
    .seo-document:not(.motion-off, .a11y-nomotion) .band-steps li::before { font-size: clamp(96px, 9vw, 160px); }
    /* A thin amber rule fills under the strip: how far along the four steps you are. */
    .seo-document:not(.motion-off, .a11y-nomotion) .track-pin::after {
      content: ""; height: 2px; margin-inline: 0; background: var(--amber); transform-origin: right center;
      animation: rule-draw linear both; animation-timeline: --track; animation-range: contain 0% contain 100%;
    }
  }
}

@keyframes title-rise { from { opacity: 0; transform: translateY(.32em); clip-path: inset(0 0 100% 0); } to { opacity: 1; transform: none; clip-path: inset(0 0 -20% 0); } }
@keyframes stage-push { from { transform: scale(1); } to { transform: scale(1.12); } }
@keyframes copy-drift { 0% { transform: none; } 100% { transform: translateY(-14svh); } }
@keyframes copy-sink { 0%, 62% { transform: none; } 100% { transform: translateY(110svh); } }
@keyframes crumb-out { to { opacity: 0; transform: translateY(-16px); } }
@keyframes site-settle { 0% { transform: none; } 70%, 100% { transform: scale(.56); } }
@keyframes room-push { from { transform: scale(1); } to { transform: scale(1.18); } }
@keyframes reel-near { from { transform: none; } to { transform: translateY(-12svh); } }
@keyframes reel-far { from { transform: none; } to { transform: translateY(-24svh); } }
@keyframes panel-settle { from { transform: scale(1.04); } to { transform: none; } }
@keyframes name-apart { from { transform: none; } to { transform: translateX(var(--name-out, 0px)); } }
@keyframes name-apart-far { from { transform: none; } to { transform: translateX(calc(var(--name-out, 0px) - 16vw)); } }
@keyframes rule-draw { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes track-travel { from { transform: none; } to { transform: translateX(var(--track-shift)); } }
@keyframes scene-title { from { opacity: 0; transform: translateY(48px); clip-path: inset(0 0 100% 0); } to { opacity: 1; transform: none; clip-path: inset(0 0 -20% 0); } }
@keyframes block-rise { from { opacity: 0; transform: translateY(40px); } }
@keyframes thumb-settle { from { transform: scale(1.18); } to { transform: none; } }
@keyframes tick-draw { from { transform: scaleX(0); } }
