/* AI Neural Network Brain Loading Animation - Enhanced Knowledge Discovery Portal */

.brain-loading-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #0f1419 0%, #1a2332 50%, #0f1419 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 1;
    transition: opacity 0.8s ease-out;
    padding: 20px;
    box-sizing: border-box;
}

.brain-loading-container.fade-out {
    opacity: 0;
    pointer-events: none;
}

/* Main Content Grid */
.knowledge-portal {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: auto 1fr auto;
    gap: 30px;
    width: 100%;
    max-width: 1200px;
    height: 80vh;
    max-height: 600px;
}

/* Query Header */
.query-header {
    grid-column: 1 / -1;
    text-align: center;
    margin-bottom: 20px;
}

.query-text {
    color: #ffffff;
    font-size: 28px;
    font-weight: 300;
    margin-bottom: 10px;
    opacity: 0;
    animation: typewriterEffect 2s ease-out 0.5s forwards;
}

.query-keywords {
    color: #ffd700;
    font-weight: 600;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

/* Wikipedia Image Section */
.wikipedia-image-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 20px;
    border: 2px solid transparent;
    background-clip: padding-box;
    position: relative;
    overflow: hidden;
}

.wikipedia-image-section::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #4a90e2, #7b68ee, #9370db, #4a90e2);
    background-size: 400% 400%;
    border-radius: 20px;
    z-index: -1;
    animation: gradientShift 3s ease-in-out infinite;
}

.image-placeholder {
    width: 180px;
    height: 180px;
    border-radius: 15px;
    background: linear-gradient(45deg, #2a2a2a, #3a3a3a);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    position: relative;
    overflow: hidden;
    animation: imagePulse 2s ease-in-out infinite;
}

.image-placeholder.loading {
    background: linear-gradient(45deg, #4a90e2, #7b68ee);
    animation: imageShimmer 1.5s ease-in-out infinite;
}

.wikipedia-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 15px;
    opacity: 0;
    transition: opacity 0.8s ease-in-out;
}

.wikipedia-image.loaded {
    opacity: 1;
}

.image-label {
    color: #7b68ee;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
}

/* Brain Animation Section */
.brain-animation {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 20px;
    padding: 20px;
}

.brain-outline {
    position: relative;
    width: 200px;
    height: 140px;
    border: 3px solid transparent;
    border-radius: 100px 100px 80px 80px;
    background: linear-gradient(45deg, #4a90e2, #7b68ee, #9370db, #4a90e2);
    background-size: 400% 400%;
    animation: brainPulse 3s ease-in-out infinite, gradientShift 4s ease-in-out infinite;
    margin-bottom: 15px;
}

.brain-outline::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    background: linear-gradient(45deg, #4a90e2, #7b68ee, #9370db, #4a90e2);
    background-size: 400% 400%;
    border-radius: 100px 100px 80px 80px;
    z-index: -1;
    animation: gradientShift 4s ease-in-out infinite;
}

.brain-outline::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #0f1419;
    border-radius: 97px 97px 77px 77px;
    z-index: -1;
}

.brain-label {
    color: #9370db;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
}

/* Processing Steps Section */
.processing-steps {
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 25px;
    border-left: 4px solid #4a90e2;
}

.steps-header {
    color: #ffffff;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
}

.steps-header::before {
    content: '⚡';
    margin-right: 10px;
    font-size: 20px;
}

.processing-step {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    padding: 8px 0;
    opacity: 0.5;
    transition: all 0.5s ease;
}

.processing-step.active {
    opacity: 1;
    transform: translateX(5px);
}

.processing-step.completed {
    opacity: 0.8;
}

.step-icon {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.step-text {
    color: #ffffff;
    font-size: 14px;
    font-weight: 400;
    flex: 1;
}

.step-progress {
    width: 60px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    margin-left: 10px;
    overflow: hidden;
}

.step-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #4a90e2, #7b68ee);
    border-radius: 2px;
    width: 0%;
    transition: width 0.5s ease;
}

/* Particle Connections */
.particle-connection {
    position: absolute;
    width: 4px;
    height: 4px;
    background: #ffd700;
    border-radius: 50%;
    opacity: 0;
    animation: particleFlow 3s ease-in-out infinite;
}

.particle-1 {
    top: 50%;
    left: 25%;
    animation-delay: 0s;
}

.particle-2 {
    top: 40%;
    left: 75%;
    animation-delay: 1s;
}

.particle-3 {
    top: 60%;
    left: 50%;
    animation-delay: 2s;
}

/* Enhanced Neural Network Elements */
.neural-node {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #4a90e2;
    border-radius: 50%;
    opacity: 0;
    animation: nodeFlicker 2s ease-in-out infinite;
}

.neural-node.active {
    background: #ffd700;
    box-shadow: 0 0 15px #ffd700, 0 0 30px #ffd700;
    animation: nodeActive 1.5s ease-in-out infinite;
}

.neural-node:nth-child(1) { top: 30px; left: 50px; animation-delay: 0s; }
.neural-node:nth-child(2) { top: 45px; left: 120px; animation-delay: 0.3s; }
.neural-node:nth-child(3) { top: 70px; left: 80px; animation-delay: 0.6s; }
.neural-node:nth-child(4) { top: 90px; left: 140px; animation-delay: 0.9s; }
.neural-node:nth-child(5) { top: 110px; left: 60px; animation-delay: 1.2s; }
.neural-node:nth-child(6) { top: 130px; left: 100px; animation-delay: 1.5s; }

/* Neural Connections */
.neural-connection {
    position: absolute;
    height: 2px;
    background: linear-gradient(90deg, transparent, #4a90e2, transparent);
    opacity: 0;
    animation: connectionPulse 3s ease-in-out infinite;
    transform-origin: left center;
}

.connection-1 {
    top: 34px;
    left: 58px;
    width: 60px;
    transform: rotate(15deg);
    animation-delay: 0.2s;
}

.connection-2 {
    top: 49px;
    left: 128px;
    width: 45px;
    transform: rotate(-45deg);
    animation-delay: 0.5s;
}

.connection-3 {
    top: 74px;
    left: 88px;
    width: 50px;
    transform: rotate(30deg);
    animation-delay: 0.8s;
}

.connection-4 {
    top: 94px;
    left: 148px;
    width: 40px;
    transform: rotate(-60deg);
    animation-delay: 1.1s;
}

.connection-5 {
    top: 114px;
    left: 68px;
    width: 35px;
    transform: rotate(45deg);
    animation-delay: 1.4s;
}

/* Wikipedia Logos */
.wiki-logo {
    position: absolute;
    width: 16px;
    height: 16px;
    background: #ffd700;
    border-radius: 2px;
    opacity: 0;
    font-size: 10px;
    font-weight: bold;
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: wikiAppear 2s ease-in-out infinite;
}

.wiki-logo::before {
    content: 'W';
}

.wiki-logo:nth-child(7) { top: 26px; left: 46px; animation-delay: 0.4s; }
.wiki-logo:nth-child(8) { top: 41px; left: 116px; animation-delay: 0.7s; }
.wiki-logo:nth-child(9) { top: 66px; left: 76px; animation-delay: 1.0s; }
.wiki-logo:nth-child(10) { top: 86px; left: 136px; animation-delay: 1.3s; }

/* Animations */
@keyframes typewriterEffect {
    from { 
        opacity: 0; 
        transform: translateY(20px);
        width: 0;
    }
    to { 
        opacity: 1; 
        transform: translateY(0);
        width: 100%;
    }
}

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

@keyframes imageShimmer {
    0% { background-position: -200px 0; }
    100% { background-position: 200px 0; }
}

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

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

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

@keyframes nodeFlicker {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}

@keyframes nodeActive {
    0%, 100% { opacity: 0.8; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.5); }
}

@keyframes connectionPulse {
    0%, 100% { opacity: 0; }
    50% { opacity: 0.8; }
}

@keyframes wikiAppear {
    0%, 70% { opacity: 0; transform: scale(0); }
    80% { opacity: 1; transform: scale(1.2); }
    100% { opacity: 1; transform: scale(1); }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .knowledge-portal {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto auto;
        gap: 20px;
        height: auto;
        max-height: none;
    }
    
    .query-text {
        font-size: 24px;
    }
}

@media (max-width: 768px) {
    .brain-loading-container {
        padding: 15px;
    }
    
    .knowledge-portal {
        gap: 15px;
    }
    
    .image-placeholder {
        width: 140px;
        height: 140px;
    }
    
    .brain-outline {
        width: 160px;
        height: 110px;
    }
    
    .query-text {
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .image-placeholder {
        width: 120px;
        height: 120px;
    }
    
    .brain-outline {
        width: 130px;
        height: 90px;
    }
    
    .query-text {
        font-size: 18px;
    }
    
    .processing-steps {
        padding: 15px;
    }
}
