/* ==========================================================================
   MULTIVERSE SOULS: 3D / MOTION FOUNDATION
   Everything here is an enhancement. The page reads fully without it.
   html.fx is added by engine.js only when ALL are true: width >= 900px,
   prefers-reduced-motion is not set, data-saver is off, device memory is not tiny.
   Without html.fx you get the calm static version: stacked, still, fully readable.
   Only transform and opacity are animated. No WebGL, no canvas, no images.
   ========================================================================== */

/* ---------- A. Depth layers (hero and page heroes) ----------
   engine.js writes --dp (scroll 0..1), --dx / --dy (pointer -1..1) on [data-depth].
   Each child declares its own depth with --z (px of travel). */
[data-depth] > [style*="--z"]{will-change:auto}
.fx [data-depth] > [style*="--z"]{
  translate:calc(var(--dx,0) * var(--z) * -.6px) calc(var(--dp,0) * var(--z) * -1px + var(--dy,0) * var(--z) * -.4px);
  will-change:translate}

/* Thin sheets behind the hero: two quiet planes that give the opening a sense of depth. */
.sheet-depth{position:absolute;inset:0;z-index:0;pointer-events:none;overflow:hidden}
.sheet-depth i{position:absolute;display:block;border:1px solid rgba(121,186,208,.26);
  background:linear-gradient(150deg,rgba(22,136,184,.16),rgba(22,136,184,.02) 55%,transparent)}
.sheet-depth i:nth-child(1){right:-8%;top:10%;width:46%;height:74%;transform:perspective(1400px) rotateY(-24deg) rotateZ(1.2deg)}
.sheet-depth i:nth-child(2){right:6%;top:18%;width:38%;height:62%;border-color:rgba(121,186,208,.4);transform:perspective(1400px) rotateY(-16deg) rotateZ(-1deg)}
.sheet-depth i:nth-child(3){right:20%;top:26%;width:26%;height:46%;border-color:rgba(247,192,52,.45);
  background:radial-gradient(70% 70% at 60% 80%,rgba(247,192,52,.22),transparent 70%);transform:perspective(1400px) rotateY(-8deg)}
@media (max-width:899px){.sheet-depth i:nth-child(1){display:none}.sheet-depth i:nth-child(2){right:-14%;width:60%}.sheet-depth i:nth-child(3){right:2%;width:40%}}

/* ---------- B. Section transition: the depth edge ----------
   A short band where hairlines slowly open apart as it arrives. Used rarely. */
.depth-edge{position:relative;height:clamp(5rem,14vh,9rem);overflow:hidden;pointer-events:none}
.depth-edge.light-to-night{background:linear-gradient(to bottom,var(--ivory),#B8CFDB 38%,var(--ocean-deep) 78%,var(--cosmic))}
.depth-edge.night-to-light{background:linear-gradient(to bottom,var(--cosmic),var(--ocean-depth) 30%,var(--sky) 66%,var(--white))}
.depth-edge i{position:absolute;left:0;right:0;top:50%;height:1px;background:linear-gradient(90deg,transparent,rgba(247,192,52,.8) 30%,rgba(247,192,52,.8) 70%,transparent);opacity:.55}
.fx .depth-edge i:nth-child(1){transform:translateY(calc((var(--p,0) - .5) * -34px))}
.fx .depth-edge i:nth-child(2){transform:translateY(0);opacity:.8}
.fx .depth-edge i:nth-child(3){transform:translateY(calc((var(--p,0) - .5) * 34px))}
html:not(.fx) .depth-edge i:nth-child(1){transform:translateY(-8px)}
html:not(.fx) .depth-edge i:nth-child(3){transform:translateY(8px)}

/* ---------- C. The Multiverse moment ----------
   Static version (default): stacked copy, a still composition of layered sheets.
   Pinned 3D version (html.fx): the camera moves through six planes while the
   viewer scrolls. surface > deeper layer > another possibility > awareness. */
.mv{position:relative;overflow:clip;
  background:radial-gradient(70% 70% at 78% 50%,rgba(22,136,184,.32),transparent 70%),linear-gradient(180deg,var(--cosmic),var(--ocean-deep))}
.mv-grid{display:grid;gap:var(--sp-8);align-items:center;padding-block:var(--sec-y)}
.mv-copy h2{margin-bottom:var(--sp-6);max-width:14ch}
.mv-line{font-family:var(--font-ref);font-style:italic;font-size:var(--t-ref-m);line-height:1.22;letter-spacing:-.012em;max-width:26ch;color:#fff;margin:0 0 var(--sp-4)}
.mv-line:last-of-type{color:var(--gold)}
.mv-copy .tlink{display:inline-block;margin-top:var(--sp-4)}
.mv-stage{position:relative;aspect-ratio:1/1;max-height:30rem;width:100%;margin-inline:auto}
.mv-world{position:absolute;inset:0}
.mv-plane{position:absolute;inset:10%;border:1px solid rgba(121,186,208,calc(.85 - var(--i) * .1));
  background:linear-gradient(135deg,rgba(22,136,184,.2),rgba(22,136,184,0) 64%);
  transform:translate(calc(var(--i) * 11px),calc(var(--i) * -11px))}
.mv-plane:nth-child(6){border-color:rgba(247,192,52,.95);
  background:radial-gradient(circle at 66% 80%,rgba(247,192,52,.4),rgba(22,136,184,.14) 55%,transparent 84%);box-shadow:0 0 60px rgba(247,192,52,.14)}
.mv-glow,.mv-rail,.mv-beam,.mv-haze{display:none}
@media (min-width:1080px){.mv-grid{grid-template-columns:5fr 6fr;gap:var(--sp-9)}}

/* Calm entrance for the stacked version: opacity only. */
@media (prefers-reduced-motion:no-preference){
  .js:not(.fx) .mv-line{opacity:0;transform:translateY(10px);transition:opacity 1.1s var(--ease),transform 1.1s var(--ease)}
  .js:not(.fx) .mv.is-in .mv-line{opacity:1;transform:none}
  .js:not(.fx) .mv.is-in .mv-line:nth-of-type(2){transition-delay:.35s}
  .js:not(.fx) .mv.is-in .mv-line:nth-of-type(3){transition-delay:.7s}
}

/* Pinned 3D */
.fx .mv-track{height:400svh}
.fx .mv-stick{position:sticky;top:0;height:100svh;overflow:hidden}
.fx .mv-grid{position:absolute;inset:0;max-width:none;display:flex;align-items:center;padding:calc(var(--hdr-h) + 1rem) var(--gutter) 4rem}
.fx .mv-stage{position:absolute;inset:0;z-index:1;max-height:none;aspect-ratio:auto;perspective:1300px;perspective-origin:66% 40%;overflow:hidden}
/* The world is a stack of luminous strata. The camera descends and pushes forward through them.
   Each stratum lies flat (rotateX 90) so it reads as a horizon of light, never as a card. */
.fx .mv-world{position:absolute;inset:0;transform-style:preserve-3d;will-change:transform}
.fx .mv-plane{position:absolute;left:50%;top:50%;width:2400px;height:1900px;margin:-950px 0 0 -1200px;transform-style:preserve-3d;backface-visibility:visible;will-change:transform,opacity;border:0;
  -webkit-mask-image:radial-gradient(closest-side,#000 38%,rgba(0,0,0,.55) 66%,transparent 100%);mask-image:radial-gradient(closest-side,#000 38%,rgba(0,0,0,.55) 66%,transparent 100%);
  background:
    radial-gradient(60% 5% at 50% 30%,rgba(214,236,246,.42),transparent 70%),
    radial-gradient(70% 60% at 50% 55%,rgba(121,186,208,.3),rgba(22,136,184,.15) 55%,transparent 82%)}
.fx .mv-plane:nth-child(1){background:
    radial-gradient(60% 4% at 50% 30%,rgba(230,244,250,.6),transparent 70%),
    repeating-radial-gradient(ellipse at 50% 58%,transparent 0 46px,rgba(214,236,246,.07) 47px 48px),
    radial-gradient(70% 60% at 50% 55%,rgba(121,186,208,.22),rgba(22,136,184,.08) 55%,transparent 82%)}
.fx .mv-plane:nth-child(3){background:
    radial-gradient(60% 5% at 50% 30%,rgba(190,225,240,.5),transparent 70%),
    radial-gradient(70% 60% at 42% 55%,rgba(22,136,184,.26),rgba(19,75,111,.1) 58%,transparent 82%)}
.fx .mv-plane:nth-child(4){background:
    radial-gradient(60% 5% at 50% 30%,rgba(247,226,170,.42),transparent 70%),
    radial-gradient(70% 60% at 58% 55%,rgba(121,186,208,.2),rgba(247,192,52,.07) 60%,transparent 82%)}
.fx .mv-plane:nth-child(5){background:
    radial-gradient(60% 6% at 50% 30%,rgba(247,214,120,.6),transparent 70%),
    radial-gradient(60% 55% at 50% 55%,rgba(247,192,52,.22),rgba(22,136,184,.08) 62%,transparent 84%)}
.fx .mv-plane:nth-child(6){background:
    radial-gradient(60% 7% at 50% 30%,rgba(255,236,170,.8),transparent 72%),
    radial-gradient(52% 50% at 50% 52%,rgba(247,192,52,.5),rgba(247,192,52,.14) 50%,transparent 80%)}
/* ---------- Multiverse strata, refined: each layer has a dark body (so layers occlude and separate), a fine grain whose
   lines converge with distance (so depth is readable), and a lit rim. Light colour warms from sky to gold. ---------- */
.fx .mv-plane:nth-child(n){
  --rim:rgba(214,236,246,.5);--grain:rgba(190,222,238,.13);--grain2:rgba(190,222,238,.08);--tint:rgba(22,136,184,.30);--base:.66;
  background:
    radial-gradient(62% 4.5% at 50% 30%,var(--rim),transparent 72%),
    repeating-linear-gradient(180deg,transparent 0 37px,var(--grain) 38px 39px),
    repeating-linear-gradient(180deg,transparent 0 113px,var(--grain2) 114px 117px),
    radial-gradient(72% 62% at 50% 55%,var(--tint),transparent 84%),
    radial-gradient(76% 66% at 50% 55%,rgba(4,20,38,var(--base)),rgba(4,20,38,calc(var(--base) * .45)) 58%,transparent 86%)}
.fx .mv-plane:nth-child(1){--rim:rgba(230,244,250,.7);--tint:rgba(121,186,208,.26)}
.fx .mv-plane:nth-child(2){--tint:rgba(22,136,184,.34)}
.fx .mv-plane:nth-child(3){--rim:rgba(190,225,240,.55);--tint:rgba(19,75,111,.5)}
.fx .mv-plane:nth-child(4){--rim:rgba(247,226,170,.5);--grain:rgba(247,226,170,.10);--grain2:rgba(247,226,170,.06);--tint:rgba(121,186,208,.22)}
.fx .mv-plane:nth-child(5){--rim:rgba(247,214,120,.7);--grain:rgba(247,214,120,.14);--grain2:rgba(247,214,120,.08);--tint:rgba(247,192,52,.2);--base:.55}
.fx .mv-plane:nth-child(6){--rim:rgba(255,236,170,.9);--grain:rgba(255,226,140,.2);--grain2:rgba(255,226,140,.1);--tint:rgba(247,192,52,.5);--base:.3}
.fx .mv-glow{display:block;position:absolute;inset:0;z-index:0;pointer-events:none;opacity:var(--glow,0);
  background:radial-gradient(50% 38% at 66% 82%,rgba(247,192,52,.5),rgba(247,192,52,.12) 52%,transparent 76%)}
.fx .mv-beam{display:block;position:absolute;left:46%;width:40%;bottom:0;height:78%;z-index:0;pointer-events:none;opacity:var(--glow,0);
  background:linear-gradient(to top,rgba(247,214,130,.34),rgba(247,214,130,.08) 55%,transparent);
  -webkit-mask-image:linear-gradient(90deg,transparent,#000 35%,#000 65%,transparent);mask-image:linear-gradient(90deg,transparent,#000 35%,#000 65%,transparent)}
.fx .mv-haze{display:block;position:absolute;inset:0;z-index:0;pointer-events:none;
  background:linear-gradient(to bottom,rgba(7,30,52,.55),transparent 28%,transparent 62%,rgba(22,136,184,.22))}
.fx .mv-shade{position:absolute;inset:0;z-index:2;pointer-events:none;background:linear-gradient(90deg,var(--cosmic) 0%,rgba(7,30,52,.88) 24%,rgba(7,30,52,0) 52%)}
.fx .mv-copy{width:min(31rem,38vw);position:relative;z-index:4}
.fx .mv-lines{position:relative;min-height:9.5rem}
.fx .mv-line{position:absolute;left:0;top:0;opacity:0;transform:translateY(14px);transition:opacity .8s var(--ease),transform .8s var(--ease);margin:0}
.fx .mv-line.is-on{opacity:1;transform:none}
.fx .mv-copy h2{margin-bottom:var(--sp-5)}
.fx .mv-rail{display:flex;gap:.55rem;position:absolute;left:var(--gutter);bottom:2.2rem;z-index:4}
.fx .mv-rail i{display:block;width:2.1rem;height:3px;background:rgba(197,219,230,.35);transition:background .6s var(--ease)}
.fx .mv-rail i.is-on{background:var(--gold)}
@media (min-width:1080px){.fx .mv-grid{grid-template-columns:none}.fx .mv-copy{width:min(32rem,36vw)}}

/* ---------- D. Calm scroll states for other moments ---------- */
.fx #m2 p{opacity:calc(.2 + .8 * var(--p,0))}
.fx #m4{height:380svh}
.fx #m4 .pin{position:sticky;top:0;height:100svh;display:grid;align-content:center;padding-block:0}
.fx #m4 .step{opacity:.22;transition:opacity var(--dur-slow) var(--ease)}
.fx #m4 .step.is-active{opacity:1}
.fx #m4 .step.is-past{opacity:.5}

/* ---------- E. Reduced motion: the engine never starts. Belt and braces: ---------- */
@media (prefers-reduced-motion:reduce){
  .mv-line,.mv-plane,.mv-world{transition:none !important;animation:none !important;transform:none}
  [data-depth] > [style*="--z"]{translate:none !important}
  .mv-plane{transform:translate(calc(var(--i) * 11px),calc(var(--i) * -11px))}
}

/* Hero atmosphere: one soft band of light that drifts at its own depth, behind the photograph. */
.hero-haze{position:absolute;inset:0;z-index:0;pointer-events:none}
.hero-haze i{position:absolute;left:-10%;right:-10%;bottom:10%;height:55%;display:block;
  background:radial-gradient(55% 55% at 72% 62%,rgba(22,136,184,.42),transparent 72%),radial-gradient(40% 30% at 30% 85%,rgba(247,192,52,.12),transparent 70%)}


/* Phase 3: below 900px the Multiverse moment is text only. The framed planes and the empty stage are removed, so no gap is left. */
@media (max-width:899px){
  .mv-stage{display:none}
  .mv-grid{padding-block:var(--sec-y)}
}
