/* ============================================
   BARRE DE RECHERCHE — templates/components/recherche.html
   Barre desktop à segments (Ville ou code postal | Type de bien | Dates | Voyageurs) et bouton
   orange « Rechercher » en pilule, panneaux déroulants, suggestions de destination, types de bien,
   compteurs de voyageurs. Accueil (variante entete) et listing (compacte).
   Le calendrier est dans calendrier_voyageur.css, la pilule et la modale mobile dans
   recherche_modale.css.
   ============================================ */

/* Panneau ouvert entre 745 et 767 px (téléphone en paysage) : la barre d'onglets mobile est
   encore là, et le contexte d'empilement à 30 la laissait recouvrir les panneaux */
@media (max-width: 767px) {
    .recherche.recherche--active {
        z-index: var(--z-feuille);
    }
}

.recherche {
    position: relative;
    z-index: 30;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    color: var(--color-text);
    font-family: var(--font-main);
}

.recherche__form {
    position: relative;
}

/* --- BARRE --- */

/* Pilule blanche ; le bouton est posé dedans, avec un léger retrait sur la droite */
.recherche__barre {
    display: flex;
    align-items: center;
    height: 54px;
    padding-right: 5px;
    background: var(--color-bg);
    border: 1.5px solid var(--color-border-strong);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: background-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.recherche--active .recherche__barre {
    background: var(--color-surface-2);
}

.recherche__segment {
    flex: 1 1 0;
    min-width: 0;
    height: 100%;
    display: flex;
    align-items: center;
    border-radius: var(--radius-pill);
    transition: background-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.recherche__segment--destination {
    flex-grow: 1.5;
}

.recherche__segment:hover {
    background: var(--color-surface-2);
}

.recherche--active .recherche__segment:hover {
    background: var(--color-surface-3);
}

.recherche__segment.recherche__segment--actif,
.recherche--active .recherche__segment.recherche__segment--actif:hover {
    background: var(--color-bg);
    box-shadow: inset 0 0 0 2px var(--color-dark);
}

.recherche__declencheur {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    display: flex;
    align-items: center;
    padding: 0 10px 0 20px;
    background: none;
    border: 0;
    border-radius: var(--radius-pill);
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.recherche__segment--destination .recherche__declencheur {
    padding-left: 26px;
}

.recherche__declencheur:focus-visible {
    outline: 2px solid var(--color-text);
    outline-offset: -2px;
}

.recherche__valeur,
.recherche__saisie {
    display: block;
    width: 100%;
    font-size: var(--font-size-base);
    font-weight: 500;
    line-height: 20px;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recherche__valeur--vide {
    font-weight: 400;
}

/* « Voyageurs » en orange, demande du client (« Orange », nov. 2026). L'orange de la marque
   ne tient pas 4,5:1 en texte courant sur blanc : on prend sa variante texte, en gras,
   vide comme rempli */
.recherche__segment--voyageurs .recherche__valeur {
    font-weight: 700;
    color: var(--color-primary-text);
}

.recherche__saisie {
    padding: 0;
    border: 0;
    outline: none;
    background: transparent;
    font-family: inherit;
}

.recherche__saisie::placeholder {
    font-weight: 400;
    color: var(--color-text);
    opacity: 1;
}

/* Séparateurs : masqués de part et d'autre du segment survolé ou actif */
.recherche__sep {
    flex: 0 0 1px;
    height: 32px;
    background: var(--color-border);
    transition: opacity 0.2s var(--ease);
}

.recherche__segment:hover + .recherche__sep,
.recherche__sep:has(+ .recherche__segment:hover),
.recherche__segment--actif + .recherche__sep,
.recherche__sep:has(+ .recherche__segment--actif) {
    opacity: 0;
}

/* Effacer : sur le segment actif qui a une valeur */
.recherche__effacer {
    flex: 0 0 24px;
    width: 24px;
    height: 24px;
    margin-right: 12px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--color-surface-2);
    color: var(--color-text);
    cursor: pointer;
}

.recherche__effacer:hover {
    background: var(--color-surface-3);
}

.recherche__effacer:focus-visible {
    outline: 2px solid var(--color-text);
    outline-offset: 2px;
}

.recherche__segment--actif .recherche__effacer:not([hidden]) {
    display: inline-flex;
}

/* Bouton rond orange vif à loupe seule.
   L'orange de la maquette ne tient que 3,3:1 sous du blanc : assez pour une icône (3:1,
   WCAG 1.4.11), pas pour un texte. Le libellé « Rechercher » reste donc réservé aux
   lecteurs d'écran, à toutes les largeurs (exception tenue par test_css.py). */
.recherche__bouton {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-left: 5px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--color-primary);
    color: var(--color-on-primary);
    font: inherit;
    cursor: pointer;
    transition: background-color 0.2s var(--ease);
}

.recherche__bouton:hover {
    background: var(--color-primary-strong);
}

.recherche__bouton:focus-visible {
    outline: 2px solid var(--color-dark);
    outline-offset: 2px;
}

.recherche__bouton-libelle {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* --- PANNEAUX --- */

.recherche__panneau {
    position: absolute;
    top: calc(100% + 12px);
    z-index: var(--z-popover);
    background: var(--color-bg);
    border-radius: var(--radius-3xl);
    box-shadow: var(--shadow-float);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s var(--ease), transform 0.2s var(--ease), visibility 0s linear 0.2s;
}

.recherche__panneau--ouvert {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition-delay: 0s;
}

.recherche__panneau--destination {
    left: 0;
    width: min(425px, 100%);
    max-height: min(520px, 70vh);
    overflow-y: auto;
    padding: 24px 0 16px;
}

.recherche__panneau--dates {
    left: 0;
    right: 0;
    padding: 28px 32px 32px;
}

.recherche__panneau--voyageurs {
    right: 0;
    width: min(400px, 100%);
    padding: 16px 32px;
}

.recherche__panneau--type {
    left: 22%;
    width: min(380px, 100%);
    padding: 22px 24px 24px;
}

.recherche__panneau--type .recherche__panneau-titre {
    padding: 0 0 12px;
}

/* Types de bien : pastilles (panneau desktop et carte « Quel logement ? » de la modale) */
.recherche-types,
.recherche-personnes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Page étudiante : une icône de personne à la place du mot « Voyageurs » (client, 30 nov. 2026) */
.recherche__icone-personne {
    flex: none;
    margin-right: 8px;
    color: var(--color-primary-text);
}

/* --- SUGGESTIONS DE DESTINATION --- */

.recherche__panneau-titre {
    margin: 0;
    padding: 0 32px 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--color-text-light);
}

.recherche-villes {
    list-style: none;
    margin: 0;
    padding: 0 16px;
}

.recherche-ville {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 16px;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: background-color 0.15s;
}

.recherche-ville:hover,
.recherche-ville--active {
    background: var(--color-surface);
}

.recherche-ville__tuile {
    flex: 0 0 56px;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    background: var(--color-primary-light);
    color: var(--color-text);
}

.recherche-ville__textes {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.recherche-ville__nom {
    font-size: var(--font-size-md);
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* En frappe : le nom en normal, la partie trouvée en gras */
.recherche-villes--filtre .recherche-ville__nom {
    font-weight: 500;
}

.recherche-ville__nom strong {
    font-weight: 800;
}

.recherche-ville__nombre {
    font-size: 13px;
    color: var(--color-text-light);
}

/* --- COMPTEURS DE VOYAGEURS --- */

.compteur {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid var(--color-surface-2);
}

.compteur:last-child {
    border-bottom: 0;
}

.compteur__textes {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.compteur__titre {
    font-size: var(--font-size-base);
    font-weight: 700;
}

.compteur__aide {
    font-size: var(--font-size-sm);
    color: var(--color-text-light);
}

/* « Vous voyagez avec un animal d'assistance ? » : un bouton qui a l'air d'un lien */
.compteur__lien {
    align-self: flex-start;
    padding: 0;
    border: 0;
    background: none;
    color: var(--color-text);
    font: inherit;
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-align: left;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.compteur__lien:focus-visible {
    outline: 2px solid var(--color-dark);
    outline-offset: 2px;
}

/* --- ANIMAL D'ASSISTANCE (<dialog>) --- */

/* margin: auto rend le centrage du <dialog> que la remise à zéro de base.css lui retire */
.recherche-assistance {
    width: min(420px, calc(100vw - 32px));
    max-width: none;
    margin: auto;
    padding: 0;
    border: 0;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    color: var(--color-text);
}

.recherche-assistance::backdrop {
    background: var(--color-scrim);
}

.recherche-assistance__boite {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 24px;
}

.recherche-assistance__titre {
    font-size: var(--font-size-lg);
    font-weight: 800;
}

.recherche-assistance__texte {
    font-size: var(--font-size-md);
    line-height: 1.55;
}

.compteur__controles {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.compteur__valeur {
    min-width: 20px;
    font-size: var(--font-size-base);
    text-align: center;
}

@media (prefers-reduced-motion: reduce) {
    .recherche * {
        transition-duration: 0s !important;
    }
}

/* Focus clavier rendu après Échap : le segment n'est plus actif, on montre quand même où l'on est */
.recherche:not(.recherche--active) .recherche__segment:focus-within {
    outline: 2px solid var(--color-text);
    outline-offset: -2px;
    border-radius: var(--radius-pill);
}
