/* Shared motion kit (docs/DARK_REDESIGN_BRIEF.md, usage: docs/handoff/motion-kit.md). Owner: Site role; used by Site and Products.
   Lifted from the approved concept (docs/samples/home-dark-concept.src.html) and made generic: nothing depends on ids,
   any number of scenes / heroes per page.

   States:
   - html.motion       JS on and motion allowed: pinned scenes pin, [data-lit] starts at --v:0 and brightens.
   - no .motion        JS off or prefers-reduced-motion: scenes are plain stacked sections, --v = 1 (everything lit and visible).
   - html.motion-forced  QA aid: URL hash #rest / #mid / #end freezes every scene at p = 0 / .5 / 1 without pinning.
   Only transform, opacity, clip-path and background/mask position animate. */

/* ---------------- Pinned scenes: <section class="scrub" data-scrub><div class="stage">... ---------------- */
.scrub { position: relative; --p: 0; --a: 0; --b: 0; --k: 0; }
.motion .scrub { height: calc(var(--stage-h) + var(--travel, 1100px)); }
.motion-forced .scrub { --travel: 0px; }
.scrub > .stage { position: relative; overflow: hidden; }
.motion .scrub > .stage { position: sticky; top: env(safe-area-inset-top, 0px); height: var(--stage-h); }

/* ---------------- Statements: .lit[data-lit] (words light up in order) ---------------- */
[data-lit] { --v: 1; }
.motion [data-lit] { --v: 0; }
.lit { font: 600 var(--text-statement)/1.18 var(--font-display); letter-spacing: -.02em; max-width: 22ch; }
.lit.wide { max-width: 26ch; }
.lit span { opacity: clamp(.3, calc(var(--v) * var(--n, 1) * 1.3 - var(--i, 0)), 1); }
.lit .hi { color: var(--mint); }

/* ---------------- Statement + moving picture: .duo / .duo.flip, .txt, .vis ---------------- */
.duo { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(28px, 6vw, 80px); align-items: center; }
.duo.flip .txt { order: 2; }
.duo + .duo { margin-top: clamp(70px, 10vw, 140px); }
.vis { position: relative; perspective: 1300px; }
.vis::before { content: ""; position: absolute; inset: 8% 4%; background: radial-gradient(50% 50% at 50% 50%, rgba(0, 216, 193, .34), rgba(0, 216, 193, 0) 70%); filter: blur(30px); opacity: calc(.2 + var(--v, 1) * .8); pointer-events: none; }
.shot { position: relative; border-radius: 16px; background: #fff; padding: 6px; box-shadow: var(--shot-shadow); }
.shot img, .win img { display: block; width: 100%; height: auto; border-radius: 10px; }
@keyframes kit-bob { 50% { translate: 0 -12px; } }

/* 1. .vis.tilt: picture tilts flat; optional .chip icons fly in and keep floating (style="--x;--y;--dx;--dy;--t").
   Moves a .shot, or a CSS-drawn product device (.p-dev, Products) placed directly in the .tilt. */
.tilt .shot, .tilt > .p-dev { transform: rotateY(calc(-26deg + var(--v) * 20deg)) rotateX(calc(12deg - var(--v) * 9deg)) translateY(calc((1 - var(--v)) * 70px)); opacity: calc(.25 + var(--v) * .75); transform-origin: 60% 50%; }
.chip { position: absolute; left: var(--x); top: var(--y); width: clamp(46px, 5.4vw, 68px); aspect-ratio: 1; border-radius: 18px; background: #fff; padding: 9px; box-shadow: 0 0 30px rgba(0, 216, 193, .45), 0 12px 24px rgba(0, 0, 0, .5); transform: translate(calc((1 - var(--v)) * var(--dx, 0px)), calc((1 - var(--v)) * var(--dy, 0px))) scale(calc(.4 + var(--v) * .6)); opacity: var(--v); animation: kit-bob 5s ease-in-out var(--t, 0s) infinite; }
.chip img { display: block; width: 100%; height: 100%; object-fit: contain; }

/* 2. .vis.reveal > .win > img (+ optional i.sweep): opens like a shutter, slow zoom, light sweep */
.reveal .win { position: relative; border-radius: 16px; overflow: hidden; clip-path: inset(calc((1 - var(--v)) * 30%) calc((1 - var(--v)) * 14%) round 16px); box-shadow: 0 0 0 1px var(--line); }
.reveal .win img { border-radius: 0; transform: scale(calc(1.3 - var(--v) * .3)); }
.sweep { position: absolute; inset: 0; background: linear-gradient(105deg, rgba(255, 255, 255, 0) 40%, rgba(255, 255, 255, .28) 50%, rgba(255, 255, 255, 0) 60%); background-size: 250% 100%; animation: kit-sweep 4.5s ease-in-out infinite; pointer-events: none; }
@keyframes kit-sweep { from { background-position: 130% 0; } to { background-position: -130% 0; } }

/* 3. .vis.slide > img: devices glide in and float */
.slide { overflow-x: clip; overflow-y: visible; }
.slide img { display: block; width: 112%; max-width: none; height: auto; margin-left: -6%; transform: translateX(calc((1 - var(--v)) * -22%)) rotate(calc((1 - var(--v)) * -5deg)); opacity: calc(.15 + var(--v) * .85); animation: kit-bob 6s ease-in-out infinite; position: relative; }

/* 4. .vis.orbit: icons tumble in and settle into orbits around one hub.
   <div class="vis orbit"><div class="ring r2"><span class="sat" style="--ang;--off"><span class="oc"><i><img></i></span></span>...</div>
   <div class="ring r1">...</div><div class="hub"><b></b><b></b><b></b><span><img></span></div></div> */
.orbit { aspect-ratio: 1; max-width: 480px; width: 100%; margin-inline: auto; --sc: calc(1.75 - var(--v) * .75); --amp: calc((1 - var(--v)) * 26px); }
.orbit .ring { position: absolute; border-radius: 50%; border: 1.5px dashed rgba(0, 216, 193, calc(var(--v) * .55)); animation: kit-spin var(--dur) linear infinite var(--dirn, normal); }
.orbit .r2 { inset: 4%; --dur: 26s; }
.orbit .r1 { inset: 25%; --dur: 17s; --dirn: reverse; }
@keyframes kit-spin { to { rotate: 360deg; } }
.orbit .sat { position: absolute; inset: 0; transform: rotate(calc(var(--ang) + (1 - var(--v)) * var(--off, 0deg))) scale(var(--sc)); opacity: calc(.35 + var(--v) * .65); }
.orbit .oc { position: absolute; right: 0; top: 50%; width: clamp(48px, 13%, 64px); aspect-ratio: 1; translate: 50% -50%; transform: rotate(calc(-1 * (var(--ang) + (1 - var(--v)) * var(--off, 0deg)))) scale(calc(1 / var(--sc))); }
.orbit .r1 .oc { width: clamp(46px, 24%, 60px); }
.orbit .oc i { display: block; width: 100%; height: 100%; border-radius: 30%; background: #fff; padding: 16%; box-shadow: 0 0 28px rgba(0, 216, 193, .55), 0 10px 22px rgba(0, 0, 0, .5); animation: kit-spin var(--dur) linear infinite var(--dirb, reverse), kit-juggle 1.5s ease-in-out infinite alternate; }
.orbit .r1 .oc i { --dirb: normal; }
.orbit .sat:nth-child(2) .oc i { animation-delay: 0s, -.5s; }
.orbit .sat:nth-child(3) .oc i { animation-delay: 0s, -1s; }
@keyframes kit-juggle { to { translate: 0 calc(var(--amp) * -1); } }
.orbit .oc img { display: block; width: 100%; height: 100%; object-fit: contain; }
.orbit .hub { position: absolute; inset: 37%; display: grid; place-items: center; transform: scale(calc(.55 + var(--v) * .45)); }
.orbit .hub span { position: relative; width: 100%; height: 100%; border-radius: 28%; background: #fff; padding: 17%; box-shadow: 0 0 calc(30px + var(--v) * 60px) rgba(0, 216, 193, .75), 0 16px 34px rgba(0, 0, 0, .55); }
.orbit .hub img { display: block; width: 100%; height: 100%; object-fit: contain; }
.orbit .hub b { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--mint); opacity: 0; animation: kit-ripple 3s ease-out infinite; }
.orbit .hub b:nth-child(2) { animation-delay: -1s; }
.orbit .hub b:nth-child(3) { animation-delay: -2s; }
@keyframes kit-ripple { from { transform: scale(.8); opacity: calc(var(--v) * .8); } to { transform: scale(3.4); opacity: 0; } }

/* ---------------- 3D turning screens: .deck > .c (style="--i:0..n-1"), inside a .scrub; JS sets --k (0..n-1) ----------------
   Optional companions in the same scene: .deck-big > * (giant changing title; span or a real heading) and .deck-desc > div (description), each with --i. */
.deck { position: relative; perspective: 1400px; }
.deck .c { margin: 0; border-radius: 16px; background: #fff; padding: 6px; box-shadow: 0 0 80px rgba(0, 216, 193, .28), 0 30px 60px rgba(0, 0, 0, .6); }
.deck .c img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top left; border-radius: 10px; }
.motion .deck .c { position: absolute; left: 50%; top: 50%; width: min(500px, 72vw); aspect-ratio: 640 / 420; --d: calc(var(--i) - var(--k)); --ad: max(var(--d), calc(var(--d) * -1)); transform: translate(-50%, -50%) translateX(calc(var(--d) * 58%)) translateZ(calc(var(--ad) * -220px)) rotateY(calc(var(--d) * -38deg)); z-index: calc(100 - var(--ad) * 10); opacity: clamp(.25, calc(1.5 - var(--ad) * .7), 1); }
.deck-big { position: relative; }
.deck-big > * { display: block; margin: 0; font: 700 clamp(2.1rem, 8vw, 6.4rem)/1 var(--font-display); letter-spacing: -.04em; background: linear-gradient(100deg, #fff 20%, var(--mint) 60%, var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.motion .deck-big { height: clamp(3rem, 9.6vw, 7.6rem); overflow: hidden; }
.motion .deck-big > * { position: absolute; inset: 0; display: grid; place-items: center; white-space: nowrap; opacity: clamp(0, calc(1 - max(var(--k) - var(--i), var(--i) - var(--k)) * 2), 1); transform: translateY(calc((var(--i) - var(--k)) * 70%)); }
.deck-desc > * { color: var(--soft); font-size: clamp(.92rem, 1.25vw, 1.08rem); line-height: 1.5; }
.motion .deck-desc { position: relative; }
.motion .deck-desc > * { position: absolute; inset: 0 0 auto; margin-inline: auto; max-width: 66ch; text-align: center; opacity: clamp(0, calc(1 - max(var(--k) - var(--i), var(--i) - var(--k)) * 2.4), 1); }
.motion .deck-desc > * :is(a, button) { visibility: hidden; }
/* links in a description are only reachable while that description shows (JS adds .on) */
.motion .deck-desc > .on :is(a, button) { visibility: visible; }

/* ---------------- Oversized sliding lines: .row[data-lit] > (h2|h3 or a wrapper holding one) + p ---------------- */
.row { padding-block: clamp(26px, 4vw, 46px); border-top: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr); gap: 16px 40px; align-items: center; overflow: hidden; }
.row:last-of-type { border-bottom: 1px solid var(--line); }
.row :is(h2, h3, h4) { color: var(--ink); font: 700 clamp(2rem, 6.2vw, 5rem)/1.08 var(--font-display); letter-spacing: -.035em; margin: 0; transform: translateX(calc((1 - var(--v)) * var(--dir, 1) * 14%)); opacity: calc(.25 + var(--v) * .75); }
.row:nth-child(even) :is(h2, h3, h4) { color: var(--mint); --dir: -1; }
.row > p, .row > div { color: var(--soft); font-size: clamp(1rem, 1.4vw, 1.2rem); margin: 0; }

/* ---------------- Living light: .grad > i.g1..g4 + span.trail (style="top;--c;--d;--w") ---------------- */
.grad { position: absolute; inset: 0; overflow: hidden; background: #06110f; }
.grad i { position: absolute; border-radius: 50%; filter: blur(60px); mix-blend-mode: screen; }
.grad .g1 { width: 70%; aspect-ratio: 1; left: -12%; top: -30%; background: radial-gradient(closest-side, var(--light-1), rgba(0, 216, 193, 0)); animation: kit-drift1 11s ease-in-out infinite alternate; }
.grad .g2 { width: 62%; aspect-ratio: 1; right: -10%; top: -8%; background: radial-gradient(closest-side, var(--light-2), rgba(255, 59, 78, 0)); animation: kit-drift2 13s ease-in-out infinite alternate; }
.grad .g3 { width: 55%; aspect-ratio: 1; left: 26%; bottom: -46%; background: radial-gradient(closest-side, var(--light-3), rgba(254, 186, 25, 0)); animation: kit-drift3 9s ease-in-out infinite alternate; }
.grad .g4 { width: 46%; aspect-ratio: 1; left: 30%; top: 4%; background: radial-gradient(closest-side, var(--light-4), rgba(31, 107, 255, 0)); animation: kit-drift2 15s ease-in-out infinite alternate-reverse; }
@keyframes kit-drift1 { to { transform: translate(34%, 26%) scale(1.2); } }
@keyframes kit-drift2 { to { transform: translate(-30%, 22%) scale(.85); } }
@keyframes kit-drift3 { to { transform: translate(-22%, -34%) scale(1.25); } }
.grad .trail { position: absolute; left: -20%; right: -20%; height: 3px; background: linear-gradient(90deg, rgba(255, 255, 255, 0), var(--c, #fff) 30%, #fff 50%, var(--c, #fff) 70%, rgba(255, 255, 255, 0)); background-size: 40% 100%; background-repeat: no-repeat; background-position: -70% 0; animation: kit-streak var(--d, 4s) linear var(--w, 0s) infinite; mix-blend-mode: screen; }
@keyframes kit-streak { from { background-position: -70% 0; } to { background-position: 170% 0; } }

/* SVG-mask hero: a word cut out of a dark plate, showing what is behind it (usually .grad).
   <svg class="mask-hero"><defs><mask id="UNIQUE" maskUnits="userSpaceOnUse" x="0" y="0" width="100%" height="100%">
   <rect width="100%" height="100%" fill="#fff"/><text data-zoom x="50%" y="46%" text-anchor="middle" dominant-baseline="central" fill="#000">WORD</text>
   </mask></defs><rect width="100%" height="100%" fill="#050d0b" mask="url(#UNIQUE)"/></svg>
   Inside a .scrub the JS scales [data-zoom] into one letter (data-zoom-char, default the middle one) so the scroll flies through it. */
.mask-hero { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.mask-hero text { font: 700 var(--ws, clamp(2.6rem, 12.4vw, 11rem)) var(--font-display); letter-spacing: -.03em; }

/* ---------------- Footer wordmark: .fword[data-lit] > span.fo + span.fg ---------------- */
.fword { position: relative; font: 700 clamp(4.5rem, 21vw, 19rem)/.86 var(--font-display); letter-spacing: calc(-.02em - var(--v) * .03em); text-align: center; white-space: nowrap; user-select: none; transform: translateY(calc((1 - var(--v)) * 28%)); cursor: default; }
.fword span { display: block; padding-top: .14em; } /* QA: room above the line box, or background-clip:text left the top of the i-dot unpainted */
.fword .fo { color: transparent; -webkit-text-stroke: 1px rgba(255, 255, 255, .16); }
.fword .fg { position: absolute; inset: 0; color: transparent; background: linear-gradient(90deg, #00d8c1, #1f6bff, #ff3b4e, #feba19, #00d8c1, #1f6bff, #ff3b4e); background-size: 300% 100%; -webkit-background-clip: text; background-clip: text; animation: kit-fflow 9s linear infinite, kit-fsweep 6s ease-in-out infinite alternate; -webkit-mask-image: linear-gradient(100deg, transparent 25%, #000 45%, #000 55%, transparent 75%); mask-image: linear-gradient(100deg, transparent 25%, #000 45%, #000 55%, transparent 75%); -webkit-mask-size: 260% 100%; mask-size: 260% 100%; }
.fword.live .fg { animation: kit-fflow 9s linear infinite; -webkit-mask-image: radial-gradient(circle clamp(140px, 22vw, 340px) at var(--mx, 50%) var(--my, 50%), #000 0, #000 35%, transparent 100%); mask-image: radial-gradient(circle clamp(140px, 22vw, 340px) at var(--mx, 50%) var(--my, 50%), #000 0, #000 35%, transparent 100%); -webkit-mask-size: 100% 100%; mask-size: 100% 100%; }
@keyframes kit-fflow { to { background-position: -150% 0; } }
@keyframes kit-fsweep { from { -webkit-mask-position: 100% 0; mask-position: 100% 0; } to { -webkit-mask-position: 0 0; mask-position: 0 0; } }

/* ---------------- Off-screen pause (JS adds .kit-off to animated blocks out of view) ---------------- */
.kit-off, .kit-off * { animation-play-state: paused !important; }

/* ---------------- Phones: one column, lighter living light ---------------- */
@media (max-width: 760px) {
    .duo { grid-template-columns: minmax(0, 1fr); }
    .duo.flip .txt { order: 0; }
    .vis { margin-inline: 6%; }
    .row { grid-template-columns: minmax(0, 1fr); }
    /* QA (4x CPU, 390 px): a 40px blur on three moving 400-500px blobs was the costliest thing on the phone home page.
       The blobs are radial gradients that already fade to nothing, so phones drop the blur and keep the same light. */
    .grad i { filter: none; will-change: transform; }
    /* tall narrow stages: bigger blobs so the light reaches the middle */
    .grad .g1 { width: 125%; left: -45%; top: 8%; }
    .grad .g2 { width: 115%; right: -50%; top: 24%; }
    .grad .g3 { width: 110%; left: 5%; bottom: 4%; }
    .grad .g4, .grad .trail:nth-of-type(n + 4) { display: none; }
}

/* ---------------- Reduced motion: no continuous animation, scenes are plain sections ---------------- */
@media (prefers-reduced-motion: reduce) {
    .grad i, .grad .trail, .chip, .slide img, .sweep, .orbit .ring, .orbit .oc i, .orbit .hub b { animation: none; }
    .grad .trail { opacity: .6; background-position: 50% 0; }
    .fword .fg { animation: none; -webkit-mask-image: none; mask-image: none; }
    .fword { transform: none; }
}
