/* ============================================================
   ANIMATED BACKGROUND SYSTEM v2
   Grid + Glow Orbs — refined for Light & Dark modes
   Save to: css/global/background.css
   ============================================================ */

/* ============================================================
   LAYER STACKING
   z-index 0: grid
   z-index 1: orbs (above grid so glows bleed through)
   z-index 2: grain
   z-index 1000+: page content (header, navbar, etc.)
   ============================================================ */
/* Ensure header and navbar stay above background */
header {
  position: fixed;
  z-index: 1000;
}

nav.nav-bar {
  z-index: 999;
}

main,
footer {
  position: relative;
  z-index: 10;
}

/* ============================================================
   1. ANIMATED GRID LAYER
   ============================================================ */
.bg-grid {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

/* The actual grid — oversized and slowly pans to feel alive */
.bg-grid::before {
  content: '';
  position: absolute;
  inset: -64px;
  animation: grid-pan 30s linear infinite;
  will-change: transform;

  /* LIGHT MODE: faint slate gridlines */
  background-image:
    linear-gradient(to right,  rgba(100, 116, 139, 0.18) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(100, 116, 139, 0.18) 1px, transparent 1px);
  background-size: 32px 32px;
}

/* DARK MODE: slate-700 gridlines at higher contrast */
[data-theme='dark'] .bg-grid::before {
  background-image:
    linear-gradient(to right,  rgba(71, 85, 105, 0.38) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(71, 85, 105, 0.38) 1px, transparent 1px);
}

/* Radial vignette — fades grid edges into the page bg color */
.bg-grid::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse 90% 70% at 50% 40%,
    transparent 20%,
    var(--bg-body) 85%
  );
}

/* Subtle slow pan — feels like the grid is breathing */
@keyframes grid-pan {
  0%   { transform: translate(0px,   0px); }
  25%  { transform: translate(10px,  14px); }
  50%  { transform: translate(20px,  0px); }
  75%  { transform: translate(10px, -14px); }
  100% { transform: translate(0px,   0px); }
}

/* ============================================================
   2. ORB CONTAINER
   ============================================================ */
.bg-orbs {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

/* Base orb — each orb sets its own animation and colors */
.bg-orb {
  position: absolute;
  border-radius: 50%;
  will-change: transform, opacity;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
}

/* ============================================================
   LIGHT MODE ORBS
   Barely-there lavender/indigo — the grid carries the visual
   weight; orbs add warmth + focal depth only.
   ============================================================ */

.bg-orb-1 {
  width: 700px; height: 700px;
  top: -200px; left: -150px;
  filter: blur(110px);
  background: radial-gradient(circle,
    rgba(92, 43, 182, 0.14) 0%,
    rgba(113, 43, 182, 0.06) 55%,
    transparent 75%);
  animation: orb-drift-1 18s ease-in-out infinite alternate;
}

.bg-orb-2 {
  width: 550px; height: 550px;
  top: -100px; right: -100px;
  filter: blur(95px);
  background: radial-gradient(circle,
    rgba(50, 43, 182, 0.11) 0%,
    rgba(92, 43, 182, 0.04) 60%,
    transparent 75%);
  animation: orb-drift-2 22s ease-in-out infinite alternate;
}

.bg-orb-3 {
  width: 500px; height: 500px;
  top: 45vh; right: -100px;
  filter: blur(95px);
  background: radial-gradient(circle,
    rgba(140, 50, 210, 0.09) 0%,
    transparent 70%);
  animation: orb-drift-3 26s ease-in-out infinite alternate;
}

.bg-orb-4 {
  width: 600px; height: 600px;
  bottom: 5vh; left: -100px;
  filter: blur(105px);
  background: radial-gradient(circle,
    rgba(56, 89, 210, 0.10) 0%,
    rgba(92, 43, 182, 0.04) 60%,
    transparent 75%);
  animation: orb-drift-4 20s ease-in-out infinite alternate;
}

.bg-orb-5 {
  width: 800px; height: 800px;
  top: 50%; left: 50%;
  filter: blur(130px);
  background: radial-gradient(circle,
    rgba(92, 43, 182, 0.05) 0%,
    transparent 70%);
  animation: orb-pulse 24s ease-in-out infinite alternate;
}

.bg-orb-6 {
  width: 450px; height: 450px;
  bottom: -80px; right: 10%;
  filter: blur(85px);
  background: radial-gradient(circle,
    rgba(113, 43, 182, 0.09) 0%,
    transparent 70%);
  animation: orb-drift-1 28s ease-in-out infinite alternate-reverse;
}

/* ============================================================
   DARK MODE ORBS
   Vivid electric glows — neon violet, cobalt, magenta.
   The grid is visible underneath; orbs illuminate it.
   ============================================================ */

[data-theme='dark'] .bg-orb-1 {
  filter: blur(90px);
  background: radial-gradient(circle,
    rgba(167, 139, 250, 0.30) 0%,
    rgba(139,  92, 246, 0.14) 45%,
    transparent 70%);
}

[data-theme='dark'] .bg-orb-2 {
  filter: blur(80px);
  background: radial-gradient(circle,
    rgba(99, 102, 241, 0.28) 0%,
    rgba(139,  92, 246, 0.11) 55%,
    transparent 75%);
}

[data-theme='dark'] .bg-orb-3 {
  filter: blur(85px);
  background: radial-gradient(circle,
    rgba(192,  38, 211, 0.24) 0%,
    rgba(167, 139, 250, 0.09) 55%,
    transparent 75%);
}

[data-theme='dark'] .bg-orb-4 {
  filter: blur(90px);
  background: radial-gradient(circle,
    rgba(79, 70, 229, 0.26) 0%,
    rgba(139, 92, 246, 0.10) 55%,
    transparent 75%);
}

[data-theme='dark'] .bg-orb-5 {
  filter: blur(115px);
  background: radial-gradient(circle,
    rgba(167, 139, 250, 0.14) 0%,
    transparent 70%);
}

[data-theme='dark'] .bg-orb-6 {
  filter: blur(75px);
  background: radial-gradient(circle,
    rgba(139, 92, 246, 0.22) 0%,
    rgba(99, 102, 241, 0.07) 60%,
    transparent 75%);
}

/* ============================================================
   3. GRAIN OVERLAY
   Unifies grid + orbs into one cohesive texture — prevents
   the glows from looking like flat colored blobs.
   ============================================================ */
.bg-grain {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  z-index: 2;
  pointer-events: none;
  opacity: 0.022;
  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.85' 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: 200px 200px;
}

[data-theme='dark'] .bg-grain {
  opacity: 0.050;
}

/* ============================================================
   4. KEYFRAME ANIMATIONS
   ============================================================ */

@keyframes orb-drift-1 {
  0%   { transform: translate(0px,    0px)   scale(1);    opacity: 0.90; }
  33%  { transform: translate(70px,   50px)  scale(1.08); opacity: 1;    }
  66%  { transform: translate(30px,   90px)  scale(0.94); opacity: 0.85; }
  100% { transform: translate(-50px,  40px)  scale(1.06); opacity: 0.80; }
}

@keyframes orb-drift-2 {
  0%   { transform: translate(0px,    0px)   scale(1);    opacity: 0.85; }
  25%  { transform: translate(-60px,  70px)  scale(1.10); opacity: 0.70; }
  75%  { transform: translate(-90px,  25px)  scale(0.92); opacity: 1;    }
  100% { transform: translate(-40px,  80px)  scale(1.07); opacity: 0.88; }
}

@keyframes orb-drift-3 {
  0%   { transform: translate(0px,     0px)   scale(1);    opacity: 0.75; }
  40%  { transform: translate(-70px,  -60px)  scale(1.12); opacity: 1;    }
  80%  { transform: translate(-110px,  35px)  scale(0.90); opacity: 0.80; }
  100% { transform: translate(-55px,  -25px)  scale(1.08); opacity: 0.88; }
}

@keyframes orb-drift-4 {
  0%   { transform: translate(0px,    0px)    scale(1);    opacity: 0.80; }
  30%  { transform: translate(80px,  -50px)   scale(1.07); opacity: 1;    }
  70%  { transform: translate(50px,  -90px)   scale(0.93); opacity: 0.82; }
  100% { transform: translate(100px, -30px)   scale(1.10); opacity: 0.70; }
}

@keyframes orb-pulse {
  0%   { transform: translate(-50%, -50%) scale(0.88); opacity: 0.50; }
  50%  { transform: translate(-50%, -50%) scale(1.06); opacity: 0.85; }
  100% { transform: translate(-50%, -50%) scale(0.93); opacity: 0.60; }
}

/* ============================================================
   5. REDUCE MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .bg-orb            { animation: none !important; }
  .bg-grid::before   { animation: none !important; }
}