/* =====================================================
   monopole.studio - Surreal Techno-Botanical Styles
   Palette: Midnight-Blue with Botanical-Green Accents
   Typography: Commissioner (display/body) + Source Serif 4 (captions)
   ===================================================== */

/* --- CSS Custom Properties --- */
:root {
    --bg-primary: #0b1628;         /* Midnight Herbarium */
    --bg-secondary: #132240;       /* Specimen Dark */
    --text-primary: #d4cbb8;       /* Pressed Vellum */
    --text-secondary: #9a917e;     /* Faded Ink */
    --accent-primary: #3d7a4a;     /* Circuit Chlorophyll */
    --accent-secondary: #6b8f63;   /* Lichen Notation */
    --accent-tertiary: #c27d45;    /* Copper Filament */
    --highlight: #5ecfb0;          /* Bioluminescent Pulse */
    --surface: #1a2d4a;            /* Aged Plate */
    --error: #c4584a;              /* Oxidized Copper */
    --visited: #7a6b8f;            /* Pressed Violet */
    --annotation-line: #4a6741;    /* Annotation line color */
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: clamp(0.95rem, 1.2vw, 1.15rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- SVG Defs (hidden) --- */
.svg-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* --- Paper Grain Overlay (fixed pseudo-element) --- */
.paper-grain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    filter: url(#paperGrain);
    opacity: 0.5;
}

/* --- Background Watermark Pattern --- */
.bg-watermark {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* --- Ruling Lines --- */
.ruling-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4500px;
    pointer-events: none;
    z-index: 0;
}

.ruling-svg {
    width: 100%;
    height: 100%;
}

/* --- Vignette Overlay --- */
.vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    background: radial-gradient(ellipse at 50% 30%, transparent 40%, rgba(11, 22, 40, 0.4) 100%);
}

/* --- Typography --- */
h1, h2, h3 {
    font-family: 'Commissioner', sans-serif;
    color: var(--text-primary);
    letter-spacing: 0.03em;
    line-height: 1.15;
}

h1.site-title {
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 4.2rem);
    letter-spacing: 0.03em;
}

h2.section-heading {
    font-weight: 600;
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    letter-spacing: 0.03em;
    margin-bottom: 1.5rem;
}

h3.specimen-name {
    font-weight: 500;
    font-size: clamp(1.1rem, 2vw, 1.5rem);
    letter-spacing: 0.02em;
    margin-bottom: 0.75rem;
    color: var(--accent-tertiary);
}

.body-text {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: clamp(0.95rem, 1.2vw, 1.15rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    max-width: 62ch;
    margin-bottom: 1.25rem;
    color: var(--text-primary);
}

.caption-text {
    font-family: 'Source Serif 4', 'Source Serif Pro', Georgia, serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(0.7rem, 0.9vw, 0.85rem);
    letter-spacing: 0.02em;
    color: var(--accent-secondary);
    display: block;
    margin-top: 0.5rem;
}

.site-descriptor {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-style: italic;
    font-size: clamp(0.9rem, 1.3vw, 1.1rem);
    color: var(--text-secondary);
    letter-spacing: 0.01em;
    line-height: 1.6;
    max-width: 30ch;
}

/* =====================================================
   HERBARIUM CANVAS (Opening Section)
   ===================================================== */
.herbarium-canvas {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    overflow: hidden;
    z-index: 2;
}

.herbarium-label {
    position: absolute;
    left: 8%;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    opacity: 0;
}

.herbarium-label .site-title {
    margin-bottom: 1rem;
    transform: translateY(12px);
}

.herbarium-label .site-descriptor {
    opacity: 0;
    transform: translateY(8px);
}

/* Fade-in animations for label */
.herbarium-label.visible {
    animation: fadeInLabel 800ms ease-out 500ms forwards;
}

.herbarium-label.visible .site-title {
    animation: fadeUpTitle 800ms ease-out 500ms forwards;
}

.herbarium-label.visible .site-descriptor {
    animation: fadeUpDesc 800ms ease-out 900ms forwards;
}

@keyframes fadeInLabel {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

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

/* Illustration container */
.herbarium-illustration {
    position: absolute;
    right: 5%;
    top: 50%;
    transform: translateY(-50%);
    width: clamp(300px, 45vw, 560px);
    height: auto;
    z-index: 2;
}

.specimen-svg {
    width: 100%;
    height: auto;
}

/* SVG path drawing animation */
.draw-path {
    stroke-dasharray: var(--path-length, 1000);
    stroke-dashoffset: var(--path-length, 1000);
    will-change: stroke-dashoffset;
}

.draw-path.animate {
    transition: stroke-dashoffset var(--draw-duration, 2000ms) var(--draw-easing, ease-in-out) var(--draw-delay, 0ms);
    stroke-dashoffset: 0;
}

.draw-path.drawn {
    stroke-dashoffset: 0;
    will-change: auto;
}

/* Junction node animations */
.junction-node {
    opacity: 0;
    transform-origin: center;
    transform: scale(0.6);
}

.junction-node.pulse-in {
    animation: nodeAppear 300ms ease-out forwards, pulseGlow 3s ease-in-out 600ms infinite;
}

@keyframes nodeAppear {
    from {
        opacity: 0;
        transform: scale(0.6);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulseGlow {
    0%, 100% {
        opacity: 0.6;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.3);
    }
}

/* =====================================================
   DRIFT ZONE (Scrollable Content)
   ===================================================== */
.drift-zone {
    position: relative;
    z-index: 2;
    padding-bottom: 15vh;
}

/* Annotation lines SVG */
.annotation-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.annotation-line {
    stroke-dasharray: var(--line-length, 500);
    stroke-dashoffset: var(--line-length, 500);
}

.annotation-line.draw {
    transition: stroke-dashoffset 1200ms cubic-bezier(0.23, 1, 0.32, 1) 200ms;
    stroke-dashoffset: 0;
}

/* =====================================================
   SPECIMEN CLUSTERS
   ===================================================== */
.specimen-cluster {
    position: relative;
    max-width: 55%;
    padding: 2.5rem 2rem;
    margin-top: 8vh;
    margin-bottom: 3vh;
    opacity: 0;
    z-index: 2;
}

/* Varied spacing between clusters */
.cluster-1 { margin-top: 12vh; }
.cluster-2 { margin-top: 15vh; }
.cluster-3 { margin-top: 8vh; }
.cluster-4 { margin-top: 13vh; }
.cluster-5 { margin-top: 10vh; }

/* Cluster background (aged plate / tea stain) */
.cluster-bg {
    position: absolute;
    top: -10px;
    left: -15px;
    right: -15px;
    bottom: -10px;
    background-color: var(--surface);
    opacity: 0.15;
    border-radius: 4px;
    z-index: -1;
    filter: blur(1px);
}

/* Reveal animations */
.specimen-cluster.reveal-up {
    animation: revealUp 700ms cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

.specimen-cluster.reveal-left {
    animation: revealLeft 700ms cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

.specimen-cluster.reveal-right {
    animation: revealRight 700ms cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

@keyframes revealUp {
    from {
        opacity: 0;
        transform: translateY(30px) rotate(var(--cluster-rotation, 0deg));
    }
    to {
        opacity: 1;
        transform: translateY(0) rotate(var(--cluster-rotation, 0deg));
    }
}

@keyframes revealLeft {
    from {
        opacity: 0;
        transform: translateX(-30px) rotate(var(--cluster-rotation, 0deg));
    }
    to {
        opacity: 1;
        transform: translateX(0) rotate(var(--cluster-rotation, 0deg));
    }
}

@keyframes revealRight {
    from {
        opacity: 0;
        transform: translateX(30px) rotate(var(--cluster-rotation, 0deg));
    }
    to {
        opacity: 1;
        transform: translateX(0) rotate(var(--cluster-rotation, 0deg));
    }
}

/* Marginalia glyphs */
.marginalia {
    position: absolute;
    left: -35px;
    top: 50%;
    transform: translateY(-50%) rotate(90deg);
    width: 20px;
    height: 60px;
    opacity: 0.6;
}

.marginalia-icon {
    width: 100%;
    height: 100%;
}

/* Specimen entries */
.specimen-entry {
    margin-bottom: 2.5rem;
    padding-left: 0.5rem;
    border-left: 1px solid rgba(61, 122, 74, 0.2);
}

/* End marks */
.end-mark {
    display: block;
    width: 32px;
    height: 32px;
    margin-top: 1.5rem;
}

/* Section dividers */
.section-divider {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 4vh 0;
}

.divider-glyph {
    width: 48px;
    height: 48px;
}

/* Secondary specimen illustration */
.secondary-specimen {
    max-width: 300px;
    margin-bottom: 2rem;
}

.specimen-small-svg {
    width: 100%;
    height: auto;
}

/* Scroll-triggered path drawing */
.draw-path-scroll {
    stroke-dasharray: var(--path-length, 500);
    stroke-dashoffset: var(--path-length, 500);
}

.draw-path-scroll.animate {
    transition: stroke-dashoffset 1500ms ease-in-out;
    stroke-dashoffset: 0;
}

.junction-node-scroll {
    opacity: 0;
    transform-origin: center;
    transform: scale(0.6);
}

.junction-node-scroll.pulse-in {
    animation: nodeAppear 300ms ease-out forwards, pulseGlow 3s ease-in-out 600ms infinite;
}

/* =====================================================
   NAVIGATION GLYPH
   ===================================================== */
.nav-glyph {
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 48px;
    height: 48px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    z-index: 100;
    border-radius: 50%;
    transition: box-shadow 300ms ease;
    animation: ambientPulse 3s ease-in-out infinite;
}

.nav-glyph svg {
    width: 100%;
    height: 100%;
}

.nav-glyph:hover {
    box-shadow: 0 0 0 3px rgba(94, 207, 176, 0.3), 0 0 20px rgba(94, 207, 176, 0.15);
}

@keyframes ambientPulse {
    0%, 100% {
        box-shadow: 0 0 0 3px rgba(94, 207, 176, 0), 0 0 20px rgba(94, 207, 176, 0);
    }
    50% {
        box-shadow: 0 0 0 3px rgba(94, 207, 176, 0.15), 0 0 20px rgba(94, 207, 176, 0.08);
    }
}

/* =====================================================
   NAVIGATION OVERLAY
   ===================================================== */
.nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 99;
    pointer-events: none;
    opacity: 0;
    transition: opacity 600ms ease;
}

.nav-overlay.active {
    pointer-events: all;
    opacity: 1;
}

.nav-overlay-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(19, 34, 64, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.nav-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
    color: var(--text-primary);
    font-family: 'Commissioner', sans-serif;
    font-weight: 500;
    font-size: clamp(0.85rem, 1.5vw, 1.1rem);
    letter-spacing: 0.06em;
    text-transform: lowercase;
    opacity: 0;
    transform: translateY(15px);
    transition: color 300ms ease;
}

.nav-item:visited {
    color: var(--visited);
}

.nav-overlay.active .nav-item {
    animation: navItemIn 400ms cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

.nav-overlay.active .nav-item[data-index="0"] { animation-delay: 0ms; }
.nav-overlay.active .nav-item[data-index="1"] { animation-delay: 80ms; }
.nav-overlay.active .nav-item[data-index="2"] { animation-delay: 160ms; }
.nav-overlay.active .nav-item[data-index="3"] { animation-delay: 240ms; }
.nav-overlay.active .nav-item[data-index="4"] { animation-delay: 320ms; }

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

.nav-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    border-radius: 50%;
    transition: box-shadow 300ms ease;
}

.nav-item:hover .nav-icon {
    box-shadow: 0 0 0 3px rgba(94, 207, 176, 0.3), 0 0 20px rgba(94, 207, 176, 0.15);
}

.nav-item:hover {
    color: var(--accent-tertiary);
}

/* =====================================================
   FOOTER
   ===================================================== */
.site-footer {
    position: relative;
    padding: 6vh 8%;
    z-index: 2;
}

.footer-line {
    width: 120px;
    height: 1px;
    background-color: var(--accent-secondary);
    opacity: 0.3;
    margin-bottom: 1.5rem;
}

/* =====================================================
   INTERACTIVE ELEMENTS - Pulse Attention
   ===================================================== */
a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color 300ms ease, box-shadow 300ms ease;
}

a:hover {
    color: var(--accent-tertiary);
    box-shadow: 0 0 0 3px rgba(94, 207, 176, 0.3), 0 0 20px rgba(94, 207, 176, 0.15);
}

a:visited {
    color: var(--visited);
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 900px) {
    .herbarium-canvas {
        flex-direction: column;
        justify-content: center;
    }

    .herbarium-label {
        position: relative;
        left: auto;
        top: auto;
        transform: none;
        text-align: center;
        padding: 2rem;
        order: 1;
    }

    .herbarium-label .site-descriptor {
        max-width: 40ch;
        margin: 0 auto;
    }

    .herbarium-illustration {
        position: relative;
        right: auto;
        top: auto;
        transform: none;
        width: 70%;
        max-width: 400px;
        order: 2;
        margin: 0 auto;
    }

    .specimen-cluster {
        max-width: 85%;
        margin-left: 8% !important;
    }

    .marginalia {
        display: none;
    }
}

@media (max-width: 600px) {
    .specimen-cluster {
        max-width: 92%;
        margin-left: 4% !important;
        padding: 1.5rem 1rem;
    }

    .herbarium-illustration {
        width: 85%;
    }

    .nav-glyph {
        width: 40px;
        height: 40px;
        bottom: 16px;
        left: 16px;
    }
}
