/* lunar.quest — Specimen Display */
/* Colors: #1E1812, #E8DFD0, #3A3028, #5C4B3A, #C4B89E, #A69882, #B8863A, #A05A3C, #5A6B7A */
/* Fonts: Playfair Display, Space Mono, Inter, Lora */

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

:root {
    --void: #1E1812;
    --parchment: #E8DFD0;
    --basalt: #3A3028;
    --shadow: #5C4B3A;
    --dust: #C4B89E;
    --stone: #A69882;
    --amber: #B8863A;
    --rust: #A05A3C;
    --slate: #5A6B7A;
    --gap: 3px;
    --basalt-alt: #3D3029;
    --muted: #8B7D6B;
}

html {
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background: var(--void);
    color: var(--parchment);
    font-family: 'Inter', sans-serif;
    font-weight: 300;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Film grain overlay */
.film-grain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-size: 256px 256px;
}

/* === TRAY (Section) Base === */
.tray {
    min-height: 100vh;
    display: grid;
    gap: var(--gap);
    padding: var(--gap);
    scroll-snap-align: start;
    position: relative;
    background: var(--void);
}

/* === CELL Base === */
.cell {
    background: var(--basalt);
    border-radius: 2px;
    position: relative;
    overflow: hidden;
    padding: clamp(1.5rem, 3vw, 3rem);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

/* === TYPOGRAPHY === */
.tray-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-style: italic;
    font-size: clamp(3rem, 6vw, 5.5rem);
    letter-spacing: -0.03em;
    line-height: 0.95;
    color: var(--parchment);
    text-shadow:
        0 2px 0 rgba(232, 223, 208, 0.3),
        0 4px 8px rgba(30, 24, 18, 0.5),
        0 0 40px rgba(184, 134, 58, 0.1);
    margin-bottom: 0.5em;
}

.specimen-label {
    font-family: 'Space Mono', monospace;
    font-size: clamp(0.6rem, 1vw, 0.75rem);
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--amber);
    display: block;
    margin-bottom: 1rem;
    opacity: 0.8;
}

.subtitle {
    font-family: 'Lora', serif;
    font-style: italic;
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
    color: var(--stone);
    max-width: 30ch;
    line-height: 1.5;
}

.body-text {
    font-family: 'Inter', sans-serif;
    font-weight: 300;
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    color: var(--dust);
    line-height: 1.7;
    max-width: 45ch;
}

.body-text-secondary {
    margin-top: 1.5em;
    color: var(--amber);
    font-style: italic;
    font-family: 'Lora', serif;
}

/* Metadata blocks */
.metadata-block {
    margin-bottom: 1.2rem;
}

.meta-label {
    font-family: 'Space Mono', monospace;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--stone);
    display: block;
    margin-bottom: 0.25rem;
}

.meta-value {
    font-family: 'Space Mono', monospace;
    font-size: clamp(0.8rem, 1.2vw, 1rem);
    color: var(--parchment);
    letter-spacing: 0.05em;
}

/* Journal entries */
.journal-entry {
    font-family: 'Lora', serif;
    font-style: italic;
    font-size: clamp(0.8rem, 1.1vw, 0.95rem);
    color: var(--dust);
    line-height: 1.6;
}

.entry-date {
    font-family: 'Space Mono', monospace;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--amber);
    display: block;
    margin-bottom: 0.75rem;
}

.journal-text {
    font-family: 'Lora', serif;
    font-style: italic;
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    color: var(--parchment);
    line-height: 1.7;
    opacity: 0.9;
}

/* Scroll indicator */
.scroll-indicator {
    position: absolute;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    z-index: 10;
}

.scroll-text {
    font-family: 'Space Mono', monospace;
    font-size: 0.55rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--stone);
    writing-mode: vertical-rl;
}

.scroll-line {
    width: 1px;
    height: 40px;
    background: linear-gradient(to bottom, var(--amber), transparent);
    animation: scrollPulse 2s ease-in-out infinite;
}

@keyframes scrollPulse {
    0%, 100% { opacity: 1; transform: scaleY(1); }
    50% { opacity: 0.3; transform: scaleY(0.6); }
}

/* === SPECIMEN FLIP (hover reveal) === */
.specimen-flip {
    position: absolute;
    inset: 0;
    background: var(--void);
    padding: clamp(1.5rem, 3vw, 3rem);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.cell:hover .specimen-flip {
    opacity: 1;
}

/* === TERRAIN CSS GRADIENTS === */
.terrain-crater {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    margin: 15%;
    background: radial-gradient(ellipse at 40% 35%, #1E1812 0%, #3A3028 40%, #5C4B3A 60%, #C4B89E 100%);
    box-shadow:
        inset 0 -8px 20px rgba(30, 24, 18, 0.8),
        inset 0 4px 15px rgba(232, 223, 208, 0.15),
        0 0 60px rgba(30, 24, 18, 0.6);
}

.terrain-crater-large {
    margin: 10%;
}

.terrain-crater-small {
    margin: 20%;
}

.terrain-crater-final {
    margin: 8%;
    background: radial-gradient(ellipse at 45% 40%, #1E1812 0%, #3A3028 35%, #5C4B3A 55%, #A69882 80%, #C4B89E 100%);
}

.terrain-ridge {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #E8DFD0 0%, #C4B89E 30%, #5C4B3A 60%, #3A3028 80%, #1E1812 100%);
    clip-path: polygon(0% 60%, 20% 30%, 35% 45%, 50% 15%, 65% 40%, 80% 25%, 100% 50%, 100% 100%, 0% 100%);
}

.terrain-ridge-wide {
    clip-path: polygon(0% 70%, 15% 40%, 25% 55%, 40% 20%, 55% 45%, 70% 15%, 85% 35%, 100% 55%, 100% 100%, 0% 100%);
}

.terrain-bulge {
    position: absolute;
    inset: 0;
    margin: 10%;
    border-radius: 50%;
    background: radial-gradient(ellipse at 55% 45%, #E8DFD0 0%, #C4B89E 25%, #A69882 45%, #5C4B3A 70%, #3A3028 100%);
    box-shadow:
        0 8px 30px rgba(30, 24, 18, 0.6),
        inset 0 -5px 15px rgba(30, 24, 18, 0.4);
}

.terrain-topographic {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 30% 40%, transparent 20%, rgba(196, 184, 158, 0.1) 21%, transparent 22%),
        radial-gradient(ellipse at 30% 40%, transparent 35%, rgba(196, 184, 158, 0.1) 36%, transparent 37%),
        radial-gradient(ellipse at 30% 40%, transparent 50%, rgba(196, 184, 158, 0.1) 51%, transparent 52%),
        radial-gradient(ellipse at 30% 40%, transparent 65%, rgba(196, 184, 158, 0.1) 66%, transparent 67%),
        radial-gradient(ellipse at 70% 60%, transparent 15%, rgba(184, 134, 58, 0.08) 16%, transparent 17%),
        radial-gradient(ellipse at 70% 60%, transparent 30%, rgba(184, 134, 58, 0.08) 31%, transparent 32%),
        radial-gradient(ellipse at 70% 60%, transparent 45%, rgba(184, 134, 58, 0.08) 46%, transparent 47%);
}

/* === TRAY 1: HERO === */
.tray-hero {
    grid-template-columns: 1fr 1.618fr 1fr;
    grid-template-rows: 1fr 0.5fr;
}

.tray-hero .cell-title {
    grid-column: 1 / 2;
    grid-row: 1 / 3;
    justify-content: center;
    background: var(--basalt);
}

.tray-hero .cell-crater {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
    background: var(--void);
}

.tray-hero .cell-metadata {
    grid-column: 3 / 4;
    grid-row: 1 / 2;
    background: var(--basalt);
    border-left: 1px solid rgba(184, 134, 58, 0.15);
}

.tray-hero .cell-ridge {
    grid-column: 2 / 4;
    grid-row: 2 / 3;
    background: var(--void);
    min-height: 150px;
}

/* === TRAY 2: SPECIMENS === */
.tray-specimens {
    grid-template-columns: 1fr 1.618fr 1fr;
    grid-template-rows: 1.2fr 0.8fr;
}

.tray-specimens .cell-wide {
    grid-column: 1 / 3;
    grid-row: 1 / 2;
    background: var(--void);
}

.tray-specimens .cell-text {
    grid-column: 3 / 4;
    grid-row: 1 / 2;
    justify-content: center;
    background: var(--basalt);
}

.tray-specimens .cell-small:nth-child(3) {
    grid-column: 1 / 2;
    grid-row: 2 / 3;
    background: var(--void);
}

.tray-specimens .cell-meta-card {
    grid-column: 2 / 4;
    grid-row: 2 / 3;
    background: var(--basalt);
    border-top: 1px solid rgba(184, 134, 58, 0.1);
}

/* === TRAY 3: JOURNAL === */
.tray-journal {
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: auto auto auto;
}

.tray-journal .cell-journal-main {
    grid-column: 1 / 2;
    grid-row: 1 / 4;
    justify-content: center;
    background: var(--basalt);
}

.tray-journal .cell-entry-1 {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
    background: var(--void);
    border-bottom: 1px solid rgba(184, 134, 58, 0.08);
}

.tray-journal .cell-entry-2 {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
    background: var(--void);
}

.tray-journal .cell-crater-sm {
    grid-column: 3 / 4;
    grid-row: 1 / 2;
    background: var(--void);
}

.tray-journal .cell-entry-3 {
    grid-column: 2 / 4;
    grid-row: 3 / 4;
    background: var(--void);
    border-top: 1px solid rgba(184, 134, 58, 0.08);
}

/* Entries with left border accent */
.cell-entry {
    background: #3D3029;
    padding-left: clamp(2rem, 4vw, 4rem);
    border-left: 2px solid rgba(184, 134, 58, 0.2);
}

/* === TRAY 4: ANALYSIS === */
.tray-analysis {
    grid-template-columns: 1fr 1.618fr 1fr;
    grid-template-rows: 0.4fr 1fr;
}

.tray-analysis .cell-analysis-title {
    grid-column: 1 / 3;
    grid-row: 1 / 2;
    background: var(--basalt);
    flex-direction: row;
    align-items: flex-end;
    gap: 2rem;
}

.tray-analysis .cell-topo {
    grid-column: 3 / 4;
    grid-row: 1 / 2;
    background: var(--void);
}

.tray-analysis .cell-data {
    grid-column: 1 / 2;
    grid-row: 2 / 3;
    background: var(--basalt);
    justify-content: center;
}

.tray-analysis .cell-ridge-wide {
    grid-column: 2 / 4;
    grid-row: 2 / 3;
    background: var(--void);
}

/* Data bars */
.data-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.2rem;
}

.data-label {
    font-family: 'Space Mono', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    color: var(--stone);
    min-width: 5ch;
    text-align: right;
}

.data-bar {
    flex: 1;
    height: 3px;
    background: rgba(232, 223, 208, 0.08);
    border-radius: 1px;
    overflow: hidden;
}

.data-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--amber), var(--rust));
    border-radius: 1px;
    width: 0%;
    transition: width 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.data-value {
    font-family: 'Space Mono', monospace;
    font-size: 0.7rem;
    color: var(--parchment);
    min-width: 5ch;
}

/* === TRAY 5: EPILOGUE === */
.tray-epilogue {
    grid-template-columns: 1fr 1.618fr 1fr;
    grid-template-rows: 1fr;
}

.tray-epilogue .cell-epilogue-text {
    grid-column: 1 / 2;
    grid-row: 1 / 2;
    justify-content: center;
    background: var(--basalt);
}

.tray-epilogue .cell-final-crater {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
    background: var(--void);
}

.tray-epilogue .cell-end-meta {
    grid-column: 3 / 4;
    grid-row: 1 / 2;
    background: var(--basalt);
    justify-content: flex-end;
}

.colophon {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(184, 134, 58, 0.15);
}

.colophon-text {
    /* #8B7D6B muted tone */
    font-family: 'Space Mono', monospace;
    font-size: 0.6rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #8B7D6B;
    opacity: 0.6;
}

/* === ANIMATIONS === */
.cell {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.cell.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger children within a tray */
.tray .cell:nth-child(1) { transition-delay: 0s; }
.tray .cell:nth-child(2) { transition-delay: 0.1s; }
.tray .cell:nth-child(3) { transition-delay: 0.2s; }
.tray .cell:nth-child(4) { transition-delay: 0.3s; }
.tray .cell:nth-child(5) { transition-delay: 0.4s; }

/* Cell hover effects */
.cell-terrain:hover .terrain-crater {
    box-shadow:
        inset 0 -8px 20px rgba(30, 24, 18, 0.8),
        inset 0 4px 15px rgba(232, 223, 208, 0.2),
        0 0 80px rgba(184, 134, 58, 0.15);
    transition: box-shadow 0.6s ease;
}

.cell-terrain .terrain-crater,
.cell-terrain .terrain-ridge,
.cell-terrain .terrain-bulge {
    transition: box-shadow 0.6s ease, transform 0.6s ease;
}

.cell-terrain:hover .terrain-bulge {
    transform: scale(1.02);
}

/* Vignette on terrain cells */
.cell-terrain::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 50%, rgba(30, 24, 18, 0.4) 100%);
    pointer-events: none;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .tray {
        grid-template-columns: 1fr !important;
        grid-template-rows: auto !important;
        min-height: auto;
        scroll-snap-align: none;
    }

    .cell {
        grid-column: 1 / -1 !important;
        grid-row: auto !important;
        min-height: 50vh;
    }

    .cell-metadata,
    .cell-meta-card,
    .cell-end-meta {
        min-height: 30vh;
    }

    .cell-terrain {
        min-height: 40vh;
    }

    html {
        scroll-snap-type: none;
    }

    .scroll-indicator {
        display: none;
    }
}

/* Specimen flip on final section - always partially visible */
.specimen-flip-final {
    opacity: 0;
    transition: opacity 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.specimen-flip-final.revealed {
    opacity: 1;
}
