:root {
    --soft-white: #faf9f6;      /* Creamy Document */
    --earth-beige: #d8d2c2;     /* Desk Surface */
    --charcoal-grey: #333333;   /* Main Text/Accents */
    --charcoal-light: #444444;  /* Sidebar Items */
    --deep-blue: #0d3b66;       /* Blueprint Accents */
    --warning-red: #8b0000;     /* Stamp Red */
    --border: 1px solid rgba(0,0,0,0.1);
}

* { box-sizing: border-box; }

body {
    background-color: var(--earth-beige);
    color: var(--charcoal-grey);
    font-family: "Courier New", Courier, monospace;
    margin: 0;
    overflow: hidden;
}

.desktop { display: flex; height: 100vh; padding: 0; }

/* --- SIDEBAR --- */
.sidebar-folder {
    width: 250px;
    background: #c7c1b1; /* A slightly darker shade of the beige */
    border-right: 1px solid rgba(0,0,0,0.15);
    padding: 60px 20px 20px 20px;
    display: flex;
    flex-direction: column;
    position: relative;
    flex-shrink: 0;
}

.folder-tab {
    background: #b7b1a1;
    padding: 5px 15px;
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: 0.7rem;
    font-weight: bold;
    color: var(--charcoal-grey);
}

.nav-item {
    padding: 12px 15px;
    margin-bottom: 5px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--charcoal-light);
    border-left: 4px solid transparent;
    transition: 0.3s;
}

.nav-item:hover { background: rgba(0,0,0,0.05); }

.nav-item.active {
    background: var(--soft-white);
    color: var(--deep-blue);
    border-left: 4px solid var(--deep-blue);
    font-weight: bold;
}

.sidebar-status {
    margin-top: auto;
    font-size: 0.75rem;
    padding-top: 20px;
    color: var(--charcoal-light);
    border-top: 1px dashed rgba(0,0,0,0.2);
}

/* --- MAIN DOCUMENT --- */
.paper-stage {
    flex-grow: 1;
    background: var(--soft-white);
    margin: 30px;
    padding: 60px;
    overflow-y: auto;
    box-shadow: 5px 5px 25px rgba(0,0,0,0.1);
    border-radius: 4px;
    position: relative;
}

.document-header { border-bottom: 2px solid var(--charcoal-grey); margin-bottom: 40px; padding-bottom: 20px; }
h1 { font-size: 1.8rem; margin: 10px 0; letter-spacing: 2px; }

.doc-section { display: none; animation: fadeIn 0.4s ease; }
.doc-section.active { display: block; }

.modern-card {
    background: white;
    border: var(--border);
    border-radius: 8px;
    padding: 30px;
    margin-top: 20px;
}

.blueprint-box {
    background: var(--deep-blue);
    color: #e0e0e0;
    padding: 40px;
    margin: 20px 0;
    border-radius: 4px;
    text-align: center;
    border: 1px dashed rgba(255,255,255,0.3);
}

.metadata-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 20px; }
.meta-item { border: var(--border); padding: 10px; font-size: 0.8rem; background: #fafafa; }

.confidential-seal {
    position: absolute; top: 40px; right: 40px;
    border: 2px solid var(--warning-red); color: var(--warning-red);
    padding: 5px 10px; transform: rotate(5deg); font-weight: bold;
}

/* --- MOBILE --- */
@media (max-width: 768px) {
    body { overflow-y: auto; }
    .desktop { flex-direction: column; height: auto; }
    .sidebar-folder { width: 100%; padding: 40px 15px; }
    #sidebar-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
    .paper-stage { margin: 10px; padding: 30px 20px; }
    .metadata-grid { grid-template-columns: 1fr; }
}

/* --- UTILS --- */
#progress-container { width: 100%; height: 3px; position: fixed; top: 0; z-index: 1000; }
#progress-bar { width: 0%; height: 100%; background: var(--deep-blue); transition: width 0.3s; }
.blink { animation: blinker 1.5s linear infinite; }
@keyframes blinker { 50% { opacity: 0; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* --- PHOTO GRID SYSTEM --- */

.photo-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-top: 30px;
}

.photo-card {
    background: #fff;
    border: 1px solid var(--border-color);
    padding: 10px;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.05);
    transition: transform 0.2s ease;
    border-radius: 10px;
}

.photo-card:hover {
    transform: translateY(-5px);
    border-color: var(--deep-blue);
}

.img-placeholder {
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #e2dfd8; /* Earthy beige placeholder */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: bold;
    color: var(--charcoal-light);
    border: 1px dashed rgba(0,0,0,0.1);
    text-align: center;
}

.photo-label {
    margin-top: 10px;
    font-size: 0.75rem;
    text-transform: uppercase;
    text-align: center;
    color: var(--charcoal-grey);
    border-top: 1px solid #eee;
    padding-top: 5px;
}

/* --- MOBILE GRID OVERRIDES --- */
@media (max-width: 768px) {
    
    /* Photo Grid: Force 3 Columns */
    .photo-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px; /* Tighter gap for small screens */
    }

    /* Video Grid: Force 2 Columns */
    .video-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px;
        margin: 15px 0;
    }

    /* Adjusting Card Padding & Labels for tight fit */
    .photo-card, .video-grid .video-container {
        padding: 5px; /* Less internal space */
    }

    .photo-label {
        font-size: 0.6rem; /* Smaller text so it fits under tiny images */
        line-height: 1.1;
        margin-top: 5px;
    }

    /* Ensure the 16:9 ratio remains clean */
    .video-frame {
        border-radius: 4px;
    }
}

/* Container for the image to handle spacing */
.img-container {
    width: 100%;
    margin: 20px 0;
    text-align: center; /* Centers the image if it's smaller than the container */
}

/* The dynamic image rule */
.report-img {
    max-width: 100%;    /* Image will never be wider than its parent card */
    height: auto;       /* Maintains aspect ratio so it doesn't look stretched */
    display: block;
    margin: 0 auto;     /* Horizontal centering */
    
    /* Optional: Adds to the vintage document feel */
    border: 1px solid var(--border-color);
    padding: 5px;
    background-color: #fff;
}

/* Enhancement for the Photo Grid images specifically */
.photo-card img {
    width: 85%;        /* Force grid images to fill their card slots */
    height: auto;
    aspect-ratio: 1 / 1; /* Matches your previous placeholder look */
    object-fit: cover;   /* Ensures the image fills the space without distortion */
    display: block;
    margin: 0 auto;
    border-radius: 10px;
}

.photo-card img, .report-img {
    cursor: pointer;
    transition: filter 0.2s ease, transform 0.2s ease;
}

.photo-card img:hover, .report-img:hover {
    filter: brightness(0.9);
    transform: scale(1.02);
}

/* Optional: Hint for users in the overlay */
#overlay-caption::after {
    content: " [ Use ← → to Navigate ]";
    font-size: 0.7rem;
    opacity: 0.6;
    display: block;
    margin-top: 5px;
}

/* --- ZOOM OVERLAY --- */
.overlay {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 2000;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color:rgb(215, 209, 193);
    backdrop-filter: blur(8px);
    cursor: zoom-out;
    animation: fadeIn 0.3s;
}

.overlay-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 85%;
    border: 3px solid var(--soft-white);
    box-shadow: 0 0 50px rgba(0,0,0,0.5);
}

#overlay-caption {
    margin: auto;
    display: block;
    width: 80%;
    text-align: center;
    color: var(--soft-white);
    padding: 20px 0;
    font-size: 1rem;
    letter-spacing: 2px;
}

.close-overlay {
    position: absolute;
    top: 30px;
    right: 50px;
    color: var(--soft-white);
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}

/* Make images look clickable */
.report-img, .photo-card img {
    cursor: zoom-in;
}

#overlay-caption {
    margin-top: 20px;
    padding: 10px 20px;
    color: var(--soft-white);
    background: rgba(0, 0, 0, 0.4); /* Subtle dark backing for readability */
    font-family: var(--font-mono);
    font-size: 0.9rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    border-left: 3px solid var(--deep-blue);
    display: inline-block;
    align-self: center;
}

/* --- 3D VIEWPORT STYLING --- */

.model-viewport {
    width: 100%;
    height: 450px; /* Adjust height based on preference */
    background-color: var(--charcoal-grey); /* Blueprint background */
    border: 1px solid var(--charcoal-grey);
    border-radius: 20px;
    margin: 20px 0;
    position: relative;
    overflow: hidden;
}

model-viewer {
    width: 100%;
    height: 100%;
    --poster-color: --charcoal-grey;
}

/* Customizing the interaction prompt */
model-viewer::part(default-progress-bar) {
    background-color: var(--soft-white);
}

/* Ensure the viewport works on mobile */
@media (max-width: 768px) {
    .model-viewport {
        height: 300px;
    }
}

/* --- VIDEO OBSERVATION SYSTEM --- */

.video-container {
    /* Set your desired width here (e.g., 70% or 600px) */
    width: 70%; 
    max-width: 800px; 
    
    /* Centers the container horizontally */
    margin: 30px auto; 
    
    background: #000;
    border: 1px solid var(--charcoal-grey);
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.video-frame {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* Keeps 16:9 ratio within the smaller container */
    height: 0;
    overflow: hidden;
    background: #000;
    border-radius: 6px; /* Slightly smaller radius for the inner frame */
}

.video-frame video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain; 
}

/* Ensure it expands back to full width on small mobile screens */
@media (max-width: 768px) {
    .video-container {
        width: 95%;
        margin: 20px auto;
    }
}

/* --- VIDEO GRID SYSTEM --- */

.video-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Two equal columns */
    gap: 20px;                      /* Space between the two videos */
    width: 100%;
    margin: 30px 0;
}

.video-grid .video-container {
    width: 100%;      /* Let the grid control the width */
    max-width: none;  /* Remove any previous restrictions */
    margin: 0;        /* Grid handles the spacing */
    background: #000;
    padding: 8px;
    border-radius: 8px;
}

.video-frame {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* Maintains 16:9 ratio */
    height: 0;
    overflow: hidden;
    border-radius: 4px;
}

.video-frame video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Mobile View: Stack them vertically */
@media (max-width: 900px) {
    .video-grid {
        grid-template-columns: 1fr; /* Single column on tablets/phones */
    }
}


/* Eye-piece / Viewfinder Details */
.viewfinder-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Allows clicking the video through the overlay */
    padding: 20px;
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.6);
    text-shadow: 1px 1px 2px #000;
}

.rec-dot {
    color: var(--warning-red);
    animation: blinker 1s linear infinite;
}

/* Ensure caption matches your photo labels */
.video-container .photo-label {
    margin-top: 15px;
    color: white;
    text-align: center;
    border-top: 1px dashed rgba(0,0,0,0.1);
    padding-top: 10px;
}

.toc-box {
    background: var(--bg-desk);
    border: 1px dashed var(--charcoal-grey);
    padding: 20px;
    margin: 20px 0 40px 0;
    border-radius: 4px;
}

.toc-title {
    font-size: 0.7rem;
    font-weight: bold;
    color: var(--deep-blue);
    margin-bottom: 10px;
    letter-spacing: 1px;
}

#help-toc {
    list-style: none;
    padding: 0;
    margin: 0;
}

#help-toc li {
    margin-bottom: 8px;
}

#help-toc a {
    text-decoration: none;
    color: var(--charcoal-grey);
    font-size: 0.9rem;
    transition: 0.2s;
    display: block;
}

#help-toc a:hover {
    color: var(--deep-blue);
    padding-left: 10px; /* Slight slide effect on hover */
}

#help-toc a::before {
    content: "DIR_";
    font-size: 0.7rem;
    opacity: 0.5;
    margin-right: 8px;
}

/* This forces the card to take up all available grid columns */
.photo-card.span-full {
    grid-column: 1 / -1; 
    width: 100%;
}

/* Optional: Adjust the image inside the spanning card */
.photo-card.span-full img {
    aspect-ratio: 21 / 9; /* Creates a cinematic panoramic look */
    object-fit: cover;    /* Ensures it fills the width without distortion */
    max-height: 500px;    /* Prevents the image from becoming vertically huge */
}

/* Mobile Fix: Ensure it still looks good on small screens */
@media (max-width: 768px) {
    .photo-card.span-full img {
        aspect-ratio: 16 / 9; /* Standard widescreen for mobile */
    }
}

.rotate-90 {
  /* Rotates the image 90 degrees clockwise */
  transform: rotate(90deg);
}


/* --- SIDEBAR CREED STYLING --- */
.sidebar-creed {
    margin-top: auto; /* Pushes it to the bottom if sidebar is a flexbox */
    padding: 15px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 10px;
}

.creed-sanskrit {
    font-size: 0.95rem;
    color: var(--deep-blue);
    line-height: 1.6;
    letter-spacing: 0.5px;
    opacity: 0.9;
}

.creed-translit {
    font-size: 0.75rem;
    color: var(--charcoal-grey); /* Or a muted grey */
    font-style: italic;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.creed-english {
    font-size: 0.75rem;
    color: var(--deep-blue);
    line-height: 1.4;
    opacity: 0.7;
    border-left: 2px solid var(--deep-blue);
    padding-left: 10px;
}

/* Ensure the sidebar container is a flexbox to use margin-top: auto */
.sidebar {
    display: flex;
    flex-direction: column;
    height: 100vh;
}