/* ============================================
   TERMINAL VISUAL EFFECTS
   Glitch burst, title wave sweep, purchase flash.
   Used by js/core/effects.js (TerminalEffects).

   Note: #terminal already has position: relative
   from terminal.css. CRT mode uses ::before and
   ::after on #terminal, so the glitch tear effect
   uses a real DOM element (.glitch-tear) instead
   of a pseudo-element to avoid conflicts.
   ============================================ */

/* ── Glitch Burst ─────────────────────────────
   Applied to #terminal for ~500ms.
   Combines screen shake, RGB channel split,
   horizontal tear lines, and block artifacts.
   ───────────────────────────────────────────── */

@keyframes glitchShake {
    0%   { transform: translate(0); }
    10%  { transform: translate(-3px, 2px); }
    20%  { transform: translate(2px, -1px); }
    30%  { transform: translate(-1px, 3px); }
    40%  { transform: translate(3px, 1px); }
    50%  { transform: translate(-2px, -3px); }
    60%  { transform: translate(1px, 2px); }
    70%  { transform: translate(-3px, -1px); }
    80%  { transform: translate(2px, 3px); }
    90%  { transform: translate(1px, -2px); }
    100% { transform: translate(0); }
}

#terminal.glitch-active {
    animation: glitchShake 0.1s linear infinite;
}

/* RGB channel split on text */
#terminal.glitch-active .terminal-content {
    text-shadow: -2px 0 #ff0000, 2px 0 #00ffff;
}

/* Horizontal tear lines — real element injected by JS
   (avoids collision with CRT ::after pseudo-element) */
.glitch-tear {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 3;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(255, 255, 255, 0.03) 2px,
        rgba(255, 255, 255, 0.03) 4px
    );
    /* Clip creates horizontal tear effect — JS animates these values */
    clip-path: inset(var(--glitch-tear-y, 30%) 0 var(--glitch-tear-y2, 60%) 0);
    background-color: rgba(255, 255, 255, 0.05);
}

/* Static noise canvas overlay (injected by JS) */
.glitch-noise {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
    opacity: 0.12;
    mix-blend-mode: overlay;
}

/* Glitch color blocks (injected by JS) */
.glitch-block {
    position: absolute;
    pointer-events: none;
    z-index: 3;
    opacity: 0.3;
    mix-blend-mode: screen;
}


/* ── Logo Color Wave ─────────────────────────
   Non-destructive spotlight sweep on ASCII logo.
   JS-driven via rAF: a brightness filter sweeps
   left-to-right across spans, creating a wave of
   white light. No background-clip:text needed.
   ───────────────────────────────────────────── */


/* ── Purchase Flash ───────────────────────────
   Brief green flash on an element after a shop
   purchase. Applied/removed by JS.
   ───────────────────────────────────────────── */

@keyframes purchaseFlash {
    0%   { background-color: transparent; }
    20%  { background-color: rgba(166, 227, 161, 0.3); }
    100% { background-color: transparent; }
}

.purchase-flash {
    animation: purchaseFlash 0.6s ease-out;
}


/* ── Reduced Motion ───────────────────────── */

@media (prefers-reduced-motion: reduce) {
    #terminal.glitch-active {
        animation: none;
    }

    .title-wave-char {
        animation-duration: 0.01ms;
    }

    .purchase-flash {
        animation-duration: 0.01ms;
    }
}
