/* Lazy carousel CLS: skeleton, reserve heights, swiper pending state */
/* Reserve height is a fixed box while loading only; after .bss-lazy-loaded content grows naturally. */
.bss-lazy-carousel:not(.bss-lazy-loaded) {
    overflow: hidden;
    contain: layout;
    box-sizing: border-box;
    min-height: var(--bss-carousel-reserve, 300px);
    max-height: var(--bss-carousel-reserve, 300px);
    height: var(--bss-carousel-reserve, 300px);
}

.bss-lazy-carousel.bss-lazy-loaded {
    overflow: visible;
    contain: none;
    height: auto;
    max-height: none;
}

@media (max-width: 768px) {
    .bss-lazy-carousel:not(.bss-lazy-loaded) {
        min-height: var(--bss-carousel-reserve-mobile, var(--bss-carousel-reserve, 260px));
        max-height: var(--bss-carousel-reserve-mobile, var(--bss-carousel-reserve, 260px));
        height: var(--bss-carousel-reserve-mobile, var(--bss-carousel-reserve, 260px));
    }
}

.bss-carousel-skeleton {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 8px 0 16px;
    pointer-events: none;
}

.bss-lazy-carousel:not(.bss-lazy-loaded) .bss-carousel-skeleton,
.bss-carousel-skeleton--overlay {
    height: 100%;
    max-height: 100%;
    box-sizing: border-box;
    overflow: hidden;
    padding: 8px 0;
    gap: 8px;
}

.bss-lazy-carousel:not(.bss-lazy-loaded) .bss-carousel-skeleton__banner,
.bss-carousel-skeleton--overlay .bss-carousel-skeleton__banner {
    flex: 0 0 auto;
    width: 100%;
    max-height: 35%;
    aspect-ratio: 16 / 9;
}

.bss-lazy-carousel:not(.bss-lazy-loaded) .bss-carousel-skeleton__slides,
.bss-carousel-skeleton--overlay .bss-carousel-skeleton__slides {
    flex: 1 1 auto;
    min-height: 0;
    align-items: stretch;
}

.bss-lazy-carousel:not(.bss-lazy-loaded) .bss-carousel-skeleton__slide,
.bss-carousel-skeleton--overlay .bss-carousel-skeleton__slide {
    flex: 1 1 0;
    min-width: 0;
    min-height: 0;
    aspect-ratio: unset;
    height: 100%;
}

.bss-carousel-skeleton__head {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 0 0 auto;
}

.bss-carousel-skeleton__banner {
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: 280px;
    border-radius: 6px;
}

.bss-carousel-skeleton__slides {
    display: flex;
    gap: 16px;
    overflow: hidden;
}

/* Legacy fallback only; lazy-load skeleton slide count/width comes from _LazyCarouselSkeleton.cshtml */
.bss-carousel-skeleton__slide {
    flex: 0 0 calc((100% - 48px) / 4);
    min-width: 120px;
    aspect-ratio: 3 / 4;
    border-radius: 6px;
}

.bss-carousel-skeleton__line {
    border-radius: 4px;
}

.bss-carousel-skeleton__line--title {
    width: 30%;
    min-width: 160px;
    height: 28px;
}

.bss-carousel-skeleton__line--subtitle {
    width: 45%;
    min-width: 200px;
    height: 16px;
}

.bss-carousel-skeleton__thumb {
    width: 100%;
    aspect-ratio: var(--bss-skeleton-thumb-ratio, 1 / 1);
    flex: 0 1 auto;
    min-height: 0;
    border-radius: 6px;
}

.bss-carousel-skeleton__line--name {
    width: 80%;
    height: 16px;
}

.bss-carousel-skeleton__line--price {
    width: 40%;
    height: 18px;
}

.bss-carousel-skeleton__line--button {
    width: 100%;
    height: 40px;
    margin-top: auto;
    border-radius: 6px;
}

/* Shimmer: compositor-friendly transform sweep instead of background-position repaints.
   Colors are theme-overridable via --bss-skeleton-base / --bss-skeleton-highlight. */
.bss-carousel-skeleton__slide,
.bss-carousel-skeleton__banner,
.bss-carousel-skeleton__thumb,
.bss-carousel-skeleton__line {
    position: relative;
    overflow: hidden;
    background: var(--bss-skeleton-base, #ececec);
}

.bss-carousel-skeleton__slide::after,
.bss-carousel-skeleton__banner::after,
.bss-carousel-skeleton__thumb::after,
.bss-carousel-skeleton__line::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: -60%;
    width: 60%;
    background: linear-gradient(90deg, transparent, var(--bss-skeleton-highlight, #f5f5f5), transparent);
    animation: bss-skeleton-sweep 1.4s ease-in-out infinite;
}

/* Structured product-card skeleton: the slide is a transparent column, its parts shimmer */
.bss-carousel-skeleton__slide--card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: transparent;
}

.bss-carousel-skeleton__slide--card::after {
    display: none;
}

@keyframes bss-skeleton-sweep {
    to { transform: translateX(280%); }
}

@media (prefers-reduced-motion: reduce) {
    .bss-carousel-skeleton__slide::after,
    .bss-carousel-skeleton__banner::after,
    .bss-carousel-skeleton__thumb::after,
    .bss-carousel-skeleton__line::after {
        animation: none;
    }
}

/* Cross-fade: the skeleton stays as an overlay above incoming content, then fades out */
.bss-lazy-carousel.bss-skeleton-cover {
    position: relative;
}

.bss-carousel-skeleton--overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    z-index: 2;
    opacity: 1;
    transition: opacity 0.25s ease-out;
    background: var(--bss-skeleton-cover-bg, #fff);
}

.bss-carousel-skeleton--fade {
    opacity: 0;
}

.anywhere-carousel-wrapper .swiper.bss-swiper-pending {
    opacity: 0;
    min-height: 0;
}

.anywhere-carousel-wrapper .swiper.bss-swiper-ready {
    opacity: 1;
    min-height: 0;
    transition: opacity 0.2s ease-out;
}

.products-carousel .carousel-banner-box .banner-link .banner {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

/* Footer fallback when inline CSS variables are absent */
.bss-lazy-type-product:not([style*="--bss-carousel-reserve"]),
.bss-lazy-type-discountproduct:not([style*="--bss-carousel-reserve"]),
.bss-lazy-type-discountproductcategory:not([style*="--bss-carousel-reserve"]),
.bss-lazy-type-discountproductmanufacturer:not([style*="--bss-carousel-reserve"]) {
    min-height: 420px;
}

.bss-lazy-type-category:not([style*="--bss-carousel-reserve"]),
.bss-lazy-type-bestsellingcategories:not([style*="--bss-carousel-reserve"]),
.bss-lazy-type-catalogpagecategory:not([style*="--bss-carousel-reserve"]) {
    min-height: 300px;
}

.bss-lazy-type-trendingcategory:not([style*="--bss-carousel-reserve"]),
.bss-lazy-type-trendingmanufacturer:not([style*="--bss-carousel-reserve"]) {
    min-height: 330px;
}

.bss-lazy-type-manufacturer:not([style*="--bss-carousel-reserve"]),
.bss-lazy-type-vendor:not([style*="--bss-carousel-reserve"]) {
    min-height: 230px;
}

.bss-lazy-type-review:not([style*="--bss-carousel-reserve"]) {
    min-height: 260px;
}

.bss-lazy-type-store:not([style*="--bss-carousel-reserve"]),
.bss-lazy-type-services:not([style*="--bss-carousel-reserve"]) {
    min-height: 300px;
}

@media (max-width: 768px) {
    .bss-lazy-type-product:not([style*="--bss-carousel-reserve"]),
    .bss-lazy-type-discountproduct:not([style*="--bss-carousel-reserve"]),
    .bss-lazy-type-discountproductcategory:not([style*="--bss-carousel-reserve"]),
    .bss-lazy-type-discountproductmanufacturer:not([style*="--bss-carousel-reserve"]) {
        min-height: 380px;
    }

    .bss-lazy-type-category:not([style*="--bss-carousel-reserve"]),
    .bss-lazy-type-bestsellingcategories:not([style*="--bss-carousel-reserve"]),
    .bss-lazy-type-catalogpagecategory:not([style*="--bss-carousel-reserve"]) {
        min-height: 260px;
    }

    .bss-lazy-type-trendingcategory:not([style*="--bss-carousel-reserve"]),
    .bss-lazy-type-trendingmanufacturer:not([style*="--bss-carousel-reserve"]) {
        min-height: 300px;
    }

    .bss-lazy-type-manufacturer:not([style*="--bss-carousel-reserve"]),
    .bss-lazy-type-vendor:not([style*="--bss-carousel-reserve"]) {
        min-height: 200px;
    }

    .bss-lazy-type-review:not([style*="--bss-carousel-reserve"]) {
        min-height: 240px;
    }

    .bss-lazy-type-store:not([style*="--bss-carousel-reserve"]),
    .bss-lazy-type-services:not([style*="--bss-carousel-reserve"]) {
        min-height: 260px;
    }
}
