/* CRT Monitor Aesthetics & Filters */

/* Mobile Optimizations */
html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
}

body {
  -webkit-user-select: none;
  user-select: none;
  overflow: hidden;
}

/* Enable smooth scrolling on iOS */
.window-body,
.terminal-body,
.ie-page-wrapper,
.exp-content,
.skills-main-panel {
  -webkit-overflow-scrolling: touch;
}

.monitor-wrapper {
  position: relative;
  width: 100vw;
  height: 100vh;
  background: #111;
  overflow: hidden;
  box-sizing: border-box;
}

.crt-screen {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* 1. Curved CRT Vignette */
.crt-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  background: radial-gradient(
    circle at center,
    rgba(255, 255, 255, 0.05) 0%,
    rgba(0, 0, 0, 0) 50%,
    rgba(0, 0, 0, 0.3) 80%,
    rgba(0, 0, 0, 0.6) 100%
  );
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.8);
}

/* 2. CRT Scanlines Overlay */
.crt-scanlines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9998;
  background: linear-gradient(
    rgba(18, 16, 16, 0) 50%, 
    rgba(0, 0, 0, 0.15) 50%
  );
  background-size: 100% 4px;
}

body.crt-enabled .crt-scanlines {
  display: block;
}

body:not(.crt-enabled) .crt-scanlines {
  display: none;
}

/* 3. Screen Flicker Simulator */
.crt-flicker {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9997;
  background: rgba(18, 16, 16, 0.015);
  opacity: 0;
}

body.flicker-enabled .crt-flicker {
  animation: crt-flicker-anim 0.15s infinite;
}

@keyframes crt-flicker-anim {
  0% { opacity: 0.15; }
  50% { opacity: 0.22; }
  100% { opacity: 0.15; }
}

/* 4. Phosphor CRT Static Noise */
.crt-static {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9996;
  opacity: 0.02;
  background-image: radial-gradient(circle, #fff 10%, transparent 11%),
                    radial-gradient(circle, #fff 10%, transparent 11%);
  background-size: 6px 6px;
  background-position: 0 0, 3px 3px;
  animation: static-noise-anim 0.2s steps(4) infinite;
  display: none;
}

body.flicker-enabled .crt-static {
  display: block;
}

@keyframes static-noise-anim {
  0% { background-position: 0 0, 3px 3px; }
  25% { background-position: 1px 2px, 4px 5px; }
  50% { background-position: -2px 1px, 1px -2px; }
  75% { background-position: 2px -1px, -1px 2px; }
  100% { background-position: 0 0, 3px 3px; }
}

/* Slight Screen Curve distortion for premium browsers */
@media (min-width: 1024px) {
  body.crt-enabled .crt-screen {
    animation: monitor-power-on 0.5s ease-out;
  }
}

/* Disable performance-heavy CRT effects on mobile */
@media (max-width: 768px) {
  body.flicker-enabled .crt-flicker {
    animation: none;
    opacity: 0;
  }
  
  body.flicker-enabled .crt-static {
    display: none !important;
    animation: none;
  }
  
  .crt-scanlines {
    opacity: 0.05;
  }
}

@keyframes monitor-power-on {
  0% {
    transform: scaleY(0.01) scaleX(0);
    filter: brightness(3);
    background: #fff;
  }
  40% {
    transform: scaleY(0.01) scaleX(1);
    filter: brightness(2);
    background: #fff;
  }
  100% {
    transform: scaleY(1) scaleX(1);
    filter: brightness(1);
  }
}

/* Cursor Glow effect */
.cursor-trail {
  position: absolute;
  width: 10px;
  height: 10px;
  background: rgba(0, 255, 128, 0.7);
  box-shadow: 0 0 10px rgba(0, 255, 128, 0.8), 0 0 20px rgba(0, 255, 128, 0.4);
  border-radius: 50%;
  pointer-events: none;
  z-index: 100000;
  transform: translate(-50%, -50%);
  mix-blend-mode: screen;
  transition: opacity 0.6s ease-out, transform 0.1s ease-out;
}
