/* ===== ANIMATED BACKGROUND SYSTEM ===== */

/* Base background color on body */
body {
  background-color: var(--color-bg);
}

/* Layer 1: Gradient mesh (JS-driven inline styles) */
#bg-canvas {
  position: fixed;
  inset: 0;
  z-index: -3;
  overflow: hidden;
}

/* Canvas layer - particles & connections (on top of gradients) */
#bg-particles {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
}

/* Layer 2: Floating shapes with parallax (JS-driven transforms) */
.bg-shape {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  will-change: transform;
}

.bg-shape--1 {
  width: 600px;
  height: 600px;
  background: var(--color-primary);
  top: -15%;
  left: -10%;
  opacity: 0.18;
}

.bg-shape--2 {
  width: 500px;
  height: 500px;
  background: var(--color-accent-1);
  top: 15%;
  right: -15%;
  opacity: 0.15;
}

.bg-shape--3 {
  width: 450px;
  height: 450px;
  background: var(--color-accent-2);
  top: 45%;
  left: 5%;
  opacity: 0.12;
}

.bg-shape--4 {
  width: 400px;
  height: 400px;
  background: var(--color-turna);
  top: 65%;
  right: 10%;
  opacity: 0.1;
}

.bg-shape--5 {
  width: 550px;
  height: 550px;
  background: var(--color-calcio);
  top: 30%;
  left: 40%;
  opacity: 0.08;
}

.bg-shape--6 {
  width: 350px;
  height: 350px;
  background: var(--color-cercaleeds);
  top: 80%;
  left: 25%;
  opacity: 0.1;
}

/* Perspective grid overlay */
#bg-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
  background:
    linear-gradient(rgba(99, 102, 241, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99, 102, 241, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 80% 50% at 50% 50%, black 20%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse 80% 50% at 50% 50%, black 20%, transparent 70%);
}

#bg-grid.is-visible {
  opacity: 1;
}

/* Layer 3: Grain texture overlay */
#bg-grain {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.03;
  pointer-events: none;
  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.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .bg-shape {
    display: none;
  }

  #bg-particles {
    display: none;
  }

  #bg-canvas {
    background:
      radial-gradient(ellipse at 20% 30%, rgba(99, 102, 241, 0.15) 0%, transparent 70%),
      radial-gradient(ellipse at 80% 70%, rgba(6, 182, 212, 0.12) 0%, transparent 70%),
      var(--color-bg);
  }
}
