/* The background grid of the heroes, in the language of the InfraCanvas home hero (P11-13): a faint square
   grid in the Qizil line colour that fades toward the edges, and a cursor spotlight in which the lines
   brighten into the dusk gradient (--q-grad-brand) with a soft glow. The spotlight sits at --mx/--my, which
   js/spotlight.js sets through the CSSOM while a fine pointer moves over the hero; the eased follow is a
   transition of the registered properties, so nothing animates while the pointer is still. Without script,
   on touch screens and under reduced motion only the static grid shows. Tokens only. */

@property --mx {
  syntax: "<length>";
  inherits: true;
  initial-value: -480px;
}

@property --my {
  syntax: "<length>";
  inherits: true;
  initial-value: -480px;
}

.grid-bg {
  --grid-size: 40px;
  --spot-radius: 240px;
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  /* Strongest behind the headline, gone toward the edges. */
  mask-image: radial-gradient(ellipse 80% 75% at 40% 30%, var(--q-fg) 25%, transparent 80%);
}

.grid-bg[data-spot="on"] {
  transition:
    --mx 220ms var(--q-ease),
    --my 220ms var(--q-ease);
}

.grid-bg__lines,
.grid-bg__spot,
.grid-bg__glow,
.grid-bg__tint {
  position: absolute;
  inset: 0;
}

.grid-bg__lines {
  background-image:
    linear-gradient(to right, var(--q-border) 1px, transparent 1px),
    linear-gradient(to bottom, var(--q-border) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
  background-position: center top;
}

/* The spotlight: everything inside shows only within the radius around the pointer. */
.grid-bg__spot {
  opacity: 0;
  transition: opacity 320ms var(--q-ease);
  mask-image: radial-gradient(
    circle var(--spot-radius) at var(--mx) var(--my),
    var(--q-fg) 0%,
    color-mix(in srgb, var(--q-fg) 45%, transparent) 45%,
    transparent 100%
  );
}

.grid-bg[data-spot="on"] .grid-bg__spot,
.grid-bg[data-spot="arming"] .grid-bg__spot {
  opacity: 1;
}

.grid-bg__glow {
  background: radial-gradient(
    circle calc(var(--spot-radius) * 0.8) at var(--mx) var(--my),
    color-mix(in srgb, var(--q-grad-dusk-2) 12%, transparent),
    transparent 70%
  );
}

/* The grid lines again, painted with the dusk gradient: the brand gradient masked by the lines. */
.grid-bg__tint {
  background: var(--q-grad-brand);
  opacity: 0.65;
  mask-image:
    linear-gradient(to right, var(--q-fg) 1px, transparent 1px),
    linear-gradient(to bottom, var(--q-fg) 1px, transparent 1px);
  mask-size: var(--grid-size) var(--grid-size);
  mask-position: center top;
}

@media (prefers-reduced-motion: reduce), (hover: none), (pointer: coarse) {
  .grid-bg__spot {
    display: none;
  }
}

/* The footer's "Reduce motion" (data-motion="off"): the same as reduced motion. */
:root[data-motion="off"] .grid-bg__spot {
  display: none;
}

@media (forced-colors: active) {
  .grid-bg {
    display: none;
  }
}

@media print {
  .grid-bg {
    display: none;
  }
}
