/* Shared language picker. This is intentionally isolated from header/nav link styles. */
.locale-form,
.language-form {
    position: relative;
    margin: 0;
}

.locale-picker {
    position: relative;
    min-width: 154px;
    color-scheme: light;
}

.locale-picker[open] {
    z-index: 500;
}

.topbar:has(.locale-picker[open]),
.site-header:has(.locale-picker[open]) {
    position: relative;
    z-index: 1000;
}

.locale-picker summary {
    list-style: none;
}

.locale-picker summary::-webkit-details-marker {
    display: none;
}

.locale-picker-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    min-height: 34px;
    padding: 7px 10px;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 9px;
    background: rgba(255, 255, 255, .94);
    color: #111827;
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 780;
    line-height: 1.2;
    text-decoration: none;
    box-shadow: 0 12px 26px rgba(7, 17, 31, .16), inset 0 1px 0 rgba(255, 255, 255, .72);
}

.locale-picker-trigger:focus-visible {
    outline: 2px solid rgba(66, 133, 244, .7);
    outline-offset: 2px;
}

.locale-picker-chevron {
    width: 7px;
    height: 7px;
    flex: 0 0 auto;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    opacity: .65;
    transform: translateY(-2px) rotate(45deg);
}

.locale-picker[open] .locale-picker-chevron {
    transform: translateY(2px) rotate(225deg);
}

.locale-picker-menu {
    position: absolute;
    top: calc(100% + 7px);
    right: 0;
    z-index: 500;
    display: grid;
    gap: 5px;
    width: 266px;
    max-height: min(460px, calc(100vh - 96px));
    padding: 8px;
    overflow-y: auto;
    border: 1px solid rgba(15, 23, 42, .12);
    border-radius: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #f2f7ff 100%);
    box-shadow: 0 22px 54px rgba(7, 17, 31, .24);
}

.locale-picker-option,
.site-header .nav .locale-picker-option,
.site-header .nav a.locale-picker-option:not(.primary),
.site-header .nav button.locale-picker-option,
.topbar .nav .locale-picker-option,
.topbar .nav a.locale-picker-option,
.topbar .nav button.locale-picker-option,
.topbar .top-actions .locale-picker-option,
.topbar .top-actions a.locale-picker-option,
.topbar .top-actions button.locale-picker-option,
.premium-research-app .topbar .locale-picker-option,
.premium-research-app .topbar a.locale-picker-option,
.premium-research-app .topbar button.locale-picker-option {
    appearance: none;
    -webkit-appearance: none;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 40px;
    padding: 7px 10px;
    border: 1px solid rgba(226, 232, 240, .58);
    border-radius: 8px;
    background: linear-gradient(180deg, #ffffff 0%, #f3f7ff 100%);
    color: #111827 !important;
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 780;
    line-height: 1.2;
    text-align: left;
    text-decoration: none !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .78), 0 10px 18px rgba(15, 23, 42, .06);
}

.locale-picker-option:hover,
.locale-picker-option:focus,
.site-header .nav .locale-picker-option:hover,
.site-header .nav .locale-picker-option:focus,
.topbar .nav .locale-picker-option:hover,
.topbar .nav .locale-picker-option:focus,
.topbar .top-actions .locale-picker-option:hover,
.topbar .top-actions .locale-picker-option:focus,
.premium-research-app .topbar .locale-picker-option:hover,
.premium-research-app .topbar .locale-picker-option:focus {
    background: linear-gradient(180deg, #ffffff 0%, #e7f0ff 100%);
    color: #111827 !important;
    outline: 0;
    text-decoration: none !important;
}

.locale-picker-option.is-active,
.site-header .nav .locale-picker-option.is-active,
.topbar .nav .locale-picker-option.is-active,
.topbar .top-actions .locale-picker-option.is-active,
.premium-research-app .topbar .locale-picker-option.is-active,
.locale-picker-option.is-active:hover,
.locale-picker-option.is-active:focus,
.site-header .nav .locale-picker-option.is-active:hover,
.site-header .nav .locale-picker-option.is-active:focus,
.topbar .nav .locale-picker-option.is-active:hover,
.topbar .nav .locale-picker-option.is-active:focus,
.topbar .top-actions .locale-picker-option.is-active:hover,
.topbar .top-actions .locale-picker-option.is-active:focus,
.premium-research-app .topbar .locale-picker-option.is-active:hover,
.premium-research-app .topbar .locale-picker-option.is-active:focus {
    border-color: rgba(31, 95, 191, .82);
    background: #1f5fbf;
    color: #ffffff !important;
    text-decoration: none !important;
}

.locale-picker-menu a.locale-picker-option.is-active:not(.primary),
.locale-picker-menu button.locale-picker-option.is-active,
.site-header .nav .locale-picker-menu a.locale-picker-option.is-active:not(.primary),
.topbar .nav .locale-picker-menu a.locale-picker-option.is-active,
.topbar .nav .locale-picker-menu button.locale-picker-option.is-active,
.topbar .top-actions .locale-picker-menu a.locale-picker-option.is-active,
.topbar .top-actions .locale-picker-menu button.locale-picker-option.is-active,
.premium-research-app .topbar .locale-picker-menu a.locale-picker-option.is-active,
.premium-research-app .topbar .locale-picker-menu button.locale-picker-option.is-active {
    background: #1f5fbf !important;
    color: #ffffff !important;
    text-decoration: none !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 10px 18px rgba(31, 95, 191, .2) !important;
}

.locale-picker-flag {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
}

.topbar .nav:has(.locale-picker[open]),
.topbar .top-actions:has(.locale-picker[open]),
.site-header .nav:has(.locale-picker[open]),
.premium-research-app .topbar .nav:has(.locale-picker[open]),
.premium-research-app .topbar .top-actions:has(.locale-picker[open]) {
    overflow: visible;
}

@media (max-width: 480px) {
    .topbar .locale-picker,
    .site-header .locale-picker,
    .premium-research-app .topbar .locale-picker {
        min-width: 126px;
    }

    .topbar .locale-picker-menu,
    .site-header .locale-picker-menu,
    .premium-research-app .topbar .locale-picker-menu {
        right: auto;
        left: 0;
        width: min(276px, calc(100vw - 24px));
        max-height: min(420px, calc(100vh - 120px));
    }

    .locale-picker-trigger {
        min-height: 32px;
        padding: 6px 8px;
    }
}
