/*
 * Фильтр каталога.
 *
 * На широком экране — карточка над списком, на узком — выезжающая слева
 * панель (её открывает showFilter() из script.js по классу open-filter).
 * Класс .filter-wrap оставлен ради этой связки, остальное своё, с fl-.
 */

.fl {
    --fl-ink: #14132B;
    --fl-muted: #77768F;
    --fl-line: #EAEAF3;
    --fl-soft: #F6F6FB;
    --fl-brand: #4F4BFF;
    --fl-brand-light: #6C69FF;

    font-family: 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif;
    color: var(--fl-ink);
    margin-bottom: 22px;
}

.fl *,
.fl *::before,
.fl *::after {
    box-sizing: border-box;
}

.fl :focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 75, 255, .3);
    border-radius: 10px;
}

.fl__panel {
    background: #fff;
    border: 1px solid var(--fl-line);
    border-radius: 22px;
    box-shadow: 0 24px 48px -34px rgba(20, 19, 43, .5);
    padding: 20px 22px;
}

/* Заголовок нужен только выехавшей панели. */
.fl__head {
    display: none;
    align-items: center;
    gap: 10px;
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--fl-line);
}

.fl__title {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -.02em;
}

.fl__badge {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: linear-gradient(135deg, #6C69FF, #4F4BFF);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

.fl__close {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    margin-left: auto;
    border: 1px solid var(--fl-line);
    border-radius: 12px;
    background: #fff;
    color: var(--fl-muted);
    cursor: pointer;
    transition: color .18s ease, border-color .18s ease, transform .18s ease;
}

.fl__close:hover {
    color: var(--fl-brand);
    border-color: #C9C7FF;
    transform: rotate(90deg);
}

.fl__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 18px 20px;
}

/* ── Поле ─────────────────────────────────────────────────────────── */

.fl-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    margin: 0;
}

.fl-field__label {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--fl-muted);
}

.fl-field__unit {
    font-size: 10.5px;
    letter-spacing: .04em;
    color: #A9A8BE;
    text-transform: none;
}

/* Выбор метро */

.fl-select {
    position: relative;
    display: flex;
    align-items: center;
}

.fl-select select {
    width: 100%;
    height: 44px;
    padding: 0 34px 0 14px;
    border: 1px solid var(--fl-line);
    border-radius: 13px;
    background: var(--fl-soft);
    font-family: inherit;
    font-size: 14px;
    color: var(--fl-ink);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    cursor: pointer;
    transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}

.fl-select select:hover {
    border-color: #C9C7FF;
}

.fl-select select:focus {
    outline: none;
    background: #fff;
    border-color: var(--fl-brand-light);
    box-shadow: 0 0 0 3px rgba(79, 75, 255, .14);
}

.fl-select svg {
    position: absolute;
    right: 14px;
    color: var(--fl-muted);
    pointer-events: none;
}

/* ── Диапазон ─────────────────────────────────────────────────────── */

.fl-range__values {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fl-num {
    width: 100%;
    min-width: 0;
    height: 40px;
    padding: 0 8px;
    border: 1px solid var(--fl-line);
    border-radius: 12px;
    background: var(--fl-soft);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    color: var(--fl-ink);
    font-variant-numeric: tabular-nums;
    transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
    -moz-appearance: textfield;
}

.fl-num::-webkit-outer-spin-button,
.fl-num::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.fl-num:focus {
    outline: none;
    background: #fff;
    border-color: var(--fl-brand-light);
    box-shadow: 0 0 0 3px rgba(79, 75, 255, .14);
}

.fl-range__dash {
    flex: 0 0 auto;
    color: #C2C1D4;
}

.fl-range__slider {
    position: relative;
    height: 22px;
    display: flex;
    align-items: center;
    padding: 0 9px;
}

.fl-range__track {
    position: absolute;
    left: 0;
    right: 0;
    height: 4px;
    border-radius: 999px;
    background: #E7E7F0;
}

.fl-range__fill {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 999px;
    background: linear-gradient(90deg, #6C69FF, #4F4BFF);
}

/* Два ползунка лежат друг на друге: событиям доступны только «шарики». */
.fl-range__input {
    position: absolute;
    left: 0;
    width: 100%;
    height: 22px;
    margin: 0;
    padding: 0;
    background: none;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
}

.fl-range__input::-webkit-slider-thumb {
    -webkit-appearance: none;
    pointer-events: auto;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 5px solid var(--fl-brand);
    box-shadow: 0 2px 6px rgba(20, 19, 43, .28);
    cursor: grab;
    transition: transform .15s ease, border-color .15s ease;
}

.fl-range__input::-webkit-slider-thumb:hover {
    transform: scale(1.12);
}

.fl-range__input:active::-webkit-slider-thumb {
    cursor: grabbing;
    border-color: var(--fl-brand-light);
}

.fl-range__input::-moz-range-thumb {
    pointer-events: auto;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 5px solid var(--fl-brand);
    box-shadow: 0 2px 6px rgba(20, 19, 43, .28);
    cursor: grab;
}

.fl-range__input::-moz-range-track {
    background: none;
}

/* ── Кнопки ───────────────────────────────────────────────────────── */

.fl__actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
}

.fl-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 24px;
    border: 0;
    border-radius: 14px;
    font-family: inherit;
    font-size: 14.5px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease, color .18s ease, border-color .18s ease;
}

.fl-btn--primary {
    color: #fff;
    background: linear-gradient(135deg, #6C69FF 0%, #4F4BFF 100%);
    box-shadow: 0 16px 32px -16px rgba(79, 75, 255, .95);
}

.fl-btn--primary:hover {
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 20px 38px -16px rgba(79, 75, 255, 1);
}

.fl-btn--primary:active {
    transform: scale(.99);
}

.fl-btn--ghost {
    color: var(--fl-muted);
    background: #fff;
    border: 1px solid var(--fl-line);
}

.fl-btn--ghost:hover {
    color: var(--fl-brand);
    border-color: #C9C7FF;
}

/* На широком экране счётчик условий заменяет значок из заголовка. */
.fl__summary {
    margin-left: auto;
    font-size: 13px;
    font-weight: 600;
    color: var(--fl-muted);
}

/* Сбрасывать нечего — кнопка есть, но не зовёт. */
.fl-btn--off {
    opacity: .45;
    pointer-events: none;
}

/* ── Экраны ───────────────────────────────────────────────────────── */

/* Старые правила делали фильтр выезжающей панелью уже с 1200px, хотя
   кнопки, которая её открывает, там ещё нет. Возвращаем карточку. */
@media (max-width: 1199px) {
    .filter-wrap.fl {
        position: static;
        display: block;
        width: auto;
        max-width: none;
        padding: 0;
        overflow: visible;
        transform: none;
        visibility: visible;
        background: none;
    }
}

@media (max-width: 991px) {
    .filter-wrap.fl {
        position: fixed;
        z-index: 60;
        top: 0;
        left: 0;
        bottom: 0;
        width: 420px;
        max-width: 92%;
        margin: 0;
        background: #fff;
        border-radius: 0 22px 22px 0;
        box-shadow: 40px 0 100px -60px rgba(20, 19, 43, .95);
        transform: translateX(-101%);
        visibility: hidden;
        transition: transform .32s cubic-bezier(.2, .8, .2, 1), visibility .32s;
        overflow: hidden;
    }

    .filter-wrap.fl.open-filter {
        transform: none;
        visibility: visible;
    }

    .fl__panel {
        display: flex;
        flex-direction: column;
        height: 100%;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
    }

    .fl__head {
        display: flex;
    }

    .fl__grid {
        flex: 1 1 auto;
        overflow-y: auto;
        overscroll-behavior: contain;
        grid-template-columns: minmax(0, 1fr);
        gap: 18px;
        padding-bottom: 8px;
        scrollbar-width: thin;
    }

    .fl__actions {
        margin-top: 16px;
        padding-top: 14px;
        border-top: 1px solid var(--fl-line);
    }

    .fl-btn {
        flex: 1 1 auto;
        padding: 0 14px;
    }

    .fl__summary {
        display: none;
    }
}

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