/*
  Motion for the public sites (website and Discover). Quiet and tied to scrolling: content eases in as it
  enters the screen, pictures drift a little as you scroll. Nothing loops or calls for attention.
  Reveals need ScrollMotion.jsx on the page (works in every browser); without it content simply shows.
  Elements opt in with data-motion="…"; nothing changes the content. Off with prefers-reduced-motion.

  data-motion="hero"      the first screen's text eases in once when the page opens
  data-motion="reveal"    the element eases in as it scrolls into view
  data-motion="stagger"   each child eases in as it scrolls into view (grids and lists)
  data-motion="parallax"  a picture drifts slightly slower than the page while scrolling
*/
@media (prefers-reduced-motion: no-preference) {
  [data-motion="hero"] > * { animation: rm-ease-in .6s cubic-bezier(.2,.7,.2,1) both; }
  [data-motion="hero"] > :nth-child(2) { animation-delay: .06s; }
  [data-motion="hero"] > :nth-child(3) { animation-delay: .12s; }
  [data-motion="hero"] > :nth-child(n+4) { animation-delay: .18s; }

  /* Reveal on scroll: ScrollMotion.jsx adds rm-ready to the page and rm-in to each item as it appears. */
  .rm-ready [data-motion="reveal"]:not(.rm-in), .rm-ready [data-motion="stagger"] > :not(.rm-in) { opacity: 0; }
  /* "backwards" keeps the start state during the delay and lets go afterwards, so hover effects still work. */
  .rm-ready [data-motion="reveal"].rm-in, .rm-ready [data-motion="stagger"] > .rm-in { animation: rm-rise .7s cubic-bezier(.2,.7,.2,1) calc(var(--rm-step, 0) * 70ms) backwards; }

  /* Pictures drift slightly with the scroll, where the browser supports scroll-linked animation. */
  @supports (animation-timeline: view()) {
    [data-motion="parallax"] { animation: rm-drift linear both; animation-timeline: view(); animation-range: cover; }
  }
}

@keyframes rm-rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes rm-ease-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes rm-drift { from { transform: translateY(-14px) scale(1.05); } to { transform: translateY(14px) scale(1.05); } }
