/*
 * Language switcher – used in the header of every page.
 * Colours come from the shared tokens in css/index.css (with fallbacks).
 * Breakpoint matches index.css: below 1024px the header becomes a dark drawer.
 */

.lang-switcher {
    position: relative;
    font-size: 1rem;
}

.lang-switcher__btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid #000;
    border-radius: 5px;
    background: transparent;
    color: #000;
    font: inherit;
    line-height: 1.2;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s;
}

.lang-switcher__btn:hover,
.lang-switcher.is-open .lang-switcher__btn {
    background: #000;
    color: #fff;
}

.lang-switcher__btn:focus-visible,
.lang-switcher__item:focus-visible {
    outline: 3px solid #000;
    outline-offset: 2px;
}

.lang-switcher__chev {
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.lang-switcher.is-open .lang-switcher__chev {
    transform: rotate(180deg);
}

.lang-switcher__menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 60;
    min-width: 11rem;
    margin: 0;
    padding: 0.35rem;
    list-style: none;
    background: #fff;
    border: 1px solid #000;
    border-radius: 5px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.lang-switcher__menu[hidden] {
    display: none;
}

.lang-switcher__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 0;
    border-radius: 5px;
    background: none;
    color: #000;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.lang-switcher__item:hover {
    background: var(--accent-soft, #eceffa);
}

.lang-switcher__item[aria-current="true"] {
    font-weight: 700;
    background: var(--accent-soft, #eceffa);
}

.lang-switcher__item[aria-current="true"]::after {
    content: "\2713";
    margin-left: 0.75rem;
}

/*
 * Drawer (below 1024px): instead of a dropdown the languages are shown as
 * always-visible pills, styled for the dark drawer background.
 */
@media not all and (min-width: 1024px) {
    .lang-switcher {
        max-width: 100%;
    }

    .lang-switcher__btn {
        display: none;
    }

    .lang-switcher__menu,
    .lang-switcher__menu[hidden] {
        position: static;
        display: flex !important;
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 0.4rem;
        min-width: 0;
        padding: 0;
        border: 0;
        box-shadow: none;
        background: transparent;
    }

    .lang-switcher__item {
        width: auto;
        padding: 0.4rem 0.8rem;
        border: 1px solid #fff;
        border-radius: 999px;
        color: #fff;
    }

    .lang-switcher__item:hover {
        background: rgba(255, 255, 255, 0.15);
    }

    .lang-switcher__item:focus-visible {
        outline-color: #fff;
    }

    .lang-switcher__item[aria-current="true"] {
        border-color: var(--accent-color, #8897d8);
        background: var(--accent-color, #8897d8);
        color: #000;
    }

    .lang-switcher__item[aria-current="true"]::after {
        content: none;
    }
}

/*
 * Desktop: index.css gives the header's collapsible area "overflow: hidden",
 * which cut off the dropdown (only its top border was visible). Let it show.
 */
@media (min-width: 1024px) {
    header > .collapsible-header {
        overflow: visible;
    }
}
