:root {
    --bg-color: #000000; /* Full black */
    --text-color: #e0e0e0;
    --accent-color: #c5a059; /* Roman Gold */
    --panel-width: 1200px; /* Increased from 800px to 1200px */
    --panel-height: 75vh; /* Increased from 60vh to 75vh */
    --radius: 2200px; /* Increased radius to accommodate wider panels without overlap */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Progress Bar Track */
.progress-bar {
    position: fixed;
    bottom: 0; /* Changed from top: 0 to bottom: 0 */
    left: 0;
    height: 3px;
    width: 100%;
    background: rgba(255, 255, 255, 0.1); /* Subtle track */
    z-index: 1000;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: var(--progress, 0%);
    background: rgba(255, 255, 255, 0.7);
    transition: width 0.15s ease-out;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Cormorant Garamond', serif;
    overflow: hidden; /* We handle scroll via JS events */
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Background textures/vignettes */
.vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Ellipse wider than tall - less darkening at top/bottom, more on sides */
    background: radial-gradient(ellipse 80% 120% at center, transparent 50%, #000000 130%);
    pointer-events: none;
    z-index: 10;
}

/* REMOVED overlay texture for purer black */
.overlay {
    display: none;
}

header {
    /* Now part of a .panel, so standard positioning within panel flex/grid context */
    width: 100%;
    text-align: center;
    pointer-events: none;
    text-shadow: 0 4px 10px rgba(0,0,0,0.8);
}

/* Reset the fixed positioning and transforms we added earlier */
header.fade-out {
    /* No longer needed */
}

/* Title panel needs higher specificity to override .panel grid layout */
.panel.title-panel {
    /* Override the grid display from .panel */
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

h1 {
    font-family: 'Cinzel', serif;
    font-size: 3.5rem;
    color: var(--text-color); /* White instead of gold */
    letter-spacing: 0.2em;
    text-transform: uppercase;
    margin-bottom: 0.8rem;
    text-align: center;
    width: 100%;
}

.subtitle {
    font-size: 1.5rem;
    letter-spacing: 0.12em;
    opacity: 0.8;
    margin-bottom: 1.5rem;
}

.description {
    font-size: 1.1rem;
    line-height: 1.6;
    max-width: 650px;
    margin: 0 auto;
    opacity: 0.7;
    font-style: italic;
    text-align: center;
}

/* 3D Scene */
.scene {
    perspective: 2000px;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.column {
    position: relative;
    width: var(--panel-width);
    height: var(--panel-height);
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d; /* Explicit WebKit prefix for iOS Safari */
    /* transition: transform 0.1s cubic-bezier(0.25, 0.46, 0.45, 0.94); REMOVED to fix jumpy start */
    /* We update transform every frame in JS, so transition can conflict or cause lag */
}

/* Panels */
.panel {
    position: absolute;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    /* Removed background and border for cleaner look */
    background: transparent;
    border: none;
    /* backdrop-filter: blur(10px); Removed blur */
    border-radius: 4px; /* Slight rounding */
    
    /* Backface visibility hidden usually, but we want to see them as they rotate? 
       Actually, hidden is better for performance and clean look. */
    backface-visibility: hidden; 
    
    /* Layout */
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr; /* Text first, then images */
    gap: 0.25rem;
    padding: 2rem;
    
    /* Initial state off-screen managed by JS transform */
    
    /* Smooth fade for visibility toggle */
    transition: opacity 1.5s ease;
}

/* Images Container */
.panel-images {
    grid-column: 1 / -1;
    grid-row: 2; /* Below text now */
    display: flex;
    justify-content: center;
    gap: 2rem;
    height: 100%;
    align-items: center;
}

.image-wrapper {
    position: relative;
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Curvature shading effect */
/* REMOVED as per user request to clear dark shapes around images */
.image-wrapper::after {
    display: none;
}


.image-wrapper img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    /* Cylindrical top/bottom curve simulation */
    border-radius: 20px; 
    box-shadow: 0 15px 40px rgba(0,0,0,0.6);
    transition: transform 0.3s ease, opacity 0.3s ease; /* Added opacity transition */
    cursor: zoom-in; /* Indicate zoom capability */
}

/* Hide placeholder images completely */
.image-wrapper img.lazy {
    opacity: 0;
    box-shadow: none;
    pointer-events: none;
}

/* Lightbox Overlay */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000; /* On top of everything */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(10px);
}

.lightbox.active {
    opacity: 1;
    pointer-events: auto;
}

.lightbox img {
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
    border-radius: 30px; /* More rounded corners for elegant lightbox */
    box-shadow: 0 0 50px rgba(0,0,0,0.5);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.lightbox.active img {
    transform: scale(1);
}

/* Zoomed state - REMOVE OLD HACKY CSS */
.image-wrapper img.zoomed {
    /* No longer used directly on the 3D image */
    display: none; /* Actually hide the original to prevent duplication artifacts? No, keep it. */
}

/* Dim backdrop when zoomed */
body.has-zoomed-image .vignette,
body.has-zoomed-image .column {
    /* Removed blur/filter transition which causes repaint lag on complex 3D scenes */
    /* Instead just rely on the dark overlay of the lightbox itself */
}

/* The "Slightly circular shape" effect - we can use a mask or border-radius */
.image-wrapper img.plate {
    /* Sepia tone for the original plates */
    filter: sepia(0.8) contrast(1.1);
}

.image-wrapper img.generated {
    /* Ensure it matches the plate vibe but cleaner */
    filter: contrast(1.1) saturate(0.9);
}

.image-label {
    /* Hiding label as per visual request to remove text below images */
    display: none;
}

/* Text Content */
.panel-text {
    grid-column: 1 / -1;
    grid-row: 1; /* Above images now */
    text-align: center;
    max-width: 80%;
    margin: 0 auto;
    font-size: clamp(0.9rem, 1.1rem, 1.2rem); /* Dynamic font sizing */
    line-height: 1.6;
    padding-bottom: 0.5rem;
    
    /* Prevent overflow issues */
    max-height: 20vh; /* Limit height */
    overflow-y: auto; /* Only show scrollbar when needed on desktop */
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.3) transparent;
    padding-right: 1rem; /* More space for text vs scrollbar */
    
    /* Mobile touch scrolling support */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain; /* Prevent scroll chaining to parent */
    
    /* Chrome iOS fix: escape 3D transform context and create isolated layer */
    position: relative;
    isolation: isolate; /* New stacking context */
    -webkit-transform-style: flat; /* Escape parent's preserve-3d */
    transform-style: flat;
    -webkit-backface-visibility: visible; /* Override parent's hidden */
    backface-visibility: visible;
    z-index: 1;
    
    /* Default state: hidden until panel is active */
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none; /* Prevent interaction with hidden text */
}

/* When panel is active/focused, show text and allow interaction */
.panel.active .panel-text {
    opacity: 1;
    pointer-events: auto; /* Allow scrolling and interaction */
}

/* Webkit Scrollbar Styling (Chrome/Safari/Edge) */
.panel-text::-webkit-scrollbar {
    width: 6px; /* Slightly larger for visibility */
}

.panel-text::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
}

.panel-text::-webkit-scrollbar-thumb {
    background-color: rgba(255,255,255,0.4);
    border-radius: 10px;
}

.panel-id {
    font-family: 'Cinzel', serif;
    font-size: 2rem;
    color: rgba(255,255,255,0.1);
    position: absolute;
    top: 1rem;
    left: 1rem;
    pointer-events: none;
}

/* Loading State */
.loading {
    color: var(--accent-color);
    font-family: 'Cinzel', serif;
}

/* Controls Hint */
.controls {
    position: fixed;
    bottom: 2rem;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    pointer-events: none;
    opacity: 0.7;
    z-index: 20;
    transition: opacity 0.5s ease; /* Add smooth transition */
}

.controls.hidden {
    opacity: 0;
}

.scroll-indicator {
    text-align: center;
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    color: var(--text-color);
    letter-spacing: 0.2em;
    animation: bounce 2s infinite;
}

/* Show desktop hint, hide mobile hint by default */
.hint-desktop {
    display: inline;
}

.hint-mobile {
    display: none;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {transform: translateY(0);}
    40% {transform: translateY(-5px);}
    60% {transform: translateY(-3px);}
}

/* Mobile Responsiveness */
@media (max-width: 900px) {
    :root {
        --panel-width: 95vw;
        --panel-height: 85vh;
        --radius: 1500px;
    }
    
    /* Reduce vignette at top where text now lives */
    .vignette {
        background: radial-gradient(ellipse 100% 150% at center 60%, transparent 45%, #000000 130%);
    }
    
    .panel {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        padding: 0.5rem;
        padding-top: 1.5rem;
        gap: 0;
    }
    
    /* Keep title centered on mobile */
    .panel.title-panel {
        justify-content: center;
        padding-top: 0;
    }

    .panel-images {
        flex-direction: column;
        gap: 0.75rem;
        height: auto;
        max-height: none;
        flex-shrink: 0;
    }
    
    .image-wrapper {
        flex: none;
        height: auto;
        max-height: 32vh;
    }
    
    .image-wrapper img {
        max-height: 32vh;
        border-radius: 12px;
    }

    .panel-text {
        font-size: 0.85rem;
        max-width: 95%;
        max-height: 18vh;
        padding: 0.5rem;
        padding-right: 0.75rem; /* Space for scrollbar */
        margin-bottom: 0.75rem; /* Space below text, above images */
        margin-top: 0;
        line-height: 1.4;
        flex-shrink: 0;
        order: -1; /* Move text above images in flexbox */
        /* Force scroll visibility for Chrome iOS */
        overflow: scroll;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    
    h1 {
        font-size: 2.2rem;
        letter-spacing: 0.15em;
    }
    
    .subtitle {
        font-size: 1.3rem;
        margin-bottom: 1rem;
    }
    
    .description {
        font-size: 1rem;
        max-width: 90%;
        line-height: 1.5;
    }
    
    .title-panel header {
        padding: 1rem;
    }
    
    /* Move scroll indicator higher on mobile */
    .controls {
        bottom: 1rem;
    }
    
    .scroll-indicator {
        font-size: 0.7rem;
        opacity: 0.5;
    }
    
    /* Swap hint text for mobile */
    .hint-desktop {
        display: none;
    }
    
    .hint-mobile {
        display: inline;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    :root {
        --panel-height: 90vh;
    }
    
    .image-wrapper {
        max-height: 28vh;
    }
    
    .image-wrapper img {
        max-height: 28vh;
        border-radius: 8px;
    }
    
    .panel-text {
        max-height: 15vh;
        font-size: 0.8rem;
        margin-bottom: 0.6rem; /* Space below text, above images */
    }
    
    h1 {
        font-size: 1.8rem;
    }
    
    .subtitle {
        font-size: 1.1rem;
    }
    
    .description {
        font-size: 0.9rem;
    }
}

/* iPad / Tablet specific adjustments */
/* Targets touch devices with tablet-like dimensions (768px - 1366px) */
@media (min-width: 768px) and (max-width: 1366px) and (hover: none) and (pointer: coarse) {
    .panel-images {
        /* Ensure images fit well on tablets */
        max-height: 65vh;
    }
    
    .image-wrapper img {
        max-height: 38vh;
    }
}


