/* ==========================================================================
   Product Cards & Single Product
   ========================================================================== */

/* ==========================================================================
   PRODUCT GRID
   ========================================================================== */
.products-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-lg);
}

.products-grid--4 {
    grid-template-columns: repeat(4, 1fr);
}


/* ==========================================================================
   PRODUCT CARD
   ========================================================================== */
.product-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--color-bg);
    overflow: hidden;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border-light);
    transition: all var(--transition-base);
}

.product-card:hover {
    border-color: var(--color-border);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

/* Image container */
.product-card__image {
    position: relative;
    aspect-ratio: 4/5;
    overflow: hidden;
    background: var(--color-bg-soft);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.product-card__image-link {
    display: block;
    text-decoration: none;
    width: 100%;
    height: 100%;
}

.product-card__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity var(--transition-slow);
}

/* Hover image swap — only on devices with hover (desktop) */
.product-card__img--hover {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    will-change: opacity;
}

@media (hover: hover) {
    .product-card:hover .product-card__img--hover {
        opacity: 1;
    }
    .product-card:hover .product-card__img:not(.product-card__img--hover) {
        opacity: 0;
    }
}

/* Hide hover image on touch devices — saves bandwidth */
@media (hover: none) {
    .product-card__img--hover {
        display: none;
    }
}

/* Badge */
.product-card__badge {
    position: absolute;
    top: var(--space-sm);
    left: var(--space-sm);
    padding: 4px 10px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-radius: var(--radius-sm);
    z-index: 2;
}

.product-card__badge--sale {
    background: var(--color-accent);
    color: #fff;
}

.product-card__badge--new {
    background: var(--color-primary);
    color: #fff;
}

.product-card__badge--bestseller {
    background: var(--color-warning);
    color: var(--color-primary);
}

.product-card__badge--limited {
    background: var(--color-primary);
    color: #fff;
}

/* Product info */
.product-card__info {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: var(--space-md) var(--space-md) var(--space-lg);
}

.product-card__title {
    font-size: var(--font-size-sm);
    font-weight: 400;
    margin-bottom: var(--space-xs);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-card__title a {
    color: var(--color-text-muted);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.product-card__title a:hover {
    color: var(--color-accent);
}

/* Price */
.product-card__price {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--color-primary);
    margin-top: auto;
    line-height: 1.3;
}

.product-card__price del {
    font-size: var(--font-size-sm);
    font-weight: 400;
    color: var(--color-text-muted);
    margin-right: var(--space-xs);
}

.product-card__price ins {
    text-decoration: none;
    color: var(--color-primary);
}

/* Hide WooCommerce accessibility text in prices */
.product-card__price .screen-reader-text,
.product-info__price .screen-reader-text,
.woocommerce .screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Add to Cart overlay button */
.product-card__add-to-cart {
    position: absolute;
    bottom: 10px;
    left: 10px;
    right: 10px;
    width: calc(100% - 20px);
    font-family: var(--font-heading);
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    padding: 12px 16px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0;
    transform: translateY(8px);
    transition: all var(--transition-base);
    z-index: 3;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(37, 37, 49, 0.25);
}

.product-card:hover .product-card__add-to-cart {
    opacity: 1;
    transform: translateY(0);
}

.product-card__add-to-cart:hover {
    background: var(--color-accent);
    box-shadow: 0 4px 16px rgba(238, 157, 164, 0.4);
}

.product-card__out-of-stock {
    display: block;
    text-align: center;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    padding: 0.5rem;
}

/* No products message */
.no-products {
    grid-column: 1 / -1;
    text-align: center;
    padding: var(--space-3xl) 0;
    color: var(--color-text-light);
}


/* ==========================================================================
   SINGLE PRODUCT
   ========================================================================== */

/* Product layout: 2-column */
.product-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3xl);
    margin-bottom: var(--space-3xl);
}

/* Gallery */
.product-gallery__main {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-gallery__main-img {
    width: 100%;
    height: auto;
    max-height: 600px;
    object-fit: contain;
    cursor: zoom-in;
}

/* Product badges on single */
.product-badge {
    position: absolute;
    top: var(--space-lg);
    left: var(--space-lg);
    padding: 6px 16px;
    font-size: var(--font-size-xs);
    font-weight: 700;
    text-transform: uppercase;
    border-radius: var(--radius-full);
    z-index: 2;
}

.product-badge--sale { background: var(--color-accent); color: #fff; }
.product-badge--new { background: var(--color-primary); color: #fff; }
.product-badge--bestseller { background: var(--color-warning); color: var(--color-primary); }
.product-badge--limited { background: var(--color-primary); color: #fff; }

/* Gallery thumbnails */
.product-gallery__thumbs {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-md);
    overflow-x: auto;
    scrollbar-width: none;
    max-width: 100%;
}

.product-gallery__thumbs::-webkit-scrollbar { display: none; }

.product-gallery__thumb {
    flex-shrink: 0;
    width: 72px;
    height: 72px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color var(--transition-fast);
    padding: 0;
    background: var(--color-bg-soft);
}

.product-gallery__thumb--active,
.product-gallery__thumb:hover {
    border-color: var(--color-accent);
}

.product-gallery__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Product Info */
.product-info__title {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    margin-bottom: var(--space-sm);
    line-height: var(--line-height-tight);
}

.product-info__sku {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin-bottom: var(--space-lg);
}

.product-info__price {
    font-size: var(--font-size-3xl);
    font-weight: 800;
    color: var(--color-primary);
    margin-bottom: var(--space-lg);
}

.product-info__price del {
    font-size: var(--font-size-xl);
    color: var(--color-text-muted);
    font-weight: 400;
}

.product-info__price ins {
    text-decoration: none;
    color: var(--color-accent);
}

.product-info__description {
    font-size: var(--font-size-sm);
    color: var(--color-text-light);
    line-height: 1.7;
    margin-bottom: var(--space-xl);
}

/* Quantity selector & Add to Cart */
.product-info__add-to-cart {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.quantity-selector {
    display: flex;
    align-items: center;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.qty-btn {
    width: 44px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-lg);
    font-weight: 500;
    color: var(--color-text);
    transition: background var(--transition-fast);
    cursor: pointer;
    border: none;
    background: none;
}

.qty-btn:hover {
    background: var(--color-bg-soft);
}

.qty-input {
    width: 48px;
    text-align: center;
    border: none;
    font-size: var(--font-size-base);
    font-weight: 500;
    -moz-appearance: textfield;
    background: transparent;
}

.qty-input::-webkit-inner-spin-button,
.qty-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
}

.product-add-to-cart {
    flex: 1;
    min-height: 52px;
    font-size: var(--font-size-sm);
    box-shadow: 0 2px 8px rgba(37, 37, 49, 0.15);
}

.product-add-to-cart:hover {
    box-shadow: 0 4px 16px rgba(238, 157, 164, 0.3);
}

/* Product attributes table */
.product-info__attributes {
    margin-top: var(--space-xl);
    margin-bottom: var(--space-xl);
}

.product-info__attributes h3 {
    font-size: var(--font-size-base);
    margin-bottom: var(--space-md);
}

.product-attributes-table {
    width: 100%;
    border-collapse: collapse;
}

.product-attributes-table th,
.product-attributes-table td {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
    text-align: left;
    border-bottom: 1px solid var(--color-border-light);
}

.product-attributes-table th {
    font-weight: 500;
    color: var(--color-text-light);
    width: 40%;
}

/* Care instructions & Video */
.product-info__care,
.product-info__video {
    margin-bottom: var(--space-xl);
}

.product-info__care h3,
.product-info__video h3 {
    font-size: var(--font-size-base);
    margin-bottom: var(--space-md);
}

/* Full description */
.product-full-description {
    max-width: 800px;
    margin-bottom: var(--space-3xl);
}

.product-full-description h2 {
    margin-bottom: var(--space-lg);
}

/* Override inline align="center" from pasted content (LibreOffice/Docs) */
.product-full-description .prose h2,
.product-full-description .prose h3,
.product-full-description .prose p,
.product-full-description .prose .western {
    text-align: left !important;
}

/* Out of stock */
.out-of-stock-msg {
    font-size: var(--font-size-base);
    color: var(--color-error);
    font-weight: 500;
    padding: var(--space-md) 0;
}

.product-info__out-of-stock {
    padding: var(--space-md) 0;
}

/* Related products */
.related-products {
    padding-top: var(--space-3xl);
    border-top: 1px solid var(--color-border-light);
}


/* ==========================================================================
   LIGHTBOX
   ========================================================================== */
.product-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.product-lightbox.is-open {
    opacity: 1;
    visibility: visible;
}

.product-lightbox__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
}

.product-lightbox__content {
    position: relative;
    z-index: 1;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.product-lightbox__img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: var(--radius-md);
}

.product-lightbox__close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 2;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    transition: background 0.2s;
}

.product-lightbox__close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.product-lightbox__prev,
.product-lightbox__next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    transition: background 0.2s;
}

.product-lightbox__prev { left: 16px; }
.product-lightbox__next { right: 16px; }

.product-lightbox__prev:hover,
.product-lightbox__next:hover {
    background: rgba(255, 255, 255, 0.2);
}

.product-lightbox__counter {
    margin-top: var(--space-md);
    color: rgba(255, 255, 255, 0.6);
    font-size: var(--font-size-sm);
}


/* ==========================================================================
   RESPONSIVE OVERRIDES (must be here, not in main.css, because
   product-card.css loads AFTER main.css — source order matters)
   ========================================================================== */
@media (max-width: 1024px) {
    .products-grid--4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .product-layout {
        grid-template-columns: 1fr;
        gap: var(--space-xl);
    }

    .product-attributes-table th {
        width: 35%;
    }

    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-md);
    }

    .products-grid--4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .product-card:hover {
        transform: none;
        box-shadow: none;
    }

    .product-card__add-to-cart {
        opacity: 1;
        transform: translateY(0);
        position: relative;
        bottom: auto;
        left: auto;
        right: auto;
        width: 100%;
        border-radius: 0 0 var(--radius-lg) var(--radius-lg);
        box-shadow: none;
    }
}

@media (max-width: 480px) {
    .products-grid,
    .products-grid--4 {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-sm);
    }

    .product-card__info {
        padding: var(--space-sm) var(--space-sm) var(--space-md);
    }

    .product-card__title { font-size: var(--font-size-xs); }
    .product-card__price { font-size: var(--font-size-sm); }

    .product-card__add-to-cart {
        padding: 8px 12px;
        font-size: 10px;
    }
}
