/*
 * GED — « Recherche en cours… » (chargement.js).
 *
 * Une barre qui court en haut de l'écran dès qu'une recherche part ; un
 * voile sur les résultats si la réponse tarde. La roue reprend le spinner de
 * Mars (style.css : bordure claire, arc rouge FO).
 */

.chargement-barre {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    height: 3px;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.chargement-actif .chargement-barre {
    opacity: 1;
}

.chargement-barre::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -40%;
    width: 40%;
    background: linear-gradient(90deg, transparent, #df2e2b 30%, #ff8a80 70%, transparent);
    animation: chargement-course 1.1s ease-in-out infinite;
}

@keyframes chargement-course {
    0% { left: -40%; }
    100% { left: 100%; }
}

.chargement-actif,
.chargement-actif body {
    cursor: progress;
}

/* --- Le voile ---------------------------------------------------------- */

.chargement-zone {
    position: relative;
}

.chargement-voile {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(1.5px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0s linear 0.2s;
}

.chargement-voile.visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.2s;
}

/* La carte suit l'écran : sur une longue liste qu'on a fait défiler, elle
   reste au milieu de ce qu'on regarde. */
.chargement-carte {
    position: sticky;
    top: 35vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    max-width: min(360px, calc(100% - 32px));
    margin-top: 80px;
    padding: 22px 28px;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
    text-align: center;
}

.chargement-roue {
    width: 40px;
    height: 40px;
    border: 4px solid #f1d0cf;
    border-top-color: #df2e2b;
    border-radius: 50%;
    animation: chargement-tour 0.9s linear infinite;
}

@keyframes chargement-tour {
    to { transform: rotate(360deg); }
}

.chargement-titre {
    margin: 0;
    font-weight: 600;
    color: var(--color-text, #222);
}

.chargement-explication {
    margin: 0;
    max-height: 0;
    overflow: hidden;
    font-size: 13px;
    color: #666;
    opacity: 0;
    transition: opacity 0.3s, max-height 0.3s;
}

.chargement-explication.visible {
    max-height: 8em;
    opacity: 1;
}

/* --- Le bouton qui a lancé la recherche --------------------------------- */

.chargement-bouton {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.chargement-bouton::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid rgba(0, 0, 0, 0.15);
    border-top-color: #df2e2b;
    border-radius: 50%;
    animation: chargement-tour 0.8s linear infinite;
}

/* Sur un bouton plein, la roue est blanche. */
.btn-filter-primary.chargement-bouton::after {
    border-color: rgba(255, 255, 255, 0.45);
    border-top-color: #fff;
}

/* Lecteur d'écran seulement. */
.chargement-annonce {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
    .chargement-barre::before {
        left: 0;
        width: 100%;
        animation: none;
        background: #df2e2b;
    }

    .chargement-roue,
    .chargement-bouton::after {
        animation-duration: 2.5s;
    }
}
