/* Language picker + i18n visibility helpers. Shared by every page. */

/*
 * Non-English pages are hidden until js/i18n.js applies the dictionary, so
 * visitors never see a flash of English first. i18n.js clears this class, and
 * has a 2.5s failsafe in case a locale file fails to load.
 */
.i18n-pending body { visibility: hidden; }

/*
 * Language-conditional blocks (e.g. the "English version governs" legal
 * notice). Resolved purely from <html lang>, which i18n.js sets before first
 * paint, so these never flash in or out.
 */
[data-i18n-if-lang] { display: none; }
html[lang="en"] [data-i18n-if-lang~="en"],
html[lang="es"] [data-i18n-if-lang~="es"],
html[lang="fr"] [data-i18n-if-lang~="fr"],
html[lang="pt"] [data-i18n-if-lang~="pt"] { display: block; }

.lang-picker {
    position: relative;
    flex: none;
}

.lang-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    height: 2rem;
    padding: 0 0.625rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.05);
    color: #d4d4d4;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.lang-trigger:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.lang-trigger:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.4);
    outline-offset: 2px;
}

.lang-globe {
    width: 0.875rem;
    height: 0.875rem;
    flex: none;
}

.lang-chevron {
    width: 0.75rem;
    height: 0.75rem;
    flex: none;
    opacity: 0.6;
    transition: transform 0.2s ease;
}

.lang-picker.is-open .lang-chevron { transform: rotate(180deg); }

.lang-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 11.5rem;
    margin: 0;
    padding: 0.25rem;
    list-style: none;
    background: #0f0f0f;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.625rem;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-0.25rem);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
    z-index: 60;
}

.lang-picker.is-open .lang-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-menu li { margin: 0; }

.lang-menu button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    padding: 0.5rem 0.625rem;
    border: 0;
    border-radius: 0.375rem;
    background: transparent;
    color: #a3a3a3;
    font-family: inherit;
    font-size: 0.8125rem;
    line-height: 1.2;
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.lang-menu button:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
}

.lang-menu button:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.4);
    outline-offset: -2px;
}

.lang-menu button.is-active { color: #ffffff; }

/* Dot marking the active language. */
.lang-menu button.is-active::after {
    content: "";
    flex: none;
    width: 0.375rem;
    height: 0.375rem;
    border-radius: 9999px;
    background: #34d399;
}
