/* CSS Variables untuk kontrol 3D yang Presisi & Responsif */
:root {
    --depth: 600px; /* Kedalaman lorong di desktop */
}

@media (max-width: 992px) {
    :root {
        --depth: 450px; /* Lebih dangkal di tablet */
    }
}

@media (max-width: 576px) {
    :root {
        --depth: 300px; /* Sangat pas untuk HP portrait */
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: #000;
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: sans-serif;
}

/* Kontainer Utama Kamera 3D */
.gallery-container {
    width: 100vw;
    height: 100vh;
    perspective: 800px; /* Jarak pandang kamera */
    perspective-origin: center;
    position: relative;
}

/* Ruangan Lorong 3D */
.cube-room {
    position: absolute;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

/* Base Dinding */
.wall {
    position: absolute;
    backface-visibility: hidden;
    pointer-events: none;
    background-color: #0a0a0a;
    box-sizing: border-box;
}

/* Grid khusus dinding dengan foto */
.wall-grid {
    display: grid;
    gap: 15px;
    padding: 20px;
}

/* --- DINDING TENGAH --- */
.center-wall {
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    transform: translateZ(calc(-1 * var(--depth))); /* Menempel pas di ujung kedalaman */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    text-align: center;
    background-color: #111;
    background-size: cover;
    background-position: center;
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: background-image 0.5s ease, border-color 0.5s ease;
    pointer-events: auto;
    z-index: 1;
}

.center-wall::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1;
    opacity: 0;
    transition: opacity 0.5s;
}
.center-wall.has-bg::before {
    opacity: 1;
}

.hero-text {
    z-index: 2;
    padding: 20px;
}

.reset-bg-btn {
    margin-top: 15px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid #fff;
    color: #fff;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    display: none;
    transition: background 0.2s;
}
.reset-bg-btn:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* --- SISI LORONG (MATEMATIKA 3D PRESISI & SEAMLESS) --- */
.left-wall {
    width: var(--depth);
    height: 100%;
    left: 0;
    top: 0;
    transform: rotateY(90deg);
    transform-origin: left center;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(4, 1fr);
}

.right-wall {
    width: var(--depth);
    height: 100%;
    right: 0;
    top: 0;
    transform: rotateY(-90deg);
    transform-origin: right center;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(4, 1fr);
}

.top-wall {
    width: 100%;
    height: var(--depth);
    left: 0;
    top: 0;
    transform: rotateX(-90deg);
    transform-origin: center top;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(3, 1fr);
}

.bottom-wall {
    width: 100%;
    height: var(--depth);
    left: 0;
    bottom: 0;
    transform: rotateX(90deg);
    transform-origin: center bottom;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(3, 1fr);
}

/* --- ITEM GAMBAR --- */
.wall .photo-item {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.15);
    filter: brightness(0.4);
    transition: filter 0.3s, transform 0.3s, border-color 0.3s;
    cursor: pointer;
    pointer-events: auto;
}

.wall .photo-item:hover {
    filter: brightness(1);
    transform: scale(1.03);
    border-color: #fff;
    z-index: 10;
}

/* --- RESPONSIVE UNTUK LAYAR MOBILE --- */
@media (max-width: 768px) {
    .wall-grid {
        gap: 8px;
        padding: 10px;
    }

    /* Penataan grid vertikal karena layar HP sempit & tinggi */
    .left-wall, .right-wall {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(6, 1fr);
    }

    /* Penataan grid horizontal untuk atap & lantai */
    .top-wall, .bottom-wall {
        grid-template-columns: repeat(6, 1fr);
        grid-template-rows: repeat(2, 1fr);
    }

    .center-wall h1 {
        font-size: 2.2rem !important;
    }
    .center-wall p {
        font-size: 0.9rem !important;
    }
}
