/* Typewriter Animation */
@keyframes typewriter {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink {
    from, to {
        border-color: transparent;
    }
    50% {
        border-color: #00ff00;
    }
}

.typewriter {
    overflow: hidden;
    border-right: 3px solid #00ff00;
    white-space: nowrap;
    margin: 0 auto;
    letter-spacing: 0.05em;
    animation: 
        typewriter 2s steps(40, end),
        blink 0.75s step-end infinite;
}

.typewriter-slow {
    animation: 
        typewriter 4s steps(40, end),
        blink 0.75s step-end infinite;
}

/* Glitch Effect */
@keyframes glitch {
    0%, 100% {
        transform: translate(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);
    }
}

.glitch {
    animation: glitch 0.5s infinite;
}

/* Fade In Effects */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.fade-in-slow {
    animation: fadeIn 1s ease-out;
}

/* Pulse Animation */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 255, 0, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(0, 255, 0, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 255, 0, 0);
    }
}

.pulse {
    animation: pulse 2s infinite;
}

/* Alert Pulse (Red) */
@keyframes alertPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 0, 0, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(255, 0, 0, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 0, 0, 0);
    }
}

.alert-pulse {
    animation: alertPulse 1s infinite;
}

/* Flicker Animation */
@keyframes flicker {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

.flicker {
    animation: flicker 0.1s infinite alternate;
}

/* Slide In Animations */
@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.slide-in-left {
    animation: slideInLeft 0.5s ease-out;
}

.slide-in-right {
    animation: slideInRight 0.5s ease-out;
}

/* Loading Bar Animation */
@keyframes loadingBar {
    0% {
        width: 0%;
    }
    100% {
        width: 100%;
    }
}

.loading-fill {
    animation: loadingBar 3s ease-out forwards;
}

/* Status Bar Animation */
@keyframes statusDrain {
    from {
        width: var(--start-width);
    }
    to {
        width: var(--end-width);
    }
}

.status-fill.draining {
    animation: statusDrain 1s ease-out forwards;
}

/* Room Highlight Animation */
@keyframes roomHighlight {
    0%, 100% {
        background: rgba(255, 0, 0, 0.3);
        box-shadow: 0 0 5px #ff0000;
    }
    50% {
        background: rgba(255, 0, 0, 0.6);
        box-shadow: 0 0 15px #ff0000;
    }
}

.room.highlight {
    animation: roomHighlight 1s infinite;
}

/* Text Reveal Animation */
@keyframes textReveal {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.text-reveal {
    opacity: 0;
    animation: textReveal 0.5s ease-out forwards;
}

/* Stagger text reveals */
.text-reveal:nth-child(1) { animation-delay: 0.1s; }
.text-reveal:nth-child(2) { animation-delay: 0.2s; }
.text-reveal:nth-child(3) { animation-delay: 0.3s; }
.text-reveal:nth-child(4) { animation-delay: 0.4s; }
.text-reveal:nth-child(5) { animation-delay: 0.5s; }

/* Matrix Rain Effect (Optional) */
@keyframes matrixRain {
    0% {
        transform: translateY(-100vh);
    }
    100% {
        transform: translateY(100vh);
    }
}

.matrix-rain {
    position: fixed;
    top: -100vh;
    left: 0;
    width: 100%;
    height: 100vh;
    pointer-events: none;
    opacity: 0.1;
    z-index: 0;
    animation: matrixRain 10s linear infinite;
}

/* Button Press Animation */
@keyframes buttonPress {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(0.95);
    }
    100% {
        transform: scale(1);
    }
}

.button-press {
    animation: buttonPress 0.1s ease-out;
}

/* Critical Alert Animation */
@keyframes criticalAlert {
    0%, 100% {
        background: rgba(255, 0, 0, 0.1);
        color: #ff0000;
    }
    50% {
        background: rgba(255, 0, 0, 0.3);
        color: #ffffff;
    }
}

.critical-alert {
    animation: criticalAlert 0.5s infinite;
}

/* Success Animation */
@keyframes successPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 255, 0, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(0, 255, 0, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 255, 0, 0);
    }
}

.success-pulse {
    animation: successPulse 1s ease-out;
}

/* Shake Animation for Errors */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

.shake {
    animation: shake 0.5s ease-out;
}

/* Zoom In Animation */
@keyframes zoomIn {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

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

/* Utility Classes for Animation Control */
.animate-delay-1 { animation-delay: 0.1s; }
.animate-delay-2 { animation-delay: 0.2s; }
.animate-delay-3 { animation-delay: 0.3s; }
.animate-delay-4 { animation-delay: 0.4s; }
.animate-delay-5 { animation-delay: 0.5s; }

.animate-duration-fast { animation-duration: 0.3s; }
.animate-duration-normal { animation-duration: 0.5s; }
.animate-duration-slow { animation-duration: 1s; }

.animate-once { animation-iteration-count: 1; }
.animate-infinite { animation-iteration-count: infinite; }

/* Disable animations for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}