/* Veva Support theme: motion (Motion feature). The page transition between pages and the rise of content blocks as
   they scroll into view. Both are progressive enhancements: a browser without View Transitions or scroll-driven
   animations changes pages and shows the blocks as before, and none of it runs for a visitor who asks for reduced
   motion.

   Page transition
   - Full page loads between theme pages (a search palette result, ?rendermode=static, a page without a circuit)
     take the browser's cross-document transition: @view-transition below.
   - Blazor's router changes pages inside the same document, which the browser does not see as a navigation between
     pages. page-transitions.js wraps those changes in document.startViewTransition, and both draw the same motion:
       root            the old page recedes a little and fades, the new page settles into place from just above,
                       the way the front page's blocks drop in
       vs-header       the site header stays put, and cross-fades between the stage and the white ground
       vs-docs-side    the docs menu stays put from one docs page to the next
       vs-consent      the cookie banner stays put while it is showing
   - The page snapshots never move down: under the header they hold the page's white ground, which would show as a
     strip below a dark header. Moving up, or shrinking toward the top edge, keeps it behind the header.
   - A named part that is out of view when a page is captured is left out for that capture (page-transitions.js
     lists it in data-vs-vt-away on <html>), so it fades instead of flying in from beyond the viewport.

   Scroll reveal
   - Section heads, cards, panels, callouts, drawings and Flow steps inside a Section rise and fade in over their
     first 240px in view; a block already in view when the page opens shows at rest. Docs pages are left still:
     their content sits outside Sections. On wide screens the Flow steps follow one another. */

:root {
  --vs-ease-out: cubic-bezier(.16, 1, .3, 1);
  --vs-ease-in: cubic-bezier(.4, 0, 1, 1);
}

@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }

  .vs-header { view-transition-name: vs-header; }
  .vs-docs__side { view-transition-name: vs-docs-side; }
  veva-cookie-consent { view-transition-name: vs-consent; }
  :root[data-vs-vt-away~="header"] .vs-header { view-transition-name: none; }
  :root[data-vs-vt-away~="docs-side"] .vs-docs__side { view-transition-name: none; }

  ::view-transition-old(root) { transform-origin: 50% 0; animation: vs-page-out .18s var(--vs-ease-in) both; }
  ::view-transition-new(root) { animation: vs-page-in .5s var(--vs-ease-out) .06s both; }

  /* The parts that stay put move to their new place (the docs menu, when the page was scrolled) on the page's curve. */
  ::view-transition-group(vs-header),
  ::view-transition-group(vs-docs-side) { animation-duration: .48s; animation-timing-function: var(--vs-ease-out); }
  ::view-transition-old(vs-header),
  ::view-transition-new(vs-header),
  ::view-transition-old(vs-docs-side),
  ::view-transition-new(vs-docs-side) { animation-duration: .32s; }
}

@keyframes vs-page-out { to { opacity: 0; transform: scale(.99); } }
@keyframes vs-page-in { from { opacity: 0; transform: translateY(-12px); } }

/* Scroll reveal. translate, not transform, so a card's hover lift (cards.css) still works on top of it. The blocks
   are listed twice: a block inside another one (a card in a panel) rides along with it instead of rising twice. */
@media screen and (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    .vs-section :is(.vs-head, .vs-card, .vs-pkg, .vs-panel, .vs-callout, .vs-scene, .vs-layers, .vs-flow__step):not(:is(.vs-head, .vs-card, .vs-pkg, .vs-panel, .vs-callout, .vs-scene, .vs-layers, .vs-flow__step) *) {
      animation-name: vs-rise;
      animation-fill-mode: both;
      animation-timing-function: ease-out;
      animation-timeline: view();
      animation-range: entry var(--vs-rise-after, 0px) entry calc(240px + var(--vs-rise-after, 0px));
    }

    @media (min-width: 1025px) {
      .vs-section .vs-flow__step:nth-child(2) { --vs-rise-after: 48px; }
      .vs-section .vs-flow__step:nth-child(3) { --vs-rise-after: 96px; }
      .vs-section .vs-flow__step:nth-child(4) { --vs-rise-after: 144px; }
      .vs-section .vs-flow__step:nth-child(n+5) { --vs-rise-after: 192px; }
    }
  }
}

@keyframes vs-rise { from { opacity: 0; translate: 0 28px; } }
