/* Shared loading UI: full-screen overlay, inline section loader and button spinner.
   Colours follow the app palette (navy #19143D, orange #E8641C, off-white #FAF6F2). */

.global-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background-color: rgba(250, 246, 242, 0.88);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 180ms ease, visibility 180ms ease;
}

.global-loading-overlay.is-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.global-loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    color: #E8641C;
    transform: translateY(6px);
    transition: transform 180ms ease;
}

.global-loading-overlay.is-active .global-loading-content {
    transform: translateY(0);
}

.global-loading-message {
    color: #19143D;
    font-family: ui-sans-serif, system-ui, sans-serif;
    font-size: 0.9375rem;
    font-weight: 600;
    text-align: center;
}

body.is-loading {
    overflow: hidden;
}

/* SVG spinner (global overlay and section loaders) */
.global-spinner {
    display: block;
    width: 44px;
    height: 44px;
}

.spinner-track {
    stroke: currentColor;
    opacity: 0.15;
}

.spinner-progress {
    stroke: currentColor;
    stroke-dasharray: 125;
    stroke-dashoffset: 95;
    transform-origin: center;
    animation: spinnerRotate 900ms linear infinite, spinnerDash 1300ms ease-in-out infinite;
}

@keyframes spinnerRotate {
    to { transform: rotate(360deg); }
}

@keyframes spinnerDash {
    0% { stroke-dashoffset: 110; }
    50% { stroke-dashoffset: 35; }
    100% { stroke-dashoffset: 110; }
}

/* Section loader: spinner + message inside a panel that is still loading */
.section-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 3rem 1rem;
    color: #E8641C;
}

.section-loader .global-spinner {
    width: 36px;
    height: 36px;
}

.section-loader-message {
    color: #999;
    font-size: 0.9375rem;
}

/* On the navy voter background */
.section-loader.on-dark .section-loader-message {
    color: #FAF6F2;
}

/* Button spinner */
.button-spinner {
    display: inline-block;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: buttonSpin 600ms linear infinite;
}

@keyframes buttonSpin {
    to { transform: rotate(360deg); }
}

.button-loading-content {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

button.is-loading,
a.is-loading {
    cursor: wait !important;
    pointer-events: none;
}

/* Reduced motion: keep the spinners turning, but slower, so loading is still visible */
@media (prefers-reduced-motion: reduce) {
    .spinner-progress {
        animation: spinnerRotate 1.6s linear infinite !important;
    }

    .button-spinner {
        animation: buttonSpin 1.2s linear infinite !important;
    }
}
