/* Motion and highlights (Alecz, 2026-11-29: "dynamic animation and places where text is highlighted in many
   ways", "the dynamic figma style animations … used in the knowmad card landing page").
   Method: the scroll-motion skill (portfolio-reconciliation/phase1/scroll-motion/, the Knowmad Card test's
   method; none of its look). Rules it keeps:
   - The finished page is the plain CSS below. Every "before" state lives only inside @keyframes.
   - Scroll motion sits inside @supports (animation-timeline: view()) and prefers-reduced-motion: no-preference,
     so people who turn motion off, and browsers without scroll timelines, get the finished page.
   - No script, no inline styles (the CSP stays style-src 'self'), nothing that loops, flashes or needs hover.
   - Moving pieces are decoration (alt="" or aria-hidden) and never block a link or a button.
   Test 2026-11-29 (the hero and three highlights), then extended to the page on Alecz's OK the same day:
   the flow cycle turns from a row into its loop, the pain lines arrive, the sheet's pages fan in, phones get
   the hero pages too. */

/* ---------- Highlights: finished state ---------- */

/* Marker: a turquoise sweep behind a phrase on light sections. The phrase turns ink, so it keeps
   11:1 or more on the tint (turquoise 32% over mist or white). */
.hl-marker{ color:var(--c-ink); padding:0 0.08em;
  background:linear-gradient(transparent 55%, rgba(64, 198, 204, 0.32) 55%) no-repeat 0 0 / 100% 100%;
  -webkit-box-decoration-break:clone; box-decoration-break:clone; }

/* Underline: a turquoise line drawn under a phrase on ink. */
.hl-under{ padding-bottom:3px; color:var(--c-white);
  background:linear-gradient(var(--c-turq), var(--c-turq)) no-repeat 0 100% / 100% 3px;
  -webkit-box-decoration-break:clone; box-decoration-break:clone; }

/* Circle: a hand-drawn loop around a phrase, the way the sheet asks readers to circle their triggers.
   Dark turquoise, decorative (aria-hidden). */
.hl-circle{ position:relative; white-space:nowrap; margin:0 0.32em; }   /* room so the loop clears the words beside it */
.hl-circle-tight{ margin-right:0.1em; }   /* when a comma follows: the loop curves in at the baseline, so the comma sits close (2026-12-01) */
.hl-circle .scribble{ position:absolute; left:-0.34em; top:-0.3em; width:calc(100% + 0.68em); height:calc(100% + 0.6em);
  overflow:visible; pointer-events:none; }
.hl-circle .scribble path{ fill:none; stroke:var(--c-turqd); stroke-width:2.4; stroke-linecap:round;
  vector-effect:non-scaling-stroke; stroke-dasharray:1; stroke-dashoffset:0; }

/* ---------- Motion ---------- */

@keyframes hl-draw{ from{ stroke-dashoffset:1; } }
@keyframes hl-sweep{ from{ background-size:0% 100%; } }
@keyframes hl-line{ from{ background-size:0% 3px; } }
@keyframes gather{ from{ translate:var(--fx) var(--fy); rotate:var(--fr); } }
@keyframes to-loop{ from{ translate:var(--rx) var(--ry); } }
@keyframes ring-in{ from{ opacity:0; scale:0.55; rotate:-120deg; } }
@keyframes fade-in{ from{ opacity:0; } }
@keyframes arrive{ from{ opacity:0; translate:-28px 0; } }
@keyframes fan-in{ from{ translate:0 56px; rotate:var(--cr, 0deg); } }

@media (prefers-reduced-motion:no-preference){
  /* The circle is in the hero, on screen at load, so it draws once with time, not with the scroll. */
  .hl-circle .scribble path{ animation:hl-draw 0.9s ease-out 0.6s both; }
}

@supports (animation-timeline: view()){
  @media (prefers-reduced-motion:no-preference){
    /* Marker and underline draw in as their line scrolls into view. */
    .hl-marker{ animation:hl-sweep linear both; animation-timeline:view(); animation-range:entry 80% cover 45%; }
    .hl-under{ animation:hl-line linear both; animation-timeline:view(); animation-range:entry 80% cover 45%; }
    /* The circle further down the page draws with the scroll, like the marker. */
    .hl-circle-scroll .scribble path{ animation:hl-draw linear both; animation-timeline:view(); animation-range:entry 80% cover 45%; }

    /* The flow cycle: the four tiles start in a row (the old chevrons) and swing out into the loop, while the
       ring of arrows turns in. Offsets are from each tile's loop position to its place in the row. */
    .loop{ view-timeline:--loop block; }
    /* The loop is whole before it reaches the middle of the screen (review 2026-12-01: until then it ended at
       cover 58%, so a reader saw Recovery still crossing the label while the loop sat mid-screen). */
    .phases li{ animation:to-loop linear both; animation-timeline:--loop; animation-range:entry 40% cover var(--end, 36%); }
    .phases .p1{ --rx:-46.5cqw; --ry:34cqw; --end:24%; }   /* one after another, in cycle order */
    .phases .p2{ --rx:-49.5cqw; --ry:0cqw; --end:28%; }
    .phases .p3{ --rx:15.5cqw;  --ry:-34cqw; --end:32%; }
    .phases .p4{ --rx:80.5cqw;  --ry:0cqw; --end:36%; }
    .loop .ring{ animation:ring-in linear both; animation-timeline:--loop; animation-range:entry 50% cover 36%; }
    .loop-label{ animation:fade-in linear both; animation-timeline:--loop; animation-range:cover 28% cover 36%; }

    /* The reader's five lines arrive one by one as each reaches the screen. */
    .problem .voices li{ animation:arrive linear both; animation-timeline:view(); animation-range:entry 10% cover 30%; }

    /* The sheet's two pages fan in. */
    .inside .cards{ view-timeline:--cards block; }
    .inside .card{ animation:fan-in linear both; animation-timeline:--cards; animation-range:entry 20% cover 45%; }
    .inside .card:nth-child(1){ --cr:-7deg; }
    .inside .card:nth-child(2){ --cr:9deg; animation-range:entry 30% cover 50%; }

    /* Tablets and phones: the hero's pages gather as they scroll into view (no pin). */
    @media (max-width:1000px){
      .hero-art .piece{ animation:gather linear both; animation-timeline:view(); animation-range:entry 5% cover 50%; }
      .hero-art .front{ --fx:-10%; --fy:-30%; --fr:-14deg; }
      .hero-art .back{ --fx:28%; --fy:22%; --fr:20deg; }
    }
  }

  /* The hero moment (wide, tall-enough screens): the hero stays pinned while the sheet's two pages,
     fanned out at the start, gather onto the grey panel. Phones keep the still hero. */
  @media (prefers-reduced-motion:no-preference) and (min-width:1001px) and (min-height:760px){
    .hero{ height:165svh; view-timeline:--hero block; }
    .hero > .wrap{ position:sticky; top:0; min-height:100svh; }
    .hero-art .piece{ animation:gather linear both; animation-timeline:--hero; animation-range:contain 0% contain var(--end, 70%); }
    .hero-art .front{ --fx:-4%; --fy:-58%; --fr:-15deg; --end:58%; }
    .hero-art .back{ --fx:46%; --fy:40%; --fr:24deg; --end:72%; }
  }
}
