/* GALERI AWAL - CSS yang Dioptimalkan */

/* Reset & Global Styles */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Variabel CSS untuk kemudahan manajemen */
    --color-primary: #4facfe;
    --color-secondary: #00f2fe;
    --color-bg-dark: #000;
    --color-text-light: #fff;
    --color-overlay-dark: rgba(0, 0, 0, 0.95);
    --color-glass-light: rgba(255, 255, 255, 0.15);
    --color-glass-border: rgba(255, 255, 255, 0.2);
    --transition-fast: 0.3s ease;
    --transition-slow: 0.4s ease;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: var(--color-bg-dark);
    color: var(--color-text-light);
    overflow-x: hidden;
}

body, html {
    height: 100%;
    min-height: 100vh;
}

/* --- Sticky Gallery --- */
.custom-gallery-wrapper {
    height: 400vh;
    position: relative;
    width: 100%;
}

.custom-gallery-container {
    position: sticky;
    top: 0;
    width: 100%; /* Gunakan 100% agar sesuai dengan parent, menghindari overflow */
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 0 20px; /* Tambahan padding untuk mobile */
}

.custom-home_gallery-layout {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 12px;
    /* Fixed width calculation untuk center yang sempurna */
    width: min(calc(100vw - 40px), 1200px);
    height: min(calc(100vh - 40px), 800px);
    max-width: 1200px;
    max-height: 800px;
    transform-origin: center center; /* Ubah ke center center */
    will-change: transform;
    perspective: 1000px;
    /* Ensure perfect centering */
    margin: 0 auto;
    position: relative;
	
}

.custom-home_gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    cursor: pointer;
    transform-style: preserve-3d;
    backface-visibility: hidden;
    transition: transform var(--transition-slow);
    /* Ensure consistent sizing */
    min-height: 200px;
    background: #333; /* Fallback background */
}

.custom-home_gallery-item:hover {
    transform: scale(1.05);
    box-shadow: 0 20px 40px rgba(255, 255, 255, 0.15);
    z-index: 2;
}

.custom-home_gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
    will-change: transform;
    display: block; /* Ensure no inline spacing */
}

.custom-home_gallery-item:hover img {
    transform: scale(1.1);
}

/* Solusi: Sembunyikan indikator zoom */
.custom-zoom-indicator {
    display: none;
}

.custom-scroll-hint {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 100px;
    opacity: 0.6;
    font-size: 12px;
    z-index: 100;
    animation: fadeInOut 3s infinite;
    transition: opacity var(--transition-fast);
}

.custom-scroll-hint.hidden {
    opacity: 0;
    visibility: hidden;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.8; }
}

/* Lightbox Styles */
.custom-lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--color-overlay-dark);
    z-index: 1000;
    backdrop-filter: blur(20px);
}

.custom-lightbox.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.4s ease;
}

.custom-lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-lightbox img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.8);
    animation: zoomIn 0.4s ease;
}

.custom-close-btn,
.custom-nav-arrow {
    background: var(--color-glass-light);
    backdrop-filter: blur(15px);
    border: 1px solid var(--color-glass-border);
    color: var(--color-text-light);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    font-weight: bold;
    z-index: 1001;
}

.custom-close-btn {
    position: absolute;
    top: 25px;
    right: 25px;
    font-size: 24px;
    width: 50px;
    height: 50px;
}

.custom-close-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1) rotate(90deg);
}

.custom-nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 24px;
    width: 60px;
    height: 60px;
}

.custom-nav-arrow:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) scale(1.1);
}

.custom-nav-arrow.prev {
    left: 30px;
}

.custom-nav-arrow.next {
    right: 30px;
}

/* Media Queries untuk responsive yang lebih baik */

/* Desktop Large */
@media (min-width: 1440px) {
    .custom-gallery-container {
        padding: 0 40px;
    }
    
    .custom-home_gallery-layout {
        width: min(calc(100vw - 80px), 1400px);
        height: min(calc(100vh - 80px), 900px);
        gap: 15px;
    }
}

/* Desktop Standard */
@media (max-width: 1439px) and (min-width: 1024px) {
    .custom-gallery-container {
        padding: 0 30px;
    }
    
    .custom-home_gallery-layout {
        width: min(calc(100vw - 60px), 1200px);
        height: min(calc(100vh - 60px), 800px);
        gap: 12px;
    }
}

/* Tablet Landscape */
@media (max-width: 1023px) and (min-width: 769px) {
    .custom-gallery-container {
        padding: 0 25px;
    }
    
    .custom-home_gallery-layout {
        width: calc(100vw - 50px);
        height: calc(100vh - 50px);
        gap: 10px;
    }
}

/* Tablet Portrait & Mobile Landscape */
@media (max-width: 768px) and (orientation: landscape) {
    .custom-gallery-container {
        padding: 0 20px;
    }
    
    .custom-home_gallery-layout {
        width: calc(100vw - 40px);
        height: calc(100vh - 40px);
        gap: 8px;
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(2, 1fr);
    }
}

/* Mobile Portrait */
@media (max-width: 768px) and (orientation: portrait) {
    .custom-gallery-container {
        padding: 0 15px;
    }
    
    .custom-home_gallery-layout {
        width: calc(100vw - 30px);
        height: calc(100vh - 30px);
        gap: 8px;
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(4, minmax(120px, 1fr));
        max-height: 85vh;
    }
    
    .custom-home_gallery-item {
        min-height: 120px;
    }
    
    .custom-close-btn, .custom-nav-arrow {
        width: 45px;
        height: 45px;
        font-size: 20px;
    }

    .custom-nav-arrow.prev { left: 20px; }
    .custom-nav-arrow.next { right: 20px; }
}

/* Small Mobile */
@media (max-width: 480px) {
    .custom-gallery-container {
        padding: 0 10px;
    }
    
    .custom-home_gallery-layout {
        width: calc(100vw - 20px);
        height: calc(100vh - 20px);
        gap: 6px;
        grid-template-rows: repeat(4, minmax(100px, 1fr));
    }
    
    .custom-home_gallery-item { 
        border-radius: 8px;
        min-height: 100px;
    }

    .custom-close-btn, .custom-nav-arrow {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .custom-close-btn { top: 15px; right: 15px; }
    .custom-nav-arrow.prev { left: 15px; }
    .custom-nav-arrow.next { right: 15px; }
}

/* Animasi & Efek */
.custom-home_gallery-item-loading {
    background: linear-gradient(90deg, #333 25%, #444 50%, #333 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

.custom-home_gallery-item-loading img {
    opacity: 0;
}

@keyframes loading {
    to { background-position: -200% 0; }
}

@keyframes fadeIn {
    from { opacity: 0; backdrop-filter: blur(0); }
    to { opacity: 1; backdrop-filter: blur(20px); }
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Menonaktifkan efek hover pada perangkat sentuh */
@media (hover: none) and (pointer: coarse) {
    .custom-home_gallery-item:hover,
    .custom-home_gallery-item:hover img,
    .custom-close-btn:hover,
    .custom-nav-arrow:hover {
        transform: none !important;
        box-shadow: none !important;
        background: var(--color-glass-light);
    }
    .custom-close-btn:hover { background: var(--color-glass-light); }
    .custom-nav-arrow:hover { background: var(--color-glass-light); }
}

/* Touch feedback untuk mobile */
@media (hover: none) and (pointer: coarse) {
    .custom-home_gallery-item:active {
        transform: scale(0.98);
        opacity: 0.8;
    }
    
    .custom-close-btn:active,
    .custom-nav-arrow:active {
        background: rgba(255, 255, 255, 0.3);
        transform: scale(0.95);
    }
    
    .custom-nav-arrow.prev:active {
        transform: translateY(-50%) scale(0.95);
    }
    
    .custom-nav-arrow.next:active {
        transform: translateY(-50%) scale(0.95);
    }
}

/* Debug helper - hapus setelah testing */
/* 
.custom-gallery-container {
    border: 2px solid red;
}

.custom-home_gallery-layout {
    border: 2px solid blue;
}
*/