/**
 * Layout Slider CSS
 * features/gallery-layout/assets/css/layout-slider.css
 */

/* Placeholder for Slider Layout to prevent CLS */
.wp-block-gallery.custom-layout[data-layout="slider"]:not(.layout-ready) {
    display: flex;
    white-space: nowrap;
    overflow-x: auto;
    gap: 10px;
}
.wp-block-gallery.custom-layout[data-layout="slider"]:not(.layout-ready) .wp-block-image {
    min-width: 300px; /* Approximate width */
    opacity: 0.5; /* Show partially */
}

/* Spinner for Slider */
.wp-block-gallery.custom-layout[data-layout="slider"].is-loading::before,
.wp-block-gallery.custom-layout[data-layout="carousel"].is-loading::before {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* R. Slider - Restored Styles */
.wp-block-gallery.custom-layout[data-layout="slider"] {
    height: 50vh;
    max-height: 500px;
    min-height: 300px;
    background: #f0f0f0;
    display: block;
    opacity: 1;
    width: 100%;
}

.wp-block-gallery.custom-layout[data-layout="slider"] .flickity-viewport,
.wp-block-gallery.custom-layout[data-layout="slider"] .flickity-slider { 
    height: 100%; 
    width: 100%;
}

.wp-block-gallery.custom-layout[data-layout="slider"] .gallery-cell {
    height: 100%;
    margin-right: 10px;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #fff; /* Optional: Ensure visibility */
}

/* Column logic */
.wp-block-gallery.custom-layout[data-layout="slider"][data-slider-cols="1"] .gallery-cell { width: 100%; }
.wp-block-gallery.custom-layout[data-layout="slider"][data-slider-cols="2"] .gallery-cell { width: calc(50% - 10px); }
.wp-block-gallery.custom-layout[data-layout="slider"][data-slider-cols="3"] .gallery-cell { width: calc(33.333% - 13.3px); /* Adjusted for mr-10 */ }
.wp-block-gallery.custom-layout[data-layout="slider"][data-slider-cols="4"] .gallery-cell { width: calc(25% - 10px); }
.wp-block-gallery.custom-layout[data-layout="slider"]:not([data-slider-cols]) .gallery-cell { width: 100%; }

.wp-block-gallery.custom-layout[data-layout="slider"] .gallery-cell img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.wp-block-gallery.custom-layout[data-layout="slider"] .flickity-enabled { outline: none; }
.wp-block-gallery.custom-layout[data-layout="slider"] .flickity-page-dots { bottom: -40px; }
.wp-block-gallery.custom-layout[data-layout="slider"] .flickity-prev-next-button { background: rgba(255, 255, 255, 0.8); border-radius: 50%; }


/* --- A1. Carousel 輪播圖 (New Style based on Slider) --- */
.wp-block-gallery.custom-layout[data-layout="carousel"] {
    height: 60vh;
    max-height: 550px;
    min-height: 350px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 12px;
    padding: 20px;
    display: block;
    opacity: 1;
}
.wp-block-gallery.custom-layout[data-layout="carousel"] .flickity-viewport,
.wp-block-gallery.custom-layout[data-layout="carousel"] .flickity-slider { height: 100%; }
.wp-block-gallery.custom-layout[data-layout="carousel"] .gallery-cell {
    height: 100%;
    margin-right: 15px;
    box-sizing: border-box;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    width: auto; 
}
.wp-block-gallery.custom-layout[data-layout="carousel"] .gallery-cell img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.wp-block-gallery.custom-layout[data-layout="carousel"] .flickity-page-dots {
    bottom: -30px;
}
.wp-block-gallery.custom-layout[data-layout="carousel"] .flickity-page-dots .dot {
    background: rgba(255, 255, 255, 0.5);
}
.wp-block-gallery.custom-layout[data-layout="carousel"] .flickity-page-dots .dot.is-selected {
    background: #fff;
}
.wp-block-gallery.custom-layout[data-layout="carousel"] .flickity-prev-next-button {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
}


/* --- RESPONSIVE --- */
@media (max-width: 768px) {
    .wp-block-gallery.custom-layout[data-layout="slider"] {
        width: 100vw;
        max-width: 100vw;
        margin-left: calc(50% - 50vw);
        margin-right: calc(50% - 50vw);
    }
}

@media (max-width: 480px) {
    /* Slider 強制變為單欄 */
    .wp-block-gallery.custom-layout[data-layout="slider"][data-slider-cols="2"] .gallery-cell,
    .wp-block-gallery.custom-layout[data-layout="slider"][data-slider-cols="3"] .gallery-cell,
    .wp-block-gallery.custom-layout[data-layout="slider"][data-slider-cols="4"] .gallery-cell {
        width: 100%;
    }
    
    /* Carousel */
    .wp-block-gallery.custom-layout[data-layout="carousel"] {
        height: 45vh;
        min-height: 280px;
        padding: 10px;
    }
}
