/* Page transitions (docs/navigation.md). Copied to public/assets/css/transitions.css by `npm run css`.
   Pages change by in-site navigation: Astro's router (src/components/Navigation.astro) swaps the next page in and animates the
   change with the browser's view transition (same-document). Browsers without the View Transition API change pages at once.
   Full page loads (the thank-you page, the kill switch) are not animated: there is no @view-transition rule.

   Layers while a page changes, bottom to top, with LAYERS = 'window' in Navigation.astro (the default since November 30, 2026):
     the window  everything but the header's parts, as one picture: the old one fades out quickly and the new one fades in,
                 in place, the same forward and back. (Until November 30, 2026 the pages also drifted 20px sideways; Justin
                 found that tacky in practice and asked for a plain quick cross-fade.)
     the header  the logo, the menu, "Work with us" and the menu button, each held as its own layer: still when the header
                 looks the same on both pages; when it changes state (the compact mark on a scrolled page, the full logo at
                 the top of the next) each part glides to its new place and the logo cross-fades, as when you scroll to the top

   With LAYERS = 'page' (the first design), the window is split further: the browser's white canvas at the bottom, then each
   page's glows held in place (the old fade out, the new fade in), then the page (all of #page) fading, then the
   header. Navigation.astro then sets html.pm-vt-out on the old page (astro:after-preparation, just before it is captured) and
   html.pm-vt-in on the new one (astro:after-swap), which give #page and the glows their names for the length of the
   transition only. In Safari that full-height page layer goes undrawn for a few frames (docs/navigation.md).

   The router marks a back or forward step with html[data-astro-transition="back"]. With the phone menu open, Navigation.astro
   leaves the open menu in the old page's picture (and "Work with us", which is under it, out of it), so the menu leaves with
   the page exactly as it was on screen. Reduced motion: no animation. */

:root {
	--vt-move: 200ms;                         /* how long a header part takes to glide, when the header changes state */
	--vt-ease: cubic-bezier(0.2, 0, 0, 1);    /* that movement: quick to start, decelerating into place */
	--vt-out: 80ms;                           /* the old page fades out quickly ... */
	--vt-out-ease: cubic-bezier(0.4, 0, 1, 1);
	--vt-in: 170ms;                           /* ... and the new one fades in (quickly at first, then settling), */
	--vt-in-ease: cubic-bezier(0, 0, 0.2, 1);
	--vt-in-delay: 30ms;                      /* starting while the old one is still visible, so there is no empty moment */
	--vt-header: 160ms;                       /* the header's cross-fade, when its picture changes */
}

/* -- Names: what is held as its own layer -- */
html:root .site-branding__link { view-transition-name: pm-logo; }
html:root #site-navigation { view-transition-name: pm-nav; }
html:root .header-link__container { view-transition-name: pm-cta; }
html:root #menu-toggle { view-transition-name: pm-burger; }
html:root .site-branding__link, html:root #site-navigation, html:root .header-link__container, html:root #menu-toggle { view-transition-class: pm-frame; }
/* On a scrolled page on desktop (not Safari) the header inverts its colours against the page (mix-blend-mode: difference).
   A layer's picture cannot carry that blend, so for the length of the transition the header shows as it looks over white:
   plain black, at once (its colours otherwise change over 0.3s). (Over a dark photo it shows light; there it turns black for
   a quarter of a second.) */
html.pm-vt-out .site-header--fixed, html.pm-vt-out .site-header--fixed *,
html.pm-vt-in .site-header--fixed, html.pm-vt-in .site-header--fixed * { mix-blend-mode: normal !important; filter: none !important; transition: none !important; }
/* during a transition (set by the script): the page is captured as two separate layers, old and new, without its white (the
   canvas shows the same white), so the glows can sit beneath it. Old and new have different names, so they never pair up:
   each stays where it was on screen. The glows' own names (pm-glow-<page>-<n>) are set in the page by PageTransitions.astro. */
html.pm-vt-out, html.pm-vt-in { view-transition-name: none; }
html.pm-vt-out #page { view-transition-name: pm-page-out; background-color: transparent; }
html.pm-vt-in #page { view-transition-name: pm-page-in; background-color: transparent; }
html:root .radial,
html:root .front-page__circle,
html:root .front-page__circle-2,
html:root .front-page__circle-3,
html:root .ai-work__glow,
html:root .ai-close__glow { view-transition-class: pm-glow; }

/* -- Stacking -- */
::view-transition-group(*.pm-glow) { z-index: 0; }
::view-transition-group(root), ::view-transition-group(pm-page-out), ::view-transition-group(pm-page-in) { z-index: 1; }
::view-transition-group(*.pm-frame) { z-index: 3; }

/* -- The page: a quick cross-fade in place, the same forward and back -- */
::view-transition-old(root), ::view-transition-old(pm-page-out) { animation: pm-vt-fade-out var(--vt-out) var(--vt-out-ease) both; }
::view-transition-new(root), ::view-transition-new(pm-page-in) { animation: pm-vt-fade-in var(--vt-in) var(--vt-in-ease) var(--vt-in-delay) both; }

/* -- The glows: cross-fade in place, on the page's timing -- */
::view-transition-old(*.pm-glow) { animation: pm-vt-fade-out var(--vt-out) linear both; }
::view-transition-new(*.pm-glow) { animation: pm-vt-fade-in var(--vt-in) linear var(--vt-in-delay) both; }

/* -- The header's parts: held; if a part changes place or picture, it glides and cross-fades on the page's timing -- */
::view-transition-group(*.pm-frame) { animation-duration: var(--vt-move); animation-timing-function: var(--vt-ease); }
::view-transition-old(*.pm-frame), ::view-transition-new(*.pm-frame) { animation-duration: var(--vt-header); }

@keyframes pm-vt-fade-out { to { opacity: 0; } }
@keyframes pm-vt-fade-in { from { opacity: 0; } }

/* -- Reduced motion: no animation at all; the new page simply replaces the old -- */
@media (prefers-reduced-motion: reduce) {
	html:root::view-transition-group(*), html:root::view-transition-old(*), html:root::view-transition-new(*) { animation: none !important; }
}

/* -- The top fade (type.css 12, phones and tablets): the white easing out at the top of each page, over the glows. Held as one
   layer across the change, the new page's at once (both pages' are the same), above the glows and the page, under the header,
   so the glows' cross-fade never shows a line under Safari's status bar. Nothing else on a page reaches into it. -- */
html.pm-vt-out .pm-top-fade, html.pm-vt-in .pm-top-fade { view-transition-name: pm-top-fade; }
::view-transition-group(pm-top-fade) { z-index: 2; animation: none; }
::view-transition-old(pm-top-fade) { animation: none; opacity: 0; }
::view-transition-new(pm-top-fade) { animation: none; opacity: 1; }
