/* Atkinson Hyperlegible — accessibility-first face (Master design-system). */
@import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:wght@400;700&display=swap');
/* Plus Jakarta Sans kept as fallback/secondary for brand-heading continuity. */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
    --brand-primary: #1992b4; /* primary accent */
    --brand-accent: #ff6680;  /* secondary accent */
    --brand-surface: rgba(26, 40, 56, 0.9);
    --brand-text: #ffffff;
    --brand-text-muted: rgba(255,255,255,0.8);
    /* Semantic status colors (UX #2 token migration). Use these instead of
       bare hex in inline styles so one change propagates everywhere. */
    --color-danger: #e64d4d;
    --color-danger-hover: #cc3b3b;
    --color-success: #2cbb5d;
    --color-warning: #f59e0b;
    --color-surface-dark: #0f172a;
    --color-surface-light: #f8fafc;
    --color-text-slate: #64748b;
    /* Safe area insets for notches */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}
body,
html {
    margin: 0;
    padding: 0;
    overflow: hidden;
    min-height: 100dvh;
    height: -webkit-fill-available;
    -webkit-text-size-adjust: 100%;
    overscroll-behavior: none;
    touch-action: manipulation;
    font-family: 'Atkinson Hyperlegible', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

#brand-logo {
    position: fixed;
    left: calc(15px + var(--safe-left));
    top: calc(15px + var(--safe-top));
    height: 44px;
    z-index: 3;
    user-select: none;
}

/* Auth logout button */
.auth-logout {
    position: fixed;
    top: calc(10px + var(--safe-top));
    right: calc(10px + var(--safe-right));
    z-index: 14;
    background: var(--brand-primary);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.6);
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
}

/* Admin link shown next to logout when role === 'admin' */
.auth-admin {
    position: fixed;
    top: calc(10px + var(--safe-top));
    right: calc(92px + var(--safe-right)); /* place to the left of logout */
    z-index: 14;
    color: #fff;
    background: rgba(15,23,42,0.55);
    border: 1px solid rgba(255,255,255,0.6);
    border-radius: 8px;
    padding: 6px 10px;
    text-decoration: none;
}

h2 {
    color: var(--brand-text);
    text-shadow: 0 0 0.2em rgba(0,0,0,.35);
}

ul {
    list-style-type: none;
    padding: 10px 0 0 0;
    margin: 0px;
}

canvas {
    width: 100vw;
    height: 100vh;
    z-index: 1;
}

/* Landing video background */
#landing-video {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    object-fit: cover;
    z-index: 0;
    background: #000;
}

/* Dark overlay above video, below hotspots */
#landing-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.35);
}

/* Map header bar behind logo */
.map-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: calc(64px + var(--safe-top));
    z-index: 2; /* under logo (z=3), above overlay (z=1) */
    pointer-events: none;
    background: linear-gradient(to bottom, rgba(15,23,42,0.85), rgba(15,23,42,0.55));
    border-bottom: 1px solid rgba(255,255,255,0.15);
    backdrop-filter: blur(8px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.25);
}

/* Scene header bar with transparent overlay background */
.scene-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: calc(64px + var(--safe-top));
    z-index: 15;
    display: grid;
    grid-template-columns: 200px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: calc(var(--safe-top)) 12px 0 12px;
    color: #fff;
    background: linear-gradient(to bottom, rgba(15,23,42,0.85), rgba(15,23,42,0.55));
    border-bottom: 1px solid rgba(255,255,255,0.15);
    backdrop-filter: blur(8px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.25);
}
.scene-loader {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(600px 400px at 30% 20%, rgba(25,146,180,.15), transparent), rgba(0,0,0,0.45);
    backdrop-filter: blur(4px);
    z-index: 50;
}
.scene-loader .card {
    background: rgba(15,23,42,0.85);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.18);
    box-shadow: 0 18px 40px rgba(0,0,0,0.35);
    border-radius: 16px;
    padding: 16px 18px;
    width: 260px;
    text-align: center;
}
.scene-loader .ring {
    --p: 0; /* percentage 0..100 */
    width: 120px; height: 120px; border-radius: 50%; margin: 8px auto 10px;
    background: conic-gradient(var(--brand-primary) calc(var(--p)*1%), rgba(255,255,255,0.15) 0);
    -webkit-mask: radial-gradient(circle closest-side, transparent 62%, #000 63%);
            mask: radial-gradient(circle closest-side, transparent 62%, #000 63%);
    position: relative;
}
.scene-loader .pct { position: absolute; inset: 0; display:flex; align-items:center; justify-content:center; font-weight: 700; font-size: 20px; text-shadow: 0 0 6px rgba(0,0,0,0.35); }
.scene-loader .label { font-size: 13px; opacity: .9; margin-top: 4px; }
.scene-header .back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.25);
}
.scene-header .title { font-weight: 700; letter-spacing: .2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scene-header .actions { display:flex; gap: 8px; }

/* Hotspot overlay */
#map-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 2;
    pointer-events: none; /* enable only on hotspots */
}

#map-overlay .hotspot {
    position: absolute;
    width: 56px;
    height: 56px;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    box-sizing: border-box;
    background: rgba(28, 130, 255, 0.9);
    border: 4px solid rgba(255,255,255,0.95);
    box-shadow: 0 0 26px rgba(28, 130, 255, 0.95);
    cursor: pointer;
    pointer-events: auto;
    z-index: 2;
}

/* Active hub stacks above all others */
#map-overlay .hotspot.active { z-index: 18; }
#map-overlay .hotspot.active .hub-wrap { z-index: 20; }

#map-overlay .hotspot:hover {
    transform: scale(1.08);
}

#map-overlay .hotspot .thumb {
    position: absolute;
    inset: 10px; /* ensures perfect circle regardless of parent size */
    border-radius: 50%;
    aspect-ratio: 1 / 1;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    pointer-events: none;
    border: 1px solid rgba(255,255,255,0.85);
    box-sizing: border-box;
    box-shadow: inset 0 0 6px rgba(0,0,0,0.35);
}

/* Area hub expansion ring */
#map-overlay .hub-child {
    position: absolute;
    left: 50%;
    top: 50%;
    min-width: 36px;
    height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(28, 130, 255, 0.92);
    color: #fff;
    font-size: 11px;
    border: 2px solid rgba(255,255,255,0.95);
    box-shadow: 0 0 18px rgba(28,130,255,0.85);
    transform: translate(-50%, -50%) scale(0.98);
    transition: transform 180ms ease, opacity 180ms ease;
    opacity: 0.95;
    pointer-events: auto;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}
#map-overlay .hub-child:hover { transform: translate(-50%, -50%) scale(1.05); }

/* Hub child container + label */
#map-overlay .hub-item { position: absolute; transform: translate(-50%, -50%); pointer-events: none; z-index: 3; }
#map-overlay .hub-item .hub-child { pointer-events: auto; }
#map-overlay .hub-item .hub-caption {
    position: absolute; left: 50%; transform: translateX(-50%);
    top: 54px; /* 44px circle + ~10px gap */
    background: rgba(15,23,42,0.75);
    color: #fff; border: 1px solid rgba(255,255,255,0.25);
    border-radius: 8px; padding: 1px 5px; font-size: 11px; white-space: nowrap;
    box-shadow: 0 6px 16px rgba(0,0,0,0.25);
}

/* Guide card for landing page */
.guide-card {
    position: fixed;
    left: 12px;
    bottom: 12px;
    width: 320px;
    border-radius: 16px;
    background: rgba(15,23,42,0.78);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: 0 14px 28px rgba(0,0,0,0.25);
    overflow: hidden;
    backdrop-filter: blur(8px);
    z-index: 4;
}
.guide-card .media {
    position: relative;
    height: 140px;
    background: #1c82ffe6; /* user-specified color */
}
.guide-card .media .close {
    position: absolute; right: 10px; top: 6px; width: 20px; height: 20px;
    border-radius: 50%; border: 1px solid rgba(255,255,255,0.5);
    background: rgba(0,0,0,0.25); color: #fff; cursor: pointer; font-size: 14px;
}
.guide-card .media .orb {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: 120px; height: 120px; border-radius: 50%; overflow: hidden;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.35), rgba(255,255,255,0.05));
}
.guide-card .media .orb video { width: 100%; height: 100%; object-fit: cover; opacity: .9; }
.guide-card .body { padding: 10px 12px 12px; background: rgba(6,11,20,0.85); }
.guide-card .title-row { display:flex; align-items:center; justify-content:space-between; }
.guide-card .title { font-weight: 700; }
.guide-card .live { background:#22c55e; color:#06251a; border-radius:999px; font-weight:700; padding:4px 8px; font-size:11px; border:1px solid rgba(255,255,255,.35); }
.guide-card .desc { font-size: 12px; opacity:.92; margin-top:6px; }
.guide-card .controls { display:flex; align-items:center; gap:10px; margin-top:10px; }
.guide-card .ctrl { background: rgba(255,255,255,0.15); color:#fff; border:1px solid rgba(255,255,255,0.35); border-radius:8px; padding:6px 10px; cursor:pointer; }
.guide-card .bar { position: relative; flex: 1; height: 6px; border-radius: 999px; background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.25); }
.guide-card .bar i { position:absolute; left:0; top:0; bottom:0; width:0%; border-radius:999px; background: linear-gradient(90deg, #1992b4, #22c55e); }

/* Show Guide toggle button */
.guide-show-btn {
    position: fixed;
    left: 12px;
    bottom: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    color: #fff;
    background: rgba(15,23,42,0.7);
    border: 1px solid rgba(255,255,255,0.25);
    backdrop-filter: blur(8px);
    box-shadow: 0 10px 24px rgba(0,0,0,0.18);
    z-index: 4;
    cursor: pointer;
}

/* Start tour button - bottom center */
.start-tour {
    position: fixed !important;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 4;
    pointer-events: auto;
    background: rgba(255,255,255,0.92) !important;
    color: #0f172a !important;
    border: 1px solid rgba(0,0,0,0.18) !important;
    padding: 10px 18px !important;
    border-radius: 999px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
}
.start-tour::before, .start-tour::after { display: none !important; content: none !important; }

/* Disclaimer above start button */
.start-disclaimer {
    position: fixed;
    left: 50%;
    bottom: 0px; /* further below the button */
    transform: translateX(-50%);
    background: rgba(15,23,42,0.7);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.25);
    padding: 6px 10px;
    border-radius: 10px;
    font-size: 12px;
    z-index: 4;
    pointer-events: none;
    text-align: center;
}

/* New start panel copy above button */
.start-panel { position: fixed; left: 50%; bottom: 72px; transform: translateX(-50%); z-index:4; text-align:center; color:#fff; }
.start-title { font-weight: 700; font-size: 22px; text-shadow: 0 1px 8px rgba(0,0,0,0.35); }
.start-sub { font-size: 18px; margin-top: 2px; text-shadow: 0 1px 8px rgba(0,0,0,0.35); }
.start-more { display:inline-block; margin-top:6px; text-decoration: underline; color:#fff; opacity:.95; }

/* Centered Start container */
.start-center { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 5; width: 90%; max-width: 420px; text-align: center; }
.start-center .start-panel { position: static; left:auto; bottom:auto; transform:none; }
.start-center .start-tour { position: static !important; left:auto; bottom:auto; transform:none; margin-top: 16px; }
.start-center .start-disclaimer { position: static; left:auto; bottom:auto; transform:none; margin-top: 12px; pointer-events:auto; }

/* Top-right Start container (under header) */
.start-topright { position: fixed; top: 72px; right: 12px; z-index: 5; width: min(90vw, 360px); text-align: right; }
.start-topright { top: calc(72px + var(--safe-top)); right: calc(12px + var(--safe-right)); }
.start-topright .start-panel { position: static; left:auto; bottom:auto; transform:none; text-align: right; }
.start-topright .start-tour { position: static !important; left:auto; bottom:auto; transform:none; margin-top: 10px; display: inline-block; }
.start-topright .start-disclaimer { position: static; left:auto; bottom:auto; transform:none; margin-top: 10px; pointer-events:auto; text-align: right; }

dialog {
    width: 100%;
    text-align: center;
    max-width: 20em;
    color: white;
    background-color: #000;
    border: none;
    position: relative;
    transform: translate(-50%, -50%);
}

#progress-container {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 3;
}

progress {
    width: 100%;
    height: 1em;
    border: none;
    background-color: #fff;
    color: #eee;
}

progress::-webkit-progress-bar {
    background-color: #333;
}

progress::-webkit-progress-value {
    background-color: #eee;
}

progress::-moz-progress-bar {
    background-color: #eee;
}

/* Prevent scroll/zoom issues on canvas interactions */
.canvas, canvas { touch-action: none; }
/* Allow touch-drag to control camera while preventing pinch-zoom scroll */
canvas { touch-action: pan-x pan-y; }

/* Content markers for KSplat viewer (match editor visibility) */
.content-marker {
    position: fixed;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #1992b4;
    border: 2px solid rgba(255,255,255,0.9);
    transform: translate(-50%, -50%);
    pointer-events: auto;
    z-index: 10001;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.content-marker.video { background: #1992b4; }
.content-marker.image { background: #22c55e; }
.content-marker.audio { background: #f59e0b; }
.content-marker.link { background: #a855f7; }

/* Simple modal for content viewing in KSplat viewer */
.content-modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.55); z-index: 10002; }
.content-modal .inner { max-width: 76vw; max-height: 76vh; background: rgba(15,23,42,0.9); border: 1px solid rgba(255,255,255,0.2); border-radius: 12px; padding: 10px; overflow: auto; box-shadow: 0 14px 28px rgba(0,0,0,0.35); }
.content-modal .close { position: absolute; right: 12px; top: 12px; border-radius: 999px; border: 1px solid rgba(255,255,255,0.55); background: rgba(0,0,0,0.35); color: #fff; padding: 4px 8px; cursor: pointer; }

/* Voice UI (KSplat) */
.voice-avatar {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    width: 62px;
    height: 62px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15,23,42,0.8);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.25);
    box-shadow: 0 10px 26px rgba(0,0,0,0.35);
    z-index: 10005;
    cursor: pointer;
}
.voice-avatar .icon { width: 28px; height: 28px; }
.voice-avatar.listening { background: rgba(34,197,94,0.85); color: #06251a; border-color: rgba(255,255,255,0.5); }
.voice-status {
    position: fixed;
    left: 50%;
    bottom: 96px;
    transform: translateX(-50%);
    padding: 8px 14px;
    border-radius: 999px;
    color: #fff;
    background: rgba(15,23,42,0.92);
    border: 1px solid rgba(255,255,255,0.35);
    box-shadow: 0 12px 28px rgba(0,0,0,0.35);
    backdrop-filter: blur(8px);
    z-index: 10005;
    display: none;
    font-size: 13px;
    font-weight: 500;
    animation: voiceStatusPulse 1.5s ease-in-out infinite;
}

@keyframes voiceStatusPulse {
    0%, 100% { opacity: 0.95; transform: translateX(-50%) scale(1); }
    50% { opacity: 1; transform: translateX(-50%) scale(1.02); }
}

@media only screen and (max-width: 600px) {
    /* General */
    h1 { font-size: 1.1rem; }
    #brand-logo { height: 36px; left: 10px; top: 10px; }
    .map-header { height: 56px; }
    .auth-admin { right: 86px; padding: 6px 8px; font-size: 13px; }
    .auth-logout { right: 10px; padding: 6px 8px; font-size: 13px; }

    /* Hotspots smaller on mobile */
    #map-overlay .hotspot { width: 46px; height: 46px; border-width: 3px; }
    #map-overlay .hotspot .thumb { inset: 8px; }

    /* Guide card compact */
    .guide-card { width: min(92vw, 340px); left: 8px; bottom: 8px; border-radius: 14px; }
    .guide-card .media { height: 120px; }
    .guide-card .body { padding: 10px; }
    .guide-card .desc { font-size: 12px; }
    .guide-card .ctrl { padding: 6px 8px; }

    /* Start CTA centered on very small widths */
    .start-topright { right: 8px; width: min(92vw, 320px); }
    .start-title { font-size: 18px; }
    .start-sub { font-size: 14px; }
    .start-tour { font-size: 15px !important; padding: 9px 16px !important; }
    .start-disclaimer { font-size: 11px; }
}

/* Tablet breakpoints */
@media (max-width: 900px) {
    .scene-header { grid-template-columns: 160px 1fr auto; height: 60px; }
}

/* Orientation enforcement: show rotate overlay on phones in portrait */
@media (max-width: 900px) and (orientation: portrait) {
    html::before {
        content: 'Please rotate your device to landscape for the best experience.';
        position: fixed;
        inset: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        padding: 24px;
        background: rgba(15,23,42,0.92);
        color: #fff;
        z-index: 9999;
        font-size: 18px;
        line-height: 1.4;
    }
}

/* Hide legacy scene controls on mobile (use on-screen joystick instead) */
@media (max-width:1024px) and (pointer:coarse) {
    #stewhe, .menuicon, #lview, #rview, #sview { display: none !important; }
}

/* --- Accessibility baseline (applies site-wide) ------------------------- */

/* Respect user preference to minimize animation. WCAG 2.3.3. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Visible keyboard focus. Suppressed only for mouse-triggered focus so the
   ring shows up for keyboard and assistive-tech users. */
:focus-visible {
    outline: 2px solid #2563EB;
    outline-offset: 2px;
    border-radius: inherit;
}
:focus:not(:focus-visible) {
    outline: none;
}

