/* Page motion for weneedthistoo.com
   Moving between pages: the header and logo hold still, the page under them
   fades out quickly and the next one fades in with a small rise.
   Uses the browser's own cross-page transitions (Chrome, Edge, Safari 18.2+).
   Other browsers load pages normally. First visit: the content fades in once.
   Reduce motion turns all of it off. */

@view-transition { navigation: auto; }

header.top { view-transition-name: wntt-top; }
header .logo { view-transition-name: wntt-logo; }

/* the page itself */
::view-transition-old(root) { animation: wntt-out 120ms ease-in both; }
::view-transition-new(root) { animation: wntt-in 280ms cubic-bezier(.2, .7, .2, 1) 40ms both; }

/* header: stays put; any difference in the links cross-fades in place */
::view-transition-group(wntt-top),
::view-transition-group(wntt-logo) { animation-duration: 240ms; animation-timing-function: cubic-bezier(.2, .7, .2, 1); }
::view-transition-old(wntt-top),
::view-transition-new(wntt-top) { animation-duration: 180ms; }

@keyframes wntt-out { to { opacity: 0; } }
@keyframes wntt-in { from { opacity: 0; transform: translateY(6px); } }

/* first visit, or a browser without page transitions */
html:not(.vt) body > main,
html:not(.vt) body > footer { animation: wntt-in 360ms cubic-bezier(.2, .7, .2, 1) backwards; }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  html:not(.vt) body > main,
  html:not(.vt) body > footer { animation: none; }
}
