/* CRT engine effects — intensity via body[data-crt] */
.fx { position: absolute; inset: 0; pointer-events: none; z-index: 5; }

.fx-scanlines {
  background: repeating-linear-gradient(
    to bottom,
    rgba(0,0,0,0) 0px, rgba(0,0,0,0) 2px,
    rgba(0,0,0,.18) 3px, rgba(0,0,0,.18) 4px);
}

.fx-vignette {
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.55) 92%, rgba(0,0,0,.85) 100%);
  border-radius: inherit;
}

.fx-bloom { box-shadow: inset 0 0 90px rgba(51,255,102,.10), inset 0 0 300px rgba(51,255,102,.05); }

.fx-noise {
  opacity: .04; mix-blend-mode: screen;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  animation: noise-shift .45s steps(3) infinite;
}

@keyframes noise-shift {
  0% { transform: translate(0,0); } 33% { transform: translate(-6px,4px); }
  66% { transform: translate(4px,-5px); } 100% { transform: translate(0,0); }
}

/* flicker applied to terminal content */
.crt-inner-flicker { animation: crt-flicker 3.2s infinite steps(60); z-index: auto; position: static; inset: auto; background: none; }
@keyframes crt-flicker {
  0%,100% { opacity: 1; } 92% { opacity: .975; } 94% { opacity: .996; } 96% { opacity: .982; }
}

/* horizontal sync jitter — triggered by glitch engine */
.crt.glitch-minor   { animation: g-minor .18s steps(3); }
.crt.glitch-warning { animation: g-warn .5s steps(7); filter: hue-rotate(-14deg) saturate(1.2); }
.crt.glitch-breach  { animation: g-breach 1.1s steps(10); }
.crt.glitch-unlock  { animation: g-flash .6s ease-out; }

@keyframes g-minor { 30% { transform: translateX(-4px) skewX(.5deg);} 60% { transform: translateX(3px);} }
@keyframes g-warn  { 20% { transform: translateX(-14px); filter: blur(1px);} 40% { transform: translateX(9px);} 70% { transform: skewX(2deg) translateX(-5px);} }
@keyframes g-breach {
  10% { transform: translateX(-3vw) scaleY(.96); filter: hue-rotate(40deg);} 
  30% { transform: translateX(2.4vw) skewX(-3deg);} 
  55% { transform: translateX(-1.2vw); filter: blur(2px) contrast(1.4);}
  80% { transform: translateY(6px) scaleY(1.03);}
}
@keyframes g-flash { 15% { filter: brightness(3);} }

/* intensity levels */
body[data-crt="low"] .fx-noise, body[data-crt="low"] .crt-inner-flicker { display: none; }
body[data-crt="low"] .fx-scanlines { opacity: .45; }
body[data-crt="high"] .fx-bloom { box-shadow: inset 0 0 130px rgba(51,255,102,.2), inset 0 0 380px rgba(51,255,102,.09); }
body[data-crt="high"] .fx-noise { opacity: .07; }

/* breach mode tints the whole screen */
body[data-mode="breach"] .crt { background: #04060a; }
body[data-mode="breach"] .fx-bloom { box-shadow: inset 0 0 120px rgba(46,230,255,.14), inset 0 0 300px rgba(255,61,242,.07); }

/* boot power-on animation */
.crt.booting .terminal { transform: scaleY(.004) scaleX(1.05); filter: brightness(8); transition: none; }
.crt.boot-open .terminal { transform: scale(1,1); filter: brightness(1); transition: transform .7s cubic-bezier(.2,.9,.3,1), filter 1s ease-out; }

@media (prefers-reduced-motion: reduce) {
  .fx-noise { animation: none; display: none; }
  .crt-inner-flicker { animation: none !important; }
  .crt.glitch-minor, .crt.glitch-warning, .crt.glitch-breach, .crt.glitch-unlock { animation-duration: .12s; filter: none; }
}
