/* ==========================================
   ANIMATED GRID BACKGROUND
   Subtle animated grid pattern for page background
   ========================================== */

.animated-grid-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.grid-canvas {
  position: absolute;
  top: -30%;
  left: 0;
  width: 100%;
  height: 160%;
  transform: skewY(-12deg);
}

.grid-pattern {
  width: 100%;
  height: 100%;
  background-image: 
    linear-gradient(rgba(37, 99, 235, 0.15) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37, 99, 235, 0.15) 1px, transparent 1px);
  background-size: 40px 40px;
  position: relative;
}

/* Radial gradient mask - fades at edges */
.grid-mask {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(
    circle 800px at center,
    transparent 0%,
    rgba(250, 251, 252, 0.1) 50%,
    rgba(250, 251, 252, 0.5) 80%,
    var(--bg-primary) 100%
  );
}

/* Animated squares */
.grid-square {
  position: absolute;
  width: 39px;
  height: 39px;
  background: currentColor;
  color: rgba(37, 99, 235, 0.35);
  animation: pulse-square 4s ease-in-out infinite;
  opacity: 0;
}

@keyframes pulse-square {
  0% {
    opacity: 0;
  }
  50% {
    opacity: 0.6;
  }
  100% {
    opacity: 0;
  }
}

/* Stagger animation delays for squares */
.grid-square:nth-child(2) { animation-delay: 0.2s; }
.grid-square:nth-child(3) { animation-delay: 0.4s; }
.grid-square:nth-child(4) { animation-delay: 0.6s; }
.grid-square:nth-child(5) { animation-delay: 0.8s; }
.grid-square:nth-child(6) { animation-delay: 1s; }
.grid-square:nth-child(7) { animation-delay: 1.2s; }
.grid-square:nth-child(8) { animation-delay: 1.4s; }
.grid-square:nth-child(9) { animation-delay: 1.6s; }
.grid-square:nth-child(10) { animation-delay: 1.8s; }
.grid-square:nth-child(11) { animation-delay: 2s; }
.grid-square:nth-child(12) { animation-delay: 2.2s; }
.grid-square:nth-child(13) { animation-delay: 2.4s; }
.grid-square:nth-child(14) { animation-delay: 2.6s; }
.grid-square:nth-child(15) { animation-delay: 2.8s; }
.grid-square:nth-child(16) { animation-delay: 3s; }
.grid-square:nth-child(17) { animation-delay: 3.2s; }
.grid-square:nth-child(18) { animation-delay: 3.4s; }
.grid-square:nth-child(19) { animation-delay: 3.6s; }
.grid-square:nth-child(20) { animation-delay: 3.8s; }

/* Additional subtle glow effect */
.grid-glow {
  position: absolute;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.03) 0%, transparent 70%);
  pointer-events: none;
  animation: float-glow 20s ease-in-out infinite;
}

.grid-glow:nth-child(1) {
  top: 20%;
  left: 10%;
  animation-delay: 0s;
}

.grid-glow:nth-child(2) {
  top: 60%;
  right: 10%;
  animation-delay: 5s;
  animation-duration: 25s;
}

.grid-glow:nth-child(3) {
  bottom: 10%;
  left: 30%;
  animation-delay: 10s;
  animation-duration: 30s;
}

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

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  .grid-square,
  .grid-glow {
    animation: none;
  }
  
  .grid-square {
    opacity: 0.05;
  }
}
