/* ===================================
   druzy.sh — CRT overlay
   Scanlines + sweep + flicker + vignette.
   Technique: aleclownes.com/2017/02/01/crt-display.html
   Reduced motion: static scanlines only, no animation.
   =================================== */

.crt-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 900;
}

/* Scanlines: repeating horizontal darkening */
.crt-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0, 0, 0, 0.12) 2px,
    rgba(0, 0, 0, 0.12) 3px
  );
  mix-blend-mode: multiply;
}

/* Vignette: soft CRT edge darkening */
.crt-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at center,
    transparent 55%,
    rgba(0, 0, 0, 0.18) 88%,
    rgba(0, 0, 0, 0.32) 100%
  );
}

/* Moving scanline sweep — one pass every ~9s, out of view most of the time */
.crt-sweep {
  position: absolute;
  left: 0;
  right: 0;
  height: 120px;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(120, 255, 150, 0.045) 40%,
    rgba(120, 255, 150, 0.08) 50%,
    rgba(120, 255, 150, 0.045) 60%,
    transparent 100%
  );
  animation: crtSweep 9s linear infinite;
  top: -140px;
}

@keyframes crtSweep {
  0%   { top: -140px; }
  80%  { top: -140px; }
  100% { top: 100%; }
}

/* Subtle full-screen flicker (toned far down from the original) */
.crt-flicker {
  position: absolute;
  inset: 0;
  background: rgba(140, 255, 160, 0.015);
  animation: crtFlicker 4s infinite;
}

@keyframes crtFlicker {
  0%   { opacity: 0.55; }
  8%   { opacity: 0.70; }
  12%  { opacity: 0.40; }
  22%  { opacity: 0.65; }
  36%  { opacity: 0.50; }
  48%  { opacity: 0.80; }
  60%  { opacity: 0.45; }
  72%  { opacity: 0.68; }
  86%  { opacity: 0.52; }
  100% { opacity: 0.55; }
}

/* Chromatic aberration on display text (headings, ascii) — static, subtle */
.crt-chroma {
  text-shadow:
    0.4px 0 0.5px rgba(0, 255, 120, 0.25),
    -0.4px 0 0.5px rgba(255, 0, 80, 0.18),
    0 0 6px rgba(44, 255, 86, 0.20);
}

/* Scramble decode ghosts (scramble.js): mid-decode chars read as dim
   phosphor, not full-bright, so the resolved text pops. Static, RM-safe. */
.scr-ghost {
  opacity: 0.5;
  color: var(--accent-dim, rgba(44, 255, 86, 0.55));
}

/* Selection — green block, like a terminal */
::selection {
  background: #2CFF56;
  color: #060807;
}

/* Focus visible — blocky accent outline */
:focus-visible {
  outline: 2px solid var(--accent, #2CFF56);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .crt-sweep,
  .crt-flicker {
    display: none;
  }
}
