/* Efectos CRT para losmochOS */

/* Efecto de curvatura CRT */
.crt-effect {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9998; /* Justo debajo del overlay de arranque */
  pointer-events: none; /* Permite interacción con elementos debajo */
  overflow: hidden;
}

/* Efecto general CRT */
.crt-effect::before {
  content: "";
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /*background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.096) 50%);*/ /* Comentado para evitar conflicto con el efecto de líneas */
  background: linear-gradient(rgba(18, 16, 16, 0) 50%,rgba(0, 0, 0, 0.25) 50%), 
              linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
  background-size: 100% 2px, 5px 100%;
  /*background-size: 100% 2px;*/ /* Comentado para evitar conflicto con el efecto de líneas */
  z-index: 9998;
  pointer-events: none;
  animation: crt-flicker 0.15s infinite;
}

/* Líneas horizontales escaneado - versión más sutil y realista */
.crt-effect::after {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* Patrón de líneas más sutil con menos contraste */
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.01) 0px,
    rgba(255, 255, 255, 0.02) 1px,
    rgba(0, 0, 0, 0.01) 1px,
    rgba(0, 0, 0, 0.02) 2px
  );
  background-size: 100% 4px;
  z-index: 9998;
  pointer-events: none;
  opacity: 0.4; /* Reducimos la opacidad general */
  animation: crt-scanlines 30s linear infinite; /* Ralentizamos la animación */
  mix-blend-mode: overlay; /* Mejora la integración con el fondo */
}

/* Curvatura del monitor CRT mejorada */
.crt-curvature {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  pointer-events: none;
  box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.9);
  border-radius: 20px;
  overflow: hidden;
  background: transparent;
}

.crt-curvature::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(
    circle at center,
    transparent 50%,
    rgba(0, 0, 0, 0.3) 100%
  );
  border-radius: 50% / 10%;
  pointer-events: none;
}

/* Efecto de borde del monitor */
.crt-border {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  box-shadow: 0 0 0 15px #111;
  border-radius: 20px;
  z-index: 9990;
  pointer-events: none;
}

/* Efecto VHS mejorado - Distorsión y desplazamiento de colores */
.vhs-effect {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9997;
  pointer-events: none;
  opacity: 0.7;
  mix-blend-mode: screen;
}

.vhs-effect::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    transparent 0%,
    rgba(0, 255, 255, 0.15) 10%,
    transparent 15%,
    rgba(255, 0, 255, 0.15) 25%,
    transparent 30%,
    rgba(0, 255, 0, 0.15) 40%,
    transparent 45%
  );
  animation: vhs-track 8s linear infinite;
  z-index: 9997;
}

.vhs-effect::after {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 1px,
    rgba(0, 0, 0, 0.15) 2px,
    rgba(0, 0, 0, 0.15) 3px
  );
  animation: vhs-noise 0.5s steps(2) infinite;
  opacity: 0.3;
}

/* Nuevo efecto de aberración cromática VHS */
.vhs-effect::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: transparent;
  box-shadow:
    2px 0 0 0 rgba(255, 0, 0, 0.2),
    -2px 0 0 0 rgba(0, 255, 255, 0.2);
  z-index: 9997;
  animation: vhs-chromatic-aberration 2.5s linear infinite alternate;
}

/* Nuevo elemento para simular el ruido de cinta VHS */
.vhs-effect::after {
  content: "";
  position: fixed;
  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='vhsnoise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23vhsnoise)' opacity='0.4'/%3E%3C/svg%3E");
  opacity: 0.05;
  animation: vhs-tape-noise 0.1s steps(1) infinite;
  mix-blend-mode: overlay;
}

/* Elemento adicional para tracking horizontal */
.vhs-effect {
  position: relative;
}

.vhs-effect::before, 
.vhs-effect::after {
  pointer-events: none;
}

/* Efecto de encendido CRT mejorado */
.crt-startup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: black;
  z-index: 10000;
  animation: crt-startup 5s ease-out forwards;
  overflow: hidden;
  /* Añadimos filtros para simular el brillo inicial */
  filter: brightness(0) contrast(1.5);
  transform-origin: center center;
}

/* Línea de encendido horizontal - ahora con más efectos */
.startup-line {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: rgb(194, 194, 194);
  transform: translateY(-50%);
  animation: startup-line 3s ease-in-out forwards;
  box-shadow: 0 0 15px 5px rgba(0, 255, 0, 0.7);
}

/* Efecto de resplandor central del monitor al encenderse */
.crt-startup::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(
    ellipse at center,
    rgba(180, 230, 180, 0.1) 0%,
    rgba(40, 120, 40, 0.05) 40%,
    rgba(0, 50, 0, 0) 70%
  );
  opacity: 0;
  animation: startup-glow 5s ease-in-out forwards;
  pointer-events: none;
  mix-blend-mode: screen;
  z-index: 10001;
}

/* Efecto de ruido estático al encender - mejorado */
.crt-startup::after {
  content: "";
  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%25' height='100%25' filter='url(%23noise)' opacity='0.4'/%3E%3C/svg%3E");
  opacity: 0.1;
  animation: noise-animation 0.2s linear infinite, startup-noise 5s ease-in-out forwards;
}

/* Nueva capa para aberración cromática durante el encendido */
.crt-startup-rgb {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10002;
  pointer-events: none;
  mix-blend-mode: screen;
  animation: startup-rgb-convergence 4s ease-in-out forwards;
  opacity: 0;
  background: transparent;
  box-shadow:
    inset 4px 0 0 0 rgba(255, 0, 0, 0.3),
    inset -4px 0 0 0 rgba(0, 255, 255, 0.3),
    inset 0 4px 0 0 rgba(0, 255, 0, 0.3);
}

/* Animaciones */
@keyframes crt-flicker {
  0% {
    opacity: 0.92;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.9;
  }
}

@keyframes crt-scanlines {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(100%);
  }
}

@keyframes vhs-track {
  0% {
    transform: translateY(0);
  }
  97% {
    transform: translateY(100%);
  }
  97.1% {
    transform: translateY(-10%);
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes vhs-chromatic-aberration {
  0% {
    box-shadow:
      1px 0 0 0 rgba(255, 0, 0, 0.2),
      -1px 0 0 0 rgba(0, 255, 255, 0.2);
  }
  25% {
    box-shadow:
      2px 0 0 0 rgba(255, 0, 0, 0.2),
      -1px 0 0 0 rgba(0, 255, 255, 0.2);
  }
  50% {
    box-shadow:
      3px 0 0 0 rgba(255, 0, 0, 0.2),
      -2px 0 0 0 rgba(0, 255, 255, 0.2);
  }
  75% {
    box-shadow:
      2px 0 0 0 rgba(255, 0, 0, 0.2),
      -3px 0 0 0 rgba(0, 255, 255, 0.2);
  }
  100% {
    box-shadow:
      1px 0 0 0 rgba(255, 0, 0, 0.2),
      -2px 0 0 0 rgba(0, 255, 255, 0.2);
  }
}

@keyframes vhs-noise {
  0% {
    transform: translateX(0) scaleY(1.01);
    opacity: 0.2;
  }
  10% {
    transform: translateX(-1%) scaleY(0.99);
    opacity: 0.3;
  }
  20% {
    transform: translateX(1%) scaleY(1.02);
    opacity: 0.2;
  }
  30% {
    transform: translateX(-2%) scaleY(0.98);
    opacity: 0.3;
  }
  40% {
    transform: translateX(3%) scaleY(1.01);
    opacity: 0.2; 
  }
  50% {
    transform: translateX(-3%) scaleY(0.97);
    opacity: 0.4;
  }
  60% {
    transform: translateX(2%) scaleY(1.03);
    opacity: 0.3;
  }
  70% {
    transform: translateX(-1%) scaleY(0.98);
    opacity: 0.2;
  }
  80% {
    transform: translateX(1%) scaleY(1.02);
    opacity: 0.3;
  }
  90% {
    transform: translateX(-2%) scaleY(0.99);
    opacity: 0.2;
  }
  100% {
    transform: translateX(0) scaleY(1);
    opacity: 0.3;
  }
}

@keyframes vhs-tape-noise {
  0%, 100% {
    opacity: 0.03;
    transform: translateX(0);
  }
  10% {
    opacity: 0.05;
    transform: translateX(0.5%);
  }
  20% {
    opacity: 0.02;
    transform: translateX(-0.5%);
  }
  30% {
    opacity: 0.04;
    transform: translateX(0.2%);
  }
  40% {
    opacity: 0.03;
    transform: translateX(-0.2%);
  }
  50% {
    opacity: 0.05;
    transform: translateX(0);
    filter: brightness(1.05);
  }
  60%, 70% {
    opacity: 0.04;
    transform: translateX(0.3%);
  }
  80%, 90% {
    opacity: 0.03;
    transform: translateX(-0.3%);
  }
}

/* Distorsión de tracking esporádico */
@keyframes vhs-tracking-distortion {
  0%, 100% {
    transform: none;
    opacity: 0;
  }
  10%, 15% {
    transform: translateY(5px) scaleY(1.2);
    opacity: 0.7;
  }
  16%, 20% {
    transform: translateY(-2px) scaleY(0.8);
    opacity: 0;
  }
}

@keyframes startup-line {
  0% {
    height: 2px;
    opacity: 0;
    transform: translateY(-50%) scaleY(1);
  }
  5% {
    height: 2px;
    opacity: 1;
    transform: translateY(-50%) scaleY(1);
  }
  10% {
    box-shadow: 0 0 20px 10px rgba(0, 255, 0, 0.8);
  }
  20% {
    height: 100%;
    transform: translateY(-50%) scaleY(2);
  }
  40% {
    height: 100%;
    transform: translateY(-50%) scaleY(1);
    box-shadow: 0 0 15px 5px rgba(0, 255, 0, 0.5);
  }
  60% {
    height: 100%;
    box-shadow: 0 0 10px 5px rgba(0, 255, 0, 0.3);
  }
  100% {
    height: 100%;
    opacity: 0;
    box-shadow: 0 0 5px 5px rgba(0, 255, 0, 0);
  }
}

@keyframes crt-startup {
  0% {
    opacity: 1;
    filter: brightness(0) contrast(1);
    transform: scale(1.02);
  }
  2% {
    filter: brightness(0.4) contrast(1.5);
    transform: scale(1.01);
  }
  5% {
    filter: brightness(0.1) contrast(1.2);
    transform: scale(1);
  }
  10% {
    filter: brightness(0.2) contrast(1.3);
  }
  20% {
    filter: brightness(0.4) saturate(0.5) contrast(1.4);
  }
  40% {
    filter: brightness(0.7) saturate(0.7) contrast(1.3);
  }
  60% {
    filter: brightness(0.9) saturate(0.9) contrast(1.1);
    opacity: 1;
  }
  80% {
    filter: brightness(1) saturate(1) contrast(1);
    opacity: 0.7;
  }
  100% {
    opacity: 0;
    visibility: hidden;
    filter: brightness(1) saturate(1) contrast(1);
  }
}

@keyframes startup-noise {
  0% {
    opacity: 0.9;
  }
  5% {
    opacity: 0.7;
  }
  20% {
    opacity: 0.5;
  }
  40% {
    opacity: 0.3;
  }
  60% {
    opacity: 0.2;
  }
  80% {
    opacity: 0.1;
  }
  100% {
    opacity: 0;
  }
}

/* Nueva animación para el resplandor del centro */
@keyframes startup-glow {
  0% {
    opacity: 0;
    transform: scale(0.1);
  }
  5% {
    opacity: 0.7;
    transform: scale(0.2);
  }
  10% {
    opacity: 0.5;
    transform: scale(0.5);
  }
  20% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  40% {
    opacity: 0.5;
    transform: scale(1);
  }
  60% {
    opacity: 0.7;
    transform: scale(1.1);
  }
  80% {
    opacity: 0.4;
    transform: scale(1.05);
  }
  100% {
    opacity: 0;
    transform: scale(1);
  }
}

/* Nueva animación para la convergencia de colores RGB */
@keyframes startup-rgb-convergence {
  0% {
    opacity: 0;
    box-shadow:
      inset 20px 0 0 0 rgba(255, 0, 0, 0.2),
      inset -20px 0 0 0 rgba(0, 255, 255, 0.2),
      inset 0 20px 0 0 rgba(0, 255, 0, 0.2);
  }
  5% {
    opacity: 0.9;
    box-shadow:
      inset 15px 0 0 0 rgba(255, 0, 0, 0.3),
      inset -15px 0 0 0 rgba(0, 255, 255, 0.3),
      inset 0 15px 0 0 rgba(0, 255, 0, 0.3);
  }
  20% {
    opacity: 0.7;
    box-shadow:
      inset 10px 0 0 0 rgba(255, 0, 0, 0.3),
      inset -10px 0 0 0 rgba(0, 255, 255, 0.3),
      inset 0 10px 0 0 rgba(0, 255, 0, 0.3);
  }
  40% {
    opacity: 0.5;
    box-shadow:
      inset 5px 0 0 0 rgba(255, 0, 0, 0.3),
      inset -5px 0 0 0 rgba(0, 255, 255, 0.3),
      inset 0 5px 0 0 rgba(0, 255, 0, 0.3);
  }
  60% {
    opacity: 0.3;
    box-shadow:
      inset 2px 0 0 0 rgba(255, 0, 0, 0.2),
      inset -2px 0 0 0 rgba(0, 255, 255, 0.2),
      inset 0 2px 0 0 rgba(0, 255, 0, 0.2);
  }
  80% {
    opacity: 0.1;
  }
  100% {
    opacity: 0;
    box-shadow:
      inset 0 0 0 0 rgba(255, 0, 0, 0),
      inset 0 0 0 0 rgba(0, 255, 255, 0),
      inset 0 0 0 0 rgba(0, 255, 0, 0);
  }
}

@keyframes noise-animation {
  0% { opacity: 0.3; }
  50% { opacity: 0.2; }
  100% { opacity: 0.3; }
}

/* Efecto de brillo y distorsión aleatorio */
.crt-glitch {
  animation: crt-glitch 8s infinite;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9996;
  background: transparent;
  opacity: 0.15;
}

.crt-glitch::before {
  content: "";
  position: absolute;
  top: 0;
  left: -10%;
  width: 120%;
  height: 5px;
  background: rgba(255, 255, 255, 0.3);
  animation: glitch-line 3s linear infinite;
  opacity: 0;
}

@keyframes glitch-line {
  0% {
    top: -5px;
    opacity: 0;
  }
  1% {
    top: 0;
    opacity: 0.5;
  }
  2% {
    top: 100px;
    opacity: 0.5;
  }
  3% {
    top: 300px;
    opacity: 0.5;
  }
  4% {
    top: 400px;
    opacity: 0.5;
  }
  5% {
    top: 500px;
    opacity: 0;
  }
  100% {
    top: 500px;
    opacity: 0;
  }
}

@keyframes crt-glitch {
  0% {
    background-position: 0 0;
    filter: hue-rotate(0deg);
  }
  2% {
    background-position: -5px 0;
  }
  4% {
    background-position: 5px 0;
  }
  5% {
    background-position: 0 0;
  }
  50% {
    filter: hue-rotate(360deg);
  }
  100% {
    background-position: 0 0;
    filter: hue-rotate(0deg);
  }
}

/* Efecto distorsión CRT en todo el contenido */
body {
  transform-style: preserve-3d;
  animation: subtle-bulge 10s ease-in-out infinite;
}

@keyframes subtle-bulge {
  0%, 100% {
    transform: perspective(1300px) rotateX(0deg);
  }
  50% {
    transform: perspective(1300px) rotateX(0.5deg);
  }
}

/* Para pantallas pequeñas, reducimos los efectos */
@media (max-width: 768px) {
  .crt-border {
    box-shadow: 0 0 0 5px #111;
    border-radius: 10px;
  }
  
  .crt-curvature {
    border-radius: 10px;
  }
}