/* Cross-document view transitions (EX-02).
   Loaded on every page while transitions are on. Both the page being left and the
   page being entered must opt in, so the switch works site-wide. */

@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }
}

/* Chrome that stays put: named so it is lifted out of the page crossfade. */
.masthead { view-transition-name: masthead; }
.colophon { view-transition-name: colophon; }

/* The current-page tab slides to the new tab. */
.nav a[aria-current='page'] { view-transition-name: nav-current; }

/* Shared elements are named inline in the markup (view-transition-name: ex-02-title,
   swatch-oxide, …) because each name must be unique on a page. */

::view-transition-group(*) {
  animation-duration: 320ms;
  animation-timing-function: cubic-bezier(0.2, 0.7, 0.2, 1);
}

::view-transition-old(root) {
  animation: 160ms ease-in both bench-out;
}
::view-transition-new(root) {
  animation: 300ms cubic-bezier(0.2, 0.7, 0.2, 1) 80ms both bench-in;
}

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