/**
 * Site loading indicators
 * - .loader — circular spinner for public / general loading
 * - .loader-dots — four-dot bounce for admin dashboard
 * - .loader-upload — progress bar for file uploads
 * - .page-loader — full-viewport overlay for route / first paint
 */

.page-loader {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: #0f3d22;
    color: #fff;
    opacity: 1;
    visibility: visible;
    pointer-events: all;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

.page-loader:not(.is-active) {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.page-loader-label {
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.85);
}

html.page-loader-open {
    overflow: hidden;
}


.loader {
    --color-1: #fff;
    --color-2: #166534;
    --size: 1px;

    width: calc(48 * var(--size));
    height: calc(48 * var(--size));
    border-radius: 50%;
    position: relative;
    display: inline-block;
    flex-shrink: 0;
    animation: ems-loader-rotate 1s linear infinite;
}

.loader::before,
.loader::after {
    content: '';
    box-sizing: border-box;
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: calc(5 * var(--size)) solid var(--color-1);
    animation: ems-loader-prix-clip-fix 2s linear infinite;
}

.loader::after {
    transform: rotate3d(90, 90, 0, 180deg);
    border-color: var(--color-2);
}

.loader-sm {
    --size: 0.65px;
}

.loader-on-light {
    --color-1: #e8f5ec;
    --color-2: #166534;
}

.loader-on-dark {
    --color-1: #ffffff;
    --color-2: #86efac;
}

/**
 * Admin dots loader (four-dot bounce via box-shadow)
 */
.loader-dots {
    --color-1: #166534;
    --size: 1.85px;

    width: calc(12 * var(--size));
    height: calc(12 * var(--size));
    border-radius: 50%;
    display: block;
    margin: calc(15 * var(--size)) auto;
    position: relative;
    color: var(--color-1);
    box-sizing: border-box;
    flex-shrink: 0;
    animation: ems-loader-dots 2s linear infinite;
}

.loader-dots::before,
.loader-dots::after {
    content: none;
    display: none;
    border: 0;
    animation: none;
}

.loader-dots.loader-sm {
    --size: 1.25px;
    margin: calc(10 * var(--size)) auto;
}

.loader-dots.loader-on-dark {
    --color-1: #ffffff;
}

.loader-dots.loader-on-light {
    --color-1: #166534;
}

.loader-upload {
    --color-1: #ffffff;
    --color-2: #166534;
    --size: 1px;
    --upload-progress: 0%;

    display: block;
    position: relative;
    height: calc(32 * var(--size));
    width: min(100%, calc(200 * var(--size)));
    max-width: 100%;
    background: var(--color-1);
    border: calc(2 * var(--size)) solid #d1e7d8;
    border-radius: 0.35rem;
    color: var(--color-2);
    overflow: hidden;
    animation: none;
}

.loader-upload::before,
.loader-upload::after {
    border: 0;
    border-radius: 0;
    inset: auto;
    transform: none;
    animation: none;
}

.loader-upload::before {
    content: '';
    background: var(--color-2);
    position: absolute;
    left: 0;
    top: 0;
    width: var(--upload-progress);
    height: 100%;
    transition: width 0.12s linear;
}

.loader-upload::after {
    content: attr(data-progress);
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    text-align: center;
    font-size: calc(14 * var(--size));
    font-weight: 700;
    line-height: calc(28 * var(--size));
    color: var(--color-2);
    mix-blend-mode: difference;
}

.loader-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
}

.loader-stack-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: inherit;
}

@keyframes ems-loader-rotate {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

@keyframes ems-loader-prix-clip-fix {
    0% {
        clip-path: polygon(50% 50%, 0 0, 0 0, 0 0, 0 0, 0 0);
    }
    50% {
        clip-path: polygon(50% 50%, 0 0, 100% 0, 100% 0, 100% 0, 100% 0);
    }
    75%,
    100% {
        clip-path: polygon(50% 50%, 0 0, 100% 0, 100% 100%, 100% 100%, 100% 100%);
    }
}

@keyframes ems-loader-dots {
    0% {
        box-shadow:
            calc(14 * var(--size)) 0 0 calc(-2 * var(--size)),
            calc(38 * var(--size)) 0 0 calc(-2 * var(--size)),
            calc(-14 * var(--size)) 0 0 calc(-2 * var(--size)),
            calc(-38 * var(--size)) 0 0 calc(-2 * var(--size));
    }
    25% {
        box-shadow:
            calc(14 * var(--size)) 0 0 calc(-2 * var(--size)),
            calc(38 * var(--size)) 0 0 calc(-2 * var(--size)),
            calc(-14 * var(--size)) 0 0 calc(-2 * var(--size)),
            calc(-38 * var(--size)) 0 0 calc(2 * var(--size));
    }
    50% {
        box-shadow:
            calc(14 * var(--size)) 0 0 calc(-2 * var(--size)),
            calc(38 * var(--size)) 0 0 calc(-2 * var(--size)),
            calc(-14 * var(--size)) 0 0 calc(2 * var(--size)),
            calc(-38 * var(--size)) 0 0 calc(-2 * var(--size));
    }
    75% {
        box-shadow:
            calc(14 * var(--size)) 0 0 calc(2 * var(--size)),
            calc(38 * var(--size)) 0 0 calc(-2 * var(--size)),
            calc(-14 * var(--size)) 0 0 calc(-2 * var(--size)),
            calc(-38 * var(--size)) 0 0 calc(-2 * var(--size));
    }
    100% {
        box-shadow:
            calc(14 * var(--size)) 0 0 calc(-2 * var(--size)),
            calc(38 * var(--size)) 0 0 calc(2 * var(--size)),
            calc(-14 * var(--size)) 0 0 calc(-2 * var(--size)),
            calc(-38 * var(--size)) 0 0 calc(-2 * var(--size));
    }
}
