/**
 * LINTENIUM FIELD TERMINAL
 * Visual effects - Glitches, transitions, animations
 */

/* Glitch overlay */
.glitch-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: var(--z-overlay);
    opacity: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(255, 0, 110, 0.1) 0px,
        transparent 2px,
        rgba(0, 217, 255, 0.1) 4px
    );
    mix-blend-mode: overlay;
    transition: opacity 0.3s ease;
}

body.glitching .glitch-overlay {
    opacity: 1;
    animation: glitch-scan 0.5s steps(10) infinite;
}

@keyframes glitch-scan {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Text glitch effect */
.glitch-text {
    position: relative;
    animation: glitch-text 0.3s steps(5) infinite;
}

@keyframes glitch-text {
    0% {
        text-shadow:
            2px 0 var(--color-accent),
            -2px 0 var(--color-primary);
    }
    25% {
        text-shadow:
            -2px 0 var(--color-accent),
            2px 0 var(--color-primary);
    }
    50% {
        text-shadow:
            2px 0 var(--color-primary),
            -2px 0 var(--color-accent);
    }
    75% {
        text-shadow:
            -2px 0 var(--color-primary),
            2px 0 var(--color-accent);
    }
    100% {
        text-shadow:
            2px 0 var(--color-accent),
            -2px 0 var(--color-primary);
    }
}

/* Screen shake */
@keyframes screen-shake {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-2px, -2px); }
    20% { transform: translate(2px, 2px); }
    30% { transform: translate(-2px, 2px); }
    40% { transform: translate(2px, -2px); }
    50% { transform: translate(-2px, -2px); }
    60% { transform: translate(2px, 2px); }
    70% { transform: translate(-2px, 2px); }
    80% { transform: translate(2px, -2px); }
    90% { transform: translate(-2px, -2px); }
}

body.shaking .terminal-wrapper {
    animation: screen-shake 0.5s ease-in-out;
}

/* Flash effect */
@keyframes flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.flash {
    animation: flash 0.3s ease-in-out;
}

/* Fade in */
@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-in {
    animation: fade-in 0.5s ease-out;
}

/* Slide in from bottom */
@keyframes slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-up {
    animation: slide-up 0.4s ease-out;
}

/* RGB split effect */
.rgb-split {
    animation: rgb-split 0.2s ease-out;
}

@keyframes rgb-split {
    0% {
        text-shadow: none;
    }
    33% {
        text-shadow:
            -4px 0 var(--color-error),
            4px 0 var(--color-primary);
    }
    66% {
        text-shadow:
            4px 0 var(--color-error),
            -4px 0 var(--color-primary);
    }
    100% {
        text-shadow: none;
    }
}

/* CRT flicker */
.crt-flicker {
    animation: crt-flicker 0.1s steps(2) infinite;
}

@keyframes crt-flicker {
    0% { opacity: 1; }
    50% { opacity: 0.97; }
    100% { opacity: 1; }
}

/* Data corruption effect */
.corrupted {
    animation: data-corrupt 0.5s steps(8) forwards;
}

@keyframes data-corrupt {
    0% { opacity: 1; filter: blur(0); }
    25% { opacity: 0.8; filter: blur(1px); }
    50% { opacity: 0.6; filter: blur(2px); }
    75% { opacity: 0.4; filter: blur(3px); }
    100% { opacity: 0.2; filter: blur(4px); }
}

/* Matrix rain effect */
.matrix-rain {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: var(--z-background);
    opacity: 0;
    transition: opacity 0.5s ease;
}

body.matrix-active .matrix-rain {
    opacity: 0.3;
}

/* Loading spinner */
.loading {
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 2px solid var(--color-text-dim);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Typing dots animation - removed (content animations unreliable) */
/* Use JS-based typewriter effect instead (see effects.js) */

/* Pulse effect */
.pulse {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(0.98);
    }
}

/* Reveal animation */
.reveal {
    opacity: 0;
    animation: reveal 0.6s ease-out forwards;
}

@keyframes reveal {
    from {
        opacity: 0;
        clip-path: inset(0 100% 0 0);
    }
    to {
        opacity: 1;
        clip-path: inset(0 0 0 0);
    }
}

/* Access granted effect */
.access-granted {
    animation: access-granted 1s ease-out;
}

@keyframes access-granted {
    0% {
        color: var(--color-text);
        text-shadow: none;
        transform: scale(1);
    }
    50% {
        color: var(--color-success);
        text-shadow: 0 0 20px var(--color-success);
        transform: scale(1.05);
    }
    100% {
        color: var(--color-success);
        text-shadow: 0 0 10px var(--color-success);
        transform: scale(1);
    }
}

/* Access denied effect */
.access-denied {
    animation: access-denied 0.5s ease-out;
}

@keyframes access-denied {
    0%, 100% {
        color: var(--color-error);
        text-shadow: none;
        transform: translateX(0);
    }
    25% {
        text-shadow: 0 0 10px var(--color-error);
        transform: translateX(-5px);
    }
    75% {
        text-shadow: 0 0 10px var(--color-error);
        transform: translateX(5px);
    }
}

/* Level up effect */
.level-up {
    animation: level-up 1.5s ease-out;
}

@keyframes level-up {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.8);
        filter: blur(10px);
    }
    50% {
        opacity: 1;
        transform: translateY(-5px) scale(1.1);
        filter: blur(0);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

/* Redacted text effect */
.redacted {
    background: var(--color-text);
    color: transparent;
    user-select: none;
    cursor: not-allowed;
}

.redacted.revealed {
    animation: unredact 1s ease-out forwards;
}

@keyframes unredact {
    from {
        background: var(--color-text);
        color: transparent;
    }
    to {
        background: transparent;
        color: var(--color-text);
    }
}

/* Decrypt effect - removed (content animations unreliable) */
/* Use JS decrypt() function from effects.js instead */

/* View Transitions */
::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 0.3s;
}

::view-transition-old(root) {
    animation-name: fade-out;
}

::view-transition-new(root) {
    animation-name: fade-in;
}

@keyframes fade-out {
    to { opacity: 0; }
}
