/*
 * SHARNIR-STUB: menu settings are at the top of SharnirMenu in MODX.
 * Shared RU shop/account pages are temporary; this file has no resource IDs.
 * Uses sharnir.css colours and the existing transparent/scrolled header.
 */

.sh-menu {
    gap: 2px;
    min-width: 0;
}

.sh-menu__item {
    position: relative;
    flex: 0 0 auto;
}

.sh-menu__group {
    position: relative;
    height: 100%;
}

.sh-menu .main-nav__link {
    gap: 9px;
    min-height: 44px;
    height: 100%;
    padding-inline: clamp(10px, 1vw, 16px);
    border-radius: 0;
    white-space: nowrap;
}

.sh-menu__trigger {
    list-style: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.sh-menu__trigger::-webkit-details-marker {
    display: none;
}

.sh-menu__trigger::marker {
    content: "";
}

.sh-menu__chevron {
    width: 14px;
    height: 14px;
    flex: 0 0 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    transition: transform var(--transition, 0.25s ease);
}

.sh-menu__group[open] > .sh-menu__trigger .sh-menu__chevron {
    transform: rotate(180deg);
}

.sh-menu .sh-menu__panel {
    position: absolute;
    z-index: 5;
    top: 100%;
    left: 0;
    width: 280px;
    max-width: calc(100vw - 40px);
    margin: 0;
    padding: 8px;
    list-style: none;
    background: var(--color-bg, #f3f5f3);
    color: var(--color-text, #282d2b);
    border: 1px solid rgba(22, 75, 59, 0.2);
    border-top: 2px solid var(--color-orange, #f96900);
    border-radius: 0;
    box-shadow: 0 12px 28px rgba(16, 47, 39, 0.12);
}

.sh-menu__group[data-menu-group="account"] > .sh-menu__panel {
    right: 0;
    left: auto;
}

.sh-menu__cart-text {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.sh-menu [data-sharnir-cart-count][hidden] {
    display: none;
}

.sh-menu__subitem {
    display: block;
    margin: 0;
    padding: 0;
}

.sh-menu .sh-menu__sublink {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 46px;
    margin: 0;
    padding: 12px 14px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--color-text, #282d2b);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.45;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    overflow-wrap: anywhere;
    transition:
        color var(--transition, 0.25s ease),
        background-color var(--transition, 0.25s ease);
}

.sh-menu .sh-menu__sublink:hover,
.sh-menu .sh-menu__sublink:focus-visible,
.sh-menu .sh-menu__subitem.active > .sh-menu__sublink {
    background: var(--color-green, #164b3b);
    color: var(--color-white, #fff);
}

.sh-menu .main-nav__link:focus-visible,
.sh-menu .sh-menu__sublink:focus-visible {
    outline: 2px solid var(--color-orange, #f96900);
    outline-offset: -3px;
}

.sh-menu__logout {
    margin-top: 7px;
    padding-top: 7px;
    border-top: 1px solid rgba(22, 75, 59, 0.18);
}

.sh-menu__logout form {
    margin: 0;
}

/* Only the header with this menu is affected; the footer keeps its own rules. */
.site-header:has(.sh-menu) .language-switch__link {
    border-radius: 0;
}

@media (min-width: 981px) {
    /* The underline follows the label width; the arrow and gap stay outside it. */
    .sh-menu .sh-menu__trigger::after {
        content: none;
        display: none;
    }

    .sh-menu__trigger > span {
        position: relative;
        display: inline-flex;
        align-self: stretch;
        align-items: center;
    }

    .sh-menu__trigger > span::after {
        content: "";
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        height: 3px;
        background: var(--color-orange, #f96900);
        transform: scaleX(0);
        transform-origin: center;
        transition: transform var(--transition, 0.25s ease);
    }

    .sh-menu__trigger:hover > span::after,
    .sh-menu__trigger:focus-visible > span::after,
    .sh-menu__item.active > .sh-menu__group > .sh-menu__trigger > span::after,
    .sh-menu__group[open] > .sh-menu__trigger > span::after {
        transform: scaleX(1);
    }

    .sh-menu__item.active > .sh-menu__group > .sh-menu__trigger {
        color: var(--color-green, #164b3b);
    }

    /* SHARNIR-MENU-SUPPLY-UI-1: follow the same scroll progress as the header. */
    .sharnir-overlay-header
    .sh-menu__item.active > .sh-menu__group > .sh-menu__trigger {
        color: var(--color-white, #fff);
        color: color-mix(
            in srgb,
            var(--color-white, #fff),
            var(--color-green, #164b3b) var(--header-scroll-percent, 0%)
        );
        transition: none;
    }
}

@media (min-width: 981px) and (max-width: 1180px) {
    .sh-menu .main-nav__link {
        padding-inline: 9px;
        font-size: 13px;
    }

    .main-nav:has(.sh-menu) .main-nav__language {
        margin-left: 10px;
    }
}

@media (max-width: 980px) {
    .main-nav:has(.sh-menu) {
        max-height: calc(100vh - var(--header-height, 70px));
        max-height: calc(100dvh - var(--header-height, 70px));
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .sh-menu .main-nav__link {
        justify-content: space-between;
        min-height: 52px;
        height: auto;
        padding: 12px 0;
        font-size: 15px;
        white-space: normal;
    }

    .sh-menu__group {
        height: auto;
    }

    .sh-menu .sh-menu__panel {
        position: static;
        width: 100%;
        max-width: none;
        margin: 0 0 8px;
        padding: 6px 0 6px 14px;
        border: 0;
        border-left: 2px solid var(--color-orange, #f96900);
        background: transparent;
        box-shadow: none;
    }

    .sh-menu .sh-menu__sublink {
        min-height: 48px;
        padding: 11px 12px;
    }

    .sharnir-overlay-header .sh-menu .sh-menu__trigger,
    .sharnir-overlay-header .sh-menu .sh-menu__link {
        color: var(--color-text, #282d2b);
    }

    .sharnir-overlay-header .sh-menu__item.active > .sh-menu__group > .sh-menu__trigger {
        color: var(--color-green, #164b3b);
    }

    .main-nav:has(.sh-menu) .main-nav__language {
        padding-inline: var(--container-padding, 20px);
    }
}

/* Узкая шапка: логотип, телефон и кнопка меню в одну строку. */
@media (max-width: 480px) {
    .site-header:has(.sh-menu) .site-header__inner {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) 44px;
        grid-template-rows: auto;
        align-items: center;
        align-content: center;
        column-gap: 6px;
        padding-inline: clamp(10px, 3vw, 14px);
    }

    .site-header:has(.sh-menu) .site-brand {
        grid-column: 1;
        grid-row: 1;
        gap: 5px;
        justify-self: start;
    }

    .site-header:has(.sh-menu) .site-brand__logo {
        width: clamp(24px, 6vw, 28px);
        height: clamp(24px, 6vw, 28px);
        flex-shrink: 0;
    }

    .site-header:has(.sh-menu) .site-brand__name {
        font-size: clamp(17px, 4.5vw, 21px);
        white-space: nowrap;
    }

    .site-header:has(.sh-menu) .header-phone {
        grid-column: 2;
        grid-row: 1;
        justify-self: end;
        height: 44px;
        margin: 0;
        padding: 0;
        gap: 3px;
        border-color: transparent;
        font-size: clamp(10px, 2.8vw, 12px);
        line-height: 1;
        white-space: nowrap;
    }

    .site-header:has(.sh-menu) .header-phone__number {
        white-space: nowrap;
    }

    .site-header:has(.sh-menu) .header-phone__icon {
        width: 11px;
        height: 11px;
        flex: 0 0 11px;
    }

    .site-header:has(.sh-menu) .menu-toggle {
        grid-column: 3;
        grid-row: 1;
        width: 44px;
        height: 44px;
        margin: 0;
        justify-self: end;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sh-menu *,
    .sh-menu *::after {
        transition: none !important;
    }
}
