/* TheFlowState.Life · the opening (own file). A living cosmos video behind the hero, the gold signature painted
   letter by letter, then the words. Plain notes: INTRO-NOTES.md. Code: js/intro.js.
   html.intro-on   = the opening is playing (set before first paint by the small script in <head>)
   html.intro-calm = reduced motion: no painting, a simple fade
   html.cosmos-still = poster only (data saver, or the phone refused to autoplay) */

/* ---------- the cosmos layer ---------- */
.cosmos{position:absolute;inset:0;z-index:0;pointer-events:none;overflow:hidden;background:var(--space);
  opacity:var(--co,1);
  /* soft edges all round, longest fade at the bottom so it melts into the page: no box, no hard line */
  -webkit-mask:radial-gradient(130% 92% at 50% 36%,#000 52%,rgba(0,0,0,.72) 70%,transparent 100%);
          mask:radial-gradient(130% 92% at 50% 36%,#000 52%,rgba(0,0,0,.72) 70%,transparent 100%)}
html.gl .cosmos{position:fixed;height:100vh;height:100lvh}
html:not(.gl) #hero > .ov{position:relative;z-index:2}
.cosmos__in,.cosmos__in > *{position:absolute;inset:0;width:100%;height:100%}
.cosmos__poster{background:var(--space) url(../assets/intro/cosmos-desktop-poster.webp) center/cover no-repeat}
.cosmos__vid{object-fit:cover;opacity:0;transition:opacity 1.2s ease}
.cosmos.is-playing .cosmos__vid{opacity:1}
@media (max-aspect-ratio:1/1){.cosmos__poster{background-image:url(../assets/intro/cosmos-phone-poster.webp)}}
/* a gentle vignette so the corners sink into the dark of the page */
.cosmos__vig{background:radial-gradient(120% 85% at 50% 42%,transparent 55%,rgba(5,6,14,.55) 100%),
  linear-gradient(rgba(6,6,14,.35),rgba(6,6,14,0) 18%)}
.cosmos__sky{display:block}

/* ---------- living nebulae: soft clouds that turn, breathe and glow (transform and opacity only) ---------- */
.cosmos__neb i{position:absolute;display:block;width:62vmax;height:62vmax;margin:-31vmax 0 0 -31vmax;background:center/contain no-repeat;
  mix-blend-mode:screen;opacity:0;will-change:transform,opacity}
.cosmos__neb .n1{left:12%;top:74%;background-image:url(../assets/img/neb-violet.webp);animation:nebA 26s ease-in-out infinite alternate,nebP1 11s ease-in-out infinite}
.cosmos__neb .n2{left:86%;top:24%;background-image:url(../assets/img/neb-magenta.webp);animation:nebB 30s ease-in-out infinite alternate,nebP2 13s ease-in-out infinite}
.cosmos__neb .n3{left:84%;top:82%;width:44vmax;height:44vmax;margin:-22vmax 0 0 -22vmax;background-image:url(../assets/img/neb-gold.webp);animation:nebA 34s ease-in-out infinite alternate-reverse,nebP3 9s ease-in-out infinite}
.cosmos__neb .n4{left:14%;top:16%;width:40vmax;height:40vmax;margin:-20vmax 0 0 -20vmax;background-image:url(../assets/img/neb-blue.webp);animation:nebB 28s ease-in-out infinite alternate-reverse,nebP4 15s ease-in-out infinite}
/* gold-lit glows that bloom and fade inside the clouds */
.cosmos__neb .g1,.cosmos__neb .g2,.cosmos__neb .g3{width:34vmax;height:34vmax;margin:-17vmax 0 0 -17vmax;mix-blend-mode:screen;
  background:radial-gradient(closest-side,rgba(var(--gold-lit-rgb),.34),rgba(var(--gold-lit-rgb),.1) 45%,rgba(var(--gold-lit-rgb),0) 100%)}
.cosmos__neb .g1{left:20%;top:70%;animation:glow 9s ease-in-out 1s infinite}
.cosmos__neb .g2{left:80%;top:30%;animation:glow 12s ease-in-out 4s infinite}
.cosmos__neb .g3{left:78%;top:84%;width:24vmax;height:24vmax;margin:-12vmax 0 0 -12vmax;animation:glow 10s ease-in-out 7s infinite}
@keyframes nebA{from{transform:rotate(-6deg) scale(1)}to{transform:rotate(9deg) scale(1.14) translate(2%,-2%)}}
@keyframes nebB{from{transform:rotate(5deg) scale(1.08)}to{transform:rotate(-10deg) scale(.96) translate(-2%,2%)}}
@keyframes nebP1{0%,100%{opacity:.26}50%{opacity:.52}}
@keyframes nebP2{0%,100%{opacity:.22}50%{opacity:.46}}
@keyframes nebP3{0%,100%{opacity:.16}50%{opacity:.42}}
@keyframes nebP4{0%,100%{opacity:.08}50%{opacity:.2}}
@keyframes glow{0%,100%{opacity:0;transform:scale(.8)}45%{opacity:.9;transform:scale(1.05)}70%{opacity:.35}}
@media (max-width:767px){.cosmos__neb .n4,.cosmos__neb .g3{display:none}.cosmos__neb i{width:80vmax;height:80vmax;margin:-40vmax 0 0 -40vmax}}
html.cosmos-still .cosmos__neb i,html.intro-calm .cosmos__neb i{animation-play-state:paused}
html.cosmos-paused .cosmos__neb i{animation-play-state:paused}
@media (prefers-reduced-motion:reduce){.cosmos__neb i{animation:none!important;opacity:.28}.cosmos__neb .g1,.cosmos__neb .g2,.cosmos__neb .g3{opacity:0}}

/* the cosmos arrives: from dark into a slow settle (poster is there from the first frame) */
html.intro-on:not(.intro-calm) .cosmos__in{animation:cosmosIn 2.4s cubic-bezier(.25,.6,.2,1) both}
@keyframes cosmosIn{from{opacity:.3;transform:scale(1.07)}to{opacity:1;transform:none}}

/* ---------- the hero: no plate, the signature sits on the living sky ---------- */
.hero{isolation:isolate}
.hero .hero__lockup{position:relative;background:none;border:0;box-shadow:none;border-radius:0;padding:0}
.hero .hero__sig{display:block;width:clamp(260px,min(44vw,40vh),760px);height:auto;max-width:none;overflow:visible;
  filter:saturate(1.12) brightness(1.03)}   /* matches the raster gold to the lit gold family */
/* a faint gold light that settles behind the finished signature (soft, no edge) */
.hero .hero__lockup::before{content:"";position:absolute;left:50%;top:44%;width:150%;aspect-ratio:1.25;transform:translate(-50%,-50%);z-index:-1;pointer-events:none;
  background:radial-gradient(closest-side,rgba(var(--gold-lit-rgb),.13),rgba(var(--gold-lit-rgb),.05) 48%,rgba(var(--gold-lit-rgb),0) 100%);
  opacity:1;transition:opacity 2.6s ease}
/* the haze behind the words: a touch stronger now that a moving picture sits behind them */
.hero::before{background:radial-gradient(closest-side,rgba(7,7,15,.66),rgba(7,7,15,.26) 62%,transparent)}
@media (max-width:767px){
  .hero .hero__sig{width:min(78vw,40vh,420px)}
  .hero::before{top:62%;width:150vw;aspect-ratio:.9}
}

/* ---------- staging (only while the opening plays) ---------- */
html.intro-on .loader{display:none}   /* one opening only: the painted signature replaces the loading line */
html.intro-on .hero .hero__lockup::before{opacity:0}
html.intro-on .hero .hero__lockup.bloom::before{opacity:1}
html.intro-on img.hero__sig{opacity:0}
html.intro-on .hero .hero__h,html.intro-on .hero .hero__sub,
html.intro-on .hero .chip,html.intro-on .hero .hero__ctas,html.intro-on .hero .jstrip{opacity:0;transform:translateY(14px);filter:blur(5px);
  transition:opacity 1.2s cubic-bezier(.3,.6,.2,1),transform 1.5s cubic-bezier(.2,.7,.1,1),filter 1.2s ease}
html.intro-on .hero .in{opacity:1!important;transform:none!important;filter:none!important}
html.intro-on.intro-calm img.hero__sig{transition:opacity 1.6s ease}
html.intro-on.intro-calm img.hero__sig.in{opacity:1}
html.intro-calm .hero .hero__h,html.intro-calm .hero .hero__sub,
html.intro-calm .hero .chip,html.intro-calm .hero .hero__ctas,html.intro-calm .hero .jstrip{transform:none;filter:none}
/* replay from the header signature: the words go at once (no fade-out), then the opening plays again */
html.intro-replay .hero *,html.intro-replay .hero__lockup::before{transition:none!important}
/* skipped: everything settles quickly */
html.intro-skip .hero *{transition-duration:.45s!important;transition-delay:0s!important}

/* the painted signature (built by js/intro.js from the raster and a hand-traced set of pen paths) */
.hero__sig--paint .tip{mix-blend-mode:screen}
/* Hero v19: the signature first signs across the whole screen, then zooms back to its place above the headline.
   js/intro.js scales the real hero signature with a transform (no second copy) and lets it glide home. */
.hero__sig--paint{transform-origin:50% 50%;position:relative;z-index:1}
html.intro-on:not(.intro-calm) .hero__sig--paint{will-change:transform}

/* ---------- Hero v19 (Bryan): deeper, richer nebulae ----------
   The clouds use the re-graded pictures (*-deep.webp, made by _src/grade_nebulae.py; the originals are untouched):
   lower brightness, squeezed whites, darker voids, richer colour pulled toward indigo night and burnished gold.
   The cosmos film is graded here with a filter (not re-encoded). The gold glows are a touch lower. */
.cosmos__poster{background-image:url(../assets/intro/cosmos-desktop-poster-deep.webp)}
@media (max-aspect-ratio:1/1){.cosmos__poster{background-image:url(../assets/intro/cosmos-phone-poster-deep.webp)}}
.cosmos__vid{filter:brightness(.8) saturate(1.22) contrast(1.08)}
.cosmos__neb .n1{background-image:url(../assets/img/neb-violet-deep.webp)}
.cosmos__neb .n2{background-image:url(../assets/img/neb-magenta-deep.webp)}
.cosmos__neb .n3{background-image:url(../assets/img/neb-gold-deep.webp)}
.cosmos__neb .n4{background-image:url(../assets/img/neb-blue-deep.webp)}
.cosmos__neb .g1,.cosmos__neb .g2,.cosmos__neb .g3{background:radial-gradient(closest-side,rgba(var(--gold-lit-rgb),.24),rgba(var(--gold-lit-rgb),.07) 45%,rgba(var(--gold-lit-rgb),0) 100%)}
/* the page backdrop behind the still page and the 3D canvas: the deeper sky too */
html.static body::before,html.gl body::before{background-image:url(../assets/img/space-1280-deep.webp)}
@media (min-width:1300px){html.static body::before,html.gl body::before{background-image:url(../assets/img/space-deep.webp)}}
