/* ─── overlays.css ─────────────────────────────────────────────────────────────
   Canvas backgrounds, CRT atmospheric overlays, and click pulse.
   All animations use transform/opacity only — zero layout triggers.
──────────────────────────────────────────────────────────────────────────── */

/* ─── Surveillance Network Canvas ───────────────────────────────────────── */
#bg-canvas {
  position: fixed;
  inset: 0;
  z-index: var(--z-bg);   /* 0 — behind all overlays */
  pointer-events: none;
  /* Opacity managed by IntroSequence — starts 0, fades to 1 in State D */
  transition: opacity 1.4s ease;
}

/* ─── Intro FX Canvas ────────────────────────────────────────────────────── */
/* Draws TV static (State B) and black cutaway (State C).
   z=11 covers terminal (z=10); tx-alert (z=20) floats above it.            */
#fx-canvas {
  position: fixed;
  inset: 0;
  z-index: 11;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}

/* ─── Click Pulse ─────────────────────────────────────────────────────────
   Faint expanding ring at click origin.
   Position: --pulse-x / --pulse-y set by surveillance.js.
   GPU only: transform + opacity.
──────────────────────────────────────────────────────────────────────────── */
body::after {
  content: '';
  position: fixed;
  left: 0;
  top: 0;
  width: 220px;
  height: 220px;
  margin-left: -110px;
  margin-top:  -110px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  border: 1px solid rgba(127, 170, 108, 0.22);
  opacity: 0;
  transform: translate(var(--pulse-x, 50vw), var(--pulse-y, 50vh)) scale(0.1);
}

body.bg-pulse::after {
  animation: bg-pulse-anim 0.6s cubic-bezier(0.15, 0.6, 0.35, 1) forwards;
}

@keyframes bg-pulse-anim {
  from {
    opacity: 0.55;
    transform: translate(var(--pulse-x, 50vw), var(--pulse-y, 50vh)) scale(0.1);
  }
  to {
    opacity: 0;
    transform: translate(var(--pulse-x, 50vw), var(--pulse-y, 50vh)) scale(2.0);
  }
}

/* ─── CRT Grain / Static Noise ───────────────────────────────────────────── */
#overlay-grain {
  position: fixed;
  inset: 0;
  z-index: var(--z-grain);
  pointer-events: none;
  opacity: 0.028;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

/* ─── Scanlines ──────────────────────────────────────────────────────────── */
#overlay-scanlines {
  position: fixed;
  inset: 0;
  z-index: var(--z-scanlines);
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent                             0px,
    transparent                             3px,
    rgba(0, 0, 0, var(--scanline-opacity))  3px,
    rgba(0, 0, 0, var(--scanline-opacity))  4px
  );
}

/* ─── Vignette ───────────────────────────────────────────────────────────── */
#overlay-vignette {
  position: fixed;
  inset: 0;
  z-index: var(--z-vignette);
  pointer-events: none;
  background: radial-gradient(
    ellipse at 50% 50%,
    transparent                              32%,
    rgba(0, 0, 0, 0.36)                      62%,
    rgba(0, 0, 0, var(--vignette-strength)) 100%
  );
}

/* ─── Reduced Motion ─────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  body::after { animation: none !important; }
  #bg-canvas, #fx-canvas { transition: none !important; }
}
