/*
 * Hero ambient light — touch devices only.
 *
 * Desktop keeps the cursor-reactive canvas; phones and tablets get no canvas
 * at all, just three layers of soft light behind the hero:
 *   ::before              Glow A — accent blue, the main moving light
 *   ::after               Glow B — paler white/blue, larger and slower,
 *                         drifting against Glow A
 *   .hero-ambient-sweep   a broad wash of light crossing every 10s
 *
 * Each glow moves on two independent axes: X through the `translate`
 * property, Y through `transform`, with different periods. Their sum is a
 * Lissajous path that keeps travelling around the hero instead of stopping
 * at keyframe waypoints. Size and intensity breathe on a third period.
 * Only translate/transform/scale/opacity animate, so it all stays on the
 * compositor and never triggers layout.
 *
 * The media query is the exact negation of the JS `finePointer` query in
 * main.js, so the two systems never overlap or leave a gap.
 */

:root {
  --ambient-accent: 15, 82, 255; /* #0F52FF, the design system accent */
}

.hero-ambient {
  display: none;
}

@media not all and (hover: hover) and (pointer: fine) {
  #bg-interactive-canvas {
    display: none;
  }

  [data-hero] {
    isolation: isolate;
  }

  .hero-ambient {
    display: block;
    position: absolute;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
  }

  .hero-ambient::before,
  .hero-ambient::after,
  .hero-ambient-sweep {
    content: '';
    position: absolute;
    will-change: translate, transform, scale, opacity;
  }

  /* Many stops with an ease-out falloff, so no ring or edge is ever visible. */
  .hero-ambient::before {
    --size: min(140vw, 1000px);
    left: calc(50% - var(--size) / 2);
    top: calc(40% - var(--size) / 2);
    width: var(--size);
    height: var(--size);
    background: radial-gradient(
      closest-side,
      rgba(var(--ambient-accent), 0.36),
      rgba(var(--ambient-accent), 0.29) 20%,
      rgba(var(--ambient-accent), 0.18) 40%,
      rgba(var(--ambient-accent), 0.08) 60%,
      rgba(var(--ambient-accent), 0.02) 80%,
      rgba(var(--ambient-accent), 0)
    );
    animation:
      glow-a-x 9s ease-in-out infinite,
      glow-a-y 6s ease-in-out infinite,
      glow-a-breathe 10s ease-in-out infinite;
  }

  .hero-ambient::after {
    --size: min(160vw, 1200px);
    left: calc(50% - var(--size) / 2);
    top: calc(55% - var(--size) / 2);
    width: var(--size);
    height: var(--size);
    background: radial-gradient(
      closest-side,
      rgba(255, 255, 255, 0.55),
      rgba(var(--ambient-accent), 0.12) 35%,
      rgba(var(--ambient-accent), 0.05) 60%,
      rgba(var(--ambient-accent), 0.012) 82%,
      rgba(var(--ambient-accent), 0)
    );
    animation:
      glow-b-x 13s ease-in-out infinite,
      glow-b-y 11s ease-in-out infinite,
      glow-b-breathe 12s ease-in-out infinite;
  }

  /* A wide, soft wash rather than a line: the band is wider than the hero. */
  .hero-ambient-sweep {
    top: -40%;
    bottom: -40%;
    left: 0;
    width: 110%;
    background: linear-gradient(
      90deg,
      rgba(var(--ambient-accent), 0) 0%,
      rgba(var(--ambient-accent), 0.03) 25%,
      rgba(255, 255, 255, 0.45) 48%,
      rgba(var(--ambient-accent), 0.06) 55%,
      rgba(var(--ambient-accent), 0.03) 75%,
      rgba(var(--ambient-accent), 0) 100%
    );
    transform: rotate(18deg);
    translate: -120% 0;
    opacity: 0;
    animation: hero-light-sweep 10s ease-in-out infinite;
  }

  /* Set by HeroAmbient.js while the hero is scrolled out of view. */
  .hero-ambient.is-paused::before,
  .hero-ambient.is-paused::after,
  .hero-ambient.is-paused .hero-ambient-sweep {
    animation-play-state: paused;
  }

  /* Nested rather than appended to the outer query: `not` there would
     negate the whole condition and match every touch device. */
  @media (prefers-reduced-motion: reduce) {
    .hero-ambient::before {
      animation: none;
      opacity: 0.4;
    }

    .hero-ambient::after,
    .hero-ambient-sweep {
      display: none;
    }
  }
}

/* Glow A: sweeps left ↔ right while bobbing up and down 1.5× as often, which
   traces top-left → top-right → centre → lower-centre → left and back. */
@keyframes glow-a-x {
  0%,
  100% {
    translate: -32vw 0;
  }
  50% {
    translate: 32vw 0;
  }
}

@keyframes glow-a-y {
  0%,
  100% {
    transform: translateY(-20vh);
  }
  50% {
    transform: translateY(18vh);
  }
}

@keyframes glow-a-breathe {
  0%,
  100% {
    scale: 0.85;
    opacity: 0.55;
  }
  25% {
    scale: 1.15;
    opacity: 1;
  }
  50% {
    scale: 0.95;
    opacity: 0.62;
  }
  75% {
    scale: 1.1;
    opacity: 0.9;
  }
}

/* Glow B: starts on the opposite side and runs against Glow A, slower. */
@keyframes glow-b-x {
  0%,
  100% {
    translate: 28vw 0;
  }
  50% {
    translate: -30vw 0;
  }
}

@keyframes glow-b-y {
  0%,
  100% {
    transform: translateY(16vh);
  }
  50% {
    transform: translateY(-18vh);
  }
}

@keyframes glow-b-breathe {
  0%,
  100% {
    scale: 1.1;
    opacity: 0.9;
  }
  50% {
    scale: 0.9;
    opacity: 0.5;
  }
}

/* Crosses the hero in 6s, then rests off-screen for 4s. */
@keyframes hero-light-sweep {
  0% {
    translate: -120% 0;
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  48% {
    opacity: 1;
  }
  60% {
    translate: 120% 0;
    opacity: 0;
  }
  100% {
    translate: 120% 0;
    opacity: 0;
  }
}
