/**
 * ExpoXR Page Transition Preloader
 * Version: 1.0.0
 * Smooth page transitions with loading bar and percentage
 */

/* ==================== PRELOADER OVERLAY ==================== */

#page-preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000000;
    z-index: 999999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s ease-out;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Active state - controlled by body class */
body.preloader-visible #page-preloader,
html.preloader-visible #page-preloader {
    opacity: 1;
    pointer-events: all;
}

/* ==================== INNER LAYOUT ==================== */

.preloader-inner {
    display: flex;
    width: 90%;
    max-width: 1400px;
    height: 100%;
    align-items: flex-end;
    padding-bottom: 80px;
    gap: 60px;
}

/* ==================== LEFT SECTION (Page Name + Loading Bar) ==================== */

.preloader-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0px;
    align-items: flex-start;
}

.preloader-page-name {
   font-family: var(--e-global-typography-148cc15-font-family), Sans-serif;
    font-size: var(--e-global-typography-148cc15-font-size);
    font-weight: var(--e-global-typography-148cc15-font-weight);
    text-transform: var(--e-global-typography-148cc15-text-transform);
    font-style: var(--e-global-typography-148cc15-font-style);
    text-decoration: var(--e-global-typography-148cc15-text-decoration);
    line-height: var(--e-global-typography-148cc15-line-height);
    color: var(--e-global-color-text);
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.6s ease-out 0.2s forwards;
}

.preloader-bar-wrapper {
    width: 100%;
    height: 2px;
    border-radius: 3px;
    overflow: hidden;
    position: relative;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.6s ease-out 0.4s forwards;
}

.preloader-bar {
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        #2AACE2 0%,
        #8062AA 25%,
        #4555A5 50%,
        #EF4681 75%,
        #F36E24 100%
    );
    border-radius: 3px;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease-out;
}

/* ==================== RIGHT SECTION (Percentage) ==================== */

.preloader-right {
    position: fixed;
    top: calc(40vh - 150px);
    right: calc(2vw - 50px);
    flex: 0 0 50%;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 0 40px;
    margin-left: -60px;
}

.preloader-percent {
    font-size: clamp(15rem, 35vw, 40rem);
    font-weight: 900;
    color: rgba(255, 255, 255, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.6s ease-out 0.3s forwards;
    letter-spacing: -0.02em;
}

/* ==================== ANIMATIONS ==================== */

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== RESPONSIVE DESIGN ==================== */

@media (max-width: 1024px) {
    .preloader-inner {
        padding-bottom: 60px;
        gap: 40px;
    }
    
    .preloader-left {
        gap: 0;
    }
}

@media (max-width: 768px) {
    .preloader-inner {
        flex-direction: column;
        justify-content: flex-end;
        padding-bottom: 40px;
        gap: 30px;
        align-items: stretch;
    }
    
    .preloader-left {
        position: fixed;
        gap: 1px;
    }
    
    .preloader-right {
        flex: 0 0 auto;
        justify-content: flex-start;
        margin-left: 0;
        padding: 20px 0;
    }
    
    .preloader-bar-wrapper {
        height: 2px;
    }
    .preloader-percent {
        transform: rotate(-90deg) !important;
    }
}

/* ==================== PREVENT CONTENT FLASH ==================== */

/* Block scrolling when preloader is visible */
html.preloader-visible,
html.preloader-visible body {
    overflow: hidden !important;
    height: 100vh !important;
    position: fixed !important;
    width: 100% !important;
}

/* Hide content during preloader */
html.preloader-visible body > *:not(#page-preloader) {
    opacity: 0;
}

/* Show content after preloader */
body:not(.preloader-visible) > *:not(#page-preloader) {
    opacity: 1;
    transition: opacity 0.3s ease-in;
}

/* Ensure Elementor content is hidden during load */
html.preloader-visible .elementor {
    opacity: 0;
}

/* ==================== ACCESSIBILITY ==================== */

@media (prefers-reduced-motion: reduce) {
    #page-preloader,
    .preloader-page-name,
    .preloader-bar-wrapper,
    .preloader-percent,
    .preloader-bar {
        animation: none !important;
        transition: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
}
