/* ============================================
   scientific.quest - Opulent Empiricism
   ============================================ */

/* CSS Custom Properties */
:root {
    --sapphire: #1B3A5C;
    --ruby: #8B2252;
    --emerald: #1A5C3A;
    --gold: #B8860B;
    --amethyst: #6A3D7B;
    --ivory: #F5F0E8;
    --inkwell: #1C1A17;
    --parchment: #E8DFD0;

    --font-headline: 'Playfair Display', Georgia, serif;
    --font-body: 'Lora', 'Times New Roman', serif;
    --font-accent: 'Cormorant Garamond', Garamond, serif;

    --sidebar-width: 48px;
}

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

/* Leather Texture Background */
html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.72;
    color: var(--parchment);
    background-color: var(--inkwell);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(27, 58, 92, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(139, 34, 82, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(26, 92, 58, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 30% 30%, rgba(184, 134, 11, 0.06) 0%, transparent 20%),
        radial-gradient(circle at 70% 60%, rgba(184, 134, 11, 0.04) 0%, transparent 15%),
        radial-gradient(circle at 50% 50%, rgba(184, 134, 11, 0.05) 0%, transparent 25%),
        radial-gradient(circle at 15% 85%, rgba(232, 223, 208, 0.04) 0%, transparent 10%),
        radial-gradient(circle at 85% 15%, rgba(232, 223, 208, 0.04) 0%, transparent 10%),
        radial-gradient(circle at 40% 70%, rgba(106, 61, 123, 0.03) 0%, transparent 20%),
        radial-gradient(circle at 60% 40%, rgba(106, 61, 123, 0.03) 0%, transparent 20%);
    padding-left: var(--sidebar-width);
    overflow-x: hidden;
}

/* ============================================
   Sidebar Navigation
   ============================================ */
#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    z-index: 100;
    background: rgba(28, 26, 23, 0.85);
    border-right: 1px solid rgba(184, 134, 11, 0.2);
}

.nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(184, 134, 11, 0.3);
    transition: border-color 300ms ease-out, box-shadow 300ms ease-out;
    text-decoration: none;
}

.nav-icon svg {
    width: 16px;
    height: 16px;
    transition: stroke 300ms ease-out;
}

.nav-icon:hover,
.nav-icon.active {
    border-color: var(--gold);
    box-shadow: 0 0 8px rgba(184, 134, 11, 0.3);
}

.nav-icon:hover svg,
.nav-icon.active svg {
    stroke: var(--gold);
}

/* ============================================
   Section Base
   ============================================ */
.section {
    min-height: 100vh;
    padding: 60px 40px 40px;
    position: relative;
}

.section-header {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: clamp(1.5rem, 4vw, 2.4rem);
    letter-spacing: 0.02em;
    color: var(--parchment);
    text-align: center;
    margin-bottom: 40px;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 500ms ease-out, transform 500ms ease-out;
}

.section-header.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================
   Section Dividers
   ============================================ */
.section-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 0;
    position: relative;
}

.section-divider::before,
.section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--gold), transparent);
    max-width: 200px;
}

.rosette {
    width: 24px;
    height: 24px;
    margin: 0 16px;
}

/* ============================================
   Bento Grid System
   ============================================ */
.bento-grid {
    display: grid;
    gap: 12px;
    max-width: 1200px;
    margin: 0 auto;
}

/* Atrium Grid: 3x3 */
.atrium-grid {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: auto;
}

.cell-title-1 {
    grid-column: 1;
    grid-row: 1;
}

.cell-title-2 {
    grid-column: 2;
    grid-row: 1;
}

.cell-title-3 {
    grid-column: 3;
    grid-row: 1;
}

.cell-intro-1 { grid-column: 1; grid-row: 2; }
.cell-intro-2 { grid-column: 2; grid-row: 2; }
.cell-intro-3 { grid-column: 3; grid-row: 2; }
.cell-intro-4 { grid-column: 1; grid-row: 3; }
.cell-intro-5 { grid-column: 2; grid-row: 3; }
.cell-intro-6 { grid-column: 3; grid-row: 3; }

/* Cabinet Grid: 4-column */
.cabinet-grid {
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: minmax(200px, auto);
}

/* Observatory Grid: 2-column with large left */
.observatory-grid {
    grid-template-columns: 2fr 1fr;
    grid-template-rows: auto auto;
}

.observatory-main {
    grid-column: 1;
    grid-row: 1 / 3;
    min-height: 500px;
}

.observatory-note-1 {
    grid-column: 2;
    grid-row: 1;
}

.observatory-note-2 {
    grid-column: 2;
    grid-row: 2;
}

.observatory-note-3 {
    grid-column: 1 / 3;
    grid-row: 3;
}

/* Archive Grid: 3x2 */
.archive-grid {
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: minmax(180px, auto);
}

/* ============================================
   Bento Cells
   ============================================ */
.bento-cell {
    border: 2px solid var(--gold);
    box-shadow: inset 0 0 0 1px rgba(184, 134, 11, 0.15);
    padding: 28px 24px;
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 400ms ease-out, transform 400ms ease-out, box-shadow 300ms ease-out;
}

.bento-cell.revealed {
    opacity: 1;
    transform: translateY(0);
}

.bento-cell:hover {
    box-shadow: inset 0 0 12px rgba(184, 134, 11, 0.15);
}

/* Jewel Tone Backgrounds */
.jewel-sapphire {
    background-color: var(--sapphire);
}

.jewel-ruby {
    background-color: var(--ruby);
}

.jewel-emerald {
    background-color: var(--emerald);
}

.jewel-amethyst {
    background-color: var(--amethyst);
}

.surface-ivory {
    background-color: var(--ivory);
    color: var(--inkwell);
}

/* ============================================
   Brass Corner Brackets
   ============================================ */
.brass-corner {
    position: absolute;
    width: 16px;
    height: 16px;
    opacity: 0;
    transition: opacity 500ms ease-out 200ms;
}

.bento-cell.revealed .brass-corner {
    opacity: 1;
}

.brass-corner.tl {
    top: 4px;
    left: 4px;
    border-top: 2px solid var(--gold);
    border-left: 2px solid var(--gold);
}

.brass-corner.tr {
    top: 4px;
    right: 4px;
    border-top: 2px solid var(--gold);
    border-right: 2px solid var(--gold);
}

.brass-corner.bl {
    bottom: 4px;
    left: 4px;
    border-bottom: 2px solid var(--gold);
    border-left: 2px solid var(--gold);
}

.brass-corner.br {
    bottom: 4px;
    right: 4px;
    border-bottom: 2px solid var(--gold);
    border-right: 2px solid var(--gold);
}

/* ============================================
   Specimen Labels
   ============================================ */
.specimen-label {
    position: absolute;
    top: 8px;
    left: 8px;
    display: flex;
    flex-direction: column;
    padding: 4px 8px;
    background: rgba(28, 26, 23, 0.5);
    border-bottom: 1px solid rgba(184, 134, 11, 0.4);
    z-index: 2;
}

.surface-ivory .specimen-label {
    background: rgba(245, 240, 232, 0.7);
}

.label-category {
    font-family: var(--font-accent);
    font-weight: 300;
    font-size: clamp(0.6rem, 1vw, 0.72rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-variant: small-caps;
    color: var(--gold);
    line-height: 1.3;
}

.label-number {
    font-family: var(--font-accent);
    font-weight: 300;
    font-size: clamp(0.55rem, 0.9vw, 0.65rem);
    letter-spacing: 0.08em;
    color: rgba(184, 134, 11, 0.6);
    line-height: 1.3;
}

/* ============================================
   Typography
   ============================================ */
.site-title-part {
    font-family: var(--font-headline);
    font-weight: 900;
    font-size: clamp(2.8rem, 8vw, 5.5rem);
    letter-spacing: 0em;
    color: var(--parchment);
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding-top: 24px;
    transition: letter-spacing 600ms ease-out;
}

.bento-cell.revealed .site-title-part {
    letter-spacing: 0.04em;
}

.atrium-subtitle {
    font-family: var(--font-accent);
    font-weight: 500;
    font-size: clamp(1rem, 2.2vw, 1.4rem);
    color: var(--parchment);
    text-align: center;
    padding-top: 24px;
    line-height: 1.5;
}

.cell-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.9rem, 1.5vw, 1.05rem);
    line-height: 1.72;
    color: var(--parchment);
    max-width: 38em;
    padding-top: 20px;
}

.cell-text-dark {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.9rem, 1.5vw, 1.05rem);
    line-height: 1.72;
    color: var(--inkwell);
    max-width: 38em;
}

/* Coordinates */
.coordinates {
    display: block;
    font-family: var(--font-accent);
    font-weight: 300;
    font-size: clamp(0.65rem, 1vw, 0.78rem);
    font-variant: small-caps;
    letter-spacing: 0.12em;
    color: rgba(184, 134, 11, 0.4);
    position: absolute;
    bottom: 10px;
    right: 12px;
}

/* ============================================
   Cabinet Drawers
   ============================================ */
.cabinet-drawer {
    cursor: pointer;
    transition: opacity 400ms ease-out, transform 400ms ease-out, box-shadow 300ms ease-out;
}

.cabinet-drawer .drawer-hidden {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 500ms cubic-bezier(0.34, 1.56, 0.64, 1), opacity 300ms ease-out;
}

.cabinet-drawer.drawer-expanded .drawer-hidden {
    max-height: 300px;
    opacity: 1;
}

.cabinet-drawer:not(.drawer-expanded) {
    transition: opacity 400ms ease-out, transform 200ms ease-out, box-shadow 300ms ease-out;
}

.drawer-contracted {
    transform: scale(0.98) !important;
}

.drawer-title {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: clamp(1.2rem, 2.5vw, 1.6rem);
    letter-spacing: 0.02em;
    color: var(--parchment);
    margin-bottom: 8px;
}

.drawer-excerpt {
    font-family: var(--font-accent);
    font-weight: 500;
    font-size: clamp(0.85rem, 1.4vw, 1rem);
    font-variant: small-caps;
    letter-spacing: 0.06em;
    color: var(--parchment);
    opacity: 0.85;
    line-height: 1.5;
}

.drawer-visible {
    padding-top: 20px;
}

.drawer-tall {
    grid-row: span 2;
}

/* ============================================
   Observatory Section
   ============================================ */
.orbit-visualization {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding-top: 20px;
}

.orbit-svg {
    width: 100%;
    max-width: 400px;
    height: auto;
}

.orbit-ring {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 2000ms ease-out;
}

.orbit-ring.animated {
    stroke-dashoffset: 0;
}

.orbit-center {
    filter: drop-shadow(0 0 4px rgba(184, 134, 11, 0.5));
}

.viz-caption {
    font-family: var(--font-accent);
    font-weight: 300;
    font-size: clamp(0.85rem, 1.4vw, 1rem);
    color: var(--parchment);
    text-align: center;
    max-width: 400px;
    margin-top: 20px;
    opacity: 0.8;
}

/* Observation Quote */
.observation-quote {
    padding: 20px 16px 12px;
}

.observation-quote p {
    font-family: var(--font-accent);
    font-weight: 500;
    font-size: clamp(1rem, 1.8vw, 1.2rem);
    line-height: 1.6;
    color: var(--inkwell);
    margin-bottom: 12px;
}

.observation-quote cite {
    font-family: var(--font-accent);
    font-weight: 300;
    font-size: clamp(0.8rem, 1.2vw, 0.9rem);
    color: rgba(28, 26, 23, 0.6);
    font-style: normal;
}

/* Note Content */
.note-title {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: clamp(1rem, 1.8vw, 1.3rem);
    letter-spacing: 0.02em;
    color: var(--inkwell);
    margin-bottom: 12px;
    padding-top: 16px;
}

/* Data Table */
.data-table {
    padding-top: 20px;
}

.data-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.data-label {
    font-family: var(--font-accent);
    font-weight: 300;
    font-size: clamp(0.8rem, 1.2vw, 0.95rem);
    font-variant: small-caps;
    letter-spacing: 0.08em;
    color: var(--parchment);
    min-width: 80px;
}

.data-bar {
    height: 6px;
    background: linear-gradient(to right, var(--gold), rgba(184, 134, 11, 0.5));
    border-radius: 3px;
    flex-shrink: 0;
    transition: width 1200ms ease-out;
}

.data-value {
    font-family: var(--font-accent);
    font-weight: 300;
    font-size: clamp(0.75rem, 1.1vw, 0.88rem);
    color: rgba(232, 223, 208, 0.7);
    white-space: nowrap;
}

/* ============================================
   Archive Section
   ============================================ */
.archive-leather {
    background-image:
        radial-gradient(circle at 30% 40%, rgba(184, 134, 11, 0.12) 0%, transparent 25%),
        radial-gradient(circle at 70% 60%, rgba(184, 134, 11, 0.08) 0%, transparent 20%),
        radial-gradient(circle at 50% 30%, rgba(232, 223, 208, 0.06) 0%, transparent 15%);
    border-radius: 4px;
}

.archive-quote {
    padding: 20px 12px 10px;
}

.archive-quote p {
    font-family: var(--font-accent);
    font-weight: 500;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.65;
    color: var(--parchment);
    margin-bottom: 12px;
}

.archive-quote cite {
    font-family: var(--font-accent);
    font-weight: 300;
    font-size: clamp(0.8rem, 1.2vw, 0.9rem);
    color: rgba(232, 223, 208, 0.6);
    font-style: normal;
}

/* Archive cells blur-to-sharp reveal */
.archive-cell {
    filter: blur(4px);
    transition: opacity 400ms ease-out, transform 400ms ease-out, box-shadow 300ms ease-out, filter 200ms ease-out;
}

.archive-cell.revealed {
    filter: blur(0);
}

/* ============================================
   Colophon Section
   ============================================ */
#colophon {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.colophon-endplate {
    text-align: center;
    max-width: 500px;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 500ms ease-out, transform 500ms ease-out;
}

.colophon-endplate.revealed {
    opacity: 1;
    transform: translateY(0);
}

.decorative-rule {
    width: 200px;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--gold), transparent);
    margin: 24px auto;
}

.colophon-rosette,
.colophon-rosette-bottom {
    display: block;
    margin: 20px auto;
}

.colophon-rosette {
    width: 40px;
    height: 40px;
}

.colophon-rosette-bottom {
    width: 28px;
    height: 28px;
}

.colophon-title {
    font-family: var(--font-accent);
    font-weight: 500;
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-variant: small-caps;
    letter-spacing: 0.12em;
    color: var(--gold);
    margin-bottom: 16px;
}

.colophon-text {
    font-family: var(--font-accent);
    font-weight: 300;
    font-size: clamp(0.85rem, 1.4vw, 1rem);
    font-variant: small-caps;
    letter-spacing: 0.08em;
    color: var(--parchment);
    opacity: 0.7;
    margin-bottom: 8px;
}

.colophon-year {
    font-family: var(--font-accent);
    font-weight: 500;
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
    letter-spacing: 0.2em;
    color: var(--gold);
    margin-top: 16px;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 1024px) {
    .cabinet-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .drawer-tall {
        grid-row: span 1;
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 0px;
    }

    #sidebar {
        display: none;
    }

    .section {
        padding: 40px 20px;
    }

    .atrium-grid {
        grid-template-columns: 1fr;
    }

    .cell-title-1,
    .cell-title-2,
    .cell-title-3,
    .cell-intro-1,
    .cell-intro-2,
    .cell-intro-3,
    .cell-intro-4,
    .cell-intro-5,
    .cell-intro-6 {
        grid-column: 1;
        grid-row: auto;
    }

    .cabinet-grid {
        grid-template-columns: 1fr;
    }

    .observatory-grid {
        grid-template-columns: 1fr;
    }

    .observatory-main {
        grid-column: 1;
        grid-row: 1;
        min-height: 350px;
    }

    .observatory-note-1 {
        grid-column: 1;
        grid-row: 2;
    }

    .observatory-note-2 {
        grid-column: 1;
        grid-row: 3;
    }

    .observatory-note-3 {
        grid-column: 1;
        grid-row: 4;
    }

    .archive-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .site-title-part {
        font-size: clamp(2rem, 12vw, 3.5rem);
    }

    .bento-cell {
        padding: 20px 16px;
    }
}
