/* ==========================================================================
   Loading shapes (skeletons): grey shapes in the exact place of the content that
   is still loading, with a soft shine moving across them.
   Used by the cart page (storefront/cart/_loading), the next page of products
   (storefront/listing/_results template) and product photos (js/storefront/photo-loading.js).

   Colours: shape #EEEAF4 · shine #FFFFFF at 65%
   ========================================================================== */

.skeleton {
    position: relative;
    display: block;
    overflow: hidden;
    border-radius: 6px;
    background: #EEEAF4;
}

.skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.65) 50%, rgba(255, 255, 255, 0) 100%);
    animation: skeleton-shine 1.3s ease-in-out infinite;
}

@keyframes skeleton-shine {
    100% { transform: translateX(100%); }
}

/* Sizes used by the shapes */
.skeleton--line    { height: 11px; }
.skeleton--title   { height: 13px; }
.skeleton--price   { height: 13px; width: 40px; }
.skeleton--button  { height: 32px; width: 60px; border-radius: 9px; }
.skeleton--stepper { height: 32px; width: 80px; border-radius: 9px; }
.skeleton--photo   { aspect-ratio: 1 / 1; border-radius: 14px; }
.skeleton--thumb   { width: 56px; height: 56px; border-radius: 12px; }
.skeleton--icon    { width: 42px; height: 42px; border-radius: 12px; }
.skeleton--tag     { width: 78px; height: 22px; border-radius: 8px; }

.skeleton--w90 { width: 90%; }
.skeleton--w75 { width: 75%; }
.skeleton--w60 { width: 60%; }
.skeleton--w45 { width: 45%; }
.skeleton--w35 { width: 35%; }

/* ---------- One product card while the next page loads ---------- */

.skeleton-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.skeleton-card__foot {
    margin-top: 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ---------- Cart page while the cart is checked ---------- */

.cart-skeleton {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cart-skeleton__card {
    padding: 12px 14px;
    border-radius: 16px;
    background: #FFFFFF;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cart-skeleton__how {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cart-skeleton__lines {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.cart-skeleton__head {
    padding: 2px 0 4px;
    display: flex;
    justify-content: space-between;
}

.cart-skeleton__row {
    padding: 10px 0;
    border-top: 1px solid #F2EFF6;
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
}

.cart-skeleton__bill-row {
    display: flex;
    justify-content: space-between;
}

/* ---------- Product photos: shine in the photo box until the photo has loaded ----------
   Only once photo-loading.js has started (it adds .has-photo-shimmer to <html>),
   so photos never stay hidden if the script cannot run. */

html.has-photo-shimmer [data-photo-box]:not(.is-loaded) {
    position: relative;
    overflow: hidden;
}

html.has-photo-shimmer [data-photo-box]:not(.is-loaded)::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(238, 234, 244, 0) 0%, rgba(238, 234, 244, 0.9) 50%, rgba(238, 234, 244, 0) 100%);
    transform: translateX(-100%);
    animation: skeleton-shine 1.3s ease-in-out infinite;
    pointer-events: none;
}

html.has-photo-shimmer [data-photo-box]:not(.is-loaded) img {
    opacity: 0;
}

[data-photo-box] img {
    transition: opacity 0.2s ease;
}

@media (prefers-reduced-motion: reduce) {
    .skeleton::after,
    html.has-photo-shimmer [data-photo-box]:not(.is-loaded)::after {
        animation: none;
    }

    [data-photo-box] img {
        transition: none;
    }
}
