/* ========================================
   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;
  opacity: 0.5;
}

/* Floating Particles (Stars/Dots) - Smooth Movement */
.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;
  box-shadow: 0 0 3px rgba(255, 255, 255, 0.5);
  pointer-events: none;
  /* Default animation for all particles */
  animation: float 30s infinite ease-in-out;
}

/* Particle size variants */
.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);
}

/* Particle animations - Ultra Smooth Movement */
.particle.float-x {
  animation-name: float-x;
  animation-duration: var(--float-duration, 30s);
  animation-iteration-count: infinite;
  animation-timing-function: cubic-bezier(0.4, 0, 0.6, 1);
}

.particle.float-diagonal {
  animation-name: float-diagonal;
  animation-duration: var(--float-duration, 35s);
  animation-iteration-count: infinite;
  animation-timing-function: cubic-bezier(0.4, 0, 0.6, 1);
}

.particle.float-circular {
  animation-name: float-circular;
  animation-duration: var(--float-duration, 40s);
  animation-iteration-count: infinite;
  animation-timing-function: cubic-bezier(0.4, 0, 0.6, 1);
}

.particle.float-wave {
  animation-name: float-wave;
  animation-duration: var(--float-duration, 32s);
  animation-iteration-count: infinite;
  animation-timing-function: cubic-bezier(0.4, 0, 0.6, 1);
}

.particle:not(.float-x):not(.float-diagonal):not(.float-circular):not(.float-wave) {
  animation-name: float;
  animation-duration: var(--float-duration, 28s);
  animation-iteration-count: infinite;
  animation-timing-function: cubic-bezier(0.4, 0, 0.6, 1);
}

/* Smooth continuous drift for all particles */
.particle {
  animation-timing-function: cubic-bezier(0.4, 0, 0.6, 1);
  will-change: transform, opacity;
  transition: opacity 0.3s ease;
}

/* Enhanced smooth movement for different sizes - longer durations for smoother feel */
.particle.tiny {
  animation-duration: calc(var(--float-duration, 35s) * 1.3);
  animation-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.particle.small {
  animation-duration: calc(var(--float-duration, 35s) * 1.15);
  animation-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.particle.medium {
  animation-duration: var(--float-duration, 35s);
  animation-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.particle.large {
  animation-duration: calc(var(--float-duration, 35s) * 0.85);
  animation-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Subtle opacity pulse built into keyframes for smoother effect */

@keyframes float {
  0%, 100% {
    transform: translateY(0) translateX(0);
    opacity: 0.6;
  }
  25% {
    transform: translateY(-12px) translateX(3px);
    opacity: 0.8;
  }
  50% {
    transform: translateY(-15px) translateX(0);
    opacity: 1;
  }
  75% {
    transform: translateY(-8px) translateX(-3px);
    opacity: 0.8;
  }
}

@keyframes float-x {
  0%, 100% {
    transform: translate(0, 0);
    opacity: 0.6;
  }
  25% {
    transform: translate(15px, -4px);
    opacity: 0.8;
  }
  50% {
    transform: translate(20px, -8px);
    opacity: 1;
  }
  75% {
    transform: translate(10px, -12px);
    opacity: 0.8;
  }
}

@keyframes float-diagonal {
  0%, 100% {
    transform: translate(0, 0);
    opacity: 0.6;
  }
  25% {
    transform: translate(-12px, -6px);
    opacity: 0.8;
  }
  50% {
    transform: translate(-18px, -12px);
    opacity: 1;
  }
  75% {
    transform: translate(-8px, -15px);
    opacity: 0.8;
  }
}

@keyframes float-circular {
  0%, 100% {
    transform: translate(0, 0) rotate(0deg);
    opacity: 0.6;
  }
  25% {
    transform: translate(8px, -6px) rotate(90deg);
    opacity: 0.8;
  }
  50% {
    transform: translate(0, -15px) rotate(180deg);
    opacity: 1;
  }
  75% {
    transform: translate(-8px, -10px) rotate(270deg);
    opacity: 0.8;
  }
}

@keyframes float-wave {
  0%, 100% {
    transform: translate(0, 0);
    opacity: 0.6;
  }
  20% {
    transform: translate(6px, -4px);
    opacity: 0.75;
  }
  40% {
    transform: translate(8px, -10px);
    opacity: 0.9;
  }
  60% {
    transform: translate(-4px, -12px);
    opacity: 1;
  }
  80% {
    transform: translate(-6px, -8px);
    opacity: 0.85;
  }
}

/* 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;
  }
}
