/* ============================================
   GLOBAL IMAGE LOADER - Skeleton + Spinner
   Applied automatically to all <img> tags
   ============================================ */

/* Wrapper created by JS around every tracked image */
.img-loader-wrap {
    position: relative;
    overflow: hidden;
    background: #f1f5f9;
}

/* Skeleton shimmer animation */
.img-loader-wrap::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        #f1f5f9 25%,
        #e2e8f0 37%,
        #f1f5f9 63%
    );
    background-size: 400% 100%;
    animation: imgShimmer 1.4s ease infinite;
    z-index: 1;
    transition: opacity 0.3s ease;
}

/* Spinner in the center */
.img-loader-wrap::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    border: 3px solid #e2e8f0;
    border-top-color: #94a3b8;
    border-radius: 50%;
    animation: imgSpin 0.7s linear infinite;
    z-index: 2;
    transition: opacity 0.3s ease;
}

/* When image is loaded, hide skeleton + spinner */
.img-loader-wrap.loaded::before,
.img-loader-wrap.loaded::after {
    opacity: 0;
    pointer-events: none;
}

/* Image starts invisible, fades in when loaded */
.img-loader-wrap img {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.img-loader-wrap.loaded img {
    opacity: 1;
}

@keyframes imgShimmer {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

@keyframes imgSpin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Match the border-radius of the parent if any */
.img-loader-wrap {
    border-radius: inherit;
}
