/* Virtual Museum — full-viewport 3D room overlay UI */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; }
.museum-body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #0b0b0d;
    color: #fff;
    -webkit-user-select: none; user-select: none;
    touch-action: none;
    overscroll-behavior: none;
}

.museum-skip { position: fixed; left: 16px; top: -80px; z-index: 100; padding: 12px 16px; border-radius: 10px; background: #f0c887; color: #101820; font-weight: 800; text-decoration: none; }
.museum-skip:focus { top: 16px; }
a:focus-visible, button:focus-visible { outline: 3px solid rgba(240,200,135,.85); outline-offset: 3px; }
button, a { -webkit-tap-highlight-color: transparent; }

#museum-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; }

.hidden { display: none !important; }

/* ── Loading screen ─────────────────────────────────────────── */
.museum-loader {
    position: fixed; inset: 0; z-index: 50;
    display: flex; align-items: center; justify-content: center;
    background: radial-gradient(circle at 50% 40%, #1c1c22 0%, #0b0b0d 70%);
    transition: opacity .6s ease;
}
.museum-loader.fade { opacity: 0; pointer-events: none; }
.loader-inner { text-align: center; max-width: 320px; padding: 24px; }
.loader-mark { width: 58px; height: 58px; margin: 0 auto 18px; color: #e8c37e; stroke-width: 1.5; animation: floaty 3s ease-in-out infinite; }
.loader-icon { font-size: 48px; margin-bottom: 16px; animation: floaty 3s ease-in-out infinite; }
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.loader-title { font-size: 20px; font-weight: 700; letter-spacing: .01em; margin-bottom: 20px; }
.loader-bar { height: 4px; background: rgba(255,255,255,.12); border-radius: 999px; overflow: hidden; }
.loader-bar-fill { height: 100%; width: 0%; background: #e8c37e; transition: width .3s ease; }
.loader-status { margin-top: 14px; font-size: 13px; color: rgba(255,255,255,.55); }

/* ── HUD ────────────────────────────────────────────────────── */
.museum-hud { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
.hud-top {
    position: absolute; top: 0; left: 0; right: 0;
    display: flex; align-items: center; gap: 16px;
    padding: 16px 20px;
    background: linear-gradient(to bottom, rgba(0,0,0,.55), transparent);
}
.hud-btn {
    pointer-events: auto;
    display: inline-flex; align-items: center;
    padding: 9px 16px; border-radius: 10px;
    background: rgba(255,255,255,.12); backdrop-filter: blur(8px);
    color: #fff; text-decoration: none; font-size: 14px; font-weight: 600;
    border: 1px solid rgba(255,255,255,.14); transition: background .2s;
}
.hud-btn:hover { background: rgba(255,255,255,.22); }
.hud-btn .btn-ico { display: none; }
.hud-title { font-size: 15px; font-weight: 600; color: rgba(255,255,255,.85); text-shadow: 0 1px 4px rgba(0,0,0,.6); min-width: 0; }
.hud-title span, .hud-title small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-title small { margin-top: 3px; color: rgba(255,255,255,.58); font-size: 11px; font-weight: 500; }
.hud-actions { margin-left: auto; display: flex; gap: 8px; pointer-events: auto; }
button.hud-btn { cursor: pointer; font-family: inherit; }

.hud-hint {
    position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
    padding: 9px 18px; border-radius: 999px;
    background: rgba(0,0,0,.5); backdrop-filter: blur(8px);
    font-size: 12.5px; color: rgba(255,255,255,.8); white-space: nowrap;
    border: 1px solid rgba(255,255,255,.1);
}
.hud-hint b { color: #e8c37e; }
.hint-touch { display: none; }

.museum-crosshair {
    position: fixed; top: 50%; left: 50%; width: 8px; height: 8px;
    margin: -4px 0 0 -4px; border-radius: 50%;
    border: 1.5px solid rgba(255,255,255,.7); box-shadow: 0 0 4px rgba(0,0,0,.6);
    opacity: 0; transition: opacity .2s, transform .2s;
}
.museum-crosshair.active { opacity: 1; }
.museum-crosshair.hot { transform: scale(1.8); border-color: #e8c37e; }

/* ── Touch pad (shown only on touch devices) ────────────────── */
.touch-pad { display: none; }
.museum-body.is-touch .touch-pad {
    display: grid; pointer-events: auto;
    position: fixed;
    left: calc(18px + env(safe-area-inset-left, 0px));
    bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    grid-template-columns: repeat(3, 56px);
    grid-template-rows: repeat(3, 56px);
    gap: 6px;
    z-index: 25;
}
.pad-btn {
    border: 1px solid rgba(255,255,255,.22);
    background: rgba(20,20,24,.62); backdrop-filter: blur(8px);
    color: rgba(255,255,255,.92); font-size: 18px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,.35);
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}
.pad-btn:active { background: rgba(232,195,126,.4); border-color: rgba(232,195,126,.6); transform: scale(.96); }
.pad-up    { grid-column: 2; grid-row: 1; }
.pad-left  { grid-column: 1; grid-row: 2; }
.pad-right { grid-column: 3; grid-row: 2; }
.pad-down  { grid-column: 2; grid-row: 3; }

/* ── Item info panel ────────────────────────────────────────── */
.museum-panel {
    position: fixed; top: 0; right: 0; z-index: 40;
    width: min(420px, 92vw); height: 100%;
    background: rgba(16,16,20,.92); backdrop-filter: blur(18px);
    border-left: 1px solid rgba(255,255,255,.1);
    box-shadow: -20px 0 60px rgba(0,0,0,.5);
    transform: translateX(100%); transition: transform .4s cubic-bezier(.16,1,.3,1);
    display: flex; flex-direction: column; overflow-y: auto;
}
.museum-panel.open { transform: translateX(0); }
.panel-grip { display: none; }
.panel-close {
    position: absolute; top: 14px; right: 16px; z-index: 2;
    width: 40px; height: 40px; border-radius: 50%;
    background: rgba(255,255,255,.14); backdrop-filter: blur(6px);
    border: none; color: #fff;
    font-size: 22px; line-height: 1; cursor: pointer;
}
.panel-close:hover { background: rgba(255,255,255,.24); }
.panel-media { width: 100%; background: #000; }
.panel-media img { width: 100%; max-height: 46vh; object-fit: contain; display: block; }
.panel-body { padding: 24px; }
.panel-body h2 { margin: 0 0 10px; font-size: 22px; font-weight: 700; line-height: 1.25; }
.panel-meta { font-size: 12.5px; color: rgba(232,195,126,.9); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 16px; }
.panel-meta span { display: inline-block; margin-right: 14px; }
.panel-desc { font-size: 14.5px; line-height: 1.65; color: rgba(255,255,255,.78); margin: 0 0 24px; }
.panel-link {
    display: inline-block; padding: 11px 20px; border-radius: 10px;
    background: #e8c37e; color: #1a1a1a; font-weight: 700; font-size: 14px; text-decoration: none;
}
.panel-link:hover { background: #f0d097; }

/* ── Empty state ────────────────────────────────────────────── */
.museum-empty {
    position: fixed; inset: 0; z-index: 45;
    display: flex; align-items: center; justify-content: center; text-align: center;
    background: radial-gradient(circle at 50% 40%, #1c1c22 0%, #0b0b0d 70%);
    padding: 24px;
}
.empty-icon { font-size: 52px; margin-bottom: 12px; }
.empty-mark { width: 58px; height: 58px; color: #e8c37e; margin: 0 auto 14px; }
.museum-empty h2 { margin: 0 0 8px; font-size: 22px; }
.museum-empty p { color: rgba(255,255,255,.6); margin: 0 0 24px; }
.fallback-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

/* Welcome and mode surfaces */
.museum-welcome { position: fixed; inset: 0; z-index: 48; display: grid; place-items: center; padding: 22px; background: radial-gradient(circle at 70% 25%, rgba(40,58,78,.78), rgba(5,8,12,.92) 64%); }
.welcome-card { width: min(580px, 100%); padding: clamp(28px, 6vw, 54px); border: 1px solid rgba(255,255,255,.16); border-radius: 24px; background: rgba(13,20,29,.86); backdrop-filter: blur(18px); box-shadow: 0 30px 100px rgba(0,0,0,.58); }
.welcome-card .eyebrow { margin: 0 0 14px; color: #e8c37e; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .2em; }
.welcome-card h1 { margin: 0; font: 700 clamp(34px,7vw,58px)/.98 Georgia,serif; letter-spacing: -.035em; }
.welcome-card > p:not(.eyebrow) { margin: 22px 0 0; color: rgba(255,255,255,.7); line-height: 1.65; }
.welcome-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.museum-primary,.museum-secondary { min-height: 46px; display: inline-flex; align-items: center; justify-content: center; border-radius: 11px; padding: 11px 18px; font: 800 14px/1 inherit; text-decoration: none; cursor: pointer; }
.museum-primary { border: 0; background: #e8c37e; color: #13181d; }
.museum-secondary { border: 1px solid rgba(255,255,255,.17); background: rgba(255,255,255,.08); color: #fff; }

/* The server-rendered accessible mode has a separate document, but this token keeps shared mode styling discoverable. */
.museum-2d { color-scheme: dark; }

@media (max-width: 820px) {
    .hint-desktop { display: none; }
    .hint-touch { display: inline; }
    .hud-top {
        padding: calc(10px + env(safe-area-inset-top, 0px)) calc(10px + env(safe-area-inset-right, 0px)) 14px calc(10px + env(safe-area-inset-left, 0px));
        gap: 8px;
        background: linear-gradient(to bottom, rgba(0,0,0,.65), transparent);
    }
    .hud-title { flex: 1; }
    .hud-title small { font-size: 10px; }
    .hud-btn { min-height: 44px; padding: 9px 12px; font-size: 13px; flex-shrink: 0; }
    #museum-reset .btn-text { display: none; }
    #museum-reset .btn-ico { display: inline; font-size: 19px; line-height: 1; }

    /* Hint sits above the touch pad and gets out of the way after a few seconds */
    .hud-hint { bottom: 12px; max-width: calc(100vw - 24px); white-space: normal; text-align: center; font-size: 12px; }
    .is-touch .hud-hint { bottom: calc(216px + env(safe-area-inset-bottom, 0px)); }
    @media (prefers-reduced-motion: no-preference) {
        .is-touch .hud-hint { animation: hint-fade .5s ease 6s forwards; }
    }

    /* Item info panel becomes a bottom sheet */
    .museum-panel {
        top: auto; bottom: 0; left: 0; right: 0;
        width: 100%; height: auto;
        max-height: 80vh; max-height: 80dvh;
        border-left: none; border-top: 1px solid rgba(255,255,255,.14);
        border-radius: 22px 22px 0 0;
        box-shadow: 0 -20px 60px rgba(0,0,0,.55);
        transform: translateY(100%);
    }
    .museum-panel.open { transform: translateY(0); }
    .panel-grip {
        display: block; position: absolute; top: 8px; left: 50%; z-index: 2;
        width: 44px; height: 4px; margin-left: -22px; border-radius: 999px;
        background: rgba(255,255,255,.35); box-shadow: 0 1px 3px rgba(0,0,0,.4);
    }
    .panel-close { top: 10px; right: 12px; width: 44px; height: 44px; }
    .panel-media img { max-height: 32vh; max-height: 32dvh; }
    .panel-body { padding: 18px 20px calc(22px + env(safe-area-inset-bottom, 0px)); }
    .panel-body h2 { font-size: 19px; }
}
@keyframes hint-fade { to { opacity: 0; visibility: hidden; } }

@media (max-width: 640px) {
    /* Welcome dialog becomes a bottom sheet */
    .museum-welcome { padding: 0; place-items: end stretch; }
    .welcome-card {
        width: 100%;
        border-radius: 26px 26px 0 0;
        border-left: 0; border-right: 0; border-bottom: 0;
        padding: 28px 22px calc(26px + env(safe-area-inset-bottom, 0px));
        box-shadow: 0 -30px 100px rgba(0,0,0,.58);
    }
    .welcome-card h1 { font-size: clamp(30px, 8.5vw, 40px); }
    .welcome-actions { flex-direction: column; margin-top: 24px; }
    .museum-primary, .museum-secondary { width: 100%; min-height: 50px; font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
