/* ==========================================================================
   MATRIX RAIN CANVAS & BACKGROUND EFFECTS
   ========================================================================== */

/* Canvas styling */
#canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: 
    radial-gradient(circle at 20% 80%, rgba(0, 255, 65, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(0, 255, 255, 0.03) 0%, transparent 50%),
    radial-gradient(circle at 40% 40%, rgba(0, 255, 65, 0.02) 0%, transparent 50%),
    #000000;
  z-index: -10;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

/* Background grid overlay */
#canvas::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    linear-gradient(rgba(0, 255, 65, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 65, 0.03) 1px, transparent 1px);
  background-size: 20px 20px;
  opacity: 0.3;
  pointer-events: none;
  animation: gridPulse 4s ease-in-out infinite;
}

@keyframes gridPulse {
  0%, 100% { opacity: 0.1; }
  50% { opacity: 0.3; }
}

/* Container adjustments for layering */
.container {
  position: relative;
  z-index: 10;
}

/* Enhanced background effects */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: 
    radial-gradient(ellipse at top, rgba(0, 255, 65, 0.1) 0%, transparent 70%),
    radial-gradient(ellipse at bottom, rgba(0, 255, 255, 0.05) 0%, transparent 70%);
  z-index: -5;
  pointer-events: none;
  animation: backgroundShift 20s ease-in-out infinite;
}

@keyframes backgroundShift {
  0%, 100% { 
    transform: scale(1) rotate(0deg);
    opacity: 0.5;
  }
  25% { 
    transform: scale(1.1) rotate(1deg);
    opacity: 0.7;
  }
  50% { 
    transform: scale(0.9) rotate(-1deg);
    opacity: 0.3;
  }
  75% { 
    transform: scale(1.05) rotate(0.5deg);
    opacity: 0.6;
  }
}

/* Scanline effects */
body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(
    transparent 0%,
    rgba(0, 255, 65, 0.03) 50%,
    transparent 100%
  );
  background-size: 100% 4px;
  z-index: -3;
  pointer-events: none;
  animation: scanlines 0.1s linear infinite;
  opacity: 0.5;
}

@keyframes scanlines {
  0% { background-position: 0 0px; }
  100% { background-position: 0 4px; }
}

/* Performance optimizations */
.reduced-motion #canvas::before,
.reduced-motion body::before,
.reduced-motion body::after {
  animation: none;
}

.reduced-motion #canvas {
  background: #000000;
}

/* High contrast mode adjustments */
.high-contrast #canvas {
  background: #000000;
  filter: contrast(2);
}

.high-contrast #canvas::before {
  background-image: 
    linear-gradient(rgba(0, 255, 65, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 65, 0.1) 1px, transparent 1px);
}

/* Mobile optimizations */
@media screen and (max-width: 768px) {
  #canvas::before {
    background-size: 15px 15px;
    opacity: 0.2;
  }
  
  body::before {
    animation-duration: 30s;
  }
  
  body::after {
    opacity: 0.3;
  }
}

/* Low-end device optimizations */
@media screen and (max-width: 480px) {
  #canvas {
    background: #000000;
  }
  
  #canvas::before,
  body::before,
  body::after {
    display: none;
  }
}

/* Ultra-wide screen adjustments */
@media screen and (min-width: 1920px) {
  #canvas::before {
    background-size: 25px 25px;
  }
}

/* Dark mode enhancements */
@media (prefers-color-scheme: dark) {
  #canvas {
    background: 
      radial-gradient(circle at 20% 80%, rgba(0, 255, 65, 0.08) 0%, transparent 50%),
      radial-gradient(circle at 80% 20%, rgba(0, 255, 255, 0.05) 0%, transparent 50%),
      #000000;
  }
}

/* Print styles */
@media print {
  #canvas,
  #canvas::before,
  body::before,
  body::after {
    display: none;
  }
}