/* ============================================================================
   Five Blocks 2026: motion layer (progressive enhancement only)
   ----------------------------------------------------------------------------
   Nothing here applies unless <html> carries .fb-motion, which the theme's
   head pre-gate and assets/js/motion.js add only when JavaScript runs,
   prefers-reduced-motion is not "reduce", IntersectionObserver exists and
   <html> does not carry .no-motion. Every rule animates FROM a start state TO
   the design's existing end state with transform / opacity / clip-path /
   colour only, so layout and document height never change (no CLS).

   Vocabulary (set by motion.js at runtime, never in markup):
     .fbm-g        a group container (its direct children stagger)
     .fbm-in       on a group / solo once it enters the viewport (reveal runs)
     .fbm-done     added ~2.6s later; every rule is scoped :not(.fbm-done) so the
                   element falls back to the untouched design CSS afterwards
     .fbm-mask     a display heading whose content was wrapped in
                   <span class="fbm-ln"> for the masked line rise
     --fbm-i       stagger index on the direct children of a group
     .fbm-scrolled on the sticky header once the page is scrolled

   The group and solo selector lists live in motion.js (FB_MOTION_GROUPS /
   FB_MOTION_SOLOS) and are mirrored in the two :where() lists below, which
   give pre-JS start states (so the head pre-gate never flashes content) and
   the no-JS safety net. Keep them in sync. :where() keeps their specificity
   at zero so per-group overrides further down always win.
   ========================================================================== */
@media (prefers-reduced-motion: no-preference) {

html.fb-motion{
  --fbm-e: cubic-bezier(.2,.7,.2,1);
  --fbm-t: .7s;
}

/* ----- 1. Groups: direct children settle in with a short stagger ---------- */
/* start state, keyed on the design's own class names (works before JS tags) */
html.fb-motion :where(
  .hero .lead, .eo-intro > .wrap, .prs-hero > .wrap,
  .head, .faq-head, .approach .body, .firm .body, .cr-synth .body, .eo-who .body, .belief > .wrap,
  .contact .grid > div:first-child, .cr-faq > .wrap, .prs-list > .wrap,
  .fork, .steps, .overlap, .pgrid, .metrics, .engines, .kcg, .kblist, .facets, .fstats, .techlist, .reassure,
  .ldr-grid, .ldr-disc, .faces,
  .cr-reasons, .cr-layerlist, .cr-tags, .cr-synth .models, .faq-list, .faq-jump, .wk-faq,
  .imp-feat, .imp-engines, .eo-grid, .eo-feats, .eo-list, .ct-row,
  .article-head, .mth-interests, .mth-items, .mth-who, .abt-ind, .abt-ethics, .cs-list, .cs-results,
  .aud-uvp, .aud-incl, .aud-engage, .geo-loc, .geo-ext, .wa-checks, .wk-incl, .wk-prop, .wk-cmp,
  .oim-needs, .oim-incl, .oim-hero-cards, .car-vals, .car-disc, .car-roles, .svc-who, .kb-lenses, .ins-feat, .ins-side
):not(.fbm-in) > *,
html.fb-motion :where(.fbm-g):not(.fbm-in) > *{
  opacity: 0;
  transform: translateY(18px);
}
html.fb-motion :where(.fbm-g):not(.fbm-done) > *{
  --fbm-d: calc(min(var(--fbm-i, 0) * 90ms, 720ms));
  transition: opacity var(--fbm-t) var(--fbm-e), transform var(--fbm-t) var(--fbm-e);
  transition-delay: var(--fbm-d);
}
/* tall groups (taller than ~1.4 viewports): motion.js adds .fbm-tall and reveals
   each child as it enters (child gets .fbm-in), staggered within its row */
html.fb-motion .fbm-g.fbm-tall > *:not(.fbm-in){ opacity: 0; transform: translateY(18px); }

/* per-group timing (Keystone "lock in"): hero paths wait for the headline,
   chips and list items move faster, engines light up one by one */
html.fb-motion .fork:not(.fbm-done) > *{ --fbm-d: calc(.32s + var(--fbm-i, 0) * .11s); }
html.fb-motion .steps:not(.fbm-done) > *{ --fbm-d: calc(.1s + var(--fbm-i, 0) * .14s); }
html.fb-motion :is(.cr-tags, .facets, .ldr-disc, .faq-jump, .abt-ind, .imp-engines, .reassure):not(.fbm-done) > *{ --fbm-d: calc(min(var(--fbm-i, 0) * 50ms, 520ms)); }
html.fb-motion :is(.cr-tags, .facets, .ldr-disc, .faq-jump, .abt-ind, .imp-engines, .reassure):not(.fbm-in) > *{ transform: translateY(10px); }
html.fb-motion :is(.faq-list, .wk-faq, .cr-faq > .wrap):not(.fbm-done) > *{ --fbm-d: calc(min(var(--fbm-i, 0) * 45ms, 520ms)); }
html.fb-motion .engines:not(.fbm-done) > *{ --fbm-d: calc(.15s + var(--fbm-i, 0) * .07s); transition-duration: .55s; }
html.fb-motion .engines:not(.fbm-in) > *{ opacity: .08; transform: translateY(6px); }
html.fb-motion .cr-synth .models:not(.fbm-done) > *{ --fbm-d: calc(.4s + var(--fbm-i, 0) * .08s); transition: opacity .6s var(--fbm-e), filter .6s var(--fbm-e); filter: grayscale(0); }
html.fb-motion .cr-synth .models:not(.fbm-in) > *{ opacity: .22; filter: grayscale(1); transform: none; }

/* ----- 2. Display headings: masked line rise (Atelier) --------------------
   motion.js wraps the heading's content in span.fbm-ln. The heading itself
   stays at full opacity and clips (with slack for ascenders / descenders and
   side bearings); the span rises out of the clip. After .fbm-done the clip
   is gone and the heading is plain design CSS again. */
html.fb-motion .fbm-mask > .fbm-ln{ display: block; }
html.fb-motion .fbm-g:not(.fbm-done) .fbm-mask{ clip-path: inset(-.3em -.25em -.2em -.25em); }
html.fb-motion .fbm-g:not(.fbm-in) > .fbm-mask{ opacity: 1; transform: none; }
html.fb-motion .fbm-g:not(.fbm-done) .fbm-mask > .fbm-ln{ transition: transform .85s var(--fbm-e); transition-delay: var(--fbm-d, 0s); }
html.fb-motion .fbm-g:not(.fbm-in) .fbm-mask > .fbm-ln{ transform: translateY(125%); }

/* spectrum / hairline rules draw in from the left */
html.fb-motion .fbm-g:not(.fbm-done) > hr.spectrum{ transform-origin: left center; transition: transform .8s var(--fbm-e); transition-delay: var(--fbm-d, 0s); }
html.fb-motion .fbm-g:not(.fbm-in) > hr.spectrum{ opacity: 1; transform: scaleX(0); }

/* ----- 3. Solo elements -------------------------------------------------- */
html.fb-motion :where(
  .serpcard, .form, .trust, .crumbs, .kb-answer, .xref, .article-cta, .nextpost .np-link,
  .ldr-founder, .cr-synth .panel, .prs-media .panel, .faq-crisis-note, .mth-overlapnote, .kbmore, .kb-intro, .svc-intro
):not(.fbm-in),
html.fb-motion :where(.fbm-s):not(.fbm-in){
  opacity: 0;
  transform: translateY(16px);
}
html.fb-motion :where(.fbm-s):not(.fbm-done){ transition: opacity .75s var(--fbm-e), transform .75s var(--fbm-e); }
html.fb-motion .crumbs:not(.fbm-in){ transform: none; }
html.fb-motion .trust:not(.fbm-done){ transition-delay: .78s; }
html.fb-motion .form:not(.fbm-done){ transition-delay: .25s; }
html.fb-motion :is(.cr-synth .panel, .prs-media .panel):not(.fbm-done){ transition-delay: .15s; }

/* ----- 4. Photos: clip-path wipes and iris reveals ------------------------ */
html.fb-motion .ldr-grid:not(.fbm-done) .lc-photo img{ transition: clip-path .9s var(--fbm-e); transition-delay: calc(var(--fbm-d, 0s) + .15s); }
html.fb-motion .ldr-grid:not(.fbm-in) .lc-photo img{ clip-path: inset(0 100% 0 0); }
html.fb-motion .ldr-founder:not(.fbm-done) .lf-photo img{ transition: clip-path 1s var(--fbm-e) .2s; }
html.fb-motion .ldr-founder:not(.fbm-in) .lf-photo img{ clip-path: inset(0 100% 0 0); }
html.fb-motion .faces:not(.fbm-done) > *{ --fbm-d: calc(.25s + var(--fbm-i, 0) * .12s); transition: clip-path .7s var(--fbm-e); transition-delay: var(--fbm-d); clip-path: circle(75% at 50% 50%); }
html.fb-motion .faces:not(.fbm-in) > *{ opacity: 1; transform: none; clip-path: circle(0% at 50% 50%); }

/* ----- 5. The proof visuals (Meridian "settle"): SERP mock + metrics ------ */
/* rows slide in one after another, then their sentiment colours resolve */
html.fb-motion .serpcard:not(.fbm-done) .srow{
  --fbm-d: calc(.45s + var(--fbm-i, 0) * .08s);
  transition: opacity .55s var(--fbm-e) var(--fbm-d), transform .55s var(--fbm-e) var(--fbm-d),
              border-color .6s var(--fbm-e) calc(var(--fbm-d) + .35s), background-color .6s var(--fbm-e) calc(var(--fbm-d) + .35s);
}
html.fb-motion .serpcard:not(.fbm-in) .srow{ opacity: 0; transform: translateX(-10px); --sc: #d3d8de; --sbg: #f5f6f8; }
html.fb-motion .serpcard:not(.fbm-done) .srow .bd{ transition: background-color .6s var(--fbm-e) calc(var(--fbm-d) + .35s), color .6s var(--fbm-e) calc(var(--fbm-d) + .35s); }
html.fb-motion .serpcard:not(.fbm-in) .srow .bd{ background: #e8eaee; color: #8a9097; }
html.fb-motion .serpcard:not(.fbm-done) .srow .lock{ transition: opacity .5s var(--fbm-e) calc(var(--fbm-d) + .45s); }
html.fb-motion .serpcard:not(.fbm-in) .srow .lock{ opacity: 0; }
/* the sentiment bar segments grow in sequence */
html.fb-motion .serpcard:not(.fbm-done) .sbar > i{ transform-origin: left center; transition: transform .9s var(--fbm-e); transition-delay: calc(.25s + var(--fbm-i, 0) * .12s); }
html.fb-motion .serpcard:not(.fbm-in) .sbar > i{ transform: scaleX(0); }
/* peer bars fill, the trend line draws, the big figure fades up (no counting) */
html.fb-motion .metrics:not(.fbm-done) .track i{ transform-origin: left center; transition: transform 1s var(--fbm-e); transition-delay: calc(.35s + var(--fbm-i, 0) * .1s); }
html.fb-motion .metrics:not(.fbm-in) .track i{ transform: scaleX(0); }
html.fb-motion .metrics:not(.fbm-done) .trend polyline{ stroke-dasharray: 420; transition: stroke-dashoffset 1.4s cubic-bezier(.4,.1,.3,1) .25s; }
html.fb-motion .metrics:not(.fbm-in) .trend polyline{ stroke-dashoffset: 420; }
html.fb-motion .metrics:not(.fbm-done) .mbig > *{ transition: opacity .7s var(--fbm-e), transform .7s var(--fbm-e); transition-delay: calc(var(--fbm-d, 0s) + .2s); }
html.fb-motion .metrics:not(.fbm-in) .mbig > *{ opacity: 0; transform: translateY(8px); }

/* ----- 5b. SERP demo loop (Meridian "instrument"). Once the card has settled,
   motion.js adds .serpcard.fbm-live and runs Type / Track / Analyze / Curate a
   few times, then rebuilds the card from its pristine markup and removes all of
   this. Row classes: .fbm-off (not loaded yet), .fbm-raw (not yet classified),
   .fbm-flag / .fbm-gap (Analyze), .fbm-neg (Curate: recedes); JS-made bits:
   i.fbm-scan in .srows, i.fbm-fl micro-label in .lines, .q.fbm-typing caret.
   Only opacity, transform, colour and the bar's inner widths animate, so the
   card's height is constant. Static (no loop) without JS or with reduced motion. */
html.fb-motion .serpcard.fbm-live .srows, html.fb-motion .serpcard.fbm-live .srow .lines{ position: relative; }
html.fb-motion .serpcard.fbm-live .srow{ position: relative; z-index: 1; } /* risers pass over; a receding negative goes under */
html.fb-motion .serpcard.fbm-live .gbox .q{ min-width: 0; overflow: hidden; } /* motion.js pins its height */
html.fb-motion .serpcard.fbm-live .srow{
  outline: 1.5px dashed transparent; outline-offset: -1px;
  transition: opacity .5s var(--fbm-e), transform 1.1s cubic-bezier(.65,0,.25,1),
              border-color .55s var(--fbm-e), background-color .55s var(--fbm-e), box-shadow .45s var(--fbm-e), outline-color .45s var(--fbm-e);
}
html.fb-motion .serpcard.fbm-live .srow :is(.l1, .l2){ transform-origin: left center; transition: transform .7s var(--fbm-e); }
html.fb-motion .serpcard.fbm-live .srow.fbm-off :is(.l1, .l2){ transform: scaleX(0); }
html.fb-motion .serpcard.fbm-live .srow.fbm-raw{ --sc: #d3d8de; --sbg: #f5f6f8; }
html.fb-motion .serpcard.fbm-live .srow .bd{ transition: background-color .55s var(--fbm-e), color .55s var(--fbm-e); }
html.fb-motion .serpcard.fbm-live .srow.fbm-raw .bd{ background: #e8eaee; color: transparent; }
html.fb-motion .serpcard.fbm-live .srow .lock{ transition: opacity .5s var(--fbm-e); }
html.fb-motion .serpcard.fbm-live .srow.fbm-raw .lock{ opacity: 0; }
/* Track: a scan line passes down the rows as they classify */
html.fb-motion .serpcard .fbm-scan{
  position: absolute; left: -2px; right: -2px; top: 0; height: 2px; border-radius: 2px; opacity: 0; pointer-events: none; z-index: 2;
  background: linear-gradient(90deg, rgba(26,115,232,0), rgba(26,115,232,.85) 30%, rgba(26,115,232,.85) 70%, rgba(26,115,232,0));
  box-shadow: 0 0 10px rgba(26,115,232,.45);
}
html.fb-motion .serpcard .fbm-scan.on{ animation: fbm-scan 1.75s cubic-bezier(.4,.1,.6,.9) both; }
@keyframes fbm-scan{ 0%{ top: 0; opacity: 0; } 10%{ opacity: 1; } 90%{ opacity: 1; } 100%{ top: 100%; opacity: 0; } }
/* Analyze: the negative is flagged (amber ring), one unrated slot is marked as a gap (dashed) */
html.fb-motion .serpcard.fbm-live .srow.fbm-flag{ box-shadow: 0 0 0 1.5px rgba(217,152,33,.8), 0 0 0 5px rgba(217,152,33,.12); }
html.fb-motion .serpcard.fbm-live .srow.fbm-gap{ outline-color: rgba(217,152,33,.85); }
html.fb-motion .serpcard .fbm-fl{
  position: absolute; right: 0; top: 50%; transform: translateY(-50%); opacity: 0; white-space: nowrap; font-style: normal;
  font-family: var(--mono); font-size: 8px; line-height: 1; letter-spacing: .08em; text-transform: uppercase;
  color: #855a0d; background: #fcf6ea; border: 1px solid #f0dcb0; padding: 3px 6px; border-radius: 100px;
  transition: opacity .4s var(--fbm-e);
}
html.fb-motion .serpcard .srow:is(.fbm-flag, .fbm-gap) .fbm-fl{ opacity: 1; }
/* Curate: rows re-order by transform (motion.js sets translateY); the negative recedes */
html.fb-motion .serpcard.fbm-live .srow.fbm-neg{ opacity: .55; z-index: 0; }
/* not loaded yet (after .fbm-neg so a receded negative still clears fully) */
html.fb-motion .serpcard.fbm-live .srow.fbm-off{ opacity: 0; }
/* the search box types: a caret */
html.fb-motion .serpcard .q.fbm-typing::after{
  content: ""; display: inline-block; width: 1px; height: 1.05em; margin-left: 1px; vertical-align: -.15em; background: #3c4043;
  animation: fbm-blink 1s steps(2, start) infinite;
}
@keyframes fbm-blink{ to{ visibility: hidden; } }
/* the sentiment bar empties while a page loads, grows back in sequence, re-proportions on curate */
html.fb-motion .serpcard.fbm-live .sbar > i{ transform-origin: left center; transition: width .9s var(--fbm-e), transform .7s var(--fbm-e) calc(var(--fbm-i, 0) * .09s); }
html.fb-motion .serpcard.fbm-live .sbar.fbm-off > i{ transform: scaleX(0); transition-delay: 0s; }

/* ----- 6. Process / timeline (Meridian): a hairline of light sweeps across
   the steps as they lock in, and the step numbers light up in order ------- */
html.fb-motion .steps{ position: relative; }
html.fb-motion .steps:not(.fbm-done)::before{
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; z-index: 1; pointer-events: none;
  background: linear-gradient(90deg, var(--amber) 0%, rgba(217,152,33,.55) 60%, rgba(217,152,33,0) 100%);
  transform: scaleX(0); transform-origin: left center; opacity: 0;
}
html.fb-motion .steps.fbm-in:not(.fbm-done)::before{ animation: fbm-sweep 1.7s var(--fbm-e) .15s forwards; }
@keyframes fbm-sweep{
  0%{ transform: scaleX(0); opacity: 1; }
  62%{ transform: scaleX(1); opacity: 1; }
  100%{ transform: scaleX(1); opacity: 0; }
}
html.fb-motion .steps:not(.fbm-done) .num{ transition: color .6s var(--fbm-e); transition-delay: calc(var(--fbm-d, 0s) + .35s); }
html.fb-motion .steps:not(.fbm-in) .num{ color: #6f8197; }

/* ----- 7. Header: shadow firms up once the page scrolls ------------------- */
html.fb-motion :is(body > header, .wp-site-blocks > header){ transition: box-shadow .4s var(--fbm-e); }
html.fb-motion :is(body > header, .wp-site-blocks > header).fbm-scrolled{ box-shadow: 0 12px 32px -14px rgba(20,37,57,.22); }

/* ----- 8. Hover polish: underline draws in from the left ----------------- */
html.fb-motion :is(.more, .crisislink){
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat; background-position: 0 100%; background-size: 0 1px;
  transition: background-size .35s var(--fbm-e), color .2s;
}
html.fb-motion :is(.more, .crisislink):hover{ text-decoration: none; background-size: 100% 1px; }

/* ----- 9. FAQ accordions: the answer fades down on open ------------------- */
html.fb-motion details[open] > :not(summary){ animation: fbm-fade-down .4s var(--fbm-e); }
@keyframes fbm-fade-down{ from{ opacity: 0; transform: translateY(-6px); } to{ opacity: 1; transform: none; } }

/* ----- 10. Safety net: the head pre-gate added .fb-motion but motion.js never
   ran (blocked / failed). Reveal everything after 2.5s so nothing stays
   hidden. motion.js adds .fb-motion-js, which switches this off. ---------- */
html.fb-motion:not(.fb-motion-js) :where(
  .hero .lead, .eo-intro > .wrap, .prs-hero > .wrap,
  .head, .faq-head, .approach .body, .firm .body, .cr-synth .body, .eo-who .body, .belief > .wrap,
  .contact .grid > div:first-child, .cr-faq > .wrap, .prs-list > .wrap,
  .fork, .steps, .overlap, .pgrid, .metrics, .engines, .kcg, .kblist, .facets, .fstats, .techlist, .reassure,
  .ldr-grid, .ldr-disc, .faces,
  .cr-reasons, .cr-layerlist, .cr-tags, .cr-synth .models, .faq-list, .faq-jump, .wk-faq,
  .imp-feat, .imp-engines, .eo-grid, .eo-feats, .eo-list, .ct-row,
  .article-head, .mth-interests, .mth-items, .mth-who, .abt-ind, .abt-ethics, .cs-list, .cs-results,
  .aud-uvp, .aud-incl, .aud-engage, .geo-loc, .geo-ext, .wa-checks, .wk-incl, .wk-prop, .wk-cmp,
  .oim-needs, .oim-incl, .oim-hero-cards, .car-vals, .car-disc, .car-roles, .svc-who, .kb-lenses, .ins-feat, .ins-side
) > *,
html.fb-motion:not(.fb-motion-js) :where(
  .serpcard, .form, .trust, .crumbs, .kb-answer, .xref, .article-cta, .nextpost .np-link,
  .ldr-founder, .cr-synth .panel, .prs-media .panel, .faq-crisis-note, .mth-overlapnote, .kbmore, .kb-intro, .svc-intro
),
html.fb-motion:not(.fb-motion-js) :where(.lc-photo img, .lf-photo img, .serpcard .srow, .serpcard .sbar > i, .metrics .track i, .metrics .trend polyline, .metrics .mbig > *){
  animation: fbm-safe 1ms linear 2.5s forwards;
}
html.fb-motion:not(.fb-motion-js) .cr-synth .models > *{ animation: fbm-safe-f 1ms linear 2.5s forwards; }
@keyframes fbm-safe{ to{ opacity: 1; transform: none; clip-path: none; stroke-dashoffset: 0; } }
@keyframes fbm-safe-f{ to{ opacity: 1; transform: none; filter: none; } }

} /* end prefers-reduced-motion: no-preference */
