/* Hero: one sticky stage inside a 300vh track. Card 1 rests centred; cards 2 and 3 rise into a
   30px offset stack as the track scrolls. */
:root {
  --card-w: 595px;
  --card-ratio: 595 / 343;
  --card-pad: 30px;
  --card-radius: 16px;
  --step: 30px;
}

.track {
  height: 300vh;
  position: relative;
}

.stage {
  position: sticky;
  top: 0;
  height: 100vh;
  /* svh, not dvh: a stage that resizes with the mobile toolbar re-centres the deck mid-scroll. */
  height: 100svh;
  display: grid;
  place-items: center;
  /* Clip like overflow: hidden, but let the cube canvas reach the viewport edges past the page gutters. */
  clip-path: inset(0 calc(-1 * var(--side-r)) -100vh calc(-1 * var(--side)));
}

.deck {
  position: relative;
  width: min(var(--card-w), 100%);
  aspect-ratio: var(--card-ratio);
}

.card {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: var(--card-radius);
  padding: var(--card-pad);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  will-change: transform;
}

.card h1,
.card h2 {
  margin: 0;
  font-weight: 400;
  font-size: 18px;
  line-height: normal;
  font-family: var(--font-display);
}

.card p {
  margin: 0;
  font-family: var(--font-utility);
  font-size: 14px;
  line-height: 1.4;
  max-width: 509px;
}

.card:nth-child(2),
.card:nth-child(3) {
  justify-content: space-between;
}

.card:nth-child(2) {
  transform: translateY(calc(100vh * (1 - var(--a, 0)) + var(--step) * var(--a, 0)));
  z-index: 2;
}

.card:nth-child(3) {
  transform: translateY(calc(100vh * (1 - var(--b, 0)) + var(--step) * 2 * var(--b, 0)));
  z-index: 3;
}

/* No trailing full stop on card titles (website.02 frames), all breakpoints. Desktop titles are 24px; mobile keeps 18px. */
.card .stop {
  display: none;
}

/* Scroll-linked rise on the compositor, so it follows a finger on iOS without waiting on the main thread.
   Same maths as hero.js (which stands down when this is supported): the track is the first thing on the
   page, so card 2 rises over the first 100vh of scroll and card 3 over the next, eased out cubic. */
@keyframes hero-rise-2 {
  from {
    transform: translateY(100vh);
  }
  to {
    transform: translateY(var(--step));
  }
}

@keyframes hero-rise-3 {
  from {
    transform: translateY(100vh);
  }
  to {
    transform: translateY(calc(var(--step) * 2));
  }
}

@supports (animation-timeline: scroll()) {
  @media (prefers-reduced-motion: no-preference) {
    .card:nth-child(2),
    .card:nth-child(3) {
      animation-fill-mode: both;
      animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
      animation-timeline: scroll(root);
    }

    .card:nth-child(2) {
      animation-name: hero-rise-2;
      animation-range: 0 100vh;
    }

    .card:nth-child(3) {
      animation-name: hero-rise-3;
      animation-range: 100vh 200vh;
    }
  }
}

@media (min-width: 601px) {
  .card h1,
  .card h2 {
    font-size: 24px;
  }
}

@media (max-width: 600px) {
  .deck {
    aspect-ratio: 343 / 595;
    max-height: calc(100vh - 220px);
    max-height: calc(100svh - 220px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .card:nth-child(2) {
    transform: translateY(var(--step));
  }

  .card:nth-child(3) {
    transform: translateY(calc(var(--step) * 2));
  }

  .track {
    height: 100vh;
  }
}
