/* Folder-style 3D gallery matching the mobile reference screenshots */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    overflow: hidden;
    background: #000;
    color: #fff;
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    user-select: none;
}

.hidden { display: none !important; }

#viewport {
    position: fixed;
    inset: 0;
    perspective: 1400px;
    perspective-origin: 50% 46%;
    overflow: hidden;
    cursor: grab;
    touch-action: none;
}
#viewport:active { cursor: grabbing; }

#scene {
    position: absolute;
    left: 50%;
    top: 48%;
    transform-style: preserve-3d;
    will-change: transform;
}

/* Portrait folder tiles — thin white border, label, play badge */
.folder-card {
    position: absolute;
    width: 240px;
    height: 320px;
    margin-left: -120px;
    margin-top: -160px;
    padding: 0;
    border: 2px solid #fff;
    border-radius: 2px;
    overflow: hidden;
    background: #111;
    color: inherit;
    transform-style: preserve-3d;
    will-change: transform, opacity;
    backface-visibility: hidden;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.65);
    cursor: pointer;
    pointer-events: none;
}

.folder-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0;
    transition: opacity 0.45s ease;
    pointer-events: none;
}

.folder-card.loaded img { opacity: 1; }

.folder-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.72) 0%, rgba(0,0,0,0.05) 42%, transparent 62%);
    pointer-events: none;
}

.folder-label {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 8px;
    z-index: 2;
    text-align: center;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.01em;
    text-shadow: 0 1px 4px rgba(0,0,0,0.9);
    padding: 0 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.play-badge {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 3;
    width: 36px;
    height: 36px;
    margin: -18px 0 0 -18px;
    border-radius: 50%;
    background: rgba(255,255,255,0.16);
    border: 2px solid #fff;
    pointer-events: none;
}
.play-badge::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 54%;
    transform: translate(-50%, -50%);
    border-left: 11px solid #fff;
    border-top: 7px solid transparent;
    border-bottom: 7px solid transparent;
}

.folder-card.selected {
    border-color: #fff;
    box-shadow:
        0 0 0 1px #fff,
        0 18px 40px rgba(0, 0, 0, 0.75);
}
.folder-card:hover { filter: brightness(1.08); }

#topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 14px 18px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.82), transparent);
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    border: 0;
    background: transparent;
    color: #fff;
    cursor: pointer;
    text-decoration: none;
}

.topbar-titles { flex: 1; min-width: 0; }
#page-title {
    font-size: 20px;
    font-weight: 600;
    line-height: 1.1;
}
#page-crumb {
    margin-top: 2px;
    font-size: 11px;
    color: rgba(255,255,255,0.48);
}

.mode-3d {
    width: 40px;
    height: 40px;
    border: 1.5px solid rgba(255,255,255,0.85);
    border-radius: 50%;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.04em;
}
.mode-3d span { transform: none; }

.admin-chip {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.55);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 6px;
    padding: 0 10px;
}

#level-hint {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 118px;
    z-index: 70;
    text-align: center;
    font-size: 12px;
    color: rgba(255,255,255,0.38);
    pointer-events: none;
}

#mode-dock {
    position: fixed;
    left: 50%;
    bottom: 72px;
    z-index: 80;
    display: flex;
    gap: 6px;
    transform: translateX(-50%);
    padding: 6px;
    border-radius: 999px;
    background: rgba(0,0,0,0.45);
    border: 1px solid rgba(255,255,255,0.12);
}

.mode-btn {
    border: 0;
    background: transparent;
    color: rgba(255,255,255,0.62);
    padding: 7px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    cursor: pointer;
}
.mode-btn.active {
    background: #fff;
    color: #000;
}

#filmstrip {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 80;
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 8px 10px 12px;
    background: #000;
    scrollbar-width: none;
}
#filmstrip::-webkit-scrollbar { display: none; }

.film-thumb {
    flex: 0 0 54px;
    width: 54px;
    height: 54px;
    border: 0;
    padding: 0;
    background: #111;
    overflow: hidden;
    cursor: pointer;
}
.film-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

#loader {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #000;
    gap: 18px;
}
#loader .spinner {
    width: 38px;
    height: 38px;
    border: 3px solid rgba(255,255,255,0.14);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loader p {
    font-size: 12px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.45);
}

#modal {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.94);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
#modal.open { opacity: 1; pointer-events: auto; }

.modal-content {
    max-width: 92vw;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.modal-content img,
.modal-content video {
    max-width: 100%;
    max-height: 72vh;
    object-fit: contain;
    border: 2px solid #fff;
}
.modal-meta { text-align: center; max-width: 560px; }
.modal-content h3 { font-size: 18px; font-weight: 600; }
.modal-content p { font-size: 13px; color: rgba(255,255,255,0.6); }

#modal-close {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 50%;
    background: rgba(0,0,0,0.45);
    color: #fff;
    font-size: 30px;
    cursor: pointer;
    z-index: 520;
}

.modal-arrow {
    position: fixed;
    top: 50%;
    z-index: 520;
    width: 56px;
    height: 56px;
    margin-top: -28px;
    border: 0;
    border-radius: 50%;
    background: rgba(0,0,0,0.45);
    color: #fff;
    font-size: 42px;
    line-height: 1;
    cursor: pointer;
}
#modal-prev { left: 16px; }
#modal-next { right: 16px; }
.modal-arrow:disabled { opacity: 0.25; cursor: default; }

.modal-chrome {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.45s ease;
}
#modal.chrome-on .modal-chrome {
    opacity: 1;
    pointer-events: auto;
}
#modal.chrome-on .modal-arrow:disabled {
    opacity: 0.28;
    pointer-events: none;
}

@media (max-width: 768px) {
    .modal-arrow {
        width: 64px;
        height: 64px;
        margin-top: -32px;
        font-size: 48px;
    }
    #modal-prev { left: 10px; }
    #modal-next { right: 10px; }
}

@media (max-width: 768px) {
    #viewport { perspective: 1100px; }
    .folder-card {
        width: 236px;
        height: 314px;
        margin-left: -118px;
        margin-top: -157px;
        border-width: 2.5px;
    }
    .folder-label { font-size: 17px; bottom: 10px; }
    .play-badge { width: 46px; height: 46px; margin: -23px 0 0 -23px; }
    .play-badge::after { border-left-width: 14px; border-top-width: 9px; border-bottom-width: 9px; }
    #topbar { padding: 16px 12px 22px; gap: 10px; }
    #page-title { font-size: 22px; }
    #page-crumb { font-size: 12px; }
    .icon-btn { min-width: 44px; height: 44px; }
    .mode-3d { width: 46px; height: 46px; font-size: 13px; }
    .admin-chip { font-size: 11px; padding: 0 12px; height: 44px; }
    #mode-dock {
        bottom: 86px;
        gap: 4px;
        padding: 6px;
        width: calc(100% - 16px);
        max-width: 420px;
        justify-content: space-between;
    }
    .mode-btn { padding: 10px 8px; font-size: 12px; }
    #level-hint { bottom: 148px; font-size: 13px; }
    #filmstrip { padding: 10px 10px 14px; gap: 6px; }
    .film-thumb { flex-basis: 68px; width: 68px; height: 68px; }
}

@media (max-width: 380px) {
    .folder-card {
        width: 210px;
        height: 280px;
        margin-left: -105px;
        margin-top: -140px;
    }
}

@media (min-width: 900px) {
    #viewport { perspective: 1600px; }
    .folder-card {
        width: 220px;
        height: 294px;
        margin-left: -110px;
        margin-top: -147px;
    }
    .folder-label { font-size: 15px; }
}
