/* Nexrena proto v10: 3D page-to-page transition, one continuous move.
   Chrome/Edge and Safari 18.2+: cross-document View Transitions, pure CSS.
   Others: js/vt.js plays the same move with a void veil (transforms, opacity, clip-path only).
   v10 flash fix: the old page is gone before the new one shows (no headline overlap), the new page
   arrives fully composed (html.vt-arrive skips the hero intro), and the void colour is set before first paint. */
@view-transition { navigation: auto; }
html { background: var(--void, #08090b); color-scheme: dark; }
body { color-scheme: light; }
#nav { view-transition-name: nx-nav; }

::view-transition { background: var(--void, #08090b); }
::view-transition-group(root) { animation-duration: 760ms; }
::view-transition-image-pair(root) { isolation: auto; }
::view-transition-old(root), ::view-transition-new(root) { mix-blend-mode: normal; backface-visibility: hidden; will-change: transform, opacity; }
/* one move, no crossfade: the old page tilts back and clears (0-380ms) while the new page, fully opaque, slides up over it
   with a gold edge (100-760ms). Pages never blend, so headlines never ghost and there is no dark or white dip. */
::view-transition-old(root) { transform-origin: 50% 0; animation: nx-out 380ms cubic-bezier(.4, 0, .6, 1) both; }
::view-transition-new(root) { transform-origin: 50% 100%; animation: nx-in 660ms cubic-bezier(.22, 1, .36, 1) 100ms both;
  box-shadow: 0 -2px 0 0 var(--gold, #c9a96e); }
/* the nav stays put; only its colours settle */
::view-transition-group(nx-nav) { animation-duration: 260ms; animation-timing-function: ease; z-index: 50; }
::view-transition-old(nx-nav), ::view-transition-new(nx-nav) { animation-duration: 260ms; height: 100%; }

/* Ask Nexrena stays put: the new widget shows at once, no crossfade */
::view-transition-group(ask-nexrena) { animation: none; z-index: 60; }
::view-transition-old(ask-nexrena) { display: none; }
::view-transition-new(ask-nexrena) { animation: none; }

/* back / forward runs the move in reverse */
html:active-view-transition-type(back)::view-transition-old(root) { transform-origin: 50% 100%; animation-name: nx-out-back; }
html:active-view-transition-type(back)::view-transition-new(root) { transform-origin: 50% 0; animation-name: nx-in-back; box-shadow: 0 2px 0 0 var(--gold, #c9a96e); }

@keyframes nx-out { from { transform: none; opacity: 1; } 20% { opacity: 1; } to { transform: perspective(1000px) translate3d(0, -6%, -440px) rotateX(15deg); opacity: 0; } }
@keyframes nx-in { from { transform: perspective(1200px) translate3d(0, 92%, -120px) rotateX(-10deg); } to { transform: none; } }
@keyframes nx-out-back { from { transform: none; opacity: 1; } 20% { opacity: 1; } to { transform: perspective(1000px) translate3d(0, 6%, -440px) rotateX(-15deg); opacity: 0; } }
@keyframes nx-in-back { from { transform: perspective(1200px) translate3d(0, -92%, -120px) rotateX(10deg); } to { transform: none; } }
@keyframes nx-fade-out { to { opacity: 0; } }
@keyframes nx-fade-in { from { opacity: 0; } }

/* ---------- first paint matches the intro's start state ----------
   The hero intros (live.js, pages.js, hx.js) hide these with GSAP a few frames after load. Hiding them under html.pre too
   means a fresh load never shows them, snaps them away, then brings them back. Arriving by a page transition, the head
   script drops .pre before first paint, so the page shows fully composed and no intro runs. */
html.pre #hero :is(.hero-top .mono, .band, .slot, .hero-zoom, .hero-foot .sub, .hero-foot .cta),
html.pre .ph :is(.ph-crumb, .ph-sub, .ph-actions, .ph-frame, .ph-big),
html.pre [data-hx] :is(.hx-crumb, .hx-sub > *, .hx-cap, .ly, [data-chip], [data-num], .hx-band .bt, [data-slot], .rc, [data-col], [data-word],
  [data-mini] .fr, [data-qz] li, [data-ix] a, .hx-steps li, [data-floor] .fr, .hxf, .hx-ans, .hx-meta) { visibility: hidden; }

/* ---------- fallback (no cross-document view transitions), driven by js/vt.js ---------- */
@keyframes vt-veil-up { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes vt-veil-off { from { clip-path: inset(0 0 0 0); } to { clip-path: inset(0 0 100% 0); } }
@keyframes vt-recede { 35% { opacity: 1; } to { opacity: 0; } }
@keyframes vt-rise { from { opacity: 0; } }
html.vt-out body, html.vt-in body { background: var(--void, #08090b); }
html.vt-out::before, html.vt-in::before { content: ""; position: fixed; inset: 0; z-index: 39; pointer-events: none; background: var(--void, #08090b); }
html.vt-out::before { border-top: 2px solid var(--gold, #c9a96e); animation: vt-veil-up 300ms cubic-bezier(.65, 0, .35, 1) 140ms both; }
/* fallback moves opacity only on main: a transform on main would re-anchor GSAP pins (position: fixed) and show other sections */
html.vt-out main, html.vt-out .foot { animation: vt-recede 420ms cubic-bezier(.45, 0, .25, 1) both; }
/* the veil covers the new page at first paint; a CSS failsafe lifts it even if JS never runs */
html.vt-in::before { border-bottom: 2px solid var(--gold, #c9a96e); animation: vt-veil-off 480ms cubic-bezier(.16, 1, .3, 1) 1.2s both; }
html.vt-in.vt-go::before { animation-delay: 0s; }
html.vt-in.vt-go main { animation: vt-rise 420ms cubic-bezier(.22, 1, .36, 1) 40ms backwards; }

/* reduced motion: a short crossfade, nothing moves */
@media (prefers-reduced-motion: reduce) {
  /* the old page holds still under the new one, so the 200ms fade never dips through the void */
  ::view-transition-old(root), html:active-view-transition-type(back)::view-transition-old(root) { animation: none; box-shadow: none; }
  ::view-transition-new(root), html:active-view-transition-type(back)::view-transition-new(root) { animation: nx-fade-in 200ms ease both; box-shadow: none; }
  ::view-transition-group(root) { animation-duration: 200ms; }
  html.vt-out::before { border: 0; animation: nx-fade-in 160ms ease both; }
  html.vt-out main, html.vt-out .foot { animation: none; }
  html.vt-in::before { border: 0; animation: nx-fade-out 200ms ease 1.2s both; }
  html.vt-in.vt-go::before { animation-delay: 0s; }
  html.vt-in.vt-go main { animation: none; }
}
