/* Pilcrow — Header styles */

/* ===== HEADER ===== */
.header {
    position: sticky;
    top: 0;
    z-index: 500;
    display: flex;
    flex-direction: column;
    background-color: #ffffff;
    overflow: visible;
}
.header__main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 90px;
    padding: 0 80px;
    max-width: var(--ys-section-max-width);
    margin: 0 auto;
    width: 100%;
}
.header__left { display: flex; align-items: center; }
.header__burger {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background var(--transition);
}
.header__burger:hover { background: transparent; }
.header__burger svg,
.header__burger img.burger-icon { width: 50px; height: 50px; }
.header__burger .close-icon { display: none; }
body.menu-open .header__burger .burger-icon { display: none; }
body.menu-open .header__burger .close-icon { display: block; }
@media (max-width: 767px) {
    .header__icon--desktop { display: none !important; }
    .header__burger { display: none !important; }
    .header__icon--cart { display: none !important; }
}


.header__logo {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}
.header__logo img { height: 80px; max-width: 400px; width: auto; }
.header__actions { display: flex; align-items: center; gap: 4px; }
.header__icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background var(--transition);
}
.header__icon:hover { background: transparent; }
.header__icon svg,
.header__icon img { width: 36px; height: 36px; stroke-width: 1.5; }
.header__icon--cart { position: relative; }
.cart-count {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: #FF4D4D;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    line-height: 16px;
    text-align: center;
    border-radius: 8px;
}

/* ===== BURGER MENU ===== */
.burger-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 99;
    opacity: 0;
    visibility: hidden;
    transition: opacity .3s, visibility .3s;
}
.burger-overlay.active {
    opacity: 1;
    visibility: visible;
}
body.menu-open {
    overflow: hidden;
}
@media (min-width: 769px) {
    .header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 100;
        background: #ffffff;
    }
    body {
        padding-top: 90px;
    }
}
@media (max-width: 768px) {
    .header {
        position: sticky;
        top: 0;
        z-index: 100;
    }
    /* Скрываем шапку на странице товара */
    .header.hide-on-product,
    .subnav-wrap.hide-on-product {
        display: none !important;
    }
}
.header__main {
    position: relative;
    z-index: 102;
    background: #ffffff;
}
.header .subnav-wrap {
    position: relative;
    background: #ffffff;
}

/* Legacy city popup/modal styles removed — see footer.css for modal, this file below for toast */

.burger-menu {
    position: fixed;
    top: 81px;
    left: 0;
    right: 0;
    z-index: 100;
    background: #ffffff;
    max-height: calc(100vh - 81px);
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s ease, visibility .25s;
}
.burger-menu.active {
    opacity: 1;
    visibility: visible;
}
.burger-menu--desktop .burger-menu__content {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0 32px;
    padding: 32px 40px;
    background: #ffffff;
    /* Ограничиваем ширину контента, чтобы на широких экранах ссылки
       не расходились к краям (сам попап остаётся на всю ширину). */
    max-width: 1100px;
    margin: 0 auto;
}
.burger-menu--desktop .burger-menu__link {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 13px;
    line-height: 30px;
    color: #2B2A2B;
    text-transform: uppercase;
    text-align: center;
    transition: opacity .15s;
}
.burger-menu--desktop .burger-menu__link:hover {
    opacity: 0.6;
}
/* Mobile burger menu */
.burger-menu--mobile {
    display: none;
    top: 80px;
    bottom: 0;
    max-height: calc(100vh - 80px);
    padding-top: 0;
}
.burger-menu--desktop {
    display: none;
}
@media (min-width: 768px) {
    .burger-menu--desktop {
        display: block;
    }
}
@media (max-width: 767px) {
    .burger-menu--mobile {
        display: block;
    }
}
.burger-mobile__level {
    display: none;
    padding: 0 16px;
}
.burger-mobile__level.active {
    display: block;
}
.burger-mobile__header {
    display: flex;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--ys-color-token-border-primary, #e4e4e6);
    position: relative;
}
.burger-mobile__back {
    position: absolute;
    left: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.burger-mobile__back svg {
    width: 20px;
    height: 20px;
}
.burger-mobile__header-title {
    flex: 1;
    text-align: center;
    font-size: 1rem;
    font-weight: 500;
    color: var(--ys-color-token-text-primary);
    text-decoration: none;
}
.burger-mobile__item--link {
    justify-content: flex-start;
}
.burger-mobile__list {
    display: flex;
    flex-direction: column;
}
.burger-mobile__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid var(--ys-color-token-border-primary, #e4e4e6);
    font-size: .95rem;
    color: var(--ys-color-token-text-primary);
    cursor: pointer;
    text-decoration: none;
}
.burger-mobile__item:last-child {
    border-bottom: none;
}
.burger-mobile__item svg {
    width: 20px;
    height: 20px;
    color: var(--ys-color-token-text-secondary);
}

/* City confirmation toast */
.city-popup {
    position: fixed;
    top: 92px;
    left: 80px;
    z-index: 50;
    width: 739px;
    max-width: calc(100vw - 160px);
    min-height: 64px;
    background: #2b2a2b;
    border-radius: 8px;
    padding: 9px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    color: #e1ded7;
    transition: opacity .25s ease, transform .25s ease, visibility .25s;
}
.city-popup.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    pointer-events: none;
}
.city-popup__text {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 20px;
    line-height: 1.2;
    color: #e1ded7;
    flex: 1;
    min-width: 0;
}
.city-popup__actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
.city-popup__btn {
    background: #e1ded7;
    color: #2b2a2b;
    border: 1px solid #e1ded7;
    border-radius: 8px;
    height: 46px;
    padding: 0 18px;
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: opacity .15s;
}
.city-popup__btn:hover { opacity: 0.85; }

@media (max-width: 768px) {
    .city-popup {
        top: 62px;
        left: 12px;
        right: 12px;
        max-width: none;
        width: auto;
        padding: 12px 14px;
        gap: 10px;
        flex-wrap: wrap;
        justify-content: center;
    }
    .city-popup__text { font-size: 16px; text-align: center; width: 100%; }
    .city-popup__btn { height: 40px; font-size: 16px; padding: 0 14px; }
}

/* Sub-nav bar */
.subnav-wrap {
    position: relative;
    overflow: visible;
}
.subnav {
    display: flex;
    align-items: center;
    gap: 0;
    padding: var(--ys-spacing-150) 80px;
    font-size: .875rem;
    line-height: 1.125rem;
    font-weight: 400;
    color: var(--ys-color-token-text-primary);
    white-space: nowrap;
    max-width: var(--ys-section-max-width);
    margin: 0 auto;
    width: 100%;
}
@media (max-width: 768px) {
    .subnav {
        padding: 4px 16px;
        font-size: .8rem;
        max-width: 100vw;
        overflow: visible;
        box-sizing: border-box;
    }
    .subnav__location-wrap {
        flex-shrink: 1;
        min-width: 0;
    }
    .subnav__location {
        min-width: 0;
    }
    #headerCityName {
        display: inline-block;
        max-width: 28vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        vertical-align: middle;
    }
}
.subnav__location {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
    color: var(--ys-color-token-text-primary);
    padding: var(--ys-spacing-150) 0;
    height: 100%;
}
@media (max-width: 768px) {
    .subnav__location {
        padding: 2px 0;
    }
}
.subnav__location svg { width: 16px; height: 16px; }
.subnav__link {
    display: flex;
    align-items: center;
    height: 100%;
    padding: var(--ys-spacing-150) 0;
    margin-left: 20px;
    color: var(--ys-color-token-text-primary);
    font-weight: 400;
    text-decoration: none;
    transition: color .15s cubic-bezier(.4,0,.2,1);
}
.subnav__link:hover { color: var(--ys-color-token-text-secondary); }

/* ===== Компактная мобильная шапка (по макету: лого по центру + поиск) ===== */
@media (max-width: 767px) {
    .header__main { height: 54px; padding: 0 16px; }
    .header__logo { top: 50%; transform: translate(-50%, -50%); }
    .header__logo img { height: 30px; }
    .header__icon { width: 36px; height: 36px; }
    .header__icon img, .header__icon svg { width: 24px; height: 24px; }
}

/* ===== Поиск в шапке (выезжает справа поверх логотипа и бургера) ===== */
.header-search {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    padding: 0 80px;
    background: #ffffff;
    opacity: 0;
    pointer-events: none;
    /* Скрываем через clip-path, а не visibility — поле остаётся «видимым» для
       системы фокуса, иначе iOS не открывает клавиатуру. Анимация — раскрытие справа. */
    clip-path: inset(0 0 0 100%);
    transition: clip-path .3s ease, opacity .3s ease;
}
.header-search.active {
    opacity: 1;
    pointer-events: auto;
    clip-path: inset(0 0 0 0);
}
.header-search__field {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    height: 55px;
    padding: 0 20px;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    background: transparent;
}
.header-search__icon { width: 24px; height: 24px; flex-shrink: 0; color: #2b2a2b; }
.header-search__input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    font-family: 'Inter', sans-serif;
    font-size: 18px;
    color: #2b2a2b;
}
.header-search__input::placeholder { color: #9e9e9e; }
.header-search__close {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: #2b2a2b;
}
.header-search__close svg { width: 24px; height: 24px; }

/* выпадающий список товаров */
.header-search__results {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    max-height: calc(100vh - 160px);
    overflow-y: auto;
    padding: 8px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .12);
}
.header-search__results.active { display: block; }
.header-search__empty {
    padding: 24px 0;
    text-align: center;
    color: #6c6c6c;
    font-family: 'Inter', sans-serif;
}
.header-search__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 8px;
    border-radius: 8px;
    text-decoration: none;
    color: #2b2a2b;
    transition: background var(--transition);
}
.header-search__item:hover { background: #f8f8f8; }
.header-search__item-img {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    background: #f0f0f0;
    border-radius: 6px;
    overflow: hidden;
}
.header-search__item-img img { width: 100%; height: 100%; object-fit: cover; }
.header-search__item-info { flex: 1; min-width: 0; font-family: 'Inter', sans-serif; }
.header-search__item-name {
    font-size: 14px;
    color: #2b2a2b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.header-search__item-price { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.header-search__price-new { font-size: 14px; font-weight: 600; color: #2b2a2b; }
.header-search__price-old { font-size: 12px; color: #9e9e9e; text-decoration: line-through; }
.header-search__discount {
    font-size: 12px;
    font-weight: 600;
    color: #ffffff;
    background: var(--red);
    padding: 1px 6px;
    border-radius: 6px;
}
.header-search__all {
    display: block;
    text-align: center;
    padding: 12px;
    margin-top: 6px;
    background: #f0f0f0;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: #2b2a2b;
    text-decoration: none;
}
.header-search__all:hover { background: #e4e4e4; }

/* затемнение под шапкой */
.header-search-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .4);
    z-index: 90;
    opacity: 0;
    visibility: hidden;
    transition: opacity .3s, visibility .3s;
}
.header-search-overlay.active { opacity: 1; visibility: visible; }
body.header-search-open { overflow: hidden; }

@media (max-width: 767px) {
    .header-search { padding: 0 16px; }
    .header-search__field { height: 40px; padding: 0 12px; gap: 8px; }
    .header-search__icon { width: 20px; height: 20px; }
    .header-search__input { font-size: 16px; }
    .header-search__close { width: 32px; height: 32px; }
    .header-search__close svg { width: 20px; height: 20px; }
    .header-search__results { max-height: calc(100vh - 150px); }
    .header-search__item-img { width: 48px; height: 48px; }
}
