/* ========================================
   Premium Curtain Preloader
   Modern, Minimal, Fluid Animation
======================================== */

:root {
    --preloader-bg: #0a0a0a;
    --preloader-accent: #06BBCC;
    --preloader-text: #ffffff;
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
    --ease-in-out-quint: cubic-bezier(0.83, 0, 0.17, 1);
}

body.loading-active {
    overflow: hidden;
}

/* Page content initial state */
body.loading-active .page-content,
body.loading-active main,
body.loading-active > *:not(.preloader-curtain):not(script):not(style):not(link) {
    opacity: 0;
    transform: translateY(40px);
}

/* Page content reveal animation */
body.content-revealed .page-content,
body.content-revealed main,
body.content-revealed > *:not(.preloader-curtain):not(script):not(style):not(link) {
    animation: contentReveal 1s var(--ease-out-expo) forwards;
}

@keyframes contentReveal {
    0% {
        opacity: 0;
        transform: translateY(40px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   Curtain Container
======================================== */
.preloader-curtain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background: var(--preloader-bg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    will-change: transform;
}

/* Subtle gradient overlay */
.preloader-curtain::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse at 50% 50%, rgba(6, 187, 204, 0.04) 0%, transparent 70%),
        linear-gradient(180deg, rgba(255,255,255,0.02) 0%, transparent 50%);
    pointer-events: none;
}

/* Slide up animation */
.preloader-curtain.slide-up {
    animation: curtainSlideUp 1s var(--ease-in-out-quint) forwards;
}

@keyframes curtainSlideUp {
    0% {
        transform: translateY(0);
    }
    100% {
        transform: translateY(-100%);
    }
}

/* ========================================
   Logo Section
======================================== */
.preloader-logo-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
}

.preloader-logo {
    position: relative;
    width: 160px;
    height: 160px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.preloader-logo img {
    width: 120px;
    height: 120px;
    object-fit: contain;
    border-radius: 50%;
    background: #fff;
    padding: 16px;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.05);
    animation: logoPulse 2.5s var(--ease-out-quart) infinite;
}

@keyframes logoPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 
            0 8px 32px rgba(0, 0, 0, 0.4),
            0 0 0 1px rgba(255, 255, 255, 0.05);
    }
    50% {
        transform: scale(1.03);
        box-shadow: 
            0 12px 40px rgba(0, 0, 0, 0.5),
            0 0 0 1px rgba(255, 255, 255, 0.08),
            0 0 60px rgba(6, 187, 204, 0.15);
    }
}

/* Animated ring around logo */
.preloader-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 1.5px solid transparent;
    border-top-color: var(--preloader-accent);
    animation: ringRotate 1.4s linear infinite;
}

.preloader-ring:nth-child(2) {
    width: 130%;
    height: 130%;
    top: -15%;
    left: -15%;
    border-top-color: transparent;
    border-right-color: rgba(255, 255, 255, 0.12);
    animation-duration: 2s;
    animation-direction: reverse;
}

@keyframes ringRotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Logo exit animation */
.preloader-curtain.slide-up .preloader-logo img {
    animation: logoExit 0.6s var(--ease-out-expo) forwards;
}

.preloader-curtain.slide-up .preloader-ring {
    animation: ringExit 0.5s var(--ease-out-expo) forwards;
}

@keyframes logoExit {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(0.85);
        opacity: 0;
    }
}

@keyframes ringExit {
    to {
        opacity: 0;
        transform: scale(1.3) rotate(90deg);
    }
}

/* ========================================
   Progress Indicator
======================================== */
.preloader-progress {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.progress-percentage {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 28px;
    font-weight: 600;
    color: var(--preloader-text);
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

.progress-track {
    width: 240px;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--preloader-accent);
    border-radius: 2px;
    transition: width 0.4s var(--ease-out-quart);
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: shimmer 1.8s infinite;
}

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

.progress-text {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.35);
    transition: color 0.3s ease;
}

.preloader-curtain.slide-up .preloader-progress {
    animation: progressExit 0.4s var(--ease-out-expo) forwards;
}

@keyframes progressExit {
    to {
        opacity: 0;
        transform: translateY(-15px);
    }
}

/* ========================================
   Responsive
======================================== */
@media (max-width: 768px) {
    .preloader-logo {
        width: 130px;
        height: 130px;
    }

    .preloader-logo img {
        width: 100px;
        height: 100px;
        padding: 14px;
    }

    .progress-percentage {
        font-size: 24px;
    }

    .progress-track {
        width: 200px;
    }

    .preloader-logo-wrapper {
        gap: 32px;
    }
}

/* ========================================
   Reduced Motion
======================================== */
@media (prefers-reduced-motion: reduce) {
    .preloader-curtain.slide-up {
        animation: curtainFade 0.5s ease forwards;
    }

    @keyframes curtainFade {
        to { opacity: 0; }
    }

    .preloader-logo img,
    .preloader-ring {
        animation: none !important;
    }

    body.content-revealed .page-content,
    body.content-revealed main,
    body.content-revealed > *:not(.preloader-curtain):not(script):not(style):not(link) {
        animation: none;
        opacity: 1;
        transform: none;
    }
}
