﻿/* Efectos de CRT sobre el monitor virtual (1280x960).
   Un pixel VGA de 640x480 equivale a 2x2 pixeles de esta pantalla. */

#crt {
  position: absolute;
  inset: 0;
  background: #000;
  transform-origin: 50% 50%;
}

#screen,
#glow,
#display {
  position: absolute;
  left: 0;
  top: 0;
  width: 1280px;
  height: 960px;
}

#screen {
  animation: flicker 5.3s infinite steps(1);
}

/* Post-proceso WebGL: sustituye a los efectos CSS */
#display { display: none; }
body.gl-on #display { display: block; }
body.gl-on #screen,
body.gl-on #glow,
body.gl-on .scanlines,
body.gl-on .vignette { display: none; }

/* Sin efectos (CRT OFF): imagen limpia */
body.crt-off #glow,
body.crt-off .scanlines,
body.crt-off .vignette { display: none; }
body.crt-off #screen { animation: none; }

/* Degauss en modo 2D */
body.degauss:not(.gl-on) #screen { animation: degauss 1.7s ease-out; }
@keyframes degauss {
  0%   { transform: skewX(6deg) scale(1.03); filter: hue-rotate(80deg) saturate(2); }
  25%  { transform: skewX(-4deg) scale(.99); filter: hue-rotate(-60deg) saturate(1.6); }
  50%  { transform: skewX(2deg); filter: hue-rotate(30deg); }
  100% { transform: none; filter: none; }
}

/* Resplandor del fosforo: copia reducida del texto, desenfocada y sumada */
#glow {
  filter: blur(3px) brightness(1.3);
  mix-blend-mode: screen;
  opacity: .55;
  pointer-events: none;
}

/* Una linea oscura por cada fila de pixeles VGA */
.scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0,
    rgba(0, 0, 0, 0) 1px,
    rgba(0, 0, 0, .26) 1px,
    rgba(0, 0, 0, .26) 2px
  );
}

/* Oscurecimiento hacia los bordes del tubo */
.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 70%, rgba(0, 0, 0, .22) 100%);
  box-shadow: inset 0 0 50px 6px rgba(0, 0, 0, .28);
}

/* Flash blanco del encendido/apagado */
.flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}

/* Reflejo del cristal (siempre por encima) */
.reflection {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(118deg, rgba(255, 255, 255, .13) 0%, rgba(255, 255, 255, .03) 28%, rgba(255, 255, 255, 0) 42%),
    radial-gradient(ellipse at 30% 18%, rgba(255, 255, 255, .06), rgba(255, 255, 255, 0) 55%);
}

@keyframes flicker {
  0%   { opacity: 1; }
  11%  { opacity: .975; }
  12%  { opacity: 1; }
  47%  { opacity: .985; }
  48%  { opacity: 1; }
  83%  { opacity: .97; }
  84%  { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  #screen { animation: none; }
}

