/* ════════════════════════════════════════════════════════════════════
   MOTION-01 — the premium motion vocabulary (2026-10-18)
   ────────────────────────────────────────────────────────────────────
   FASE 21.D (platforma-motion.css) animates a SECTION as one box: five
   entrance presets on `.platforma-motion-wrap`. That was the only motion a
   tenant website had — measured 2026-10-17: zero @keyframes across all
   seven platforma.website.*.css sheets.

   This sheet adds what makes a section look brand-made INSIDE itself:
   children that arrive one after another, cards that answer the pointer,
   media that settles, a rule that draws itself, a strip that runs.

   ── Why it is gated on the BODY, not adopted per template ─────────────
   The obvious route was a bespoke partial per template, the way
   TEMPLATE-BAKERY-01 did its hero. Measured cost of that route for the
   sections service-portal actually uses: `_QuickActions.cshtml` is 118
   lines of real logic — an IDynamicSectionDataSource probe, the
   admin-cards/auto-synth fallback, HeroiconResolver, and per-slot
   click-to-edit hooks. Forking that per template duplicates the logic and
   guarantees the next fix to the shared one never reaches the copy.

   So the classes live in the SHARED partials, and this stylesheet only
   engages under `body.pf-motion-premium`. The layout appends that class
   when BOTH hold: the active template declares `PremiumMotion: true` in
   WebsiteTemplateRegistry, AND `feature.website.premium-motion.v1` is ON
   for the tenant. Everyone else renders byte-identically to before — the
   classes are inert markup.

   ── The vocabulary ────────────────────────────────────────────────────
     .pf-m-stagger   on a container → its direct children arrive in turn
     .pf-m-rise      on a block     → settles up into place
     .pf-m-reveal    on a media box → the image eases out of a 1.04 scale
     .pf-m-rule      on a hairline  → draws itself from the leading edge
     .pf-m-lift      on a card      → answers pointer + keyboard focus
     .pf-m-marquee   on a strip     → runs continuously, pauses on hover

   ── Two rules the BROWSER taught this file, not the tests ─────────────
   Both were measured on 2026-10-18 on a real Service Portal page with the
   flag ON, and both had a fully green test matrix behind them.

   1. ENTRANCE STATES USE `translate` / `scale`, NEVER `transform`.
      A quick-action card is both a `.pf-m-stagger` child and a
      `.pf-m-lift`. With the entrance written as `transform: translateY(...)`,
      the deeper stagger selector won the `transition` shorthand outright,
      so the card's computed transition was `opacity, transform` and the
      lift's `box-shadow` never animated at all (measured:
      transitionProperty = "opacity, transform"). Writing the entrance with
      the standalone `translate` and `scale` properties means the two
      effects touch disjoint properties and compose instead of competing:
      a card can be mid-entrance AND hovered.

   2. EVERY `.is-in-view` RULE REPEATS THE FENCE CHAIN.
      The fence below carries `[data-motion]:not([data-motion="none"])`,
      which makes it MORE specific than a plain `.is-in-view` selector —
      so the hidden state outranked the visible one and the cards stayed at
      `opacity: 0` forever with the gate ON (measured: 3 wrappers in view,
      first card opacity 0). That is the blank-content failure
      platforma-section-interactions.js already carries two 2026-05-09
      hotfix comments about. The in-view rules therefore repeat the chain,
      which is exactly what FASE 21.D does for its own presets.

   ── The safety contract (why each guard exists) ───────────────────────
   Every hidden initial state is fenced four ways, ordered so the LAST word
   is always "visible":

     1. It only applies inside `.platforma-motion-wrap[data-motion]` whose
        preset is NOT "none". A wrapper set to "none" never receives
        `.is-in-view` — the observer returns early for it and so does the
        1.5 s fail-safe — so a hidden state under that preset would stay
        hidden for good. Page.cshtml forces "none" in the editor.
     2. `body[data-edit-mode="true"]` — the editor canvas is for clicking,
        not for watching.
     3. `prefers-reduced-motion: reduce` — collapses to the final state.
     4. `.no-js` — set by the layout's <noscript>; without JS there is no
        `.is-in-view` to arrive.

   Each guard releases `opacity`, `translate`, `scale` AND `transform`: a
   guard that forgot one of the individual properties would leave the
   content displaced while claiming to have released it.

   .pf-m-lift and .pf-m-marquee have NO hidden state, which is why they
   are safe outside those fences and work with JS off and in the editor.

   ── Performance ───────────────────────────────────────────────────────
   No `will-change` except on the marquee track: declaring it per section
   is what turns an animation into a Core Web Vitals regression. Every
   transition animates `opacity`, `translate`, `scale`, `transform` and
   `box-shadow` only — all composited, none forces layout. Nothing here
   animates width, height, top or left.
   ──────────────────────────────────────────────────────────────────── */

body.pf-motion-premium .chub {
    /* One step between two staggered siblings. Past ~90ms the last card
       reads as late rather than choreographed. */
    --pf-m-step: 70ms;
    --pf-m-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
    --pf-m-dur: 0.68s;
    --pf-m-hover: 0.32s;
}

/* ── .pf-m-stagger — children arrive one after another ──────────────── */

/* The transition list carries the LIFT's properties too, at the lift's own duration.
   That is not redundancy: `transition` is a single CSS property, so this deeper rule wins
   the whole shorthand from `.pf-m-lift` on any card that is both a stagger child and a
   lift — which every quick-action card is. Measured on 2026-10-18 without these two
   lines: computed transitionProperty was "opacity, translate", so the hover moved and
   gained its shadow with no easing at all. Disjoint properties were not enough; the
   shorthand had to be made whole. */
body.pf-motion-premium .chub .platforma-motion-wrap[data-motion]:not([data-motion="none"]) .pf-m-stagger > * {
    opacity: 0;
    translate: 0 18px;
    transition:
        opacity var(--pf-m-dur) var(--pf-m-ease),
        translate var(--pf-m-dur) var(--pf-m-ease),
        transform var(--pf-m-hover) var(--pf-m-ease),
        box-shadow var(--pf-m-hover) var(--pf-m-ease);
}

body.pf-motion-premium .chub .platforma-motion-wrap[data-motion]:not([data-motion="none"]).is-in-view .pf-m-stagger > * {
    opacity: 1;
    translate: none;
}

/* Ten steps is the ceiling on purpose: an eleventh card would wait 770ms
   for its turn, which reads as a slow page rather than as polish. Every
   child past the tenth arrives with the tenth. */
body.pf-motion-premium .chub .platforma-motion-wrap[data-motion]:not([data-motion="none"]).is-in-view .pf-m-stagger > *:nth-child(1) { transition-delay: calc(var(--pf-m-step) * 0); }
body.pf-motion-premium .chub .platforma-motion-wrap[data-motion]:not([data-motion="none"]).is-in-view .pf-m-stagger > *:nth-child(2) { transition-delay: calc(var(--pf-m-step) * 1); }
body.pf-motion-premium .chub .platforma-motion-wrap[data-motion]:not([data-motion="none"]).is-in-view .pf-m-stagger > *:nth-child(3) { transition-delay: calc(var(--pf-m-step) * 2); }
body.pf-motion-premium .chub .platforma-motion-wrap[data-motion]:not([data-motion="none"]).is-in-view .pf-m-stagger > *:nth-child(4) { transition-delay: calc(var(--pf-m-step) * 3); }
body.pf-motion-premium .chub .platforma-motion-wrap[data-motion]:not([data-motion="none"]).is-in-view .pf-m-stagger > *:nth-child(5) { transition-delay: calc(var(--pf-m-step) * 4); }
body.pf-motion-premium .chub .platforma-motion-wrap[data-motion]:not([data-motion="none"]).is-in-view .pf-m-stagger > *:nth-child(6) { transition-delay: calc(var(--pf-m-step) * 5); }
body.pf-motion-premium .chub .platforma-motion-wrap[data-motion]:not([data-motion="none"]).is-in-view .pf-m-stagger > *:nth-child(7) { transition-delay: calc(var(--pf-m-step) * 6); }
body.pf-motion-premium .chub .platforma-motion-wrap[data-motion]:not([data-motion="none"]).is-in-view .pf-m-stagger > *:nth-child(8) { transition-delay: calc(var(--pf-m-step) * 7); }
body.pf-motion-premium .chub .platforma-motion-wrap[data-motion]:not([data-motion="none"]).is-in-view .pf-m-stagger > *:nth-child(9) { transition-delay: calc(var(--pf-m-step) * 8); }
body.pf-motion-premium .chub .platforma-motion-wrap[data-motion]:not([data-motion="none"]).is-in-view .pf-m-stagger > *:nth-child(n+10) { transition-delay: calc(var(--pf-m-step) * 9); }

/* ── .pf-m-rise — a block settles up into place ─────────────────────── */

body.pf-motion-premium .chub .platforma-motion-wrap[data-motion]:not([data-motion="none"]) .pf-m-rise {
    opacity: 0;
    translate: 0 22px;
    transition:
        opacity var(--pf-m-dur) var(--pf-m-ease),
        translate var(--pf-m-dur) var(--pf-m-ease);
}

body.pf-motion-premium .chub .platforma-motion-wrap[data-motion]:not([data-motion="none"]).is-in-view .pf-m-rise {
    opacity: 1;
    translate: none;
}

/* ── .pf-m-reveal — media eases out of a slight over-scale ──────────── */

/* The box clips; the picture inside is what moves. This goes on the frame,
   not on the img, or the overflow has nothing to crop against. */
body.pf-motion-premium .chub .pf-m-reveal {
    overflow: hidden;
}

body.pf-motion-premium .chub .platforma-motion-wrap[data-motion]:not([data-motion="none"]) .pf-m-reveal > img,
body.pf-motion-premium .chub .platforma-motion-wrap[data-motion]:not([data-motion="none"]) .pf-m-reveal > picture > img {
    scale: 1.04;
    transition: scale 1.1s var(--pf-m-ease);
}

body.pf-motion-premium .chub .platforma-motion-wrap[data-motion]:not([data-motion="none"]).is-in-view .pf-m-reveal > img,
body.pf-motion-premium .chub .platforma-motion-wrap[data-motion]:not([data-motion="none"]).is-in-view .pf-m-reveal > picture > img {
    scale: 1;
}

/* ── .pf-m-rule — a hairline draws itself from the leading edge ─────── */

body.pf-motion-premium .chub .platforma-motion-wrap[data-motion]:not([data-motion="none"]) .pf-m-rule {
    scale: 0 1;
    transform-origin: left center;
    transition: scale 0.9s var(--pf-m-ease);
}

body.pf-motion-premium .chub .platforma-motion-wrap[data-motion]:not([data-motion="none"]).is-in-view .pf-m-rule {
    scale: 1 1;
}

/* A right-to-left page draws it from the right. */
[dir="rtl"] body.pf-motion-premium .chub .platforma-motion-wrap[data-motion]:not([data-motion="none"]) .pf-m-rule,
body.pf-motion-premium[dir="rtl"] .chub .platforma-motion-wrap[data-motion]:not([data-motion="none"]) .pf-m-rule {
    transform-origin: right center;
}

/* ════════════════════════════════════════════════════════════════════
   .pf-m-lift — a card answers the pointer AND the keyboard.
   No hidden state, so no fence. It animates `transform`, which no
   entrance state touches (see note 1 in the header), so a card that is
   also a stagger child keeps both effects.
   Keyboard parity is not optional: a card that reacts only to :hover
   tells a keyboard user nothing.
   ════════════════════════════════════════════════════════════════════ */

body.pf-motion-premium .chub .pf-m-lift {
    transition:
        transform var(--pf-m-hover) var(--pf-m-ease),
        box-shadow var(--pf-m-hover) var(--pf-m-ease);
}

body.pf-motion-premium .chub .pf-m-lift:hover,
body.pf-motion-premium .chub .pf-m-lift:focus-within {
    transform: translateY(-4px);
    box-shadow: 0 18px 40px -22px rgba(17, 24, 39, 0.38);
}

/* The lift must never swallow the focus ring — a translated card with no
   visible ring is a WCAG 2.4.7 failure dressed up as polish. */
body.pf-motion-premium .chub .pf-m-lift:focus-within {
    outline: 2px solid var(--chub-primary, currentColor);
    outline-offset: 3px;
}

/* ════════════════════════════════════════════════════════════════════
   .pf-m-marquee — a continuous strip (trust claims, partner names).
   Markup contract: .pf-m-marquee > .pf-m-marquee-track > items, and the
   track's content is DUPLICATED by the partial so the -50% loop is
   seamless. The duplicate carries aria-hidden="true" there, or a screen
   reader reads the strip twice.
   ════════════════════════════════════════════════════════════════════ */

body.pf-motion-premium .chub .pf-m-marquee {
    overflow: hidden;
    /* Decorative movement, not a scroll region; without this a trackpad
       swipe drags the track out of its loop. */
    overscroll-behavior-x: contain;
}

body.pf-motion-premium .chub .pf-m-marquee-track {
    display: flex;
    width: max-content;
    will-change: transform;
    animation: pf-m-marquee-run 38s linear infinite;
}

body.pf-motion-premium .chub .pf-m-marquee:hover .pf-m-marquee-track,
body.pf-motion-premium .chub .pf-m-marquee:focus-within .pf-m-marquee-track {
    animation-play-state: paused;
}

@keyframes pf-m-marquee-run {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}

/* ════════════════════════════════════════════════════════════════════
   Guard 2 — the editor canvas.
   Page.cshtml already forces data-motion="none" in edit mode, which the
   fence alone would catch. This repeats it on the body attribute so a
   future editor that previews a real preset still gets a still canvas.
   ════════════════════════════════════════════════════════════════════ */

body[data-edit-mode="true"] .chub .pf-m-stagger > *,
body[data-edit-mode="true"] .chub .pf-m-rise,
body[data-edit-mode="true"] .chub .pf-m-reveal > img,
body[data-edit-mode="true"] .chub .pf-m-reveal > picture > img,
body[data-edit-mode="true"] .chub .pf-m-rule {
    opacity: 1 !important;
    translate: none !important;
    scale: none !important;
    transform: none !important;
    transition: none !important;
}

/* ════════════════════════════════════════════════════════════════════
   Guard 4 — no JS, so no `.is-in-view` will ever arrive. Placed before
   the reduced-motion block so that block stays the file's last word.
   ════════════════════════════════════════════════════════════════════ */

.no-js .chub .pf-m-stagger > *,
.no-js .chub .pf-m-rise,
.no-js .chub .pf-m-reveal > img,
.no-js .chub .pf-m-reveal > picture > img,
.no-js .chub .pf-m-rule {
    opacity: 1 !important;
    translate: none !important;
    scale: none !important;
    transform: none !important;
    transition: none !important;
}

/* ════════════════════════════════════════════════════════════════════
   Guard 3 — prefers-reduced-motion. LAST in the file so it outranks
   every rule above it at equal specificity. Nothing moves; everything is
   visible; the marquee becomes a static, readable, wrapping row.
   ════════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
    body.pf-motion-premium .chub .pf-m-stagger > *,
    body.pf-motion-premium .chub .pf-m-rise,
    body.pf-motion-premium .chub .pf-m-reveal > img,
    body.pf-motion-premium .chub .pf-m-reveal > picture > img,
    body.pf-motion-premium .chub .pf-m-rule,
    body.pf-motion-premium .chub .pf-m-lift,
    body.pf-motion-premium .chub .pf-m-lift:hover,
    body.pf-motion-premium .chub .pf-m-lift:focus-within {
        opacity: 1 !important;
        translate: none !important;
        scale: none !important;
        transform: none !important;
        transition: none !important;
    }

    /* A merely paused marquee would clip every claim past the first
       viewport width. Dropping the animation and letting the row wrap
       keeps all of them readable. */
    body.pf-motion-premium .chub .pf-m-marquee-track {
        animation: none !important;
        will-change: auto;
        width: auto;
        flex-wrap: wrap;
    }

    /* The focus ring is an affordance, not motion — it stays, and so does
       the shadow that tells a mouse user the card is live. */
    body.pf-motion-premium .chub .pf-m-lift:focus-within {
        outline: 2px solid var(--chub-primary, currentColor);
        outline-offset: 3px;
    }

    body.pf-motion-premium .chub .pf-m-lift:hover,
    body.pf-motion-premium .chub .pf-m-lift:focus-within {
        box-shadow: 0 18px 40px -22px rgba(17, 24, 39, 0.38);
    }
}
