/* =========================================================
   MSB Polylang Switcher
   Круглый флаг в шапке + модалка выбора языка
   ======================================================== */

/* ---------- ТРИГГЕР В ШАПКЕ (круглый флаг) ---------- */

.msb-lang-switcher {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
}

.msb-lang-switcher__trigger {
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
}

/* флаг – и для шапки, и для модалки */
.msb-lang-flag {
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(0,0,0,0.20);
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    display: inline-block;
    flex-shrink: 0;
}

/* вариант без флага – текст в кружке */
.msb-lang-flag--text {
    background-color: #f5f5f5;
    color: #333;
    font-size: 12px;
    font-weight: 600;
    line-height: 30px;
    text-align: center;
}

/* подгонка под шапку темы */
.wc-blocks-header-pattern .msb-lang-switcher {
    display: inline-flex;
    align-items: center;
}

/* ---------- МОДАЛКА ---------- */

.msb-lang-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.msb-lang-modal.is-open {
    display: flex;
}

/* затемнение */
.msb-lang-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.35);
}

/* белый блок */
.msb-lang-modal__dialog {
    position: relative;
    background: #ffffff;
    border-radius: 18px;
    padding: 22px 26px 24px;
    box-shadow: 0 20px 50px rgba(15,23,42,0.25);
    max-width: 820px;
    width: 90%;
    z-index: 1;
}

/* заголовок + крестик */
.msb-lang-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.msb-lang-modal__title {
    font-size: 18px;
    font-weight: 600;
    color: #111827;
}

.msb-lang-modal__close {
    background: transparent;
    border: none;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
}

/* ---------- Список языков ---------- */

/* КАПСУЛЫ НАЧИНАЮТСЯ СЛЕВА, до 5 в строке */
.msb-lang-modal__grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 18px;          /* вертикальный / горизонтальный зазор */
    justify-content: flex-start; /* начинаем слева */
}

/* одна капсула языка
   flex-basis 20% -> 5 штук в строке на широком экране */
.msb-lang-modal__item {
    flex: 0 0 calc(20% - 18px);
    max-width: calc(20% - 18px);

    display: flex;
    align-items: center;      /* флаг и текст по вертикали по центру */
    justify-content: center;  /* вся группа (флаг+текст) по центру капсулы */

    gap: 8px;
    padding: 8px 10px;
    min-height: 40px;

    border-radius: 999px;
    text-decoration: none;
    color: #111827;
    background: #f8f9ff;
    box-shadow: 0 0 0 rgba(0,0,0,0);
    transition:
        background 0.15s ease,
        transform 0.15s ease,
        box-shadow 0.15s ease;
}

/* наведение */
.msb-lang-modal__item:hover {
    background: #f3f4ff;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(148,163,184,0.35);
}

/* активный язык – мягкий фон + тень + красный текст */
.msb-lang-modal__item.is-current {
    background: #eef3ff;
    box-shadow: 0 8px 22px rgba(129,140,248,0.45);
    font-weight: 600;
}

.msb-lang-modal__item.is-current .msb-lang-modal__label {
    color: #e11d48;
}

/* подпись языка */
.msb-lang-modal__label {
    font-size: 14px;
    line-height: 1.2;
    display: inline-block;
    white-space: nowrap;
}

/* ---------- АДАПТАЦИЯ ---------- */

/* ~до 900px – по 4 языка в строке */
@media (max-width: 900px) {
    .msb-lang-modal__item {
        flex: 0 0 calc(25% - 18px);
        max-width: calc(25% - 18px);
    }
}

/* ~до 700px – по 3 языка в строке */
@media (max-width: 700px) {
    .msb-lang-modal__item {
        flex: 0 0 calc(33.333% - 18px);
        max-width: calc(33.333% - 18px);
    }
}

/* ~до 520px – по 2 языка в строке */
@media (max-width: 520px) {
    .msb-lang-modal__item {
        flex: 0 0 calc(50% - 18px);
        max-width: calc(50% - 18px);
    }
}

/* совсем узко – 1 язык в строке */
@media (max-width: 360px) {
    .msb-lang-modal__item {
        flex: 0 0 100%;
        max-width: 100%;
        justify-content: flex-start; /* на очень узком можно уже выровнять по левому краю */
    }
}

/* скрытый текст для читателей экрана */
.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}
