/* ================= Base Styles ================= */
html,
body {
    margin: 0;
    padding: 0;
    font-family: Arial, Helvetica, sans-serif;
    background-color: #222;
    color: #fff;
    box-sizing: border-box;
    min-height: 100vh;
}

/* Grid layout */
#grid-container {
    display: grid;
    grid-template-columns: 15% auto;
    grid-template-areas: "object-container object-viewer";
    width: 100%;
}

/* Sidebar container */
#object-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-height: 100vh;
    z-index: 3;
}

/* Sidebar header */
#object-header {
    text-align: center;
    background-color: #000;
    flex: 0 0 auto;
    padding: 8px;

    position: sticky;
    top: 0;
    /* stick to top of container */
    z-index: 20;
    /* above search box */
}

/* Scrollable thumbnail list */
#objects-list {
    flex: 1 1 auto;
    margin: 0;
    padding: 8px;
    overflow-y: auto;
}

/* Individual thumbnail */
.object {
    margin-bottom: 10px;
    padding: 4px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 90%;
    overflow: visible;
}

.img-thumbnail {
    width: 100%;
    height: auto;
    object-fit: contain;
}

.span-text {
    font-size: 0.8em;
    display: block;
    margin-top: 4px;
}

/* ================= Viewer & Info ================= */
#object-viewer {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    /* prevents scrollbars from loader */
}

/* screen resolutions (as of 2025)

| HD (720p)              |	1280 x 720	Budget laptops, older displays
| Full HD (1080p)        |	1920 x 1080	Most common standard for monitors and laptops
| Quad HD (1440p)	     |  2560 x 1440	Gaming, creative work
| 4K Ultra HD (4K UHD)   |	3840 x 2160	High-end gaming, video and photo editing, professional use
| 5K                     |	5120 x 2880	Professional creative work (e.g., Mac displays)
| 8K Ultra HD (8K UHD)	 |  7680 x 4320	Niche professional use, early adopter technology

/* brekpoints for #info panel height based on media */
@media (min-width: 769px) {
    #info {
        height: 15%;
    }
}

@media (max-width: 768px) {
    #info {
        height: 25%;
    }
}

@media (max-height: 800px) {
    #info .info-container {
        padding: 6px;
    }

    #info .info-card {
        padding: 6px;
        height: calc(100% - 6px);
    }
}

#placeholder-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 1.5rem;
    text-align: center;
    pointer-events: none;
    /* let clicks pass through if needed */
    display: none;
}

/* Info panel fixed to bottom */
#info {
    position: absolute;
    /* fixed at bottom of viewport */
    left: 0;
    bottom: 10px;
    top: auto;
    width: 100%;
    height: auto;
    /* let content decide height */
    max-height: 25vh;
    /* or 30vh — restrict by viewport height */
    margin: 0 0 0 2%;
    background: transparent;
    /* no margin gaps */
    border-radius: 6px 6px 0 0;
    z-index: 1;
    /* above viewer */
    display: none;
    /* ensure visible when needed */
    overflow: hidden;
    /* Transition for smooth slide */
    /* Start hidden off-screen */
    transform: translateY(100%);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.35s ease, opacity 0.35s ease, visibility 0.35s;
}

/* When active → slide up */
#info.active {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

#info-toggle {
    position: fixed;
    bottom: 10px;
    right: 10px;
    z-index: 2;
    /* Ensure it's above other elements */
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background-color: rgba(30, 30, 30, 0.85);
    color: white;
    font-weight: bold;
    font-size: 1.2rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    display: none;
}

/*
#info-toggle:hover {
    background-color: #4fc3f7;
    transform: scale(1.1);
}*/
#info-toggle:active {
    background-color: rgba(30, 30, 30, 0.85);
    transform: scale(1);
}

#info-toggle.active {
    display: block;
}

#info .info-container {
    height: 100%;
    background-color: rgba(30, 30, 30, 0.85);
    padding: 8px;
    /* tighter padding */
    border-radius: 6px 6px 0 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* no vertical scroll here */
    box-sizing: border-box;
}

/* Header behaves like a card */
#info .header {
    flex: 0 0 auto;
    min-width: 220px;
    background-color: rgba(44, 44, 44, 0.4);
    border-radius: 10px;
    padding: 12px;
    margin-right: 6px;
    /* gap between header & cards */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    /* center vertically inside card */
    scroll-snap-align: start;
}

/* Horizontal scroll container */
#info .grid-info {
    display: flex;
    flex-direction: row;
    gap: 16px;
    overflow-x: auto;
    /* horizontal scroll only */
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    /* smooth snap effect */
    -webkit-overflow-scrolling: touch;
    /* momentum scroll on iOS */
    padding-bottom: 4px;
    /* tiny space under cards */
}

/* Cards in horizontal scroll */
#info .info-card {
    flex: 0 0 auto;
    width: 220px;
    /* fixed width */
    height: calc(100% - 8px);
    /* fill the panel vertically */
    padding: 8px;
    background-color: rgba(44, 44, 44, 0.4);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* center text vertically */
    align-items: flex-start;
    /* left-align text */
    scroll-snap-align: start;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

/* ensure text scales nicely */
.info-container h2 {
    font-size: 1.7rem;
}

.info-container p,
.info-card p {
    font-size: 0.95rem;
}



#watermark-status {
    font-size: 0.9rem;
    color: #ccc;
}

#model-desc {
    margin-bottom: 20px;
    color: #aaa;
    font-size: 0.95rem;
}




.info-card h3 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 1rem;
    color: #4fc3f7;
}

.info-card p {
    margin: 4px 0;
    font-size: 0.9rem;
    color: #ddd;
}

/* Wide card spans multiple columns */
.wide-card {
    grid-column: span 2;
}

.info-card a {
    color: #4fc3f7;
    text-decoration: none;
}

.info-card a:hover {
    text-decoration: underline;
}

.poly-info {
    display: flex;
    /* put items side-by-side */
    gap: 1rem;
    /* space between items */
    align-items: center;
    /* vertical alignment */
    flex-wrap: wrap;
    /* wrap on small screens */
}

.poly-info p {
    margin: 0;
    /* remove default paragraph margins */
}

#title-watermark-container {
    display: flex;
    /* horizontal layout */
    align-items: center;
    /* vertical centering */
    gap: 10px;
    /* space between elements */
}

#title-watermark-container h2,
#title-watermark-container p {
    margin: 0;
    /* remove default margins */
}

.impact-text {
    display: inline-block;
    /* shrink-wrap the background to text */
    background-color: white;
    /* filled background */
    color: black;
    /* text color */
    font-weight: bold;
    /* optional, make it bold */
    padding: 2px 6px;
    /* optional: space around text */
    border-radius: 2px;
    /* optional: slightly rounded corners */
    font-family: Arial, sans-serif;
    /* choose your font */
    font-size: 1rem;
    /* adjust size */
}

/* HDRI loader message */
#hdri-loader {
    display: none;
    /* hidden by default */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    /* above viewer content */
    font-weight: bold;
    color: #fff;
    /* text color */
    background-color: rgba(0, 0, 0, 0.6);
    /* semi-transparent background */
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 1rem;
    pointer-events: none;
    /* clicks pass through */

    display: flex;
    /* flex layout */
    flex-direction: row;
    /* horizontal layout */
    align-items: center;
    justify-content: center;
    /* center horizontally */
    text-align: center;
    /* optional, also centers text lines */
    /* vertical alignment */
    gap: 8px;
    /* spacing between spinner and text */
}

#hdri-loader .spinner {
    display: inline-block;
    /* ensure inline with text */
    width: 20px;
    height: 20px;
    border: 3px solid #ccc;
    border-top-color: #1d72b8;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}


/* ================= Loader / Spinner ================= */
#loader {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
}

#loader .spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #ccc;
    border-top-color: #1d72b8;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Error message */
#error-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.2);
    color: white;
    padding: 20px;
    border-radius: 5px;
    display: none;
    z-index: 10000;
}

/* ================= Tooltip ================= */
.tooltip {
    position: relative;
    display: inline-block;
    cursor: default;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: max-content;
    max-width: 200px;
    background-color: rgba(0, 0, 0, 0.85);
    color: #fff;
    text-align: left;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.2;
    position: absolute;
    z-index: 100;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s;
    white-space: pre-line;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

/* Search box above thumbnails */
/* Container to position input & clear button */
#search-container {
    position: relative;
    width: calc(100% - 24px);
    /* full width minus horizontal margins (12px * 2 [left/right]) */
    margin: 0 12px;
    /* left and right margins */
    max-width: none;
    /* remove hard cap */
    box-sizing: border-box;
    /* ensures width includes padding/margin */
}

/* Dark mode input */
#model-search {
    width: 100%;
    padding: 8px 12px 8px 12px;
    /* extra right padding for clear button */
    border-radius: 6px;
    border: 1px solid #555;
    background-color: #222;
    color: #fff;
    font-size: 14px;
    outline: none;
    box-sizing: border-box;
}

#model-search::placeholder {
    color: #888;
}

/* Clear button */
#model-search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    color: #aaa;
    cursor: pointer;
    display: none;
    transition: color 0.2s ease, transform 0.2s ease;
}

#model-search-clear:hover {
    color: #fff;
    transform: translateY(-50%) scale(1.2);
}

/* ================== HDRi links ================== */
/* Hide the link on page load */
#hdri-select {
    display: none;
    /* hidden initially */
    color: #9ecfff;
    text-decoration: none;
    position: relative;
    padding-right: 1.2em;
    transition: color 0.3s ease;
    cursor: pointer;
}

#hdri-select::after {
    content: "↗";
    font-size: 0.8em;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.7;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Hover effects */
#hdri-select:hover {
    color: #ffffff;
}

#hdri-select:hover::after {
    opacity: 1;
    transform: translateY(-50%) scale(1.1);
}

/* ================ Model Selection Highlight ================= */
.object:hover {
    border: 2px solid #1d72b8;
    /* blue border on hover */
    cursor: pointer;
    /* hand cursor */
    transition: border-color 0.3s ease;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    #search-container {
        max-width: 90%;
    }

    #model-search {
        font-size: 13px;
        padding: 6px 30px 6px 10px;
    }

    #model-search-clear {
        font-size: 14px;
    }
}


/* ================ HDRi preloader ================= */
#objects-list.disabled .thumb {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ================= Mobile Drawer / Toggle ================= */
#menu-toggle {
    display: none;
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 5;
    background: #000;
    color: #fff;
    border: none;
    font-size: 20px;
    padding: 10px 14px;
    border-radius: 4px;
    cursor: pointer;
}

/* Overlay for mobile sidebar */
#overlay {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1400;
}

/* ================= Responsive ================= */
@media (max-width: 1024px) {
    #grid-container {
        grid-template-columns: 25% auto;
    }
}

@media (max-width: 768px) {
    #menu-toggle {
        display: block;
    }

    #grid-container {
        grid-template-columns: 1fr;
        grid-template-areas: "object-viewer";
    }

    /* Sidebar slides over viewer */
    #object-container {
        position: fixed;
        top: 0;
        right: -100%;
        width: 70%;
        height: 100vh;
        background-color: #111;
        z-index: 3;
        transition: right 0.35s cubic-bezier(0.25, 1, 0.5, 1);
        box-shadow: -4px 0 12px rgba(0, 0, 0, 0.6);
        display: flex;
        flex-direction: column;
    }

    #object-container.active {
        right: 0;
    }

    /* Keep thumbnails scrollable inside sidebar */
    #objects-list {
        flex: 1 1 auto;
        overflow-y: auto;
        padding: 8px;
        max-height: 100%;
    }

    /* Sticky header and search box */
    #object-header {
        position: sticky;
        top: 0;
        z-index: 20;
    }

    #search-container {
        position: sticky;
        top: 40px;
        z-index: 15;
    }

    /* Overlay visible when sidebar active */
    #object-container.active~#overlay {
        opacity: 1;
        visibility: visible;
    }

    /* Viewer fills screen */
    #object-viewer {
        width: 100%;
        height: 100vh;
        overflow: hidden;
    }
}