/* Carousel wrapper: contains the entire carousel */
.elcwg-carousel-wrapper {
    position: relative;
    width: 100%;
    margin: 0 auto;
    overflow: hidden;
}

/* Gallery base styles: respect WordPress width */
.wp-block-gallery.elcwg_carousel_active {
    width: 100%;
    margin: 0;
    padding: 0;
    display: block;
}

/* Inner wrapper: handles sliding animation */
.elcwg-carousel-inner {
    display: flex;
    flex-wrap: nowrap;
    transition: transform 0.5s ease;
    will-change: transform;
}

/* 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: 0;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none !important;
    position: relative; /* Important pour le positionnement du caption */
    container-type: inline-size; /* Active les container queries */
}

/* Image styles: respect WordPress-defined sizes */
.elcwg-carousel-inner .wp-block-image img {
    width: 100%;
    height: auto;
    display: block;
    box-shadow: none !important;
}

/* Caption styles: proportionnel à la largeur de l'image */
.elcwg-carousel-inner .wp-block-image figcaption {
    position: absolute;
    bottom: 5px;
    left: 5px;
    right: 5px;
    padding: clamp(8px, 2cqi, 24px); /* Padding basé sur la largeur du conteneur */
    background: rgba(0, 0, 0, 0.7);
    color: white;
    text-align: center;
    font-size: clamp(1rem, 8cqi, 6rem); /* Texte basé sur la largeur de l'image */
    line-height: clamp(1.2, 1.4, 1.6);
    border-radius: clamp(4px, 1cqi, 12px);
    max-height: clamp(60px, 15cqi, 120px); /* Hauteur adaptative */
    overflow: hidden;
    text-overflow: ellipsis;
    backdrop-filter: blur(3px);
}

/* Pour les navigateurs plus anciens sans support cqi */
@supports not (font-size: 1cqi) {
    .elcwg-carousel-inner .wp-block-image figcaption {
        font-size: clamp(1rem, 8vw, 6rem);
        padding: clamp(8px, 2vw, 24px);
        border-radius: clamp(4px, 1vw, 12px);
        max-height: clamp(60px, 15vw, 120px);
    }
}

/* Hero page - version plus dramatique */
.elcwg-carousel-wrapper.hero-carousel .elcwg-carousel-inner .wp-block-image figcaption {
    font-size: clamp(1.5rem, 12cqi, 8rem); /* Plus grand pour hero */
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.8) 100%);
    padding: clamp(16px, 4cqi, 40px);
    border-radius: 0; /* Supprime les coins arrondis pour hero */
    max-height: clamp(80px, 25cqi, 200px);
    bottom: 0;
    left: 0;
    right: 0;
}

/* Version full-width hero */
.elcwg-carousel-wrapper.hero-carousel.elcwg-full-width .elcwg-carousel-inner .wp-block-image figcaption {
    font-size: clamp(2rem, 15cqi, 12rem); /* Encore plus grand pour full-width */
    padding: clamp(24px, 6cqi, 60px);
    max-height: clamp(120px, 35cqi, 300px);
}

/* 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: clamp(6px, 2vi, 14px) clamp(8px, 2.5vi, 16px);
    cursor: pointer;
    font-size: clamp(1rem, 3vi, 1.5rem);
    border-radius: clamp(2px, 0.5vi, 6px);
    transition: background 0.2s ease, transform 0.2s ease;
    z-index: 20;
    min-width: clamp(32px, 8vi, 48px);
    min-height: clamp(32px, 8vi, 48px);
}

.elcwg-carousel-nav.prev {
    left: clamp(5px, 2vi, 15px);
}

.elcwg-carousel-nav.next {
    right: clamp(5px, 2vi, 15px);
}

.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: clamp(4px, 1vi, 12px);
    margin: clamp(8px, 2vi, 16px) 0;
    z-index: 20;
    position: relative;
}

.elcwg-carousel-dot {
    width: clamp(8px, 2vi, 14px);
    height: clamp(8px, 2vi, 14px);
    background: #ccc;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.3s ease, scale 0.2s ease;
    min-width: 8px;
    min-height: 8px;
}

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

.elcwg-carousel-dot:hover {
    background: #666;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    :root {
        --slides-per-view: 2;
    }
}

@media (max-width: 480px) {
    .wp-block-gallery.elcwg_carousel_active {
        --slides-per-view: 1;
    }

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

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

/* Full width carousel modifier */
.elcwg-carousel-wrapper.elcwg-full-width {
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
}

/* Overlay dots positioning */
.elcwg-carousel-wrapper.elcwg-overlay-dots .elcwg-carousel-dots {
    position: absolute;
    bottom: clamp(10px, 3vi, 25px);
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    z-index: 30;
    background: rgba(0, 0, 0, 0.3);
    padding: clamp(4px, 1.5vi, 10px) clamp(8px, 3vi, 20px);
    border-radius: clamp(10px, 3vi, 25px);
    backdrop-filter: blur(5px);
}

.elcwg-carousel-wrapper.elcwg-overlay-dots .elcwg-carousel-dot {
    background: rgba(255, 255, 255, 0.6);
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.elcwg-carousel-wrapper.elcwg-overlay-dots .elcwg-carousel-dot.active {
    background: white;
    border-color: rgba(255, 255, 255, 0.8);
    scale: 1.3;
}

.elcwg-carousel-wrapper.elcwg-overlay-dots .elcwg-carousel-dot:hover {
    background: rgba(255, 255, 255, 0.8);
}

/* Responsive adjustments for overlay dots */
@media (max-width: 480px) {
    .elcwg-carousel-wrapper.elcwg-overlay-dots .elcwg-carousel-dots {
        bottom: 15px;
        padding: 6px 12px;
    }
}

/* Support for older browsers without vi units */
@supports not (font-size: 1vi) {
    .elcwg-carousel-nav {
        font-size: clamp(1rem, 3vw, 1.5rem);
        padding: clamp(6px, 2vw, 14px) clamp(8px, 2.5vw, 16px);
    }
    
    .elcwg-carousel-dot {
        width: clamp(8px, 2vw, 14px);
        height: clamp(8px, 2vw, 14px);
    }
    
    .elcwg-carousel-dots {
        gap: clamp(4px, 1vw, 12px);
        margin: clamp(8px, 2vw, 16px) 0;
    }
    
    .elcwg-carousel-wrapper.elcwg-overlay-dots .elcwg-carousel-dots {
        bottom: clamp(10px, 3vw, 25px);
        padding: clamp(4px, 1.5vw, 10px) clamp(8px, 3vw, 20px);
        border-radius: clamp(10px, 3vw, 25px);
    }
}

/* Variantes de style pour différents types de hero */
.elcwg-carousel-wrapper.hero-minimal .elcwg-carousel-inner .wp-block-image figcaption {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    font-weight: 300;
    text-shadow: none;
    backdrop-filter: blur(10px);
}

.elcwg-carousel-wrapper.hero-bold .elcwg-carousel-inner .wp-block-image figcaption {
    background: rgba(0, 0, 0, 0.9);
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: clamp(1px, 0.5cqi, 4px);
}

/* Animation d'apparition des captions */
.elcwg-carousel-inner .wp-block-image figcaption {
    opacity: 0;
    animation: fadeInUp 0.8s ease forwards;
    animation-delay: 0.3s;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Pause animation on hover */
.elcwg-carousel-wrapper:hover .elcwg-carousel-inner .wp-block-image figcaption {
    animation-play-state: paused;
}