/*
 * ATOM 23.10.2026 — каталог food-fresh.ru: дерево категорий вместо всплывашек по наведению + панель рубрики
 * (чипы подразделов, поиск, «только с ценой», порядок, PDF-прайс). Подключается только при atom_catalog_on() (functions.php).
 * Цвета — из темы: #4eac4c (бренд), #2e7d32 — тот же зелёный темнее для текста и активных состояний (контраст 5,1:1 на белом).
 */

/* ---------- Дерево категорий: слева на рубриках, «Продукция» в шапке, мобильное меню ---------- */
.categories .menu.atom-tree,
.mobile__categories .menu.atom-tree {
    gap: 4px;
    justify-content: flex-start
}

.categories .menu.atom-tree > .menu-item,
.mobile__categories .menu.atom-tree > .menu-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 32px;
    column-gap: 6px;
    align-items: center
}

.atom-tree > .menu-item > a {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    color: inherit;
    text-decoration: none
}

.categories .menu.atom-tree > .menu-item > a:before,
.mobile__categories .menu.atom-tree > .menu-item > a:before {
    top: 50%;
    transform: translateY(-50%)
}

.categories .menu.atom-tree a:after,
.mobile__categories .menu.atom-tree a:after {
    display: none
}

.atom-tree > .menu-item > a:hover {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 4px
}

.atom-tree a:focus-visible,
.atom-tree-tgl:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
    border-radius: 8px
}

.atom-tree .atom-cnt {
    flex: none;
    margin-left: auto;
    min-width: 26px;
    padding: 0 7px;
    border-radius: 999px;
    background: #fff;
    color: #2e7d32;
    font-size: 12px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    font-variant-numeric: tabular-nums
}

.atom-tree-tgl {
    grid-column: 2;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #fff;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: background-color .2s ease-out
}

.atom-tree-tgl:hover {
    background: rgba(255, 255, 255, .16)
}

.atom-tree-tgl svg {
    transition: transform .22s cubic-bezier(.2, .8, .2, 1)
}

.atom-tree > .menu-item.is-open > .atom-tree-tgl svg {
    transform: rotate(90deg)
}

/* подменю — в потоке, под пунктом; всплывашки по наведению выключены */
.categories .menu.atom-tree > .menu-item .sub-menu,
.mobile__categories .menu.atom-tree > .menu-item > .sub-menu {
    grid-column: 1 / -1;
    position: static;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    min-width: 0;
    margin: 4px 0 8px 22px;
    padding: 0 0 0 10px;
    background: none;
    border-radius: 0;
    border-left: 1px solid rgba(255, 255, 255, .45);
    animation: none
}

.categories .menu.atom-tree > .menu-item .sub-menu:before {
    display: none
}

.categories .menu.atom-tree > .menu-item:hover > .sub-menu {
    display: none;
    animation: none
}

.categories .menu.atom-tree > .menu-item.is-open > .sub-menu,
.mobile__categories .menu.atom-tree > .menu-item.is-open > .sub-menu {
    display: flex;
    animation: atomSub .18s cubic-bezier(.2, .8, .2, 1)
}

@keyframes atomSub {
    from {
        opacity: 0;
        transform: translateY(-4px)
    }
}

.categories .menu.atom-tree .sub-menu .menu-item,
.mobile__categories .menu.atom-tree .sub-menu .menu-item {
    width: 100%;
    padding: 0
}

.atom-tree .sub-menu a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.3;
    color: inherit;
    text-decoration: none;
    transition: background-color .15s ease-out
}

.atom-tree .sub-menu a:hover {
    background: rgba(255, 255, 255, .14)
}

.atom-tree .sub-menu .current-menu-item > a,
.atom-tree .sub-menu .current-menu-parent > a,
.atom-tree .sub-menu .current-post-parent > a {
    background: rgba(255, 255, 255, .22);
    font-weight: 600
}

.atom-tree .sub-menu .atom-cnt {
    min-width: 24px;
    font-size: 11px;
    line-height: 18px
}

/* развёрнутое дерево длиннее экрана — прокрутка внутри панели, а не обрезанный низ липкой колонки */
.aside .categories,
.header__nav-btn .categories {
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .55) transparent
}

.mobile__categories-content {
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    overscroll-behavior: contain;
    border-radius: 20px
}

.mobile__categories .menu.atom-tree > .menu-item {
    grid-template-columns: minmax(0, 1fr) 44px
}

.mobile__categories .atom-tree-tgl {
    width: 44px;
    height: 44px
}

.mobile__categories .atom-tree > .menu-item > a {
    min-height: 44px
}

.mobile__categories .atom-tree .sub-menu a {
    min-height: 40px
}

/* ---------- Плитки подразделов: число товаров ---------- */
.atom-tile-cnt {
    margin-top: -6px;
    font-size: 13px;
    line-height: 1.3;
    color: #5d5d5d;
    font-variant-numeric: tabular-nums
}

/* ---------- Панель рубрики ---------- */
.atom-cat-wrap {
    gap: 24px
}

.atom-cat {
    width: 100%;
    display: grid;
    gap: 16px
}

.atom-cat + .category__products {
    margin-top: -26px
}

.atom-cat-wrap .atom-cat + .category__products {
    margin-top: 0
}

.atom-cat__title {
    margin: 0;
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px 12px
}

.atom-cat__total {
    font-size: .6em;
    font-weight: 600;
    color: #5d5d5d;
    font-variant-numeric: tabular-nums
}

.atom-cat__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px
}

.atom-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid rgba(78, 172, 76, .45);
    border-radius: 999px;
    background: #fff;
    color: #2b2b2b;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    transition: background-color .2s ease-out, border-color .2s ease-out, color .2s ease-out
}

.atom-chip:hover {
    border-color: #4eac4c;
    background: #f3faf3
}

.atom-chip:focus-visible,
.atom-cat__price:focus-visible,
.atom-cat__pdf:focus-visible,
.atom-cat__reset:focus-visible {
    outline: 2px solid #2e7d32;
    outline-offset: 2px
}

.atom-chip__n {
    font-size: 13px;
    font-weight: 500;
    color: #5d5d5d;
    font-variant-numeric: tabular-nums
}

.atom-chip.is-active {
    border-color: #2e7d32;
    background: #2e7d32;
    color: #fff
}

.atom-chip.is-active .atom-chip__n {
    color: #fff
}

.atom-chip--up {
    gap: 6px;
    padding-left: 10px;
    border-color: transparent;
    background: #f3f3f3
}

.atom-chip--up:hover {
    border-color: transparent;
    background: #e9f4e9
}

.atom-cat__bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px
}

.atom-cat:not(.is-ready) .atom-cat__js {
    visibility: hidden
}

.atom-cat__search {
    flex: 1 1 260px;
    max-width: 400px;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 48px;
    padding: 0 16px;
    border: 1px solid #d9d9d9;
    border-radius: 25px;
    background: #fff;
    color: #5d5d5d;
    cursor: text;
    transition: border-color .2s ease-out
}

.atom-cat__search:focus-within {
    border-color: #4eac4c;
    outline: 2px solid #2e7d32;
    outline-offset: 2px
}

.atom-cat__search svg {
    flex: none
}

.atom-cat__q {
    flex: 1;
    min-width: 0;
    height: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    font: inherit;
    font-size: 15px;
    color: #2b2b2b
}

.atom-cat__q::placeholder {
    color: #6b6b6b;
    opacity: 1
}

.atom-cat__price {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 48px;
    padding: 0 18px 0 12px;
    border: 1px solid #d9d9d9;
    border-radius: 25px;
    background: #fff;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    color: #2b2b2b;
    cursor: pointer;
    transition: border-color .2s ease-out, background-color .2s ease-out
}

.atom-cat__short {
    display: none
}

.atom-cat__price:hover {
    border-color: #4eac4c
}

.atom-cat__price[aria-pressed="true"] {
    border-color: #2e7d32;
    background: #f3faf3
}

.atom-cat__sw {
    position: relative;
    flex: none;
    width: 34px;
    height: 20px;
    border-radius: 999px;
    background: #bdbdbd;
    transition: background-color .2s ease-out
}

.atom-cat__sw:after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
    transition: transform .22s cubic-bezier(.2, .8, .2, 1)
}

.atom-cat__price[aria-pressed="true"] .atom-cat__sw {
    background: #2e7d32
}

.atom-cat__price[aria-pressed="true"] .atom-cat__sw:after {
    transform: translateX(14px)
}

.atom-cat__sort {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 48px;
    padding: 0 6px 0 16px;
    border: 1px solid #d9d9d9;
    border-radius: 25px;
    background: #fff;
    font-size: 15px;
    color: #5d5d5d;
    transition: border-color .2s ease-out
}

.atom-cat__sort:hover {
    border-color: #4eac4c
}

.atom-cat__sort:focus-within {
    outline: 2px solid #2e7d32;
    outline-offset: 2px
}

.atom-cat__sort select {
    height: 100%;
    padding: 0 30px 0 0;
    border: 0;
    outline: 0;
    background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%232e7d32' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 8px center;
    font: inherit;
    font-weight: 600;
    color: #2b2b2b;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer
}

.atom-cat__pdf {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 48px;
    padding: 0 20px 0 16px;
    border-radius: 25px;
    background: #eaf5ea;
    color: #1f5f22;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.15;
    text-decoration: none;
    transition: background-color .2s ease-out
}

.atom-cat__pdf:hover {
    background: #dcefdc
}

.atom-cat__pdf svg {
    flex: none
}

.atom-cat__pdf small {
    display: block;
    font-size: 12px;
    font-weight: 400;
    color: #33613a
}

.atom-cat__count {
    margin: 0;
    font-size: 14px;
    color: #5d5d5d
}

.atom-cat__count b {
    color: #2b2b2b;
    font-variant-numeric: tabular-nums
}

.category__products-product[hidden] {
    display: none
}

.atom-cat__empty {
    width: 100%;
    padding: 32px 24px;
    border: 1px dashed rgba(78, 172, 76, .55);
    border-radius: 20px;
    text-align: center;
    font-size: 16px;
    line-height: 1.5
}

.atom-cat__empty[hidden] {
    display: none
}

.atom-cat__empty p {
    margin: 0
}

.atom-cat__reset {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-weight: 600;
    color: #2e7d32;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer
}

@media screen and (max-width: 640px) {
    .atom-cat__chips {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 4px;
        scroll-snap-type: x proximity;
        scrollbar-width: none;
        -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent);
        mask-image: linear-gradient(90deg, #000 88%, transparent)
    }

    .atom-cat__chips::-webkit-scrollbar {
        display: none
    }

    .atom-chip {
        flex: none;
        min-height: 44px;
        scroll-snap-align: start
    }

    .atom-cat__bar {
        gap: 10px
    }

    .atom-cat__search {
        flex-basis: 100%;
        max-width: none;
        height: 46px
    }

    .atom-cat__price,
    .atom-cat__sort {
        flex: 1 1 0;
        min-width: 0;
        height: 46px;
        font-size: 14px
    }

    .atom-cat__price {
        justify-content: center;
        padding: 0 12px
    }

    .atom-cat__long {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap
    }

    .atom-cat__short {
        display: inline
    }

    .atom-cat__sort > span {
        display: none
    }

    .atom-cat__sort select {
        width: 100%
    }

    .atom-cat__pdf {
        flex-basis: 100%;
        justify-content: center;
        margin-left: 0;
        height: 46px
    }

    .atom-cat + .category__products {
        margin-top: 0
    }
}

@media (prefers-reduced-motion: reduce) {
    .atom-tree-tgl svg,
    .atom-cat__sw,
    .atom-cat__sw:after {
        transition: none
    }

    .categories .menu.atom-tree > .menu-item.is-open > .sub-menu,
    .mobile__categories .menu.atom-tree > .menu-item.is-open > .sub-menu {
        animation: none
    }
}
