/*
 * Shams FoodHub
 * ------------------------------------------------------------
 * Branded global loading state
 *
 * This component is intentionally isolated from the storefront
 * layout. It only becomes interactive while a navigation/form
 * operation is in progress.
 */


/* ============================================================
   GLOBAL OVERLAY
   ============================================================ */

.global-loader {
    position: fixed;
    inset: 0;
    z-index: 9999;

    display: flex;
    align-items: center;
    justify-content: center;

    /*
     * Slightly warm translucent background works better with the
     * FoodHub brand than a completely opaque white screen.
     */
    background:
        rgba(255, 250, 246, 0.94);

    /*
     * Modern browsers create a subtle glass-like effect while
     * keeping the content underneath visually subdued.
     */
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);

    /*
     * Hidden by default.
     */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transition:
        opacity 240ms ease,
        visibility 240ms ease;
}


/*
 * Active loading state.
 */
.global-loader.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}


/* ============================================================
   LOADER CARD
   ============================================================ */

.loader-card {
    position: relative;

    width: min(340px, calc(100vw - 40px));

    display: flex;
    flex-direction: column;
    align-items: center;

    padding: 34px 30px 30px;

    /*
     * The card itself is deliberately very subtle.
     * The animation should remain the focal point.
     */
    background: rgba(255, 255, 255, 0.96);

    border: 1px solid rgba(232, 111, 0, 0.08);
    border-radius: 24px;

    box-shadow:
        0 25px 70px rgba(80, 45, 20, 0.12);

    /*
     * Small entrance animation.
     */
    transform: translateY(8px) scale(0.97);

    transition:
        transform 260ms cubic-bezier(0.22, 1, 0.36, 1);
}


.global-loader.is-visible .loader-card {
    transform: translateY(0) scale(1);
}


/* ============================================================
   BRAND LOGO
   ============================================================ */

.loader-brand {
    position: relative;

    width: 82px;
    height: 82px;

    display: flex;
    align-items: center;
    justify-content: center;

    margin-bottom: 20px;
}


/*
 * Rotating ring around the logo.
 *
 * We use a pseudo-element so no additional DOM element is needed.
 */
.loader-brand::before {
    content: "";

    position: absolute;
    inset: 0;

    border-radius: 50%;

    border: 3px solid rgba(232, 111, 0, 0.12);

    border-top-color: #e86f00;
    border-right-color: #e86f00;

    animation:
        loader-ring-spin 900ms linear infinite;
}


/*
 * Small pulsing glow behind the logo.
 */
.loader-brand::after {
    content: "";

    position: absolute;

    width: 62px;
    height: 62px;

    border-radius: 50%;

    background:
        rgba(232, 111, 0, 0.08);

    animation:
        loader-glow 1.8s ease-in-out infinite;
}


/*
 * Actual Shams FoodHub logo.
 */
.loader-logo {
    position: relative;
    z-index: 2;

    width: 52px;
    height: 52px;

    object-fit: contain;

    /*
     * A tiny amount of breathing animation keeps the logo alive
     * without making the interface distracting.
     */
    animation:
        loader-logo-breathe 1.8s ease-in-out infinite;
}


/* ============================================================
   TEXT
   ============================================================ */

.loader-title {
    margin: 0;

    color: #222222;

    font-size: 1rem;
    font-weight: 800;

    letter-spacing: -0.01em;
}


.loader-text {
    display: flex;
    align-items: center;

    min-height: 24px;

    margin-top: 6px;

    color: #777777;

    font-size: 0.82rem;
    font-weight: 500;

    text-align: center;
}


/*
 * Animated dots.
 */
.loader-dots {
    display: inline-flex;

    margin-left: 3px;

    letter-spacing: 2px;
}


.loader-dots span {
    opacity: 0.2;

    animation:
        loader-dot 1.2s ease-in-out infinite;
}


.loader-dots span:nth-child(2) {
    animation-delay: 150ms;
}


.loader-dots span:nth-child(3) {
    animation-delay: 300ms;
}


/* ============================================================
   PROGRESS INDICATOR
   ============================================================ */

.loader-progress {
    width: 150px;
    height: 3px;

    overflow: hidden;

    margin-top: 20px;

    border-radius: 999px;

    background: rgba(232, 111, 0, 0.10);
}


.loader-progress-bar {
    width: 45%;
    height: 100%;

    border-radius: inherit;

    background: #e86f00;

    transform: translateX(-150%);

    animation:
        loader-progress 1.25s ease-in-out infinite;
}


/* ============================================================
   ANIMATIONS
   ============================================================ */

@keyframes loader-ring-spin {
    to {
        transform: rotate(360deg);
    }
}


@keyframes loader-glow {
    0%,
    100% {
        transform: scale(0.88);
        opacity: 0.45;
    }

    50% {
        transform: scale(1.08);
        opacity: 0.9;
    }
}


@keyframes loader-logo-breathe {
    0%,
    100% {
        transform: scale(0.96);
    }

    50% {
        transform: scale(1.04);
    }
}


@keyframes loader-dot {
    0%,
    60%,
    100% {
        opacity: 0.2;
        transform: translateY(0);
    }

    30% {
        opacity: 1;
        transform: translateY(-2px);
    }
}


@keyframes loader-progress {
    0% {
        transform: translateX(-150%);
    }

    50% {
        transform: translateX(70%);
    }

    100% {
        transform: translateX(240%);
    }
}


/* ============================================================
   BUTTON LOADING STATE
   ============================================================ */

.is-loading {
    position: relative;

    cursor: wait !important;
}


/*
 * Hide the existing button content while the button spinner is
 * visible. This prevents text and spinner from overlapping.
 */
.is-loading > * {
    visibility: hidden;
}


.is-loading::after {
    content: "";

    position: absolute;

    top: 50%;
    left: 50%;

    width: 17px;
    height: 17px;

    margin-top: -8.5px;
    margin-left: -8.5px;

    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: currentColor;

    border-radius: 50%;

    animation:
        loader-ring-spin 650ms linear infinite;
}


/* ============================================================
   MOBILE
   ============================================================ */

@media (max-width: 480px) {

    .loader-card {
        width: calc(100vw - 32px);

        padding: 30px 22px 26px;

        border-radius: 20px;
    }

    .loader-brand {
        width: 74px;
        height: 74px;
    }

    .loader-logo {
        width: 47px;
        height: 47px;
    }

    .loader-progress {
        width: 130px;
    }
}


/* ============================================================
   REDUCED MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {

    .global-loader,
    .loader-card {
        transition: none;
    }

    .loader-brand::before,
    .loader-brand::after,
    .loader-logo,
    .loader-dots span,
    .loader-progress-bar,
    .is-loading::after {
        animation: none;
    }

    /*
     * Keep the loader visually usable even when animation has
     * been disabled by the user's accessibility preference.
     */
    .loader-progress-bar {
        width: 100%;
        transform: none;
    }
}