/* ========================================
Locale / regional language panel
======================================== */

.locale-switcher {
    position: relative;
}

.locale-switcher__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0.25rem;
    color: var(--site-header-ink, var(--color-text));
    background-color: transparent;
    border: 0;
    cursor: pointer;
    transition: color var(--transition-base);
}

.locale-switcher__toggle:hover,
.locale-switcher.is-open .locale-switcher__toggle {
    color: var(--color-brand-red);
}

.locale-switcher__toggle:focus-visible {
    outline: 2px solid var(--color-brand-red);
    outline-offset: 3px;
}

.locale-switcher__icon {
    width: 1.75rem;
    height: 1.75rem;
}

.locale-nav-entry {
    display: none;
}

.locale-panel {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 2;
    width: 100%;
    display: grid;
    grid-template-rows: 0fr;
    pointer-events: none;
    transition: grid-template-rows var(--transition-base);
}

.site-header.is-locale-open .locale-panel {
    grid-template-rows: 1fr;
    pointer-events: auto;
}

.locale-panel__clip {
    min-height: 0;
    overflow: hidden;
    background-color: var(--color-background);
}

.locale-panel__inner {
    display: flex;
    flex-direction: column;
    height: var(--mega-menu-panel-height);
    max-height: var(--mega-menu-panel-height);
    overflow: hidden;
    padding: 1.25rem var(--layout-gutter-x) 1.5rem;
    background-color: var(--color-background);
}

.locale-panel__toolbar--mobile {
    display: none;
}

.locale-panel__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* Desktop column counts until mobile menu (< 1024px) */
.locale-panel__list {
    margin: 0;
    padding: 0;
    list-style: none;
    column-count: 3;
    column-gap: 2.5rem;
}

@media (min-width: 1280px) {
    .locale-panel__list {
        column-count: 4;
    }
}

@media (min-width: 1400px) {
    .locale-panel__list {
        column-count: 5;
    }
}

.locale-location {
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    page-break-inside: avoid;
    border-bottom: 1px solid var(--color-border);
}

.locale-location__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: 2.75rem;
    padding: 0.55rem 0.65rem;
    border-left: 3px solid transparent;
}

.locale-location.is-active .locale-location__row {
    background-color: var(--color-surface);
    border-left-color: var(--color-brand-red);
}

.locale-location__name {
    flex-shrink: 0;
    font-size: var(--font-size-sm);
    font-weight: 600;
    line-height: 1.3;
    color: var(--color-text);
}

.locale-location__langs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
    min-width: 0;
}

.locale-location__sep {
    font-size: var(--font-size-sm);
    line-height: 1;
    color: var(--color-text-muted);
}

/* Language controls: links (or legacy buttons) inside a location row */
.locale-location__langs .locale-location__lang,
.locale-location__langs button {
    margin: 0;
    padding: 0;
    font-size: var(--font-size-sm);
    font-weight: 400;
    line-height: 1.3;
    color: var(--color-text);
    text-align: right;
    text-decoration: none;
    background: transparent;
    border: 0;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.locale-location__langs .locale-location__lang:hover,
.locale-location__langs button:hover {
    color: var(--color-brand-red);
}

.locale-location__langs .locale-location__lang.is-active,
.locale-location__langs button.is-active {
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

.locale-location__langs .locale-location__lang:focus-visible,
.locale-location__langs button:focus-visible {
    outline: 2px solid var(--color-brand-red);
    outline-offset: 2px;
}

.site-header.is-locale-open .site-header__page-blur {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

body.is-locale-open {
    overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
    .locale-panel {
        transition: none;
    }
}

/* Mobile: fullscreen panel */
@media (max-width: 1023.98px) {
    .locale-switcher {
        display: none;
    }

    .locale-nav-entry {
        display: block;
        padding: 1.5rem var(--layout-gutter-x) 2rem;
    }

    .locale-nav-entry__button {
        display: inline-flex;
        align-items: center;
        gap: 0.45rem;
        margin: 0;
        padding: 0.25rem 0;
        font-family: inherit;
        font-size: var(--font-size-sm);
        font-weight: 500;
        line-height: 1.2;
        color: var(--color-text-muted);
        text-align: left;
        background: transparent;
        border: 0;
        cursor: pointer;
    }

    .locale-nav-entry__button:hover {
        color: var(--color-text);
    }

    .locale-nav-entry__button:focus-visible {
        outline: 2px solid var(--color-brand-red);
        outline-offset: 3px;
    }

    .locale-nav-entry__globe {
        flex-shrink: 0;
        width: 1.15rem;
        height: 1.15rem;
    }

    .locale-panel {
        position: fixed;
        top: var(--header-height);
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 4;
        display: flex;
        flex-direction: column;
        grid-template-rows: none;
        overflow: hidden;
        background-color: var(--color-background);
        visibility: hidden;
        transform: translateX(100%);
        transition:
            transform var(--transition-base),
            visibility var(--transition-base);
    }

    .site-header.is-locale-open .locale-panel {
        visibility: visible;
        transform: translateX(0);
    }

    .site-header.is-nav-open.is-locale-open .site-header__nav {
        transform: translateX(-20%);
    }

    .locale-panel__clip {
        flex: 1;
        min-height: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .locale-panel__inner {
        flex: 1;
        height: auto;
        max-height: none;
        min-height: 0;
        overflow: auto;
        padding: 0;
        border-top: 0;
    }

    .locale-panel__toolbar--mobile {
        position: sticky;
        top: 0;
        z-index: 1;
        display: flex;
        align-items: center;
        min-height: 3.25rem;
        padding: 0.75rem var(--layout-gutter-x);
        background-color: var(--color-background);
    }

    .locale-panel__back {
        display: inline-flex;
        align-items: center;
        gap: 0.65rem;
        margin: 0;
        padding: 0;
        font-family: inherit;
        font-size: var(--font-size-base);
        font-weight: 700;
        line-height: 1.25;
        color: var(--color-text);
        text-align: left;
        background: transparent;
        border: 0;
        cursor: pointer;
    }

    .locale-panel__back:focus-visible {
        outline: 2px solid var(--color-brand-red);
        outline-offset: 2px;
    }

    .locale-panel__back-icon {
        flex-shrink: 0;
        width: 1.35rem;
        height: 1.35rem;
    }

    .locale-panel__body {
        padding: 0.5rem var(--layout-gutter-x) 2rem;
        overflow: visible;
    }

    .locale-panel__list {
        column-count: 1;
        column-gap: 0;
    }

    .locale-location__row {
        min-height: 3.25rem;
        padding: 0.75rem 0.75rem;
    }

    .locale-location__name {
        font-size: var(--font-size-base);
    }

    .locale-location__langs .locale-location__lang,
    .locale-location__langs button,
    .locale-location__sep {
        font-size: var(--font-size-sm);
    }

    .site-header.is-locale-open .site-header__page-blur {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }

    @media (prefers-reduced-motion: reduce) {
        .locale-panel {
            transition: none;
        }
    }
}
