/**
 * ClashPush — Global animated background system
 * Layers: grid → orbs → stars → mouse-follow glow → scan line
 * Loaded on every page via includes/layout.php
 */

.cp-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
    background:
        radial-gradient(ellipse 80% 60% at 50% -10%, rgba(76, 29, 149, 0.25) 0%, transparent 60%),
        linear-gradient(180deg, var(--bg2, #0d1030) 0%, var(--bg, #07091a) 40%);
}

/* Content stacking — everything real sits above the background */
.topbar,
.main-content,
.footer,
.cookie-banner {
    position: relative;
    z-index: 1;
}

/* ---------------------------------------------------------------------------
   Layer 1 — Grid
--------------------------------------------------------------------------- */
.cp-bg-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(124, 58, 237, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(124, 58, 237, 0.04) 1px, transparent 1px);
    background-size: 60px 60px;
    mask-image: radial-gradient(ellipse 90% 80% at 50% 30%, #000 0%, transparent 100%);
    -webkit-mask-image: radial-gradient(ellipse 90% 80% at 50% 30%, #000 0%, transparent 100%);
}

/* ---------------------------------------------------------------------------
   Layer 2 — Floating orbs
--------------------------------------------------------------------------- */
.cp-bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    will-change: transform;
}

.cp-bg-orb--1 {
    width: 500px;
    height: 500px;
    top: -120px;
    left: -120px;
    background: #7c3aed;
    opacity: 0.18;
    animation: cpOrbFloat1 20s ease-in-out infinite;
}

.cp-bg-orb--2 {
    width: 400px;
    height: 400px;
    bottom: -100px;
    right: -100px;
    background: #f59e0b;
    opacity: 0.15;
    animation: cpOrbFloat2 25s ease-in-out infinite;
}

.cp-bg-orb--3 {
    width: 300px;
    height: 300px;
    top: 40%;
    right: 12%;
    background: #0ea5e9;
    opacity: 0.15;
    animation: cpOrbFloat3 18s ease-in-out infinite;
}

@keyframes cpOrbFloat1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%      { transform: translate(80px, 60px) scale(1.08); }
    66%      { transform: translate(30px, 120px) scale(0.94); }
}

@keyframes cpOrbFloat2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%      { transform: translate(-90px, -50px) scale(1.1); }
    66%      { transform: translate(-40px, -110px) scale(0.92); }
}

@keyframes cpOrbFloat3 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50%      { transform: translate(-70px, 80px) scale(1.12); }
}

/* ---------------------------------------------------------------------------
   Layer 3 — Stars (spans injected by background.js)
--------------------------------------------------------------------------- */
.cp-bg-stars {
    position: absolute;
    inset: 0;
}

.cp-star {
    position: absolute;
    border-radius: 50%;
    animation: cpTwinkle var(--tw-dur, 4s) ease-in-out var(--tw-delay, 0s) infinite;
}

@keyframes cpTwinkle {
    0%, 100% { opacity: 0.15; transform: scale(0.8); }
    50%      { opacity: 0.9;  transform: scale(1.2); }
}

/* ---------------------------------------------------------------------------
   Layer 4 — Mouse-follow glow (vars --mx / --my set by background.js)
--------------------------------------------------------------------------- */
.cp-bg-glow {
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse 60% 40% at var(--mx, 50%) var(--my, 30%),
        rgba(124, 58, 237, 0.12) 0%,
        transparent 70%
    );
    animation: cpGlowHue 14s ease-in-out infinite;
}

@keyframes cpGlowHue {
    0%, 100% { filter: hue-rotate(0deg);   opacity: 1; }
    50%      { filter: hue-rotate(-75deg); opacity: 0.85; } /* drifts toward gold */
}

/* ---------------------------------------------------------------------------
   Layer 5 — Scan line
--------------------------------------------------------------------------- */
.cp-bg-scanline {
    position: absolute;
    left: 0;
    right: 0;
    top: -2px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(245, 158, 11, 0.8), transparent);
    opacity: 0.03;
    animation: cpScan 8s linear infinite;
}

@keyframes cpScan {
    0%   { transform: translateY(0); }
    100% { transform: translateY(100vh); }
}

/* ---------------------------------------------------------------------------
   Scroll reveal
--------------------------------------------------------------------------- */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.7s ease, transform 0.7s ease;
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ---------------------------------------------------------------------------
   Performance: mobile + reduced motion
--------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .cp-bg-orb { filter: blur(60px); animation-duration: 30s; }
    .cp-bg-orb--3 { display: none; }
    .cp-bg-scanline { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .cp-bg-orb,
    .cp-star,
    .cp-bg-glow,
    .cp-bg-scanline {
        animation: none !important;
    }
    .reveal {
        opacity: 1;
        transform: none;
        transition: none;
    }
}
