/* ============================================
   BBATTL.com - Botanical Chronicle Styles
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --deep-forest: #064635;
    --mineral-core: #1a5653;
    --crystalline-teal: #2d8a7e;
    --quartz-rose: #e8d5d3;
    --amethyst-wash: #9b7eb4;
    --geode-interior: #4a2c6e;
    --mica-gold: #c9a96e;
    --frost-white: #f7f5f2;
    --obsidian: #12110f;

    --gradient-primary: linear-gradient(180deg, #064635 0%, #1a5653 25%, #2d8a7e 45%, #9b7eb4 70%, #e8d5d3 100%);
    --gradient-panel: linear-gradient(135deg, rgba(45,138,126,0.08), rgba(155,126,180,0.08));
    --gradient-accent: linear-gradient(90deg, #c9a96e, #9b7eb4);

    --font-heading: 'Playfair Display', Georgia, serif;
    --font-subheading: 'Outfit', 'Helvetica Neue', sans-serif;
    --font-body: 'Source Serif 4', 'Georgia', serif;
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;

    --gutter: clamp(1rem, 3vw, 2.5rem);
    --timeline-left: 33.333%;
    --spine-width: 3px;
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background-color: var(--obsidian);
    color: var(--frost-white);
    font-family: var(--font-body);
    font-size: clamp(1rem, 1vw + 0.75rem, 1.25rem);
    line-height: 1.65;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Noise Texture Overlay --- */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.025;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
}

/* --- Typography --- */
h1 {
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: clamp(2.75rem, 5vw + 1rem, 5.5rem);
    letter-spacing: -0.02em;
    line-height: 1.1;
}

h2 {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: clamp(1.875rem, 3vw + 0.75rem, 3.5rem);
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin-bottom: 1.5rem;
    color: var(--frost-white);
}

h3, h4 {
    font-family: var(--font-subheading);
    font-weight: 500;
}

.body-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1vw + 0.75rem, 1.25rem);
    line-height: 1.65;
    color: var(--frost-white);
    margin-bottom: 1.25rem;
    opacity: 0.92;
}

/* --- Crystallize heading animation --- */
.crystallize-heading {
    font-variation-settings: 'wght' 400;
    transition: font-variation-settings 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.crystallize-heading.revealed {
    font-variation-settings: 'wght' 900;
}

/* --- Sidebar Navigation --- */
#sidebar-nav {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 20px 0;
    background: rgba(18, 17, 15, 0.3);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-right: 1px solid rgba(201, 169, 110, 0.1);
    opacity: 0.4;
    transition: opacity 0.3s ease;
}

#sidebar-nav:hover {
    opacity: 1;
}

.nav-dot {
    width: 8px;
    height: 8px;
    background: var(--mica-gold);
    transform: rotate(45deg);
    cursor: pointer;
    position: relative;
    transition: transform 0.3s ease, background 0.3s ease;
    opacity: 0.5;
}

.nav-dot:hover {
    transform: rotate(45deg) scale(1.5);
    opacity: 1;
    background: var(--crystalline-teal);
}

.nav-dot.active {
    opacity: 1;
    background: var(--amethyst-wash);
}

.nav-label {
    position: absolute;
    left: 24px;
    top: 50%;
    transform: translateY(-50%);
    font-family: var(--font-subheading);
    font-size: clamp(0.75rem, 0.8vw + 0.5rem, 0.9375rem);
    font-weight: 400;
    color: var(--mica-gold);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    transform: translateY(-50%) translateX(-8px);
}

.nav-dot:hover .nav-label {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* --- Timeline Spine --- */
#timeline-spine {
    position: fixed;
    left: var(--timeline-left);
    top: 0;
    width: var(--spine-width);
    height: 100vh;
    z-index: 10;
    pointer-events: none;
}

.spine-line {
    width: 100%;
    height: 100%;
    background: var(--gradient-primary);
    background-size: 100% 200%;
    animation: spineShift 20s ease-in-out infinite;
    opacity: 0.7;
}

@keyframes spineShift {
    0% { background-position: 0% 0%; }
    50% { background-position: 0% 100%; }
    100% { background-position: 0% 0%; }
}

/* --- Hex Texture Overlay --- */
#hex-texture-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    opacity: 0.035;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='52' viewBox='0 0 60 52' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 0L60 15V37L30 52L0 37V15Z' fill='none' stroke='%232d8a7e' stroke-width='0.5'/%3E%3C/svg%3E");
    background-size: 60px 52px;
}

/* --- Hidden SVG filter --- */
#noise-filter {
    position: absolute;
    width: 0;
    height: 0;
}

/* --- Full Screen Sections --- */
.full-screen-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* --- Opening Section --- */
#opening {
    background: radial-gradient(ellipse at 50% 80%, var(--mineral-core) 0%, var(--deep-forest) 40%, var(--obsidian) 80%);
}

.opening-content {
    text-align: center;
    z-index: 10;
    position: relative;
}

#opening h1 {
    font-size: clamp(4rem, 10vw + 1rem, 10rem);
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.15em;
    margin-bottom: 1.5rem;
}

.opening-subtitle {
    font-family: var(--font-subheading);
    font-weight: 300;
    font-size: clamp(1rem, 1.5vw + 0.5rem, 1.5rem);
    color: var(--quartz-rose);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0.7;
    margin-bottom: 3rem;
}

.scroll-indicator {
    animation: scrollBounce 2s ease-in-out infinite;
}

.scroll-dot {
    animation: scrollDotMove 2s ease-in-out infinite;
}

@keyframes scrollBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(8px); }
}

@keyframes scrollDotMove {
    0% { cy: 12; }
    50% { cy: 26; }
    100% { cy: 12; }
}

.bg-botanical {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80vw;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

/* --- Timeline Chapters --- */
.timeline-chapter {
    position: relative;
    padding: clamp(4rem, 8vh, 8rem) 0;
    min-height: 60vh;
}

/* --- Timeline Markers --- */
.timeline-marker {
    position: absolute;
    left: var(--timeline-left);
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.marker-diamond {
    width: 24px;
    height: 24px;
    transform: rotate(45deg);
    border: 1px solid var(--mica-gold);
    background: linear-gradient(135deg, var(--geode-interior), var(--amethyst-wash));
    box-shadow: 0 0 12px rgba(155, 126, 180, 0.3), inset 0 0 6px rgba(201, 169, 110, 0.2);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0;
}

.marker-diamond.revealed {
    opacity: 1;
    animation: markerReveal 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes markerReveal {
    from {
        transform: rotate(45deg) scale(0.3);
        opacity: 0;
    }
    to {
        transform: rotate(45deg) scale(1);
        opacity: 1;
    }
}

.marker-timestamp {
    font-family: var(--font-mono);
    font-size: 0.85em;
    color: var(--mica-gold);
    letter-spacing: 0.05em;
    white-space: nowrap;
    position: absolute;
    top: 100%;
    margin-top: 12px;
    opacity: 0.7;
}

/* --- Branch Panels --- */
.branch-panel {
    position: relative;
    width: clamp(300px, 50vw, 580px);
    padding: clamp(2rem, 4vw, 3rem);
    background: var(--gradient-panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(201, 169, 110, 0.12);
    border-radius: 2px;
    overflow: hidden;
}

.branch-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='52' viewBox='0 0 60 52' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 0L60 15V37L30 52L0 37V15Z' fill='none' stroke='%232d8a7e' stroke-width='0.3'/%3E%3C/svg%3E");
    background-size: 60px 52px;
    opacity: 0.04;
    pointer-events: none;
}

.panel-left {
    margin-left: calc(var(--timeline-left) - clamp(300px, 50vw, 580px) - 40px);
    margin-right: auto;
}

.panel-right {
    margin-left: calc(var(--timeline-left) + 40px);
    margin-right: auto;
}

/* --- Slide Reveal Animations --- */
.reveal-left {
    opacity: 0;
    transform: translateX(-80px);
    transition: transform 0.7s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.5s ease;
}

.reveal-right {
    opacity: 0;
    transform: translateX(80px);
    transition: transform 0.7s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.5s ease;
}

.reveal-left.revealed,
.reveal-right.revealed {
    opacity: 1;
    transform: translateX(0);
}

/* --- Corner Ornament --- */
.corner-ornament {
    position: absolute;
    top: 8px;
    right: 8px;
    opacity: 0.4;
    z-index: 2;
}

/* --- Panel Content --- */
.panel-content {
    position: relative;
    z-index: 3;
}

/* --- Branch Illustrations --- */
.branch-illustration {
    position: absolute;
    width: 200px;
    height: 300px;
    pointer-events: none;
    z-index: 0;
    opacity: 0.3;
}

.branch-left {
    right: -60px;
    top: 0;
}

.branch-right {
    left: -60px;
    top: 0;
}

.branch-path {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.branch-panel.revealed .branch-path {
    stroke-dashoffset: 0;
}

/* --- Specimen List --- */
.specimen-list {
    list-style: none;
    padding: 0;
    margin-top: 1.5rem;
}

.specimen-list li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 0.75rem;
    font-family: var(--font-body);
    font-size: clamp(0.875rem, 0.9vw + 0.6rem, 1.1rem);
    line-height: 1.55;
    color: var(--frost-white);
    opacity: 0.85;
}

.leaf-bullet {
    flex-shrink: 0;
    margin-top: 4px;
}

/* --- Interstitial Sections --- */
.interstitial-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

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

.interstitial-section:nth-of-type(1) {
    background: radial-gradient(ellipse at 30% 50%, rgba(45, 138, 126, 0.15), transparent 70%),
                radial-gradient(ellipse at 70% 50%, rgba(155, 126, 180, 0.1), transparent 60%),
                var(--obsidian);
}

.interstitial-section:nth-of-type(2) {
    background: radial-gradient(ellipse at 50% 30%, rgba(74, 44, 110, 0.2), transparent 60%),
                radial-gradient(ellipse at 50% 70%, rgba(6, 70, 53, 0.15), transparent 60%),
                var(--obsidian);
}

.interstitial-section:nth-of-type(3) {
    background: radial-gradient(ellipse at 40% 40%, rgba(201, 169, 110, 0.1), transparent 50%),
                radial-gradient(ellipse at 60% 60%, rgba(45, 138, 126, 0.12), transparent 50%),
                var(--obsidian);
}

#interstitial-1 {
    background: radial-gradient(ellipse at 30% 50%, rgba(45, 138, 126, 0.15), transparent 70%),
                radial-gradient(ellipse at 70% 50%, rgba(155, 126, 180, 0.1), transparent 60%),
                var(--obsidian);
}

#interstitial-2 {
    background: radial-gradient(ellipse at 50% 30%, rgba(74, 44, 110, 0.2), transparent 60%),
                radial-gradient(ellipse at 50% 70%, rgba(6, 70, 53, 0.15), transparent 60%),
                var(--obsidian);
}

#interstitial-3 {
    background: radial-gradient(ellipse at 40% 40%, rgba(201, 169, 110, 0.1), transparent 50%),
                radial-gradient(ellipse at 60% 60%, rgba(45, 138, 126, 0.12), transparent 50%),
                var(--obsidian);
}

.interstitial-botanical {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.interstitial-heading {
    font-size: clamp(3rem, 8vw, 7rem);
    text-align: center;
    z-index: 10;
    position: relative;
    background: linear-gradient(135deg, var(--quartz-rose), var(--amethyst-wash), var(--crystalline-teal));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.interstitial-heading.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* --- Parallax Layer --- */
.parallax-layer {
    will-change: transform;
}

/* --- Closing Section --- */
.closing-section {
    background: radial-gradient(ellipse at 50% 50%, var(--mineral-core) 0%, var(--deep-forest) 35%, var(--obsidian) 75%);
}

.closing-content {
    text-align: center;
    z-index: 10;
    position: relative;
}

.closing-content h1 {
    font-size: clamp(2.5rem, 6vw + 1rem, 6rem);
    background: linear-gradient(135deg, var(--mica-gold), var(--amethyst-wash), var(--quartz-rose));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1.5rem;
}

.closing-text {
    font-family: var(--font-subheading);
    font-weight: 300;
    font-size: clamp(1rem, 1.5vw + 0.5rem, 1.5rem);
    color: var(--quartz-rose);
    opacity: 0.65;
    max-width: 600px;
    margin: 0 auto 3rem;
    letter-spacing: 0.03em;
}

.closing-diamond {
    opacity: 0.5;
    animation: closingPulse 4s ease-in-out infinite;
}

@keyframes closingPulse {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.05); }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    .spine-line {
        animation: none;
    }
    .reveal-left,
    .reveal-right {
        transition: none;
        opacity: 1;
        transform: none;
    }
    .crystallize-heading {
        transition: none;
        font-variation-settings: 'wght' 900;
    }
    .marker-diamond {
        opacity: 1;
        animation: none;
        transform: rotate(45deg) scale(1);
    }
    .branch-path {
        stroke-dasharray: none;
        stroke-dashoffset: 0;
        transition: none;
    }
    .interstitial-heading {
        opacity: 1;
        transform: none;
        transition: none;
    }
    .scroll-indicator {
        animation: none;
    }
    .scroll-dot {
        animation: none;
    }
    .closing-diamond {
        animation: none;
    }
}

/* --- Responsive Adjustments --- */
@media (max-width: 1024px) {
    :root {
        --timeline-left: 20%;
    }

    .panel-left {
        margin-left: calc(var(--timeline-left) + 40px);
    }

    .panel-right {
        margin-left: calc(var(--timeline-left) + 40px);
    }

    .branch-panel {
        width: clamp(280px, 65vw, 550px);
    }
}

@media (max-width: 768px) {
    :root {
        --timeline-left: 10%;
    }

    #sidebar-nav {
        display: none;
    }

    .panel-left,
    .panel-right {
        margin-left: calc(var(--timeline-left) + 30px);
        width: clamp(240px, 75vw, 500px);
    }

    .branch-illustration {
        display: none;
    }

    .timeline-marker {
        left: var(--timeline-left);
    }
}

@media (max-width: 480px) {
    :root {
        --timeline-left: 6%;
    }

    .panel-left,
    .panel-right {
        margin-left: calc(var(--timeline-left) + 20px);
        width: calc(100vw - var(--timeline-left) - 40px);
        padding: 1.5rem;
    }

    #opening h1 {
        font-size: clamp(2.5rem, 15vw, 5rem);
    }
}
