/* l3-1 speed tunnel: the void and the light at its end, the walls and rails, the neon frames, the
   warp streaks, near lights out of focus and the sport objects rushing out. Everything is centred
   on the vanishing point (--cx, --cy, the centre of "150%"). Base styles are the still frame
   (no JS, reduced motion); in .is-warp page.mjs draws the moving frames and streaks on a canvas and
   moves the objects with transform and opacity. Only small or few layers move: everything else is
   painted once. All decorative. */

.hero {
  /* side of the square box the tunnel is drawn in: a frame at depth 1 runs just past every corner */
  --tun: max(150vw, 235svh);
  /* frames and rails are drawn this many times smaller and scaled up: their composited layers stay
     small (a frame drawn full size is a layer several screens wide, and ten of them are run). The
     upscale softens a near frame a little, which reads as depth of field. */
  --tun-r: 2.5;
}
@media (max-aspect-ratio: 1 / 1) {
  .hero {
    --tun: max(175svh, 240vw);
  }
}

/* The camera: everything on the screen, so page.mjs can kick it on the number's landing. Its
   content runs far past the screen (rays, rails); the clip keeps it to the screen box, so the
   kick only moves the camera's layer and never repaints the tunnel. The kick zooms in, so the
   clipped edge is always off screen. */
.camera {
  position: absolute;
  inset: 0;
  overflow: clip;
}

/* ------------------------------------------------------------------ void and core */

.void {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 42% 34% at var(--cx) var(--cy), var(--void-hot) 0%, var(--void-0) 100%),
    radial-gradient(
      ellipse 90% 70% at var(--cx) var(--cy),
      var(--void-amber) 0%,
      var(--void-0) 100%
    ),
    var(--ground-deep);
}

.tunnel {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

/* Light at the end of the tunnel: white-hot point, yellow and orange haze. */
.core {
  position: absolute;
  left: var(--cx);
  top: var(--cy);
  width: max(80vmin, 30rem);
  aspect-ratio: 1;
  translate: -50% -50%;
}
.core__glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    closest-side,
    var(--core-white) 0%,
    var(--core-yellow) 5%,
    var(--core-amber) 16%,
    var(--core-hot) 42%,
    var(--core-0) 100%
  );
}

.rays {
  position: absolute;
  left: var(--cx);
  top: var(--cy);
  /* drawn at half size and scaled up: the soft rays lose nothing, the turning layer is 4x smaller */
  width: calc(max(150vmax, 60rem) / 2);
  aspect-ratio: 1;
  translate: -50% -50%;
  scale: 2;
  mask-image: radial-gradient(
    closest-side,
    transparent 4%,
    var(--black) 16%,
    var(--black) 40%,
    transparent 85%
  );
}
.rays__wheel {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: repeating-conic-gradient(var(--ray) 0deg 2deg, var(--ray-0) 2deg 9deg);
}

/* ------------------------------------------------------------------ walls, rails, frames */

.rails,
.ring {
  position: absolute;
  left: var(--cx);
  top: var(--cy);
  width: calc(var(--tun) / var(--tun-r));
  height: calc(var(--tun) / var(--tun-r));
  translate: -50% -50%;
  overflow: visible;
}
.rails {
  scale: var(--tun-r);
}
.o-port {
  display: none;
}
@media (max-aspect-ratio: 1 / 1) {
  .o-land {
    display: none;
  }
  .o-port {
    display: inline;
  }
}

.w-ceil {
  fill: url(#g-ceil);
}
.w-floor {
  fill: url(#g-floor);
}
.w-side {
  fill: url(#g-side);
}
.w-side--low {
  fill: url(#g-floor);
  opacity: 0.6;
}
.lane {
  fill: none;
  stroke: url(#g-lane);
  stroke-width: 0.3;
}
.rail {
  fill: none;
  stroke: url(#g-rail);
  stroke-width: 0.55;
}
.st-rail-0 {
  stop-color: var(--rail-0);
}
.st-rail {
  stop-color: var(--rail);
}
.st-lane {
  stop-color: var(--lane);
}
.st-wall-0 {
  stop-color: var(--wall-0);
}
.st-ceil {
  stop-color: var(--ceil);
}
.st-floor {
  stop-color: var(--floor);
}
.st-side {
  stop-color: var(--side);
}

/* A frame at depth --k (1 = at the viewer). Strokes are in the box's own units, so a near frame
   is thick and a far one a hairline, like in a real perspective. */
.ring {
  scale: calc(var(--k) * var(--tun-r));
  opacity: var(--o);
  stroke-linejoin: round;
  stroke-linecap: round;
}
.r-glow {
  stroke: var(--ring-glow);
  stroke-width: 4.5;
}
.r-mid {
  stroke: var(--ring-mid);
  stroke-width: 1.2;
}
.r-core {
  stroke: var(--ring-core);
  stroke-width: 0.42;
}
.r-dots {
  stroke: var(--ring-dots);
  stroke-width: 1.5;
  stroke-dasharray: 0 4.6;
}
.r-dots-glow {
  stroke: var(--ring-dots-glow);
  stroke-width: 3.6;
  stroke-dasharray: 0 4.6;
}
.r-thin {
  stroke: var(--ring-thin);
  stroke-width: 0.4;
}
.r-hot-glow {
  stroke: var(--ring-hot-glow);
  stroke-width: 6;
}
.r-hot {
  stroke: var(--ring-hot);
  stroke-width: 2;
}
/* Phone: two of the ten frames and half of the streaks stay out. */
@media (max-width: 47.99rem) {
  .ring--x,
  .sl:nth-child(2n) {
    display: none;
  }
}

/* ------------------------------------------------------------------ warp streaks */

/* A thin line of light pointing away from the vanishing point: --a direction, --r distance in
   vmax, --l length. Origin on the inner end. */
.sl {
  position: absolute;
  left: var(--cx);
  top: var(--cy);
  width: 14vmax;
  height: clamp(1.5px, 0.22vmin, 3px);
  border-radius: 2px;
  transform-origin: 0 50%;
  transform: rotate(var(--a)) translateX(calc(var(--r) * 1vmax)) scaleX(var(--l));
  opacity: var(--o);
  background: linear-gradient(90deg, var(--streak-0), var(--streak-mid) 65%, var(--streak-hot));
}

/* ------------------------------------------------------------------ near lights, lens */

/* Lights of the tunnel walls right next to the lens: big soft discs at the rim, under the moving
   tunnel so they are painted once with the ground. */
.bokeh {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle 7vmin at 6% 18%, var(--bk-a) 0 62%, var(--bk-0) 100%),
    radial-gradient(circle 11vmin at 94% 12%, var(--bk-hot) 0 60%, var(--bk-0) 100%),
    radial-gradient(circle 5vmin at 88% 44%, var(--bk-w) 0 62%, var(--bk-0) 100%),
    radial-gradient(circle 9vmin at 4% 58%, var(--bk-w) 0 60%, var(--bk-0) 100%),
    radial-gradient(circle 13vmin at 12% 96%, var(--bk-hot) 0 58%, var(--bk-0) 100%),
    radial-gradient(circle 8vmin at 92% 88%, var(--bk-a) 0 62%, var(--bk-0) 100%),
    radial-gradient(circle 4vmin at 30% 6%, var(--bk-a) 0 62%, var(--bk-0) 100%),
    radial-gradient(circle 4.5vmin at 70% 95%, var(--bk-w) 0 62%, var(--bk-0) 100%);
}

/* Anamorphic lens streak through the end of the tunnel: faint at rest, bright on the entrance. */
.lens {
  position: absolute;
  left: var(--cx);
  top: var(--cy);
  z-index: 2;
  width: 170vw;
  height: clamp(0.75rem, 2.2vmin, 1.5rem);
  translate: -50% -50%;
  background: linear-gradient(
    90deg,
    var(--lens-0),
    var(--lens-soft) 28%,
    var(--lens) 50%,
    var(--lens-soft) 72%,
    var(--lens-0)
  );
  mask-image: linear-gradient(180deg, transparent, var(--black) 46% 54%, transparent);
  opacity: var(--lens-rest);
  pointer-events: none;
}
.whiteout {
  position: absolute;
  inset: 0;
  z-index: 6;
  background: radial-gradient(
    ellipse 60% 55% at var(--cx) var(--cy),
    var(--whiteout),
    var(--whiteout-edge)
  );
  opacity: 0;
  pointer-events: none;
}

/* ------------------------------------------------------------------ objects */

/* No z-index on the container: each object sits behind the copy (2) or in front of it (4). The
   box is drawn at the biggest size an object reaches (--fly * --fly-max) and scaled down. */
.flyers {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.fly {
  position: absolute;
  z-index: 2;
  left: var(--x);
  top: var(--y);
  width: calc(var(--fly) * var(--fly-max));
  aspect-ratio: 1;
  translate: -50% -50%;
  scale: calc(var(--s) / var(--fly-max));
  rotate: calc(var(--r, 0) * 1deg);
  --cast-d: calc(var(--fly) * 0.12);
}
.fly.is-front {
  z-index: 4;
}
.fly img,
.fly__l {
  position: absolute;
  inset: 0;
  width: 100%;
}
.fly img {
  filter: drop-shadow(
    calc(var(--cast-d) * 0.45) var(--cast-d) calc(var(--cast-d) * 0.9) var(--cast)
  );
}
/* out of focus: too far or too near */
.fly.is-soft > img,
.fly .fly__soft {
  filter: blur(calc(var(--fly) * 0.07));
}
/* ghost copy trailing toward the tunnel's end, placed by page.mjs while the object is fast */
.fly .fly__ghost {
  filter: blur(calc(var(--fly) * 0.05));
}
.fly__l--ghost {
  opacity: 0;
}

/* Still frame, landscape: a burst of objects around the number, near ones big and soft. */
.y1 {
  --x: 71%;
  --y: 16%;
  --s: 1.05;
  --r: -8;
}
.y2 {
  --x: 88%;
  --y: 74%;
  --s: 1.75;
  --r: 12;
}
.y3 {
  --x: 25%;
  --y: 19%;
  --s: 1.15;
  --r: -14;
}
.y4 {
  --x: 9%;
  --y: 78%;
  --s: 1.6;
  --r: -22;
}
.y5 {
  --x: 63%;
  --y: 25%;
  --s: 0.5;
  --r: 20;
}
.y6 {
  --x: 37%;
  --y: 11%;
  --s: 0.5;
}
.y7 {
  --x: 86%;
  --y: 38%;
  --s: 1;
}
.y8 {
  --x: 12%;
  --y: 45%;
  --s: 1.15;
  --r: -10;
}
.y9 {
  --x: 24%;
  --y: 66%;
  --s: 0.85;
  --r: -12;
}
.y10 {
  --x: 77%;
  --y: 58%;
  --s: 0.7;
  --r: 14;
}
.y11 {
  --x: 45%;
  --y: 7%;
  --s: 0.42;
}
.y12 {
  --x: 68%;
  --y: 91%;
  --s: 0.8;
  --r: 8;
}

/* Still frame, portrait: objects frame the copy from above and below, one on each side. */
@media (max-aspect-ratio: 1 / 1) {
  .y1 {
    --x: 80%;
    --y: 11%;
    --s: 1.05;
  }
  .y2 {
    --x: 86%;
    --y: 91%;
    --s: 1.55;
  }
  .y3 {
    --x: 18%;
    --y: 12%;
    --s: 1;
  }
  .y4 {
    --x: 11%;
    --y: 89%;
    --s: 1.35;
  }
  .y5 {
    --x: 57%;
    --y: 19%;
    --s: 0.5;
  }
  .y6 {
    --x: 40%;
    --y: 5%;
    --s: 0.42;
  }
  .y7 {
    --x: 95%;
    --y: 52%;
    --s: 0.62;
  }
  .y8 {
    --x: 5%;
    --y: 53%;
    --s: 0.7;
  }
  .y9 {
    --x: 49%;
    --y: 92%;
    --s: 0.72;
  }
  .y10,
  .y11,
  .y12 {
    display: none;
  }
}

/* ------------------------------------------------------------------ live (page.mjs) */

/* page.mjs owns the frames, the streaks and the objects from here on. */
/* The loop draws the frames and streaks on one canvas (page.mjs): the still ones step out. */
.tunnel__cv {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.is-warp :is(.ring, .sl) {
  display: none;
}
/* An object at rest in the pool is hidden and not composited. A flying one is a moving box with
   no paint and no opacity of its own, and three layers in it (ghost, soft copy, sharp copy). The
   filters sit on the images inside the layer boxes, so they are painted into the layers once and
   the compositor never runs them per frame; the loop only moves the box and the ghost and fades
   the layers. */
.is-warp .fly {
  scale: none;
  rotate: none;
  visibility: hidden;
}
.is-warp .fly__l {
  opacity: 0;
}
.is-warp .fly.is-on {
  visibility: visible;
  will-change: transform;
}
.is-warp .fly.is-on > .fly__l {
  will-change: transform, opacity;
}
.is-warp .fly {
  left: var(--cx);
  top: var(--cy);
}

/* The hit of the entrance is over: its layers leave the screen for good. */
html:not([data-intro]) :is(.burst, .whiteout) {
  display: none;
}
.is-pending .lens {
  opacity: 0;
}
[data-intro="running"]
  :is(
    .camera,
    .lens,
    .whiteout,
    .flash,
    .wave,
    .core,
    .offer__lead,
    .offer__free,
    .cta-wrap,
    .num
  ) {
  will-change: transform, opacity;
}
