/* ==========================================================================
   Image Placeholder & Shimmer
   Shared across all themes. Include before theme-specific CSS.
   ========================================================================== */

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

/* --- Product card images ------------------------------------------------- */

.product-card .product-image {
    position: relative;
    overflow: hidden;
}

/* Shimmer – runs only while there are images to wait for */
.product-card .product-image:has(img)::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 25%, rgba(255,255,255,0.4) 50%, transparent 75%);
    background-size: 200% 100%;
    animation: img-shimmer 1.5s ease-in-out infinite;
    z-index: 1;
}

/* Placeholder icon – always present, sits behind loaded images */
.product-card .product-image::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='2'/%3E%3Ccircle cx='8.5' cy='8.5' r='1.5'/%3E%3Cpath d='m21 15-5-5L5 21'/%3E%3C/svg%3E") center/contain no-repeat;
    opacity: 0.5;
    z-index: 0;
}

/* Dismiss shimmer & icon once the first image is ready */
.product-card .product-image:has(img.loaded)::before {
    animation: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.product-card .product-image:has(img.loaded)::after {
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Images start invisible, fade in on load */
.product-card .product-image img {
    position: relative;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.product-card .product-image img.loaded {
    opacity: 1;
}

/* Hover image – stays hidden even after load; revealed on card hover */
.product-card .product-image .product-image-hover {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 3;
}

.product-card .product-image .product-image-hover.loaded {
    opacity: 0;
}

.product-card:hover .product-image .product-image-hover.loaded {
    opacity: 1;
}

/* --- Product detail gallery ---------------------------------------------- */

.gallery-main {
    position: relative;
    overflow: hidden;
}

.gallery-main:has(img)::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 25%, rgba(255,255,255,0.4) 50%, transparent 75%);
    background-size: 200% 100%;
    animation: img-shimmer 1.5s ease-in-out infinite;
    z-index: 1;
}

.gallery-main::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 64px;
    height: 64px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='2'/%3E%3Ccircle cx='8.5' cy='8.5' r='1.5'/%3E%3Cpath d='m21 15-5-5L5 21'/%3E%3C/svg%3E") center/contain no-repeat;
    opacity: 0.5;
    z-index: 0;
}

.gallery-main:has(img.loaded)::before {
    animation: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-main:has(img.loaded)::after {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-main img {
    position: relative;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.15s ease;
    will-change: transform;
}

.gallery-main img.loaded {
    opacity: 1;
}
