/* Antiphon v2 · The Institute — WebGL observation light & fallback */

#light-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 600ms ease;
}

body[data-light="on"] #light-canvas {
  opacity: 0.9;
}

body[data-light="off"] #light-canvas,
body[data-light="fallback"] #light-canvas {
  opacity: 0;
}

/* static twin of the shader: sparse embers + paper grain + aperture vignette */

#light-fallback {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: none;
  pointer-events: none;
  opacity: 0.5;
  background-color: transparent;
  background-image:
    radial-gradient(circle at 50% 50%, rgba(194, 102, 60, 0.26) 0 1px, transparent 1.5px),
    repeating-linear-gradient(0deg, rgba(21, 20, 15, 0.045) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at 50% 46%, rgba(21, 20, 15, 0) 46%, rgba(21, 20, 15, 0.2) 100%);
  background-size: 46px 46px, 100% 3px, 100% 100%;
  background-repeat: repeat, repeat, no-repeat;
}

body[data-mode="night"] #light-fallback {
  opacity: 0.8;
  /* on a black desk the 3px scanline would read as a screen, so at night it
     drops to 0.02 and behaves like grain in the emulsion instead */
  background-image:
    radial-gradient(circle at 50% 50%, rgba(224, 140, 107, 0.32) 0 1px, transparent 1.5px),
    repeating-linear-gradient(0deg, rgba(242, 237, 227, 0.02) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at 50% 46%, rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, 0.5) 100%);
}

body[data-light="fallback"] #light-fallback {
  display: block;
}

body[data-light="fallback"] #light-btn {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  #light-canvas {
    transition: none;
  }
}
