/* Without script or with reduced motion, the stage is one finished ruby screen. */
.stage {
  position: relative;
  background: var(--ruby-600);
}

.stage__pin {
  position: relative;
  height: 100svh;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.stage__light,
.field {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}

.grainient-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.stage__copy {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 28px;
  padding-inline: var(--margin);
  text-align: center;
  color: var(--on-ruby);
}

.stage__headline {
  display: grid;
  font-size: var(--t-display);
  font-weight: 800;
  letter-spacing: -0.025em;
}

/* The long question must stay two lines on a phone, so the size follows the screen width here. */
@media (max-width: 600px) {
  .stage__headline {
    font-size: 9.4vw;
    text-wrap: balance;
  }
}

.stage__headline span {
  grid-area: 1 / 1;
}

.stage__beat-one {
  visibility: hidden;
}

.stage__after {
  display: grid;
  justify-items: center;
  gap: 28px;
}

.stage__lead {
  max-width: 620px;
  font-size: var(--t-lead);
  line-height: 1.4;
}

.stage__melt {
  position: absolute;
  inset: auto 0 0;
  height: 100%;
  /* Passing through pale ruby: fading dark ruby straight to white turns it muddy grey. */
  background: linear-gradient(to bottom, rgb(245 140 166 / 0), rgb(251 234 239 / 0.92) 65%, var(--bg) 100%);
  opacity: 0;
  pointer-events: none;
}

/* The scroll scene: script adds this class, and drives the variables below. */
.stage-live .stage {
  height: 340vh;
  background: var(--bg);
}

.stage-live .stage__pin {
  position: sticky;
  top: 0;
}

.stage-live .stage__beat-one {
  visibility: visible;
  color: color-mix(in srgb, var(--on-ruby) calc(var(--covered, 0) * 100%), var(--ink));
  opacity: var(--one-in, 1);
  transform: translateY(calc((1 - var(--one-in, 1)) * -28px));
}

.stage-live .stage__beat-two {
  opacity: var(--two-in, 0);
  transform: translateY(calc((1 - var(--two-in, 0)) * 28px));
}

.stage-live .stage__after {
  opacity: var(--after-in, 0);
  transform: translateY(calc((1 - var(--after-in, 0)) * 24px));
}

.stage-live .stage .field {
  opacity: var(--field-in, 0);
}

.stage-live .stage__melt {
  opacity: var(--melt, 0);
}

.stage-live .stage__copy {
  /* Until the text below appears, the headline alone sits on the true centre of the screen. */
  transform: translateY(calc((1 - var(--after-in, 0)) * var(--lift, 0px) + var(--melt, 0) * -14vh));
}

.stage__beat-one {
  animation: first-words 1100ms var(--ease) both;
}

@keyframes first-words {
  from {
    clip-path: inset(0 0 100% 0);
    translate: 0 30%;
  }
  to {
    clip-path: inset(-20%);
    translate: 0 0;
  }
}

.sample__text:not([hidden]) {
  animation: settle 450ms var(--ease) both;
}

@keyframes settle {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

.tip:not([hidden]) {
  animation: settle 220ms var(--ease) both;
}

.js .reveal {
  opacity: 0;
  transform: translateY(40px);
  transition:
    opacity 900ms var(--ease),
    transform 900ms var(--ease);
}

.js .reveal.is-in {
  opacity: 1;
  transform: none;
}

/* Scrolling acts out the promise: the hard word fades, the easy one lights up. */
@supports (animation-timeline: view()) {
  .words__hard {
    animation: hard-fades linear both;
    animation-timeline: view();
    animation-range: cover 25% cover 60%;
  }

  .words__easy {
    animation: easy-lights linear both;
    animation-timeline: view();
    animation-range: cover 25% cover 60%;
  }

  @keyframes hard-fades {
    to {
      opacity: 0.12;
      filter: blur(5px);
    }
  }

  @keyframes easy-lights {
    from {
      opacity: 0.12;
    }
    to {
      color: var(--ruby-600);
    }
  }

  .band img {
    animation: picture-settles linear both;
    animation-timeline: view();
    animation-range: entry 0% cover 45%;
  }

  @keyframes picture-settles {
    from {
      opacity: 0.5;
      transform: scale(0.94);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .js .reveal {
    opacity: 1;
    transform: none;
  }
}
