/* Animation definitions for style switching and effects */

/* Transition defaults */
* {
    transition: background-color 0.8s, border-color 0.8s, color 0.8s, box-shadow 0.8s, transform 0.3s;
}

/* Bulb flicker animation */
@keyframes bulb-flicker {
    0%, 100% { opacity: 1; }
    20% { opacity: 0.7; }
    40% { opacity: 1; }
    60% { opacity: 0.4; }
    80% { opacity: 0.9; }
}

.bulb-flicker {
    animation: bulb-flicker 0.3s ease-in-out 3;
}

/* Background color transition */
.bg-transition {
    transition: background-color 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Text color transition */
.text-transition {
    transition: color 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Character fragmentation animations */
@keyframes char-break-apart {
    0% {
        opacity: 1;
        transform: translate(0, 0) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translate(var(--tx, 0), var(--ty, 0)) rotate(var(--r, 0deg));
    }
}

@keyframes char-fall {
    0% {
        opacity: 1;
        transform: translate(0, 0) rotate(0deg);
    }
    100% {
        opacity: 1;
        transform: translate(var(--tx-end, 0), var(--ty-end, 100vh)) rotate(var(--r-end, 360deg));
    }
}

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

.char-fragment {
    position: fixed;
    pointer-events: none;
    z-index: 1000;
    font-family: 'Rubik Glitch', monospace;
    font-size: 24px;
    color: #FF6B35;
    text-shadow: 0 0 8px rgba(255, 107, 53, 0.7);
    opacity: 0;
    will-change: transform, opacity;
}

/* Stacked characters at bottom */
.char-pile {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 120px;
    pointer-events: none;
    z-index: 900;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-end;
    padding: 10px;
}

.char-pile-item {
    font-family: 'Rubik Glitch', monospace;
    font-size: 20px;
    color: #8B2635;
    margin: 2px;
    opacity: 0.7;
    transform-origin: center;
    animation: char-bounce 3s infinite ease-in-out;
    animation-delay: calc(var(--i) * 0.1s);
}

/* AI sidebar slide animations */
@keyframes slide-in-right {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slide-out-right {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.ai-sidebar.open {
    animation: slide-in-right 0.3s ease-out;
}

.ai-sidebar.closing {
    animation: slide-out-right 0.3s ease-out;
}

/* Message bubble animations */
@keyframes message-pop {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.message {
    animation: message-pop 0.2s ease-out;
}

/* Button click effect */
@keyframes button-click {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(0.95);
    }
    100% {
        transform: scale(1);
    }
}

.button-click {
    animation: button-click 0.2s ease;
}

/* Loading spinner */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(64, 158, 255, 0.3);
    border-radius: 50%;
    border-top-color: #409EFF;
    animation: spin 1s ease-in-out infinite;
}

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

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

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

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

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

.fade-out {
    animation: fade-out 0.3s ease-out;
}

/* Particle floating */
@keyframes float-particle {
    0% {
        transform: translateY(0) translateX(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-100vh) translateX(var(--float-x, 20px));
        opacity: 0;
    }
}

.ash-particle {
    animation: float-particle 20s linear infinite;
    animation-delay: calc(var(--i) * 0.1s);
}

/* Core info overlay glow */
@keyframes core-glow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(255, 107, 53, 0.5);
    }
    50% {
        box-shadow: 0 0 40px rgba(255, 42, 42, 0.8);
    }
}

.core-info-overlay {
    animation: core-glow 3s ease-in-out infinite;
}

/* Tab content switch */
.tab-pane {
    animation: fade-in 0.4s ease-out;
}

/* Hover lift effect */
.hover-lift {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Pulse for notifications */
@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.pulse {
    animation: pulse 2s infinite;
}

/* Text typing effect */
@keyframes typing {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink-caret {
    from, to {
        border-color: transparent;
    }
    50% {
        border-color: #409EFF;
    }
}

.typing-effect {
    overflow: hidden;
    border-right: 2px solid;
    white-space: nowrap;
    animation: typing 3s steps(40, end), blink-caret 0.75s step-end infinite;
}

/* Rotating gear for loading */
@keyframes rotate-gear {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.gear-spin {
    animation: rotate-gear 2s linear infinite;
}

/* Bounce for attention */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

.bounce {
    animation: bounce 2s infinite;
}

/* Ripple effect for buttons */
@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    transform: scale(0);
    animation: ripple 0.6s linear;
}