/* Caeliai ML Loading States & Animations */
/* Sophisticated machine learning visualization animations with broken geometric aesthetic */

/* Neural Network Layer Animations */
.neural-network-container {
    position: relative;
    width: 100%;
    height: 320px;
    background: transparent;
    overflow: visible;
}

.neural-layer {
    position: absolute;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    height: 100%;
    width: 60px;
}

.neural-node {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--caeliai-charcoal);
    position: relative;
    animation: neural-pulse 2s ease-in-out infinite;
    animation-delay: var(--node-delay, 0s);
}

.neural-node.active {
    background: var(--caeliai-sage);
    box-shadow: 0 0 8px var(--caeliai-sage);
    animation: neural-active-pulse 1s ease-in-out infinite;
}

.neural-connection {
    position: absolute;
    height: 1px;
    background: linear-gradient(
        to right,
        var(--caeliai-charcoal),
        transparent 50%,
        var(--caeliai-charcoal)
    );
    opacity: 0.6;
    animation: data-flow 3s linear infinite;
}

.neural-connection.active {
    background: linear-gradient(
        to right,
        var(--caeliai-sage),
        var(--caeliai-charcoal) 50%,
        var(--caeliai-sage)
    );
    animation: active-data-flow 1.5s linear infinite;
}

/* Data Pipeline Flow Animation */
.data-pipeline {
    position: relative;
    width: 100%;
    height: 180px;
    background: transparent;
    overflow: visible;
}

.pipeline-stage {
    position: absolute;
    width: 160px;
    height: 60px;
    background: rgba(186, 217, 181, 0.1);
    border: 1px solid var(--caeliai-sage);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--caeliai-charcoal);
}

.pipeline-stage.processing {
    border-color: var(--caeliai-sage);
    background: rgba(186, 217, 181, 0.3);
    animation: pipeline-processing 2s ease-in-out infinite;
}

.data-packet {
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--caeliai-sage);
    border-radius: 50%;
    animation: packet-flow 4s linear infinite;
    opacity: 0;
}

.data-packet::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 1px;
    background: linear-gradient(
        to right,
        var(--caeliai-sage),
        transparent
    );
    left: -20px;
    top: 50%;
    transform: translateY(-50%);
}

/* Matrix Operations Visualization */
.matrix-operations {
    position: relative;
    width: 100%;
    height: 260px;
    background: transparent;
    display: grid;
    grid-template-columns: 1fr auto 1fr auto 1fr;
    align-items: center;
    padding: 1rem 0;
    gap: 1rem;
}

.matrix-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 2px;
    width: 80px;
    height: 80px;
}

.matrix-cell {
    background: var(--caeliai-charcoal);
    opacity: 0.3;
    transition: all 0.3s ease;
    animation: matrix-compute 3s ease-in-out infinite;
    animation-delay: var(--cell-delay, 0s);
}

.matrix-cell.active {
    opacity: 1;
    background: var(--caeliai-sage);
    transform: scale(1.1);
}

.matrix-operator {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    color: var(--caeliai-charcoal);
    text-align: center;
}

/* Gradient Descent Visualization */
.gradient-descent {
    position: relative;
    width: 100%;
    height: 260px;
    background: transparent;
    overflow: hidden;
}

.loss-surface {
    position: absolute;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(
            ellipse at 30% 70%,
            transparent 20%,
            rgba(186, 217, 181, 0.2) 40%,
            rgba(186, 217, 181, 0.4) 60%,
            rgba(186, 217, 181, 0.6) 80%
        );
}

.gradient-path {
    position: absolute;
    width: 2px;
    height: 2px;
    background: var(--caeliai-sage);
    border-radius: 50%;
    animation: gradient-step 8s ease-in-out infinite;
}

.gradient-vector {
    position: absolute;
    width: 1px;
    height: 20px;
    background: var(--caeliai-charcoal);
    transform-origin: bottom center;
    animation: vector-rotate 4s ease-in-out infinite;
}

/* Loading Progress with Geometric Breaks */
.geometric-progress {
    position: relative;
    width: 100%;
    height: 60px;
    background: transparent;
    overflow: hidden;
}

.progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(
        to right,
        var(--caeliai-sage),
        rgba(186, 217, 181, 0.6)
    );
    width: 0%;
    animation: progress-fill 3s ease-out infinite;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 0;
    height: 0;
    border-left: 15px solid var(--caeliai-sage);
    border-top: 30px solid transparent;
    border-bottom: 30px solid transparent;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--caeliai-black);
    z-index: 2;
}

/* Scatter Plot Animation */
.scatter-animation {
    position: relative;
    width: 100%;
    height: 320px;
    background: transparent;
}

.scatter-point {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    animation: scatter-emerge 2s ease-out infinite;
    animation-delay: var(--point-delay, 0s);
    opacity: 0;
}

.scatter-axis {
    position: absolute;
    background: var(--caeliai-charcoal);
    opacity: 0.3;
}

.scatter-axis.x-axis {
    bottom: 50px;
    left: 50px;
    right: 50px;
    height: 1px;
}

.scatter-axis.y-axis {
    left: 50px;
    top: 50px;
    bottom: 50px;
    width: 1px;
}

/* Feature Extraction Animation */
.feature-extraction {
    position: relative;
    width: 100%;
    height: 260px;
    background: transparent;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 1.25rem 0;
    gap: 1.5rem;
}

.feature-input {
    width: 100px;
    height: 100px;
    background: linear-gradient(
        45deg,
        rgba(186, 217, 181, 0.2),
        rgba(186, 217, 181, 0.4)
    );
    border: 1px solid var(--caeliai-sage);
    position: relative;
    animation: feature-scan 3s linear infinite;
}

.feature-arrow {
    font-size: 2rem;
    color: var(--caeliai-charcoal);
    animation: arrow-pulse 2s ease-in-out infinite;
}

.feature-output {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.feature-vector {
    width: 60px;
    height: 8px;
    background: var(--caeliai-charcoal);
    opacity: 0.3;
    animation: vector-activate 4s ease-in-out infinite;
    animation-delay: var(--vector-delay, 0s);
}

/* Keyframes */
@keyframes neural-pulse {
    0%, 100% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.2); opacity: 1; }
}

@keyframes neural-active-pulse {
    0%, 100% { box-shadow: 0 0 8px var(--caeliai-sage); }
    50% { box-shadow: 0 0 16px var(--caeliai-sage); }
}

@keyframes data-flow {
    0% { opacity: 0; transform: translateX(-20px); }
    50% { opacity: 1; }
    100% { opacity: 0; transform: translateX(20px); }
}

@keyframes active-data-flow {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

@keyframes pipeline-processing {
    0%, 100% { 
        border-color: var(--caeliai-sage);
        box-shadow: none;
    }
    50% { 
        border-color: var(--caeliai-sage);
        box-shadow: 0 0 8px rgba(186, 217, 181, 0.6);
    }
}

@keyframes packet-flow {
    0% { 
        left: 0%; 
        opacity: 0; 
        transform: translateY(0);
    }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { 
        left: 100%; 
        opacity: 0; 
        transform: translateY(-10px);
    }
}

@keyframes matrix-compute {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

@keyframes gradient-step {
    0% { left: 80%; top: 20%; }
    25% { left: 60%; top: 40%; }
    50% { left: 45%; top: 60%; }
    75% { left: 35%; top: 70%; }
    100% { left: 30%; top: 75%; }
}

@keyframes vector-rotate {
    0%, 100% { transform: rotate(45deg); }
    50% { transform: rotate(-30deg); }
}

@keyframes progress-fill {
    0% { width: 0%; }
    70% { width: 85%; }
    100% { width: 100%; }
}

@keyframes scatter-emerge {
    0% { opacity: 0; transform: scale(0); }
    50% { opacity: 1; transform: scale(1.2); }
    100% { opacity: 0.8; transform: scale(1); }
}

@keyframes feature-scan {
    0%, 100% { 
        box-shadow: inset 0 0 0 0 rgba(186, 217, 181, 0.3);
    }
    50% { 
        box-shadow: inset 100px 100px 0 0 rgba(186, 217, 181, 0.3);
    }
}

@keyframes arrow-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes vector-activate {
    0%, 100% { opacity: 0.3; background: var(--caeliai-charcoal); }
    50% { opacity: 1; background: var(--caeliai-sage); }
}

/* Responsive Animations */
@media (max-width: 768px) {
    .neural-network-container,
    .data-pipeline,
    .matrix-operations,
    .gradient-descent,
    .scatter-animation,
    .feature-extraction {
        height: 200px;
    }
    
    .neural-node {
        width: 8px;
        height: 8px;
    }
    
    .matrix-grid {
        width: 60px;
        height: 60px;
    }
    
    .feature-input {
        width: 60px;
        height: 60px;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}