/* Carousel wrapper: contains the entire carousel */
.elcwg-carousel-wrapper {
    position: relative;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    overflow: hidden;
    background-color: white !important; /* Force white background */
}

/* Remove any background color from cover elements */
.wp-block-cover__background,
.has-accent-6-background-color,
.has-background-dim {
    background-color: transparent !important;
}

/* Gallery base styles: ensure proper layout */
.wp-block-gallery.elcwg_carousel_active {
    width: 100%;
    margin: 0;
    padding: 0;
    display: block;
    height: auto;
    background-color: white !important; /* Force white background */
}

/* Inner wrapper: handles sliding animation */
.elcwg-carousel-inner {
    display: flex;
    flex-wrap: nowrap;
    transition: transform 0.5s ease;
    will-change: transform; /* Optimize for smoother animations */
    background-color: white !important; /* Force white background */
}

/* Slide styles: dynamic width based on --slides-per-view */
.elcwg-carousel-inner .wp-block-image {
    flex: 0 0 calc(100% / var(--slides-per-view, 1));
    width: calc(100% / var(--slides-per-view, 1));
    padding: 5px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: white !important; /* Force white background */
}

/* Image styles: ensure uniform sizing and coverage */
.elcwg-carousel-inner .wp-block-image img {
    width: 100%;
    height: auto; /* Fallback to natural height */
    min-height: 200px; /* Prevent collapse */
    object-fit: cover;
    display: block;
}

/* Caption styles: clean and readable */
.elcwg-carousel-inner .wp-block-image figcaption {
    position: absolute;
    bottom: 5px;
    left: 5px;
    right: 5px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    text-align: center;
    font-size: 0.9em;
    border-radius: 4px;
    max-height: 60px; /* Prevent overflow */
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Navigation arrows: centered, accessible, and subtle */
.elcwg-carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 1.3em;
    border-radius: 4px;
    transition: background 0.2s ease, transform 0.2s ease;
    z-index: 20;
}

.elcwg-carousel-nav.prev {
    left: 10px;
}

.elcwg-carousel-nav.next {
    right: 10px;
}

.elcwg-carousel-nav:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: translateY(-50%) scale(1.05);
}

.elcwg-carousel-nav:active {
    transform: translateY(-50%) scale(0.95);
}

/* Navigation dots: clean and interactive */
.elcwg-carousel-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 10px 0;
    z-index: 20;
    position: relative;
    background-color: white !important; /* Force white background */
}

.elcwg-carousel-dot {
    width: 10px;
    height: 10px;
    background: #ccc;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.3s ease, scale 0.2s ease;
}

.elcwg-carousel-dot.active {
    background: #333;
    scale: 1.2;
}

/* Non-carousel galleries: maintain WordPress default */
.wp-block-gallery:not(.elcwg_carousel_active) {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .elcwg-carousel-inner .wp-block-image img {
        min-height: 150px;
    }

    .elcwg-carousel-nav {
        padding: 8px 12px;
        font-size: 1.1em;
    }

    .elcwg-carousel-dot {
        width: 8px;
        height: 8px;
    }
}

@media (max-width: 480px) {
    .wp-block-gallery.elcwg_carousel_active {
        --slides-per-view: 1; /* Ensure consistency with JS */
    }

    .elcwg-carousel-inner .wp-block-image {
        flex: 0 0 100%;
        width: 100%;
    }

    .elcwg-carousel-inner .wp-block-image img {
        min-height: 120px;
    }

    .elcwg-carousel-nav {
        padding: 6px 10px;
        font-size: 1em;
    }
}

/* Paused state: visual feedback */
.elcwg-carousel-wrapper.paused .elcwg-carousel-nav,
.elcwg-carousel-wrapper.paused .elcwg-carousel-dot {
    opacity: 0.7;
}
