/*
 * Шапка сайта: ПК (верхняя панель и выпадающее меню), мобильная версия (верхняя панель, меню, нижняя навигация).
 * Разметка: include/site-header.php, меню: include/header-menus.php, скрипт: assets/js/site-header.js.
 * Макет Figma: ПК node 3559:27802, мобильная версия node 3527:2742 и 3559:27927.
 * Мобильная версия включается на экранах до 1040 px (как в остальных стилях темы).
 */

:root {
    --sh-ink: #1b1e1b;
    --sh-text: #1d1d1b;
    --sh-grey: #767676;
    --sh-hover: #808080;
    --sh-line: #e5e5e5;
}

/* ---------- иконки (маска: цвет задаётся color) ---------- */
.sh-icon {
    display: block;
    width: 24px;
    height: 24px;
    background-color: currentColor;
    -webkit-mask: var(--sh-ico) center / var(--sh-ico-size, 24px) no-repeat;
    mask: var(--sh-ico) center / var(--sh-ico-size, 24px) no-repeat;
}

.sh-icon--search {
    --sh-ico: url("../img/header/search.svg");
    --sh-ico-size: 17px;
}

.sh-icon--apps {
    --sh-ico: url("../img/header/apps.svg");
}

/* ---------- шапка ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 99;
    width: 100%;
    box-sizing: border-box;
    border-bottom: 1px solid var(--sh-line);
    background-color: #ffffff;
    color: var(--sh-text);
    font-weight: 200;
    letter-spacing: -0.28px;
}

.site-header__bar {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 40px;
}

.sh-nav__list {
    display: flex;
    align-items: flex-start;
    gap: 32px;
}

/* пункт занимает всю высоту панели, чтобы выпадающее меню не закрывалось, пока мышь идёт к нему от ссылки */
.sh-nav__item {
    padding: 20px 0;
    margin: -20px 0;
}

.sh-nav__link {
    display: block;
    font-size: 14px;
    font-weight: 200;
    line-height: 32px;
    letter-spacing: -0.28px;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--sh-ink);
}

.site-header__logo {
    position: absolute;
    left: 50%;
    top: 50%;
    display: block;
    line-height: 0;
    transform: translate(-50%, -50%);
}

.site-header__logo-img {
    display: block;
    width: 143px;
    height: auto;
}

.site-header__right {
    display: flex;
    align-items: center;
    gap: 32px;
}

.site-header__btns {
    display: flex;
    align-items: center;
    gap: 24px;
}

.site-header .sh-icon-btn,
.site-header .header__search,
.site-header .header__cart {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin: 0;
    padding: 0;
    color: var(--sh-text);
    cursor: pointer;
}

.site-header__close {
    display: none;
}

/* ---------- корзина: иконка и счётчик ---------- */
.sh-cart__box {
    position: relative;
    display: block;
    width: 24px;
    height: 24px;
}

.sh-cart__icon {
    display: block;
    width: 24px;
    height: 24px;
}

.sh-cart .sh-count {
    position: absolute;
    top: -5px;
    right: auto;
    left: 13px;
    box-sizing: border-box;
    min-width: 14px;
    width: auto;
    height: 14px;
    padding: 0 2px;
    border-radius: 0;
    background-color: var(--sh-ink);
    font-family: inherit;
    font-size: 10px;
    font-weight: 400;
    line-height: 14px;
    letter-spacing: 0;
    text-align: center;
    color: #ffffff;
}

.sh-cart .sh-count.is-empty {
    display: none;
}

/* ---------- выпадающая панель каталога (ПК) ---------- */
.sh-mega {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1;
    background-color: #ffffff;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.15s ease, visibility 0s linear 0.12s;
}

/* затемнение страницы под панелью (мышь через него проходит) */
.sh-mega::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.4);
    pointer-events: none;
}

.site-header:not(.sh-hover-js) .sh-nav__item:hover > .sh-mega,
.sh-nav__item:focus-within > .sh-mega,
.sh-nav__item.is-open > .sh-mega {
    visibility: visible;
    opacity: 1;
    transition-delay: 0s;
}

.sh-mega__inner {
    display: flex;
    align-items: flex-start;
    gap: 40px;
    padding: 40px;
}

.sh-mega__columns {
    display: flex;
    flex: 1 1 auto;
    gap: 40px;
    min-width: 0;
}

.sh-mega__col {
    display: flex;
    flex: 0 0 170px;
    flex-direction: column;
    gap: 24px;
    width: 170px;
}

.sh-mega__group {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sh-mega__title,
.sh-mega__link {
    display: block;
    font-size: 14px;
    font-weight: 200;
    line-height: 1.2;
    letter-spacing: -0.28px;
    transition: opacity 0.15s ease;
}

.sh-mega__title {
    text-transform: uppercase;
    color: var(--sh-text);
}

.sh-mega__sub {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sh-mega__link {
    color: var(--sh-grey);
}

/* наведение на пункты меню (по образцу): цвет #808080 за 333 мс и тонкая линия, которая выезжает под текстом */
.sh-nav__link,
.sh-mega__title,
.sh-mega__link,
.sh-drop__link {
    position: relative;
    width: fit-content;
    transition: all 333ms ease;
}

.sh-nav__link::before,
.sh-mega__title::before,
.sh-mega__link::before,
.sh-drop__link::before {
    content: " ";
    position: absolute;
    bottom: -0.2em;
    left: 0;
    width: 100%;
    height: 1px;
    background: currentColor;
    pointer-events: none;
    visibility: hidden;
    transform: scaleX(0);
    transform-origin: left center;
    transition: 0.25s linear;
}

.sh-nav__item:hover > .sh-nav__link,
.sh-nav__item:focus-within > .sh-nav__link,
.sh-nav__item.is-open > .sh-nav__link,
a.sh-mega__title:hover,
a.sh-mega__title:focus-visible,
a.sh-mega__link:hover,
a.sh-mega__link:focus-visible,
a.sh-drop__link:hover,
a.sh-drop__link:focus-visible {
    color: var(--sh-hover);
}

.sh-nav__item:hover > .sh-nav__link::before,
.sh-nav__item:focus-within > .sh-nav__link::before,
.sh-nav__item.is-open > .sh-nav__link::before,
a.sh-mega__title:hover::before,
a.sh-mega__title:focus-visible::before,
a.sh-mega__link:hover::before,
a.sh-mega__link:focus-visible::before,
a.sh-drop__link:hover::before,
a.sh-drop__link:focus-visible::before {
    visibility: visible;
    transform: scaleX(1);
}

.sh-mega__banners {
    display: flex;
    flex: 0 0 auto;
    gap: 4px;
    margin-left: auto;
}

.sh-banner {
    position: relative;
    display: block;
    flex: 0 1 213px;
    width: 213px;
    color: #000000;
}

.sh-banner__media {
    position: relative;
    display: block;
    height: 282px;
    overflow: hidden;
    background-color: #f2f2f2;
}

/* название и цена как в карточке каталога (.product-card__desc) */
.sh-banner__desc {
    padding-top: 12px;
}

.sh-banner__title {
    display: block;
    margin-bottom: 6px;
    font-size: 17px;
    line-height: 1.2;
}

.sh-banner__wrap {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 12px;
    font-size: 19px;
    line-height: 1.2;
}

.sh-banner__wrap .product-card__old {
    font-size: 17px;
}

.sh-banner__img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sh-banner__tag {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 4px 8px;
    background-color: #000000;
    font-size: 12px;
    font-weight: 200;
    line-height: 1;
    letter-spacing: 0;
    color: #ffffff;
}

/* ---------- выпадающий список у пунктов правого меню ---------- */
.sh-nav__item.has-drop {
    position: relative;
}

.sh-drop {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 1;
    min-width: 200px;
    padding: 16px 20px;
    border: 1px solid var(--sh-line);
    background-color: #ffffff;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.15s ease, visibility 0s linear 0.12s;
}

.sh-nav__item.has-drop:hover > .sh-drop,
.sh-nav__item.has-drop:focus-within > .sh-drop {
    visibility: visible;
    opacity: 1;
    transition-delay: 0s;
}

.sh-drop li + li {
    margin-top: 12px;
}

.sh-drop__link {
    display: block;
    font-size: 14px;
    font-weight: 200;
    line-height: 1.2;
    white-space: nowrap;
    color: var(--sh-grey);
}

/* ---------- мобильное меню и нижняя навигация: на ПК скрыты ---------- */
.sm,
.site-nav {
    display: none;
}

@media screen and (max-width: 1500px) {
    .sh-banner:nth-child(n + 3) {
        display: none;
    }
}

@media screen and (max-width: 1280px) {
    .site-header__bar {
        padding-left: 24px;
        padding-right: 24px;
    }

    .sh-nav__list,
    .site-header__right {
        gap: 20px;
    }

    .sh-mega__inner {
        padding: 32px 24px;
        gap: 24px;
    }

    .sh-mega__columns {
        gap: 24px;
    }
}

@media screen and (max-width: 1200px) {
    .sh-mega__banners {
        display: none;
    }
}

/* ---------- мобильная версия ---------- */
@media screen and (max-width: 1040px) {
    body {
        padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    }

    .site-header {
        height: 60px;
    }

    .site-header__bar {
        height: 100%;
        padding: 0 16px;
        justify-content: center;
    }

    .sh-nav--main,
    .site-header__right {
        display: none;
    }

    .site-header__logo {
        left: 50%;
    }

    .site-header__logo-img {
        width: 149px;
    }

    /* крестик слева виден, пока открыто меню */
    .site-header__close:not([hidden]) {
        position: absolute;
        top: 50%;
        left: 16px;
        display: block;
        width: 24px;
        height: 24px;
        margin-top: -12px;
        background-color: var(--sh-text);
        -webkit-mask: url("../img/header/close.svg") center / 24px no-repeat;
        mask: url("../img/header/close.svg") center / 24px no-repeat;
        cursor: pointer;
    }

    /* поиск и корзина открываются из нижней навигации: поле поиска начинается под шапкой */
    .site-header .search {
        height: calc(100dvh - 60px);
    }

    .sm {
        position: fixed;
        top: 60px;
        right: 0;
        bottom: calc(60px + env(safe-area-inset-bottom, 0px));
        left: 0;
        z-index: 97;
        display: block;
        overflow-y: auto;
        overscroll-behavior: contain;
        background-color: #ffffff;
        visibility: hidden;
        opacity: 0;
        transition: opacity 0.2s ease, visibility 0s linear 0.2s;
    }

    .sm--open {
        visibility: visible;
        opacity: 1;
        transition-delay: 0s;
    }

    .sm__nav {
        padding: 16px;
    }

    .sm__list {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .sm__item--gap {
        margin-top: 28px;
    }

    .sm__item--sep {
        margin-top: 12px;
        padding-top: 8px;
        border-top: 1px solid var(--sh-line);
    }

    .sm__row {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .sm__link {
        flex: 1 1 auto;
        font-size: 14px;
        font-weight: 200;
        line-height: 32px;
        letter-spacing: -0.28px;
        text-transform: uppercase;
        color: var(--sh-ink);
    }

    .sm__item.has-children > .sm__row {
        cursor: pointer;
    }

    .sm__toggle {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        flex: 0 0 auto;
        width: 44px;
        height: 32px;
        margin-right: -15px;
        padding-right: 15px;
        cursor: pointer;
    }

    .sm__arrow {
        display: block;
        width: 14px;
        height: 14px;
        background-color: var(--sh-ink);
        -webkit-mask: url("../img/header/arrow.svg") center / 14px no-repeat;
        mask: url("../img/header/arrow.svg") center / 14px no-repeat;
        transition: transform 0.2s ease;
    }

    .sm__toggle[aria-expanded="true"] .sm__arrow {
        transform: rotate(180deg);
    }

    .sm__sub {
        display: none;
        column-count: 2;
        column-gap: 8px;
        margin-top: 4px;
        padding-bottom: 4px;
    }

    .sm__item.is-open > .sm__sub {
        display: block;
    }

    .sm__sub li {
        break-inside: avoid;
        margin-bottom: 12px;
    }

    .sm__sublink {
        display: block;
        font-size: 14px;
        font-weight: 200;
        line-height: 1.2;
        letter-spacing: -0.28px;
        color: var(--sh-grey);
    }

    .site-nav {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 98;
        display: flex;
        align-items: center;
        justify-content: space-between;
        box-sizing: border-box;
        height: calc(60px + env(safe-area-inset-bottom, 0px));
        padding: 0 16px env(safe-area-inset-bottom, 0px);
        border-top: 1px solid var(--sh-line);
        background-color: #ffffff;
    }

    .site-nav__btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        min-width: 56px;
        height: 100%;
        color: var(--sh-grey);
        cursor: pointer;
    }

    .site-nav__btn.is-active {
        color: var(--sh-text);
    }

    .site-nav__label {
        font-size: 10px;
        font-weight: 200;
        line-height: 1.2;
        letter-spacing: -0.2px;
        white-space: nowrap;
    }

    .back-to-top-btn {
        bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    }
}

/* уведомление о cookie на телефоне стоит над нижней навигацией, а не закрывает её */
@media screen and (max-width: 1040px) {
    .cookiebar-wrapper.--show {
        bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    }
}

/* поиск и корзина закрывают нижнюю навигацию, уведомление о cookie тогда прижато к низу экрана */
@media screen and (max-width: 1040px) {
    body:has(.search--active, .cart--active) .cookiebar-wrapper.--show {
        bottom: 0;
    }
}

/* ---------- доступность ---------- */
/* на сайте у .btn-reset убрана рамка фокуса: для шапки, меню и нижней навигации возвращаем заметную рамку при управлении с клавиатуры */
.site-header a:focus-visible,
.site-header button:focus-visible,
.sm a:focus-visible,
.sm button:focus-visible,
.site-nav button:focus-visible {
    outline: 2px solid var(--sh-ink);
    outline-offset: 3px;
}

.site-nav button:focus-visible {
    outline-offset: -3px;
}

/* кнопка пункта верхнего меню без адреса (раскрывает панель) выглядит как обычный пункт */
button.sh-nav__link {
    padding-top: 0;
    padding-right: 0;
    padding-left: 0;
    background: none;
    border-top: 0;
    border-right: 0;
    border-left: 0;
    font-family: inherit;
    cursor: default;
}

@media (prefers-reduced-motion: reduce) {
    .site-header *,
    .sm,
    .sm * {
        transition: none !important;
    }
}

#content:focus {
    outline: none;
}

/* окно «Фильтры и сортировка» открывается поверх шапки и нижней навигации (раньше они его перекрывали, и закрыть окно было нельзя) */
.filter.filter--active {
    z-index: 120;
}

/* пока открыто окно фильтров, страница под ним не прокручивается (прокрутка остаётся только внутри окна) */
html.filter-open,
body.filter-open {
    overflow: hidden;
}

.filter,
.filter__body {
    overscroll-behavior: contain;
}
