/* ============================================================================
 * category.css — страницы агрегаторов и линеек
 * ========================================================================= */

/* Контейнер категории — стандартный 1280px max + 24px padding из .container
   в site.css. Дополнительных padding'ов не добавляем, чтобы layout влезал
   симметрично (260px filter + gap32 + 4×carousel ≈ 1232 ровно в 1280-2×24). */
.cat-page { margin: 24px auto 56px; }

/* Большой hero c картинкой (.cat-hero) — только когда задан hero_image_url.
   Иначе рендерится компактный .cat-title (без серого блока 320px впустую). */
.cat-title {
    font-family: var(--font-head);
    font-size: var(--fs-h2);
    font-weight: 700;
    color: var(--text);
    margin: 0 0 24px;
    line-height: 1.2;
}
.cat-hero {
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-card);
    aspect-ratio: 1280 / 320;
    margin-bottom: 32px;
    display: flex;
    align-items: center;
    padding: 0 56px;
    position: relative;
}
.cat-hero img {
    position: absolute;
    inset: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    z-index: 0;
    opacity: 0.6;
}
.cat-hero__title {
    position: relative;
    z-index: 1;
    font-size: var(--fs-hero);
    margin: 0;
    color: var(--text);
}

.cat-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 28px;
    align-items: start;
}

/* sidebar filter — sticky под pill-nav (он ~78px высотой) */
.cat-filter {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    position: sticky;
    top: 90px;
    min-width: 0;
}
.cat-filter__title {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    margin: 0 0 12px;
    /* reset для button (на мобиле — кликабельный, на десктопе — статичный) */
    background: transparent;
    border: 0;
    padding: 0;
    text-align: left;
    width: 100%;
    font-family: inherit;
}
.cat-filter__group { margin-bottom: 20px; }
.cat-filter__group-title {
    font-family: var(--font-head);
    font-weight: 600;
    font-size: 14px;
    margin: 0 0 8px;
}
.cat-filter__list { list-style: none; padding: 0; margin: 0; }
.cat-filter__list li { padding: 4px 0; font-size: 13px; }
.cat-filter__list a {
    color: var(--text);
    display: flex;
    justify-content: space-between;
}
.cat-filter__list a:hover { color: var(--primary); text-decoration: none; }
.cat-filter__list .count { color: var(--text-mute); font-size: 12px; }
.cat-filter__list .is-active a { color: var(--primary); font-weight: 600; }

/* toolbar */
.cat-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}
.cat-toolbar__count {
    color: var(--text-dim);
    font-size: 13px;
}
.cat-sort {
    display: flex;
    align-items: center;
    gap: 8px;
}
.cat-sort__label {
    color: var(--text-dim);
    font-size: 13px;
}
.cat-sort select {
    padding: 8px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: #fff;
    cursor: pointer;
}

/* load more */
.load-more-row {
    text-align: center;
    margin: 32px 0;
}
.empty-state {
    padding: 80px 24px;
    text-align: center;
    color: var(--text-mute);
    font-size: 16px;
}

@media (max-width: 1024px) {
    .cat-layout {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .cat-filter {
        position: static;
        padding: 14px 16px;
    }
    .cat-hero { aspect-ratio: 16/9; padding: 0 24px; }
    .cat-hero__title { font-size: 28px; }
}

/* Мобильный фильтр сворачивается в плашку. Стартовая высота показывает только
   заголовок «Фильтр» — пользователь раскрывает кликом (handler в category.js).
   Без JS — fallback: всё видно по умолчанию. */
@media (max-width: 720px) {
    .cat-title { font-size: 24px; margin: 0 0 16px; }
    .cat-filter {
        padding: 0;
    }
    .cat-filter__title {
        margin: 0;
        padding: 14px 16px;
        cursor: pointer;
        user-select: none;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    .cat-filter__title::after {
        content: '';
        width: 10px;
        height: 10px;
        border-right: 2px solid var(--text-dim);
        border-bottom: 2px solid var(--text-dim);
        transform: rotate(45deg);
        transition: transform 0.2s ease;
    }
    .cat-filter.is-open .cat-filter__title::after { transform: rotate(-135deg); }
    .cat-filter__body {
        display: none;
        padding: 0 16px 16px;
    }
    .cat-filter.is-open .cat-filter__body { display: block; }

    .cat-toolbar {
        margin-bottom: 12px;
        flex-wrap: nowrap;
        gap: 8px;
    }
    .cat-toolbar__count { font-size: 12px; }
    .cat-sort__label { display: none; }
    .cat-sort select { padding: 6px 10px; font-size: 12px; }

    /* minmax(0,1fr) — иначе карточки с длинными именами расширяют колонки за
       пределы grid (см. CSS Grid spec: min-content default = max(min-content)). */
    .product-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }
    .product-grid > .product-card {
        min-width: 0;
        padding: 10px;
    }
    .product-card__title {
        font-size: 13px;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }
    /* Кнопки на мобиле — в столбик во всю ширину, иначе «Купить» выходит за рамки */
    .product-card__cta {
        flex-direction: column;
        gap: 6px;
    }
    .product-card__cta .btn {
        width: 100%;
        padding: 8px 10px;
        font-size: 12px;
        min-width: 0;
    }
    .cat-toolbar > * { min-width: 0; }
    .cat-sort select { max-width: 140px; }
    .load-more-row { margin: 20px 0; }
}
