/* =========================================================
   cyber-bg.css — Animated Cyber Background (index.php only)
   Colors: brand only — #0b0f14 base + #00ffa3/#00f5a0 neon
   ========================================================= */

/* ----------------------------------------------------------
   Wrapper — sits behind everything
   ---------------------------------------------------------- */
#cyber-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

/* ----------------------------------------------------------
   Layer 1 — subtle digital grid
   ---------------------------------------------------------- */
#cyber-bg__grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(0, 255, 163, 0.032) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 255, 163, 0.032) 1px, transparent 1px);
    background-size: 42px 42px;
    animation: gridDrift 32s linear infinite;
}

@keyframes gridDrift {
    0%   { background-position: 0 0; }
    100% { background-position: 42px 42px; }
}

/* ----------------------------------------------------------
   Layer 2 — Matrix/code canvas (injected by JS)
   ---------------------------------------------------------- */
#cyber-bg__canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0.42;
}

/* ----------------------------------------------------------
   Layer 3 — pulsing glow orbs
   ---------------------------------------------------------- */
#cyber-bg__glows {
    position: absolute;
    inset: 0;
}

.cg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    animation: orbPulse var(--orb-dur, 8s) ease-in-out infinite alternate;
}

.cg-orb--a {
    width: 500px;
    height: 500px;
    top: -100px;
    left: -80px;
    background: radial-gradient(circle, rgba(0, 255, 163, 0.13) 0%, transparent 70%);
    --orb-dur: 9s;
}

.cg-orb--b {
    width: 420px;
    height: 420px;
    bottom: -60px;
    right: -60px;
    background: radial-gradient(circle, rgba(0, 200, 130, 0.10) 0%, transparent 70%);
    --orb-dur: 11s;
    animation-delay: -4s;
}

.cg-orb--c {
    width: 280px;
    height: 280px;
    top: 40%;
    left: 50%;
    transform: translateX(-50%);
    background: radial-gradient(circle, rgba(0, 245, 160, 0.07) 0%, transparent 70%);
    --orb-dur: 13s;
    animation-delay: -7s;
}

@keyframes orbPulse {
    0%   { opacity: 0.5; transform: scale(1); }
    100% { opacity: 1;   transform: scale(1.15); }
}

.cg-orb--c {
    transform-origin: center center;
}

/* ----------------------------------------------------------
   Layer 4 — horizontal scan beams (one down, one up)
   ---------------------------------------------------------- */
#cyber-bg__scanbeam {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(0, 255, 163, 0.0) 10%,
        rgba(0, 255, 163, 0.65) 50%,
        rgba(0, 255, 163, 0.0) 90%,
        transparent 100%
    );
    box-shadow: 0 0 22px 5px rgba(0, 255, 163, 0.22);
    animation: scanBeamDown 8s linear infinite;
    opacity: 0.75;
}

#cyber-bg__scanbeam2 {
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255, 60, 60, 0.0) 15%,
        rgba(255, 60, 60, 0.45) 50%,
        rgba(255, 60, 60, 0.0) 85%,
        transparent 100%
    );
    box-shadow: 0 0 14px 3px rgba(255, 40, 40, 0.15);
    animation: scanBeamUp 13s linear infinite;
    animation-delay: -6s;
    opacity: 0.5;
}

@keyframes scanBeamDown {
    0%   { top: -2px;    opacity: 0; }
    4%   { opacity: 0.75; }
    96%  { opacity: 0.75; }
    100% { top: 100vh;   opacity: 0; }
}

@keyframes scanBeamUp {
    0%   { top: 100vh;   opacity: 0; }
    4%   { opacity: 0.5; }
    96%  { opacity: 0.5; }
    100% { top: -2px;    opacity: 0; }
}

/* ----------------------------------------------------------
   Layer 5 — CRT scan lines
   ---------------------------------------------------------- */
#cyber-bg__crt {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 3px,
        rgba(0, 0, 0, 0.09) 3px,
        rgba(0, 0, 0, 0.09) 4px
    );
    pointer-events: none;
}

/* ----------------------------------------------------------
   Heartbeat radar — a sudden rapid burst ring every ~15s
   ---------------------------------------------------------- */
.cg-radar--burst {
    animation: radarBurst 1.2s ease-out infinite;
    animation-delay: -0.6s;
    border-color: rgba(255, 60, 60, 0.55) !important;
    box-shadow: 0 0 6px rgba(255, 40, 40, 0.35);
}

@keyframes radarBurst {
    0%   { transform: scale(0.3);  opacity: 0.9; }
    100% { transform: scale(10);   opacity: 0;   }
}

/* ==========================================================
   LOGO-INSPIRED LAYERS — the "soul" of the brand in the bg
   Giant ghosted shield + glowing eyes + bubbling flask
   All positioned & scaled relative to .cg-logo-stage
   ========================================================== */

.cg-logo-stage {
    position: absolute;
    top: 50%;
    left: 50%;
    width: min(85vh, 850px);
    height: min(85vh, 850px);
    transform: translate(-50%, -50%);
    will-change: transform;
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Ghosted shield image — breathing slowly */
.cg-logo-ghost {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0.07;
    filter:
        drop-shadow(0 0 40px rgba(0, 255, 163, 0.35))
        drop-shadow(0 0 80px rgba(0, 255, 163, 0.18))
        brightness(1.2)
        contrast(1.1);
    animation: shieldBreath 9s ease-in-out infinite alternate;
    mix-blend-mode: screen;
}

@keyframes shieldBreath {
    0%   { transform: scale(1);    opacity: 0.06; }
    100% { transform: scale(1.04); opacity: 0.10; }
}

/* SVG layer aligned 1:1 with the logo image — for FX over specific points */
.cg-logo-fx {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}

/* Two mask eyes — JS-driven blink + look-around */
.cg-eye-group {
    transform-box: fill-box;
    transform-origin: center;
    transition: transform 0.5s cubic-bezier(0.3, 0.7, 0.4, 1);
}

.cg-eye-socket {
    fill: rgba(0, 0, 0, 0.5);
    filter: blur(0.3px);
}

.cg-eye-pupil {
    fill: #00ffa3;
    filter: drop-shadow(0 0 4px rgba(0, 255, 163, 1))
            drop-shadow(0 0 10px rgba(0, 255, 163, 0.7))
            drop-shadow(0 0 20px rgba(0, 255, 163, 0.4));
    transform-box: fill-box;
    transform-origin: center;
    transition: transform 0.6s cubic-bezier(0.3, 0.7, 0.4, 1),
                opacity 0.08s ease;
}

.cg-eye-pupil.is-blinking {
    transform: scaleY(0.05);
    opacity: 0.4;
}

.cg-eye-inner-glow {
    fill: rgba(255, 255, 255, 0.85);
    filter: blur(0.2px);
    animation: eyeInnerPulse 2.4s ease-in-out infinite alternate;
}
.cg-eye-group--r .cg-eye-inner-glow { animation-delay: -0.7s; }

@keyframes eyeInnerPulse {
    0%   { opacity: 0.5; }
    100% { opacity: 1;   }
}

/* Flask glow at center of shield — slow pulse */
.cg-flask-glow {
    fill: url(#cgFlaskGrad);
    animation: flaskPulse 4.5s ease-in-out infinite;
    transform-origin: center;
    transform-box: fill-box;
}

@keyframes flaskPulse {
    0%, 100% { opacity: 0.6;  transform: scale(1); }
    50%      { opacity: 1;    transform: scale(1.12); }
}

/* Liquid surface inside flask — wave shimmer */
.cg-flask-liquid {
    fill: url(#cgLiquidGrad);
    animation: liquidShimmer 3s ease-in-out infinite alternate;
    transform-box: fill-box;
    transform-origin: center bottom;
}

@keyframes liquidShimmer {
    0%   { opacity: 0.55; transform: scaleY(1);    }
    100% { opacity: 0.85; transform: scaleY(1.04); }
}

/* Bubbling specks rising inside flask */
.cg-bubble {
    fill: rgba(0, 255, 163, 0.95);
    filter: drop-shadow(0 0 1.5px rgba(0, 255, 163, 0.8));
    animation: bubbleRise 2.8s ease-in infinite;
    transform-box: fill-box;
    transform-origin: center;
}
.cg-bubble--1 { animation-delay: 0s;    }
.cg-bubble--2 { animation-delay: 0.55s; }
.cg-bubble--3 { animation-delay: 1.1s;  }
.cg-bubble--4 { animation-delay: 1.7s;  }
.cg-bubble--5 { animation-delay: 2.3s;  }

@keyframes bubbleRise {
    0%   { opacity: 0; transform: translateY(0)    scale(0.3); }
    15%  { opacity: 1; }
    100% { opacity: 0; transform: translateY(-9px) scale(1.1); }
}

/* Smoke/steam rising from the flask top */
.cg-smoke {
    fill: rgba(0, 255, 163, 0.35);
    filter: blur(1.2px);
    animation: smokeRise 5s ease-out infinite;
    transform-box: fill-box;
    transform-origin: center bottom;
    opacity: 0;
}
.cg-smoke--1 { animation-delay: 0s;   }
.cg-smoke--2 { animation-delay: 1.6s; }
.cg-smoke--3 { animation-delay: 3.2s; }

@keyframes smokeRise {
    0%   { opacity: 0;    transform: translateY(0)     scale(0.4) rotate(-5deg); }
    20%  { opacity: 0.55; }
    100% { opacity: 0;    transform: translateY(-22px) scale(2)   rotate(8deg); }
}

/* Energy pulse traveling through circuits — radial sweep */
.cg-circuit-pulse {
    fill: none;
    stroke: rgba(0, 255, 163, 0.45);
    stroke-width: 0.25;
    stroke-dasharray: 4 100;
    animation: circuitFlow 6s linear infinite;
}
.cg-circuit-pulse--2 { animation-delay: -2s; }
.cg-circuit-pulse--3 { animation-delay: -4s; }

@keyframes circuitFlow {
    0%   { stroke-dashoffset: 0;   opacity: 0; }
    10%  { opacity: 1; }
    90%  { opacity: 1; }
    100% { stroke-dashoffset: -104; opacity: 0; }
}

/* ==========================================================
   HUD PANELS — floating terminal widgets
   ========================================================== */

.cg-hud {
    position: absolute;
    font-family: 'Courier New', 'Consolas', monospace;
    font-size: 10.5px;
    color: rgba(0, 255, 163, 0.55);
    background: rgba(8, 14, 20, 0.55);
    border: 1px solid rgba(0, 255, 163, 0.18);
    border-radius: 6px;
    padding: 8px 12px;
    backdrop-filter: blur(2px);
    box-shadow: 0 0 18px rgba(0, 255, 163, 0.06),
                inset 0 0 12px rgba(0, 255, 163, 0.04);
    line-height: 1.55;
    letter-spacing: 0.02em;
    white-space: pre;
    pointer-events: none;
    will-change: transform, opacity;
    transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
    direction: ltr;
    text-align: left;
    animation: hudFlicker 6s steps(60, end) infinite;
}

.cg-hud::before {
    content: "";
    position: absolute;
    top: 6px; left: 8px;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #00ffa3;
    box-shadow: 0 0 6px rgba(0, 255, 163, 0.9);
    animation: hudDot 1.4s ease-in-out infinite;
}

.cg-hud__head {
    display: block;
    color: rgba(0, 255, 163, 0.85);
    font-weight: 700;
    margin: 0 0 4px 14px;
    font-size: 9.5px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.cg-hud__body {
    display: block;
    color: rgba(180, 255, 220, 0.55);
    font-size: 10.5px;
    min-height: 1.55em;
}

.cg-hud--tl { top: 12%;  left: 4%;  }
.cg-hud--tr { top: 18%;  right: 4%; }
.cg-hud--bl { bottom: 18%; left: 5%; }
.cg-hud--br { bottom: 12%; right: 5%; }

@keyframes hudDot {
    0%, 100% { opacity: 1;   }
    50%      { opacity: 0.3; }
}

@keyframes hudFlicker {
    0%, 96%, 100% { opacity: 1;    }
    97%           { opacity: 0.4;  }
    98%           { opacity: 0.85; }
    99%           { opacity: 0.55; }
}

/* Rotating HUD rings — concentric scanner circles */
.cg-ring {
    position: absolute;
    border-radius: 50%;
    border: 1px dashed rgba(0, 255, 163, 0.18);
    animation: ringSpin 30s linear infinite;
    pointer-events: none;
}

.cg-ring--inner {
    width: 240px; height: 240px;
    top: 50%; left: 50%;
    margin: -120px 0 0 -120px;
    animation-duration: 22s;
    border-style: dashed;
    border-color: rgba(0, 255, 163, 0.22);
}

.cg-ring--mid {
    width: 420px; height: 420px;
    top: 50%; left: 50%;
    margin: -210px 0 0 -210px;
    animation-duration: 38s;
    animation-direction: reverse;
    border-color: rgba(0, 255, 163, 0.13);
}

.cg-ring--outer {
    width: 620px; height: 620px;
    top: 50%; left: 50%;
    margin: -310px 0 0 -310px;
    animation-duration: 60s;
    border-color: rgba(0, 255, 163, 0.08);
}

@keyframes ringSpin {
    0%   { transform: rotate(0deg);   }
    100% { transform: rotate(360deg); }
}

/* Radar pulse — expanding ring */
.cg-radar {
    position: absolute;
    top: 50%; left: 50%;
    width: 50px; height: 50px;
    margin: -25px 0 0 -25px;
    border-radius: 50%;
    border: 1.5px solid rgba(0, 255, 163, 0.6);
    animation: radarPulse 4s ease-out infinite;
    pointer-events: none;
}
.cg-radar--2 { animation-delay: -1.3s; }
.cg-radar--3 { animation-delay: -2.6s; }

@keyframes radarPulse {
    0%   { transform: scale(0.4); opacity: 0.85; }
    100% { transform: scale(8);    opacity: 0;    }
}

/* ==========================================================
   ATMOSPHERE — fog + vignette
   ========================================================== */

.cg-fog {
    position: absolute;
    inset: -10%;
    background:
        radial-gradient(ellipse at 30% 40%, rgba(0, 255, 163, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 60%, rgba(0, 200, 130, 0.04) 0%, transparent 55%);
    filter: blur(40px);
    animation: fogDrift 30s ease-in-out infinite alternate;
    will-change: transform;
}

@keyframes fogDrift {
    0%   { transform: translate(0, 0)       scale(1);    }
    100% { transform: translate(3%, -2%)    scale(1.08); }
}

.cg-vignette {
    position: absolute;
    inset: 0;
    background:
        /* deep dark edge vignette */
        radial-gradient(
            ellipse at center,
            transparent 20%,
            rgba(0, 0, 0, 0.55) 65%,
            rgba(0, 0, 0, 0.88) 100%
        ),
        /* blood-red danger pulse at top-left corner — very faint */
        radial-gradient(
            ellipse at 0% 0%,
            rgba(120, 0, 0, 0.12) 0%,
            transparent 40%
        ),
        /* red tint bottom-right */
        radial-gradient(
            ellipse at 100% 100%,
            rgba(100, 0, 0, 0.10) 0%,
            transparent 40%
        );
    pointer-events: none;
    animation: vignetteBreath 14s ease-in-out infinite alternate;
}

@keyframes vignetteBreath {
    0%   { opacity: 0.9; }
    100% { opacity: 1;   }
}

/* ----------------------------------------------------------
   Layer 6 — dark overlay (readability guarantee)
   ---------------------------------------------------------- */
#cyber-bg__overlay {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg,
            rgba(11, 15, 20, 0.55) 0%,
            rgba(11, 15, 20, 0.35) 40%,
            rgba(11, 15, 20, 0.55) 100%
        );
}

/* ----------------------------------------------------------
   Subtle glitch flash (every ~20s, very gentle)
   ---------------------------------------------------------- */
@keyframes glitchFlash {
    0%,  100% { opacity: 0; }
    50%        { opacity: 1; }
}

.cg-glitch-bar {
    position: absolute;
    left: 0; right: 0;
    height: 1px;
    background: rgba(0, 255, 163, 0.35);
    animation: glitchFlash 0.12s steps(1) forwards;
    pointer-events: none;
}

/* ----------------------------------------------------------
   Make sure page content stays above bg
   ---------------------------------------------------------- */
main,
.tools-page {
    position: relative;
    z-index: 1;
}

/* ----------------------------------------------------------
   Mobile — lighter version for performance
   ---------------------------------------------------------- */
@media (max-width: 768px) {
    #cyber-bg__canvas   { opacity: 0.10; }
    #cyber-bg__grid     { background-size: 60px 60px; }
    #cyber-bg__scanbeam2 { display: none; }
    .cg-orb--a { width: 300px; height: 300px; }
    .cg-orb--b { width: 260px; height: 260px; }
    .cg-orb--c { display: none; }
    #cyber-bg__crt    { display: none; }

    .cg-logo-stage    { width: 90vw; height: 90vw; }
    .cg-logo-ghost    { opacity: 0.05; }
    .cg-fog           { display: none; }
    .cg-hud--bl, .cg-hud--tr { display: none; }
    .cg-ring--outer, .cg-ring--mid { display: none; }
    .cg-radar         { display: none; }
    .cg-radar--burst  { display: none; }
}

/* ----------------------------------------------------------
   Reduced-motion — strip all animations
   ---------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    #cyber-bg__grid,
    #cyber-bg__canvas,
    #cyber-bg__scanbeam,
    .cg-orb,
    .cg-logo-ghost,
    .cg-eye,
    .cg-flask-glow,
    .cg-bubble,
    .cg-circuit-pulse,
    .cg-fog {
        animation: none !important;
    }
    #cyber-bg__scanbeam  { display: none; }
    #cyber-bg__scanbeam2 { display: none; }
    .cg-logo-stage      { transition: none !important; }
}
