﻿:root {
    --bg-color: #0a0a0a;
    --text-main: #e0e0e0;
    --text-muted: #888;
    --accent: #c5a059;
    /* Muted Gold */
    --font-serif: "Noto Serif TC", "Songti TC", "PMingLiU", "Didot", "Bodoni MT", "Times New Roman", serif;
    --font-sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-sans);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    user-select: none;
    /* Prevent selection during drag */
}

/* Noise Texture */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.05'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 1000;
    opacity: 0.4;
}

/* Subtle Gradient Background */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 30%, #1a1a1a 0%, #000000 90%);
    z-index: -1;
}

header {
    text-align: center;
    padding: 2rem;
    position: relative;
    z-index: 1;
    /* Removed animation/opacity from container to keep nav visible */
    pointer-events: none;
    /* Pass clicks through empty space */

    /* Full Screen Layout */
    min-height: 90vh;
    /* Leave a hint of content or use 100vh */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin-bottom: 2rem;
}

/* New: Handle Title Fading Separately */
/* New: Handle Title Fading Separately */
.header-content {
    opacity: 0;
    transition: opacity 1.5s ease-out;
    pointer-events: none;
    /* Default: Pass clicks through when hidden */
}

/* Corrected selector: header tag instead of .header-nav class */
header.active {
    opacity: 1;
    pointer-events: auto;
}

header.active .header-content {
    opacity: 1;
    pointer-events: auto;
}

/* Ensure Nav Buttons are always interactive */
/* Ensure Nav Buttons are always interactive and fixed */
.top-nav-group {
    position: fixed;
    top: 30px;
    right: 50px;
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 5000;
    /* High z-index to stay on top */
    pointer-events: auto;
}

.nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 6px 16px;
    font-family: var(--font-serif);
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.15em;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 5001;
    text-transform: uppercase;
}

.nav-btn:hover {
    background: var(--accent);
    color: #000;
    box-shadow: 0 0 10px rgba(197, 160, 89, 0.4);
}

h1 {
    font-family: var(--font-serif);
    font-size: 4rem;
    font-weight: 300;
    margin: 0 0 1.5rem 0;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--accent);
    position: relative;
    display: inline-block;
}

h1::after {
    content: '';
    display: block;
    width: 60px;
    height: 1px;
    background: var(--accent);
    margin: 1.5rem auto 0;
}

.subtitle {
    font-family: var(--font-sans);
    color: var(--text-muted);
    letter-spacing: 0.6em;
    font-size: 0.8rem;
    text-transform: uppercase;
    margin-top: 1rem;
}

/* Gallery Grid */
.gallery-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 5rem 4rem;
    padding: 0 6rem 8rem;
    max-width: 1800px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

@media (max-width: 1024px) {
    .gallery-container {
        padding: 0 3rem 6rem;
        gap: 3rem 2rem;
    }
}

@media (max-width: 600px) {
    .gallery-container {
        grid-template-columns: 1fr;
        padding: 0 1.5rem 4rem;
    }

    h1 {
        font-size: 2.5rem;
    }
}

.art-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0;
}

/* Realistic Framed Art CSS */
.art-image-wrapper {
    position: relative;
    width: 100%;
    cursor: pointer;
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), box-shadow 0.4s;
    background-color: #0d0d0d;
    padding: 12px;
    border: 1px solid #222;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5), 0 15px 35px rgba(0, 0, 0, 0.3);
}

.art-image-wrapper::after {
    content: '';
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    bottom: 12px;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    z-index: 2;
}

.art-image-wrapper:hover {
    transform: translateY(-5px) scale(1.01);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), 0 40px 80px rgba(0, 0, 0, 0.4);
    border-color: #333;
}

.art-image {
    width: 100%;
    height: auto;
    display: block;
}

.art-info {
    margin-top: 1.5rem;
    text-align: center;
    width: 100%;
}

.art-title {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    letter-spacing: 0.05em;
    font-weight: 400;
    color: #fff;
    margin: 0 0 0.4rem;
}

.art-meta {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.6;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.art-year {
    font-size: 0.75rem;
    color: var(--accent);
    margin-top: 0.3rem;
    font-family: var(--font-serif);
    font-style: italic;
}

/* Lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.98);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    backdrop-filter: blur(5px);
}

/* Lightbox Navigation */
.lb-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    color: #fff;
    font-size: 2rem;
    opacity: 0.6;
    transition: opacity 0.3s, background 0.3s;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 2100;
    user-select: none;
}

.lb-nav:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.6);
}

.lb-prev {
    left: 2rem;
}

.lb-next {
    right: 2rem;
}

@media (max-width: 1024px) {
    .lb-nav {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }

    .lb-prev {
        left: 1rem;
    }

    .lb-next {
        right: 1rem;
    }
}



/* Room Thumbnail Items */
.room-thumb-item {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    opacity: 0.6;
    transition: all 0.3s;
    position: relative;
}

.room-thumb-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.room-thumb-item:hover {
    opacity: 1;
    transform: scale(1.1);
}

.room-thumb-item.active {
    border-color: #fff;
    opacity: 1;
    transform: scale(1.15);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.room-thumb-tooltip {
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.room-thumb-item:hover .room-thumb-tooltip {
    opacity: 1;
}

/* Lightbox Content & Layout */
.lightbox.active {
    opacity: 1;
    pointer-events: all;
}

.lightbox-content {
    max-width: 90vw;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.lightbox-img {
    max-width: 100%;
    max-height: 65vh;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.8);
    transform: scale(0.95);
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    object-fit: contain;
}

.lightbox.active .lightbox-img {
    transform: scale(1);
}

.lightbox-caption {
    margin-top: 1.5rem;
    text-align: center;
    color: #fff;
    animation: fadeReveal 0.8s 0.3s ease-out forwards;
    opacity: 0;
    transform: translateY(10px);
    flex-shrink: 0;
}

.lb-title {
    font-family: var(--font-serif);
    font-size: 1.8rem;
    font-weight: 300;
    margin-bottom: 0.3rem;
    letter-spacing: 0.1em;
}

.lb-detail {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.lightbox-btn-group {
    margin-top: 1.5rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
    opacity: 0;
    animation: fadeReveal 0.8s 0.5s ease-out forwards;
}

.close-btn {
    position: absolute;
    top: 2rem;
    right: 2rem;
    color: var(--text-muted);
    font-size: 3rem;
    font-weight: 100;
    cursor: pointer;
    transition: color 0.3s, transform 0.3s;
    line-height: 0.5;
    font-family: var(--font-sans);
    z-index: 6000;
}

.close-btn:hover {
    color: #fff;
    transform: rotate(90deg);
}


/* Updated Room Controls to match Gallery Style */
.room-controls {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    background: rgba(10, 10, 10, 0.85);
    padding: 0.8rem 2rem;
    border-radius: 50px;
    backdrop-filter: blur(10px);
    z-index: 2600;
    pointer-events: auto;
    white-space: nowrap;
    width: auto;
    max-width: 95%;
}

.sheet-handle {
    display: none;
}

.control-actions {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.room-controls input[type="file"] {
    display: none;
}

.room-thumbs {
    display: flex;
    gap: 10px;
    padding: 0;
    background: transparent;
    border-radius: 0;
    backdrop-filter: none;
    margin-right: 5px;
}

/* Updated Button Style */
.btn {
    border: 1px solid #444;
    /* Darker border default */
    background: transparent;
    color: #aeaeae;
    /* Muted text */
    padding: 0.8em 1.5em;
    font-family: 'Noto Sans TC', sans-serif;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s;
    border-radius: 2px;
    white-space: nowrap;
    font-weight: 400;
}

.btn:hover {
    border-color: #fff;
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.room-dim-info {
    font-family: 'Noto Sans TC', sans-serif;
    font-size: 0.7rem;
    color: var(--accent);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 0.5rem;
    text-transform: uppercase;
    font-weight: 300;
}

/* 
   --- ROOM VIEW BASE STYLES ---
*/
#room-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #111;
    z-index: 2500;
    display: none;
    overflow: hidden;
    cursor: grab;
}

#room-view.active {
    display: block;
    animation: fadeIn 0.5s ease-out;
}

#scene-world {
    position: absolute;
    top: 50%;
    left: 50%;
    will-change: transform, width, height;
    background-size: cover;
    background-position: center;
    transform-origin: center center;
    box-shadow: 0 0 200px rgba(0, 0, 0, 0.8);
    transition: width 0.5s ease, height 0.5s ease, background-image 0.5s ease;
}

#room-art-container {
    position: absolute;
    transform: translate(-50%, -50%);
    cursor: move;
    box-shadow: 10px 20px 50px rgba(0, 0, 0, 0.6);
    will-change: top, left;
}

#room-art {
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
    border: 1.5px solid #111;
    box-sizing: border-box;
}

#room-guide {
    position: absolute;
    top: 2rem;
    left: 0;
    width: 100%;
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    font-family: 'Noto Sans TC', sans-serif;
    font-size: 0.8rem;
    font-weight: 300;
    pointer-events: none;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    z-index: 2600;
}

.room-info-overlay {
    position: absolute;
    bottom: 2rem;
    left: 2rem;
    width: 250px;
    background: rgba(10, 10, 10, 0.6);
    backdrop-filter: blur(8px);
    padding: 1.5rem;
    border-left: 2px solid var(--accent);
    color: #fff;
    z-index: 2600;
    pointer-events: none;
    text-align: left;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.room-info-title {
    font-family: 'Cormorant Garamond', 'Noto Serif TC', serif;
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: #fff;
    line-height: 1.2;
    font-weight: 400;
}

.room-info-meta {
    font-family: 'Noto Sans TC', sans-serif;
    font-size: 0.75rem;
    color: #bbb;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1.5;
    margin-bottom: 1rem;
    font-weight: 300;
}

/* Mobile/Tablet Optimizations (<= 1024px) */
@media (max-width: 1024px) {
    #room-guide {
        font-size: 0.7rem;
        top: 10px;
        padding: 0 50px;
        /* Avoid Close Button */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        opacity: 0.7;
    }

    /* Change text for mobile via ::after hack or just hide/simplify */
    #room-guide {
        content: url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7");
        /* Clear text */
        height: 20px;
    }

    #room-guide::after {
        content: "Drag to Move · Pinch to Zoom";
        display: block;
        text-align: center;
        width: 100%;
    }

    .room-controls {
        width: 100%;
        max-width: 100%;
        padding: 0 15px 25px;
        /* Reduced top padding */
        padding-bottom: calc(15px + env(safe-area-inset-bottom));
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        gap: 8px;
        /* Reduced gap for tighter look */

        position: fixed;
        bottom: 0;
        left: 0;
        display: none;
        /* Let JS handle display */

        background: rgba(10, 10, 10, 0.98);
        /* Slightly darker for premium feel */
        backdrop-filter: blur(25px);
        -webkit-backdrop-filter: blur(25px);

        border-top-left-radius: 24px;
        border-top-right-radius: 24px;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;

        pointer-events: auto !important;
        z-index: 7000 !important;
        will-change: transform;
        box-shadow: 0 -10px 50px rgba(0, 0, 0, 0.6);
        touch-action: none !important;

        user-select: none !important;
        -webkit-user-select: none !important;
        -webkit-tap-highlight-color: transparent !important;
    }

    .room-controls.active {
        display: flex;
    }

    .sheet-toggle {
        order: -1;
        width: 100%;
        height: 20px;
        /* Adjusted to 20px */
        margin-top: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        background: transparent !important;
        cursor: grab;
        z-index: 7010 !important;
        pointer-events: auto !important;
        touch-action: none !important;
        flex-shrink: 0;
        user-select: none !important;
        -webkit-tap-highlight-color: transparent !important;
    }

    .toggle-icon {
        width: 36px;
        height: 7px;
        /* Adjusted cap for 20px handle */
        position: relative;
        pointer-events: none;
    }

    .toggle-icon::before,
    .toggle-icon::after {
        content: "";
        position: absolute;
        left: 0;
        width: 100%;
        height: 1.5px;
        /* Thin lines */
        background: rgba(255, 255, 255, 0.35);
        border-radius: 1px;
    }

    .toggle-icon::before {
        top: 0;
    }

    .toggle-icon::after {
        bottom: 0;
    }

    .room-thumbs {
        order: 0;
        width: 100%;
        margin: 5px 0 0;
        padding-top: 10px;
        /* Kept padding to prevent clipping when active */
        display: flex;
        justify-content: center;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 5px;
        pointer-events: auto;
        scrollbar-width: none;
        touch-action: pan-x;
    }

    .room-thumbs::-webkit-scrollbar {
        display: none;
    }

    .control-actions {
        order: 1;
        display: flex;
        gap: 6px;
        /* Closer buttons to stay within bounds */
        background: transparent;
        backdrop-filter: none;
        padding: 0;
        border-radius: 0;
        pointer-events: auto;
        box-shadow: none;
        width: 100%;
        justify-content: center;
    }

    .room-controls .btn {
        padding: 0.7em 0.5em;
        /* Tighter padding */
        font-size: 0.65rem;
        /* Smaller font to avoid overflow */
        flex: 1;
        text-align: center;
        white-space: nowrap;
        min-width: 0;
        letter-spacing: 0.05em;
        /* Reduced spacing */
        border: 1px solid rgba(255, 255, 255, 0.2);
    }

    /* Make buttons distinct row - REMOVE this logic, we want single row */
    .room-controls button,
    .room-controls label {
        display: inline-block;
    }

    /* Container for buttons to sit side-by-side - REMOVE, redundant */
    .room-controls-buttons {
        display: contents;
        /* Or remove entirely */
    }

    /* Removing duplicate room-thumbs logic */

    /* Info box smaller and top-left or hidden? */
    .room-info-overlay {
        top: 1rem;
        bottom: auto;
        left: 1rem;
        width: auto;
        max-width: 60%;
        padding: 1rem;
        background: rgba(0, 0, 0, 0.4);
    }

    .room-info-title {
        font-size: 1rem;
    }

    .room-info-meta {
        display: none;
    }

    /* Hide details on mobile to save space */
    .room-dim-info {
        display: none;
    }

    .close-btn {
        top: 1rem;
        right: 1rem;
        font-size: 2.5rem;
    }
}



/* 
   --- CUSTOM CURSOR --- 
*/
#cursor {
    position: fixed;
    top: 0;
    left: 0;
    width: 20px;
    height: 20px;
    border: 1px solid #fff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 9999;
    mix-blend-mode: difference;
    transition: width 0.3s, height 0.3s, background-color 0.3s, transform 0.1s;
    will-change: top, left, width, height;
}

#cursor.hover {
    width: 50px;
    height: 50px;
    background-color: rgba(255, 255, 255, 0.2);
    border-color: transparent;
}

#cursor.hidden {
    opacity: 0;
}

/* Hide Default Cursor on Desktop when not touch */
@media (hover: hover) and (pointer: fine) {

    body,
    a,
    button,
    .art-image-wrapper,
    .room-thumb-item,
    .lb-nav,
    .close-btn {
        cursor: none !important;
    }
}

/* Hide Custom Cursor on Mobile */
@media (hover: none) {
    #cursor {
        display: none;
    }
}

/* Frame Style Indicator */
#frame-btn span {
    display: none;
    width: 10px;
    height: 10px;
    margin-right: 8px;
    border: 1px solid #666;
    vertical-align: middle;
}

/* 
   --- INTRO & LOADING --- 
*/
#intro-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    transition: opacity 1.5s ease-out, visibility 1.5s;
}

#intro-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.intro-content {
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1s ease-out, transform 1s ease-out;
}

.intro-content.show {
    opacity: 1;
    transform: translateY(0);
}

.intro-title {
    font-family: var(--font-serif);
    font-size: 3rem;
    color: var(--accent);
    margin-bottom: 1rem;
    letter-spacing: 0.2em;
}

.intro-subtitle {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    color: var(--text-muted);
    letter-spacing: 0.4em;
    font-size: 1rem;
    color: #888;
    margin-bottom: 2.5rem;
    letter-spacing: 2px;
}

.intro-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: center;
}

.enter-btn {
    padding: 15px 40px;
    background: transparent;
    border: 1px solid #c5a059;
    color: #c5a059;
    font-family: inherit;
    font-size: 1rem;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all 0.5s ease;
    text-transform: uppercase;
    opacity: 0;
    animation: fadeIn 2s 1s ease-out forwards;
}

.secondary-btn {
    background: rgba(197, 160, 89, 0.1);
    /* Subtle fill for 3D button */
}

.enter-btn:hover {
    background: #c5a059;
    color: #000;
    box-shadow: 0 0 20px rgba(197, 160, 89, 0.3);
}

/* Animations Triggered Only When Active */
body.exhibition-active header {
    animation: fadeReveal 1.5s ease-out forwards;
}

.header-logo {
    width: 140px;
    height: 140px;
    display: block;
    margin: 0 auto 1.5rem;
    opacity: 0.9;

    /* Crop disabled */
    /* clip-path: circle(34% at 50% 50%); */

    /* No blend mode needed as image is transparent, but crop is needed */
    object-fit: contain;
}

.intro-logo {
    width: 220px;
    height: 220px;
    display: block;
    margin: 0 auto 2rem;
    opacity: 0;
    animation: fadeReveal 1s ease-out forwards;

    /* Crop disabled */
    /* clip-path: circle(34% at 50% 50%); */

    object-fit: contain;
}

/* Disable initial animations (moved control to JS adding class) */
header {
    opacity: 0;
}

/* Loading Spinner Text */
.loader-text {
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    animation: pulse 2s infinite;
    position: absolute;
    bottom: 10%;
}

@keyframes fadeReveal {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes pulse {
    0% {
        opacity: 0.3;
    }

    50% {
        opacity: 0.8;
    }

    100% {
        opacity: 0.3;
    }
}

#ambient-light {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
    /* Below controls (z-index usually higher) but above world */
    mix-blend-mode: overlay;
    background: radial-gradient(circle 800px at var(--lx, 50%) var(--ly, 50%),
            rgba(255, 255, 255, 0.15) 0%,
            rgba(0, 0, 0, 0) 40%,
            rgba(0, 0, 0, 0.4) 100%);
    transition: background 0.1s;
    opacity: 0.8;
}

/* Top Navigation Group */
.top-nav-group {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 100;
}

/* Social Icons */
.social-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #c5a059;
    transition: all 0.3s ease;
    opacity: 0.8;
}

.social-icon:hover {
    opacity: 1;
    transform: scale(1.1);
    color: #fff;
    filter: drop-shadow(0 0 5px rgba(197, 160, 89, 0.6));
}

/* New Header 3D Button */
.header-3d-btn {
    /* Removed absolute pos, now in group */
    /* top: 20px; right: 20px; */
    padding: 8px 20px;
    border: 1px solid #c5a059;
    color: #c5a059;
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    text-decoration: none;
    transition: all 0.3s ease;
    letter-spacing: 0.1em;
}

.header-3d-btn:hover {
    background: #c5a059;
    color: #000;
    box-shadow: 0 0 15px rgba(197, 160, 89, 0.4);
}

/* Scroll Navigation */
.scroll-nav {
    position: fixed;
    bottom: 30px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
}

.scroll-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid #c5a059;
    color: #c5a059;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

/* Only apply hover effects on mouse-capable devices */
@media (hover: hover) {
    .scroll-btn:hover {
        background: #c5a059;
        color: #000;
        transform: translateY(-2px);
        box-shadow: 0 0 15px rgba(197, 160, 89, 0.4);
    }
}

/* Dynamic feedback for touch devices */
.scroll-btn:active {
    background: #c5a059;
    color: #000;
    transform: scale(0.9);
    transition: all 0.1s;
}

/* Header Exhibition Info */
.header-info-divider {
    width: 40px;
    height: 1px;
    background: #c5a059;
    margin: 15px auto 10px;
    opacity: 0.6;
}

.header-info {
    font-family: var(--font-sans);
    color: #aeaeae;
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    margin-top: 5px;
    opacity: 0.9;
}

/* Copyright Footer */
.copyright-footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--accent);
    font-family: var(--font-sans);
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    opacity: 0.6;
    margin-top: 4rem;
}

/* --- INDEX SPECIFIC STYLES --- */

/* One-Page Scroll Presentation Styles (Index Only) */
*,
*::before,
*::after {
    box-sizing: border-box;
    /* Prevent padding overflow */
}

body {
    overflow: hidden;
    background-color: #050505;
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
}

/* Essential for full screen isolation */
.slide-container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

/* Slides - Unified Selector for all full-screen slides */
header,
.art-item,
#poem-slide,
#poem-slide-2,
#poem-slide-3,
#poem-slide-4,
#poem-slide-5 {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    margin: 0 !important;
    padding: 3rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1.5s ease-in-out;
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    overflow: hidden;
}

header.active,
.art-item.active,
#poem-slide.active,
#poem-slide-2.active,
#poem-slide-3.active,
#poem-slide-4.active,
#poem-slide-5.active {
    opacity: 1;
    pointer-events: auto;
    z-index: 20;
}

/* Social Links - Keep them fixed and visible/accessible */
.top-nav-group {
    position: fixed !important;
    top: 1.5rem !important;
    right: 1.5rem !important;
    z-index: 1000;
    display: flex;
    gap: 1.2rem;
    opacity: 1 !important;
    /* Always visible or use JS to toggle */
    pointer-events: auto !important;
}

/* Gallery Container override */
.gallery-container {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    height: 100% !important;
}

/* Artwork Presentation */
.art-image-wrapper {
    flex: 0 1 auto;
    width: auto;
    height: auto;
    max-width: 90vw;
    max-height: 75vh;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.9);
    margin-bottom: 2vh;
}

.art-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

.art-info {
    flex: 0 0 auto;
    margin-top: 1rem;
    text-align: center;
    max-width: 800px;
    background: none !important;
    /* Cleaner look */
    backdrop-filter: none !important;
}

/* Fix Header items */
header .header-logo {
    margin-bottom: 1.5rem;
}

header hr,
header .header-info-divider {
    margin: 1.5rem auto !important;
}

/* Scroll Navigation */
.scroll-nav {
    display: flex !important;
    /* Restore Visibility */
    z-index: 1000;
}

/* Animation Reset */
header,
.art-item,
#poem-slide,
#poem-slide-2,
#poem-slide-3,
#poem-slide-4,
#poem-slide-5 {
    animation: none !important;
}

/* Golden Shine Animation */
header h1 {
    background: linear-gradient(90deg,
            #c5a059 0%,
            #c5a059 33%,
            #fff 50%,
            #c5a059 67%,
            #c5a059 100%);
    background-size: 300% 100%;
    background-repeat: repeat-x;
    color: transparent !important;
    -webkit-background-clip: text;
    background-clip: text;
    background-position: 100% center;
    transition: background-position 0s;
}

header.active h1 {
    animation: golden-shine 1.5s linear 1.2s forwards !important;
}

@keyframes golden-shine {
    from {
        background-position: 100% center;
    }

    to {
        background-position: 0% center;
    }
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    header h1 {
        font-size: 2.2rem;
        letter-spacing: 0.2em;
    }

    .subtitle {
        font-size: 0.65rem;
        letter-spacing: 0.3em;
    }

    .header-info {
        font-size: 0.65rem;
        padding: 0 1rem;
        line-height: 1.8;
    }

    .mobile-br {
        display: block !important;
        height: 0.3rem;
    }

    header h1 {
        touch-action: manipulation;
    }

    .poem-wrap {
        font-size: 0.8rem;
        /* Further reduced */
        line-height: 1.5;
        padding: 0;
        /* Absolute zero padding */
        width: 100%;
        max-width: 100vw;
        letter-spacing: 0.05em;
        /* Minimal spacing */
        overflow-x: hidden;
    }

    body>p {
        display: none !important;
    }

    .force-nowrap {
        white-space: nowrap !important;
    }

    .art-item {
        padding: 1rem;
    }

    .art-item.active {
        cursor: pointer;
        touch-action: manipulation;
    }

    .art-image-wrapper {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 50vh !important;
        /* Reduced from 70vh to show text */
        max-height: 50vh !important;
        box-shadow: none;
        margin-bottom: 1rem;
        /* Reduced margin */
        cursor: pointer;
        /* Change to pointer to hint interactivity */
        display: flex;
        align-items: center;
        justify-content: center;
        pointer-events: none;
        /* Let clicks pass through wrapper if not hitting image */
    }

    .art-image {
        width: auto;
        /* Allow width to shrink to fit height logic */
        max-width: 100%;
        height: 100%;
        object-fit: contain;
        pointer-events: auto !important;
        /* Only image captures clicks */
        cursor: pointer;
        position: relative;
        z-index: 50;
        /* Lift above everything */
    }

    .art-info {
        font-size: 0.8rem;
        padding: 0.5rem 1rem;
        margin-top: 0;
        transform: translateY(-10px);
        /* Pull text up slightly */
    }

    .top-nav-group {
        top: 1rem !important;
        right: 1rem !important;
        gap: 0.8rem;
    }

    .desktop-sep {
        display: none !important;
    }
}

/* Poem Specific */
.poem-wrap {
    font-family: var(--font-serif);
    color: var(--accent);
    text-align: center;
    line-height: 1.8;
    letter-spacing: 0.25em;
    font-size: 1.15rem;
    width: 100vw;
    padding: 2rem 1rem;
    /* Reduced horizontal padding */
    transform: translateY(-5vh);
    /* Shift everything up slightly */
}

.poem-row {
    margin-bottom: 1.2rem;
    width: 100%;
    display: block;
}

.poem-fading-group {
    opacity: 1;
    display: block;
    width: 100%;
}

.active .poem-fading-group {
    animation: fadeOutGroup 1s ease-in-out 5s forwards;
}

@keyframes fadeOutGroup {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

.poem-segment {
    opacity: 0;
    transition: opacity 1.2s ease-in-out;
    display: inline-block;
    white-space: pre-wrap;
}

.force-show .poem-segment,
.force-show .poem-fading-group {
    transition: none !important;
    animation: none !important;
    transition-delay: 0s !important;
    opacity: 1 !important;
}

.active .poem-segment {
    opacity: 1;
}

/* Reset state immediately when not active to allow replay */
/* Ensure fading-group is hidden when resetting to prevent flash */
.slide-section:not(.active) .poem-segment,
.slide-section:not(.active) .poem-fading-group {
    transition-delay: 0s !important;
    transition-duration: 0.1s !important;
    opacity: 0 !important;
}

/* End of Reset Block */

/* 
   --- NAVIGATION & MODAL STYLES --- 
*/
.nav-btn {
    background: transparent;
    border: 1px solid var(--accent);
    /* Gold border */
    color: var(--accent);
    /* Gold text */
    padding: 0.5em 1em;
    font-family: var(--font-serif);
    /* Serif font for elegance */
    font-size: 0.8rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-left: 10px;
    /* Reduced gap since we have more buttons */
    border-radius: 2px;
    -webkit-appearance: none;
    /* iOS Safari reset */
    appearance: none;
}

.nav-btn:hover {
    background: var(--accent);
    color: #000;
    /* Black text on hover */
    border-color: var(--accent);
}

.home-btn {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.home-btn.show {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}



/* Playback Mode (Hide Statement & Social) */
.top-nav-group.playback-active .statement-btn,
.top-nav-group.playback-active .social-icon {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.statement-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 10, 0.45);
    /* Even more transparent */
    backdrop-filter: blur(10px);
    /* Slightly reduce blur to match transparency */
    -webkit-backdrop-filter: blur(10px);
    z-index: 4000;
    /* Highest priority */
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    /* Crucial: Pass clicks when hidden */
    transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.6s;
}

.statement-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    /* Enable clicks only when active */
}

.statement-content {
    position: relative;
    max-width: 90vw;
    max-height: 85vh;
    /* Increased right padding to 12rem to clear the absolute title */
    padding: 4rem 12rem 4rem 6rem;
    color: #e0e0e0;
    overflow-x: auto;
    /* Horizontal scroll for vertical text */
    overflow-y: hidden;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE */
    /* Reveal Animation */
    transform: translateY(30px);
    transition: transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);

    /* Ensure content flows correctly */
    display: flex;
    flex-direction: row-reverse;
    /* Or relying on vertical-rl might need container adjust */
}

.statement-overlay.active .statement-content {
    transform: translateY(0);
}

.statement-content::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

/* Vertical Text Layout */
.statement-text {
    writing-mode: vertical-rl;
    /* Vertical writing, right to left */
    text-orientation: mixed;
    font-family: var(--font-serif);
    font-size: 1.1rem;
    line-height: 2.2;
    letter-spacing: 0.15em;
    height: 60vh;
    /* Fixed height for text area */
    text-align: justify;
    margin: 0 auto;
    position: relative;
    /* Context for footer */
}

.statement-text p {
    margin-left: 1.5em;
    /* Spacing between vertical lines */
}

/* Vertical Text Utilities */
.tcy {
    text-combine-upright: all;
    -webkit-text-combine: horizontal;
    /* Safari/Chrome */
    font-family: var(--font-sans);
    /* Numbers look better in Sans */
}

.upright {
    text-orientation: upright;
    font-family: var(--font-sans);
    /* Letters look better in Sans */
    letter-spacing: 0;
}

.statement-title {
    position: absolute;
    top: 2rem;
    right: 4rem;
    writing-mode: vertical-rl;
    font-family: var(--font-serif);
    font-size: 2rem;
    color: var(--accent);
    letter-spacing: 0.3em;
    border-left: 1px solid var(--accent);
    padding-left: 1rem;
    height: auto;
    max-height: 80%;
}

.statement-footer {
    position: absolute;
    bottom: -3rem;
    /* Push below the text block */
    left: 0;
    /* Align with leftmost edge of the text block */
    font-family: var(--font-sans);
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 0.2em;
    opacity: 0.6;
    writing-mode: horizontal-tb;
    /* Reset to horizontal text */
    width: 100%;
    /* Ensure width if needed, or stick to content */
    text-align: left;
    /* Align text start */
}

.statement-close {
    position: absolute;
    top: 2rem;
    left: 2rem;
    /* Left side for close button in vertical layout */
    right: auto;
    font-size: 3rem;
    color: rgba(255, 255, 255, 0.4);
    z-index: 4001;
}

.statement-close:hover {
    color: var(--accent);
    transform: rotate(90deg);
}

/* Mobile Optimizations for Statement */
@media (max-width: 768px) {
    .statement-content {
        /* Increased right padding for mobile too */
        padding: 4rem 5rem 4rem 2rem;
        width: 100%;
    }

    .statement-text {
        font-size: 0.95rem;
        line-height: 2;
        height: 55vh;
    }

    .statement-title {
        right: 1.5rem;
        font-size: 1.5rem;
    }

    .statement-close {
        top: 1rem;
        left: 1rem;
        font-size: 2.5rem;
    }

    /* Fix overlap between Enter button and Loader on mobile */
    .loader-text {
        bottom: 5%;
        /* Push lower to avoid button */
        font-size: 0.7rem;
        /* Slightly smaller text */
    }

    .statement-footer {
        bottom: -3rem;
        left: 0;
        transform: none;
        width: auto;
        text-align: left;
    }
}

@media (max-width: 768px) {
    #room-info-box {
        display: block !important;
        position: fixed !important;
        top: 0 !important;
        /* Snap to top edge */
        bottom: auto !important;
        left: 0 !important;
        right: auto !important;
        width: auto !important;
        max-width: 85% !important;
        pointer-events: none;
        z-index: 2000 !important;
        background: rgba(0, 0, 0, 0.6) !important;
        backdrop-filter: blur(5px) !important;
        padding: 10px 15px 10px 15px !important;
        /* Adjusted padding */
        margin: 0 !important;
        visibility: visible !important;
        opacity: 1 !important;
        border: none !important;
        border-radius: 0 0 10px 0 !important;
        /* Round bottom-right corner only */
        text-align: left !important;
        box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.3) !important;
    }

    #ri-title {
        display: block !important;
        font-size: 1.1rem !important;
        line-height: 1.3 !important;
        color: var(--text-gold) !important;
        text-shadow: none !important;
        margin-bottom: 5px !important;
        font-weight: 500 !important;
    }

    #ri-meta {
        display: block !important;
        font-size: 0.8rem !important;
        color: #eee !important;
        text-shadow: none !important;
        margin-top: 0 !important;
        line-height: 1.4 !important;
        visibility: visible !important;
    }

    #ri-meta br {
        content: " " !important;
        display: inline-block !important;
        width: 10px !important;
        height: 10px !important;
        margin: 0 !important;
    }

    #ri-dim {
        display: block !important;
        font-size: 0.75rem !important;
        color: var(--text-gold) !important;
        /* Yellow as requested */
        margin-top: 6px !important;
        border-top: 1px solid rgba(197, 160, 89, 0.3) !important;
        /* Subtle gold line */
        padding-top: 4px !important;
        font-weight: 400 !important;
        opacity: 0.9 !important;
    }

    .room-info-overlay {
        opacity: 1 !important;
        visibility: visible !important;
    }
}