/* ==========================================================================
   Standardized Product Cards CSS Component
   Pinterest-Inspired & Globally Configurable via Dynamic CSS Variables
   ========================================================================== */

:root {
    --pc-aspect-ratio: 1 / 1;
    --pc-fit-mode: contain;
    --pc-radius: 1.25rem;
    --pc-title-size: 0.8125rem;
    --pc-price-size: 0.9375rem;
    --pc-border: #f1f5f9;
    --pc-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.06);
}

.product-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    background-color: #ffffff;
    border-radius: var(--pc-radius, 1.25rem);
    border: 1px solid var(--pc-border, #f1f5f9);
    box-shadow: var(--pc-shadow, 0 4px 20px -2px rgba(15, 23, 42, 0.06));
    overflow: hidden;
    position: relative;
    transition: transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.24s ease;
    transform: translateZ(0); /* Hardware accelerate to lock subpixel text rasterization */
    backface-visibility: hidden;
    -webkit-font-smoothing: subpixel-antialiased;
    will-change: transform, box-shadow;
}

.product-card:hover {
    transform: translateY(-4px) translateZ(0);
    box-shadow: 0 16px 32px -8px rgba(15, 23, 42, 0.12);
}

.product-card-image-box {
    position: relative;
    width: 100%;
    aspect-ratio: var(--pc-aspect-ratio, 1 / 1);
    background-color: #f8fafc;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    flex-shrink: 0; /* Strictly preserve aspect ratio, never collapse */
    contain: layout paint;
}

.product-card-img-link {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    text-decoration: none;
}

.product-card-img {
    width: 100%;
    height: 100%;
    object-fit: var(--pc-fit-mode, contain);
    transition: transform 0.35s ease;
    display: block;
}

.product-card:hover .product-card-img:not(.is-fallback-img) {
    transform: scale(1.04);
}

/* Zero-Jitter Clean Placeholder Component when product has no image */
.product-card-no-img {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1.5px dashed #cbd5e1;
    border-radius: 0.875rem;
    user-select: none;
    pointer-events: none;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    padding: 0.5rem;
    box-sizing: border-box;
}

.product-card:hover .product-card-no-img {
    background-color: #f1f5f9;
    border-color: #94a3b8;
}

.no-img-icon-box {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    border: 1px solid #e2e8f0;
}

.product-card-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    padding: 0.875rem 1rem;
    justify-content: space-between;
}

.product-card-category {
    font-size: 0.6875rem;
    font-weight: 600;
    color: #94a3b8;
    margin-bottom: 0.25rem;
}

.product-card-title {
    font-size: var(--pc-title-size, 0.8125rem);
    font-weight: 700;
    color: #1e293b;
    line-height: 1.35rem;
    height: 2.7rem; /* Exactly 2 fixed lines - prevents any vertical jitter/jump */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
    margin-bottom: 0.5rem;
    transition: color 0.2s ease;
    transform: translateZ(0); /* Lock subpixel rasterization */
    backface-visibility: hidden;
}

.product-card:hover .product-card-title {
    color: var(--theme-primary, #4f46e5);
}

.product-card-price-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 0.5rem;
    border-top: 1px dashed #f1f5f9;
}

.product-card-price {
    font-size: var(--pc-price-size, 0.9375rem);
    font-weight: 800;
    color: var(--theme-price, #059669);
}

.product-card-badge {
    position: absolute;
    top: 0.625rem;
    right: 0.625rem;
    z-index: 10;
    padding: 0.2rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 800;
}

/* Skeleton Loading Shimmer for Catalog */
.product-card-skeleton {
    border-radius: var(--pc-radius, 1.25rem);
    border: 1px solid #f1f5f9;
    background: #ffffff;
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.skeleton-shimmer {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
