/*
 * MOTION ON THE PUBLIC END (docs/design/07-motion.md). Loaded by the rental
 * site's layout and by a shop's landing page, which only a visitor sees;
 * never by an admin, never by a page a signed-in customer uses. Colour comes
 * from the surface's own accent: the rental site's gold, a shop's own.
 *
 * Big screens, 900px and wider, move; under 900px a piece only fades and
 * nothing answers a hover. Only transform and opacity change. Every rule
 * that moves something is answered in the reduced-motion block at the end,
 * last so it wins (MotionGuardsTest).
 */

:root {
    --motion-accent: var(--gold, var(--accent, var(--primary, #8a8a8a)));
    --motion-ease: cubic-bezier(.16, 1, .3, 1);
    --motion-pop: cubic-bezier(.34, 1.56, .64, 1);
}

/* M1. Words rise. site-motion.js splits a heading into its words, each in a
   box that clips it. The hero's headline, and the line and buttons under
   it, wait for the words only while the script is on its way; if it never
   comes, they show by themselves. Under 900px they only fade in. */
.mw { display: inline-block; overflow: clip; padding-bottom: .14em; margin-bottom: -.14em; vertical-align: top; }
.mw > span { display: inline-block; }
/* Only the headline waits; the line under it is the page's largest paint. */
html.motion .hero h1:not([data-words]) { opacity: 0; animation: motion-unhide 0s linear 1.6s forwards; }
/* A shop's platform tiles wait the same way, to arrive as the page opens
   (section 3), and show by themselves if the script never comes. */
html.motion:not(.motion-on) .platform-tiles > li { opacity: 0; animation: motion-unhide 0s linear 1.6s forwards; }
@keyframes motion-unhide { to { opacity: 1; } }

/* 1. Arriving, both ways and every time (site-motion.js). A piece is is-in
   on screen and not in out of view, waiting on its side (--side: one below,
   minus one above); the change is a transition. Items side by side go in
   turn (--order), first to last going down and last to first going up.
   Nothing is hidden until the script has started (motion-on), and a piece
   with the keyboard's focus inside it is always shown. */
[data-side="above"] { --side: -1; }
[data-piece], [data-carousel-item], .mw > span, .iw { --order: var(--i, 0); }
html[data-scrolling="up"] :is([data-piece], [data-carousel-item], .mw > span, .iw) { --order: calc(var(--n, 1) - 1 - var(--i, 0)); }
html.motion-hold [data-piece], html.motion-hold [data-piece] * { transition: none !important; }

@media (max-width: 899px) {
    .hero h1, .hero h1 ~ * { transition: opacity .3s ease; }
    html.motion-on [data-piece] { transition: opacity .3s ease; }
    html.motion-on [data-piece]:not(.is-in):not(:focus-within) { opacity: 0; }
}

@media (min-width: 900px) {
    [data-words].is-words-pending .mw > span { transform: translateY(130%); }
    [data-words].is-words-in .mw > span { transition: transform .75s var(--motion-ease) calc(var(--order) * 70ms); }
    .hero h1.is-words-pending ~ * { transform: translateY(.75rem); }
    .hero h1.is-words-in ~ * { transition: transform .7s var(--motion-ease) .35s; }

    html.motion-on [data-piece="block"], html.motion-on [data-piece="carousel"] [data-carousel-item] { transition: opacity .55s ease calc(var(--order) * 80ms), transform .8s var(--motion-ease) calc(var(--order) * 80ms); }
    html.motion-on [data-piece="block"]:not(.is-in):not(:focus-within), html.motion-on [data-piece="carousel"]:not(.is-in):not(:focus-within) [data-carousel-item] { opacity: 0; transform: translate3d(0, calc(var(--side, 1) * 2.5rem), 0) scale(.97); }
    html.motion-on [data-piece="carousel"] .carousel-controls { transition: opacity .5s ease .2s; }
    html.motion-on [data-piece="carousel"]:not(.is-in):not(:focus-within) .carousel-controls { opacity: 0; }
    /* A title's words rise from their lines in turn, and leave the same way. */
    html.motion-on [data-piece="words"] .mw > span { transition: transform .7s var(--motion-ease) calc(var(--order) * 55ms); }
    html.motion-on [data-piece="words"]:not(.is-in) .mw > span { transform: translate3d(0, calc(var(--side, 1) * 130%), 0); }
    /* M8. A paragraph inks in, word by word, and dims back as it leaves. */
    html.motion-on [data-piece] .iw { transition: opacity .45s ease calc(var(--order) * 14ms); }
    html.motion-on [data-piece]:not(.is-in):not(:focus-within) .iw { opacity: .25; }
    /* Section 2. The plans grow into place one after another, a little past
       their size and back: the first, the second, the third going down, the
       third first going up, and shrink back the same way as they leave. */
    html.motion-on .plan-preview > [data-piece] { transition: opacity .5s ease calc(var(--order) * 170ms), transform .8s var(--motion-pop) calc(var(--order) * 170ms); }
    html.motion-on .plan-preview > [data-piece]:not(.is-in):not(:focus-within) { opacity: 0; transform: translate3d(0, calc(var(--side, 1) * 1.5rem), 0) scale(.8); }
}

/* Section 3. A shop's platform tiles as a loop that never stops, on every
   screen, the one exception to big screens only; site-motion.js says how
   the seam stays hidden and the run flips. Only the transform moves. Three
   tiles at a time on a phone, sized once from the loop's own width. */
.tiles-loop { overflow: clip; container-type: inline-size; padding-block: var(--space-2, .5rem); -webkit-mask-image: linear-gradient(90deg, transparent, black 6%, black 94%, transparent); mask-image: linear-gradient(90deg, transparent, black 6%, black 94%, transparent); }
.platform-tiles.is-loop { display: flex; flex-wrap: nowrap; gap: 0; width: max-content; animation: motion-loop var(--loop-time, 30s) linear infinite; }
.platform-tiles.is-loop > li { flex: none; margin-inline-end: var(--space-3, .75rem); }
.tiles-loop:hover .platform-tiles, .tiles-loop:focus-within .platform-tiles, .platform-tiles.is-paused { animation-play-state: paused; }
@keyframes motion-loop { to { transform: translateX(-50%); } }
@media (min-width: 900px) {
    .platform-tiles.is-loop .platform-tile { min-width: 9rem; }
}
@media (max-width: 899px) {
    .platform-tiles.is-loop > li { width: calc((100cqi - 2 * var(--space-3, .75rem)) / 3); }
    .platform-tiles.is-loop .platform-tile { height: 100%; flex-direction: column; justify-content: center; gap: .35rem; text-align: center; font-size: .85rem; }
}

/* A panel's home hero stays put on a big screen and the page slides up over
   it, a sheet (site-motion.js). The rental site scrolls as one page instead,
   nothing over anything (owner, 18 Oct 2026). Past half way the hero settles
   back and its words sink; on the way back up they rise. */
@media (min-width: 900px) {
    html.motion .shop main > .hero:first-child + * { border-top: 1px solid var(--border); border-radius: 2rem 2rem 0 0; }
    .shop .hero.is-pinned { position: sticky; top: var(--pin-top, 0px); }
    .shop .hero.is-pinned ~ * { position: relative; z-index: 1; }
    .shop .hero.is-pinned ~ :not(.section-alt) { background-color: var(--bg); }
    .hero.is-pinned > * { transition: opacity .6s ease, transform .8s var(--motion-ease); transform-origin: 50% 0; }
    .hero.is-pinned:not(.is-in):not(:focus-within) > * { opacity: .25; transform: translate3d(0, -1.5rem, 0) scale(.94); }
    .hero.is-pinned .mw > span { transition: transform .6s var(--motion-ease) calc(var(--order) * 50ms); }
    .hero.is-pinned:not(.is-in) .mw > span { transform: translate3d(0, 130%, 0); }
}

/* M2. Light. The hero's glow fades in; on a big screen it then breathes. */
.hero { position: relative; isolation: isolate; }
.hero::before {
    content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: 0;
    background: radial-gradient(44rem 22rem at 50% -8%, color-mix(in srgb, var(--motion-accent) 15%, transparent), transparent 70%);
    animation: motion-light 1.4s ease-out .1s forwards;
}
@keyframes motion-light { to { opacity: 1; } }
@keyframes motion-breathe { from { opacity: 1; } to { opacity: .55; } }

/* M4. A counted figure keeps its width while it counts. */
[data-count], .facts strong, .trust-grid strong { font-variant-numeric: tabular-nums; }

/* Big screens only: the drift, the shine, the ripples, the slow glow and the
   folds that grow. */
@media (min-width: 900px) {
    .hero::before { animation: motion-light 1.4s ease-out .1s forwards, motion-breathe 7s ease-in-out 1.6s infinite alternate; }

    /* M3. Drift. A shop's hero picture floats, slowly. */
    .hero-art > * { animation: motion-float 7s ease-in-out infinite alternate; }

    /* M7. Shine. Now and then a band of light passes over the button that
       matters, as the parent panel does on its primary buttons. */
    .hero .button-primary, .cta-band .button-primary, .final-cta .button-primary, .plan.is-highlight .button { position: relative; overflow: hidden; isolation: isolate; }
    .hero .button-primary::after, .cta-band .button-primary::after, .final-cta .button-primary::after, .plan.is-highlight .button::after {
        content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; transform: translateX(-120%);
        background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, .38) 50%, transparent 70%);
        animation: motion-shine 4.2s ease-in-out 1.8s infinite;
    }

    /* M11. Ripples spread from the closing call to action and fade. */
    .cta-band, .final-cta { position: relative; isolation: isolate; overflow: clip; }
    .cta-band::before, .cta-band::after, .final-cta::before, .final-cta::after {
        content: ""; position: absolute; left: 50%; top: 50%; z-index: -1; width: 20rem; height: 20rem; margin: -10rem 0 0 -10rem;
        border-radius: 50%; border: 1px solid color-mix(in srgb, var(--motion-accent) 45%, transparent); pointer-events: none; opacity: 0;
        animation: motion-ripple 6s ease-out infinite;
    }
    .cta-band::after, .final-cta::after { animation-delay: 3s; }

    /* M12. Lift. The highlighted plan glows, slowly. */
    .plan-mini.is-highlight { position: relative; }
    .plan.is-highlight::before, .plan-mini.is-highlight::before {
        content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none; opacity: .3;
        box-shadow: 0 0 2.5rem color-mix(in srgb, var(--motion-accent) 32%, transparent);
        animation: motion-glow 3.2s ease-in-out infinite alternate;
    }
}
@keyframes motion-float { from { transform: translateY(0); } to { transform: translateY(-.6rem); } }
@keyframes motion-shine { 0% { transform: translateX(-120%); } 35%, 100% { transform: translateX(120%); } }
@keyframes motion-ripple { from { transform: scale(.35); opacity: .8; } to { transform: scale(2.2); opacity: 0; } }
@keyframes motion-glow { to { opacity: 1; } }

/* M13. Folds. A question opens by growing, on a big screen where the
   browser can size to its content. */
@supports (interpolate-size: allow-keywords) {
    @media (min-width: 900px) {
        .faq-item, .plan-details { interpolate-size: allow-keywords; }
        .faq-item::details-content, .plan-details::details-content { block-size: 0; overflow: clip; transition: block-size .35s var(--motion-ease), content-visibility .35s allow-discrete; }
        .faq-item[open]::details-content, .plan-details[open]::details-content { block-size: auto; }
    }
}

/* What answers a mouse, on a big screen only: M6, the card under the
   pointer lights where the pointer is and its edge takes the accent; M12, a
   platform's mark lifts; M13, a question row nudges towards the pointer. */
@media (min-width: 900px) and (hover: hover) and (pointer: fine) {
    [data-glow] { position: relative; isolation: isolate; transition: border-color .3s ease; }
    [data-glow]::after {
        content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none; opacity: 0;
        background: radial-gradient(16rem circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--motion-accent) 16%, transparent), transparent 70%);
        transition: opacity .3s ease;
    }
    [data-glow]:hover::after { opacity: 1; }
    [data-glow]:hover { border-color: color-mix(in srgb, var(--motion-accent) 50%, var(--border, transparent)); }
    .platform-tile .platform-mark { transition: transform .4s var(--motion-pop); }
    .platform-tile:hover .platform-mark { transform: translateY(-2px) rotate(-8deg) scale(1.12); }
    .faq-item > summary { transition: transform .25s var(--motion-ease); }
    .faq-item > summary:hover { transform: translateX(4px); }

    /* Section 1. The feature card under the pointer grows a little and
       comes forward while the others step back; its edge and a fine fade of
       the accent light up around it, and a glossy sheen passes across it. */
    .feature-card { position: relative; isolation: isolate; overflow: hidden; transition: scale .45s var(--motion-ease), box-shadow .45s ease, border-color .45s ease; }
    html.motion-on [data-piece="carousel"] .feature-card[data-carousel-item] { transition: opacity .55s ease calc(var(--order) * 80ms), transform .8s var(--motion-ease) calc(var(--order) * 80ms), scale .45s var(--motion-ease), box-shadow .45s ease, border-color .45s ease; }
    .feature-track:has(.feature-card:hover) .feature-card { scale: .95; }
    .feature-track:has(.feature-card:hover) .feature-card:hover {
        scale: 1.05; border-color: color-mix(in srgb, var(--motion-accent) 60%, transparent);
        box-shadow: 0 0 0 1px color-mix(in srgb, var(--motion-accent) 30%, transparent), 0 0 1.5rem color-mix(in srgb, var(--motion-accent) 22%, transparent), 0 1.5rem 3rem -1rem color-mix(in srgb, var(--motion-accent) 38%, transparent);
    }
    .feature-card::before {
        content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; transform: translateX(-120%);
        background: linear-gradient(110deg, transparent 32%, rgba(255, 255, 255, .22) 48%, rgba(255, 255, 255, .06) 56%, transparent 72%);
        transition: transform .95s var(--motion-ease);
    }
    .feature-card:hover::before { transform: translateX(120%); }
}

/* On paper, everything where it belongs. */
@media print {
    html.motion-on [data-piece], html.motion-on [data-piece] * { opacity: 1 !important; transform: none !important; }
}

/* Asked for less motion: nothing waits, nothing moves. Last, so it wins. */
@media (prefers-reduced-motion: reduce) {
    html.motion .hero h1:not([data-words]) { opacity: 1; animation: none; }
    [data-words].is-words-pending .mw > span, [data-words].is-words-in .mw > span { transform: none; transition: none; }
    .hero h1.is-words-pending ~ *, .hero h1.is-words-in ~ * { opacity: 1; transform: none; transition: none; }
    html.motion-on [data-piece="block"], html.motion-on [data-piece="carousel"] [data-carousel-item], html.motion-on [data-piece="words"] .mw > span { opacity: 1; transform: none; transition: none; }
    html.motion-on .plan-preview > [data-piece] { opacity: 1; transform: none; transition: none; }
    html.motion:not(.motion-on) .platform-tiles > li { opacity: 1; animation: none; }
    .platform-tiles.is-loop { animation: none; }
    .hero.is-pinned { position: relative; }
    .hero.is-pinned > *, .hero.is-pinned .mw > span { opacity: 1; transform: none; transition: none; }
    .hero::before { opacity: .8; animation: none; }
    .hero-art > * { animation: none; }
    .hero .button-primary::after, .cta-band .button-primary::after, .final-cta .button-primary::after, .plan.is-highlight .button::after { animation: none; }
    .cta-band::before, .cta-band::after, .final-cta::before, .final-cta::after { animation: none; }
    .plan.is-highlight::before, .plan-mini.is-highlight::before { animation: none; }
    .platform-tile .platform-mark, .platform-tile:hover .platform-mark { transform: none; transition: none; }
    .faq-item > summary, .faq-item > summary:hover { transform: none; transition: none; }
    .faq-item::details-content, .plan-details::details-content { transition: none; }
    .feature-card, html.motion-on [data-piece="carousel"] .feature-card[data-carousel-item], .feature-track:has(.feature-card:hover) .feature-card, .feature-track:has(.feature-card:hover) .feature-card:hover { scale: none; transition: none; }
    .feature-card::before, .feature-card:hover::before { transform: translateX(-120%); transition: none; }
}
