/* Нижнее мобильное меню (mbn) и шторка «Ещё».
   Меню видно на телефонах (до 767px) и на мобильных/планшетах до 991px.
   Все отступы под меню включаются классом html.mbn-on, который ставит js/mobile-nav.js,
   только когда меню действительно показано. */
:root {
    --mbn-h: 62px;
    --mbn-safe: env(safe-area-inset-bottom, 0px);
    --mbn-ink: #121212;
    --mbn-muted: #6b7280;
    --mbn-line: #eceef1;
    --mbn-yellow: #ffcc33;
    --mbn-green: #61bb37;
}

.mbn { display: none; }

@media (max-width: 767px) {
    .mbn { display: flex; }
}
@media (max-width: 991px) {
    .mbn.mbn--ua { display: flex; }
}

.mbn {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99990;
    align-items: stretch;
    height: calc(var(--mbn-h) + var(--mbn-safe));
    padding: 0 4px var(--mbn-safe);
    background: #fff;
    border-top: 1px solid var(--mbn-line);
    box-shadow: 0 -4px 18px rgba(18, 18, 18, .08);
    font-family: inherit;
}

.mbn__item {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin: 0;
    padding: 0 2px 9px;
    border: 0;
    background: none;
    color: var(--mbn-muted);
    font: inherit;
    font-size: 11px;
    line-height: 1.1;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color .15s ease;
}
.mbn__item:hover,
.mbn__item:focus-visible { color: var(--mbn-ink); }
.mbn__item:focus-visible { outline: 2px solid var(--mbn-yellow); outline-offset: -4px; border-radius: 10px; }

.mbn__label {
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.mbn__icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    transition: transform .15s ease;
}
.mbn__icon svg { width: 24px; height: 24px; display: block; }
.mbn__item:active .mbn__icon { transform: scale(.9); }

.mbn__item.is-active { color: var(--mbn-ink); font-weight: 600; }
.mbn__item.is-active::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: 22px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--mbn-yellow);
    transform: translateX(-50%);
}

/* Корзина — круглая кнопка в цветах логотипа */
.mbn__item--cart { color: var(--mbn-ink); font-weight: 500; }
.mbn__item--cart.is-active::before { display: none; }
.mbn__item--cart .mbn__icon {
    width: 50px;
    height: 50px;
    margin-bottom: -2px;
    border-radius: 50%;
    background: var(--mbn-ink);
    color: var(--mbn-yellow);
    box-shadow: 0 6px 16px rgba(0, 0, 0, .22), 0 0 0 4px #fff;
}
.mbn__item--cart .mbn__icon svg { width: 25px; height: 25px; }
.mbn__item--cart.is-active .mbn__icon { box-shadow: 0 6px 16px rgba(0, 0, 0, .22), 0 0 0 4px #fff, 0 0 0 6px var(--mbn-yellow); }

.mbn__badge {
    position: absolute;
    top: -6px;
    right: -11px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 9px;
    background: #3a3e51;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    line-height: 17px;
    text-align: center;
    box-shadow: 0 0 0 2px #fff;
}
.mbn__badge:empty { display: none; }
.mbn__item--cart .mbn__badge { top: -2px; right: -4px; background: var(--mbn-green); }

/* Шторка «Ещё» */
.mbn-overlay {
    position: fixed;
    inset: 0;
    z-index: 100005;
    background: rgba(17, 17, 17, .45);
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s ease, visibility .25s ease;
}
.mbn-overlay.is-open { opacity: 1; visibility: visible; }

.mbn-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100010;
    max-width: 560px;
    max-height: 86vh;
    max-height: 86dvh;
    margin: 0 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 6px 16px calc(18px + var(--mbn-safe));
    border-radius: 18px 18px 0 0;
    background: #fff;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, .18);
    transform: translateY(105%);
    visibility: hidden;
    transition: transform .28s cubic-bezier(.2, .8, .2, 1), visibility .28s;
    font-size: 15px;
    color: var(--mbn-ink);
}
.mbn-sheet.is-open { transform: none; visibility: visible; }

.mbn-sheet__grip {
    width: 40px;
    height: 4px;
    margin: 4px auto 8px;
    border-radius: 2px;
    background: #d9dce1;
}
.mbn-sheet__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.mbn-sheet__title { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.3; }
.mbn-sheet__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-right: -8px;
    border: 0;
    border-radius: 50%;
    background: none;
    color: var(--mbn-ink);
    cursor: pointer;
}
.mbn-sheet__close:hover { background: #f3f4f6; }

.mbn-sheet__list { margin: 0 0 12px; padding: 0; list-style: none; }
.mbn-sheet__list li { margin: 0; padding: 0; }
.mbn-sheet__link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 8px 2px;
    border-bottom: 1px solid var(--mbn-line);
    color: var(--mbn-ink);
    text-decoration: none;
}
.mbn-sheet__link:hover { color: #000; }
.mbn-sheet__link svg { flex: 0 0 22px; width: 22px; height: 22px; color: var(--mbn-muted); }
.mbn-sheet__link span { flex: 1 1 auto; min-width: 0; }
.mbn-sheet__link::after {
    content: "";
    flex: 0 0 8px;
    width: 8px;
    height: 8px;
    border-top: 2px solid #b8bdc6;
    border-right: 2px solid #b8bdc6;
    transform: rotate(45deg);
}
.mbn-sheet__link--account { font-weight: 600; }

.mbn-sheet__contacts {
    padding: 14px;
    border-radius: 14px;
    background: #f6f7f9;
}
.mbn-sheet__phones { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.mbn-sheet__phone { color: var(--mbn-ink); font-size: 18px; font-weight: 600; text-decoration: none; }
.mbn-sheet__messengers { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.mbn-sheet__msg {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    border-radius: 10px;
    color: #fff;
    font-weight: 600;
    text-decoration: none;
}
.mbn-sheet__msg svg { width: 20px; height: 20px; }
.mbn-sheet__msg--wa { background: #25d366; }
.mbn-sheet__msg--tg { background: #2aa3df; }
.mbn-sheet__hours { margin: 0; color: var(--mbn-muted); font-size: 13px; }

html.mbn-lock,
html.mbn-lock body { overflow: hidden; }

/* Отступы и плавающие кнопки, когда нижнее меню показано */
html.mbn-on body { padding-bottom: calc(var(--mbn-h) + var(--mbn-safe)); }
html.mbn-on .whatsapp-button { bottom: calc(var(--mbn-h) + var(--mbn-safe)); }
html.mbn-on .footer_call { bottom: calc(var(--mbn-h) + var(--mbn-safe) + 70px); }
html.mbn-on .scrol_top_head { bottom: calc(var(--mbn-h) + var(--mbn-safe)); }
/* кнопка «Оформить заказ» в корзине стоит над нижним меню */
html.mbn-on .cart_mob_bbb { bottom: calc(var(--mbn-h) + var(--mbn-safe)); }
html.mbn-on body:has(.cart_mob_bbb) { padding-bottom: calc(var(--mbn-h) + var(--mbn-safe) + 80px); }
/* корзина и избранное уже есть в нижнем меню — в мобильной шапке их прячем, чтобы она помещалась на 320px */
html.mbn-on header.header .head_right .favorit.f_hed,
html.mbn-on header.header .head_right > .cart { display: none; }

/* скрытая панель «Купить» в карточке товара не должна перехватывать нажатия */
.scrol_top_head:not(.scroll_show) { pointer-events: none; }

@media (max-width: 360px) {
    .mbn__item { font-size: 10px; }
}

/* Мелкие исправления мобильной вёрстки */
@media (max-width: 767px) {
    /* длинные артикулы и названия не вылезают за экран */
    h1, h2, h3, .content_descr { overflow-wrap: break-word; word-break: break-word; }
    /* кнопки соцсетей в подвале переносятся, а не расширяют страницу на 320px */
    .social-btn-row { flex-wrap: wrap; gap: 8px; padding: 0; }
    .social-btn-row .social-btn { margin: 0; }
    /* меню категорий на главной: текст не наезжает на стрелку */
    li.home_menu_mob_li a { padding-right: 32px; }
    li.home_menu_mob_li img { flex: 0 0 25px; }
}

/* Компактная десктопная шапка (#myHeader) на узком окне — как на metall-profill:
   логотип слева, справа круглые кнопки «телефон / поиск / меню», поиск выезжает строкой под шапкой.
   Корзина, избранное и каталог на этой ширине — в нижнем меню. */
.dsh-mob { display: none; }
@media (max-width: 767px) {
    #myHeader .header_top,
    #myHeader .header_bottom,
    #myHeader .head_right,
    #myHeader .cd-dropdown-trigger { display: none; }
    #myHeader .container { max-width: 100%; width: 100%; padding: 0; }
    #myHeader .wrapper {
        position: relative;
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        min-height: 60px;
        padding: 0 12px 0 14px;
    }
    #myHeader .header_left { flex: 1 1 auto; min-width: 0; }
    /* в .header-item-left_mix лежат поиск, кнопки .dsh-mob и .head_right */
    #myHeader .header-item-left_mix { flex: 0 0 auto; width: auto; margin: 0; gap: 0; }
    #myHeader .header-item-left_mix > .header-search { display: none; }
    html.dsh-search-open #myHeader .wrapper::after {
        content: "";
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        height: 64px;
        background: #fff;
        border-top: 1px solid var(--mbn-line);
        box-shadow: 0 10px 18px rgba(18, 18, 18, .08);
    }
    html.dsh-search-open #myHeader .header-item-left_mix > .header-search {
        display: flex;
        position: absolute;
        top: calc(100% + 11px);
        left: 12px;
        right: 12px;
        width: auto;
        z-index: 2;
    }
    .dsh-mob { display: flex; flex: 0 0 auto; align-items: center; gap: 8px; }
}
.dsh-mob__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #f3f4f6;
    color: var(--mbn-ink);
    cursor: pointer;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: background-color .15s ease, transform .15s ease;
}
.dsh-mob__btn svg { width: 20px; height: 20px; display: block; }
.dsh-mob__btn:hover { background: #e8eaee; }
.dsh-mob__btn:active { transform: scale(.94); }
.dsh-mob__btn:focus-visible { outline: 2px solid var(--mbn-yellow); outline-offset: 2px; }
.dsh-mob__btn--phone { background: #eaf6e3; color: #3f9a1f; }
.dsh-mob__btn--phone:hover { background: #dcf0d1; }
.dsh-mob__btn[aria-expanded="true"] { background: var(--mbn-yellow); }

@media (prefers-reduced-motion: reduce) {
    .mbn-sheet, .mbn-overlay, .mbn__icon, .mbn__item { transition: none; }
}
