/* @group Page transitions */

/* Each change of page is one smooth step (cross-document view transitions).
   Both pages opt in, so the old page stays until the new one can draw. Then
   the browser fades between them. A screen names the parts that move rather
   than fade (blocks/swipe_pager.css). Without view transitions, or with
   reduced motion, the page changes without a transition. */
@supports (view-transition-name: none) {
  @view-transition {
    navigation: auto;
  }

  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: var(--ui-duration-reveal);
    animation-timing-function: var(--ui-ease-reveal);
  }

  @media (prefers-reduced-motion: reduce) {
    @view-transition {
      navigation: none;
    }
  }
}

/* Leaving a page (user_interface/navigation/leaving): a progress line across
   the top, drawn in the frame of the tap. WebKit draws nothing more until the
   next page arrives, so that frame must show it. Where the browser keeps
   drawing, the line then grows slowly, as a browser's own progress bar does.
   With reduced motion it stays as it is drawn. */
html[data-leaving] body::after {
  position: fixed;
  inset-block-start: env(safe-area-inset-top);
  inset-inline: 0;
  z-index: var(--ui-layer-overlay);
  block-size: calc(var(--ui-space-unit) / 2);
  background-color: var(--color-neutral);
  transform: scaleX(0.3);
  transform-origin: left;
  pointer-events: none;
  content: '';
  animation: page-leaving-progress var(--ui-duration-background-work) var(--ui-ease-reveal) var(--ui-delay-loading) forwards;
}

@keyframes page-leaving-progress {
  to { transform: scaleX(0.9); }
}

@media (prefers-reduced-motion: reduce) {
  html[data-leaving] body::after {
    animation: none;
  }
}

/* @end */
