/* =========================================
   LIGHTBOX STYLES (Shared)
   ========================================= */
.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: 5000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    backdrop-filter: blur(10px);
}

.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;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.8s 0.3s;
}

.lightbox.active .lightbox-caption {
    opacity: 1;
    transform: translateY(0);
}

.lb-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.8rem;
    font-weight: 300;
    margin-bottom: 0.3rem;
    letter-spacing: 0.1em;
}

.lb-detail {
    font-family: 'Noto Sans TC', sans-serif;
    font-size: 0.85rem;
    color: #888;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.lightbox-btn-group {
    margin-top: 1.5rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
}

/* 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: 5100;
    user-select: none;
}

.lb-nav:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.6);
}

.lb-prev {
    left: 2rem;
}

.lb-next {
    right: 2rem;
}

.lb-close {
    position: fixed;
    /* Changed from absolute to fixed to ensure it stays in viewport even if scroll happens */
    top: 2rem;
    right: 2rem;
    color: #888;
    font-size: 3rem;
    font-weight: 100;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    cursor: pointer;
    transition: color 0.3s, transform 0.3s;
    line-height: 0.5;
    z-index: 6100;
    /* Increased z-index above everything else */
}

.lb-close:hover {
    color: #fff;
    transform: rotate(90deg);
}

/* =========================================
   ROOM VIEW STYLES (Gallery Mode)
   ========================================= */
#room-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #111;
    z-index: 6000;
    display: none;
    overflow: hidden;
    cursor: grab;
}

#room-view.active {
    display: block;
}

#scene-world {
    position: absolute;
    top: 50%;
    left: 50%;
    will-change: transform, width, height;
    background-size: cover;
    background-position: center;
    transform-origin: center center;
    transition: width 0.5s, height 0.5s, background-image 0.5s;
}

#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;
    backface-visibility: hidden;
    transform: translateZ(0);
    image-rendering: -webkit-optimize-contrast;
}

.art-lighting-fx {
    display: none !important;
}

#ambient-light {
    display: none !important;
}

/* Controls & UI */
.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: 4px;
    /* Sharper corners as per reference usually, but 40px was there. Let's keep consistent with existing if not requested, but reference image looks boxy? No, reference 1 is button group. Let's stick to flex row. */
    border-radius: 50px;
    /* Keep pill shape based on current trend or reference 1 */
    backdrop-filter: blur(10px);
    z-index: 6100;
    white-space: nowrap;
    /* Prevent wrapping */
    width: auto;
    max-width: 95%;
}

.room-thumbs {
    display: flex;
    gap: 10px;
    margin-right: 15px;
}

.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;
    overflow: hidden;
}

.room-thumb-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.room-thumb-item.active {
    border-color: #fff;
    opacity: 1;
    transform: scale(1.15);
}

.room-thumb-tooltip {
    display: none;
    /* Can be enabled if needed */
}

/* Info Overlay */
.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 #c5a059;
    color: #fff;
    z-index: 6100;
    pointer-events: none;
}

.room-info-title {
    font-family: 'Cormorant Garamond', 'Noto Serif TC', serif;
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    font-weight: 400;
}

.room-info-meta {
    font-family: 'Noto Sans TC', sans-serif;
    font-size: 0.75rem;
    color: #bbb;
    line-height: 1.5;
    margin-bottom: 1rem;
    font-weight: 300;
}

.room-dim-info {
    font-family: 'Noto Sans TC', sans-serif;
    font-size: 0.7rem;
    color: #c5a059;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 0.5rem;
    font-weight: 300;
}

/* Buttons */
.btn {
    background: transparent;
    border: 1px solid #666;
    color: #ddd;
    padding: 0.8em 1.5em;
    font-family: 'Noto Sans TC', sans-serif;
    font-size: 0.8rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s;
    border-radius: 2px;
}

.room-controls .btn {
    border: 1px solid #444;
    /* Darker border default */
    background: transparent;
    color: #aeaeae;
    /* Muted text */
    padding: 0.8em 1.5em;
    font-size: 0.75rem;
    font-family: 'Noto Sans TC', sans-serif;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    white-space: nowrap;
    border-radius: 2px;
    /* Slightly rounded or sharp */
    transition: all 0.3s ease;
}

.btn:hover,
.room-controls .btn:hover {
    border-color: #fff;
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

#room-guide {
    position: absolute;
    top: 2rem;
    left: 0;
    width: 100%;
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.8rem;
    font-family: 'Noto Sans TC', sans-serif;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    pointer-events: none;
    z-index: 6100;
    font-weight: 300;
}

#ambient-light {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle 500px at var(--lx, 50%) var(--ly, 50%), rgba(197, 160, 89, 0.03) 0%, transparent 100%);
    pointer-events: none;
    z-index: 5500;
    opacity: 0;
    transition: opacity 1s;
}

#room-view.active~#ambient-light {
    opacity: 1;
}

/* =========================================
   CUSTOM CURSOR (Shared)
   ========================================= */
#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;
    display: none;
}

@media (hover: hover) {
    #cursor {
        display: block;
    }

    #cursor.hover {
        width: 50px;
        height: 50px;
        background-color: rgba(255, 255, 255, 0.2);
        border-color: transparent;
    }
}

#cursor.hidden {
    opacity: 0;
}

/* =========================================
   MOBILE RESPONSIVE ADJUSTMENTS
   ========================================= */
@media (max-width: 768px) {
    .lb-nav {
        font-size: 1.5rem;
        width: 40px;
        height: 40px;
    }

    .lb-prev {
        left: 10px;
    }

    .lb-next {
        right: 10px;
    }

    #room-guide {
        font-size: 0.7rem;
        top: 10px;
        padding: 0 50px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        opacity: 0.7;
        content: url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7");
        /* Hides text by replacment if we relied on pure css, but text is in HTML. */
    }

    /* Using pseudo-element to override text for visual simplicity if needed,
       but here we rely on the HTML text primarily or simpler CSS override */
    #room-guide span {
        display: none;
    }

    /* If we wrapped text */

    /* Force specific mobile guide style */
    #room-guide {
        color: transparent;
        /* Hide original text */
    }

    #room-guide::after {
        content: "Drag to Move · Pinch to Zoom";
        color: rgba(255, 255, 255, 0.7);
        display: block;
        text-align: center;
        width: 100%;
        position: absolute;
        top: 0;
        left: 0;
    }

    /* Room Controls Repositioning */
    /* Room Controls Repositioning (Mobile Drawer) */
    .room-controls {
        position: fixed !important;
        left: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: auto;
        min-height: 120px;
        /* Ensure enough height for thumbs */
        background: rgba(20, 20, 20, 0.95);
        backdrop-filter: blur(10px);
        border-top: 1px solid #444;
        padding: 20px 10px 10px 10px;
        /* Reduced bottom padding from 30px to 10px */
        /* Top padding for handle */
        flex-direction: column;
        display: flex !important;
        /* Force flex display */
        visibility: visible !important;
        /* Force visibility */
        /* Stack items: Toggle -> Thumbs -> Actions */
        align-items: center;
        justify-content: flex-start;
        gap: 15px;
        z-index: 7000;
        transform: translateY(0);
        /* Controlled by JS, but default visible */
        transition: transform 0.3s ease;
        border-radius: 20px 20px 0 0;
        /* Rounded top corners */
        overflow-x: hidden;
        /* Vertical stack mostly */
    }

    /* The Drawer Handle Container */
    .sheet-toggle {
        display: flex !important;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 25px;
        justify-content: center;
        align-items: center;
        cursor: grab;
        background: transparent;
    }

    /* The Drawer Handle Bar */
    /* The Drawer Handle Bar - Double Lines */
    .toggle-icon {
        width: 40px;
        height: 10px;
        /* Increased height to fit two lines */
        background: transparent;
        border-top: 2px solid #666;
        border-bottom: 2px solid #666;
        border-radius: 0;
    }

    /* Ensure specific items stack properly in drawer */
    .control-actions {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        width: 100%;
        justify-content: center;
        gap: 10px;
        padding-bottom: 5px;
        /* Reduced from 20px */
        /* Extra bottom padding for safety */
    }

    .room-thumbs {
        width: 100%;
        overflow-x: auto;
        display: flex;
        /* Ensure flex for horizontal scroll */
        justify-content: flex-start;
        padding: 5px 0;
        /* Vertical padding only */
        margin: 0;
        scroll-padding: 0 20px;
        box-sizing: border-box;
    }

    /* Ensure thumbnails themselves don't shrink */
    .room-thumbs>div,
    .room-thumbs>img,
    .room-thumb {
        flex-shrink: 0 !important;
    }

    /* Ensure content is centered if few items, or scrollable if many */
    #room-thumbs-container {
        justify-content: flex-start;
        /* Default start for scroll */
    }

    /* Pseudo-elements to add breathing room at start/end of scroll */
    .room-thumbs::before,
    .room-thumbs::after {
        content: '';
        display: block;
        flex: 0 0 20px;
        /* Force 20px spacer */
        width: 20px;
        height: 1px;
    }

    .room-thumbs {
        width: auto;
        margin-right: 5px;
        margin-bottom: 0;
        justify-content: flex-start;
        flex-wrap: nowrap;
        order: 0;
        /* Keep order */
        flex: 0 0 auto;
    }

    .room-controls .btn {
        padding: 0.6em 0.8em;
        font-size: 0.65rem;
        flex: 0 0 auto;
        /* Don't stretch */
        text-align: center;
        white-space: nowrap;
        min-width: auto;
    }

    /* Enhanced Info Overlay for Mobile (Synced with 2026_Tree_River Template) */
    .room-info-overlay {
        position: absolute;
        top: 0 !important;
        /* Snap to top edge */
        left: 0 !important;
        /* Snap to left edge */
        width: auto !important;
        max-width: 85% !important;
        padding: 15px 20px 15px 20px !important;
        background: rgba(0, 0, 0, 0.8) !important;
        backdrop-filter: blur(5px) !important;
        border-radius: 0 0 20px 0 !important;
        /* Template Style: Round bottom-right only */
        pointer-events: none;
        z-index: 6050;
        bottom: auto !important;
        right: auto !important;
        height: auto !important;
        box-shadow: 2px 2px 15px rgba(0, 0, 0, 0.4) !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        border-right: 1px solid rgba(255, 255, 255, 0.1);
    }

    /* Text Styling Matching Template */
    .room-info-title {
        font-size: 1.2rem !important;
        line-height: 1.3 !important;
        color: #c5a059 !important;
        /* Gold */
        margin-bottom: 5px !important;
        font-weight: 500 !important;
        text-shadow: none !important;
        font-family: "Noto Serif TC", serif !important;
    }

    .room-info-meta {
        font-size: 0.8rem !important;
        color: #ccc !important;
        line-height: 1.6 !important;
        text-shadow: none !important;
    }

    /* Dim Info with Separator */
    .room-dim-info {
        display: block !important;
        font-size: 0.7rem !important;
        color: #c5a059 !important;
        /* Gold */
        margin-top: 8px !important;
        border-top: 1px solid rgba(197, 160, 89, 0.3) !important;
        /* Divider */
        padding-top: 6px !important;
        font-weight: 400 !important;
        opacity: 0.9 !important;
        text-transform: uppercase;
        letter-spacing: 1px;
    }

    /* Fix Close Button Position & Size on Mobile - Unified Style */
    #room-view .close-btn,
    #room-view .lb-close {
        display: block !important;
        position: absolute !important;
        top: 2rem !important;
        right: 2rem !important;
        left: auto !important;
        font-size: 30px !important;
        /* Fixed pixel size */
        font-weight: bold !important;
        width: 40px !important;
        height: 40px !important;
        line-height: 40px !important;
        text-align: center !important;
        color: #fff !important;
        opacity: 1 !important;
        z-index: 7000 !important;
        text-shadow: 0 0 10px rgba(0, 0, 0, 0.5) !important;
        background: transparent !important;
        cursor: pointer !important;
    }

    .room-info-title {
        font-size: 1.2rem;
        color: #c5a059;
        margin-bottom: 0.2rem;
    }

    .room-info-meta {
        display: block;
        font-size: 0.75rem;
        color: #ddd;
        opacity: 0.9;
    }

    .room-dim-info {
        display: block;
        font-size: 0.65rem;
        color: #c5a059;
        margin-top: 5px;
        text-transform: uppercase;
        opacity: 0.9;
    }

    #room-view .lb-close {
        top: 1rem;
        right: 1rem;
        font-size: 2rem;
        z-index: 6200;
        text-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
    }
}