/**
 * Ultra-Premium AI Loading Animations
 * Power of Knowledge - AI-Powered Academic Journal
 * Custom loading states as specified in the metaprompt:
 * - DNA helix animation
 * - Orbiting atoms
 * - Neural network connection
 * - Typewriter "Analyzing..." text
 */

/* ============================================
   Base Loading Container
   ============================================ */

.up-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 40px;
}

.up-loader-text {
    font-family: var(--font-display, 'Space Grotesk', sans-serif);
    font-size: 0.875rem;
    color: var(--silver, #9ca3af);
    letter-spacing: 0.05em;
}

/* ============================================
   1. DNA Helix Animation
   ============================================ */

.up-loader-dna {
    position: relative;
    width: 60px;
    height: 80px;
}

.up-loader-dna .strand {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: dna-helix 2s ease-in-out infinite;
}

.up-loader-dna .strand:nth-child(odd) {
    background: var(--quantum-blue, #00d4ff);
    left: 0;
}

.up-loader-dna .strand:nth-child(even) {
    background: var(--neural-purple, #8b5cf6);
    right: 0;
}

.up-loader-dna .strand:nth-child(1) {
    top: 0;
    animation-delay: 0s;
}

.up-loader-dna .strand:nth-child(2) {
    top: 0;
    animation-delay: 0s;
}

.up-loader-dna .strand:nth-child(3) {
    top: 20px;
    animation-delay: 0.2s;
}

.up-loader-dna .strand:nth-child(4) {
    top: 20px;
    animation-delay: 0.2s;
}

.up-loader-dna .strand:nth-child(5) {
    top: 40px;
    animation-delay: 0.4s;
}

.up-loader-dna .strand:nth-child(6) {
    top: 40px;
    animation-delay: 0.4s;
}

.up-loader-dna .strand:nth-child(7) {
    top: 60px;
    animation-delay: 0.6s;
}

.up-loader-dna .strand:nth-child(8) {
    top: 60px;
    animation-delay: 0.6s;
}

@keyframes dna-helix {

    0%,
    100% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }

    25% {
        transform: translateX(20px) scale(0.8);
        opacity: 0.7;
    }

    50% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }

    75% {
        transform: translateX(-20px) scale(0.8);
        opacity: 0.7;
    }
}

/* Connecting lines */
.up-loader-dna::before,
.up-loader-dna::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 80px;
    background: linear-gradient(180deg,
            transparent 0%,
            rgba(0, 212, 255, 0.3) 25%,
            rgba(139, 92, 246, 0.3) 50%,
            rgba(0, 212, 255, 0.3) 75%,
            transparent 100%);
    animation: dna-pulse 1s ease-in-out infinite;
}

@keyframes dna-pulse {

    0%,
    100% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }
}

/* ============================================
   2. Orbiting Atoms Animation
   ============================================ */

.up-loader-atoms {
    position: relative;
    width: 80px;
    height: 80px;
}

.up-loader-atoms .nucleus {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    background: linear-gradient(135deg, var(--quantum-blue, #00d4ff), var(--neural-purple, #8b5cf6));
    border-radius: 50%;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.5);
}

.up-loader-atoms .orbit {
    position: absolute;
    top: 50%;
    left: 50%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transform-origin: center center;
}

.up-loader-atoms .orbit:nth-child(2) {
    width: 50px;
    height: 50px;
    margin-left: -25px;
    margin-top: -25px;
    animation: orbit-rotate 3s linear infinite;
}

.up-loader-atoms .orbit:nth-child(3) {
    width: 70px;
    height: 70px;
    margin-left: -35px;
    margin-top: -35px;
    transform: rotate(60deg);
    animation: orbit-rotate 4s linear infinite reverse;
}

.up-loader-atoms .orbit:nth-child(4) {
    width: 60px;
    height: 60px;
    margin-left: -30px;
    margin-top: -30px;
    transform: rotate(-30deg);
    animation: orbit-rotate 3.5s linear infinite;
}

.up-loader-atoms .electron {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    top: -3px;
    left: 50%;
    transform: translateX(-50%);
}

.up-loader-atoms .orbit:nth-child(2) .electron {
    background: var(--quantum-blue, #00d4ff);
    box-shadow: 0 0 10px var(--quantum-blue, #00d4ff);
}

.up-loader-atoms .orbit:nth-child(3) .electron {
    background: var(--neural-purple, #8b5cf6);
    box-shadow: 0 0 10px var(--neural-purple, #8b5cf6);
}

.up-loader-atoms .orbit:nth-child(4) .electron {
    background: var(--synapse-pink, #ec4899);
    box-shadow: 0 0 10px var(--synapse-pink, #ec4899);
}

@keyframes orbit-rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   3. Neural Network Animation
   ============================================ */

.up-loader-neural {
    position: relative;
    width: 80px;
    height: 80px;
}

.up-loader-neural .node {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--quantum-blue, #00d4ff);
    border-radius: 50%;
    animation: node-pulse 1.5s ease-in-out infinite;
}

/* Layer 1 - Input nodes */
.up-loader-neural .node:nth-child(1) {
    left: 0;
    top: 10px;
    animation-delay: 0s;
}

.up-loader-neural .node:nth-child(2) {
    left: 0;
    top: 35px;
    animation-delay: 0.1s;
}

.up-loader-neural .node:nth-child(3) {
    left: 0;
    top: 60px;
    animation-delay: 0.2s;
}

/* Layer 2 - Hidden nodes */
.up-loader-neural .node:nth-child(4) {
    left: 35px;
    top: 20px;
    animation-delay: 0.3s;
    background: var(--neural-purple, #8b5cf6);
}

.up-loader-neural .node:nth-child(5) {
    left: 35px;
    top: 50px;
    animation-delay: 0.4s;
    background: var(--neural-purple, #8b5cf6);
}

/* Layer 3 - Output node */
.up-loader-neural .node:nth-child(6) {
    left: 70px;
    top: 35px;
    animation-delay: 0.5s;
    background: var(--plasma-green, #10b981);
}

@keyframes node-pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.6;
        box-shadow: 0 0 5px currentColor;
    }

    50% {
        transform: scale(1.3);
        opacity: 1;
        box-shadow: 0 0 15px currentColor;
    }
}

/* Connection lines */
.up-loader-neural .connection {
    position: absolute;
    height: 1px;
    background: linear-gradient(90deg, var(--quantum-blue, #00d4ff), var(--neural-purple, #8b5cf6));
    transform-origin: left center;
    animation: connection-flow 1.5s ease-in-out infinite;
}

@keyframes connection-flow {
    0% {
        opacity: 0.2;
    }

    50% {
        opacity: 0.8;
    }

    100% {
        opacity: 0.2;
    }
}

/* ============================================
   4. Typewriter "Analyzing..." Text
   ============================================ */

.up-loader-typewriter {
    display: flex;
    align-items: center;
    gap: 4px;
}

.up-loader-typewriter .text {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.875rem;
    color: var(--platinum, #e5e7eb);
    overflow: hidden;
    white-space: nowrap;
    animation: typewriter 2s steps(12) infinite;
}

.up-loader-typewriter .cursor {
    width: 2px;
    height: 1.2em;
    background: var(--quantum-blue, #00d4ff);
    animation: blink 0.7s step-end infinite;
}

@keyframes typewriter {

    0%,
    100% {
        width: 0;
    }

    50%,
    90% {
        width: 8ch;
    }
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* ============================================
   5. Combined AI Loader (Premium)
   ============================================ */

.up-loader-ai {
    position: relative;
    width: 100px;
    height: 100px;
}

.up-loader-ai .ring {
    position: absolute;
    top: 50%;
    left: 50%;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: var(--quantum-blue, #00d4ff);
    animation: spin 1s linear infinite;
}

.up-loader-ai .ring:nth-child(1) {
    width: 80px;
    height: 80px;
    margin: -40px 0 0 -40px;
}

.up-loader-ai .ring:nth-child(2) {
    width: 60px;
    height: 60px;
    margin: -30px 0 0 -30px;
    border-top-color: var(--neural-purple, #8b5cf6);
    animation-direction: reverse;
    animation-duration: 0.8s;
}

.up-loader-ai .ring:nth-child(3) {
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border-top-color: var(--synapse-pink, #ec4899);
    animation-duration: 0.6s;
}

.up-loader-ai .core {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    background: linear-gradient(135deg, var(--quantum-blue, #00d4ff), var(--neural-purple, #8b5cf6));
    border-radius: 50%;
    animation: core-pulse 1.5s ease-in-out infinite;
}

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

@keyframes core-pulse {

    0%,
    100% {
        transform: translate(-50%, -50%) scale(1);
        box-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
    }

    50% {
        transform: translate(-50%, -50%) scale(1.2);
        box-shadow: 0 0 30px rgba(0, 212, 255, 0.8);
    }
}

/* ============================================
   Loader Size Variants
   ============================================ */

.up-loader-sm {
    transform: scale(0.7);
}

.up-loader-lg {
    transform: scale(1.3);
}

/* ============================================
   Loading Overlay
   ============================================ */

.up-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 15, 0.9);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100001 !important;
    /* Must be higher than sticky header (10000) */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.up-loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   Inline Loading States
   ============================================ */

.up-loading-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.up-loading-inline .dot {
    width: 6px;
    height: 6px;
    background: var(--quantum-blue, #00d4ff);
    border-radius: 50%;
    animation: dot-bounce 1.4s ease-in-out infinite;
}

.up-loading-inline .dot:nth-child(1) {
    animation-delay: 0s;
}

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

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

@keyframes dot-bounce {

    0%,
    80%,
    100% {
        transform: scale(0.8);
        opacity: 0.5;
    }

    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}