﻿/* ==========================================================
   GLOBAL PAGE LOADER (SAFE & ISOLATED)
   ========================================================== */

/* Prevent scrolling when loader is active - fixed to prevent page-jump */
body.loader-active {
    overflow: hidden !important;
}

/* Fullscreen wrapper */
#pageLoader {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    pointer-events: none;
    transition: opacity .35s ease, visibility .35s ease;
}

/* Enhanced semi-transparent blur backdrop */
.loader-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.45);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    transition: opacity .35s ease;
}

/* Fallback for browsers without backdrop-filter */
@supports not (backdrop-filter: blur(8px)) {
    .loader-backdrop {
        background: rgba(10, 20, 40, 0.35);
    }
}

/* Enhanced glass card effect */
.loader-box {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
    padding: 18px 22px;
    border-radius: 12px;
    pointer-events: auto;
    z-index: 100000;
    background: var(--white); /* Linked to site.css */
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    box-shadow: 0 10px 30px rgba(8, 20, 40, 0.12);
    min-width: 220px;
    max-width: min(84vw, 520px);
}

/* Loader animation using site.css primary color */
.loader-animation {
    width: 90px;
    height: 90px;
    /* Using var(--primary) from site.css instead of creating new root vars */
    --g: radial-gradient(farthest-side, #0000 calc(95% - 3px), var(--primary) calc(100% - 3px) 98%, #0000 101%) no-repeat;
    background: var(--g), var(--g), var(--g);
    background-size: 40px 40px;
    animation: loaderMove 1.5s linear infinite;
}

@keyframes loaderMove {
    0% {
        background-position: 0 0, 0 100%, 100% 100%;
    }

    25% {
        background-position: 100% 0, 0 100%, 100% 100%;
    }

    50% {
        background-position: 100% 0, 0 0, 100% 100%;
    }

    75% {
        background-position: 100% 0, 0 0, 0 100%;
    }

    100% {
        background-position: 100% 100%, 0 0, 0 100%;
    }
}

/* Typography linked to site.css fonts */
.loader-text .collageLoaderTitle {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
    color: #12243b;
    letter-spacing: 0.2px;
    font-family: 'Playfair Display', serif; /* Linked to site.css headings */
}

.loader-text .collageLoaderSub {
    margin: 0;
    font-size: 0.95rem;
    color: rgba(8, 20, 40, 0.75);
    opacity: 0.95;
    font-family: 'Poppins', sans-serif; /* Linked to site.css body */
}

/* Hidden state */
#pageLoader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Responsive */
@media (max-width: 520px) {
    .loader-box {
        padding: 14px;
        min-width: 180px;
    }

    .loader-animation {
        width: 72px;
        height: 72px;
        background-size: 32px 32px;
    }

    .loader-text .collageLoaderTitle {
        font-size: 1.05rem;
    }

    .loader-text .collageLoaderSub {
        font-size: 0.9rem;
    }
}
