/**
 * Sélecteur de langue GTranslate — bulle du drapeau courant + menu déroulant de bulles.
 *
 * Couleurs reprises de tailwind.config.js : primary #121212, gray-light #cfcfcf.
 * Les sélecteurs sont volontairement plus spécifiques que ceux injectés par GTranslate,
 * dont la feuille est ajoutée par JavaScript, donc après celle-ci.
 */

.gb-langs {
    position: relative;
    display: inline-flex;
    line-height: 1;
}

/* ---- Bulle principale : langue courante ---- */

.gb-langs__toggle {
    position: relative;
    display: block;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.gb-langs__bubble {
    display: block;
    width: 40px;
    height: 40px;
    overflow: hidden;
    border: 1px solid #cfcfcf;
    border-radius: 9999px;
    background-color: #fff;
    box-shadow: 0 1px 3px rgb(0 0 0 / 12%);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.gb-langs__bubble img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gb-langs__toggle:hover .gb-langs__bubble,
.gb-langs__toggle:focus-visible .gb-langs__bubble {
    border-color: #121212;
    box-shadow: 0 3px 8px rgb(0 0 0 / 20%);
    transform: translateY(-1px);
}

/* Petit chevron d'affordance, en pastille sur le bord de la bulle. */
.gb-langs__caret {
    position: absolute;
    right: -2px;
    bottom: -2px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border: 1px solid #cfcfcf;
    border-radius: 9999px;
    background-color: #fff;
    transition: transform 0.2s ease, border-color 0.15s ease;
}

.gb-langs__caret::before {
    content: "";
    width: 5px;
    height: 5px;
    margin-top: -2px;
    border-right: 1.5px solid #121212;
    border-bottom: 1.5px solid #121212;
    transform: rotate(45deg);
}

.gb-langs.is-open .gb-langs__caret {
    border-color: #121212;
    transform: rotate(180deg);
}

/* ---- Menu : les autres langues, en bulles empilées ---- */

.gb-langs__menu {
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    border: 1px solid #e6e6e6;
    border-radius: 9999px;
    background-color: #fff;
    box-shadow: 0 8px 24px rgb(0 0 0 / 14%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(-50%) translateY(-6px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
}

.gb-langs.is-open .gb-langs__menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.gb-langs__item {
    display: block;
}

.gb-langs__menu a,
.gb-langs__menu a.glink {
    display: block;
    width: 34px;
    height: 34px;
    overflow: hidden;
    border: 1px solid #cfcfcf;
    border-radius: 9999px;
    text-decoration: none;
    transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.gb-langs__menu a img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gb-langs__menu a:hover,
.gb-langs__menu a.glink:hover,
.gb-langs__menu a:focus-visible {
    border-color: #121212;
    box-shadow: 0 2px 6px rgb(0 0 0 / 18%);
    transform: scale(1.08);
}

/* La langue courante est déjà affichée dans la bulle principale : on la retire du menu.
   La classe est posée côté serveur puis déplacée par le JS de GTranslate. */
.gb-langs__menu .gb-langs__item:has(a.gt-current-lang) {
    display: none;
}

/* Repli pour les navigateurs sans :has() — la bulle est alors simplement estompée. */
@supports not selector(:has(*)) {
    .gb-langs__menu a.gt-current-lang {
        opacity: 0.35;
        pointer-events: none;
    }
}

/* ---- Mobile : le sélecteur est dans le menu déroulant du header ---- */

@media (max-width: 767px) {
    .gb-langs {
        margin-top: 0.5rem;
    }

    .gb-langs__bubble {
        width: 44px;
        height: 44px;
    }

    .gb-langs__menu a,
    .gb-langs__menu a.glink {
        width: 38px;
        height: 38px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .gb-langs__bubble,
    .gb-langs__caret,
    .gb-langs__menu,
    .gb-langs__menu a {
        transition: none;
    }
}
