/* ========================================
   Language Picker
   Shared by the landing page, blog and shared count pages.
   Pages retheme it by overriding the custom properties below.
   The popover is moved to <body> at runtime, so its rules
   must not depend on .lang-picker as an ancestor.
   ======================================== */

:root {
    --lang-picker-text: #10221f;
    --lang-picker-muted: rgba(16, 34, 31, 0.66);
    --lang-picker-accent: #236f65;
    --lang-picker-accent-strong: #1d574e;
    --lang-picker-surface: #fbfaf2;
    --lang-picker-soft: #eef5ef;
    --lang-picker-selected: rgba(35, 111, 101, 0.1);
    --lang-picker-line: rgba(16, 34, 31, 0.14);
    --lang-picker-field-line: #c5d2c9;
    --lang-picker-ring: rgba(35, 111, 101, 0.16);
    --lang-picker-shadow: 0 10px 40px rgba(16, 34, 31, 0.16);
    --lang-picker-radius: 12px;
    --lang-picker-control-radius: 8px;
}

.lang-picker {
    display: flex;
    flex-shrink: 0;
    min-width: 0;
}

/* Trigger */

.lang-picker__trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    max-width: 100%;
    min-height: 40px;
    margin: 0;
    padding: 0 10px;
    border: 1px solid transparent;
    border-radius: var(--lang-picker-control-radius);
    background: transparent;
    color: var(--lang-picker-text);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.lang-picker__trigger:hover,
.lang-picker__trigger[aria-expanded="true"] {
    background: var(--lang-picker-soft);
    color: var(--lang-picker-accent-strong);
}

.lang-picker__trigger:focus-visible {
    outline: 2px solid var(--lang-picker-accent);
    outline-offset: 2px;
}

.lang-picker__globe,
.lang-picker__chevron {
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.lang-picker__globe {
    width: 18px;
    height: 18px;
    stroke-width: 1.6;
}

.lang-picker__name {
    min-width: 0;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Pages with a tight header swap the name for the code */
.lang-picker__code {
    display: none;
    letter-spacing: 0.02em;
}

.lang-picker__chevron {
    width: 12px;
    height: 12px;
    color: var(--lang-picker-muted);
    stroke-width: 1.8;
    transition: transform 0.15s ease;
}

.lang-picker__trigger[aria-expanded="true"] .lang-picker__chevron {
    transform: rotate(180deg);
}

/* Popover */

.lang-picker__popover {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    width: min(320px, calc(100vw - 24px));
    max-height: min(420px, calc(100vh - 24px));
    padding: 12px 8px 8px;
    border: 1px solid var(--lang-picker-line);
    border-radius: var(--lang-picker-radius);
    background: var(--lang-picker-surface);
    color: var(--lang-picker-text);
    box-shadow: var(--lang-picker-shadow);
    font-size: 14px;
    line-height: 1.4;
    text-align: start;
}

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

.lang-picker__popover:focus {
    outline: none;
}

.lang-picker__heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-block: 0 8px;
    padding-inline: 8px 4px;
    font-size: 13px;
    font-weight: 700;
}

.lang-picker__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--lang-picker-muted);
    cursor: pointer;
}

.lang-picker__close:hover {
    background: var(--lang-picker-soft);
    color: var(--lang-picker-text);
}

.lang-picker__close:focus-visible {
    outline: 2px solid var(--lang-picker-accent);
    outline-offset: 1px;
}

.lang-picker__close svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
}

.lang-picker__search {
    position: relative;
    flex-shrink: 0;
    margin: 0 4px 8px;
}

.lang-picker__search-icon {
    position: absolute;
    top: 50%;
    inset-inline-start: 11px;
    width: 17px;
    height: 17px;
    transform: translateY(-50%);
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    color: var(--lang-picker-muted);
    pointer-events: none;
}

.lang-picker__input {
    display: block;
    box-sizing: border-box;
    width: 100%;
    min-height: 40px;
    margin: 0;
    padding-block: 8px;
    padding-inline: 36px 10px;
    border: 1px solid var(--lang-picker-field-line);
    border-radius: var(--lang-picker-control-radius);
    background: var(--lang-picker-soft);
    color: var(--lang-picker-text);
    font: inherit;
    font-size: 14px;
    -webkit-appearance: none;
    appearance: none;
}

.lang-picker__input::placeholder {
    color: var(--lang-picker-muted);
    opacity: 1;
}

.lang-picker__input:focus {
    border-color: var(--lang-picker-accent);
    box-shadow: 0 0 0 3px var(--lang-picker-ring);
    outline: none;
}

.lang-picker__options {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    padding: 0 2px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}

.lang-picker__option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 52px;
    padding: 8px 10px;
    border-radius: var(--lang-picker-control-radius);
    color: var(--lang-picker-text);
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

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

.lang-picker__option:hover,
.lang-picker__option.is-active {
    background: var(--lang-picker-soft);
    color: var(--lang-picker-text);
    text-decoration: none;
}

.lang-picker__option[aria-selected="true"] {
    background: var(--lang-picker-selected);
}

/* Arrow keys move this highlight while the search field has focus */
.lang-picker__popover:has(.lang-picker__input:focus) .lang-picker__option.is-active {
    box-shadow: inset 0 0 0 1px var(--lang-picker-accent);
}

.lang-picker__option-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-width: 0;
}

.lang-picker__native {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
}

.lang-picker__english {
    color: var(--lang-picker-muted);
    font-size: 11.5px;
    line-height: 1.3;
}

.lang-picker__check {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    fill: none;
    stroke: var(--lang-picker-accent);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    visibility: hidden;
}

.lang-picker__option[aria-selected="true"] .lang-picker__check {
    visibility: visible;
}

.lang-picker__empty {
    margin: 0;
    padding: 22px 12px;
    color: var(--lang-picker-muted);
    font-size: 13.5px;
    text-align: center;
}

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

/* Roomier rows for fingers, and 16px text so iOS does not zoom into the search field */
@media (pointer: coarse) {
    .lang-picker__input {
        font-size: 16px;
    }

    .lang-picker__option {
        min-height: 54px;
    }
}
