/* ============================================================
   PlugIn Traduction — Sélecteur de langue (frontend)
   ============================================================ */

/* ── Conteneur principal ──────────────────────────────────── */
.tp-switcher {
    position: relative;
    display: inline-block;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    z-index: 9990;
}

/* ── Bouton déclencheur ───────────────────────────────────── */
.tp-switcher__toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(0, 0, 0, 0.14);
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    color: #222;
    line-height: 1.4;
    transition: background 0.15s, box-shadow 0.15s, border-color 0.15s;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.10);
    white-space: nowrap;
}

.tp-switcher__toggle:hover,
.tp-switcher__toggle:focus-visible {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.22);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
    outline: none;
}

/* Flèche */
.tp-arrow {
    display: flex;
    align-items: center;
    transition: transform 0.2s ease;
    color: #666;
}

.tp-switcher.tp-open .tp-arrow {
    transform: rotate(180deg);
}

/* ── Liste déroulante ────────────────────────────────────── */
.tp-switcher__list {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    min-width: 170px;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14), 0 2px 6px rgba(0, 0, 0, 0.08);
    animation: tp-fade-in 0.15s ease;
    z-index: 9999;
}

.tp-switcher.tp-open .tp-switcher__list {
    display: block;
}

@keyframes tp-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Éléments de la liste ────────────────────────────────── */
.tp-switcher__item a {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: 7px;
    text-decoration: none;
    color: #333;
    font-size: 14px;
    transition: background 0.12s;
    line-height: 1.3;
}

.tp-switcher__item a:hover,
.tp-switcher__item a:focus-visible {
    background: #f4f4f4;
    outline: none;
}

.tp-switcher__item--active a {
    background: #f0f0f0;
    font-weight: 600;
    color: #111;
}

/* Drapeau */
.tp-flag {
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0;
}

/* Coche de langue active */
.tp-check {
    margin-left: auto;
    display: flex;
    align-items: center;
    color: #1d72b8;
}

/* ── Style compact (codes courts) ────────────────────────── */
.tp-style-compact .tp-lang-native {
    display: none;
}
.tp-style-compact .tp-switcher__toggle {
    padding: 6px 10px;
}

/* ── Style texte uniquement ─────────────────────────────── */
.tp-style-text-only .tp-flag {
    display: none;
}

/* ── Bouton flottant ─────────────────────────────────────── */
.tp-floating {
    position: fixed;
    z-index: 99999;
}
.tp-floating--bottom-right { bottom: 20px; right: 20px; }
.tp-floating--bottom-left  { bottom: 20px; left:  20px; }
.tp-floating--top-right    { top:    20px; right: 20px; }
.tp-floating--top-left     { top:    20px; left:  20px; }

/* Liste vers le haut pour le positionnement en bas de page */
.tp-floating--bottom-right .tp-switcher__list,
.tp-floating--bottom-left  .tp-switcher__list {
    bottom: calc(100% + 8px);
    top: auto;
}

/* Liste vers le bas pour le positionnement en haut de page */
.tp-floating--top-right .tp-switcher__list,
.tp-floating--top-left  .tp-switcher__list {
    top: calc(100% + 8px);
    bottom: auto;
}

.tp-floating--bottom-right .tp-switcher__list,
.tp-floating--top-right    .tp-switcher__list { left: auto; right: 0; }

.tp-floating--bottom-left .tp-switcher__list,
.tp-floating--top-left    .tp-switcher__list { left: 0; right: auto; }

/* ── Accessibilité ───────────────────────────────────────── */
.tp-switcher *:focus-visible {
    outline: 2px solid #1d72b8;
    outline-offset: 2px;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 600px) {
    .tp-floating { bottom: 12px; right: 12px; }
    .tp-floating--bottom-left  { left:  12px; right: auto; }
    .tp-floating--top-right    { top:   12px; bottom: auto; }
    .tp-floating--top-left     { top:   12px; left: 12px; bottom: auto; right: auto; }

    .tp-switcher__list {
        min-width: 150px;
    }
}

/* ============================================================
   Intégration dans le menu de navigation WordPress
   ============================================================ */

/* L'item <li> est poussé à droite si le menu est en flexbox
   (comportement standard des thèmes modernes). */
.tp-menu-item {
    margin-left: auto !important;
    display: flex !important;
    align-items: center;
    list-style: none;
}

/* Le .tp-switcher à l'intérieur du menu hérite du style
   du thème pour le fond et la couleur. */
.tp-style-menu {
    position: relative;
    display: inline-flex;
    align-items: center;
}

/* Bouton toggle menu : fond transparent, hérite la couleur du thème */
.tp-style-menu .tp-switcher__toggle {
    background: transparent;
    border: 1px solid transparent;
    box-shadow: none;
    padding: 5px 8px;
    gap: 4px;
    color: currentColor;
    border-radius: 6px;
}

.tp-style-menu .tp-switcher__toggle:hover,
.tp-style-menu .tp-switcher__toggle:focus-visible {
    background: rgba(128, 128, 128, 0.12);
    border-color: transparent;
    box-shadow: none;
}

/* Code de langue court (ex: "FR", "EN") affiché dans le menu */
.tp-menu__lang-code {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    line-height: 1;
}

/* Drapeau légèrement plus grand dans le menu */
.tp-style-menu .tp-flag {
    font-size: 22px;
}

/* Le dropdown s'ouvre VERS LE BAS dans le menu (pas vers le haut) */
.tp-style-menu .tp-switcher__list,
.tp-menu__list {
    top: calc(100% + 6px) !important;
    bottom: auto !important;
    right: 0;
    left: auto;
    margin-top: 0;
    margin-bottom: 0;
    min-width: 160px;
    /* Ombre plus marquée pour se détacher du menu */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.10);
}

/* Séparateur visuel pour le premier élément (langue active) */
.tp-style-menu .tp-switcher__item--active a {
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 4px;
    padding-bottom: 10px;
}

/* Sur mobile : le menu est souvent en colonne,
   le sélecteur doit s'adapter */
@media (max-width: 768px) {
    .tp-menu-item {
        margin-left: 0 !important;
        width: 100%;
        justify-content: flex-start;
        padding: 0;
    }

    .tp-style-menu .tp-switcher__toggle {
        width: 100%;
        justify-content: flex-start;
        padding: 10px 14px;
    }

    .tp-style-menu .tp-switcher__list,
    .tp-menu__list {
        position: static !important;
        box-shadow: none;
        border: none;
        border-radius: 0;
        padding: 0 0 0 24px;
        background: transparent;
        animation: none;
    }

    .tp-style-menu .tp-switcher__item a:hover {
        background: rgba(0, 0, 0, 0.05);
    }
}

/* ============================================================
   Thème Through History — Barre de navigation sombre
   Tokens : --stone-lt #BFB09A · --gold #C8973A · --gold-dk #8B6520
   Vient en dernier pour surcharger les règles génériques ci-dessus.
   ============================================================ */

/* Bouton toggle : couleur pierre claire, typographie Cinzel.
   --stone-lt     → token du thème Through History (prioritaire).
   --tp-sync-color → calculé par syncMenuColor() sur les autres thèmes. */
.tp-menu-item .tp-style-menu .tp-switcher__toggle {
    color: var(--stone-lt, var(--tp-sync-color, #BFB09A));
    font-family: 'Cinzel', serif;
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.tp-menu-item .tp-style-menu .tp-arrow {
    color: inherit;
    opacity: 0.7;
}

/* Hover / focus : couleur or */
.tp-menu-item .tp-style-menu .tp-switcher__toggle:hover,
.tp-menu-item .tp-style-menu .tp-switcher__toggle:focus-visible {
    color: var(--gold, #C8973A);
    background: rgba(200, 151, 58, 0.08);
}
.tp-menu-item .tp-style-menu .tp-switcher__toggle:hover .tp-arrow,
.tp-menu-item .tp-style-menu .tp-switcher__toggle:focus-visible .tp-arrow {
    color: var(--gold, #C8973A);
    opacity: 1;
}

/* Dropdown : fond sombre, liseré or en haut */
.tp-menu-item .tp-style-menu .tp-switcher__list {
    background: rgba(18, 14, 10, 0.98);
    border: 1px solid rgba(200, 151, 58, 0.2);
    border-top: 2px solid var(--gold, #C8973A);
    border-radius: 0 0 4px 4px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
}

/* Liens dans la liste */
.tp-menu-item .tp-style-menu .tp-switcher__item a {
    color: var(--stone-lt, #BFB09A);
    font-family: 'Cinzel', serif;
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    border-radius: 0;
    border-left: 2px solid transparent;
}
.tp-menu-item .tp-style-menu .tp-switcher__item a:hover,
.tp-menu-item .tp-style-menu .tp-switcher__item a:focus-visible {
    color: var(--gold, #C8973A);
    background: rgba(200, 151, 58, 0.07);
    border-left-color: var(--gold, #C8973A);
}

/* Langue active */
.tp-menu-item .tp-style-menu .tp-switcher__item--active a {
    color: var(--stone-lt, #BFB09A);
    background: rgba(200, 151, 58, 0.04);
    border-bottom: 1px solid rgba(139, 115, 85, 0.15);
    font-weight: 600;
}

/* Coche : or */
.tp-menu-item .tp-style-menu .tp-check {
    color: var(--gold, #C8973A);
}

/* ── Mobile : accordéon vertical (miroir du thème) ─────────── */
@media (max-width: 768px) {
    .tp-menu-item .tp-style-menu .tp-switcher__toggle {
        padding: 0.7rem 0;
    }

    /* Fond légèrement assombri + bordure gauche or foncé,
       comme les sous-menus natifs du thème */
    .tp-menu-item .tp-style-menu .tp-switcher__list {
        background: rgba(0, 0, 0, 0.25) !important;
        border: none !important;
        border-left: 2px solid var(--gold-dk, #8B6520) !important;
        border-top: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
        padding: 0.25rem 0 0.5rem 0.75rem !important;
        margin: 0.25rem 0 0.25rem 0.75rem !important;
    }

    .tp-menu-item .tp-style-menu .tp-switcher__item a {
        padding: 0.5rem 0.75rem;
        font-size: 0.7rem;
        opacity: 0.85;
        border-left: none;
    }
    .tp-menu-item .tp-style-menu .tp-switcher__item a:hover {
        border-left: none;
        padding-left: 0.75rem;
    }
}
