/* ========================================
   Animated Background (CSS-only, replaces Three.js)
   ======================================== */

/* Main background container */
.animated-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -10;
  background: var(--color-bg-primary);
  overflow: hidden;
}

/* Gradient Grid Pattern */
.gradient-grid {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(
      to right,
      var(--color-overlay-light) 1px,
      transparent 1px
    ),
    linear-gradient(to bottom, var(--color-overlay-light) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(circle at 50% 0%, white 20%, transparent 70%);
  -webkit-mask-image: radial-gradient(
    circle at 50% 0%,
    white 20%,
    transparent 70%
  );
}

/* Radial Gradient Backdrop */
.radial-gradient {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at 50% 0%,
    rgba(0, 0, 0, 0) 6%,
    rgba(0, 0, 0, 0.8) 45%
  );
  pointer-events: none;
}

/* Spotlight Effect (follows mouse cursor) */
.spotlight {
  position: fixed;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    var(--color-overlay-medium) 0%,
    transparent 70%
  );
  pointer-events: none;
  transition: transform 0.2s ease-out;
  transform: translate(-50%, -50%);
  z-index: 0;
  mix-blend-mode: lighten;
}

/* Floating Particles */
.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 1) 0%,
    rgba(255, 255, 255, 0.8) 40%,
    rgba(255, 255, 255, 0.4) 100%
  );
  border-radius: 50%;
  opacity: 0.6;
  will-change: transform, opacity, box-shadow;
  backface-visibility: hidden;
  transform: translateZ(0);
  box-shadow: 0 0 3px rgba(255, 255, 255, 0.5);
}

/* Simple float animations - just gentle movement */
.particle.float-x {
  animation: float-x var(--float-duration, 25s) infinite ease-in-out;
}

.particle.float-diagonal {
  animation: float-diagonal var(--float-duration, 25s) infinite ease-in-out;
}

.particle.float-circular {
  animation: float-circular var(--float-duration, 25s) infinite ease-in-out;
}

.particle.float-wave {
  animation: float-wave var(--float-duration, 25s) infinite ease-in-out;
}

/* Default float animation */
.particle:not(.float-x):not(.float-diagonal):not(.float-circular):not(
    .float-wave
  ) {
  animation: float var(--float-duration, 25s) infinite ease-in-out;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

@keyframes float-x {
  0%,
  100% {
    transform: translate(0, 0);
  }
  50% {
    transform: translate(10px, -6px);
  }
}

@keyframes float-diagonal {
  0%,
  100% {
    transform: translate(0, 0);
  }
  50% {
    transform: translate(-8px, -10px);
  }
}

@keyframes float-circular {
  0%,
  100% {
    transform: translate(0, 0);
  }
  25% {
    transform: translate(6px, -4px);
  }
  50% {
    transform: translate(0, -10px);
  }
  75% {
    transform: translate(-6px, -4px);
  }
}

@keyframes float-wave {
  0%,
  100% {
    transform: translate(0, 0);
  }
  33% {
    transform: translate(5px, -6px);
  }
  66% {
    transform: translate(-5px, -8px);
  }
}

/* Particle size variants - brightness based on size */
.particle.tiny {
  width: 1px;
  height: 1px;
  opacity: 0.3;
  background: rgba(255, 255, 255, 0.5);
  box-shadow: 0 0 1px rgba(255, 255, 255, 0.3);
}

.particle.small {
  width: 2px;
  height: 2px;
  opacity: 0.45;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 1) 0%,
    rgba(255, 255, 255, 0.3) 100%
  );
  box-shadow: 0 0 3px rgba(255, 255, 255, 0.5), 0 0 1px rgba(255, 255, 255, 0.8);
}

.particle.medium {
  width: 3px;
  height: 3px;
  opacity: 0.65;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 1) 0%,
    rgba(255, 255, 255, 0.4) 100%
  );
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.6), 0 0 2px rgba(255, 255, 255, 1);
}

.particle.large {
  width: 4px;
  height: 4px;
  opacity: 0.85;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 1) 0%,
    rgba(255, 255, 255, 0.5) 100%
  );
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.8), 0 0 4px rgba(255, 255, 255, 1),
    0 0 1px rgba(255, 255, 255, 1);
}

/* Simple twinkle animation */
@keyframes twinkle-medium {
  0%,
  100% {
    opacity: var(--base-opacity, 0.5);
  }
  50% {
    opacity: calc(var(--base-opacity, 0.5) * 1.3);
  }
}

/* ========== Animated Gradient Orbs ========== */
.gradient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.3;
  animation: float-orb 20s infinite ease-in-out;
}

@keyframes float-orb {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }
  33% {
    transform: translate(100px, -50px) scale(1.1);
  }
  66% {
    transform: translate(-50px, 100px) scale(0.9);
  }
}

.gradient-orb.purple {
  background: var(--color-primary-dark);
  width: 300px;
  height: 300px;
  top: 10%;
  right: 20%;
  animation-duration: 25s;
}

.gradient-orb.blue {
  background: rgba(59, 130, 246, 0.2);
  width: 250px;
  height: 250px;
  bottom: 20%;
  left: 15%;
  animation-duration: 30s;
  animation-delay: -10s;
}

/* ========== Scanline Effect (Optional) ========== */
.scanline {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(
    to bottom,
    transparent,
    var(--color-overlay-dark),
    transparent
  );
  animation: scan 8s linear infinite;
  pointer-events: none;
  opacity: 0.3;
}

@keyframes scan {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(100vh);
  }
}

/* ========== Noise Texture (Subtle grain effect) ========== */
.noise {
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  opacity: 0.02;
  pointer-events: none;
}

/* ========== Vignette Effect ========== */
.vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at center,
    transparent 0%,
    transparent 50%,
    rgba(0, 0, 0, 0.3) 100%
  );
  pointer-events: none;
}

/* ========== Performance Optimizations ========== */
.animated-background * {
  will-change: transform;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  .particle,
  .gradient-orb,
  .scanline {
    animation: none;
  }

  .spotlight {
    transition: none;
  }
}
