/* Page-to-page animation for the whole site.
   Browsers with cross-document view transitions slide the page in the
   direction of travel through the menu, keep the menu still, and glide the
   highlighted menu tab to its new place. Other browsers get a short fade-in. */
@view-transition { navigation: auto; }

.top { view-transition-name: site-menu; }
.top-links a[aria-current] { view-transition-name: menu-tab; }
.top-sub a[aria-current] { view-transition-name: menu-subtab; }

html { --pt-x: 36px; }
html:active-view-transition-type(back) { --pt-x: -36px; }

::view-transition-old(root) { animation: pt-out .22s ease-in both; }
::view-transition-new(root) { animation: pt-in .5s cubic-bezier(.16,1,.3,1) both; }
::view-transition-group(menu-tab), ::view-transition-group(menu-subtab) { animation-duration: .45s; animation-timing-function: cubic-bezier(.16,1,.3,1); }
::view-transition-group(site-menu) { animation-duration: .3s; }

@keyframes pt-out { to { opacity: 0; transform: translateX(calc(var(--pt-x) * -0.5)); } }
@keyframes pt-in { from { opacity: 0; transform: translateX(var(--pt-x)); } }

/* Fallback: fade the page content in (opacity only, so pinned and fixed parts stay put). */
@supports not (view-transition-name: none) {
  body > :not(.top):not(script) { animation: pt-fade .35s ease both; }
}
@keyframes pt-fade { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  body > * { animation: none !important; }
}
