/*-----------
Header START
------------*/

header {
    padding-top: 12px;
    display: flex;
    justify-content: center;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 20;
}

.header-main>.section-wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 87px;
    padding: 0;
}

.header-main {
    position: relative;
    padding: 12px 40px;
    width: calc(100% - 64px);
    background: rgba(35, 31, 31, 0.35);
    transition: 0.5s;
    border-radius: 12px;
    box-shadow: 0px 10px 20px -20px #00000054;
}

.header-main--right {
    display: flex;
    align-items: center;
    gap: 32px;
}

.header-main nav {
    display: inline-flex;
    height: 100%;
    align-items: center;
    gap: 4px;
    font-weight: 400;
    font-size: 16px;
    line-height: 140%;
    color: #223721;
}

.header-main nav a.main-menu-link {
    padding: 10px;
    display: inline-flex;
    align-items: start;
    position: relative;
    color: #fffbf4;
    text-transform: uppercase;
    transition: 0.3s;
}

.header-main nav .submenu a.main-menu-link {
    color: #263b25;
    text-transform: none;
}

.header-main nav a.main-menu-link svg {
    margin-top: 3px;
    transition: 0.3s;
}

.header__profile svg path,
.header-main__info svg path {
    fill: #fffbf4;
}

.header--white .header-main__logo svg path {
    fill: #223721;
}

.header--white .header__profile svg path,
.header--white .header-main__info svg path {
    fill: #223721;
}

.header--white .header-main nav a.main-menu-link {
    color: #223721;
}

.header--white .burger__line {
    background: #223721;
}

header.header--white .header-main {
    background: #fff;
}

.header-main nav a.main-menu-link:hover {
    color: #7fad3c;
}

.header-main nav a.main-menu-link.is-active {
    color: #7fad3c;
    font-weight: 600;
}

header .header--green {
    background: #223721;
}

.header--white.opened-menu .header-main nav a.main-menu-link {
    color: #fffbf4;
}

.header--white.opened-menu .header-main__logo svg path {
    fill: #fffbf4;
}

.header--white.opened-menu .header__profile svg path,
.header--white.opened-menu .header-main__info svg path {
    fill: #fffbf4;
}

.header--white.opened-menu .burger__line {
    background: #fffbf4;
}

.header-main__info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-search {
    position: relative;
}

.header__search {
    display: inline-flex;
    padding: 0;
    border: none;
    background: none;
    color: inherit;
    cursor: pointer;
    line-height: 0;
}

.header-search__dropdown {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 320px;
    padding: 8px;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e4ebda;
    box-shadow: 0 8px 24px rgba(34, 55, 33, 0.12);
    z-index: 25;
}

.header-search__dropdown[hidden] {
    display: none;
}

.header-search.is-open .header-search__dropdown {
    display: block;
}

.header-search__form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.header-search__input {
    flex: 1;
    min-width: 0;
}

.header-search__submit {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: #7fad3c;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s;
}

.header-search__submit:hover {
    background: #6f9a35;
}

.header-profile {
    position: relative;
}

.header__profile {
    display: inline-flex;
    padding: 0;
    border: none;
    background: none;
    color: inherit;
    cursor: pointer;
    line-height: 0;
}

.header-profile__dropdown {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    min-width: 180px;
    padding: 8px;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e4ebda;
    box-shadow: 0 8px 24px rgba(34, 55, 33, 0.12);
    z-index: 25;
}

.header-profile__dropdown[hidden] {
    display: none;
}

.header-profile.is-open .header-profile__dropdown {
    display: block;
}

.header-profile__menu {
    margin: 0;
    padding: 0;
    list-style: none;
}

.header-profile__link {
    display: block;
    padding: 8px 12px;
    border-radius: 6px;
    font-family: var(--third-family);
    font-size: 16px;
    line-height: 140%;
    color: #223721;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}

.header-profile__link:hover {
    background: #f4f1e8;
    color: #7fad3c;
}

/*-----------
Header END
------------*/


/*-----------
Mobile menu START
------------*/

.mobile-menu-wrapper {
    display: none;
}

.burger--wrap {
    padding: 1px;
    transition: 0.3s;
}

.burger {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    position: relative;
    width: 28px;
    height: 28px;
    cursor: pointer;
}

.burger__line {
    width: 86%;
    height: 2px;
    transform: scale(1, 1.2);
    background: #fcfcfc;
    transition: 0.3s;
}

header.hovered .burger__line {
    background: #D4D4D4;
}

.burger.active .burger__line:nth-child(1) {
    transform: scale(1, 1) translate(0, 5px) rotate(45deg);
}

.burger.active .burger__line:nth-child(2) {
    opacity: 0;
}

.burger.active .burger__line:nth-child(3) {
    transform: scale(1, 1) translate(0, -7px) rotate(-45deg);
}

header.hovered .burger--inner {
    background: #5D5D5D;
}

header.opened-menu .header-main {
    height: 420px;
    background: #223721;
}

/*-----------
Mobile menu END
------------*/

/*-----------
Bottom menu START
------------*/

.bottom-menu {
    display: none;
}

@media screen and (max-width: 1080px) {
    .header-main__info {
        display: none;
    }

    .bottom-menu {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 40;
        display: flex;
        align-items: stretch;
        justify-content: space-around;
        gap: 4px;
        padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
        background: #fff;
        border-top: 1px solid #e4ebda;
        box-shadow: 0 -8px 24px rgba(34, 55, 33, 0.08);
        transform: translate3d(0, 0, 0);
        transition: transform 0.28s ease;
        will-change: transform;
    }

    .bottom-menu.is-hidden {
        transform: translate3d(0, 100%, 0);
        pointer-events: none;
    }

    .bottom-menu__item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        min-width: 0;
        padding: 6px 4px;
        border-radius: 10px;
        color: #223721;
        text-decoration: none;
        transition: color 0.2s, background 0.2s;
    }

    .bottom-menu__item:hover,
    .bottom-menu__item:focus-visible,
    .bottom-menu__item.is-active {
        color: #7fad3c;
        background: rgba(127, 173, 60, 0.08);
    }

    .bottom-menu__icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 24px;
        height: 24px;
        line-height: 0;
    }

    .bottom-menu__icon--cart {
        position: relative;
    }

    .bottom-menu__icon--cart .header__cart-count {
        left: auto;
        right: -8px;
        top: -6px;
        width: 16px;
        height: 16px;
        font-size: 10px;
        line-height: 1;
    }

    .bottom-menu__icon svg {
        display: block;
        width: 24px;
        height: 24px;
    }

    .bottom-menu__label {
        font-family: var(--third-family);
        font-size: 11px;
        font-weight: 400;
        line-height: 120%;
        letter-spacing: -0.01em;
        text-align: center;
        white-space: nowrap;
    }

    body {
        padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    }
}

/*-----------
Bottom menu END
------------*/

@media screen and (max-width: 1450px) {
	.header-main__menu nav {
		gap: 18px;
	}

    .header-main>.section-wrap {
        gap: 60px;
    }
}

@media screen and (max-width: 1400px) {
	.header-main .section-wrap {
		gap: 0;
	}
}

@media screen and (max-width: 1280px) {
    .main-menu .menu-level-1 {
        gap: 8px 12px;
    }

    .header-main--right {
        gap: 16px;
    }

    .header-main nav a.main-menu-link {
        padding: 6px;
    }
}

@media screen and (max-width: 1180px) {
    header {
        padding-top: 0;
    }
    
    .header-main {
        padding: 12px 20px 12px;
        width: 100%;
        height: 82px;
        border-radius: 0 0 4px 4px;
        overflow: hidden;
    }

    .header__mobile--wrap nav a {
        padding: 10px;
        overflow: visible;
    }

    /* dropdown профиля: fixed, т.к. .header-main здесь имеет
       overflow:hidden (он скрывает закрытое мобильное меню)
       и обрезал выпадающий список профиля */
    .header-profile__dropdown {
        position: fixed;
        top: 82px;
        right: 12px;
        z-index: 45;
    }

    .main-menu .menu-level-1 {
        gap: 6px;
    }

    .main-menu .menu-item > .main-menu-link {
        font-size: 14px;
    }
}

@media screen and (max-width: 1080px) {
    .header__mobile--wrap nav {
        position: absolute;
        top: calc(100% + 20px);
        display: flex;
        align-items: start;
        flex-direction: column;
        gap: 4px;
        height: auto;
        transform: translateX(-10px);
    }

    .burger {
        display: flex;
    }

    .header__mobile--wrap {
        order: 1;
    }

    .header-main__logo {
        order: 2;
    }

    .header-main--right {
        order: 3;
    }
}

@media screen and (max-width: 770px) {
    .header-main {
        padding: 36px 20px 12px;
    }

    .header-main__logo svg {
        width: 60px;
        height: 34px
    }

    .header-search__dropdown {
        width: min(320px, calc(100vw - 40px));
        right: -8px;
    }

    .header-profile__dropdown {
        right: 0;
        min-width: 160px;
    }
}


/*-----------
Mobile menu: accordion submenu START
------------*/

.submenu__all {
    display: none;
}

@media screen and (max-width: 1080px) {
    /* Панель растёт под содержимое: nav в потоке, высота анимируется max-height */
    .header-main > .section-wrap {
        flex-wrap: wrap;
    }

    .header__mobile--wrap {
        display: contents;
    }

    .header__mobile--wrap .burger {
        order: 1;
    }

    .header-main__logo {
        order: 2;
    }

    .header-main--right {
        order: 3;
    }

    .header__mobile--wrap nav.main-menu {
        position: static;
        transform: none;
        order: 4;
        flex-basis: 100%;
        width: 100%;
        display: block;
        height: auto;
        gap: 0;
        padding: 0;
    }

    .header-main {
        height: auto;
        max-height: 82px;
    }

    header.opened-menu .header-main {
        height: auto;
        max-height: calc(100vh - 20px);
        max-height: calc(100dvh - 20px);
        overflow-y: auto;
        overflow-x: hidden;
    }

    .main-menu .menu-level-1 {
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        padding: 4px 0 14px;
    }

    .main-menu .menu-item > .main-menu-link {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        min-height: 46px;
        padding: 12px 10px;
        border-radius: 8px;
        transition: color 0.25s ease;
    }

    /* Подменю: скрытый аккордеон вместо hover-выпадашки */
    .main-menu .submenu,
    .main-menu .menu-item:hover > .submenu,
    .main-menu .menu-item:focus-within > .submenu {
        position: static;
        min-width: 0;
        max-width: 100%;
        margin: 0;
        padding: 0;
        background: transparent;
        border-radius: 0;
        box-shadow: none;
        display: block;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        visibility: hidden;
        transform: none;
        pointer-events: none;
        transition: max-height 0.4s ease, opacity 0.3s ease, visibility 0.3s ease;
    }

    .main-menu .menu-item.is-open > .submenu,
    .main-menu .menu-item.is-open:hover > .submenu,
    .main-menu .menu-item.is-open:focus-within > .submenu {
        max-height: 800px;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        margin: 2px 0 8px 8px;
        border-left: 1px solid rgba(255, 251, 244, 0.18);
    }

    /* Галочки подменю крупнее на мобильном */
    .main-menu .has-submenu > .main-menu-link::after {
        width: 10px;
        height: 10px;
    }

    /* Открытый родитель: подсветка и разворот стрелки */
    .main-menu .menu-item.is-open > .main-menu-link {
        color: #9dc46a;
    }

    .main-menu .menu-item.is-open > .main-menu-link::after,
    .main-menu .menu-item.is-open:hover > .main-menu-link::after,
    .main-menu .menu-item.is-open:focus-within > .main-menu-link::after {
        transform: translateY(0) rotate(225deg);
    }

    /* Пункты подменю на тёмно-зелёном фоне панели */
    .header-main nav .submenu a.main-menu-link {
        display: block;
        padding: 10px 12px;
        font-size: 15px;
        color: rgba(255, 251, 244, 0.85);
        border-radius: 8px;
    }

    .header-main nav .submenu a.main-menu-link:hover {
        color: #9dc46a;
        background: rgba(255, 251, 244, 0.06);
    }

    /* «Смотреть все» — переход на страницу раздела */
    .submenu__all {
        display: list-item;
    }

    .header-main nav .submenu .submenu__all-link {
        color: #9dc46a;
        font-weight: 600;
    }

    .header-main nav .submenu .submenu__all-link::after {
        content: "\2192"; /* стрелка вправо */
        margin-left: 6px;
    }
}

/*-----------
Mobile menu: accordion submenu END
------------*/

/*-----------
Header favorite icon START
------------*/

.header__favorite {
    position: relative;
    display: inline-flex;
    position: relative;
    color: inherit;
    line-height: 0;
    overflow: unset;
}

.header-favorite .header__favorite-count {
    left: auto;
    right: -4px;
    top: -2px;
}

.header__favorite svg path {
    fill: none;
    stroke: #fff;
}

@media screen and (max-width: 1080px) {
    .bottom-menu__icon--favorite {
        position: relative;
    }

    .bottom-menu__icon--favorite .header__cart-count {
        left: auto;
        right: -8px;
        top: -6px;
        width: 16px;
        height: 16px;
        font-size: 10px;
        line-height: 1;
    }
}

/*-----------
Header favorite icon END
------------*/
