/* ==========================================================================
   Rall Motion Kit  (css/motion.css)  v1.0
   Reusable, dependency-free motion + layout primitives. Pair with js/motion.js.

   Load order: main.css, components.css, animations.css, responsive.css, motion.css
   (motion.css must come LAST so it wins over responsive.css heading sizes).

   Contract
   --------
   - Everything that hides content is gated behind `html.mo-js` (set by an inline
     <head> script). No JS / failed JS / crawlers => all content stays visible.
   - Hidden "start" states only exist inside `prefers-reduced-motion: no-preference`.
   - Reveal uses the individual transform properties (translate / scale / rotate),
     interactive effects (tilt, magnetic, parallax) use `transform`. That keeps
     the two layers from fighting each other on the same element.
   - Only compositor-friendly properties are animated (opacity, transform,
     clip-path, filter on small elements).

   Public attributes (see js/motion.js header for the full API):
     data-reveal="up|down|left|right|scale|fade|blur|mask|mask-x"
     data-delay="ms"            data-stagger="ms" (on a parent)
     data-split="words|chars"   data-scrub-text     data-count / data-mo-count
     data-parallax="0.12"       data-tilt="6"       data-spotlight
     data-magnetic="0.35"       data-marquee="60"   data-draw="in|scrub"
     data-accordion="single"    data-mo-pause
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */
:root {
    --mo-ease: cubic-bezier(0.16, 1, 0.3, 1);
    /* expo-out: fast start, long soft landing */
    --mo-ease-io: cubic-bezier(0.65, 0, 0.35, 1);
    --mo-ease-back: cubic-bezier(0.34, 1.56, 0.64, 1);
    --mo-dur: 1.05s;
    --mo-header: 92px;
    /* real value measured by motion.js */
    --mo-ink: #0b1220;
    --mo-navy: #0f1829;
    --mo-navy-2: #1a2744;
    --mo-navy-3: #2d3d5c;
    --mo-gold: #e6d14d;
    --mo-gold-deep: #8a7a12;
    /* AA-contrast gold for text on light backgrounds */
    --mo-wrap: 1240px;
    --mo-gutter: clamp(1rem, 4vw, 2rem);
}

/* --------------------------------------------------------------------------
   2. Page-level fixes
   -------------------------------------------------------------------------- */
/* main.css sets overflow-x:hidden on html AND body. That makes body a scroll
   container and silently breaks position:sticky (pinned scenes). `clip` hides
   horizontal overflow without creating a scroll container. */
html:has(body.mo-page),
body.mo-page {
    overflow-x: clip;
}

body.mo-page {
    background: var(--mo-navy);
}

.mo-progress {
    position: fixed;
    inset: 0 0 auto 0;
    height: 3px;
    z-index: calc(var(--z-sticky, 200) + 5);
    background: linear-gradient(90deg, var(--mo-gold), #fff);
    transform: scaleX(0);
    transform-origin: 0 50%;
    pointer-events: none;
    will-change: transform;
}

/* --------------------------------------------------------------------------
   3. Layout primitives
   -------------------------------------------------------------------------- */
.mo-wrap {
    width: min(var(--mo-wrap), 100% - 2 * var(--mo-gutter));
    margin-inline: auto;
}

.mo-section {
    position: relative;
    padding-block: clamp(4.5rem, 9vw, 8.5rem);
}

.mo-light {
    background: #fff;
    color: var(--text-secondary);
}

.mo-soft {
    background: linear-gradient(180deg, #f6f8fb 0%, #eef2f8 100%);
    color: var(--text-secondary);
}

.mo-dark {
    background: var(--mo-navy);
    color: rgba(255, 255, 255, 0.78);
}

.mo-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0 0 1.1rem;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--primary-light);
}

.mo-eyebrow::before {
    content: "";
    width: 2.2rem;
    height: 2px;
    background: var(--mo-gold);
    transform-origin: 0 50%;
}

.mo-dark .mo-eyebrow,
.mo-eyebrow--light {
    color: var(--mo-gold);
}

.mo-title {
    margin: 0;
    font-size: clamp(2rem, 4.7vw, 3.7rem);
    line-height: 1.05;
    letter-spacing: -0.028em;
    font-weight: 800;
    color: var(--primary);
}

.mo-dark .mo-title {
    color: #fff;
}

.mo-lead {
    margin: 1.4rem 0 0;
    max-width: 62ch;
    font-size: clamp(1.05rem, 1.45vw, 1.25rem);
    line-height: 1.7;
    color: inherit;
}

.mo-center {
    text-align: center;
}

.mo-center .mo-lead {
    margin-inline: auto;
}

.mo-center .mo-eyebrow {
    justify-content: center;
}

.mo-center .mo-eyebrow::after {
    content: "";
    width: 2.2rem;
    height: 2px;
    background: var(--mo-gold);
}

/* --------------------------------------------------------------------------
   4. Reveal (IntersectionObserver driven, one-shot)
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
    .mo-js [data-reveal] {
        opacity: 0;
        translate: 0 var(--mo-y, 48px);
        scale: 1;
        transition:
            opacity calc(var(--mo-dur) * 0.75) var(--mo-ease) var(--mo-delay, 0ms),
            translate var(--mo-dur) var(--mo-ease) var(--mo-delay, 0ms),
            scale var(--mo-dur) var(--mo-ease) var(--mo-delay, 0ms),
            filter var(--mo-dur) var(--mo-ease) var(--mo-delay, 0ms),
            clip-path calc(var(--mo-dur) * 1.1) var(--mo-ease-io) var(--mo-delay, 0ms);
    }

    .mo-js [data-reveal="down"] {
        translate: 0 -48px;
    }

    .mo-js [data-reveal="left"] {
        translate: -72px 0;
    }

    .mo-js [data-reveal="right"] {
        translate: 72px 0;
    }

    .mo-js [data-reveal="scale"] {
        translate: 0 24px;
        scale: 0.9;
    }

    .mo-js [data-reveal="fade"] {
        translate: none;
    }

    .mo-js [data-reveal="blur"] {
        translate: 0 28px;
        filter: blur(14px);
    }

    .mo-js [data-reveal="mask"] {
        opacity: 1;
        translate: none;
        clip-path: inset(0 0 100% 0);
    }

    .mo-js [data-reveal="mask-x"] {
        opacity: 1;
        translate: none;
        clip-path: inset(0 100% 0 0);
    }

    .mo-js [data-reveal].is-in {
        opacity: 1;
        translate: none;
        scale: 1;
        filter: none;
        clip-path: inset(0 0 0 0);
    }
}

/* --------------------------------------------------------------------------
   5. Split text (words / chars). motion.js keeps aria-label on the heading,
      the split spans are aria-hidden, the raw text stays in the HTML source.
   -------------------------------------------------------------------------- */
.mo-word {
    display: inline-block;
    vertical-align: top;
    overflow: hidden;
    padding: 0.12em 0.06em 0.22em;
    margin: -0.12em -0.06em -0.22em;
}

.mo-c {
    display: inline-block;
    transform-origin: 0 100%;
}

@media (prefers-reduced-motion: no-preference) {

    /* hide only until JS has split the text (prevents a flash of plain text) */
    .mo-js [data-split]:not(.mo-ready) {
        visibility: hidden;
    }

    .mo-js [data-split] .mo-c {
        translate: 0 118%;
        rotate: 7deg;
        opacity: 0;
        transition:
            translate 1.15s var(--mo-ease) calc(var(--mo-delay, 0ms) + var(--i, 0) * var(--mo-step, 60ms)),
            rotate 1.15s var(--mo-ease) calc(var(--mo-delay, 0ms) + var(--i, 0) * var(--mo-step, 60ms)),
            opacity 0.5s linear calc(var(--mo-delay, 0ms) + var(--i, 0) * var(--mo-step, 60ms));
    }

    .mo-js [data-split].is-in .mo-c {
        translate: 0 0;
        rotate: 0deg;
        opacity: 1;
    }
}

/* Scroll-scrubbed word highlight (Apple-style statement). --p, --i, --n are
   written by motion.js; one custom-property write per frame, no layout. */
.mo-js [data-scrub-text] .mo-sw {
    opacity: calc(0.14 + 0.86 * clamp(0, calc(var(--p, 0) * var(--n) - var(--i)), 1));
}

@media (prefers-reduced-motion: reduce) {
    .mo-js [data-scrub-text] .mo-sw {
        opacity: 1;
    }
}

/* --------------------------------------------------------------------------
   6. Buttons
   -------------------------------------------------------------------------- */
.mo-btn {
    --bg: var(--mo-gold);
    --fg: var(--mo-navy);
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.75em;
    padding: 1.02em 1.55em 1.02em 1.8em;
    border: 0;
    border-radius: 999px;
    background: var(--bg);
    color: var(--fg);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.005em;
    white-space: nowrap;
    text-decoration: none;
    isolation: isolate;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 10px 30px -10px rgba(230, 209, 77, 0.55);
    transition: box-shadow 0.5s var(--mo-ease), background-color 0.3s, color 0.3s;
}

.mo-btn::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, 0.6) 50%, transparent 70%);
    translate: -130% 0;
    transition: translate 0.9s var(--mo-ease);
}

.mo-btn:hover::before,
.mo-btn:focus-visible::before {
    translate: 130% 0;
}

.mo-btn:hover {
    box-shadow: 0 18px 40px -12px rgba(230, 209, 77, 0.7);
}

.mo-btn__icon {
    display: inline-grid;
    place-items: center;
    width: 1.7em;
    height: 1.7em;
    border-radius: 50%;
    background: rgba(15, 24, 41, 0.12);
    transition: transform 0.5s var(--mo-ease-back), background-color 0.3s;
}

.mo-btn__icon svg {
    width: 0.95em;
    height: 0.95em;
}

.mo-btn:hover .mo-btn__icon {
    transform: translateX(3px) rotate(-45deg);
    background: rgba(15, 24, 41, 0.2);
}

.mo-btn--ghost {
    --bg: transparent;
    --fg: #fff;
    box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.34);
}

.mo-btn--ghost:hover {
    background: rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.7);
}

.mo-btn--ghost .mo-btn__icon {
    background: rgba(255, 255, 255, 0.14);
}

.mo-btn--dark {
    --bg: var(--mo-navy-2);
    --fg: #fff;
    box-shadow: 0 10px 30px -12px rgba(15, 24, 41, 0.6);
}

.mo-btn--dark .mo-btn__icon {
    background: rgba(255, 255, 255, 0.14);
}

/* Inline text link with animated underline + arrow */
.mo-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
    color: var(--primary);
}

.mo-link::after {
    content: "";
    position: absolute;
    left: 0;
    right: 1.9rem;
    bottom: -4px;
    height: 2px;
    background: currentColor;
    transform: scaleX(0);
    transform-origin: 100% 50%;
    transition: transform 0.6s var(--mo-ease);
}

.mo-link:hover::after,
a:hover>.mo-link::after,
.mo-card:hover .mo-link::after {
    transform: scaleX(1);
    transform-origin: 0 50%;
}

.mo-link svg {
    width: 1.1em;
    height: 1.1em;
    transition: transform 0.5s var(--mo-ease-back);
}

.mo-link:hover svg,
.mo-card:hover .mo-link svg {
    transform: translateX(6px);
}

/* --------------------------------------------------------------------------
   7. Card with pointer spotlight (tilt applied inline by motion.js)
   -------------------------------------------------------------------------- */
.mo-card {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    border-radius: 1.6rem;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 24, 41, 0.05), 0 24px 50px -28px rgba(15, 24, 41, 0.35);
    transition: box-shadow 0.6s var(--mo-ease);
}

.mo-card::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    opacity: 0;
    background: radial-gradient(520px circle at var(--sx, 50%) var(--sy, 50%), rgba(230, 209, 77, 0.2), transparent 45%);
    transition: opacity 0.5s;
}

.mo-card:hover::after {
    opacity: 1;
}

.mo-card:hover {
    box-shadow: 0 1px 2px rgba(15, 24, 41, 0.05), 0 40px 70px -30px rgba(15, 24, 41, 0.5);
}

.mo-card--dark {
    background: linear-gradient(160deg, var(--mo-navy-2), var(--mo-navy));
    color: rgba(255, 255, 255, 0.8);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 30px 60px -30px rgba(0, 0, 0, 0.6);
}

/* stretched link: whole card is clickable through ONE anchor */
.mo-stretch::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 4;
}

/* --------------------------------------------------------------------------
   8. Marquee (JS adds .is-live; without JS / reduced motion it wraps statically)
   -------------------------------------------------------------------------- */
.mo-marquee {
    position: relative;
    overflow: hidden;
}

.mo-marquee__track {
    display: flex;
    width: max-content;
    max-width: none;
}

.mo-marquee__group {
    display: flex;
    flex: none;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.mo-marquee:not(.is-live) .mo-marquee__track {
    width: auto;
    justify-content: center;
}

.mo-marquee.is-live {
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
    mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}

.mo-marquee.is-live .mo-marquee__group {
    flex-wrap: nowrap;
}

.mo-marquee.is-live .mo-marquee__track {
    will-change: transform;
}

/* --------------------------------------------------------------------------
   9. Pinned scrollytelling scaffold
   -------------------------------------------------------------------------- */
.mo-pin {
    position: relative;
}

.mo-pin__stage {
    position: sticky;
    top: var(--mo-header);
    height: calc(100svh - var(--mo-header));
    min-height: 460px;
}

/* --------------------------------------------------------------------------
   10. FAQ accordion (native <details>; motion.js animates height)
   -------------------------------------------------------------------------- */
.mo-faq {
    display: grid;
    gap: 0.85rem;
}

.mo-faq details {
    border-radius: 1.2rem;
    background: #fff;
    border: 1px solid rgba(15, 24, 41, 0.08);
    box-shadow: 0 12px 30px -24px rgba(15, 24, 41, 0.45);
    transition: box-shadow 0.5s var(--mo-ease), border-color 0.4s, transform 0.5s var(--mo-ease);
}

.mo-faq details:hover {
    transform: translateY(-2px);
    border-color: rgba(15, 24, 41, 0.18);
}

.mo-faq details[open] {
    border-color: var(--mo-gold);
    box-shadow: 0 24px 50px -28px rgba(15, 24, 41, 0.55), 0 0 0 3px rgba(230, 209, 77, 0.22);
}

.mo-faq summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.2rem;
    padding: 1.25rem 1.5rem;
    cursor: pointer;
    list-style: none;
}

.mo-faq summary::-webkit-details-marker {
    display: none;
}

.mo-faq__q {
    margin: 0;
    font-size: clamp(1rem, 1.5vw, 1.15rem);
    line-height: 1.35;
    font-weight: 700;
    color: var(--primary);
}

.mo-faq__plus {
    position: relative;
    flex: none;
    width: 2.3rem;
    height: 2.3rem;
    border-radius: 50%;
    background: #eef2f8;
    transition: background-color 0.4s, rotate 0.6s var(--mo-ease);
}

.mo-faq__plus::before,
.mo-faq__plus::after {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: 0.9rem;
    height: 2px;
    border-radius: 2px;
    background: var(--primary);
    transition: rotate 0.5s var(--mo-ease), background-color 0.3s;
}

.mo-faq__plus::after {
    rotate: 90deg;
}

.mo-faq details[open] .mo-faq__plus {
    background: var(--mo-gold);
    rotate: 180deg;
}

.mo-faq details[open] .mo-faq__plus::after {
    rotate: 0deg;
}

.mo-faq__a {
    overflow: hidden;
}

.mo-faq__a-inner {
    padding: 0 1.5rem 1.4rem;
    max-width: 68ch;
}

.mo-faq__a-inner p {
    margin: 0;
    line-height: 1.75;
}

/* --------------------------------------------------------------------------
   11. Aurora background (pure CSS, transform-only animation)
   -------------------------------------------------------------------------- */
.mo-aurora {
    position: absolute;
    inset: -25%;
    pointer-events: none;
    background:
        radial-gradient(38% 42% at 22% 30%, rgba(230, 209, 77, 0.32), transparent 62%),
        radial-gradient(34% 46% at 80% 22%, rgba(96, 156, 255, 0.28), transparent 62%),
        radial-gradient(42% 40% at 62% 92%, rgba(45, 61, 92, 0.95), transparent 62%);
    animation: mo-aurora 22s ease-in-out infinite alternate;
}

@keyframes mo-aurora {
    0% {
        transform: translate3d(-3%, -2%, 0) rotate(0deg) scale(1);
    }

    50% {
        transform: translate3d(4%, 3%, 0) rotate(8deg) scale(1.08);
    }

    100% {
        transform: translate3d(-2%, 5%, 0) rotate(-6deg) scale(1.02);
    }
}

/* Offscreen scenes pause their CSS loops (class toggled by motion.js) */
.mo-paused,
.mo-paused *,
.mo-paused *::before,
.mo-paused *::after {
    animation-play-state: paused !important;
}

/* --------------------------------------------------------------------------
   12. Reduced motion: no loops, no parallax, everything visible
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {

    .mo-aurora,
    .mo-btn::before {
        animation: none;
        transition: none;
    }

    .mo-progress {
        display: none;
    }
}
