/* ============================================================
   storiographer.net — Crystal Herbarium
   Botanical Crystallography Design System
   ============================================================ */

:root {
    --bg-deep: #0a1f18;
    --bg-sidebar: #0d3b2e;
    --accent-primary: #7ecfb3;
    --accent-secondary: #a8e6cf;
    --accent-tertiary: #4db6ac;
    --text-headline: #e8f5e9;
    --text-body: #c8e6c9;
    --text-note: #81c784;
    --accent-warm: #f0c674;
    --mono-color: #66bb6a;
    --sidebar-width: 280px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-deep);
    color: var(--text-body);
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.72;
    overflow-x: hidden;
}

/* ---- Background Crystal Lattice ---- */
.bg-lattice {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

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

/* ---- Sidebar — The Herbarium Index ---- */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: rgba(13, 59, 46, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 100;
    display: flex;
    flex-direction: column;
    padding: 2rem 1.25rem;
    overflow-y: auto;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@supports not (backdrop-filter: blur(1px)) {
    .sidebar {
        background: #0d3b2e;
    }
}

.sidebar-header {
    margin-bottom: 2rem;
    text-align: center;
}

.sidebar-title {
    display: block;
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: 1.1rem;
    letter-spacing: 0.18em;
    color: var(--text-headline);
    margin-bottom: 0.25rem;
}

.sidebar-subtitle {
    display: block;
    font-family: 'Caveat', cursive;
    font-size: 0.95rem;
    color: var(--text-note);
    letter-spacing: 0.01em;
}

/* Sidebar Vine */
.sidebar-vine {
    position: absolute;
    left: 8px;
    top: 120px;
    width: 16px;
    height: 360px;
    pointer-events: none;
}

.vine-draw {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    animation: vineDraw 4s ease-out forwards;
}

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

/* Navigation List */
.nav-list {
    list-style: none;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem 0.75rem;
    cursor: pointer;
    border-radius: 6px;
    transition: background-color 0.3s ease, box-shadow 0.4s ease;
    position: relative;
}

.nav-item:hover {
    background: rgba(126, 207, 179, 0.06);
}

.nav-item.active {
    background: rgba(126, 207, 179, 0.08);
    box-shadow: 0 0 18px rgba(126, 207, 179, 0.3);
}

.nav-crystal-icon {
    flex-shrink: 0;
}

.crystal-fill {
    fill-opacity: 0;
    transition: fill-opacity 0.5s ease;
}

.nav-item.active .crystal-fill {
    fill-opacity: 0.25;
}

.nav-item:hover .crystal-outline {
    animation: crystalPulse 1s ease-in-out;
}

@keyframes crystalPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.nav-label {
    font-family: 'Caveat', cursive;
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
    color: var(--text-note);
    letter-spacing: 0.01em;
    line-height: 1.5;
    transition: color 0.3s ease;
}

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

.nav-item.active .nav-label {
    color: var(--accent-secondary);
}

.nav-catalog {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.7rem;
    color: var(--mono-color);
    opacity: 0.7;
    margin-left: auto;
    white-space: nowrap;
}

/* Sidebar Footer */
.sidebar-footer {
    margin-top: 1.5rem;
    text-align: center;
}

.sidebar-note {
    font-family: 'Caveat', cursive;
    font-size: 0.85rem;
    color: var(--text-note);
    opacity: 0.6;
}

/* ---- Mobile Toggle ---- */
.mobile-toggle {
    display: none;
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    z-index: 150;
    background: rgba(13, 59, 46, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(126, 207, 179, 0.2);
    border-radius: 50%;
    width: 52px;
    height: 52px;
    cursor: pointer;
    padding: 8px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.mobile-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(126, 207, 179, 0.3);
}

/* ---- Main Content — The Observation Chamber ---- */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    position: relative;
}

/* ---- Story Sections ---- */
.story-section {
    min-height: 100vh;
    padding: 4rem 3rem;
    position: relative;
}

.fracture-top {
    margin-bottom: 2rem;
}

.fracture-divider {
    padding: 0 3rem;
}

.fracture-svg {
    width: 100%;
    height: 40px;
    filter: drop-shadow(0 0 6px rgba(168, 230, 207, 0.35));
}

/* Section Inner Layout */
.section-inner {
    display: flex;
    align-items: flex-start;
    gap: 3rem;
    max-width: 1100px;
    margin: 0 auto;
}

.section-inner.layout-left {
    flex-direction: row;
}

.section-inner.layout-right {
    flex-direction: row-reverse;
}

/* ---- Specimen Container ---- */
.specimen-container {
    flex: 0 0 55%;
    max-width: 55%;
    position: relative;
    transform: perspective(800px) rotateX(5deg) rotateY(-8deg);
    transition: transform 0.8s ease;
}

.layout-right .specimen-container {
    transform: perspective(800px) rotateX(5deg) rotateY(8deg);
}

.specimen-container:hover {
    transform: perspective(800px) rotateX(2deg) rotateY(-4deg);
    filter: brightness(1.1) saturate(1.2);
}

.layout-right .specimen-container:hover {
    transform: perspective(800px) rotateX(2deg) rotateY(4deg);
    filter: brightness(1.1) saturate(1.2);
}

.specimen-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: 80%;
    background: radial-gradient(ellipse at center, rgba(126, 207, 179, 0.08) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
}

.specimen-svg {
    width: 100%;
    height: auto;
    max-height: 500px;
    display: block;
}

/* 3D Crystal Depth */
.specimen-container::after {
    content: '';
    position: absolute;
    inset: 0;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3), 0 12px 24px rgba(0,0,0,0.2), inset 0 1px 0 rgba(126,207,179,0.1);
    pointer-events: none;
    border-radius: 4px;
    opacity: 0.5;
}

/* ---- Path Draw Animations ---- */
.draw-path {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    opacity: 1;
}

.in-view .draw-path {
    animation: pathDraw 4s ease-out forwards;
}

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

/* Spore glow animations */
.spore {
    opacity: 0;
}

.in-view .spore {
    animation: sporeAppear 1.5s ease-out forwards;
}

@keyframes sporeAppear {
    0% { opacity: 0; transform: scale(0.5); }
    50% { opacity: 0.9; }
    100% { opacity: 0.7; }
}

/* Bloom center animations */
.bloom-center,
.bloom-center-inner {
    opacity: 0;
}

.in-view .bloom-center {
    animation: bloomGlow 2s ease-out forwards;
}

.in-view .bloom-center-inner {
    animation: bloomGlow 2s ease-out forwards;
}

@keyframes bloomGlow {
    0% { opacity: 0; }
    50% { opacity: 0.8; }
    100% { opacity: 0.6; }
}

/* Crystal frame stays visible but subtle */
.crystal-frame {
    opacity: 0.4;
}

.crystal-frame.frame-inner {
    opacity: 0.25;
}

/* ---- Story Text ---- */
.story-text {
    flex: 0 0 40%;
    max-width: 40%;
    padding-top: 2rem;
}

.story-title {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(2.4rem, 5vw, 4.2rem);
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--text-headline);
    margin-bottom: 0.75rem;
}

.story-catalog {
    display: block;
    font-family: 'Caveat', cursive;
    font-size: 0.95rem;
    color: var(--text-note);
    margin-bottom: 1.5rem;
}

.mono-accent {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.85rem;
    color: var(--mono-color);
    opacity: 0.7;
}

.story-para {
    margin-bottom: 1.2rem;
    color: var(--text-body);
}

.story-para em {
    font-style: italic;
    color: #a5d6a7;
}

.story-annotation {
    font-family: 'Caveat', cursive;
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
    color: var(--text-note);
    letter-spacing: 0.01em;
    line-height: 1.5;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(126, 207, 179, 0.1);
}

.warm-highlight {
    color: var(--accent-warm);
}

/* ---- Fade Text Animation ---- */
.fade-text {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.in-view .fade-text {
    opacity: 1;
    transform: translateY(0);
}

.in-view .fade-text:nth-child(2) { transition-delay: 0.3s; }
.in-view .fade-text:nth-child(3) { transition-delay: 0.6s; }
.in-view .fade-text:nth-child(4) { transition-delay: 0.9s; }
.in-view .fade-text:nth-child(5) { transition-delay: 1.2s; }
.in-view .fade-text:nth-child(6) { transition-delay: 1.5s; }

/* ---- Colophon / Footer ---- */
.colophon {
    text-align: center;
    padding: 4rem 2rem 3rem;
    opacity: 0.6;
}

.colophon-text {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: 1.4rem;
    color: var(--text-headline);
    margin-bottom: 0.5rem;
}

.colophon-note {
    font-family: 'Caveat', cursive;
    font-size: 0.95rem;
    color: var(--text-note);
}

/* ---- Responsive: Desktop Large ---- */
@media (min-width: 1200px) {
    .story-section {
        padding: 5rem 4rem;
    }

    .section-inner {
        max-width: 1200px;
    }
}

/* ---- Responsive: Tablet ---- */
@media (max-width: 1024px) {
    .section-inner {
        gap: 2rem;
    }

    .specimen-container {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .story-text {
        flex: 0 0 45%;
        max-width: 45%;
    }
}

/* ---- Responsive: Mobile ---- */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        width: 100%;
        height: auto;
        max-height: 70vh;
        transform: translateY(calc(100% - 0px));
        border-radius: 16px 16px 0 0;
        padding: 1.5rem 1.25rem;
        z-index: 200;
    }

    .sidebar.open {
        transform: translateY(0);
    }

    .sidebar-vine {
        display: none;
    }

    .mobile-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .main-content {
        margin-left: 0;
    }

    .story-section {
        padding: 2.5rem 1.5rem;
    }

    .fracture-divider {
        padding: 0 1.5rem;
    }

    .section-inner,
    .section-inner.layout-left,
    .section-inner.layout-right {
        flex-direction: column;
        align-items: center;
    }

    .specimen-container,
    .layout-right .specimen-container {
        flex: 0 0 auto;
        max-width: 90%;
        width: 90%;
        transform: perspective(800px) rotateX(3deg) rotateY(0deg);
        margin-bottom: 1.5rem;
    }

    .specimen-container:hover,
    .layout-right .specimen-container:hover {
        transform: perspective(800px) rotateX(1deg) rotateY(0deg);
    }

    .story-text {
        flex: 0 0 auto;
        max-width: 100%;
        width: 100%;
        padding-top: 0;
    }

    .story-title {
        font-size: clamp(1.8rem, 6vw, 2.8rem);
    }
}

/* ---- Selection Color ---- */
::selection {
    background: rgba(126, 207, 179, 0.25);
    color: var(--text-headline);
}

/* ---- Scrollbar Styling ---- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-deep);
}

::-webkit-scrollbar-thumb {
    background: rgba(126, 207, 179, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(126, 207, 179, 0.35);
}
