/* ============================================================================
   LOADING SCREEN - Animated Professor Overlay
   ============================================================================ */

.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.8s ease-out;
}

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

/* Professor Container */
.professor-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: professor-fade-in 0.8s ease-out forwards;
}

/* Professor Sprite - 8-Bit pixel art (using box-shadow) */
.professor-sprite {
    /* Scale up the 4px sprite to be visible - much larger scale */
    transform: scale(15);
    transform-origin: center center;
    margin-bottom: 3rem;
    opacity: 0;
    min-width: 200px;
    min-height: 200px;
    display: flex;
    justify-content: center;
    align-items: center;
    /* Waving animation is handled by professor-sprite.css */
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
    cursor: default;
    user-select: none;
    /* Add fade-in appearance animation */
    animation: professor-appear 1s ease-out 0.5s forwards;
}

/* Speech Bubble */
.speech-bubble {
    position: relative;
    background: #ffffff;
    color: #2d3748;
    padding: 1.5rem 2rem;
    border-radius: 20px;
    font-size: 1.5rem;
    font-weight: bold;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(20px);
    animation: speech-bubble-appear 0.6s ease-out 2.2s forwards;
    max-width: 400px;
    text-align: center;
}

/* Speech bubble tail */
.speech-bubble::after {
    content: '';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 10px;
    border-style: solid;
    border-color: transparent transparent #ffffff transparent;
}

/* Chalkboard texture overlay */
.loading-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 100px 100px, 150px 150px, 200px 200px;
    pointer-events: none;
    opacity: 0.5;
}

/* ============================================================================
   ANIMATIONS
   ============================================================================ */

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

/* Professor appears with bounce */
@keyframes professor-appear {
    0% {
        opacity: 0;
        transform: scale(0.5) translateY(-50px);
    }
    60% {
        transform: scale(1.1) translateY(10px);
    }
    80% {
        transform: scale(0.95) translateY(-5px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Professor waves - slight rotation */
@keyframes professor-wave {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(-10deg);
    }
    75% {
        transform: rotate(10deg);
    }
}

/* Speech bubble appears */
@keyframes speech-bubble-appear {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ============================================================================
   VARIATIONS & ALTERNATIVES
   ============================================================================ */

/* Alternative: Typing effect for speech bubble */
.speech-bubble.typing-effect {
    overflow: hidden;
    white-space: nowrap;
}

.speech-bubble.typing-effect .text-content {
    display: inline-block;
    overflow: hidden;
    white-space: nowrap;
    border-right: 3px solid #2d3748;
    animation: typing 1.5s steps(25) 2.2s forwards,
               blink-caret 0.75s step-end infinite;
}

@keyframes typing {
    from { width: 0; }
    to { width: 100%; }
}

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

/* Alternative: Pulse animation for professor */
.professor-sprite.pulse {
    animation: professor-appear 1s ease-out 0.5s forwards,
               professor-pulse 2s ease-in-out 1.5s infinite;
}

@keyframes professor-pulse {
    0%, 100% {
        transform: scale(1);
        filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
    }
    50% {
        transform: scale(1.05);
        filter: drop-shadow(0 6px 12px rgba(79, 195, 247, 0.4));
    }
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

@media (max-width: 768px) {
    .professor-sprite {
        font-size: 6rem;
        margin-bottom: 1.5rem;
    }

    .speech-bubble {
        font-size: 1.2rem;
        padding: 1.2rem 1.5rem;
        max-width: 300px;
    }
}

@media (max-width: 480px) {
    .professor-sprite {
        font-size: 5rem;
        margin-bottom: 1rem;
    }

    .speech-bubble {
        font-size: 1rem;
        padding: 1rem 1.2rem;
        max-width: 250px;
    }
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
    .loading-screen,
    .professor-sprite,
    .speech-bubble {
        animation: none;
        transition: none;
    }

    .professor-sprite {
        opacity: 1;
        transform: none;
    }

    .speech-bubble {
        opacity: 1;
        transform: none;
    }
}

/* Focus styles for keyboard navigation */
.loading-screen:focus {
    outline: none;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .loading-screen {
        background: #1a202c;
    }

    .speech-bubble {
        border: 2px solid #2d3748;
    }
}
