/* Фильтр каталога Wyatboat (layout wyatfilter) */

.wf-filter {
    background: #212229;
    border-radius: 30px;
    color: #fff;
    font-size: 16px;
}

.wf-head {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 26px;
    transition: padding .3s ease;
}

.wf-filter.wf-open .wf-head {
    padding: 22px 28px 4px;
}

.wf-toggle,
.wf-toggle:hover,
.wf-toggle:focus,
.wf-toggle:active {
    /* сброс глобальных стилей button{...}/button:hover{...} из template.css */
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    background: none;
    border: none;
    border-radius: 0;
    color: #fff;
    font-family: inherit;
    font-size: 18px;
    font-weight: 500;
    text-align: left;
    padding: 0;
    cursor: pointer;
    min-width: 0;
    outline: none;
}

.wf-toggle:focus-visible {
    outline: 2px solid rgba(255, 255, 255, .45);
    outline-offset: 6px;
    border-radius: 10px;
}

.wf-toggle-icon {
    flex: none;
}

.wf-toggle-badge {
    background: #2d43f6;
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    font-variant-numeric: tabular-nums;
}

.wf-toggle-badge[hidden] {
    display: none;
}

.wf-chevron {
    flex: none;
    margin-left: auto;
    transition: transform .3s ease;
}

.wf-filter.wf-open .wf-chevron {
    transform: rotate(180deg);
}

/* в закрытом состоянии убираем совсем, чтобы пилюля была компактной */
.wf-reset {
    display: none !important;
}

.wf-filter.wf-open.wf-has-selection .wf-reset {
    flex: none;
    display: inline !important;
    font-size: 13px;
    color: rgba(255, 255, 255, .55) !important;
    text-decoration: underline !important;
    text-underline-offset: 3px;
    white-space: nowrap;
}

/* строка "найдено N моделей" */
.wf-found {
    font-size: 13.5px;
    color: rgba(255, 255, 255, .55);
    padding-bottom: 4px;
    font-variant-numeric: tabular-nums;
}

.wf-found:empty {
    display: none;
}

.wf-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height .35s ease;
    /* display:none обязателен: иначе скрытое содержимое панели участвует в
       расчёте max-content и закрытая пилюля растягивается на всю колонку */
    display: none;
}

.wf-filter.wf-open .wf-body,
.wf-filter.wf-closing .wf-body {
    display: block;
}

.wf-body .wf-form {
    padding: 0 28px 28px;
}

.wf-block {
    padding: 18px 0;
    border-top: 1px solid rgba(255, 255, 255, .08);
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .25s ease, transform .25s ease;
}

/* .wf-found — тоже div, поэтому :first-of-type первому блоку уже не достаётся */
.wf-block:first-of-type,
.wf-found + .wf-block {
    border-top: none;
}

.wf-filter.wf-open .wf-block {
    opacity: 1;
    transform: translateY(0);
}

.wf-filter.wf-open .wf-block:nth-child(1) { transition-delay: .04s; }
.wf-filter.wf-open .wf-block:nth-child(2) { transition-delay: .08s; }
.wf-filter.wf-open .wf-block:nth-child(3) { transition-delay: .12s; }
.wf-filter.wf-open .wf-block:nth-child(4) { transition-delay: .16s; }
.wf-filter.wf-open .wf-block:nth-child(5) { transition-delay: .20s; }
.wf-filter.wf-open .wf-block:nth-child(6) { transition-delay: .24s; }
.wf-filter.wf-open .wf-block:nth-child(7) { transition-delay: .28s; }

@media (prefers-reduced-motion: reduce) {
    .wf-block {
        transition: none;
        opacity: 1;
        transform: none;
    }

    .wf-body {
        transition: none;
    }
}

.wf-title {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 14px;
}

.wf-title small {
    color: rgba(255, 255, 255, .55);
    font-weight: 400;
    font-size: 13px;
}

/* чекбоксы */
.wf-checks {
    display: flex;
    flex-direction: column;
    gap: 11px;
}

.wf-checks-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 11px 6px;
}

.wf-checks label {
    display: flex;
    align-items: center;
    gap: 11px;
    font-size: 14.5px;
    cursor: pointer;
    line-height: 1.25;
}

.wf-checks input {
    display: none;
}

.wf-box {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 1.5px solid rgba(255, 255, 255, .35);
    flex: none;
    display: inline-grid;
    place-items: center;
    transition: background .15s, border-color .15s;
}

.wf-checks input:checked + .wf-box {
    background: #2d43f6;
    border-color: #2d43f6;
}

.wf-checks input:checked + .wf-box::before {
    content: "";
    width: 10px;
    height: 6px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg) translate(1px, -1px);
}

.wf-cnt {
    color: rgba(255, 255, 255, .45);
    font-size: 12.5px;
    margin-left: auto;
    font-variant-numeric: tabular-nums;
}

/* значение выбрано, но по текущей комбинации фильтров сейчас нет в наличии —
   оставляем видимым (чтобы можно было снять), но приглушаем */
.wf-unavailable {
    opacity: .4;
}

.wf-checks label.wf-unavailable .wf-cnt {
    font-size: 11.5px;
}

/* чипы */
.wf-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.wf-chips label {
    cursor: pointer;
}

.wf-chips input {
    display: none;
}

.wf-chips span {
    display: inline-block;
    min-width: 44px;
    text-align: center;
    padding: 8px 14px;
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, .25);
    font-size: 14px;
    transition: background .15s, border-color .15s;
}

.wf-chips input:checked + span {
    background: #2d43f6;
    border-color: #2d43f6;
}

/* слайдеры (noUiSlider) */
.wf-slider {
    margin: 8px 9px 16px;
    height: 4px;
}

.wf-filter .noUi-target {
    background: rgba(255, 255, 255, .15);
    border: none;
    box-shadow: none;
    height: 4px;
    border-radius: 2px;
}

.wf-filter .noUi-connect {
    background: #2d43f6;
}

.wf-filter .noUi-horizontal .noUi-handle {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .5);
    right: -9px;
    top: -7px;
    cursor: grab;
}

.wf-filter .noUi-handle::before,
.wf-filter .noUi-handle::after {
    display: none;
}

.wf-range-inputs {
    display: flex;
    gap: 10px;
}

.wf-range-inputs label {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #191a20;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 14px;
    padding: 9px 14px;
    font-size: 13px;
    color: rgba(255, 255, 255, .55);
}

/* .wf-filter впереди — template.css грузится прямым <link> после head,
   поэтому при равной специфичности input[type="text"] побеждал и лепил
   свои padding: 20px 24px / border-radius: 30px внутрь поля */
.wf-filter .wf-range-inputs input {
    -webkit-appearance: none;
    appearance: none;
    display: block;
    width: 100%;
    min-width: 0;
    height: auto;
    min-height: 0;
    padding: 0;
    margin: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    outline: none;
    box-shadow: none;
    color: #fff;
    font-size: 14px;
    line-height: 1.3;
    font-family: inherit;
    font-variant-numeric: tabular-nums;
}

.wf-range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 13.5px;
    color: rgba(255, 255, 255, .8);
}

/*
 * Режим «оверлей»: на витрине «Модельный ряд» без активного фильтра рядом
 * с панелью нет сетки товаров, и раскрытие в потоке просто распирало пустой
 * блок, утаскивая категории вниз. Здесь панель раскрывается поверх контента.
 */
.category-main.has-wf-filter .filter-right {
    position: relative;
}

@media (min-width: 901px) {
    /*
     * Витрина «Модельный ряд» (.wf-bar): фильтр — широкая полоса над товарами.
     * Закрыт — компактная пилюля справа; открыт — блок раскрывается во всю
     * ширину прямо в потоке (ничего не перекрывает), товары остаются в 3 колонки.
     */
    .category-main.has-wf-filter.wf-bar .filter-right {
        grid-column: 1 / -1;
        grid-row: 1;
    }

    .category-main.has-wf-filter.wf-bar .category-items,
    .category-main.has-wf-filter.wf-bar.wf-panel-open .category-items {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .category-main.has-wf-filter.wf-bar.wf-panel-open .category-items.grid-columns-3 {
        grid-template-columns: repeat(3, 1fr);
    }

    .category-main.has-wf-filter.wf-bar.wf-panel-open .wf-filter {
        width: 100%;
    }

    /* блоки в ряд — иначе на всю ширину получится пустая простыня */
    .category-main.wf-bar .wf-filter .wf-form {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
        gap: 0 34px;
        padding: 8px 30px 26px;
        align-items: start;
    }

    .category-main.wf-bar .wf-block {
        border-top: none;
        padding: 18px 0 4px;
    }

    .category-main.wf-bar .wf-found {
        grid-column: 1 / -1;
        padding: 18px 0 12px;
        border-bottom: 1px solid rgba(255, 255, 255, .08);
    }

    /* в узкой колонке мощность шла в 2 столбца — в широкой полосе это лишнее */
    .category-main.wf-bar .wf-checks-cols {
        grid-template-columns: 1fr;
    }

    /* полоса не липнет к экрану — она часть потока */
    .category-main.has-wf-filter.wf-bar.wf-panel-open .filter-right {
        position: static;
        max-height: none;
        overflow: visible;
    }
}

.wf-filter.wf-overlay .wf-body {
    /* высоту задаёт JS с ограничением по экрану */
    overscroll-behavior: contain;
}

/* подпись категории на карточке в общей выдаче каталога */
.catalog-item-cat {
    font-size: 12.5px;
    line-height: 1.2;
    color: rgba(255, 255, 255, .45);
    margin-bottom: 6px;
}

/* состояние загрузки товаров */
.category-items.wf-loading {
    opacity: .4;
    pointer-events: none;
    transition: opacity .2s;
}

/* мобильный каталог-лендинг: фильтр в каждом блоке категории не нужен */
.pack-category-products .filter-right {
    display: none;
}

/*
 * Раскладка категории (mobile-first).
 *
 * Мобильные: фильтр всегда во всю ширину над товарами, сетка товаров
 * не меняется при открытии панели (остаётся такой, какой её задал шаблон).
 *
 * Десктоп (>900px): .category-main — CSS-грид 3×N.
 *   закрыто — кнопка отдельной строкой над товарами (row 1, col 3),
 *             товары под ней во всю ширину в 3 колонки (row 2);
 *   открыто — панель остаётся на своём месте (row 1, col 3), а товары
 *             поднимаются к ней в ту же строку и сжимаются до 2 колонок.
 * Панель буквально раскрывается "вместо третьей колонки", кнопка при этом
 * не прыгает — минимум движения на экране.
 */
.category-main.has-wf-filter {
    display: flex;
    flex-direction: column;
}

.category-main.has-wf-filter .filter-right {
    order: -1;
    width: 100%;
    position: static;
    margin-bottom: 20px;
}

.category-main.has-wf-filter .category-items {
    width: 100%;
}

@media (min-width: 901px) {
    .category-main.has-wf-filter {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 30px;
        align-items: start;
    }

    /* width:100% + justify-self:stretch обязательны: при width:auto грид-элемент
       ужимается по max-content своего содержимого, и на категориях с небольшим
       числом/узкими карточками сетка вставала уже контейнера и центрировалась */
    .category-main.has-wf-filter .filter-right {
        order: 0;
        grid-column: 3;
        grid-row: 1;
        width: 100%;
        justify-self: stretch;
        margin-bottom: 0;
    }

    .category-main.has-wf-filter .category-items {
        grid-column: 1 / -1;
        grid-row: 2;
        width: 100%;
        justify-self: stretch;
    }

    /* закрытая кнопка — компактная пилюля, прижата к правому краю */
    .category-main.has-wf-filter .wf-filter {
        width: -moz-fit-content;
        width: fit-content;
        margin-left: auto;
    }

    /* .category.inner имеет overflow:hidden (гасит горизонтальный вылет баннера),
       а он создаёт контейнер прокрутки и убивает sticky. overflow-x:clip клипает
       так же, но контейнер прокрутки не создаёт. :has() ограничивает правило
       страницами с фильтром; в браузерах без :has() правило просто игнорируется */
    .category.inner:has(.category-main.has-wf-filter) {
        overflow-x: clip;
        overflow-y: visible;
    }

    /* открытая панель едет за прокруткой; 96px — высота фиксированной шапки (80) + отступ.
       Область прилипания = строка грида, а она высотой со всю сетку товаров */
    .category-main.has-wf-filter.wf-panel-open .filter-right {
        position: sticky;
        top: 96px;
        align-self: start;
        max-height: calc(100vh - 120px);
        overflow-y: auto;
        scrollbar-width: thin;
        scrollbar-color: rgba(255, 255, 255, .25) transparent;
    }

    .category-main.has-wf-filter.wf-panel-open .filter-right::-webkit-scrollbar {
        width: 6px;
    }

    .category-main.has-wf-filter.wf-panel-open .filter-right::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, .25);
        border-radius: 3px;
    }

    .category-main.has-wf-filter.wf-panel-open .category-items {
        grid-column: 1 / 3;
        grid-row: 1;
    }

    .category-main.has-wf-filter.wf-panel-open .category-items.grid-columns-3 {
        grid-template-columns: repeat(2, 1fr);
    }

    .category-main.has-wf-filter.wf-panel-open .wf-filter {
        width: 100%;
    }
}
