/* =========================================================
   ENHANCED AMBIENT EFFECTS — ADDITIVE ONLY
   Requires: existing portfolio CSS (do NOT remove anything)
   ========================================================= */

/* ================= SVG GLASS DISTORTION SUPPORT =================
   NOTE: requires <svg filter id="glassDistortion"> in HTML
   This CSS safely references it (no break if missing)
------------------------------------------------------------------ */

/* ================= LAYER FIX (NON-DESTRUCTIVE) ================= */

.square-particles {
    position: fixed;
    inset: 0;
    z-index: -2; /* below particles-js, above bg-noise */
    pointer-events: none;
    overflow: hidden;
}

/* ================= GLASS WIREFRAME SQUARES ================= */

.square-particles span {
    position: absolute;
    width: var(--size);
    height: var(--size);

    /* outline-only glass look */
    background: transparent;
    border: 1.5px solid var(--accent-live, var(--accent));
    border-radius: 8px;

    opacity: var(--opacity);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    filter: blur(var(--blur)) url(#glassDistortion);

    animation:
            squareFloat var(--moveDur) linear infinite,
            squareBreathe var(--breathDur) ease-in-out infinite;

    will-change: transform, opacity;
    transform-origin: center;
}

/* ================= FLOATING MOTION ================= */

@keyframes squareFloat {
    from {
        transform: translateY(110vh) rotate(0deg);
    }
    to {
        transform: translateY(-20vh) rotate(180deg);
    }
}

/* ================= BREATHING MOTION ================= */

@keyframes squareBreathe {
    0%, 100% {
        opacity: calc(var(--opacity) * 0.8);
    }
    50% {
        opacity: calc(var(--opacity) * 1.1);
    }
}

/* ================= ACCENT COLOR LIVE BINDING =================
   Allows JS to change accent per section safely
---------------------------------------------------------------- */

:root {
    --accent-live: var(--accent);
}

.accent {
    color: var(--accent-live) !important;
}

.btn,
.filter-active {
    background-color: var(--accent-live) !important;
}

.square-particles span {
    border-color: var(--accent-live);
}

/* ================= DEPTH / PARALLAX PREP =================
   JS controls transforms — CSS ensures GPU path
---------------------------------------------------------------- */

.square-particles span {
    transform-style: preserve-3d;
}

/* ================= MOBILE OPTIMIZATION ================= */

@media (max-width: 768px) {
    .square-particles span {
        opacity: calc(var(--opacity) * 0.6);
        filter: blur(calc(var(--blur) + 1px));
    }
}

/* ================= REDUCED MOTION SAFETY ================= */

@media (prefers-reduced-motion: reduce) {
    .square-particles span {
        animation: none !important;
        transform: none !important;
        opacity: 0.08 !important;
    }
}

/* ================= VISUAL POLISH =================
   Slight glow when overlapping bright areas
---------------------------------------------------------------- */

.square-particles span {
    box-shadow: 0 0 0 transparent;
}

@media (hover: hover) {
    .square-particles span {
        transition: box-shadow 300ms ease;
    }
}
