/*--------------------------------------------------------------
   MDK Falang Language Switcher
   Pastille unique, drapeau centré, contour fin, ouverture vers le bas,
   compatible en-tête collant
---------------------------------------------------------------*/

/* Mesures (pixels entiers) :
   drapeau 26 px + 3 px de blanc + 1 px de contour de chaque côté = pastille de 34 px.
   Le drapeau est centré par construction (flex), avec le même blanc tout autour.
   Chaque langue de la liste occupe 34 px (4 + 26 + 4). */

/* Bloc global = zone fixe dans le flux (la navbar ne bouge pas à l'ouverture) */
.mod-jt-languageswitcher.jt-falang-switcher-custom {
    position: relative;
    display: inline-block;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    width: 34px;
    height: 34px;
    z-index: 1100; /* au-dessus du contenu, y compris avec un en-tête collant */
}

/* Pastille visible : contour fin, sans ombre au repos */
.mod-jt-languageswitcher.jt-falang-switcher-custom [id^="select-container-"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: block;
    padding: 3px;
    background: #ffffff;
    border-radius: 17px;
    border: 1px solid #e1e5ea;
    box-shadow: none;
    box-sizing: border-box;
    transition: box-shadow 0.2s ease, border-color 0.2s ease, padding 0.2s ease;
}

/* Ouverture au survol (ou au clavier) : contour plus marqué, ombre légère */
.mod-jt-languageswitcher.jt-falang-switcher-custom [id^="select-container-"]:hover {
    border-color: #8a9096;
    box-shadow: 0 6px 16px rgba(23, 25, 27, 0.12);
}
.mod-jt-languageswitcher.jt-falang-switcher-custom [id^="select-container-"]:has(:focus-visible) {
    border-color: #8a9096;
    box-shadow: 0 6px 16px rgba(23, 25, 27, 0.12);
}

/* Hauteur ouverte = 34 px par langue en plus + 3 px, pour garder le même blanc en bas qu'en haut */
.mod-jt-languageswitcher.jt-falang-switcher-custom [id^="select-container-"][data-lang-count="1"]:hover {
    padding-bottom: 37px;
}
.mod-jt-languageswitcher.jt-falang-switcher-custom [id^="select-container-"][data-lang-count="1"]:has(:focus-visible) {
    padding-bottom: 37px;
}
.mod-jt-languageswitcher.jt-falang-switcher-custom [id^="select-container-"][data-lang-count="2"]:hover {
    padding-bottom: 71px;
}
.mod-jt-languageswitcher.jt-falang-switcher-custom [id^="select-container-"][data-lang-count="2"]:has(:focus-visible) {
    padding-bottom: 71px;
}
.mod-jt-languageswitcher.jt-falang-switcher-custom [id^="select-container-"][data-lang-count="3"]:hover {
    padding-bottom: 105px;
}
.mod-jt-languageswitcher.jt-falang-switcher-custom [id^="select-container-"][data-lang-count="3"]:has(:focus-visible) {
    padding-bottom: 105px;
}
.mod-jt-languageswitcher.jt-falang-switcher-custom [id^="select-container-"][data-lang-count="4"]:hover {
    padding-bottom: 139px;
}
.mod-jt-languageswitcher.jt-falang-switcher-custom [id^="select-container-"][data-lang-count="4"]:has(:focus-visible) {
    padding-bottom: 139px;
}
.mod-jt-languageswitcher.jt-falang-switcher-custom [id^="select-container-"][data-lang-count="5"]:hover {
    padding-bottom: 173px;
}
.mod-jt-languageswitcher.jt-falang-switcher-custom [id^="select-container-"][data-lang-count="5"]:has(:focus-visible) {
    padding-bottom: 173px;
}

/* Wrapper interne : bouton + liste, centrés */
.mod-jt-languageswitcher.jt-falang-switcher-custom .mod-jt-languageswitcher__select {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

/* --------- Bouton langue active --------- */

.mod-jt-languageswitcher.jt-falang-switcher-custom button.active-lang {
    border: 0;
    background: transparent;
    box-shadow: none;
    padding: 0;
    margin: 0;
    min-width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* Conteneur d'image générique */
.mod-jt-languageswitcher.jt-falang-switcher-custom .img-cover {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    background: none;
}

/* Drapeaux : ronds, sans ombre, rien ne bouge au survol */
.mod-jt-languageswitcher.jt-falang-switcher-custom .img-cover img {
    width: 26px;
    height: 26px;
    max-width: none;
    margin: 0;
    border-radius: 50%;
    box-shadow: none;
    object-fit: cover;
    display: block;
    transition: box-shadow 0.15s ease;
}

/* Code langue optionnel (si show_codes = true) */
.mod-jt-languageswitcher.jt-falang-switcher-custom button.active-lang .langname-code {
    margin-left: 6px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #465663;
}

/* --------- Liste des autres langues --------- */

.mod-jt-languageswitcher.jt-falang-switcher-custom .mod-jt-languageswitcher__select > ul {
    position: absolute;
    top: 100%;              /* juste sous le drapeau actif */
    left: 0;
    right: 0;
    margin: 0;
    padding: 4px 0;
    list-style: none;
    background: none;       /* la pastille porte le fond */
    box-sizing: border-box;
    z-index: 9999;

    max-height: 0;
    opacity: 0;
    overflow: visible;
    transition: max-height 0.2s ease-out, opacity 0.2s ease-out;
    pointer-events: none;   /* pas cliquable quand fermée */
}

.mod-jt-languageswitcher.jt-falang-switcher-custom [id^="select-container-"]:hover .mod-jt-languageswitcher__select > ul,
.mod-jt-languageswitcher.jt-falang-switcher-custom .mod-jt-languageswitcher__select > ul:hover {
    max-height: 200px;
    opacity: 1;
    pointer-events: auto;
}
.mod-jt-languageswitcher.jt-falang-switcher-custom [id^="select-container-"]:has(:focus-visible) .mod-jt-languageswitcher__select > ul {
    max-height: 200px;
    opacity: 1;
    pointer-events: auto;
}

.mod-jt-languageswitcher.jt-falang-switcher-custom .mod-jt-languageswitcher__select > ul li {
    display: flex;
    justify-content: center;
    margin: 0;
    padding: 4px 0;
    font-size: 14px;
    line-height: 26px;
    background: none;
}

.mod-jt-languageswitcher.jt-falang-switcher-custom .mod-jt-languageswitcher__select > ul li a {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
}

.mod-jt-languageswitcher.jt-falang-switcher-custom .mod-jt-languageswitcher__select > ul li .img-cover {
    flex: 0 0 auto; /* le drapeau ne se fait pas écraser */
}

/* Survol ou clavier sur une langue : anneau fin autour du drapeau, sans fond ni déplacement */
.mod-jt-languageswitcher.jt-falang-switcher-custom .mod-jt-languageswitcher__select > ul li a:hover .img-cover img,
.mod-jt-languageswitcher.jt-falang-switcher-custom .mod-jt-languageswitcher__select > ul li a:focus-visible .img-cover img {
    box-shadow: 0 0 0 1px #ffffff, 0 0 0 2px #5b6470;
}
.mod-jt-languageswitcher.jt-falang-switcher-custom .mod-jt-languageswitcher__select > ul li a:focus-visible {
    outline: none;
}

.mod-jt-languageswitcher.jt-falang-switcher-custom .mod-jt-languageswitcher__select > ul li .langname-code {
    margin-left: 6px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #465663;
}

/* --------- Tooltip (facultatif, mais propre) --------- */

[tooltip] {
    position: relative;
}

/* Base tooltip */
[tooltip]::before,
[tooltip]::after {
    position: absolute;
    display: none;
    opacity: 0;
    pointer-events: none;
    user-select: none;
    z-index: 100000;
    font-size: 12px;
    line-height: 1.2;
}

/* Triangle */
[tooltip]::before {
    content: "";
    border: 5px solid transparent;
}

/* Etiquette */
[tooltip]::after {
    content: attr(tooltip);
    background: #465663;
    color: #fff;
    font-family: Helvetica, Arial, sans-serif;
    border-radius: 4px;
    padding: 4px 6px;
    box-shadow: 0 0.8em 2em -0.6em rgba(0,0,0,0.4);
    white-space: nowrap;
}

/* Tooltip vers le bas */
[tooltip][flow^="down"]::before {
    top: 100%;
    left: 50%;
    border-top-width: 0;
    border-bottom-color: #465663;
    transform: translate(-50%, 0);
}

[tooltip][flow^="down"]::after {
    top: calc(100% + 6px);
    left: 50%;
    transform: translate(-50%, 0);
}

/* Tooltip vers le haut (si tu en as encore) */
[tooltip][flow^="up"]::before {
    bottom: 100%;
    left: 50%;
    border-bottom-width: 0;
    border-top-color: #465663;
    transform: translate(-50%, 0);
}

[tooltip][flow^="up"]::after {
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translate(-50%, 0);
}

/* Affichage au survol */
[tooltip]:hover::before,
[tooltip]:hover::after {
    display: block;
    animation: jt-tooltip-fade 180ms ease-out forwards;
}

/* Animation tooltip */
@keyframes jt-tooltip-fade {
    from {
        opacity: 0;
        transform: translate(-50%, 4px);
    }
    to {
        opacity: 0.9;
        transform: translate(-50%, 0);
    }
}

/* Désactiver tous les tooltips sur mobile */
@media (max-width: 640px) {
    [tooltip]::before,
    [tooltip]::after {
        display: none !important;
    }
}
