/* ═══════════════════════════════════════════════════════════
   СТРАНИЦА МАГАЗИНА / АРХИВ ТОВАРОВ
   Стратегия: desktop-first.
   Мобильный: @media (max-width: 767px)
═══════════════════════════════════════════════════════════ */

h1.woocommerce-products-header__title.page-title {
    text-align: center;
    margin-bottom: 40px;
    text-transform: uppercase;
    font-size: 30px;
}

/* Скрываем счётчик и сортировку */
.woocommerce-result-count,
.woocommerce-ordering {
    display: none !important;
}

/* ─── Сетка товаров ─── */
ul.products {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    padding: 0 !important;
    margin: 0 !important;
    list-style: none !important;
}

/* Первый товар — WooCommerce добавляет класс .first */
ul.products .product.first {
    grid-column: 1 / -1;
}

/* ─── Сброс фиксированных размеров из content-product.css ─── */
ul.products .product-home {
    width: 100%;
    max-width: 100%;
    height: auto;
}

ul.products .product-home__image,
ul.products .product-home__content,
ul.products .product-home__bottom,
ul.products .product-home__buttons,
ul.products .product-home__title {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

ul.products .product-home__image {
    height: auto;
    aspect-ratio: 500 / 376;
}

ul.products .product.first .product-home__image {
    aspect-ratio: 16 / 7;
}

ul.products .product-home__bottom {
    height: auto;
    min-height: 52px;
}

ul.products .product-home__buttons {
    width: 100%;
    max-width: 100%;
    height: 52px;
    margin-left: 0;
}

ul.products .product-home__more {
    flex: 0 0 auto;
    width: auto;
    max-width: none;
}

ul.products .product-home__buttons > a.button,
ul.products .product-home__buttons a.add_to_cart_button,
ul.products .product-home__buttons .product-home__cart-btn {
    flex: 1;
    width: auto;
    max-width: none;
}

/* Первый товар — кнопки фиксированной ширины, выравнивание по правому краю */
ul.products .product.first .product-home__buttons {
    width: 392px;
    max-width: 392px;
    margin-left: auto;
}

ul.products .product.first .product-home__more {
    width: 168px;
    max-width: 168px;
    flex: 0 0 168px;
}

ul.products .product.first .product-home__buttons > a.button,
ul.products .product.first .product-home__buttons a.add_to_cart_button,
ul.products .product.first .product-home__buttons .product-home__cart-btn {
    width: 208px;
    max-width: 208px;
    flex: 0 0 208px;
}

/* Не первый товар — кнопка корзины: квадрат с иконкой */
ul.products .product:not(.first) .product-home__buttons {
    width: auto;
    max-width: none;
    margin-left: auto;
}

ul.products .product:not(.first) .product-home__buttons > a.button,
ul.products .product:not(.first) .product-home__buttons a.add_to_cart_button,
ul.products .product:not(.first) .product-home__buttons .product-home__cart-btn {
    width: 52px;
    max-width: 52px;
    flex: 0 0 52px;
    height: 52px;
    font-size: 0;
    padding: 0;
    background-image: url("../images/Cart.svg");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 24px 24px;
}

/* ═══════════════════════════════════════════════════════════
   МОБИЛЬНЫЙ (≤ 767px)
═══════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
    ul.products {
        grid-template-columns: 1fr;
        gap: 32px;
    }

    ul.products .product.first {
        grid-column: 1;
    }

    ul.products .product.first .product-home__image {
        aspect-ratio: 500 / 376;
    }

    ul.products .product-home__bottom {
        flex-wrap: nowrap;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        height: auto;
        min-height: 39px;
    }

    ul.products .product.first .product-home__bottom {
        flex-wrap: nowrap;
    }

    ul.products .product.first .product-home__price {
        flex: 0 1 auto;
        min-width: 0;
    }

    ul.products .product-home__buttons {
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: flex-end;
        gap: 14px;
        width: auto;
        max-width: none;
        height: 39px;
        margin-left: auto;
        flex-shrink: 0;
    }

    ul.products .product.first .product-home__buttons {
        width: auto;
        max-width: none;
        margin-left: auto;
    }

    ul.products .product-home__more {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 126px;
        width: 126px !important;
        min-width: 126px !important;
        max-width: 126px !important;
        height: 39px !important;
        min-height: 39px !important;
        max-height: 39px !important;
        padding: 0 !important;
        font-family: "Inter", sans-serif;
        font-weight: 300;
        font-size: 12px;
        line-height: 1.72;
        letter-spacing: -0.03em;
    }

    ul.products .product-home__buttons > a.button,
    ul.products .product-home__buttons a.add_to_cart_button,
    ul.products .product-home__buttons .product-home__cart-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 59px;
        width: 59px !important;
        min-width: 59px !important;
        max-width: 59px !important;
        height: 39px !important;
        min-height: 39px !important;
        max-height: 39px !important;
        padding: 0 !important;
        font-size: 0;
        line-height: 0;
        color: transparent;
        background-image: url("../images/cart.svg");
        background-repeat: no-repeat;
        background-position: center;
        background-size: 16px 16px;
    }

    ul.products .product:not(.first) .product-home__buttons {
        width: auto;
        max-width: none;
        margin-left: auto;
    }

    ul.products .product:not(.first) .product-home__buttons > a.button,
    ul.products .product:not(.first) .product-home__buttons a.add_to_cart_button,
    ul.products .product:not(.first) .product-home__buttons .product-home__cart-btn {
        width: 59px !important;
        min-width: 59px !important;
        max-width: 59px !important;
        height: 39px !important;
        background-size: 16px 16px;
    }
}
