/* The shelf as a room: the 3D scene fills the screen and the paper bits sit on top of it. */
/* the paper texture's path, from one folder down */
.room3d {
    --texture: url('../assets/handmade-paper.jpg');
}

:root[data-theme='dark'] .room3d {
    --texture: url('../assets/dark-handmade-paper-1040.jpg');
}

.room3d {
    height: 100dvh;
    overflow: hidden;
    padding-bottom: 0;
}

.room3d-scene {
    display: block;
    height: 100dvh;
    inset: 0;
    position: fixed;
    touch-action: none;
    width: 100vw;
}

.room3d-top {
    background-color: rgba(var(--sheet), 0.9);
    background-image: linear-gradient(rgba(var(--sheet), 0.8), rgba(var(--sheet), 0.8)), var(--texture);
    background-size: 100% 100%, 520px auto;
    border-radius: 3px;
    box-shadow: 0 1px 1px rgba(var(--shadow), 0.08), 0 18px 30px -20px rgba(0, 0, 0, 0.55);
    left: max(1rem, env(safe-area-inset-left));
    max-width: min(22rem, calc(100% - 2rem));
    padding: 0.85rem 1.1rem 0.95rem;
    pointer-events: none;
    position: fixed;
    top: max(1rem, env(safe-area-inset-top));
    transform: rotate(-0.8deg);
    transition: opacity 0.25s;
    z-index: 5;
}

.room3d-back {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
    pointer-events: auto;
    text-decoration: none;
}

.room3d-back:hover,
.room3d-back:focus-visible {
    color: var(--ink);
}

.room3d-title {
    font-size: clamp(1.5rem, 4.4vw, 2.3rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.05;
    margin-top: 0.35rem;
}

.room3d-title span {
    color: var(--accent);
}

.room3d-hint {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 0.4rem;
    max-width: 30ch;
}

/* the corners: a row of paper tabs above the dock */
.room3d-spots {
    bottom: calc(84px + env(safe-area-inset-bottom));
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: center;
    left: 50%;
    max-width: calc(100% - 20px);
    position: fixed;
    transform: translateX(-50%);
    width: max-content;
    z-index: 6;
}

.room3d-spots[hidden] {
    display: none;
}

.room3d-spots button {
    background: rgba(var(--sheet), 0.94);
    border: 1px solid var(--rule);
    border-radius: 999px;
    box-shadow: 0 8px 18px -12px rgba(var(--shadow), 0.6);
    color: var(--ink);
    cursor: pointer;
    font: 700 0.82rem var(--sans);
    min-height: 40px;
    padding: 0 0.95rem;
}

.room3d-spots button[aria-pressed='true'] {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--on-primary);
}

.room3d-spots button:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
}

/* the card for what's pulled out: to the right on wide screens, under it on phones */
.room3d-card {
    pointer-events: none;
    position: fixed;
    right: max(4vw, 1.25rem);
    top: 50%;
    transform: translateY(-50%);
    z-index: 7;
}

.room3d-card[hidden] {
    display: none;
}

.room3d-card .index-card {
    pointer-events: auto;
}

.room3d-pulled-nav {
    bottom: calc(84px + env(safe-area-inset-bottom));
    z-index: 8;
}

.room3d-pulled-nav[hidden] {
    display: none;
}

.room3d-tip {
    background: rgba(var(--sheet), 0.96);
    border-radius: 6px;
    box-shadow: 0 6px 14px -8px rgba(0, 0, 0, 0.5);
    color: var(--ink);
    font-size: 0.78rem;
    font-weight: 700;
    left: 0;
    padding: 0.3rem 0.55rem;
    pointer-events: none;
    position: fixed;
    top: 0;
    z-index: 9;
}

.room3d-tip[hidden] {
    display: none;
}

.room3d-loading,
.room3d-fail,
.room3d-noscript {
    color: var(--muted);
    font-weight: 700;
    left: 50%;
    position: fixed;
    text-align: center;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(90vw, 26rem);
    z-index: 4;
}

.room3d-loading[hidden],
.room3d-fail[hidden] {
    display: none;
}

.room3d-fail a,
.room3d-noscript a {
    color: var(--ink);
}

@media (max-width: 760px), (max-aspect-ratio: 9/10) {
    .room3d-card {
        bottom: calc(140px + env(safe-area-inset-bottom));
        left: 50%;
        max-height: calc(48dvh - 70px);
        overflow-y: auto;
        padding: 14px 6px 6px;
        right: auto;
        top: auto;
        transform: translateX(-50%);
        width: min(340px, calc(100% - 2rem));
    }

    .room3d-card .index-card {
        min-height: 0;
        padding: 1.1rem 1.1rem 1.3rem 3rem;
        width: 100%;
    }

    .room3d-hint {
        font-size: 0.78rem;
    }

    .room3d-spots button {
        font-size: 0.8rem;
        min-height: 44px;
        padding: 0 0.85rem;
    }

    .room3d-back-room {
        min-height: 44px;
        padding: 0 1rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .room3d-card .index-card {
        animation: none;
    }
}

/* on a phone the pulled thing takes the top of the screen, so the heading steps aside */
@media (max-width: 760px), (max-aspect-ratio: 9/10) {
    .is-pulled .room3d-top {
        opacity: 0;
    }
}

/* back out of a corner */
.room3d-back-room {
    background: var(--primary);
    border: 0;
    border-radius: 999px;
    color: var(--on-primary);
    cursor: pointer;
    font: 800 0.78rem var(--sans);
    margin-top: 0.6rem;
    min-height: 36px;
    padding: 0 0.9rem;
    pointer-events: auto;
}

.room3d-back-room[hidden] {
    display: none;
}

.room3d-back-room:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
}

/* the nudge towards the turntable while a record is out */
.room3d-deck-hint {
    background: #ffd76a;
    border-radius: 999px;
    bottom: calc(140px + env(safe-area-inset-bottom));
    box-shadow: 0 8px 18px -10px rgba(0, 0, 0, 0.6);
    color: #211e19;
    font-size: 0.8rem;
    font-weight: 800;
    left: 50%;
    padding: 0.45rem 0.9rem;
    pointer-events: none;
    position: fixed;
    transform: translateX(-50%);
    white-space: nowrap;
    z-index: 8;
}

.room3d-deck-hint[hidden] {
    display: none;
}

@media (max-width: 760px), (max-aspect-ratio: 9/10) {
    .room3d-deck-hint {
        bottom: auto;
        top: max(0.75rem, env(safe-area-inset-top));
    }
}

/* on a phone, inside a corner, the heading shrinks to the hint and the way back */
@media (max-width: 760px), (max-aspect-ratio: 9/10) {
    .in-corner .room3d-back,
    .in-corner .room3d-title {
        display: none;
    }

    .in-corner .room3d-top {
        padding: 0.6rem 0.8rem 0.7rem;
    }

    .in-corner .room3d-hint {
        margin-top: 0;
    }
}
