
/* =========================================================
   catalog-mobile.css
   Elitautocolor — мобильная адаптация каталога
   Desktop не изменяем
   ========================================================= */

/* =========================================================
   1. ОБЩАЯ СТРАНИЦА
   ========================================================= */

@media (max-width: 767px) {

    .catalog {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
        width: 100%;
        min-width: 0;
        padding-top: 14px;
        padding-bottom: 30px;
    }

    .catalog__main {
        width: 100%;
        min-width: 0;
    }

    .catalog__results {
        width: 100%;
        min-width: 0;
    }

    .catalog__main,
    .catalog__results,
    .products-grid,
    .products-grid > li {
        min-width: 0;
    }

    /* =====================================================
       2. ЗАГОЛОВОК КАТАЛОГА
       ===================================================== */

    .catalog__header {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 15px;

        padding-bottom: 17px;
        margin-bottom: 18px;

        border-bottom: 1px solid var(--color-border);
    }

    .catalog__header-left {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
        width: 100%;
    }

    .catalog__title {
        font-size: clamp(23px, 6vw, 28px);
        line-height: 1.2;
        font-weight: var(--fw-bold);
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .catalog__count {
        font-size: 12px;
        color: var(--color-text-muted);
    }

    /* =====================================================
       3. ФИЛЬТРЫ И СОРТИРОВКА
       ===================================================== */

    .catalog__header-right {
        display: grid;
        grid-template-columns: 1fr 1fr;
        align-items: stretch;
        gap: 10px;
        width: 100%;
    }

    .catalog__filters-toggle {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        gap: 8px;

        width: 100%;
        min-width: 0;
        min-height: 44px;
        padding: 10px 12px;

        border: 1px solid var(--color-border);
        border-radius: 10px;
        background: #fff;
        color: var(--color-text);

        font-size: 13px;
        font-weight: 600;
        white-space: nowrap;
    }

    .catalog__filters-toggle:active {
        background: #fff5f6;
        border-color: var(--color-accent);
    }

    .catalog__filters-toggle svg {
        flex-shrink: 0;
    }

    .catalog__sort {
        display: flex;
        align-items: stretch;
        width: 100%;
        min-width: 0;
    }

    .catalog__sort-label {
        display: none;
    }

    .catalog__sort-select {
        width: 100%;
        max-width: none;
        min-width: 0;
        min-height: 44px;

        padding: 9px 32px 9px 11px;

        border: 1px solid var(--color-border);
        border-radius: 10px;
        background-color: #fff;

        font-size: 12px;
        color: var(--color-text);

        white-space: nowrap;
        text-overflow: ellipsis;
    }

    /* =====================================================
       4. СЕТКА ТОВАРОВ
       ===================================================== */

    .products-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;

        width: 100%;
        margin: 0;
        padding: 0;

        list-style: none;
    }

    .products-grid > li {
        display: flex;
        width: 100%;
        min-width: 0;
        margin: 0;
        padding: 0;
    }

    /* =====================================================
       5. КАРТОЧКА ТОВАРА
       ===================================================== */

    .products-grid .product-card {
        display: flex;
        flex-direction: column;

        width: 100%;
        min-width: 0;
        height: 100%;

        overflow: hidden;

        background: #fff;
        border: 1px solid rgba(184, 197, 211, 0.48);
        border-radius: 13px;

        box-shadow: 0 2px 8px rgba(32, 42, 53, 0.035);

        transition:
            border-color 150ms ease,
            box-shadow 150ms ease;
    }

    /* Фотография */

    .products-grid .product-card__media {
        position: relative;
        width: 100%;
        aspect-ratio: 1 / 1;

        flex-shrink: 0;
        overflow: hidden;

        background: #fff;
        border: none;
    }

    .products-grid .product-card__media-link {
        display: flex;
        align-items: center;
        justify-content: center;

        width: 100%;
        height: 100%;
        padding: 10px;
    }

    .products-grid .product-card__media img {
        display: block;

        width: 100%;
        height: 100%;

        object-fit: contain;
        object-position: center;

        transition: transform 200ms ease;
    }

    /* Избранное */

    .products-grid .product-card__like {
        position: absolute;
        top: 9px;
        right: 9px;
        z-index: 2;

        display: flex;
        align-items: center;
        justify-content: center;

        width: 34px;
        height: 34px;

        padding: 0;

        border: 1px solid rgba(184, 197, 211, 0.4);
        border-radius: 50%;

        background: rgba(255, 255, 255, 0.96);
        color: var(--color-text-muted);

        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .products-grid .product-card__like svg {
        width: 17px;
        height: 17px;
    }

    .products-grid .product-card__like.is-active {
        color: var(--color-accent);
        border-color: rgba(230, 50, 75, 0.25);
    }

    .products-grid .product-card__like.is-active svg {
        fill: var(--color-accent);
    }

    /* Информация о товаре */

    .products-grid .product-card__body {
        display: flex;
        flex-direction: column;
        align-items: flex-start;

        flex: 1 1 auto;
        min-width: 0;

        padding: 10px 11px 12px;
        gap: 4px;

        overflow: hidden;
    }

    /* Бренд */

    .products-grid .product-card__brand {
        display: block;
        width: 100%;
        min-width: 0;

        margin: 0;

        color: #9299A1;
        font-size: 10px;
        font-weight: 500;

        line-height: 1.3;

        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Название */

    .products-grid .product-card__title-wrapper {
        display: block;
        width: 100%;
        min-width: 0;

        margin: 0;
        padding: 0;

        font-size: 13px;
        line-height: 1.35;
        font-weight: 500;
    }

    .products-grid .product-card__title {
        display: -webkit-box;

        width: 100%;
        max-width: 100%;

        margin: 0;

        color: var(--color-text);
        font-size: 13px;
        line-height: 1.35;
        font-weight: 500;

        overflow: hidden;
        overflow-wrap: anywhere;

        -webkit-box-orient: vertical;
        -webkit-line-clamp: 3;
    }

    /* Цена */

    .products-grid .product-card__price {
        width: 100%;

        margin-top: auto;
        padding-top: 9px;

        color: var(--color-text);
        font-size: 15px;
        line-height: 1.3;
        font-weight: 700;
    }

    /* =====================================================
       6. ПАГИНАЦИЯ
       ===================================================== */

    .pagination {
        display: flex;
        justify-content: center;
        align-items: center;
        flex-wrap: wrap;

        gap: 5px;
        margin-top: 24px;
        padding: 0 0 10px;
    }

    .pagination__link {
        min-width: 36px;
        height: 38px;
        padding-inline: 9px;

        border-radius: 9px;
        font-size: 12px;
    }

    .pagination__ellipsis {
        min-width: 20px;
    }

    /* =====================================================
       7. ПУСТОЙ КАТАЛОГ
       ===================================================== */

    .catalog__empty {
        padding: 35px 18px;
        border-radius: 13px;
    }

    .catalog__empty-title {
        font-size: 17px;
    }

    .catalog__empty-text {
        font-size: 13px;
        line-height: 1.5;
    }
}

/* =========================================================
   8. МОБИЛЬНАЯ ПАНЕЛЬ ФИЛЬТРОВ
   ========================================================= */

/* Панель-шторка используется на всех экранах уже 1024px,
   потому что на планшетах кнопка «Фильтры» ещё видима. */

@media (max-width: 1023px) {

    .catalog__sidebar {
        position: fixed;

        top: 0;
        left: 0;
        bottom: 0;

        z-index: 200;

        width: min(380px, 90vw);
        max-width: 100%;

        height: 100vh;
        height: 100dvh;

        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;

        background: #fff;

        border: none;
        border-right: 1px solid var(--color-border);
        border-radius: 0 16px 16px 0;

        box-shadow: 8px 0 35px rgba(20, 30, 40, 0.12);

        transform: translateX(-105%);
        transition: transform 250ms ease;
    }

    .catalog__sidebar.is-open {
        transform: translateX(0);
    }

    /* Заголовок панели */

    .catalog__sidebar-head {
        position: sticky;
        top: 0;
        z-index: 5;

        display: flex;
        align-items: center;
        justify-content: space-between;

        min-height: 62px;
        padding: 12px 18px;

        background: #fff;
        border-bottom: 1px solid var(--color-border);
    }

    .catalog__sidebar-title {
        color: var(--color-text);
        font-size: 19px;
        font-weight: 700;
    }

    .catalog__sidebar-close {
        display: flex;
        align-items: center;
        justify-content: center;

        width: 40px;
        height: 40px;

        border-radius: 50%;
        background: #F3F5F7;
        color: var(--color-text);
    }

    /* Форма фильтров */

    .filters {
        padding: 8px 17px 20px;
    }

    .filters__group {
        padding-top: 18px;
        padding-bottom: 17px;

        border-bottom: 1px solid var(--color-border);
    }

    .filters__group:first-child {
        padding-top: 12px;
    }

    .filters__title {
        margin-bottom: 11px;

        color: var(--color-text);
        font-size: 12px;
        font-weight: 700;

        letter-spacing: 0.07em;
    }

    /* Категории */

    .filters__link {
        min-height: 42px;
        display: flex;
        align-items: center;

        padding: 10px 12px;

        font-size: 14px;
        line-height: 1.4;

        border-radius: 8px;
    }

    .filters__link--parent {
        padding-right: 32px;
    }

    /* Стрелка раскрытия категории */

    .filters__link--parent::after {
        content: "";

        position: absolute;
        right: 13px;
        top: 50%;

        width: 7px;
        height: 7px;

        border-right: 1.7px solid currentColor;
        border-bottom: 1.7px solid currentColor;

        transform: translateY(-70%) rotate(45deg);
        transition: transform 180ms ease;
    }

    .filters__item.is-open > .filters__link--parent::after {
        transform: translateY(-25%) rotate(225deg);
    }

    .filters__item.is-open > .filters__link--parent::before {
        display: none;
        content: none;
    }

    .filters__sublist {
        padding-left: 10px;
    }

    .filters__link--child {
        min-height: 39px;
        padding: 9px 12px;
        font-size: 13px;
    }

    /* Чекбоксы */

    .filters__check {
        display: flex;
        align-items: center;

        min-height: 43px;
        padding: 9px 2px;

        gap: 11px;

        font-size: 14px;
        line-height: 1.4;
    }

    .filters__check input[type="checkbox"] {
        width: 20px;
        height: 20px;
        border-radius: 5px;
    }

    .filters__check input[type="checkbox"]:checked::after {
        background-size: 13px 13px;
    }

    .filters__swatch {
        width: 20px;
        height: 20px;
    }

    /* Кнопки фильтров */

    .filters__actions {
        position: sticky;
        bottom: 0;
        z-index: 4;

        display: flex;
        flex-direction: column;
        gap: 9px;

        margin: 0 -17px;
        padding: 14px 17px max(14px, env(safe-area-inset-bottom));

        background: rgba(255, 255, 255, 0.97);
        border-top: 1px solid var(--color-border);
    }

    .filters__actions .btn {
        display: flex;
        align-items: center;
        justify-content: center;

        width: 100%;
        min-height: 46px;

        border-radius: 10px;
        font-size: 14px;
        font-weight: 600;
    }

    .filters__apply {
        display: flex !important;
    }

    /* Оверлей */

    .catalog__overlay {
        position: fixed;
        inset: 0;

        z-index: 150;
        background: rgba(22, 30, 39, 0.58);
        backdrop-filter: blur(2px);

        opacity: 0;
        pointer-events: none;
        transition: opacity 200ms ease;
    }

    .catalog__overlay.is-visible {
        opacity: 1;
        pointer-events: auto;
    }
}

/* =========================================================
   9. НЕБОЛЬШИЕ ТЕЛЕФОНЫ
   ========================================================= */

@media (max-width: 420px) {

    .products-grid {
        gap: 10px;
    }

    .products-grid .product-card {
        border-radius: 11px;
    }

    .products-grid .product-card__media-link {
        padding: 8px;
    }

    .products-grid .product-card__like {
        top: 7px;
        right: 7px;

        width: 31px;
        height: 31px;
    }

    .products-grid .product-card__body {
        padding: 9px 9px 11px;
    }

    .products-grid .product-card__brand {
        font-size: 9px;
    }

    .products-grid .product-card__title,
    .products-grid .product-card__title-wrapper {
        font-size: 12px;
    }

    .products-grid .product-card__price {
        font-size: 14px;
    }

    .catalog__header {
        gap: 13px;
    }
}

/* =========================================================
   10. ОЧЕНЬ УЗКИЕ ЭКРАНЫ
   ========================================================= */

@media (max-width: 359px) {

    .products-grid {
        gap: 8px;
    }

    .products-grid .product-card__body {
        padding: 8px;
    }

    .products-grid .product-card__title,
    .products-grid .product-card__title-wrapper {
        font-size: 11px;
    }

    .products-grid .product-card__price {
        font-size: 13px;
    }

    .catalog__sort-select {
        font-size: 11px;
        padding-left: 8px;
    }

    .catalog__filters-toggle {
        font-size: 12px;
        gap: 5px;
    }
}

/* =========================================================
   11. УМЕНЬШЕНИЕ АНИМАЦИИ
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

    .catalog__sidebar,
    .catalog__overlay,
    .products-grid .product-card,
    .products-grid .product-card__media img,
    .filters__link--parent::after {
        transition: none !important;
    }
}
