/* Fallback sebelum Swiper terinisialisasi */
.custom-stacked-carousel {
    display: block;
    position: relative;
}

.custom-stacked-carousel:not(.swiper-initialized) .swiper-wrapper {
    display: flex;
    flex-wrap: nowrap;
}

.custom-stacked-carousel:not(.swiper-initialized) .swiper-slide:not(:first-child) {
    display: none; /* Sembunyikan gambar lain sebelum JS jalan */
}

.custom-stacked-carousel {
    width: 100%;
    max-width: 400px; /* Sesuaikan dengan kebutuhan desain Anda */
    margin: 0 auto;
    padding-bottom: 20px;
    overflow: visible !important; /* Penting agar shadow dan kartu belakang tidak terpotong */
}

.custom-stacked-carousel .swiper-slide {
    border-radius: 20px;
    overflow: hidden;
    aspect-ratio: 4 / 5;
    box-shadow: -5px 10px 30px rgba(0, 0, 0, 0.2);
    background-color: #fff;
}

.custom-stacked-carousel .swiper-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Mencegah kebocoran layout horizontal pada layar mobile */
.elementor-widget-stacked_gallery {
    max-width: 100vw;
    overflow-x: unset;
    padding: 20px; /* Memberikan sedikit ruang bernapas agar bayangan tidak terpotong tajam */
}

/* ==========================================================================
   FINAL FIX: MASONRY GRID CAROUSEL (NO GAPS & NO DESKTOP DRAG BUG)
   ========================================================================== */

/* Kontainer Utama Carousel */
.custom-grid-carousel {
    width: 100%;
    position: relative;
    overflow: hidden;
}

/* Memastikan Wrapper Swiper Tetap Flexbox ke Samping */
.custom-grid-carousel .swiper-wrapper {
    display: flex !important;
    align-items: stretch;
}

/* Layout Grid per Slide */
.grid-slide-layout {
    display: grid !important;
    width: 100% !important;
    flex-shrink: 0 !important; /* Mencegah slide mengkerut */
    grid-template-columns: 2fr repeat(var(--small-cols, 2), 1fr);
    grid-template-rows: repeat(var(--small-rows, 2), min-content);
    align-items: stretch; 
}

/* Kontainer untuk Masing-masing Gambar */
.grid-gallery-item {
    display: block;
    width: 100%;
    position: relative; 
    overflow: hidden;
}

/* ─── GAMBAR KECIL (Kanan) ─── */
.grid-gallery-item:not(:nth-child(1)) {
    aspect-ratio: var(--img-aspect, 4/5) !important;
}

/* ─── GAMBAR UTAMA / BESAR (Kiri) ─── */
.grid-gallery-item:nth-child(1) {
    grid-column: 1;
    grid-row: span var(--small-rows, 2);
    height: 100%; /* Memaksa tinggi mengikuti total tumpukan gambar kecil */
}

/* ─── ANTI GHOST DRAG DESKTOP ─── */
.custom-grid-carousel a,
.custom-grid-carousel img,
.grid-gallery-item {
    -webkit-user-drag: none !important;
    -khtml-user-drag: none !important;
    -moz-user-drag: none !important;
    -o-user-drag: none !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    pointer-events: auto !important; /* Klik Lightbox tetap aktif */
}

/* ─── PENGATURAN TAG GAMBAR DI DALAM GRID ─── */
.grid-gallery-item img {
    position: absolute !important; /* Keluar dari flow agar tidak merusak baris grid */
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important; /* Memotong gambar secara proporsional tanpa gap */
    display: block;
    transition: transform 0.4s ease;
}

/* Efek Hover Gambar */
.grid-gallery-item:hover img {
    transform: scale(1.05);
}

/* Navigasi Arrow (Pastikan di Lapisan Teratas) */
.custom-grid-carousel .custom-nav-btn {
    color: #fff;
    background: rgba(0, 0, 0, 0.4);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10 !important;
}

.custom-grid-carousel .custom-nav-btn::after {
    font-size: 16px;
    font-weight: bold;
}

/* ─── RESPONSIF MOBILE (DIBAWAH 768px) ─── */
@media (max-width: 768px) {
    .grid-slide-layout {
        grid-template-columns: 1fr 1fr !important;
        grid-template-rows: auto !important;
    }
    .grid-gallery-item:nth-child(1) {
        grid-column: span 2 !important;
        grid-row: span 1 !important;
        aspect-ratio: var(--img-aspect, 4/5) !important;
    }
}