/**
 * Styles for Core Gallery as Swiper Carousel
 * These styles are applied only when the 'swiper' class is present.
 * The 'swiper' class is added via PHP filter only on the frontend.
 */

/* 1. FRONTEND ONLY: Carousel Layout */
/* Only triggers when 'swiper' class is injected by PHP on the frontend */
.wp-block-gallery.is-style-ccl-carousel.swiper {
    display: block !important;
    position: relative !important;
    overflow: hidden !important;
    padding-bottom: 50px;
    margin-bottom: 30px;
}

.wp-block-gallery.swiper .swiper-wrapper {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}

.wp-block-gallery.swiper .swiper-slide {
    flex-shrink: 0;
    width: 100%;
    height: auto;
    position: relative;
    transition-property: transform;
    display: block !important;
}

.wp-block-gallery.swiper .swiper-slide figure,
.wp-block-gallery.swiper .swiper-slide .wp-block-image {
    margin: 0 !important;
    width: 100% !important;
    display: block !important;
}

.wp-block-gallery.swiper .swiper-slide img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 8px;
    display: block !important;
}

/* Navigation Buttons */
.wp-block-gallery.swiper .swiper-button-prev,
.wp-block-gallery.swiper .swiper-button-next {
    width: 40px;
    height: 40px;
    background: var(--color-white) !important;
    border-radius: 50% !important;
    color: var(--color-primary) !important;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1) !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 10 !important;
}

.wp-block-gallery.swiper .swiper-button-prev::after,
.wp-block-gallery.swiper .swiper-button-next::after {
    font-size: 16px !important;
    font-weight: bold;
}

.wp-block-gallery.swiper .swiper-button-prev { left: 10px !important; }
.wp-block-gallery.swiper .swiper-button-next { right: 10px !important; }

/* Pagination */
.wp-block-gallery.swiper .swiper-pagination {
    bottom: 5px !important;
}

.wp-block-gallery.swiper .swiper-pagination-bullet-active {
    background: var(--color-accent) !important;
}

/* 2. EDITOR ONLY: Dynamic Grid based on classes */
/* We force the grid specifically for our style in the editor to avoid vertical stacking */
.editor-styles-wrapper .wp-block-gallery.is-style-ccl-carousel {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important; /* Default 3 columns */
    gap: 16px !important;
}

.editor-styles-wrapper .wp-block-gallery.is-style-ccl-carousel.items-1 { grid-template-columns: repeat(1, 1fr) !important; }
.editor-styles-wrapper .wp-block-gallery.is-style-ccl-carousel.items-2 { grid-template-columns: repeat(2, 1fr) !important; }
.editor-styles-wrapper .wp-block-gallery.is-style-ccl-carousel.items-3 { grid-template-columns: repeat(3, 1fr) !important; }
.editor-styles-wrapper .wp-block-gallery.is-style-ccl-carousel.items-4 { grid-template-columns: repeat(4, 1fr) !important; }
.editor-styles-wrapper .wp-block-gallery.is-style-ccl-carousel.items-5 { grid-template-columns: repeat(5, 1fr) !important; }
.editor-styles-wrapper .wp-block-gallery.is-style-ccl-carousel.items-6 { grid-template-columns: repeat(6, 1fr) !important; }

/* Ensure images in the editor don't behave like slides */
.editor-styles-wrapper .wp-block-gallery.is-style-ccl-carousel .wp-block-image {
    width: 100% !important;
    height: auto !important;
    margin: 0 !important;
}

/* Hide Swiper elements in editor */
.editor-styles-wrapper .wp-block-gallery.is-style-ccl-carousel .swiper-button-prev,
.editor-styles-wrapper .wp-block-gallery.is-style-ccl-carousel .swiper-button-next,
.editor-styles-wrapper .wp-block-gallery.is-style-ccl-carousel .swiper-pagination {
    display: none !important;
}
