/**
 * HANAVERSE SPA TRANSITIONS
 * Smooth page transition animations and loading states
 */

/* ==================== PAGE LOADING BAR ==================== */
#spa-loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 99999;
    height: 3px;
    background: transparent;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

.spa-loader-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #00d2ff, #7b61ff, #b026ff);
    box-shadow: 0 0 20px rgba(0, 210, 255, 0.6), 0 0 40px rgba(123, 97, 255, 0.4);
    animation: spaLoaderProgress 0.8s ease-out forwards, spaLoaderPulse 0.8s ease-in-out infinite;
    border-radius: 0 2px 2px 0;
}

@keyframes spaLoaderProgress {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

@keyframes spaLoaderPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ==================== CONTENT FADE TRANSITIONS ==================== */
.main-content {
    transition: opacity 200ms ease, transform 200ms ease;
}

.spa-content-fade-out {
    opacity: 0 !important;
    transform: translateY(12px) !important;
}

.spa-content-fade-in {
    opacity: 1 !important;
    transform: translateY(0) !important;
}

/* ==================== NAVIGATION HIGHLIGHT PULSE ==================== */
.nav-link {
    position: relative;
    overflow: hidden;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #00d2ff, #7b61ff);
    transition: width 0.3s ease, left 0.3s ease;
    border-radius: 1px;
}

.nav-link.active::after {
    width: 60%;
    left: 20%;
}

/* ==================== PAGE ENTER ANIMATIONS ==================== */
@keyframes spaPageEnter {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes spaSlideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes spaSlideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes spaFadeScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ==================== STAGGERED CARD ENTRANCE ==================== */
.spa-card-enter {
    animation: spaCardSlideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
    transform: translateY(30px);
}

@keyframes spaCardSlideUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.spa-card-enter:nth-child(1) { animation-delay: 0.05s; }
.spa-card-enter:nth-child(2) { animation-delay: 0.1s; }
.spa-card-enter:nth-child(3) { animation-delay: 0.15s; }
.spa-card-enter:nth-child(4) { animation-delay: 0.2s; }
.spa-card-enter:nth-child(5) { animation-delay: 0.25s; }
.spa-card-enter:nth-child(6) { animation-delay: 0.3s; }
.spa-card-enter:nth-child(7) { animation-delay: 0.35s; }
.spa-card-enter:nth-child(8) { animation-delay: 0.4s; }

/* ==================== SMOOTH SCROLL BEHAVIOR ==================== */
html {
    scroll-behavior: smooth;
}

/* Prevent scroll during transitions */
body.spa-navigating {
    overflow-y: hidden;
    pointer-events: none;
}

body.spa-navigating .main-content {
    pointer-events: none;
}

/* ==================== FEED LAYOUT TRANSITIONS ==================== */
.feed-layout {
    transition: opacity 0.3s ease;
}

/* ==================== PROFILE HEADER ANIMATION ==================== */
.profile-header {
    animation: spaFadeScale 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ==================== LEADERBOARD ANIMATIONS ==================== */
.leaderboard-podium {
    animation: spaFadeScale 0.5s ease-out forwards;
}

/* ==================== CHAT MESSAGES CONTAINER ==================== */
.chat-container,
.messages-layout {
    animation: spaFadeScale 0.4s ease-out forwards;
}

/* ==================== GALLERY GRID ==================== */
.gallery-grid {
    animation: spaPageEnter 0.4s ease-out forwards;
}

/* ==================== MODAL SPA HANDLING ==================== */
.modal {
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* ==================== FORM SUBMIT LOADING STATE ==================== */
form.spa-submitting {
    opacity: 0.7;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

form.spa-submitting button[type="submit"] {
    position: relative;
    overflow: hidden;
}

form.spa-submitting button[type="submit"]::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    animation: spaShimmer 1s infinite;
}

@keyframes spaShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ==================== MOBILE TAB BAR TRANSITION ==================== */
.tab-item {
    transition: color 0.2s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ==================== SKELETON LOADING FOR SPA ==================== */
.spa-skeleton {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.02) 25%,
        rgba(255, 255, 255, 0.06) 50%,
        rgba(255, 255, 255, 0.02) 75%
    );
    background-size: 200% 100%;
    animation: spaSkeletonWave 1.5s ease-in-out infinite;
    border-radius: 12px;
}

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

/* ==================== REDUCED MOTION ==================== */
@media (prefers-reduced-motion: reduce) {
    #spa-loader,
    .spa-loader-bar,
    .main-content,
    .spa-card-enter,
    .profile-header,
    .leaderboard-podium,
    .chat-container,
    .messages-layout,
    .gallery-grid {
        animation: none !important;
        transition: none !important;
    }
    
    .spa-card-enter {
        opacity: 1;
        transform: none;
    }
}
