/* ============================================================
   NAUSTALGIAOS TERMINAL - AAA VISUAL UPGRADE v1.0
   Professional game-quality atmosphere for main experience
   
   Layer this AFTER styles.css for enhanced visuals
============================================================ */

/* ============================================================
   ATMOSPHERIC BACKGROUND LAYERS
   Inject depth into the void behind the CRT
============================================================ */

/* Deep atmospheric overlay on voidLayer */
#voidLayer::before {
  background: 
    /* Central warm glow from TV */
    radial-gradient(ellipse 50% 60% at 50% 45%, rgba(0, 180, 255, 0.06) 0%, transparent 50%),
    /* Magenta nebula clouds */
    radial-gradient(ellipse 80% 50% at 25% 70%, rgba(150, 0, 200, 0.08) 0%, transparent 45%),
    radial-gradient(ellipse 60% 40% at 80% 30%, rgba(200, 0, 180, 0.06) 0%, transparent 40%),
    radial-gradient(ellipse 70% 60% at 15% 25%, rgba(100, 0, 150, 0.05) 0%, transparent 50%),
    /* Deep vignette */
    radial-gradient(ellipse 100% 100% at 50% 50%, transparent 30%, rgba(0, 0, 0, 0.4) 100%) !important;
  animation: nebulaShift 30s ease-in-out infinite;
  mix-blend-mode: screen !important;
}

@keyframes nebulaShift {
  0%, 100% { 
    opacity: 1;
    transform: translate(var(--mid-x, 0px), var(--mid-y, 0px)) scale(1);
  }
  50% { 
    opacity: 0.8;
    transform: translate(var(--mid-x, 0px), var(--mid-y, 0px)) scale(1.05);
  }
}

/* ============================================================
   AMBIENT FLOATING PARTICLES
============================================================ */
.terminal-particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  overflow: hidden;
}

.terminal-particles .dust {
  position: absolute;
  width: 2px;
  height: 2px;
  background: rgba(0, 255, 255, 0.4);
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(0, 255, 255, 0.6);
  animation: dustFloat 25s ease-in-out infinite;
}

.terminal-particles .dust:nth-child(odd) {
  background: rgba(255, 0, 200, 0.3);
  box-shadow: 0 0 6px rgba(255, 0, 200, 0.5);
}

.terminal-particles .dust:nth-child(3n) {
  background: rgba(255, 229, 0, 0.3);
  box-shadow: 0 0 6px rgba(255, 229, 0, 0.5);
  width: 3px;
  height: 3px;
}

@keyframes dustFloat {
  0%, 100% { 
    transform: translateY(0) translateX(0);
    opacity: 0;
  }
  10% { opacity: 0.8; }
  50% { 
    transform: translateY(-40vh) translateX(20px);
    opacity: 0.5;
  }
  90% { opacity: 0.8; }
}

/* ============================================================
   CRT TV FRAME - DRAMATIC SCREEN GLOW
============================================================ */
#crtShell {
  filter: 
    drop-shadow(4px 6px 30px rgba(0, 0, 0, 0.9))
    drop-shadow(0 0 60px rgba(0, 0, 0, 0.7))
    /* Screen glow bleeding out */
    drop-shadow(0 0 30px rgba(0, 200, 255, 0.15))
    drop-shadow(0 0 80px rgba(0, 200, 255, 0.08))
    drop-shadow(0 0 150px rgba(255, 0, 200, 0.05)) !important;
}

/* Animated screen glow pulse */
@keyframes screenGlow {
  0%, 100% {
    filter: 
      drop-shadow(4px 6px 30px rgba(0, 0, 0, 0.9))
      drop-shadow(0 0 60px rgba(0, 0, 0, 0.7))
      drop-shadow(0 0 30px rgba(0, 200, 255, 0.12))
      drop-shadow(0 0 80px rgba(0, 200, 255, 0.06));
  }
  50% {
    filter: 
      drop-shadow(4px 6px 30px rgba(0, 0, 0, 0.9))
      drop-shadow(0 0 60px rgba(0, 0, 0, 0.7))
      drop-shadow(0 0 40px rgba(0, 200, 255, 0.18))
      drop-shadow(0 0 100px rgba(0, 200, 255, 0.1))
      drop-shadow(0 0 180px rgba(255, 0, 200, 0.06));
  }
}

#crtShell {
  animation: screenGlow 8s ease-in-out infinite;
}

/* ============================================================
   TERMINAL TEXT AREA - PHOSPHOR GLOW
============================================================ */
#term {
  /* Subtle inner glow */
  text-shadow: 0 0 8px #00FFFF, 0 0 20px rgba(0, 255, 255, 0.3) !important;
}

#term .line {
  text-shadow: 
    0 0 4px currentColor,
    0 0 12px rgba(0, 255, 255, 0.4);
}

/* ============================================================
   GHOST SIGIL - SUBTLE PRESENCE (CRASH's Eye Colors)
   Yellow/gold gradient with depth, softer glow
============================================================ */
#glitchGhost {
  filter: 
    drop-shadow(0 0 4px rgba(255, 229, 0, 0.5))
    drop-shadow(0 0 12px rgba(255, 229, 0, 0.25))
    drop-shadow(0 0 24px rgba(255, 200, 0, 0.15));
  animation: sigilPulse 5s ease-in-out infinite, sigilDrift 8s ease-in-out infinite;
}

@keyframes sigilPulse {
  0%, 100% {
    filter: 
      drop-shadow(0 0 4px rgba(255, 229, 0, 0.4))
      drop-shadow(0 0 12px rgba(255, 229, 0, 0.2))
      drop-shadow(0 0 20px rgba(255, 200, 0, 0.1));
  }
  50% {
    filter: 
      drop-shadow(0 0 6px rgba(255, 229, 0, 0.55))
      drop-shadow(0 0 16px rgba(255, 229, 0, 0.3))
      drop-shadow(0 0 28px rgba(255, 180, 0, 0.15));
  }
}

/* Subtle rotation drift */
@keyframes sigilDrift {
  0%, 100% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(0.5deg) scale(1.01); }
  50% { transform: rotate(-0.3deg) scale(0.99); }
  75% { transform: rotate(0.2deg) scale(1.005); }
}

/* ============================================================
   COUNTDOWN - MASSIVE GLOWING DISPLAY
============================================================ */
#countdown {
  font-size: 3.2em !important;
  font-weight: 900;
  color: #00FFFF !important;
  letter-spacing: 0.12em !important;
  text-shadow: 
    0 0 5px #00FFFF,
    0 0 15px #00FFFF,
    0 0 30px #00FFFF,
    0 0 60px rgba(0, 255, 255, 0.7),
    0 0 100px rgba(0, 255, 255, 0.4),
    0 0 150px rgba(255, 0, 200, 0.2) !important;
  filter: drop-shadow(0 0 20px rgba(0, 255, 255, 0.5));
  animation: countdownPulse 3s ease-in-out infinite;
}

@keyframes countdownPulse {
  0%, 100% {
    text-shadow: 
      0 0 5px #00FFFF,
      0 0 15px #00FFFF,
      0 0 30px #00FFFF,
      0 0 60px rgba(0, 255, 255, 0.6),
      0 0 100px rgba(0, 255, 255, 0.3);
    filter: drop-shadow(0 0 15px rgba(0, 255, 255, 0.4));
  }
  50% {
    text-shadow: 
      0 0 8px #00FFFF,
      0 0 20px #00FFFF,
      0 0 40px #00FFFF,
      0 0 80px rgba(0, 255, 255, 0.8),
      0 0 120px rgba(0, 255, 255, 0.5),
      0 0 180px rgba(255, 0, 200, 0.2);
    filter: drop-shadow(0 0 25px rgba(0, 255, 255, 0.6));
  }
}

#clock {
  text-shadow: 
    0 0 8px rgba(0, 255, 255, 0.8),
    0 0 20px rgba(0, 255, 255, 0.4) !important;
}

/* ============================================================
   AUDIO VISUALIZER - DRAMATIC FULL-WIDTH
============================================================ */
#viz {
  height: 180px !important;
  opacity: 0.95 !important;
  filter: 
    drop-shadow(0 0 10px rgba(0, 255, 255, 0.6))
    drop-shadow(0 0 30px rgba(0, 255, 255, 0.4))
    drop-shadow(0 0 60px rgba(255, 0, 200, 0.2)) !important;
  mask-image: linear-gradient(to top, black 0%, black 60%, transparent 100%);
  -webkit-mask-image: linear-gradient(to top, black 0%, black 60%, transparent 100%);
}

/* ============================================================
   CRT SCANLINES - MORE CINEMATIC
============================================================ */
#crtOverlay {
  background: 
    repeating-linear-gradient(
      to bottom, 
      rgba(0, 0, 0, 0.05) 0px, 
      rgba(0, 0, 0, 0.05) 1px, 
      transparent 1px, 
      transparent 3px
    ) !important;
  opacity: 0.2 !important;
  mix-blend-mode: multiply !important;
}

/* ============================================================
   SCREEN WARP / BREATHING HALO
============================================================ */
#screenWarp {
  background: radial-gradient(
    ellipse 60% 50% at 50% 45%,
    rgba(0, 200, 255, 0.03) 0%,
    transparent 50%
  ) !important;
  animation: screenBreath 6s ease-in-out infinite;
}

@keyframes screenBreath {
  0%, 100% {
    opacity: 0.5;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.02);
  }
}

/* ============================================================
   BACKGROUND FLICKER - AUDIO REACTIVE ENHANCEMENT
============================================================ */
#backgroundFlicker {
  background: radial-gradient(
    ellipse 70% 60% at 50% 45%,
    rgba(0, 200, 255, 0.15) 0%,
    rgba(255, 0, 200, 0.05) 40%,
    transparent 70%
  ) !important;
  mix-blend-mode: screen;
}

/* ============================================================
   BLEED TEXT - MORE DRAMATIC
============================================================ */
#bleedText {
  font-size: 2rem !important;
  letter-spacing: 0.5em !important;
  text-shadow: 
    0 0 10px currentColor,
    0 0 30px currentColor,
    0 0 60px currentColor !important;
}

/* ============================================================
   CONTROL PANEL - REFINED
============================================================ */
#controlPanel {
  background: rgba(5, 10, 20, 0.95) !important;
  border: 1px solid rgba(0, 255, 255, 0.3) !important;
  box-shadow: 
    0 0 30px rgba(0, 0, 0, 0.8),
    0 0 60px rgba(0, 200, 255, 0.1),
    inset 0 0 30px rgba(0, 0, 0, 0.5) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

#trackScroll {
  text-shadow: 0 0 10px rgba(0, 255, 255, 0.6) !important;
}

/* ============================================================
   LINK BAR - REFINED GLOW
============================================================ */
#linkBar .link-btn {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 
    0 0 15px rgba(0, 255, 255, 0.2),
    inset 0 0 20px rgba(0, 0, 0, 0.5) !important;
}

#linkBar .link-btn:hover {
  box-shadow: 
    0 0 30px rgba(0, 255, 255, 0.4),
    0 0 60px rgba(0, 255, 255, 0.2),
    inset 0 0 20px rgba(0, 255, 255, 0.1) !important;
}

/* ============================================================
   AMBIENT SCREEN GLOW LAYER
   Adds soft light emanating from TV screen area
============================================================ */
.screen-ambient-glow {
  position: fixed;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  width: 70vw;
  height: 50vh;
  background: radial-gradient(
    ellipse 100% 100% at 50% 50%,
    rgba(0, 180, 255, 0.04) 0%,
    rgba(0, 150, 255, 0.02) 30%,
    transparent 60%
  );
  pointer-events: none;
  z-index: 1;
  filter: blur(40px);
  animation: ambientGlow 8s ease-in-out infinite;
}

@keyframes ambientGlow {
  0%, 100% {
    opacity: 0.6;
    transform: translateX(-50%) scale(1);
  }
  50% {
    opacity: 1;
    transform: translateX(-50%) scale(1.1);
  }
}

/* Secondary magenta ambient */
.screen-ambient-glow-secondary {
  position: fixed;
  top: 30%;
  left: 50%;
  transform: translateX(-50%);
  width: 50vw;
  height: 40vh;
  background: radial-gradient(
    ellipse 100% 100% at 50% 50%,
    rgba(255, 0, 180, 0.025) 0%,
    transparent 50%
  );
  pointer-events: none;
  z-index: 1;
  filter: blur(60px);
  animation: ambientGlow 10s ease-in-out infinite 2s;
}

/* ============================================================
   VIGNETTE OVERLAY - CINEMATIC DEPTH
============================================================ */
.terminal-vignette {
  position: fixed;
  inset: 0;
  background: radial-gradient(
    ellipse 70% 60% at 50% 50%,
    transparent 0%,
    transparent 40%,
    rgba(0, 0, 0, 0.3) 70%,
    rgba(0, 0, 0, 0.7) 100%
  );
  pointer-events: none;
  z-index: 7;
}

/* ============================================================
   NOISE GRAIN OVERLAY
============================================================ */
.terminal-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
  animation: grainDrift 0.1s steps(4) infinite;
}

@keyframes grainDrift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-1%, 1%); }
  50% { transform: translate(1%, -1%); }
  75% { transform: translate(-1%, -1%); }
  100% { transform: translate(0, 0); }
}

/* ============================================================
   CURSOR GHOST - ENHANCED TRAIL
============================================================ */
#cursorGhost {
  box-shadow: 
    0 0 10px rgba(0, 255, 255, 0.8),
    0 0 20px rgba(0, 255, 255, 0.5),
    0 0 40px rgba(0, 255, 255, 0.3) !important;
}

/* ============================================================
   SIGNAL LOSS FLASH - MORE DRAMATIC
============================================================ */
#signalLoss.glitching {
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.1) 45%,
    rgba(0, 255, 255, 0.3) 50%,
    rgba(255, 255, 255, 0.1) 55%,
    transparent 100%
  ) !important;
  animation: signalSweep 0.15s ease-out !important;
}

@keyframes signalSweep {
  0% { 
    transform: translateX(-100%);
    opacity: 1;
  }
  100% { 
    transform: translateX(100%);
    opacity: 0;
  }
}

/* ============================================================
   ACHIEVEMENT POPUP - POLISHED
============================================================ */
.achievement-popup {
  background: rgba(5, 10, 20, 0.98) !important;
  border: 2px solid rgba(0, 255, 255, 0.5) !important;
  box-shadow: 
    0 0 40px rgba(0, 255, 255, 0.4),
    0 0 80px rgba(0, 255, 255, 0.2),
    0 10px 40px rgba(0, 0, 0, 0.8),
    inset 0 0 40px rgba(0, 0, 0, 0.5) !important;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.achievement-icon {
  text-shadow: 
    0 0 10px #00ffff,
    0 0 30px #00ffff !important;
  filter: drop-shadow(0 0 10px rgba(0, 255, 255, 0.6));
}

/* ============================================================
   MOBILE ADJUSTMENTS
============================================================ */
@media (max-width: 768px) {
  #countdown {
    font-size: 2em !important;
  }
  
  #viz {
    height: 120px !important;
  }
  
  .screen-ambient-glow,
  .screen-ambient-glow-secondary {
    display: none;
  }
  
  .terminal-particles {
    display: none;
  }
}

/* ============================================================
   REDUCED MOTION
============================================================ */
@media (prefers-reduced-motion: reduce) {
  #crtShell,
  #glitchGhost,
  #countdown,
  .screen-ambient-glow,
  .screen-ambient-glow-secondary,
  #screenWarp {
    animation: none !important;
  }
  
  .terminal-particles,
  .terminal-grain {
    display: none;
  }
}
