/* Language switcher: right after the last menu item ("Контакти"), separate from the menu list.
   An invisible spacer of the same width on the left keeps the menu (and the logo) centered. */
@media (min-width: 768px) {
    .main header nav.top {
        display: flex;
        justify-content: center;
        align-items: center;
    }
    .main header nav.top:before,
    .lang-switch-wrap--desktop {
        flex: 0 0 auto;
        width: 90px;
        margin-left: 36px;      /* same gap as between menu items */
    }
    .main header nav.top:before {
        content: '';
        margin: 0 36px 0 0;
    }
    .main header nav.top #menu-main {
        flex: 0 1 auto;
    }
}
.lang-switch-wrap--desktop {
    display: flex;
    align-items: center;
    text-align: left;
}

.lang-switch {
    position: relative;
    font-size: 16px;
    line-height: 1;
}
.lang-switch-wrap--desktop .lang-switch {
    padding-left: 28px;
}
.lang-switch-wrap--desktop .lang-switch:before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    height: 30px;
    margin-top: -15px;
    border-left: 1px solid currentColor;
    opacity: .35;
}

.lang-switch__toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 2px;
    margin: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    font-size: 19px;
    font-size: 1.9rem;
    letter-spacing: .02em;
    cursor: pointer;
}
.lang-switch__toggle:focus-visible {
    outline: 2px solid #E34B4A;
    outline-offset: 2px;
    border-radius: 4px;
}
.lang-switch__chevron {
    transition: transform .2s ease;
}
.lang-switch.is-open .lang-switch__chevron {
    transform: rotate(180deg);
}

/* Colors per header variant */
.main nav.top .lang-switch { color: #fff; }               /* home: red bar */
.main.page nav.top .lang-switch { color: #252627; }       /* inner pages: white bar */
.main.page.class8 nav.top .lang-switch { color: #fff; }   /* black bar */
.main.page nav.top .lang-switch__toggle:hover,
.main.page nav.top .lang-switch.is-open .lang-switch__toggle { color: #E34B4A; }
.main nav.top .lang-switch__toggle:hover { opacity: .85; }

/* Dropdown */
.lang-switch__menu {
    position: absolute;
    top: calc(100% + 12px);
    right: -16px;
    z-index: 1000;
    min-width: 236px;
    margin: 0;
    padding: 8px;
    list-style: none;
    background: #fff;
    border: 1px solid #ececec;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .12);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity .18s ease, transform .18s ease, visibility 0s linear .18s;
}
.lang-switch.is-open .lang-switch__menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition: opacity .18s ease, transform .18s ease;
}
.lang-switch__menu li,
nav.top .lang-switch__menu li {
    display: block;
    margin: 0;
}
.lang-switch__menu li:before { display: none !important; }

.lang-switch__item,
nav.top .lang-switch__item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 14px;
    border-radius: 6px;
    color: #252627 !important;
    font-size: 17px;
    line-height: 1.2;
    text-decoration: none;
    transition: background-color .15s ease;
}
.lang-switch__item:hover,
.lang-switch__item:focus-visible {
    background: #f5f5f5;
    outline: none;
}
.lang-switch__item.is-active {
    background: #fdeceb;
}
.lang-switch__code {
    min-width: 26px;
    font-weight: 600;
    letter-spacing: .02em;
}
.lang-switch__name {
    flex: 1;
}
.lang-switch__check {
    color: #E34B4A;
    flex-shrink: 0;
}

/* common.js copies the whole nav.top into .mobile-menu; that copy is the mobile switcher */
.mobile-menu .lang-switch-wrap--desktop {
    display: none;
}
/* Mobile bar: compact switcher left of the hamburger */
@media (max-width: 767px) {
    .mobile-menu .lang-switch-wrap--desktop {
        display: flex;
        align-items: center;   /* vertically centered in the bar, like the hamburger */
        position: absolute;
        top: 3px;          /* same box as .mobile-menu-reveal (top 3px, 46px high) */
        height: 46px;
        right: 64px;
    }
    .mobile-menu .lang-switch { color: #fff; padding-left: 0; }
    .mobile-menu .lang-switch:before { display: none; }
    .mobile-menu .lang-switch__toggle {
        font-size: 15px;
        padding: 12px 6px;
    }
    .mobile-menu .lang-switch__menu {
        right: -50px;
        top: 100%;
    }
}

/* Tablet widths: no centering spacer, tighter gaps */
@media (min-width: 768px) and (max-width: 1099px) {
    .main header nav.top:before { display: none; }
    .lang-switch-wrap--desktop { width: auto; margin-left: 20px; }
    .lang-switch-wrap--desktop .lang-switch { padding-left: 16px; }
    .lang-switch__toggle { font-size: 16px; }
}
@media (min-width: 768px) and (max-width: 900px) {
    nav.top #menu-main li a { font-size: 16px; }
    nav.top #menu-main li { margin-left: 12px; }
    nav.top #menu-main li:first-child { margin-left: 0; }
}
