/* ===== Base layout & resets ===== */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap');

body, html {
    margin: 0;
    height: 100%;
    overflow: hidden;
    /* Prevent bounce on mobile */
    overscroll-behavior: none;
}

#pano {
    width: 100%;
    height: 100%;
    background-color: black;
    /* Ensure pano stays behind UI */
    position: relative;
    z-index: 0;
}

/* Loading overlay */
#loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2147483646;
}

.loading-box {
    width: min(90%, 200px);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 25px 20px;
    color: #fff;
    font-family: 'Poppins', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    backdrop-filter: blur(8px);
    text-align: center;
}

.loading-label {
    font-size: 20px;
    margin-bottom: 10px;
}

.loading-percent {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
}

/* ===== Components (shared) ===== */

.hotspot {
    width: 32px;
    height: 32px;
    background: url('images/hotspot.png') no-repeat center;
    background-size: contain;
    cursor: pointer;
}

/* ===== Desktop UI (default styles) ===== */
/* Scene Navigation Panel */
#scene-nav {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.253);
    color: white;
    padding: 20px;
    border-radius: 10px;
    z-index: 1000;
    width: 380px; /* Fixed width for 3 columns */
    max-width: 50vw; /* Safety cap for overlap prevention */
    backdrop-filter: blur(10px);
    border: 1.5px solid rgba(255, 255, 255, 0.1);
    font-family: 'Poppins', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    transform-origin: left bottom;
    /* Performance hints */
    will-change: transform, opacity;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

    #scene-nav h3 {
        margin: 0 0 15px 0;
        font-size: 18px;
        text-align: center;
        color: #fff;
    }

.nav-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 15px;
    /* Show only 3 rows, scroll for rest */
    max-height: 140px;
    overflow-y: auto;
    padding-right: 5px;
    /* Enable smooth touch scrolling on iOS */
    -webkit-overflow-scrolling: touch;
    /* Custom scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.4) transparent;
}

/* Webkit scrollbar styling */
.nav-buttons::-webkit-scrollbar {
    width: 6px;
}

.nav-buttons::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 3px;
}

.nav-buttons::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.4);
    border-radius: 3px;
}

.nav-buttons::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.6);
}


.nav-btn {
    /* background: linear-gradient(135deg, #4d4d4d 0%, #292929 100%); */
    background: rgba(255, 255, 255, 0.185);
    color: white;
    border: none;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.3s ease;
    text-align: center;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Poppins', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

    .nav-btn:hover {
        /* background: linear-gradient(135deg, #764ba2 0%, #667eea 100%); */
        background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(255, 255, 255, 0.4);
    }

    .nav-btn:active {
        transform: translateY(0);
    }

    .nav-btn.active {
        background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
        box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
        transform: scale(1.05);
    }

.toggle-btn {
    width: 100%;
    background: rgba(29, 29, 29, 0.308);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
    font-family: 'Poppins', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

    .toggle-btn:hover {
        background: rgba(255, 255, 255, 0.2);
    }

/* Hide navigation when toggled */
#scene-nav.hidden {
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
}

/* Global Show Navigation button */
#show-nav-btn {
    position: fixed;
    bottom: 40px;
    left: 40px;
    right: auto;
    z-index: 1001;
    width: 270px;
    transform-origin: left bottom;
    background: rgba(0, 0, 0, 0.568);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    /* Fix layout inside button */
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
}

    #show-nav-btn:hover {
        background: #ffffff41; /* hover color */
    }

    #show-nav-btn.hidden {
        display: none;
    }

/* Watermark Box - Base Style */
#watermark {
    position: fixed;
    z-index: 2147483647; /* Highest priority */
    bottom: 10px;
    right: 10px;
    width: 2in;
    height: 0.5in;
    background: rgba(0, 0, 0, 0);
    border-radius: 8px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 1;
    transition: opacity 1s ease-out;
    transform-origin: right bottom;
}

    #watermark img {
        width: 100%;
        height: 100%;
        object-fit: contain;
        display: block;
    }

/* ===== Mobile UI (<= 768px) ===== */
@media (max-width: 500px) {
    /* Fill dynamic viewport height on mobile */
    #pano {
        height: 100svh;
    }

    /* Scale down loading overlay on mobile */
    .loading-box {
        width: min(85%, 180px);
        padding: 20px 15px;
        border-radius: 8px;
    }

    .loading-label {
        font-size: 12px;
    }

    .loading-percent {
        font-size: 30px;
    }

    /* Waypoint markers preserved - just ensuring correct sizing context */
    .hotspot {
        width: 28px;
        height: 28px;
    }

    /* Scale down navigation panel on mobile */
    #scene-nav {
        /* Use Safe Area for notched phones */
        bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
        left: max(8px, env(safe-area-inset-left));
        right: auto;
        width: auto;
        max-width: 55vw; /* Limit width to prevent overlap with watermark */
        padding: 10px;
        transform: scale(0.95);
        transform-origin: left bottom;
    }

        #scene-nav h3 {
            font-size: 14px;
            margin: 0 0 10px 0;
        }

    .nav-buttons {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
        margin-bottom: 10px;
        max-height: 125px;
    }

    .nav-btn {
        font-size: 10px;
        padding: 8px 10px;
        min-height: 36px;
    }

    .toggle-btn {
        font-size: 10px;
        padding: 6px;
    }

    /* Mobile-only Show button overrides */
    #show-nav-btn {
        bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
        left: max(8px, env(safe-area-inset-left));
        width: 160px;
        font-size: 11px;
        padding: 8px 10px;
        transform: scale(0.95);
    }

    /* Watermark - Repositioned to avoid overlap */
    #watermark {
        bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
        right: max(8px, env(safe-area-inset-right));
        width: 1.4in;
        height: 0.35in;
        padding: 5px;
        transform: scale(0.85);
        /* Crucial: Ensure watermark doesn't grow into the nav area */
        max-width: 40vw;
    }
}

/* ===== Mobile Landscape Orientation (<= 500px landscape) ===== */
@media (max-width: 900px) and (max-height: 500px) and (orientation: landscape) {

    /* Scrollable Nav for short screens */
    #scene-nav {
        max-height: 85vh;
        overflow-y: auto;
        bottom: 10px;
        left: max(20px, env(safe-area-inset-left)); /* Avoid notch */
    }

    #show-nav-btn {
        bottom: 10px;
        left: max(20px, env(safe-area-inset-left));
    }

    #watermark {
        bottom: 5px;
        right: max(20px, env(safe-area-inset-right)); /* Avoid dynamic island */
        transform: scale(0.75);
    }
}

/* ===== Small phones (<= 300px) ===== */
@media (max-width: 300px) {
    .hotspot {
        width: 26px;
        height: 26px;
    }

    #scene-nav {
        transform: scale(0.9);
        padding: 8px;
        max-width: 100%;
        left: 5px;
    }

    .nav-buttons {
        grid-template-columns: repeat(3, 1fr);
        max-height: 120px;
    }

    #watermark {
        transform: scale(0.7);
        right: 0;
    }
}

/* ===== Tablet UI (501px - 768px) ===== */
@media (min-width: 501px) and (max-width: 768px) {
    #scene-nav {
        padding: 14px;
        width: 340px;
        left: 20px;
        bottom: 20px;
    }

    .nav-buttons {
        grid-template-columns: repeat(3, 1fr);
        max-height: 135px;
    }

    #show-nav-btn {
        width: 220px;
        font-size: 12px;
        bottom: 30px;
        left: 30px;
    }

    #watermark {
        width: 1.7in;
        height: 0.42in;
        bottom: 18px;
        right: 18px;
    }
}
