/* Animation Styles for Deep Learning Visualizations */

/* Keyframe Animations */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
    }
    50% {
        box-shadow: 0 0 30px rgba(102, 126, 234, 0.8);
    }
}

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

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

@keyframes slideInFromTop {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

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

@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

@keyframes neuronPulse {
    0% {
        r: 15;
        opacity: 0.8;
    }
    50% {
        r: 20;
        opacity: 1;
    }
    100% {
        r: 15;
        opacity: 0.8;
    }
}

@keyframes edgeFlow {
    0% {
        stroke-dashoffset: 100;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

@keyframes dataFlow {
    0% {
        transform: translateX(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Neural Network Animation Classes */
.neuron {
    transition: all 0.3s ease;
}

.neuron.active {
    animation: neuronPulse 1s infinite;
    fill: var(--accent-color);
}

.neuron.firing {
    animation: glow 0.5s ease;
}

.synapse {
    stroke-dasharray: 5, 5;
    transition: all 0.3s ease;
}

.synapse.transmitting {
    animation: edgeFlow 2s linear infinite;
    stroke: var(--accent-color);
    stroke-width: 3;
}

/* Gradient Descent Animation */
.gradient-ball {
    animation: pulse 2s infinite;
}

.loss-surface {
    animation: gradientShift 10s ease infinite;
    background: linear-gradient(
        -45deg,
        #667eea,
        #764ba2,
        #f093fb,
        #f5576c
    );
    background-size: 400% 400%;
}

.trajectory-line {
    stroke-dasharray: 5, 5;
    animation: edgeFlow 3s linear infinite;
}

/* Convolution Animation */
.conv-window {
    border: 3px solid var(--accent-color);
    animation: pulse 1s infinite;
    transition: all 0.5s ease;
}

.conv-cell {
    transition: all 0.3s ease;
}

.conv-cell.active {
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(240, 147, 251, 0.6);
}

.kernel-weight {
    animation: rotate 4s linear infinite;
}

/* Backpropagation Animation */
.backprop-layer {
    opacity: 0;
    animation: slideInFromRight 0.5s ease forwards;
}

.backprop-layer.reverse {
    animation: slideInFromLeft 0.5s ease forwards;
}

.gradient-flow {
    stroke-dasharray: 10, 5;
    animation: edgeFlow 1s linear infinite reverse;
}

.weight-update {
    animation: pulse 0.5s ease;
}

/* Attention Mechanism Animation */
.attention-head {
    transition: all 0.3s ease;
}

.attention-head.focusing {
    transform: scale(1.2);
    filter: brightness(1.2);
}

.attention-weight {
    opacity: 0;
    animation: fadeIn 0.5s ease forwards;
}

.attention-line {
    stroke-dasharray: 5, 3;
    animation: edgeFlow 2s linear infinite;
}

/* LSTM Gates Animation */
.lstm-gate {
    transition: all 0.3s ease;
}

.lstm-gate.open {
    fill: var(--success-color);
    animation: glow 0.5s ease;
}

.lstm-gate.closed {
    fill: var(--error-color);
    opacity: 0.5;
}

.memory-cell {
    animation: pulse 2s infinite;
}

.memory-flow {
    stroke-dasharray: 10, 5;
    animation: dataFlow 3s linear infinite;
}

/* RNN Unfolding Animation */
.rnn-timestep {
    opacity: 0;
    transform: translateX(-50px);
    animation: slideInFromLeft 0.5s ease forwards;
}

.rnn-timestep:nth-child(2) {
    animation-delay: 0.2s;
}

.rnn-timestep:nth-child(3) {
    animation-delay: 0.4s;
}

.rnn-timestep:nth-child(4) {
    animation-delay: 0.6s;
}

.rnn-connection {
    stroke-dasharray: 5, 5;
    animation: edgeFlow 2s linear infinite;
}

/* GAN Animation */
.generator-node {
    fill: var(--primary-color);
    animation: pulse 3s infinite;
}

.discriminator-node {
    fill: var(--secondary-color);
    animation: pulse 3s infinite;
    animation-delay: 1.5s;
}

.gan-battle {
    animation: shake 0.5s ease infinite;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Transformer Animation */
.transformer-block {
    opacity: 0;
    transform: translateY(20px);
    animation: slideInFromBottom 0.5s ease forwards;
}

.self-attention {
    animation: rotate 10s linear infinite;
}

.position-encoding {
    animation: gradientShift 5s ease infinite;
}

/* Interactive Elements */
.interactive-element {
    cursor: pointer;
    transition: all 0.3s ease;
}

.interactive-element:hover {
    transform: scale(1.05);
    filter: brightness(1.1);
}

.draggable {
    cursor: grab;
}

.draggable:active {
    cursor: grabbing;
}

.droppable {
    border: 2px dashed transparent;
    transition: all 0.3s ease;
}

.droppable.drag-over {
    border-color: var(--accent-color);
    background: rgba(240, 147, 251, 0.1);
}

/* Loading Animations */
.loading-spinner {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: rotate 1s linear infinite;
}

.loading-dots {
    display: flex;
    gap: 5px;
}

.loading-dot {
    width: 10px;
    height: 10px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

.loading-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dot:nth-child(3) {
    animation-delay: 0.4s;
}

/* Progress Animations */
.progress-bar-animated {
    position: relative;
    overflow: hidden;
}

.progress-bar-animated::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    animation: progress-shine 2s infinite;
}

@keyframes progress-shine {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Matrix Rain Effect */
.matrix-rain {
    position: relative;
    overflow: hidden;
}

.matrix-rain-column {
    position: absolute;
    top: -100%;
    color: var(--success-color);
    font-family: monospace;
    animation: matrix-fall linear infinite;
}

@keyframes matrix-fall {
    to {
        top: 100%;
    }
}

/* Particle Effects */
.particle {
    position: absolute;
    pointer-events: none;
    animation: particle-float 4s ease-in-out infinite;
}

@keyframes particle-float {
    0%, 100% {
        transform: translateY(0) translateX(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    50% {
        transform: translateY(-100px) translateX(50px);
    }
}

/* Wave Animation */
.wave {
    animation: wave 2s linear infinite;
}

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

/* Morphing Shapes */
.morph {
    animation: morph 8s ease-in-out infinite;
}

@keyframes morph {
    0%, 100% {
        border-radius: 50%;
        transform: rotate(0deg);
    }
    25% {
        border-radius: 0;
        transform: rotate(90deg);
    }
    50% {
        border-radius: 50% 0;
        transform: rotate(180deg);
    }
    75% {
        border-radius: 0 50%;
        transform: rotate(270deg);
    }
}

/* Tooltip Animations */
.tooltip {
    position: absolute;
    background: var(--dark-bg);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
    animation: tooltip-appear 0.3s ease forwards;
}

@keyframes tooltip-appear {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--dark-bg);
}

/* Tour Overlay */
.tour-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9998;
    animation: fadeIn 0.3s ease;
}

.tour-highlight {
    position: relative;
    z-index: 9999;
    animation: glow 2s infinite;
}

.tour-content {
    position: fixed;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-xl);
    z-index: 10000;
    animation: slideInFromBottom 0.3s ease;
}

/* Responsive Animations */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Performance Optimizations */
.gpu-accelerated {
    transform: translateZ(0);
    will-change: transform;
}

.animation-paused {
    animation-play-state: paused !important;
}

.animation-running {
    animation-play-state: running !important;
}