/* =========================================================================
   Product card + grid — shared styles
   Used by: page-builder blocks (Сітка товарів / Обраний товар), catalog.
   Loaded on page.php via <link>. Self-contained (no dependency on page CSS).
   ========================================================================= */

.product-grid {
    display: grid;
    grid-template-columns: repeat(var(--product-cols, 3), minmax(0, 1fr));
    gap: 24px;
    margin: 24px 0;
}

.product-grid.cols-1 { --product-cols: 1; }
.product-grid.cols-2 { --product-cols: 2; }
.product-grid.cols-3 { --product-cols: 3; }
.product-grid.cols-4 { --product-cols: 4; }

@media (max-width: 900px) {
    .product-grid { grid-template-columns: repeat(min(var(--product-cols, 3), 2), minmax(0, 1fr)); }
}
@media (max-width: 560px) {
    .product-grid { grid-template-columns: 1fr; }
}

/* --- Single product (accent) block: one wide card --- */
.product-single-block .product-card {
    max-width: 360px;
    margin: 0 auto;
}

/* --- Card --- */
.product-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #ececec;
    border-radius: 12px;
    padding: 16px;
    box-sizing: border-box;
    transition: box-shadow .25s ease, transform .2s ease;
    height: 100%;
}
.product-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, .08);
    transform: translateY(-3px);
}

.product-card .image-wrapper {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #f6f6f6;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 12px;
}
/* Головна: фото більше за контентну ширину картки — заходить у її внутрішній
   відступ порівну з боків і згори, розмір картки не змінюється. Відсотки підібрані
   під 300 px (екран 1024) і 320 px (телефон 375); на широких картках стеля — край картки. */
.page-home .product-card .image-wrapper {
    --pc-img-w: min(109.1%, 100% + 32px);
    flex: none;
    width: var(--pc-img-w);
    margin: calc((100% - var(--pc-img-w)) / 2) 0 12px calc((100% - var(--pc-img-w)) / 2);
}
/* Телефон: картки без обведення */
@media (max-width: 768px) {
    .product-card { border: 0; }
}
@media (max-width: 560px) {
    .page-home .product-card .image-wrapper { --pc-img-w: min(105.6%, 100% + 32px); }
}
.product-card .image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.product-card .stickers {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
}
/* Групи стікерів за кутом зображення (product_stickers.corner) */
.product-card .sticker-group {
    position: absolute;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
}
.product-card .sticker-group.pos-top_left { top: 8px; left: 8px; }
.product-card .sticker-group.pos-top_right { top: 8px; right: 8px; align-items: flex-end; }
.product-card .sticker-group.pos-bottom_left { bottom: 8px; left: 8px; }
.product-card .sticker-group.pos-bottom_right { bottom: 8px; right: 8px; align-items: flex-end; }
.product-card .sticker {
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    background-color: #333;
    border-radius: 4px;
    line-height: 1.2;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}
.product-card .sticker.sticker-image {
    background-color: transparent !important;
    padding: 0;
    box-shadow: none;
}
.product-card .sticker.sticker-image img {
    max-height: 34px;
    width: auto;
}
/* Пресети величини текстового стікера (product_stickers.size); середній — базове правило */
.product-card .sticker.sz-small:not(.sticker-image) {
    padding: 3px 8px;
    font-size: 10px;
}
.product-card .sticker.sz-large:not(.sticker-image) {
    padding: 6px 14px;
    font-size: 15px;
}
/* Пресети висоти зображення-стікера (product_stickers.size) */
.product-card .sticker.sticker-image.sz-small img {
    max-height: 24px;
}
.product-card .sticker.sticker-image.sz-large img {
    max-height: 46px;
}

.product-card h3 {
    font-size: 16px;
    line-height: 1.35;
    margin: 0 0 8px;
    font-weight: 600;
}
.product-card h3 a { color: #222; text-decoration: none; }
.product-card h3 a:hover { color: var(--g-brand-500, #2c7a5b); }

/* Рейтинг у карточці: кеш products.rating_* (approved-відгуки, міграція 0022) */
.product-card .card-rating {
    display: flex;
    align-items: baseline;
    gap: 5px;
    margin: -2px 0 8px;
    font-size: 13px;
    line-height: 1;
}
.product-card .card-rating-stars { color: #f5a623; font-weight: 600; }
.product-card .card-rating-count { color: #9aa0ac; font-size: 12px; }

.product-card p.description {
    font-size: 13px;
    color: #7a7a7a;
    margin: 0 0 12px;
    line-height: 1.5;
    flex: 1 1 auto;
}

.product-card .price {
    font-size: 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.product-card .old-price { text-decoration: line-through; color: #999; font-size: 14px; }
.product-card .new-price { color: var(--g-brand-500, #2c7a5b); font-weight: 700; }

.product-card .buy-button {
    display: block;
    width: 100%;
    padding: 11px 16px;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    background-color: var(--g-action, #01a045);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: background-color .25s ease, transform .15s ease;
    box-sizing: border-box;
}
.product-card .buy-button:hover:not(.is-disabled) {
    background-color: var(--g-action, #00bc53);
    transform: translateY(-2px);
    color: #fff;
}
.product-card .buy-button.is-disabled {
    background-color: #ccc;
    cursor: not-allowed;
    pointer-events: none;
}
