/* Prevent FOUC when language is not the source */
html.arcadia-translating body {
    opacity: 0;
    pointer-events: none;
}

html.arcadia-ready body {
    opacity: 1;
    transition: opacity 0.2s ease;
}

/* Arcadia Language Switcher (uses flag-icons CSS for real SVG flags) */
.lang-switcher {
    position: relative;
    margin-right: 0.75rem;
    display: flex;
    align-items: center;
}

.lang-switcher-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(217, 119, 6, 0.25);
    color: #e5e7eb;
    padding: 0.35rem 0.7rem;
    border-radius: var(--arc-r) 0;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
    font-family: inherit; corner-shape: bevel;
}

.lang-switcher-btn:hover,
.lang-switcher-btn:focus {
    background: rgba(217, 119, 6, 0.15);
    border-color: rgba(217, 119, 6, 0.6);
    color: #f5f5f5;
    outline: none;
}

.lang-switcher-btn.is-busy {
    position: relative;
}

.lang-switcher-btn.is-busy::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: var(--arc-r) 0;
    border: 1.5px solid transparent;
    border-top-color: rgba(251, 191, 36, 0.9);
    border-right-color: rgba(251, 191, 36, 0.4);
    animation: arcadia-lang-spin 0.7s linear infinite;
    pointer-events: none; corner-shape: bevel;
}

@keyframes arcadia-lang-spin {
    to { transform: rotate(360deg); }
}

.lang-switcher .fi {
    border-radius: var(--arc-r-sm) 0;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
    line-height: 1em; corner-shape: bevel;
}

.lang-switcher-btn .fi {
    width: 1.2em;
    height: 0.9em;
    font-size: 1em;
}

.lang-switcher-btn .lang-caret {
    font-size: 0.55rem;
    opacity: 0.7;
    transition: transform 0.2s ease;
}

.lang-switcher.open .lang-switcher-btn .lang-caret {
    transform: rotate(180deg);
}

.lang-switcher-menu {
    position: absolute;
    top: calc(100% + 0.45rem);
    right: 0;
    min-width: 170px;
    max-height: 360px;
    overflow-y: auto;
    background: rgba(20, 15, 10, 0.98);
    border: 1px solid rgba(217, 119, 6, 0.3);
    border-radius: var(--arc-r) 0;
    padding: 0.35rem;
    list-style: none;
    margin: 0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.16s cubic-bezier(0.23, 1, 0.32, 1),
                transform 0.16s cubic-bezier(0.23, 1, 0.32, 1),
                visibility 0s linear 0.16s;
    z-index: 1050;
    backdrop-filter: blur(10px);
    scrollbar-width: thin;
    scrollbar-color: rgba(217, 119, 6, 0.5) transparent; corner-shape: bevel;
}

.lang-switcher-menu::-webkit-scrollbar {
    width: 6px;
}
.lang-switcher-menu::-webkit-scrollbar-thumb {
    background: rgba(217, 119, 6, 0.5);
    border-radius: var(--arc-r-sm) 0; corner-shape: bevel;
}

.lang-switcher.open .lang-switcher-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    /* À l'ouverture, le menu doit être visible IMMÉDIATEMENT (le délai de
       visibility ne vaut que pour la fermeture, pour masquer après le fondu). */
    transition: opacity 0.16s cubic-bezier(0.23, 1, 0.32, 1),
                transform 0.16s cubic-bezier(0.23, 1, 0.32, 1),
                visibility 0s;
}

.lang-switcher-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.5rem 0.7rem;
    border-radius: var(--arc-r-sm) 0;
    color: #e5e7eb;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.15s ease;
    user-select: none; corner-shape: bevel;
}

.lang-switcher-item:hover {
    background: rgba(217, 119, 6, 0.18);
    color: #fff;
}

.lang-switcher-item.active {
    background: rgba(217, 119, 6, 0.25);
    color: #fbbf24;
}

.lang-switcher-item .fi {
    width: 1.6em;
    height: 1.2em;
    font-size: 1em;
    flex-shrink: 0;
}

@media (max-width: 991px) {
    /* In the collapsed burger nav, every nav-item is centered full-width.
       The lang switcher sits inside its own .nav-item but is NOT a .nav-link,
       so the existing centering rules from Arcadia.css don't apply to it.
       Force-center it here so the FR pill aligns with the rest of the menu. */
    .navbar-nav .nav-item:has(.lang-switcher) {
        justify-content: center;
        width: 100%;
        display: flex;
    }
    .lang-switcher {
        margin: 0.5rem auto;
        justify-content: center;
        width: auto;
    }
    /* Center the dropdown menu under the pill instead of left-aligning it
       (which clips off-screen on narrow viewports). */
    .lang-switcher-menu {
        right: auto;
        left: 50%;
        transform: translate(-50%, -6px);
        min-width: min(170px, calc(100vw - 3rem));
    }
    .lang-switcher.open .lang-switcher-menu {
        transform: translate(-50%, 0);
    }
}

@media (max-width: 400px) {
    .arcadia-lang-picker-card {
        padding: 1.5rem 1rem;
    }
    .arcadia-lang-picker-title {
        font-size: 1.15rem;
    }
}

/* First-visit language picker */
.arcadia-lang-picker {
    position: fixed;
    inset: 0;
    background: rgba(8, 6, 4, 0.85);
    backdrop-filter: blur(10px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.arcadia-lang-picker.is-visible {
    opacity: 1;
    visibility: visible;
}

.arcadia-lang-picker-card {
    background: linear-gradient(160deg, rgba(30, 22, 14, 0.98), rgba(15, 10, 5, 0.98));
    border: 1px solid rgba(217, 119, 6, 0.4);
    border-radius: var(--arc-r-lg) 0;
    padding: 2.25rem 2rem;
    max-width: 620px;
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6), 0 0 60px rgba(217, 119, 6, 0.15) inset;
    text-align: center;
    transform: scale(0.96) translateY(8px);
    transition: transform 0.3s ease; corner-shape: bevel;
}

.arcadia-lang-picker.is-visible .arcadia-lang-picker-card {
    transform: scale(1) translateY(0);
}

.arcadia-lang-picker-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(217, 119, 6, 0.15);
    border: 1px solid rgba(217, 119, 6, 0.4);
    color: #fbbf24;
    font-size: 1.6rem;
}

.arcadia-lang-picker-title {
    color: #fbbf24;
    font-size: 1.45rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
    letter-spacing: 0.5px;
}

.arcadia-lang-picker-subtitle {
    color: rgba(229, 231, 235, 0.7);
    font-size: 0.9rem;
    margin: 0 0 1.5rem;
}

.arcadia-lang-picker-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.65rem;
}

@media (max-width: 600px) {
    .arcadia-lang-picker-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.arcadia-lang-picker-option {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(217, 119, 6, 0.25);
    color: #e5e7eb;
    border-radius: var(--arc-r) 0;
    padding: 0.85rem 0.7rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
    font-family: inherit; corner-shape: bevel;
}

.arcadia-lang-picker-option:hover,
.arcadia-lang-picker-option:focus {
    background: rgba(217, 119, 6, 0.18);
    border-color: rgba(251, 191, 36, 0.7);
    color: #fff;
    transform: translateY(-2px);
    outline: none;
}

.arcadia-lang-picker-option .fi {
    width: 2.2em;
    height: 1.6em;
    border-radius: var(--arc-r-sm) 0;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1); corner-shape: bevel;
}

.arcadia-lang-picker-name {
    font-size: 0.95rem;
    font-weight: 600;
}

.arcadia-lang-picker-code {
    font-size: 0.65rem;
    letter-spacing: 1.5px;
    color: rgba(251, 191, 36, 0.75);
    text-transform: uppercase;
    font-weight: 700;
}

@media (max-width: 380px) {
    .arcadia-lang-picker-grid {
        grid-template-columns: 1fr;
    }
    .arcadia-lang-picker-card {
        padding: 1.75rem 1.25rem;
    }
}
