/* Homepage rotoscope 3D layer. Loaded only on the home page. */

.is-home {
  --roto-rx: 0deg;
  --roto-ry: 0deg;
  --hero-x: 0px;
  --hero-y: 0px;
}

.home-stage {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  mix-blend-mode: screen;
  transition: opacity 480ms ease;
}

.is-home.has-webgl .home-stage {
  opacity: 1;
}

.is-home.has-webgl .stories-grid,
.is-home.has-webgl .coverage-grid,
.is-home.has-webgl .about,
.is-home.has-webgl .youtube {
  perspective: 1200px;
}

.is-home.has-webgl .hero__art {
  transform: scale(1.04) translate3d(var(--art-x, 0px), var(--art-y, 0px), 0);
  will-change: transform;
}

.is-home.has-webgl .hero__content {
  position: relative;
  z-index: 3;
  padding-block: 28px 32px;
}

.is-home.has-webgl [data-hero-copy] {
  transform: translate3d(var(--hero-x), var(--hero-y), 0);
}

.is-home.has-webgl .hero__actions {
  position: relative;
  z-index: 4;
}

@media (max-height: 780px) {
  .is-home.has-webgl .hero__content {
    padding-block: 20px 22px;
  }

  .is-home.has-webgl .hero h1 {
    font-size: clamp(34px, 5vw, 64px);
  }

  .is-home.has-webgl .hero__lede {
    margin-top: 14px;
  }

  .is-home.has-webgl .hero__actions {
    margin-top: 18px;
  }
}

.is-home.has-webgl [data-tilt] {
  --tilt-x: 0px;
  --tilt-y: 0px;
  --tilt-rx: 0deg;
  --tilt-ry: 0deg;
  --tilt-z: 0px;
  transform:
    translate3d(var(--tilt-x), var(--tilt-y), var(--tilt-z))
    rotateX(var(--tilt-rx))
    rotateY(var(--tilt-ry));
  transform-style: preserve-3d;
  transition:
    transform 220ms cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 220ms ease,
    border-color 180ms ease;
}

.is-home.has-webgl .story-card:hover {
  transform:
    translate3d(calc(var(--tilt-x) - 3px), calc(var(--tilt-y) - 3px), 22px)
    rotateX(var(--tilt-rx))
    rotateY(var(--tilt-ry));
}

.is-home.has-webgl .coverage-tile:hover {
  transform:
    translate3d(var(--tilt-x), calc(var(--tilt-y) - 6px), 18px)
    rotateX(var(--tilt-rx))
    rotateY(var(--tilt-ry));
}

.is-home.has-webgl .tools-cta:hover,
.is-home.has-webgl .about__portrait:hover,
.is-home.has-webgl .youtube__screen:hover {
  transform:
    translate3d(var(--tilt-x), var(--tilt-y), 16px)
    rotateX(var(--tilt-rx))
    rotateY(var(--tilt-ry));
}

.is-home.has-webgl .about__portrait {
  transform:
    translate3d(var(--tilt-x), var(--tilt-y), var(--tilt-z))
    rotateX(var(--tilt-rx))
    rotateY(var(--tilt-ry))
    rotate(-2deg);
}

.is-home.has-webgl .about__portrait:hover {
  transform:
    translate3d(var(--tilt-x), var(--tilt-y), 20px)
    rotateX(var(--tilt-rx))
    rotateY(var(--tilt-ry))
    rotate(-2deg);
}

@supports (animation-timeline: view()) {
  .is-home.has-webgl .story-card,
  .is-home.has-webgl .coverage-tile,
  .is-home.has-webgl .tools-cta,
  .is-home.has-webgl .about__portrait,
  .is-home.has-webgl .youtube {
    animation: roto-enter linear both;
    animation-timeline: view();
    animation-range: entry 0% cover 28%;
  }
}

@keyframes roto-enter {
  from { opacity: 0.45; }
  to { opacity: 1; }
}

.roto-ripples {
  position: fixed;
  inset: 0;
  z-index: 18;
  pointer-events: none;
  overflow: hidden;
}

.roto-ripple {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.4);
  opacity: 0.9;
  animation: roto-ripple 720ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--sun) 55%, transparent);
}

.roto-ripple--ink {
  border-color: #f8f2dc;
  animation-duration: 920ms;
}

@keyframes roto-ripple {
  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(18);
  }
}

.is-home.has-webgl .pixel-button:active {
  transform: translate(3px, 3px) scale(0.98);
}

@media (max-width: 680px) {
  .is-home.has-webgl [data-tilt] {
    --tilt-rx: 0deg !important;
    --tilt-ry: 0deg !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .home-stage,
  .roto-ripples {
    display: none;
  }

  .is-home.has-webgl [data-tilt],
  .is-home.has-webgl .story-card:hover,
  .is-home.has-webgl .coverage-tile:hover,
  .is-home.has-webgl .tools-cta:hover,
  .is-home.has-webgl .about__portrait,
  .is-home.has-webgl .about__portrait:hover,
  .is-home.has-webgl .youtube__screen:hover,
  .is-home.has-webgl .hero__content,
  .is-home.has-webgl [data-hero-copy] {
    transform: none;
    animation: none;
  }
}
