/* ========================================
   AI Mind Quest — Animations & Effects
   ======================================== */

/* Room Entrance */
@keyframes roomFadeIn {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes roomFadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(1.04);
    }
}

.room-enter {
    animation: roomFadeIn 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.room-exit {
    animation: roomFadeOut 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Role Badge Transition */
@keyframes rolePulse {
    0% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); opacity: 0.7; }
}

.role-badge-animate {
    animation: rolePulse 1.5s ease-in-out;
}

/* Level Number Pop */
@keyframes levelPop {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.level-pop {
    animation: levelPop 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Transition Screen */
.transition-screen {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.transition-screen.active {
    opacity: 1;
    pointer-events: auto;
}

.transition-screen__level {
    font-size: 80px;
    font-weight: 900;
    color: var(--room-accent, var(--color-accent));
    line-height: 1;
    margin-bottom: 16px;
}

.transition-screen__title {
    font-size: 24px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 8px;
    text-align: center;
    padding: 0 24px;
}

.transition-screen__role {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--room-accent, var(--color-accent));
    margin-bottom: 40px;
}

.transition-screen__loader {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255, 255, 255, 0.08);
    border-top-color: var(--room-accent, var(--color-accent));
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Scanlines — Room 1 (Terminal) */
@keyframes scanline {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100vh); }
}

.fx-scanlines::after {
    content: '';
    position: fixed;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(76, 175, 80, 0.03) 2px,
        rgba(76, 175, 80, 0.03) 4px
    );
    pointer-events: none;
    z-index: -1;
}

/* Vignette — Room 2 (Library) */
.fx-vignette::after {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(
        ellipse at center,
        transparent 50%,
        rgba(0, 0, 0, 0.4) 100%
    );
    pointer-events: none;
    z-index: -1;
}

/* Typewriter — Room 3 */
@keyframes blink-cursor {
    0%, 50% { border-color: var(--room-accent); }
    51%, 100% { border-color: transparent; }
}

.fx-typewriter {
    border-right: 2px solid var(--room-accent);
    animation: blink-cursor 1s step-end infinite;
    white-space: nowrap;
    overflow: hidden;
}

/* Floating Particles — Room 4 (Studio) */
@keyframes float-particle {
    0%, 100% { transform: translateY(0) rotate(0deg); opacity: 0.6; }
    50% { transform: translateY(-30px) rotate(180deg); opacity: 1; }
}

.fx-particles {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}

.fx-particles__dot {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--room-accent);
    animation: float-particle 4s ease-in-out infinite;
}

/* Data Stream — Room 5 (Control Room) */
@keyframes data-flow {
    0% { transform: translateY(-100%); opacity: 0; }
    10% { opacity: 0.5; }
    90% { opacity: 0.5; }
    100% { transform: translateY(100vh); opacity: 0; }
}

.fx-datastream {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}

.fx-datastream__line {
    position: absolute;
    width: 1px;
    height: 60px;
    background: linear-gradient(transparent, var(--room-accent), transparent);
    animation: data-flow 3s linear infinite;
    opacity: 0.3;
}

/* Blueprint Grid — Room 6 (Workshop) */
.fx-blueprint {
    background-image:
        linear-gradient(rgba(255, 152, 0, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 152, 0, 0.06) 1px, transparent 1px);
    background-size: 24px 24px;
}

/* Node Network — Room 7 (Command Center) */
@keyframes orbit {
    0% { transform: rotate(0deg) translateX(80px) rotate(0deg); }
    100% { transform: rotate(360deg) translateX(80px) rotate(-360deg); }
}

@keyframes pulse-node {
    0%, 100% { box-shadow: 0 0 8px var(--room-accent-glow); }
    50% { box-shadow: 0 0 24px var(--room-accent-glow); }
}

.fx-nodes {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
}

.fx-nodes__node {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--room-accent);
    animation: pulse-node 2s ease-in-out infinite;
}

/* General fade */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.4s ease forwards;
}

.fade-in-up {
    animation: fadeInUp 0.5s ease forwards;
}

.fade-in-delay-1 { animation-delay: 0.1s; opacity: 0; }
.fade-in-delay-2 { animation-delay: 0.2s; opacity: 0; }
.fade-in-delay-3 { animation-delay: 0.3s; opacity: 0; }
.fade-in-delay-4 { animation-delay: 0.4s; opacity: 0; }
.fade-in-delay-5 { animation-delay: 0.5s; opacity: 0; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
