/* The first screen — Worldfall.
   Place paintings tumble from above with rotation, settle into a soft constellation around a modest
   centred Fraunces headline, then fall through and away as you keep scrolling. Sticky pin + scrubbed --p. */

.hero {
  position: relative;
  --mx: 0; --my: 0;
}

/* sticky viewport that holds the constellation while the track scrolls beneath */
.wf-pin {
  position: sticky; top: 0; z-index: 2;
  display: flex; flex-direction: column;
  height: 100svh; min-height: 36rem;
  padding: 0 clamp(1.25rem, 4vw, 4.5rem);
  overflow: clip;
}
.wf-track { height: 240vh; pointer-events: none; }

/* ---- nav: always above the falling art, with a clear paper band ---- */
.site-header {
  position: relative; z-index: 8; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1.6rem 0 1rem; flex: none;
}
.site-header::before {
  content: ""; position: absolute; left: 50%; top: -.4rem; bottom: -.2rem; width: 100vw;
  translate: -50% 0; z-index: -1; pointer-events: none;
  background: linear-gradient(to bottom, var(--paper) 0%, var(--paper) 72%, rgba(245, 244, 238, .85) 88%, rgba(245, 244, 238, 0) 100%);
}
.logo {
  font-family: var(--display); font-weight: 500; font-size: 1.65rem; letter-spacing: -.04em;
  color: var(--purple); text-decoration: none; line-height: 1; font-variation-settings: "SOFT" 50, "WONK" 0.4;
}
.logo b { font-weight: 600; } .logo i { font-style: italic; color: var(--magenta); font-weight: 400; }
.site-header nav { display: flex; align-items: center; gap: .25rem; }
.nav-link {
  display: inline-flex; align-items: center; min-height: 2.75rem; padding: .4rem 1rem; border-radius: 999px;
  font-family: var(--sans); font-weight: 500; font-size: 1.05rem; letter-spacing: -.03em; text-decoration: none;
  transition: background-color .2s var(--ease-col), color .2s var(--ease-col);
}
.nav-link:hover { background: var(--card); }
.nav-resume { color: var(--purple-ink); }
.nav-dice {
  display: grid; place-items: center; width: 2.9rem; height: 2.9rem; margin-left: .4rem; border-radius: 50%;
  background: var(--purple-btn); color: #fff; transition: transform .45s var(--spring), background-color .2s var(--ease-col);
}
.nav-dice svg { width: 1.4rem; height: 1.4rem; transition: rotate .5s var(--ease); }
.nav-dice:hover { transform: scale(1.1); background: var(--purple-btn-2); }
.nav-dice:hover svg { rotate: 90deg; }
.pill {
  display: inline-flex; align-items: center; gap: .45rem; min-height: 2.75rem; padding: .2rem 1rem .2rem .25rem;
  border-radius: 999px; background: var(--card); font-family: var(--sans); font-weight: 500; font-size: .95rem;
  letter-spacing: -.02em; transition: transform .45s var(--spring);
}
.pill:hover { transform: scale(1.04); }
.pill .portrait { background: var(--lilac); border-radius: 50%; overflow: hidden; }
.pill span:last-child { max-width: 11rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- the sky of falling worlds ---- */
.wf-sky {
  /* clear zone under the header (~5.5rem) so paintings never sit on logo/nav */
  position: absolute; left: 0; right: 0; top: 6.25rem; bottom: 0; z-index: 1; pointer-events: none;
  overflow: clip;
  /* gentle magnetic lean toward the pointer */
  transform: translate3d(calc(var(--mx, 0) * 1.4rem), calc(var(--my, 0) * .9rem), 0);
  transition: transform 1.1s var(--ease);
}

.wf-piece {
  --i: 0; --x: 50%; --y: 40%; --r: 0deg; --s: .85;
  /* fall in early so ~all 12 are settled at rest; fall out evenly across the scrub */
  --in-start: calc(var(--i) * .028 - .55);
  --in-end: calc(var(--in-start) + .28);
  /* out windows tile 0.22 → ~0.92 so the cascade is even, not back-loaded */
  --out-start: calc(.22 + var(--i) * .05);
  --tin: clamp(0, (var(--p, 0) - var(--in-start)) / (var(--in-end) - var(--in-start)), 1);
  --tout: clamp(0, (var(--p, 0) - var(--out-start)) / .42, 1);
  --ein: calc(1 - (1 - var(--tin)) * (1 - var(--tin)) * (1 - var(--tin)));
  --eout: calc(var(--tout) * var(--tout));
  position: absolute;
  left: var(--x); top: var(--y);
  width: clamp(11rem, 26vw, 22rem);
  margin: 0;
  translate: -50% -50%;
  /* tumble in from above with spin, then tumble out below */
  transform:
    translate3d(
      calc(var(--mx, 0) * (var(--i) * .08rem + .4rem)),
      calc((1 - var(--ein)) * -115vh + var(--eout) * 120vh),
      0
    )
    rotate(calc(var(--r) + (1 - var(--ein)) * -38deg + var(--eout) * 42deg))
    scale(calc(var(--s) * (.55 + .45 * var(--ein)) * (1 - var(--eout) * .25)));
  opacity: calc(var(--ein) * (1 - var(--eout)));
  filter: drop-shadow(0 .8rem 1.2rem rgba(64, 44, 110, .18));
  will-change: transform, opacity;
}
.wf-piece img {
  display: block; width: 100%; height: auto;
  filter:
    drop-shadow(1.5px 0 0 #fffdf6) drop-shadow(-1.5px 0 0 #fffdf6)
    drop-shadow(0 1.5px 0 #fffdf6) drop-shadow(0 -1.5px 0 #fffdf6);
}

/* settle positions — balanced ring around the headline, clear of the header band */
.p1  { --i: 0;  --x: 12%; --y: 26%; --r: -12deg; --s: 1; }
.p2  { --i: 1;  --x: 88%; --y: 24%; --r:  11deg; --s: .96; }
.p3  { --i: 2;  --x: 50%; --y: 18%; --r:  -5deg; --s: .82; }
.p4  { --i: 3;  --x: 18%; --y: 56%; --r:   8deg; --s: .98; }
.p5  { --i: 4;  --x: 84%; --y: 54%; --r: -10deg; --s: .94; }
.p6  { --i: 5;  --x: 4%;  --y: 40%; --r:   6deg; --s: .88; }
.p7  { --i: 6;  --x: 70%; --y: 76%; --r:  -7deg; --s: .9; }
.p8  { --i: 7;  --x: 94%; --y: 38%; --r:  13deg; --s: .84; }
.p9  { --i: 8;  --x: 30%; --y: 82%; --r:  -4deg; --s: .9; }
.p10 { --i: 9;  --x: 66%; --y: 32%; --r:   7deg; --s: .8; }
.p11 { --i: 10; --x: 10%; --y: 72%; --r:  10deg; --s: .86; }
.p12 { --i: 11; --x: 52%; --y: 88%; --r: -9deg;  --s: .88; }

/* ---- the modest centred headline ---- */
.hero-copy {
  position: relative; z-index: 3;
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  /* soft fade as the worlds fall away at the end of the scrub */
  opacity: calc(1 - clamp(0, (var(--p, 0) - .82) / .18, 1));
  translate: 0 calc(clamp(0, (var(--p, 0) - .82) / .18, 1) * -3vh);
  pointer-events: none;
}
.hero-copy::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: min(36rem, 90vw); height: 14rem;
  translate: -50% -55%; border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(245, 244, 238, .92) 0%, rgba(245, 244, 238, .55) 45%, rgba(245, 244, 238, 0) 72%);
  pointer-events: none; z-index: -1;
}
.hero-copy .hero-go { pointer-events: auto; }

.hero-h {
  margin: 0;
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(1.85rem, 3.2vw, 2.85rem);
  line-height: 1.05;
  letter-spacing: -.035em;
  color: var(--ink);
  font-variation-settings: "SOFT" 80, "WONK" 0.7, "opsz" 72;
}
.hero-vis { display: flex; flex-direction: column; align-items: center; gap: .12em; }
.hero-h .ln {
  display: block; white-space: nowrap;
}
.hero-h .ln:nth-child(2) {
  font-style: italic;
  font-weight: 450;
  letter-spacing: -.03em;
  font-variation-settings: "SOFT" 100, "WONK" 0.9, "opsz" 72;
}
.hero-h .ch {
  display: inline-block;
  transform-origin: 50% 100%;
}
.hero-h .sp { display: inline-block; width: .28em; }
.hero-go {
  display: grid; place-items: center; width: 3.4rem; height: 3.4rem; margin-top: 1.6rem;
  border-radius: 50%; background: var(--purple-btn); color: #fff;
  transition: transform .45s var(--spring), background-color .2s var(--ease-col);
  pointer-events: auto;
}
.hero-go svg { width: 1.35rem; height: 1.35rem; transition: translate .6s var(--ease); }
.hero-go:hover { transform: scale(1.1); background: var(--purple-btn-2); }
.hero-go:hover svg { translate: 0 .2rem; }

/* ---- load: letters cascade up, pieces already begin to tumble ---- */
.hero.intro .logo { animation: fade-in .7s var(--ease-out) both .05s; }
.hero.intro .site-header nav > * { animation: nav-in .8s var(--ease) both; }
.hero.intro .site-header nav > :nth-child(1) { animation-delay: .85s; }
.hero.intro .site-header nav > :nth-child(2) { animation-delay: .93s; }
.hero.intro .site-header nav > :nth-child(3) { animation-delay: 1.01s; }
.hero.intro .site-header nav > :nth-child(4) { animation-delay: 1.09s; }
.hero.intro .site-header nav > :nth-child(5) { animation-delay: 1.17s; }

.hero.intro .hero-h .ch {
  animation: letter-up 1.05s var(--ease) both;
}
.hero.intro .hero-h .ln:nth-child(1) .ch:nth-child(1)  { animation-delay: .55s; }
.hero.intro .hero-h .ln:nth-child(1) .ch:nth-child(2)  { animation-delay: .58s; }
.hero.intro .hero-h .ln:nth-child(1) .ch:nth-child(3)  { animation-delay: .61s; }
.hero.intro .hero-h .ln:nth-child(1) .ch:nth-child(5)  { animation-delay: .66s; }
.hero.intro .hero-h .ln:nth-child(1) .ch:nth-child(6)  { animation-delay: .69s; }
.hero.intro .hero-h .ln:nth-child(1) .ch:nth-child(7)  { animation-delay: .72s; }
.hero.intro .hero-h .ln:nth-child(1) .ch:nth-child(8)  { animation-delay: .75s; }
.hero.intro .hero-h .ln:nth-child(1) .ch:nth-child(9)  { animation-delay: .78s; }
.hero.intro .hero-h .ln:nth-child(1) .ch:nth-child(10) { animation-delay: .81s; }
.hero.intro .hero-h .ln:nth-child(2) .ch:nth-child(1)  { animation-delay: .86s; }
.hero.intro .hero-h .ln:nth-child(2) .ch:nth-child(2)  { animation-delay: .89s; }
.hero.intro .hero-h .ln:nth-child(2) .ch:nth-child(3)  { animation-delay: .92s; }
.hero.intro .hero-h .ln:nth-child(2) .ch:nth-child(4)  { animation-delay: .95s; }
.hero.intro .hero-h .ln:nth-child(2) .ch:nth-child(6)  { animation-delay: 1s; }
.hero.intro .hero-h .ln:nth-child(2) .ch:nth-child(7)  { animation-delay: 1.03s; }
.hero.intro .hero-h .ln:nth-child(2) .ch:nth-child(8)  { animation-delay: 1.06s; }
.hero.intro .hero-h .ln:nth-child(2) .ch:nth-child(9)  { animation-delay: 1.09s; }
.hero.intro .hero-h .ln:nth-child(2) .ch:nth-child(10) { animation-delay: 1.12s; }
.hero.intro .hero-h .ln:nth-child(2) .ch:nth-child(11) { animation-delay: 1.15s; }
.hero.intro .hero-h .ln:nth-child(2) .ch:nth-child(12) { animation-delay: 1.18s; }
.hero.intro .hero-h .ln:nth-child(2) .ch:nth-child(13) { animation-delay: 1.21s; }
.hero.intro .hero-h .ln:nth-child(2) .ch:nth-child(14) { animation-delay: 1.24s; }
.hero.intro .hero-go { animation: pop-in .9s var(--spring) both 1.45s; }

.hero.intro .wf-sky { animation: sky-in 1.4s var(--ease-out) both .05s; }

@keyframes fade-in { from { opacity: 0; } }
@keyframes nav-in { from { opacity: 0; transform: translateY(-.9rem); } }
@keyframes letter-up {
  from { opacity: 0; transform: translateY(110%) rotate(-6deg); }
  to   { opacity: 1; transform: none; }
}
@keyframes pop-in { from { opacity: 0; scale: .3; } }
@keyframes sky-in { from { opacity: 0; } to { opacity: 1; } }

/* ---- tablets and phones ---- */
@media (max-width: 60rem) {
  .hero-h { font-size: clamp(1.7rem, 6.5vw, 2.6rem); }
  .wf-piece { width: clamp(7.5rem, 34vw, 14rem); }
  .wf-sky { top: 5.2rem; }
  .p10 { display: none; } /* thin one piece on mid widths */
}
@media (max-width: 46rem) {
  .site-header { padding-top: 1.1rem; }
  .logo { font-size: 1.4rem; }
  .site-header nav .nav-link:not(.nav-resume) { display: none; }
  .site-header nav .nav-link:first-child { display: inline-flex; }
  .nav-link { font-size: 1rem; padding: .4rem .8rem; }
  .pill { padding-right: .8rem; } .pill span:last-child { max-width: 5.5rem; }
  .wf-pin { min-height: 0; padding-bottom: 2rem; }
  .wf-track { height: 200vh; }
  .hero-h { font-size: clamp(1.55rem, 7.2vw, 2.2rem); }
  .hero-go { margin-top: 1.2rem; width: 3.1rem; height: 3.1rem; }
  .wf-sky { top: 4.6rem; }
  .wf-piece { width: clamp(7.5rem, 44vw, 12rem); }
  /* thin two edge pieces on phones so the letters stay readable */
  .p8, .p10 { display: none; }
  .p1  { --x: 14%; --y: 18%; }
  .p2  { --x: 88%; --y: 16%; }
  .p3  { --x: 50%; --y: 10%; }
  .p4  { --x: 16%; --y: 62%; }
  .p5  { --x: 86%; --y: 58%; }
  .p6  { --x: 6%;  --y: 40%; }
  .p7  { --x: 72%; --y: 78%; }
  .p9  { --x: 32%; --y: 86%; }
  .p11 { --x: 10%; --y: 74%; }
  .p12 { --x: 54%; --y: 90%; }
}

@media (prefers-reduced-motion: reduce) {
  .hero-copy { opacity: 1; translate: none; }
  .wf-piece {
    --tin: 1; --tout: 0;
    transform: rotate(var(--r)) scale(var(--s));
    opacity: 1;
    animation: none !important;
  }
  .wf-sky { transform: none; transition: none; }
  .hero.intro .hero-h .ch, .hero.intro .hero-go, .hero.intro .logo, .hero.intro .site-header nav > * { animation: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .hero-copy { will-change: translate, opacity; }
  .wf-piece { will-change: transform, opacity; }
}
