/* ========================================
   scientific.quest - Styles
   Botanical Cabinet of Curiosities
   ======================================== */

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

:root {
    --navy-deep: #1B2A4A;
    --metallic-silver: #A0B0C0;
    --brass-gold: #C8A050;
    --specimen-cream: #F5ECD7;
    --botanical-green: #4A7B5A;
    --label-brown: #6B5A45;
    --ink-dark: #0A1428;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Crimson Pro', Georgia, serif;
    font-weight: 400;
    font-size: clamp(16px, 1.5vw, 18px);
    line-height: 1.85;
    color: var(--specimen-cream);
    background: var(--ink-dark);
    overflow-x: hidden;
}

/* --- Typography --- */
h1, h2, h3 {
    font-family: 'Playfair Display', 'Georgia', serif;
    font-weight: 700;
}

.label-classification,
.card-classification,
.card-ref,
.card-note,
.library-card-class,
.chapter-number,
.note-label,
.colophon-year,
.label-date,
.card-footer span {
    font-family: 'Space Mono', 'Courier New', monospace;
    font-weight: 400;
    font-size: 13px;
}

/* ========================================
   THE CABINET (Hero Section)
   ======================================== */
.cabinet {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: linear-gradient(
        165deg,
        var(--navy-deep) 0%,
        #1E2F52 25%,
        var(--navy-deep) 50%,
        #17243F 75%,
        var(--navy-deep) 100%
    );
}

/* Metallic sheen overlay */
.cabinet::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(160, 176, 192, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(200, 160, 80, 0.04) 0%, transparent 50%);
    pointer-events: none;
    z-index: 1;
}

/* Noise texture overlay */
.cabinet::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 2;
}

/* Background layer (z:1) - tech lines */
.cabinet-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.tech-lines-bg {
    width: 100%;
    height: 100%;
}

.tech-line {
    stroke: var(--metallic-silver);
    stroke-width: 0.5;
    opacity: 0.08;
}

.tech-line-h {
    stroke: var(--metallic-silver);
    stroke-width: 0.5;
    opacity: 0.06;
}

.tech-circuit {
    fill: none;
    stroke: var(--metallic-silver);
    stroke-width: 0.5;
    opacity: 0.12;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
}

.tech-node {
    fill: var(--metallic-silver);
    opacity: 0.15;
}

/* Midground layer (z:2) - botanical illustration */
.cabinet-midground {
    position: absolute;
    top: 0;
    right: 5%;
    width: 35%;
    height: 100%;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
}

.botanical-specimen {
    width: 100%;
    max-width: 400px;
    height: auto;
}

.botanical-draw path,
.botanical-draw line,
.botanical-draw circle {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
}

/* Foreground layer (z:3) - content */
.cabinet-foreground {
    position: relative;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 1100px;
    padding: 60px 40px;
    min-height: 100vh;
}

/* Specimen Labels */
.specimen-label {
    background: linear-gradient(
        145deg,
        var(--specimen-cream) 0%,
        #EDE0C8 40%,
        #E8D8B8 100%
    );
    padding: 20px 28px;
    border-radius: 3px;
    position: absolute;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.15),
        2px 2px 0 rgba(107, 90, 69, 0.08),
        inset 0 0 30px rgba(107, 90, 69, 0.05);
    transform: perspective(800px) rotateX(1deg);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

.specimen-label::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 3px;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    pointer-events: none;
}

/* Corner curl effect */
.specimen-label::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, transparent 50%, rgba(107, 90, 69, 0.1) 50%);
    border-radius: 0 0 3px 0;
}

.specimen-label:hover {
    transform: perspective(800px) rotateX(0deg) scale(1.02) translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

.specimen-label-1 {
    top: 18%;
    left: 8%;
}

.specimen-label-2 {
    top: 35%;
    left: 5%;
}

.specimen-label-3 {
    bottom: 22%;
    left: 10%;
}

.label-classification {
    color: var(--metallic-silver);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 10px;
    opacity: 0.7;
}

.label-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-style: italic;
    color: var(--label-brown);
    font-size: clamp(16px, 2vw, 22px);
}

.label-detail {
    font-family: 'Crimson Pro', serif;
    color: var(--label-brown);
    font-size: 14px;
    opacity: 0.8;
    line-height: 1.5;
}

.label-date {
    color: var(--botanical-green);
    opacity: 0.6;
    font-size: 11px;
    letter-spacing: 1px;
    margin-top: 4px;
}

/* Wordmark */
.wordmark {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(36px, 5.5vw, 72px);
    color: var(--specimen-cream);
    text-align: center;
    letter-spacing: 0.02em;
    opacity: 0;
    text-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
    margin-top: auto;
    margin-bottom: 10px;
}

.wordmark-subtitle {
    font-family: 'Space Mono', monospace;
    font-size: 13px;
    color: var(--metallic-silver);
    letter-spacing: 4px;
    text-transform: uppercase;
    text-align: center;
    opacity: 0;
    margin-bottom: auto;
}

/* Tech connecting lines overlay */
.tech-lines-connect {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 4;
    pointer-events: none;
}

.connect-line {
    fill: none;
    stroke: var(--metallic-silver);
    stroke-width: 0.5;
    opacity: 0.2;
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    filter: drop-shadow(0 0 2px rgba(160, 176, 192, 0.3));
}

.connect-node {
    fill: var(--brass-gold);
    opacity: 0.4;
}

/* ========================================
   EXPEDITION CHAPTERS
   ======================================== */
.expeditions {
    position: relative;
    width: 100%;
    padding: 120px 0;
    overflow: hidden;
    background: linear-gradient(
        180deg,
        var(--navy-deep) 0%,
        #1A2845 50%,
        var(--navy-deep) 100%
    );
}

.expeditions-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.tech-lines-exp {
    width: 100%;
    height: 100%;
}

.expeditions-midground {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

.botanical-mid {
    position: absolute;
    width: 200px;
    height: 300px;
}

.botanical-mid-1 {
    top: 5%;
    right: 8%;
}

.botanical-mid-2 {
    bottom: 10%;
    left: 5%;
}

.expeditions-foreground {
    position: relative;
    z-index: 3;
    max-width: 900px;
    margin: 0 auto;
    padding: 0 40px;
    display: flex;
    flex-direction: column;
    gap: 80px;
}

/* Chapter layout */
.chapter {
    opacity: 0;
    transform: translateY(30px);
}

.chapter-header {
    margin-bottom: 24px;
}

.chapter-number {
    display: block;
    color: var(--brass-gold);
    text-transform: uppercase;
    letter-spacing: 3px;
    font-size: 12px;
    margin-bottom: 8px;
}

.chapter-title {
    font-size: clamp(28px, 4.5vw, 56px);
    color: var(--specimen-cream);
    line-height: 1.15;
}

/* Specimen Cards */
.specimen-card {
    background: linear-gradient(
        145deg,
        var(--specimen-cream) 0%,
        #EDE0C8 40%,
        #E8D8B8 100%
    );
    padding: 32px 36px;
    border-radius: 3px;
    position: relative;
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.15),
        2px 2px 0 rgba(107, 90, 69, 0.08),
        inset 0 0 30px rgba(107, 90, 69, 0.05);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    transform-style: preserve-3d;
}

/* Noise texture for cards */
.specimen-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 3px;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    pointer-events: none;
}

/* Corner curl */
.specimen-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, transparent 50%, rgba(107, 90, 69, 0.1) 50%);
    border-radius: 0 0 3px 0;
}

.specimen-card:hover {
    transform: scale(1.02) translateY(-4px) translateZ(10px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(107, 90, 69, 0.15);
}

.card-classification {
    color: var(--label-brown);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 11px;
    opacity: 0.7;
}

.card-ref {
    color: var(--botanical-green);
    font-size: 11px;
    opacity: 0.6;
}

.card-body {
    font-family: 'Crimson Pro', serif;
    color: var(--label-brown);
    font-size: clamp(16px, 1.5vw, 18px);
    line-height: 1.85;
    margin-bottom: 20px;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid rgba(107, 90, 69, 0.15);
}

.card-note {
    color: var(--label-brown);
    opacity: 0.5;
    font-size: 11px;
    letter-spacing: 1px;
}

.card-specimen-icon {
    width: 40px;
    height: 40px;
}

/* ========================================
   THE LIBRARY
   ======================================== */
.library {
    position: relative;
    width: 100%;
    padding: 120px 40px;
    overflow: hidden;
    background: linear-gradient(
        180deg,
        var(--navy-deep) 0%,
        #172340 50%,
        var(--navy-deep) 100%
    );
}

/* Subtle metallic sheen */
.library::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 50% 30%, rgba(200, 160, 80, 0.03) 0%, transparent 60%);
    pointer-events: none;
}

.library-header {
    text-align: center;
    margin-bottom: 80px;
    position: relative;
    z-index: 2;
}

.library-title {
    font-size: clamp(28px, 4vw, 48px);
    color: var(--specimen-cream);
    margin-bottom: 12px;
}

.library-subtitle {
    font-family: 'Space Mono', monospace;
    font-size: 13px;
    color: var(--metallic-silver);
    letter-spacing: 3px;
    text-transform: uppercase;
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 32px;
    max-width: 1100px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

/* Library Cards */
.library-card {
    background: linear-gradient(
        145deg,
        var(--specimen-cream) 0%,
        #EDE0C8 40%,
        #E8D8B8 100%
    );
    padding: 28px 24px;
    border-radius: 3px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    position: relative;
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.15),
        2px 2px 0 rgba(107, 90, 69, 0.08),
        inset 0 0 30px rgba(107, 90, 69, 0.05);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    transform-style: preserve-3d;
    opacity: 0;
    transform: translateY(20px);
}

/* Noise overlay */
.library-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 3px;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    pointer-events: none;
}

/* Corner curl */
.library-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, transparent 50%, rgba(107, 90, 69, 0.1) 50%);
    border-radius: 0 0 3px 0;
}

.library-card:hover {
    transform: scale(1.02) translateY(-4px) translateZ(10px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

.library-card-illustration {
    width: 80px;
    height: 80px;
    margin-bottom: 8px;
}

.library-card-class {
    font-family: 'Space Mono', monospace;
    font-size: 10px;
    color: var(--metallic-silver);
    letter-spacing: 2.5px;
    text-transform: uppercase;
    opacity: 0.6;
}

.library-card-name {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-style: italic;
    color: var(--label-brown);
    font-size: clamp(16px, 1.8vw, 20px);
}

.library-card-desc {
    font-family: 'Crimson Pro', serif;
    color: var(--label-brown);
    font-size: 14px;
    opacity: 0.75;
    line-height: 1.5;
}

/* Library wires */
.library-wires {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.wire-line {
    fill: none;
    stroke: var(--metallic-silver);
    stroke-width: 0.5;
    opacity: 0.1;
    filter: drop-shadow(0 0 2px rgba(160, 176, 192, 0.3));
}

.wire-node {
    fill: var(--brass-gold);
    opacity: 0.3;
}

/* ========================================
   OBSERVATORY FOOTER
   ======================================== */
.observatory {
    position: relative;
    width: 100%;
    padding: 100px 40px 80px;
    background: var(--ink-dark);
    overflow: hidden;
}

.observatory-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.tech-lines-footer {
    width: 100%;
    height: 100%;
}

.observatory-content {
    position: relative;
    z-index: 2;
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 60px;
}

.observatory-note {
    background: linear-gradient(
        145deg,
        var(--specimen-cream) 0%,
        #EDE0C8 40%,
        #E8D8B8 100%
    );
    padding: 32px 36px;
    border-radius: 3px;
    position: relative;
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.15),
        inset 0 0 30px rgba(107, 90, 69, 0.05);
    text-align: center;
}

/* Noise overlay */
.observatory-note::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 3px;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    pointer-events: none;
}

.note-label {
    display: block;
    font-family: 'Space Mono', monospace;
    font-size: 10px;
    color: var(--botanical-green);
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 16px;
    opacity: 0.7;
}

.note-text {
    font-family: 'Crimson Pro', serif;
    color: var(--label-brown);
    font-size: clamp(16px, 1.5vw, 18px);
    line-height: 1.85;
    font-style: italic;
}

.observatory-colophon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.colophon-mark {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    color: var(--specimen-cream);
    font-size: 20px;
    opacity: 0.6;
}

.colophon-detail {
    font-family: 'Space Mono', monospace;
    font-size: 11px;
    color: var(--metallic-silver);
    letter-spacing: 2px;
    text-transform: uppercase;
    opacity: 0.4;
}

.colophon-year {
    font-size: 11px;
    color: var(--brass-gold);
    letter-spacing: 2px;
    opacity: 0.4;
}

/* ========================================
   ANIMATIONS - Initial states
   ======================================== */
.tech-circuit,
.connect-line {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
}

.botanical-draw path,
.botanical-draw line {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
}

/* Animated states */
.cabinet.is-loaded .tech-circuit {
    animation: drawLine 1.5s ease forwards;
}

.cabinet.is-loaded .connect-line {
    animation: drawLine 1.5s ease 0.5s forwards;
}

.cabinet.is-loaded .botanical-draw path,
.cabinet.is-loaded .botanical-draw line {
    animation: drawBotanical 2.5s ease forwards;
}

.cabinet.is-loaded .specimen-label {
    animation: fadeInLabel 0.6s ease forwards;
}

.cabinet.is-loaded .specimen-label-1 {
    animation-delay: 0.2s;
}

.cabinet.is-loaded .specimen-label-2 {
    animation-delay: 0.4s;
}

.cabinet.is-loaded .specimen-label-3 {
    animation-delay: 0.6s;
}

.cabinet.is-loaded .wordmark {
    animation: fadeInWordmark 0.8s ease 0.8s forwards;
}

.cabinet.is-loaded .wordmark-subtitle {
    animation: fadeInWordmark 0.8s ease 1.0s forwards;
}

/* Chapter reveal */
.chapter.is-visible {
    animation: fadeInChapter 0.7s ease forwards;
}

/* Library card reveal */
.library-card.is-visible {
    animation: fadeInCard 0.6s ease forwards;
}

/* ========================================
   KEYFRAMES
   ======================================== */
@keyframes drawLine {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes drawBotanical {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes fadeInLabel {
    from {
        opacity: 0;
        transform: perspective(800px) rotateX(3deg) translateY(15px);
    }
    to {
        opacity: 1;
        transform: perspective(800px) rotateX(1deg) translateY(0);
    }
}

@keyframes fadeInWordmark {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInChapter {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInCard {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 900px) {
    .library-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 24px;
    }

    .specimen-label-1 {
        top: 10%;
        left: 5%;
    }

    .specimen-label-2 {
        top: 28%;
        left: 3%;
    }

    .specimen-label-3 {
        bottom: 25%;
        left: 5%;
    }

    .cabinet-midground {
        right: -5%;
        width: 45%;
        opacity: 0.35;
    }
}

@media (max-width: 600px) {
    .library-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .cabinet-foreground {
        padding: 40px 20px;
    }

    .specimen-label {
        position: relative;
        top: auto !important;
        left: auto !important;
        bottom: auto !important;
        right: auto !important;
        margin-bottom: 16px;
    }

    .cabinet-midground {
        display: none;
    }

    .expeditions-foreground {
        padding: 0 20px;
        gap: 50px;
    }

    .specimen-card {
        padding: 24px 20px;
    }

    .library {
        padding: 80px 20px;
    }

    .observatory {
        padding: 60px 20px 50px;
    }

    .observatory-note {
        padding: 24px 20px;
    }

    .botanical-mid {
        display: none;
    }
}
