/* =========================================================================
   BILOOU — landing motion graphics
   Scroll-driven scenes for the landing page only. Loaded after style.css.

   The engine (landing-motion.js) writes three custom properties:

     --p    0..1 — how far a [data-scene] has travelled through the viewport
                   (or, for pinned scenes, through its own pinned distance)
     --vel  roughly -1..1 — smoothed scroll velocity, on <html>
     --sp   0..1 — whole-page progress, on <html>

   Everything in this file only *reads* those. When JavaScript is absent, or
   the visitor asked for reduced motion, <html> never gets `.lm-active` and
   the page lays out as a perfectly ordinary static document — every gated
   rule below simply never applies.
   ========================================================================= */

/* -------------------------------------------------------------------------
   1. Page progress bar
   ------------------------------------------------------------------------- */
.lm-progress {
    position: fixed;
    top: 0; left: 0;
    z-index: 200;
    width: 100%;
    height: 6px;
    background: var(--pink);
    border-bottom: 2px solid var(--ink);
    transform: scaleX(var(--sp, 0));
    transform-origin: 0 50%;
    pointer-events: none;
    opacity: 0;
}
html.lm-active .lm-progress { opacity: 1; }

/* -------------------------------------------------------------------------
   2. Hero — pinned kinetic type
   The section is taller than the screen; the inner block sticks while the
   letters scatter along --p. Without the engine it is a normal hero.
   ------------------------------------------------------------------------- */
.lm-hero {
    position: relative;
    overflow: clip;
}

html.lm-active .lm-hero {
    height: 220vh;
    height: 220svh;
}

.lm-hero__sticky {
    position: relative;
    display: grid;
    align-content: center;
    min-height: calc(100vh - 4.5rem);
    min-height: calc(100svh - 4.5rem);
    padding-block: clamp(2.5rem, 6vw, 4rem);
}

html.lm-active .lm-hero__sticky {
    position: sticky;
    top: 4.5rem;
    height: calc(100vh - 4.5rem);
    height: calc(100svh - 4.5rem);
    min-height: 0;
    overflow: clip;
}

.lm-hero__inner { position: relative; z-index: 1; }

/* Once the letters have scattered, the leftovers (eyebrow, highlight box)
   fade too, so the scene exits clean instead of leaving furniture behind. */
html.lm-active .lm-hero__inner {
    opacity: clamp(0, 1 - (var(--p, 0) - 0.72) * 4, 1);
}

/* The three-line headline ------------------------------------------------- */
.lm-hero__title {
    /* Width-driven, but capped by viewport height so the lede and buttons
       stay above the fold on short screens. */
    font-size: clamp(2.6rem, 10.5vw, 8.5rem);
    font-size: clamp(2.6rem, min(10.5vw, 15svh), 8.5rem);
    line-height: 0.94;
    letter-spacing: -0.015em;
}

.lm-line { display: block; }

.lm-line--mid { margin-block: 0.06em; }

.lm-line__hl {
    display: inline-block;
    padding: 0 0.16em;
    background: var(--yellow);
    border: var(--border);
    box-shadow: var(--sh);
    transform: rotate(-1.2deg);
}

.lm-line--out {
    color: transparent;
    -webkit-text-stroke: 3px var(--ink);
}

/* Split letters. The engine wraps each word in .lm-word and each character
   in .lm-ch carrying --dx/--dy/--dr; at --p:0 everything is at rest. */
.lm-word { display: inline-block; white-space: nowrap; }

html.lm-active .lm-ch {
    display: inline-block;
    will-change: transform;
    transform:
        translate(calc(var(--p, 0) * var(--dx, 0) * 1px),
                  calc(var(--p, 0) * var(--dy, 0) * 1px))
        rotate(calc(var(--p, 0) * var(--dr, 0) * 1deg));
}

/* Entrance: each line lands with a stagger on load. */
html.lm-active .lm-line { animation: lm-rise 0.65s var(--ease-pop) backwards; }
html.lm-active .lm-line--mid { animation-delay: 0.12s; }
html.lm-active .lm-line--end { animation-delay: 0.24s; }

@keyframes lm-rise {
    from { opacity: 0; transform: translateY(0.5em); }
    to   { opacity: 1; transform: none; }
}

/* Short copy + CTAs, fading out as the letters leave ----------------------- */
.lm-hero__foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem 1.5rem;
    margin-top: clamp(1.5rem, 3.5vw, 2.5rem);
}

html.lm-active .lm-hero__foot {
    opacity: clamp(0, 1 - (var(--p, 0) - 0.35) * 2.4, 1);
    transform: translateY(calc(var(--p, 0) * 8vh));
}

.lm-hero__lede {
    width: 100%;
    max-width: 38ch;
    font-size: clamp(1.05rem, 1rem + 0.5vw, 1.3rem);
    font-weight: 700;
}

/* Floating shapes, each on its own parallax depth -------------------------- */
.lm-hero__deco {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

.lm-shape { position: absolute; border: var(--border); }

html.lm-active .lm-shape {
    will-change: transform;
    transform:
        translateY(calc(var(--p, 0) * var(--dp, 0) * -1px))
        rotate(calc(var(--rot, 0deg) + var(--p, 0) * var(--rr, 0) * 1deg));
}

.lm-shape--brick {
    top: 16%; right: 7%;
    width: clamp(60px, 8vw, 110px);
    height: clamp(36px, 5vw, 64px);
    background: var(--pink);
    --rot: 8deg; --dp: 260; --rr: -50;
    transform: rotate(var(--rot));
}
.lm-shape--ring {
    bottom: 20%; left: 3%;
    width: clamp(64px, 8vw, 110px);
    height: clamp(64px, 8vw, 110px);
    border-width: 10px;
    border-radius: 50%;
    --dp: 150; --rr: 20;
}
.lm-shape--star {
    top: 10%; left: 26%;
    width: clamp(40px, 5vw, 70px);
    height: clamp(40px, 5vw, 70px);
    background: var(--lime);
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    border: none;
    filter: drop-shadow(3px 3px 0 var(--ink));
    --rot: -10deg; --dp: 340; --rr: 120;
    transform: rotate(var(--rot));
}
.lm-shape--cross {
    top: 58%; right: 30%;
    width: clamp(26px, 3vw, 40px);
    height: clamp(26px, 3vw, 40px);
    background: var(--purple);
    --rot: 24deg; --dp: 420; --rr: 200;
    transform: rotate(var(--rot));
}
.lm-shape--half {
    bottom: 8%; right: 16%;
    width: clamp(56px, 7vw, 96px);
    height: clamp(28px, 3.5vw, 48px);
    background: var(--cyan);
    border-radius: 999px 999px 0 0;
    --dp: 200; --rr: -30;
}
.lm-shape--dots {
    top: 6%; left: 55%;
    width: 100px; height: 52px;
    border: none;
    background-image: radial-gradient(var(--ink) 2px, transparent 2px);
    background-size: 14px 14px;
    opacity: 0.35;
    --dp: 120; --rr: 0;
}
.lm-shape--zig {
    bottom: 30%; left: 40%;
    width: 90px; height: 22px;
    border: none;
    background:
        linear-gradient(135deg, transparent 49%, var(--ink) 49% 62%, transparent 62%) 0 0 / 18px 22px repeat-x;
    opacity: 0.6;
    --dp: 300; --rr: 0;
}

/* Rotating "scroll" coin --------------------------------------------------- */
.lm-hero__cue {
    position: absolute;
    right: clamp(0.5rem, 4vw, 3rem);
    bottom: clamp(1rem, 4vh, 2.5rem);
    z-index: 2;
    display: grid;
    place-items: center;
    width: 5.5rem;
    height: 5.5rem;
    background: var(--yellow);
    border: var(--border);
    border-radius: 50%;
    box-shadow: var(--sh-sm);
    font-family: var(--font-display);
    font-size: 0.65rem;
    letter-spacing: 0.14em;
    text-align: center;
    line-height: 1.3;
}
html.lm-active .lm-hero__cue {
    transform: rotate(calc(var(--sp, 0) * 720deg));
    opacity: clamp(0, 1 - var(--p, 0) * 2.6, 1);
}
.lm-hero__cue span { display: block; font-size: 1.1rem; letter-spacing: 0; }

/* -------------------------------------------------------------------------
   3. Double marquee — opposite directions, skewed by scroll velocity
   ------------------------------------------------------------------------- */
.lm-marquee {
    overflow: clip;
    border-block: var(--border);
}

.lm-marquee__row {
    padding-block: 0.7rem;
    background: var(--ink);
    color: var(--paper);
    overflow: clip;
}
.lm-marquee__row--alt {
    background: var(--yellow);
    color: var(--ink);
    border-top: var(--border);
}

html.lm-active .lm-marquee__row {
    will-change: transform;
    transform: skewX(calc(var(--vel, 0) * -9deg));
}

.lm-marquee__track {
    display: flex;
    align-items: center;
    gap: 1.75rem;
    width: max-content;
    animation: scroll-x 26s linear infinite;
}
.lm-marquee__row--alt .lm-marquee__track {
    animation-direction: reverse;
    animation-duration: 32s;
}

.lm-marquee__item {
    font-family: var(--font-display);
    font-size: clamp(1.3rem, 3.2vw, 2.3rem);
    letter-spacing: 0.02em;
    text-transform: uppercase;
    white-space: nowrap;
}
.lm-marquee__sep { font-size: 1.2rem; color: var(--pink); }
.lm-marquee__row--alt .lm-marquee__sep { color: var(--ink); }

/* -------------------------------------------------------------------------
   4. Ghost titles — huge outlined words drifting behind section heads
   ------------------------------------------------------------------------- */
.lm-sec { overflow: clip; }

.lm-ghost {
    position: absolute;
    top: clamp(0.5rem, 2vw, 1.5rem);
    left: 0;
    z-index: 0;
    font-family: var(--font-display);
    font-size: clamp(4rem, 15vw, 11rem);
    line-height: 1;
    text-transform: uppercase;
    white-space: nowrap;
    color: transparent;
    -webkit-text-stroke: 2px rgba(20, 18, 16, 0.14);
    pointer-events: none;
    user-select: none;
}
.section--dark .lm-ghost { -webkit-text-stroke-color: rgba(255, 248, 236, 0.14); }

html.lm-active .lm-ghost {
    will-change: transform;
    transform: translateX(calc((var(--p, 0.5) - 0.5) * -22vw));
}

.lm-sec .shell { position: relative; z-index: 1; }

/* -------------------------------------------------------------------------
   5. Template gallery — columns drifting at different speeds
   The cards keep their .card hover lift; each drift rule restates it so the
   two transforms compose instead of fighting.
   ------------------------------------------------------------------------- */
html.lm-active .lm-drift .tpl { will-change: transform; }

html.lm-active .lm-drift .tpl:nth-child(odd) {
    transform: translateY(calc((var(--p, 0.5) - 0.5) * -52px));
}
html.lm-active .lm-drift .tpl:nth-child(even) {
    transform: translateY(calc((var(--p, 0.5) - 0.5) * 44px));
}
html.lm-active .lm-drift .tpl:nth-child(odd):hover {
    transform: translate(-4px, calc((var(--p, 0.5) - 0.5) * -52px - 4px));
}
html.lm-active .lm-drift .tpl:nth-child(even):hover {
    transform: translate(-4px, calc((var(--p, 0.5) - 0.5) * 44px - 4px));
}

/* -------------------------------------------------------------------------
   6. Features — sticker wall, blurb on hover/focus
   ------------------------------------------------------------------------- */
.lm-wall {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: clamp(1rem, 2vw, 1.5rem);
}

.lm-stick {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.8rem;
    padding: 1.4rem 1.2rem;
    background: var(--paper);
    border: var(--border);
    box-shadow: var(--sh);
    overflow: clip;
    cursor: default;
}

.lm-stick:nth-child(4n + 1) { --tilt: -1.4deg; }
.lm-stick:nth-child(4n + 2) { --tilt: 1.2deg; }
.lm-stick:nth-child(4n + 3) { --tilt: -0.8deg; }
.lm-stick:nth-child(4n + 4) { --tilt: 1.6deg; }
.lm-stick { transform: rotate(var(--tilt, 0deg)); }

/* Row-by-row counter-drift while the wall crosses the screen. */
html.lm-active .lm-wall .lm-stick:nth-child(odd) {
    transform: rotate(var(--tilt, 0deg)) translateY(calc((var(--p, 0.5) - 0.5) * -30px));
}
html.lm-active .lm-wall .lm-stick:nth-child(even) {
    transform: rotate(var(--tilt, 0deg)) translateY(calc((var(--p, 0.5) - 0.5) * 24px));
}

.lm-stick__icon {
    display: grid;
    place-items: center;
    width: 2.6rem;
    height: 2.6rem;
    border: var(--border);
    box-shadow: var(--sh-sm);
    font-size: 1.25rem;
}
.lm-stick__icon--lime   { background: var(--lime); }
.lm-stick__icon--yellow { background: var(--yellow); }
.lm-stick__icon--cyan   { background: var(--cyan); }
.lm-stick__icon--pink   { background: var(--pink); }
.lm-stick__icon--orange { background: var(--orange); }
.lm-stick__icon--purple { background: var(--purple); }

.lm-stick__title {
    font-family: var(--font-display);
    font-size: 1rem;
    line-height: 1.1;
    text-transform: uppercase;
}

.lm-stick .badge { margin-top: auto; }

/* The words live under an ink layer that slides up on demand. */
.lm-stick__blurb {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: grid;
    align-content: center;
    padding: 1.2rem;
    background: var(--ink);
    color: var(--paper);
    font-size: 0.85rem;
    line-height: 1.5;
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.22s ease, transform 0.22s var(--ease-pop);
}
.lm-stick:hover .lm-stick__blurb,
.lm-stick:focus-visible .lm-stick__blurb,
.lm-stick:focus-within .lm-stick__blurb {
    opacity: 1;
    transform: none;
}

.lm-wall__hint {
    margin-top: 1.25rem;
    font-size: 0.8125rem;
    font-weight: 700;
    opacity: 0.7;
}

/* -------------------------------------------------------------------------
   7. How it works — giant numbers sliding in from alternate sides
   ------------------------------------------------------------------------- */
.lm-steps {
    display: grid;
    gap: clamp(2.5rem, 6vw, 4.5rem);
    margin: 0;
    padding: 0;
    list-style: none;
}

.lm-step {
    display: flex;
    align-items: center;
    gap: clamp(1.25rem, 4vw, 3rem);
}
.lm-step:nth-child(even) {
    flex-direction: row-reverse;
    text-align: right;
}

.lm-step__big {
    flex: none;
    font-family: var(--font-display);
    font-size: clamp(5rem, 15vw, 10.5rem);
    line-height: 0.85;
    text-shadow: 8px 8px 0 rgba(255, 248, 236, 0.12);
}
.lm-step__big--yellow { color: var(--yellow); }
.lm-step__big--cyan   { color: var(--cyan); }
.lm-step__big--pink   { color: var(--pink); }

html.lm-active .lm-step:nth-child(odd) .lm-step__big {
    transform: translateX(calc((var(--p, 0.5) - 0.5) * -120px));
}
html.lm-active .lm-step:nth-child(even) .lm-step__big {
    transform: translateX(calc((var(--p, 0.5) - 0.5) * 120px));
}

.lm-step__title { font-size: clamp(1.4rem, 3vw, 2.1rem); }

.lm-step__blurb {
    max-width: 46ch;
    margin-top: 0.6rem;
    color: rgba(255, 248, 236, 0.78);
}
.lm-step:nth-child(even) .lm-step__blurb { margin-left: auto; }

/* -------------------------------------------------------------------------
   8. Roadmap — stat cards tilting as they pass
   ------------------------------------------------------------------------- */
html.lm-active #roadmap .stat:nth-child(odd) {
    transform: rotate(calc((var(--p, 0.5) - 0.5) * 3deg));
}
html.lm-active #roadmap .stat:nth-child(even) {
    transform: rotate(calc((var(--p, 0.5) - 0.5) * -3deg));
}
html.lm-active #roadmap .stat:nth-child(odd):hover {
    transform: translate(-4px, -4px) rotate(calc((var(--p, 0.5) - 0.5) * 3deg));
}
html.lm-active #roadmap .stat:nth-child(even):hover {
    transform: translate(-4px, -4px) rotate(calc((var(--p, 0.5) - 0.5) * -3deg));
}

/* -------------------------------------------------------------------------
   9. Final CTA — striped conveyor + rolling stamp
   ------------------------------------------------------------------------- */
.lm-cta {
    background:
        repeating-linear-gradient(-45deg,
            var(--cyan) 0 34px,
            #55d4cf 34px 68px);
}

html.lm-active .lm-cta {
    background-position: calc(var(--p, 0) * 192px) 0;
}

html.lm-active .lm-cta .cta__box {
    transform: rotate(calc((var(--p, 0.5) - 0.5) * 1.6deg));
}

html.lm-active .lm-cta .cta__stamp {
    animation: none;
    transform: rotate(calc(-32deg + var(--p, 0) * 52deg));
}

/* -------------------------------------------------------------------------
   10. Responsive
   ------------------------------------------------------------------------- */
@media (max-width: 880px) {
    html.lm-active .lm-hero { height: 185vh; height: 185svh; }

    .lm-step,
    .lm-step:nth-child(even) {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        text-align: left;
    }
    .lm-step:nth-child(even) .lm-step__blurb { margin-left: 0; }

    .lm-hero__cue { display: none; }

    /* Letter scatter stays, gentler. */
    html.lm-active .lm-ch {
        transform:
            translate(calc(var(--p, 0) * var(--dx, 0) * 0.5px),
                      calc(var(--p, 0) * var(--dy, 0) * 0.5px))
            rotate(calc(var(--p, 0) * var(--dr, 0) * 0.6deg));
    }
}

/* -------------------------------------------------------------------------
   11. Preferences & print
   Reduced motion never gets .lm-active (the engine refuses to start), so
   every scroll effect above is already off; this only stills what remains.
   ------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .lm-marquee__track { animation: none; }
    .lm-line { animation: none !important; }
}

@media print {
    .lm-progress, .lm-marquee, .lm-hero__deco, .lm-hero__cue { display: none; }
    .lm-stick__blurb { position: static; opacity: 1; transform: none; background: none; color: inherit; padding: 0; }
}
