/* Skeleton Loading Animation */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

.skeleton {
    background: #e0e0e0;
    /* Darker base */
    background-image: linear-gradient(90deg,
            #e0e0e0 25%,
            #d0d0d0 50%,
            #e0e0e0 75%);
    /* Darker shimmer */
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite linear;

    /* Layout */
    display: block;
    width: 100%;
    position: relative;
    /* Default to relative */
    overflow: hidden;
    z-index: 1;
}

/* Force Square Aspect Ratio for Product Cards */
/* This ensures 1:1 box even if image is 0 height */
.skeleton::before {
    content: "";
    display: block;
    padding-top: 100%;
    /* 1:1 Ratio */
}

/* Absolute position the content (img) inside the skeleton so it doesn't push height */
.skeleton img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    /* Hide image initially */
    transition: opacity 0.3s ease;
}

/* Once loaded, we remove .skeleton class. 
   The wrapper wrapper div remains. 
   We need to ensure it behaves correctly when NOT skeleton. */

/* When image loads, it gets .loaded class. */
img.loaded {
    opacity: 1 !important;
    position: static !important;
    /* Restore normal flow */
    height: auto !important;
}

/* Overrides for specific containers */
.home-img .skeleton::before {
    padding-top: 125%;
    /* Taller ratio for main product image if typical, or 100% */
}

/* Skeleton Text - for loading text placeholders */
.skeleton-text {
    background: #e0e0e0;
    background-image: linear-gradient(90deg,
            #e0e0e0 25%,
            #d0d0d0 50%,
            #e0e0e0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite linear;
    color: transparent !important;
    border-radius: 4px;
    display: inline-block;
    min-height: 1em;
    user-select: none;
    pointer-events: none;
}

/* Skeleton Block - for larger content blocks */
.skeleton-block {
    background: #e0e0e0;
    background-image: linear-gradient(90deg,
            #e0e0e0 25%,
            #d0d0d0 50%,
            #e0e0e0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite linear;
    border-radius: 8px;
    min-height: 100px;
}

/* Loaded state for text */
.skeleton-text.loaded,
.skeleton-block.loaded {
    background: none !important;
    color: inherit !important;
    animation: none !important;
    user-select: auto;
    pointer-events: auto;
}