/*
 * Каталог проектов. Контрольные ширины макета: 1920, 1440, 990, 375.
 * Слева фильтр 330px, справа полоса с чипами и сортировкой и две колонки
 * карточек; на 990 фильтр 272px; на мобильном фильтр — панель по кнопке.
 */

.w-crumbs {
    margin-top: 60px;
    color: #1e2529;
    font-size: 14px;
    line-height: 1;
}

.w-crumbs__link { color: inherit; text-decoration: none; }
.w-crumbs__link:hover { color: var(--w-green); }
.w-crumbs__current { color: #8b8b8b; }

.w-catalog__title {
    margin: 40px 0 0;
    color: var(--w-ink);
    font-family: var(--w-font-display);
    font-size: 60px;
    font-weight: 400;
    line-height: 1;
    text-transform: uppercase;
}

.w-catalog {
    position: relative;
    display: grid;
    grid-template-columns: 330px 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
        "filter bar"
        "filter grid";
    gap: 19px 30px;
    margin: 30px 0 130px;
    align-items: start;
}

/* Форма оборачивает панель и фильтр, но не участвует в сетке. */
.w-catalog__form { display: contents; }

.w-catalog__bar {
    grid-area: bar;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 36px;
}

.w-catalog__grid {
    grid-area: grid;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.w-catalog__empty {
    grid-column: 1 / -1;
    margin: 20px 0;
    color: #535353;
    font-size: 16px;
}

.w-catalog__empty a { color: var(--w-green); }

/* --- Чипы этажности --- */
.w-chips { display: flex; gap: 10px; }

.w-chips__item { cursor: pointer; }

.w-chips__item input,
.w-filter__tab input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    clip: rect(0 0 0 0);
    overflow: hidden;
}

.w-chips__item span {
    display: inline-flex;
    align-items: center;
    height: 36px;
    padding: 0 12px;
    border-radius: 40px;
    background: #e8e8e8;
    color: #242424;
    font-size: 16px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
}

/*
 * Чип, за которым стоит посадочная страница: снаружи это та же кнопка,
 * но ведёт она по своему адресу. Вид намеренно общий с переключателями —
 * для посетителя жест один и тот же, и разное оформление в одном ряду
 * сбивало бы с толку.
 */
a.w-chips__item { text-decoration: none; }

a.w-chips__item:hover span { background: #dcdcdc; }

a.w-chips__item:focus-visible span { outline: 2px solid var(--w-green); outline-offset: 2px; }

/* Открытая сейчас страница — как выбранный вариант; ссылкой уже не является. */
.w-chips__item--current span { background: #212121; color: #fff; }

.w-chips__item input:checked + span { background: #212121; color: #fff; }
.w-chips__item input:focus-visible + span { outline: 2px solid var(--w-green); outline-offset: 2px; }

/* Вариант, ведущий к пустой выдаче: input с disabled, кнопка приглушена —
   пунктирная рамка, бледный текст, курсор «нельзя». Клик по label
   с выключенным input ничего не делает, pointer-events не нужны. */
.w-chips__item:has(input:disabled),
.w-filter__tab:has(input:disabled) { cursor: not-allowed; }

.w-filter__tab input:disabled + span {
    border-style: dashed;
    border-color: #e4e4e4;
    background: #fbfbfb;
    color: #c6c6c6;
}

.w-filter__tabs--num .w-filter__tab input:disabled + span { color: #c6c6c6; }

.w-chips__item input:disabled + span {
    background: #f0f0f0;
    color: #b8b8b8;
}

/* --- Сортировка: кнопка со стрелками, под ней свой список вместо системного select --- */
.w-sort { position: relative; }

.w-sort__button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 0;
    border: 0;
    background: none;
    color: #212121;
    font: inherit;
    font-size: 16px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
}

.w-sort__button:focus-visible { outline: 2px solid var(--w-green); outline-offset: 2px; }
.w-sort .w-icon--sort { width: 13px; height: 14px; }

.w-sort__menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 5;
    min-width: 100%;
    margin: 0;
    padding: 6px;
    list-style: none;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 4px 30px rgba(132, 136, 139, .46);
}

.w-sort__menu[hidden] { display: none; }

.w-sort__option {
    position: relative;
    padding: 9px 14px 9px 32px;
    border-radius: 6px;
    color: #212121;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    outline: 0;
}

.w-sort__option:hover, .w-sort__option:focus-visible { background: var(--w-bg); }
.w-sort__option[aria-selected="true"] { font-weight: 600; }

/* Галочка у выбранного пункта — рисуется рамкой, без картинки. */
.w-sort__option[aria-selected="true"]::before {
    content: '';
    position: absolute;
    left: 13px;
    top: 50%;
    width: 5px;
    height: 9px;
    border: solid var(--w-green);
    border-width: 0 2px 2px 0;
    transform: translateY(-60%) rotate(45deg);
}

/* --- Кнопка «Фильтр» — только мобильный --- */
.w-catalog__filter-btn {
    display: none;
    align-items: center;
    gap: 4px;
    height: 29px;
    padding: 0 10px;
    border: 0;
    border-radius: 4px;
    background: #e8e8e8;
    color: #242424;
    font: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
}

.w-catalog__filter-btn .w-icon--filter { width: 15px; height: 15px; }

/* --- Фильтр --- */
.w-filter {
    grid-area: filter;
    /* Панель едет вместе с сеткой: карточек больше экрана, а фильтр нужен
       на любой высоте прокрутки. Если панель выше окна, прокручивается сама. */
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 30px;
    padding: 19px 16px;
    border-radius: 10px;
    background: #fff;
}

/* Секция — fieldset без flex: legend во flex-fieldset у Safari выпадает
   из потока и ложится на кнопки. Отступ до кнопок даёт margin заголовка. */
.w-filter__section {
    display: block;
    margin: 0;
    padding: 0;
    border: 0;
    min-width: 0;
}

.w-filter__title {
    display: block;
    margin: 0 0 16px;
    padding: 0;
    color: var(--w-ink);
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
}

.w-filter__tabs { display: flex; gap: 10px; }
.w-filter__tabs--grid { display: grid; grid-template-columns: 1fr 1fr; }
.w-filter__tabs--num { width: 260px; max-width: 100%; }

.w-filter__tab { position: relative; flex: 1 1 0; min-width: 0; cursor: pointer; }
.w-filter__tabs--num .w-filter__tab { flex: 0 0 44px; }

.w-filter__tab span,
.w-filter__input {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 50px;
    padding: 0 14px;
    border: 1px solid #ececec;
    border-radius: 6px;
    background: #f6f6f6;
    color: #797979;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
}

.w-filter__tabs--num .w-filter__tab span { padding: 0; color: var(--w-ink); }

.w-filter__tab input:checked + span {
    border-color: var(--w-green);
    background: var(--w-green);
    color: #fff;
    font-weight: 700;
}

.w-filter__tab input:focus-visible + span { outline: 2px solid var(--w-green); outline-offset: 2px; }

.w-filter__input {
    flex: 1 1 0;
    justify-content: flex-start;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    -moz-appearance: textfield;
}

.w-filter__input::-webkit-outer-spin-button,
.w-filter__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.w-filter__input::placeholder { color: #797979; }
.w-filter__input:focus { outline: 2px solid var(--w-green); outline-offset: -1px; }

.w-filter__reset {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 50px;
    border: 1px solid var(--w-green);
    border-radius: 6px;
    color: var(--w-green);
    font-size: 14px;
    font-weight: 700;
    line-height: 20px;
    text-decoration: none;
}

.w-filter__reset:hover { background: rgba(40, 142, 98, .08); }

/* --- 1440 --- */
@media (max-width: 1919px) {
    .w-crumbs { margin-top: 48px; }
    .w-catalog { margin-bottom: 80px; }
}

/* --- 990 --- */
@media (max-width: 1439px) {
    .w-crumbs { margin-top: 26px; }
    .w-catalog__title { font-size: 40px; }
    .w-catalog { grid-template-columns: 272px 1fr; gap: 20px 16px; margin: 26px 0 60px; }
    .w-catalog__bar { min-height: 34px; }
    .w-chips__item span { height: 34px; font-size: 14px; }
    .w-filter { padding: 16px 12px; gap: 24px; }
    .w-filter__tabs--num { width: 100%; }
    .w-filter__tabs--num .w-filter__tab { flex: 1 1 0; }
    .w-filter__tab span, .w-filter__input { height: 44px; padding: 0 10px; font-size: 13px; }
}

/* --- Мобильный: одна колонка, фильтр — панель по кнопке --- */
@media (max-width: 989px) {
    .w-crumbs { margin-top: 30px; }
    .w-catalog__title { margin-top: 40px; font-size: 40px; }
    .w-catalog {
        display: block;
        margin: 30px 0 60px;
    }

    .w-catalog__bar { margin-bottom: 20px; }
    .w-chips { gap: 8px; }
    .w-chips__item span { height: 29px; padding: 0 10px; font-size: 12px; }
    .w-sort { display: none; }
    .w-catalog__filter-btn { display: inline-flex; }

    .w-catalog__grid { grid-template-columns: 1fr; gap: 20px; }

    /* Панель фильтра: справа под полосой, поверх карточек — как в макете. */
    .w-filter {
        position: absolute;
        top: 37px;
        max-height: none;
        overflow: visible;
        right: 0;
        z-index: 30;
        display: none;
        width: 272px;
        box-shadow: 0 4px 30px rgba(132, 136, 139, .46);
    }

    .w-catalog.is-filter-open .w-filter { display: flex; }

    .w-filter__tabs--num .w-filter__tab { flex: 1 1 0; }
    .w-filter__tab span, .w-filter__input { height: 42px; padding: 0 12px; font-size: 14px; }
}

/* =====================================================================
   Ховеры каталога: крошки, чипы, кнопка «Фильтр», сортировка, кнопки
   вариантов, поля «от — до», «Очистить». Выбранное и выключенное
   на наведение не реагируют.
   ===================================================================== */

.w-crumbs__link,
.w-chips__item span,
.w-catalog__filter-btn,
.w-sort__button,
.w-sort__option,
.w-filter__tab span,
.w-filter__input,
.w-filter__reset,
.w-catalog__empty a {
    transition: color var(--w-ease), background-color var(--w-ease), border-color var(--w-ease),
        box-shadow var(--w-ease);
}

.w-catalog__empty a { text-decoration-color: transparent; }

@media (hover: hover) {
    /* Серые чипы и кнопка «Фильтр» темнеют на тон; выбранный чип — чёрный, ему некуда. */
    .w-chips__item:hover input:not(:checked):not(:disabled) + span { background: #d9d9d9; }
    .w-catalog__filter-btn:hover { background: #d9d9d9; }

    /* Сортировка: подпись зеленеет, пункт списка подсвечен (см. выше). */
    .w-sort__button:hover { color: var(--w-green); }

    /* Вариант фильтра: рамка проявляется, текст темнеет; выбранный — зелёный, его не трогаем. */
    .w-filter__tab:hover input:not(:checked):not(:disabled) + span {
        border-color: #cfcfcf;
        background: #efefef;
        color: #212121;
    }

    .w-filter__input:hover { border-color: #cfcfcf; }

    /* «Очистить»: заливка зелёным, как у остальных кнопок действия. */
    .w-filter__reset:hover {
        background: var(--w-green);
        color: #fff;
    }

    .w-catalog__empty a:hover { text-decoration-color: currentColor; }
}

/* --- Страница категории ---------------------------------------------------
 * Тексты приходят HTML-ом из редактора админки, поэтому стили заданы
 * потомкам блока, а не классам: разметку пишет менеджер, а не вёрстка.
 */

/* Типографику даёт общий .w-prose из layout.css — здесь только раскладка. */
.w-category__text {
    max-width: 900px;
    margin: 24px 0 0;
}

.w-category__text--bottom { margin: 40px 0 0; }

/* Подразделы — чипы над сеткой: тот же вид, что у чипов фильтра. */
.w-category__children {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 24px;
}

.w-category__child {
    padding: 9px 18px;
    border: 1px solid #e3e3e3;
    border-radius: 100px;
    color: var(--w-ink);
    font-size: 14px;
    line-height: 1;
    text-decoration: none;
    transition: border-color .2s, color .2s;
}

.w-category__child:hover,
.w-category__child:focus-visible {
    border-color: var(--w-green);
    color: var(--w-green);
}

@media (max-width: 989px) {
    .w-category__text { margin-top: 18px; font-size: 15px; }
    .w-category__text--bottom { margin-top: 30px; }
    .w-category__children { margin-top: 18px; }
}
