/* Animations and Effects */

/* Keyframe Animations */
@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes messagePulse {
    0%, 100% { 
        box-shadow: 0 0 0 rgba(255, 165, 0, 0.4);
    }
    50% { 
        box-shadow: 0 0 20px rgba(255, 165, 0, 0.8);
    }
}

@keyframes alertPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

@keyframes alertGlow {
    0%, 100% { box-shadow: 0 0 20px rgba(255, 51, 102, 0.4); }
    50% { box-shadow: 0 0 40px rgba(255, 51, 102, 0.8); }
}

@keyframes stressFlicker {
    0% { opacity: 0.1; }
    100% { opacity: 0.3; }
}

@keyframes eventAppear {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes modalAppear {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes sceneTransition {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes typewriter {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes scanline {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100vw); }
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { 
        transform: translateY(20px);
        opacity: 0;
    }
    to { 
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideDown {
    from { 
        transform: translateY(-20px);
        opacity: 0;
    }
    to { 
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideLeft {
    from { 
        transform: translateX(20px);
        opacity: 0;
    }
    to { 
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideRight {
    from { 
        transform: translateX(-20px);
        opacity: 0;
    }
    to { 
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes rotateIn {
    from {
        transform: rotate(-180deg) scale(0.5);
        opacity: 0;
    }
    to {
        transform: rotate(0) scale(1);
        opacity: 1;
    }
}

@keyframes zoomIn {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-30px);
    }
    60% {
        transform: translateY(-15px);
    }
}

/* Alert Animations */
.alert {
    position: absolute;
    width: clamp(35px, 6vw, 50px);
    height: clamp(35px, 6vw, 50px);
    background: linear-gradient(45deg, var(--accent-red), var(--accent-orange));
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Orbitron', monospace;
    font-weight: 700;
    color: white;
    font-size: clamp(10px, 1.5vw, 12px);
    animation: alertPulse 1.5s infinite, alertGlow 3s infinite;
    transition: transform var(--transition-normal) ease, box-shadow var(--transition-normal) ease;
    box-shadow: 0 0 20px rgba(255, 51, 102, 0.4);
    z-index: var(--z-elevated);
}

.alert:hover {
    transform: scale(1.1);
    box-shadow: 0 0 30px rgba(255, 51, 102, 0.6);
}

.alert.urgent {
    background: linear-gradient(45deg, var(--warning-color), var(--danger-color));
    animation: alertPulse 0.8s infinite, urgentBlink 1s infinite, alertGlow 2s infinite;
}

.alert.multiple {
    animation: alertPulse 1s infinite, bounce 2s infinite, alertGlow 2.5s infinite;
}

/* Scene Transitions */
.scene-enter {
    animation: sceneTransition var(--transition-slow) ease;
}

.scene-exit {
    animation: sceneTransition var(--transition-slow) ease reverse;
}

/* UI State Animations */
.ui-enter {
    animation: slideUp var(--transition-normal) ease;
}

.ui-exit {
    animation: slideDown var(--transition-normal) ease;
}

.ui-slide-left {
    animation: slideLeft var(--transition-normal) ease;
}

.ui-slide-right {
    animation: slideRight var(--transition-normal) ease;
}

.ui-fade-in {
    animation: fadeIn var(--transition-normal) ease;
}

.ui-zoom-in {
    animation: zoomIn var(--transition-normal) ease;
}

.ui-rotate-in {
    animation: rotateIn var(--transition-slow) ease;
}

/* Stress Effects */
.stress-level-1 {
    filter: contrast(1.1) saturate(1.1);
}

.stress-level-2 {
    filter: contrast(1.2) saturate(1.2);
    animation: glitchShake 0.1s infinite;
}

.stress-level-3 {
    filter: contrast(1.3) saturate(1.3) hue-rotate(10deg);
    animation: glitchShake 0.1s infinite;
}

.stress-level-4 {
    filter: contrast(1.4) saturate(1.4) hue-rotate(20deg);
    animation: glitchShake 0.05s infinite;
}

.stress-level-5 {
    filter: contrast(1.5) saturate(1.5) hue-rotate(30deg) blur(1px);
    animation: glitchShake 0.05s infinite;
}

/* Scanline Effect for High Stress */
.scanline-effect::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 2px;
    background: rgba(255, 255, 255, 0.5);
    animation: scanline 2s infinite;
}

/* Typing Effect for Messages */
.typing-effect {
    overflow: hidden;
    white-space: nowrap;
    border-right: 2px solid var(--accent-blue);
    animation: typewriter 2s steps(40) 1s 1 normal both;
}

.typing-effect::after {
    content: '';
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Hover Effects */
.hover-glow:hover {
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.5);
    transform: translateY(-2px);
    transition: all var(--transition-normal) ease;
}

.hover-scale:hover {
    transform: scale(1.05);
    transition: transform var(--transition-fast) ease;
}

.hover-rotate:hover {
    transform: rotate(5deg);
    transition: transform var(--transition-normal) ease;
}

/* Loading Animations */
.loading-dots::after {
    content: '...';
    animation: loadingDots 1.5s infinite;
}

@keyframes loadingDots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
    100% { content: ''; }
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--accent-blue);
    animation: spin 1s ease-in-out infinite;
}

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

/* Performance Optimizations */
.will-animate {
    will-change: transform, opacity;
}

.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000;
}