/* CRT Monitor Styles */

:root {
  /* Default values, will be overridden by JS */
  --terminal-scale: 1;
  --terminal-width: 720px;
  --terminal-height: 480px;
  /* Base dimensions (unscaled) */
  --base-screen-padding: 30px;
  --base-frame-padding: 30px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #1a1a1a;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: 'Courier New', monospace;
  overflow: hidden;
}

/* CRT Container */
.crt-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Monitor Frame - 1994 Beige CRT Style */
.monitor-frame {
  background: linear-gradient(180deg, #d4d0c4 0%, #c8c4b8 50%, #b8b4a8 100%);
  border-radius: 8px 8px 4px 4px;
  padding: calc(30px * var(--terminal-scale)) calc(30px * var(--terminal-scale)) calc(15px * var(--terminal-scale)) calc(30px * var(--terminal-scale));
  border: 3px solid #a8a498;
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.5),
    inset 0 2px 0 rgba(255, 255, 255, 0.4),
    inset 0 -2px 0 rgba(0, 0, 0, 0.15),
    inset 2px 0 0 rgba(255, 255, 255, 0.2),
    inset -2px 0 0 rgba(0, 0, 0, 0.1);
}

/* Screen Container - Deep Inset Bezel */
.screen-container {
  position: relative;
  width: calc(var(--terminal-width) + 20px * var(--terminal-scale));
  height: calc(var(--terminal-height) + 10px * var(--terminal-scale));
  background: #000;
  border-radius: 4px;
  overflow: hidden;
  box-shadow:
    inset 0 0 50px rgba(0, 0, 0, 0.5),
    inset 0 0 10px rgba(0, 0, 0, 0.8),
    0 0 0 4px #1a1a1a,
    0 0 0 6px #0a0a0a,
    0 0 0 8px #2a2a2a;
}

/* Terminal Container */
#terminal {
  position: absolute;
  top: calc(5px * var(--terminal-scale));
  left: calc(10px * var(--terminal-scale));
  right: calc(10px * var(--terminal-scale));
  bottom: calc(5px * var(--terminal-scale));
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* PixiJS Canvas Styles */
#terminal canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* CRT Overlay Effects */
.crt-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

/* Scanlines */
.scanlines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.15),
    rgba(0, 0, 0, 0.15) 1px,
    transparent 1px,
    transparent 2px
  );
  animation: scanline-scroll 10s linear infinite;
}

@keyframes scanline-scroll {
  0% { transform: translateY(0); }
  100% { transform: translateY(4px); }
}

/* Screen Flicker */
.flicker {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  animation: flicker 0.15s infinite;
  opacity: 0.02;
}

@keyframes flicker {
  0%, 100% { opacity: 0.02; }
  50% { opacity: 0.04; }
}

/* Vignette */
.vignette {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(
    ellipse at center,
    transparent 60%,
    rgba(0, 0, 0, 0.4) 100%
  );
}

/* Screen weathering - subtle dust and aging effects */
.screen-dirt {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  /* Subtle dust spots and smudges */
  background:
    /* Corner dust accumulation - top left */
    radial-gradient(ellipse at 5% 8%, rgba(80, 70, 60, 0.03) 0%, transparent 25%),
    /* Corner dust - top right */
    radial-gradient(ellipse at 92% 5%, rgba(70, 65, 55, 0.025) 0%, transparent 20%),
    /* Bottom edge dust */
    radial-gradient(ellipse at 15% 95%, rgba(75, 68, 58, 0.02) 0%, transparent 30%),
    /* Slight center-bottom smudge (from cleaning) */
    radial-gradient(ellipse at 50% 88%, rgba(60, 55, 50, 0.015) 0%, transparent 35%),
    /* Faint fingerprint smudge - right side */
    radial-gradient(ellipse at 85% 60%, rgba(70, 65, 55, 0.012) 0%, transparent 15%);
}

/* Subtle phosphor aging - very faint burn-in at corners */
.screen-aging {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  /* Slight phosphor degradation at edges */
  background: radial-gradient(
    ellipse at center,
    transparent 70%,
    rgba(20, 18, 15, 0.08) 100%
  );
  /* Barely visible uneven aging */
  mask-image:
    radial-gradient(ellipse at 30% 20%, black 0%, transparent 60%),
    radial-gradient(ellipse at 70% 80%, black 0%, transparent 50%);
  mask-composite: intersect;
  -webkit-mask-image:
    radial-gradient(ellipse at 30% 20%, black 0%, transparent 60%),
    radial-gradient(ellipse at 70% 80%, black 0%, transparent 50%);
  -webkit-mask-composite: source-in;
}

/* Noise */
.noise {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%' height='100%' filter='url(%23noise)'/%3E%3C/svg%3E");
  opacity: 0.03;
  animation: noise 0.5s steps(10) infinite;
}

@keyframes noise {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-1%, -1%); }
  20% { transform: translate(1%, 1%); }
  30% { transform: translate(-1%, 1%); }
  40% { transform: translate(1%, -1%); }
  50% { transform: translate(-1%, 0); }
  60% { transform: translate(1%, 0); }
  70% { transform: translate(0, 1%); }
  80% { transform: translate(0, -1%); }
  90% { transform: translate(1%, 1%); }
}

/* Power Off Screen */
.power-off-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 20;
}

.power-off-screen.active {
  display: flex;
}

/* Already off on page load - just show black, hide the effect elements */
.power-off-screen.immediate .power-off-dot {
  display: none;
}

/* CRT power-off line effect */
.power-off-dot {
  position: absolute;
  width: 100%;
  height: 100%;
  background: #111;
  animation: crt-collapse 0.5s ease-out forwards;
}

.power-off-dot::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 2px;
  background: #4a9;
  box-shadow: 0 0 10px #4a9, 0 0 20px #4a9, 0 0 40px #4a9;
  transform: translateY(-50%);
  animation: line-fade 1.5s ease-out 0.3s forwards;
}

@keyframes crt-collapse {
  0% {
    clip-path: inset(0 0 0 0);
    background: #111;
  }
  100% {
    clip-path: inset(49% 0 49% 0);
    background: #000;
  }
}

@keyframes line-fade {
  0% {
    opacity: 1;
    box-shadow: 0 0 10px #4a9, 0 0 20px #4a9, 0 0 40px #4a9;
  }
  100% {
    opacity: 0;
    box-shadow: 0 0 5px #4a9, 0 0 10px #4a9;
  }
}

/* Front Panel - Beige Plastic */
.front-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: calc(12px * var(--terminal-scale));
  padding: calc(10px * var(--terminal-scale)) calc(20px * var(--terminal-scale));
  background: linear-gradient(180deg, #c8c4b8 0%, #bab6aa 100%);
  border-radius: 3px;
  border-top: 1px solid rgba(255, 255, 255, 0.3);
  border-bottom: 1px solid rgba(0, 0, 0, 0.15);
}

.panel-left {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 15px;
}

.model-text {
  color: #5a5a50;
  font-size: calc(10px * var(--terminal-scale));
  letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* Adjustment Knobs */
.knob-group {
  display: flex;
  gap: 10px;
}

.knob-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.knob {
  width: calc(20px * var(--terminal-scale));
  height: calc(20px * var(--terminal-scale));
  border-radius: 50%;
  background: linear-gradient(145deg, #4a4a4a, #2a2a2a);
  border: 2px solid #3a3a3a;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.3),
    inset 0 1px 1px rgba(255, 255, 255, 0.1);
  position: relative;
}

.knob::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 6px;
  background: #888;
  border-radius: 1px;
}

.knob-interactive {
  cursor: grab;
  transition: box-shadow 0.15s ease;
}

.knob-interactive:hover {
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.3),
    inset 0 1px 1px rgba(255, 255, 255, 0.15),
    0 0 6px rgba(255, 255, 255, 0.08);
}

.knob-interactive:active,
.knob-interactive.dragging {
  cursor: grabbing;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.4),
    inset 0 1px 1px rgba(255, 255, 255, 0.1);
}

.knob-interactive::after {
  background: #aaa;
}

.knob-label {
  color: #5a5a50;
  font-size: calc(7px * var(--terminal-scale));
  letter-spacing: 0.5px;
  text-transform: uppercase;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

.panel-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.led-group {
  display: flex;
  gap: 20px;
}

.led-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.led {
  width: calc(8px * var(--terminal-scale));
  height: calc(8px * var(--terminal-scale));
  border-radius: 50%;
  background: #333;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
  transition: all 0.1s ease;
}

.led.on {
  box-shadow:
    0 0 5px currentColor,
    0 0 10px currentColor,
    inset 0 0 3px rgba(255, 255, 255, 0.3);
}

.led-power {
  color: #0f0;
}

.led-power.on {
  background: #0f0;
}

.led-hdd {
  color: #f90;
}

.led-hdd.on {
  background: #f90;
}

.led-network {
  color: #09f;
}

.led-network.on {
  background: #09f;
}

.led-label {
  color: #5a5a50;
  font-size: calc(8px * var(--terminal-scale));
  letter-spacing: 1px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

.panel-right {
  flex: 1;
  display: flex;
  justify-content: flex-end;
}

/* Power Button - Rectangular Rocker Switch */
.power-button {
  width: calc(40px * var(--terminal-scale));
  height: calc(24px * var(--terminal-scale));
  border: none;
  border-radius: 3px;
  background: linear-gradient(180deg, #4a4a4a 0%, #2a2a2a 50%, #3a3a3a 100%);
  color: #aaa;
  font-size: calc(10px * var(--terminal-scale));
  font-family: 'Arial', sans-serif;
  font-weight: bold;
  cursor: pointer;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    inset 0 -1px 0 rgba(0, 0, 0, 0.3);
  transition: all 0.1s ease;
  border: 1px solid #222;
}

.power-button:hover {
  background: linear-gradient(180deg, #5a5a5a 0%, #3a3a3a 50%, #4a4a4a 100%);
  color: #ccc;
}

.power-button:active {
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.4),
    inset 0 2px 4px rgba(0, 0, 0, 0.4);
  transform: translateY(1px);
}

.power-text {
  display: inline-block;
  letter-spacing: 1px;
}

/* Monitor Stand - Chunky Beige Tilt Base */
.monitor-stand {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stand-neck {
  width: calc(80px * var(--terminal-scale));
  height: calc(25px * var(--terminal-scale));
  background: linear-gradient(90deg, #b8b4a8, #c8c4b8, #b8b4a8);
  border-left: 2px solid rgba(0, 0, 0, 0.1);
  border-right: 2px solid rgba(0, 0, 0, 0.1);
}

.stand-base {
  width: calc(260px * var(--terminal-scale));
  height: calc(20px * var(--terminal-scale));
  background: linear-gradient(180deg, #c8c4b8 0%, #b8b4a8 50%, #a8a498 100%);
  border-radius: 0 0 8px 8px;
  box-shadow:
    0 5px 15px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  border: 2px solid #a8a498;
  border-top: none;
}

/* Connection Status */
.connection-status {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 20px;
  color: #aaa;
  font-size: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f90;
  animation: pulse 1s infinite;
}

.connection-status.connected .status-dot {
  background: #0f0;
  animation: none;
}

.connection-status.disconnected .status-dot {
  background: #f00;
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* CRT Decay Levels */
.screen-container.decay-1 .scanlines {
  opacity: 0.2;
}

.screen-container.decay-2 .scanlines {
  opacity: 0.25;
}

.screen-container.decay-2 .flicker {
  animation-duration: 0.1s;
  opacity: 0.03;
}

.screen-container.decay-3 .scanlines {
  opacity: 0.3;
}

.screen-container.decay-3 .flicker {
  animation-duration: 0.08s;
  opacity: 0.05;
}

.screen-container.decay-3::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 0, 0, 0.02) 25%,
    transparent 50%,
    rgba(0, 255, 0, 0.02) 75%,
    transparent 100%
  );
  animation: color-shift 5s linear infinite;
  pointer-events: none;
  z-index: 11;
}

@keyframes color-shift {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Pause all CRT animations when power is off or tab is hidden */
.crt-paused .crt-overlay,
.crt-paused .scanlines,
.crt-paused .flicker,
.crt-paused .noise {
  animation-play-state: paused !important;
}

/* Volume OSD - TV-style overlay */
.volume-osd {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid rgba(0, 255, 0, 0.3);
  border-radius: 2px;
  z-index: 15;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.volume-osd.visible {
  opacity: 1;
}

.volume-osd-label {
  color: #0f0;
  font-family: 'Courier New', monospace;
  font-size: calc(11px * var(--terminal-scale));
  font-weight: bold;
  letter-spacing: 1px;
  text-shadow: 0 0 4px rgba(0, 255, 0, 0.5);
}

.volume-osd-bar {
  display: flex;
  gap: 2px;
  align-items: flex-end;
}

.volume-osd-segment {
  width: calc(8px * var(--terminal-scale));
  height: calc(12px * var(--terminal-scale));
  background: #1a1a1a;
  border: 1px solid #333;
  transition: background 0.1s ease;
}

.volume-osd-segment.active {
  background: #0c0;
  border-color: #0f0;
  box-shadow: 0 0 3px rgba(0, 255, 0, 0.4);
}

.volume-osd-segment:nth-child(9).active {
  background: #cc0;
  border-color: #ff0;
  box-shadow: 0 0 3px rgba(255, 255, 0, 0.4);
}

.volume-osd-segment:nth-child(10).active {
  background: #c00;
  border-color: #f00;
  box-shadow: 0 0 3px rgba(255, 0, 0, 0.4);
}

/* =============================================================================
   Continuous CRT Effects (var()-driven, smooth degradation)
   ============================================================================= */

.screen-container.crt-continuous .scanlines {
  opacity: var(--crt-scanline-opacity, 0.15);
  animation-duration: var(--crt-scanline-speed, 10s);
  transition: opacity 0.5s ease, animation-duration 0.5s ease;
}

.screen-container.crt-continuous .flicker {
  opacity: var(--crt-flicker-opacity, 0.02);
  animation-duration: var(--crt-flicker-speed, 0.15s);
  transition: opacity 0.5s ease;
}

.screen-container.crt-continuous .noise {
  opacity: var(--crt-noise-opacity, 0.03);
  transition: opacity 0.5s ease;
}

.screen-container.crt-continuous .vignette {
  background: radial-gradient(
    ellipse at center,
    transparent calc(100% - 100% * var(--crt-vignette-strength, 0.4)),
    rgba(0, 0, 0, var(--crt-vignette-strength, 0.4)) 100%
  );
  transition: background 0.5s ease;
}

/* Phosphor glow */
.screen-container.crt-continuous #terminal canvas {
  filter:
    blur(var(--crt-focus-blur, 0px))
    saturate(var(--crt-color-saturation, 1))
    hue-rotate(var(--crt-color-temp-shift, 0deg));
  transition: filter 1s ease;
}

/* Phosphor glow effect using text-shadow on the canvas container */
.screen-container.crt-continuous #terminal {
  filter: drop-shadow(0 0 var(--crt-phosphor-glow, 0px) rgba(0, 255, 0, 0.15));
  transition: filter 1s ease;
}

/* Burn-in overlay */
.screen-container.crt-continuous::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(
    ellipse at center,
    transparent 40%,
    rgba(0, 20, 0, var(--crt-burn-in-opacity, 0)) 100%
  );
  pointer-events: none;
  z-index: 12;
  transition: background 1s ease;
}

/* Convergence error (RGB misalignment) */
.screen-container.crt-continuous::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 0, 0, var(--crt-color-fringe, 0)) 25%,
    transparent 50%,
    rgba(0, 255, 0, var(--crt-color-fringe, 0)) 75%,
    transparent 100%
  );
  animation: crt-color-shift var(--crt-brightness-pump-speed, 4s) linear infinite;
  pointer-events: none;
  z-index: 11;
  transition: background 0.5s ease;
}

/* Brightness pump animation */
@keyframes crt-brightness-pump {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(calc(1 + var(--crt-brightness-amplitude, 0))); }
}

.screen-container.crt-continuous {
  animation: crt-brightness-pump var(--crt-brightness-pump-speed, 4s) ease-in-out infinite;
}

/* Uneven brightness (vignette-like but asymmetric) */
.screen-container.crt-continuous .screen-aging {
  opacity: var(--crt-uneven-brightness, 0);
  transition: opacity 1s ease;
}

@keyframes crt-color-shift {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Raster jitter (subtle vertical shake) */
@keyframes crt-jitter {
  0%, 100% { transform: translateY(0); }
  25% { transform: translateY(var(--crt-jitter-amplitude, 0px)); }
  75% { transform: translateY(calc(-1 * var(--crt-jitter-amplitude, 0px))); }
}

.screen-container.crt-continuous #terminal {
  animation: crt-jitter 0.1s steps(2) infinite;
}

/* Wave distortion */
@keyframes crt-wave {
  0% { transform: translateX(0); }
  25% { transform: translateX(var(--crt-wave-amplitude, 0px)); }
  50% { transform: translateX(0); }
  75% { transform: translateX(calc(-1 * var(--crt-wave-amplitude, 0px))); }
  100% { transform: translateX(0); }
}

/* =============================================================================
   CRT One-Shot Event Animations
   ============================================================================= */

/* Degauss flash - bright color flash + wave */
@keyframes crt-degauss {
  0% {
    filter: brightness(2) saturate(3) hue-rotate(0deg);
    transform: scale(1.02);
  }
  20% {
    filter: brightness(1.5) saturate(2) hue-rotate(90deg);
    transform: scale(1.01);
  }
  50% {
    filter: brightness(1.2) saturate(1.5) hue-rotate(180deg);
    transform: scale(1.005);
  }
  100% {
    filter: brightness(1) saturate(1) hue-rotate(0deg);
    transform: scale(1);
  }
}

.screen-container.crt-event-degauss {
  animation: crt-degauss var(--crt-event-duration, 500ms) ease-out forwards;
}

/* Power sag - brightness drops then recovers */
@keyframes crt-power-sag {
  0% { filter: brightness(1); }
  10% { filter: brightness(0.3); }
  30% { filter: brightness(0.5); }
  60% { filter: brightness(0.8); }
  100% { filter: brightness(1); }
}

.screen-container.crt-event-power-sag {
  animation: crt-power-sag var(--crt-event-duration, 300ms) ease-out forwards;
}

/* Flyback line - bright horizontal line sweeps across */
@keyframes crt-flyback {
  0% {
    background: linear-gradient(0deg,
      transparent 0%,
      transparent 49%,
      rgba(255, 255, 255, 0.8) 50%,
      transparent 51%,
      transparent 100%
    );
    background-position: 0 0%;
  }
  100% {
    background: linear-gradient(0deg,
      transparent 0%,
      transparent 49%,
      rgba(255, 255, 255, 0.8) 50%,
      transparent 51%,
      transparent 100%
    );
    background-position: 0 100%;
  }
}

.screen-container.crt-event-flyback::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 15;
  animation: crt-flyback var(--crt-event-duration, 200ms) linear forwards;
}

/* Static overlay - brief burst of noise over the screen */
@keyframes crt-static-overlay {
  0% { opacity: 0; }
  10% { opacity: calc(0.6 * var(--crt-event-intensity, 0.5)); }
  50% { opacity: calc(0.4 * var(--crt-event-intensity, 0.5)); }
  90% { opacity: calc(0.2 * var(--crt-event-intensity, 0.5)); }
  100% { opacity: 0; }
}

.screen-container.crt-event-static-overlay::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 16;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4'%3E%3Crect x='0' y='0' width='1' height='1' fill='%23fff' opacity='0.3'/%3E%3Crect x='2' y='1' width='1' height='1' fill='%23fff' opacity='0.2'/%3E%3Crect x='1' y='3' width='1' height='1' fill='%23fff' opacity='0.4'/%3E%3Crect x='3' y='2' width='1' height='1' fill='%23fff' opacity='0.1'/%3E%3C/svg%3E");
  background-size: 4px 4px;
  animation: crt-static-overlay var(--crt-event-duration, 800ms) ease-out forwards;
}

/* Horizontal tear - screen splits and shifts horizontally */
@keyframes crt-h-tear {
  0% { clip-path: inset(0); transform: translateX(0); }
  15% { clip-path: inset(30% 0 40% 0); transform: translateX(8px); }
  30% { clip-path: inset(20% 0 50% 0); transform: translateX(-6px); }
  50% { clip-path: inset(45% 0 25% 0); transform: translateX(4px); }
  70% { clip-path: inset(10% 0 60% 0); transform: translateX(-3px); }
  100% { clip-path: inset(0); transform: translateX(0); }
}

.screen-container.crt-event-h-tear {
  animation: crt-h-tear var(--crt-event-duration, 500ms) linear forwards;
}

/* Vertical roll - screen scrolls vertically as if losing V-hold */
@keyframes crt-v-roll {
  0% { transform: translateY(0); }
  25% { transform: translateY(-10%); }
  50% { transform: translateY(-20%); filter: brightness(0.7); }
  75% { transform: translateY(-5%); }
  100% { transform: translateY(0); filter: brightness(1); }
}

.screen-container.crt-event-v-roll {
  animation: crt-v-roll var(--crt-event-duration, 600ms) ease-in-out forwards;
}
