/* Scroll entrances are prepared by intro.js so every block follows one motion system. */
@keyframes hero-copy-enter {
  from {
    opacity: 0;
    transform: translate3d(0, 16px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes hero-action-enter {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* The first viewport cannot wait for deferred JavaScript on slower phones. */
.enhanced .hero-copy > .intro > *,
.enhanced .hero-copy > .hero-links > * {
  animation: hero-copy-enter 700ms var(--ease) backwards;
}

.enhanced .hero-copy > .actions > * {
  animation: hero-action-enter 700ms var(--ease) backwards;
}

.enhanced .hero-copy > .intro > :nth-child(2) { animation-delay: 45ms; }
.enhanced .hero-copy > .intro > :nth-child(3) { animation-delay: 90ms; }
.enhanced .hero-copy > .intro > :nth-child(n + 4) { animation-delay: 135ms; }
.enhanced .hero-copy > .actions > :nth-child(1) { animation-delay: 180ms; }
.enhanced .hero-copy > .actions > :nth-child(2) { animation-delay: 220ms; }
.enhanced .hero-copy > .hero-links > :nth-child(1) { animation-delay: 260ms; }
.enhanced .hero-copy > .hero-links > :nth-child(n + 2) { animation-delay: 300ms; }

.enhanced :is(.motion-reveal, .fade-in, .fade-up, .fade-left, .fade-right) {
  --motion-from: translate3d(0, 16px, 0);
  --motion-duration: 700ms;
  opacity: 0;
  transform: var(--motion-from);
  transition:
    opacity var(--motion-duration) var(--ease),
    transform var(--motion-duration) var(--ease);
  transition-delay: var(--anim-delay, 0ms);
}

/* Commit the hidden starting state before enabling transitions on initial load. */
.enhanced.motion-preparing .hero-media {
  opacity: 0;
  transform: translate3d(0, 10px, 0) scale(0.985);
}

.enhanced.motion-preparing :is(.motion-reveal, .fade-in, .fade-up, .fade-left, .fade-right) {
  transition: none;
}

.enhanced :is(.motion-fade, .fade-in) {
  --motion-from: translate3d(0, 0, 0);
}

.enhanced :is(.motion-left, .fade-left) {
  --motion-from: translate3d(-20px, 0, 0);
}

.enhanced :is(.motion-right, .fade-right) {
  --motion-from: translate3d(20px, 0, 0);
}

.enhanced .motion-scale {
  --motion-from: translate3d(0, 10px, 0) scale(0.985);
  --motion-duration: 760ms;
}

.enhanced :is(.motion-reveal, .fade-in, .fade-up, .fade-left, .fade-right).is-animated {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
}

/* Entrance motion must not replace the interaction transitions of controls. */
.enhanced :is(a, button, .icon-button):is(.motion-reveal, .fade-in, .fade-up, .fade-left, .fade-right) {
  transition:
    opacity var(--motion-duration) var(--ease),
    transform var(--motion-duration) var(--ease),
    background-color var(--duration) ease,
    border-color var(--duration) ease,
    color var(--duration) ease;
  transition-delay: var(--anim-delay, 0ms), var(--anim-delay, 0ms), 0ms, 0ms, 0ms;
}

.enhanced :is(.button, .icon-button):is(.motion-reveal, .fade-in, .fade-up, .fade-left, .fade-right).is-animated:active {
  transform: scale(0.97);
}

@media (hover: hover) and (pointer: fine) {
  .enhanced .button:is(.motion-reveal, .fade-in, .fade-up, .fade-left, .fade-right).is-animated:hover {
    transform: translateY(-2px);
  }

  .enhanced .button:is(.motion-reveal, .fade-in, .fade-up, .fade-left, .fade-right).is-animated:active {
    transform: translateY(0) scale(0.97);
  }
}

/* Horizontal carousels keep their vertical position stable under a finger. */
@media (max-width: 991px) {
  .enhanced .cards-scroll > :is(.motion-reveal, .fade-in, .fade-up, .fade-left, .fade-right) {
    --motion-from: translate3d(0, 0, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .enhanced .hero-copy > .intro > *,
  .enhanced .hero-copy > .actions > *,
  .enhanced .hero-copy > .hero-links > * {
    animation: none;
  }

  .enhanced :is(.motion-reveal, .fade-in, .fade-up, .fade-left, .fade-right) {
    --motion-from: translate3d(0, 0, 0);
    --motion-duration: 200ms;
    transition-delay: 0ms;
  }
}
