/* ===========================================
   historygrapher.com - Styles
   Generative / Dreamy-Ethereal / Sunset-Warm
   =========================================== */

/* --- CSS Custom Properties --- */
:root {
    --deep-twilight: #1a1028;
    --dusk-violet: #2d1b3d;
    --twilight-rose: #c2506a;
    --amber-glow: #e8913a;
    --dusty-coral: #d4836a;
    --pale-amber: #f0dcc0;
    --warm-parchment: #faf3e6;
    --burnt-sienna: #8b3a2a;
    --scroll-progress: 0;
}

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

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

body {
    background: var(--deep-twilight);
    color: var(--pale-amber);
    font-family: 'Source Serif 4', 'Georgia', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.78;
    overflow-x: hidden;
    min-height: 100vh;
}

/* --- Dynamic Background Gradient --- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        180deg,
        #1a1028 0%,
        #2d1b3d 20%,
        #3d2245 35%,
        #5a2d3d 45%,
        #8b4a2a 50%,
        #5a2d3d 55%,
        #3d2245 65%,
        #2d1b3d 80%,
        #1a1028 100%
    );
    background-size: 100% 300%;
    background-position: 0% calc(var(--scroll-progress) * 100%);
    z-index: -3;
    pointer-events: none;
    transition: background-position 0.1s linear;
}

/* --- Dendrite Canvas --- */
#dendrite-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    pointer-events: none;
    opacity: 0.05;
    transition: opacity 1.5s ease;
}

body.loaded #dendrite-canvas {
    opacity: 0.15;
}

/* --- Organic Blobs --- */
#blob-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}

.organic-blob {
    position: absolute;
    border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
    background: radial-gradient(ellipse at center, rgba(232, 145, 58, 0.4) 0%, rgba(194, 80, 106, 0.1) 70%, transparent 100%);
    filter: blur(40px);
    opacity: 0;
    transition: opacity 2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform, border-radius;
}

body.loaded .organic-blob {
    opacity: 1;
}

.blob-1 {
    width: 350px;
    height: 320px;
    top: 5%;
    left: 10%;
    animation: blobMorph1 16s ease-in-out infinite, blobDrift1 25s ease-in-out infinite;
}

.blob-2 {
    width: 250px;
    height: 280px;
    top: 20%;
    right: 8%;
    animation: blobMorph2 14s ease-in-out infinite, blobDrift2 22s ease-in-out infinite;
    animation-delay: -3s;
}

.blob-3 {
    width: 400px;
    height: 370px;
    top: 35%;
    left: 25%;
    animation: blobMorph3 18s ease-in-out infinite, blobDrift3 28s ease-in-out infinite;
    animation-delay: -7s;
}

.blob-4 {
    width: 180px;
    height: 200px;
    top: 50%;
    right: 20%;
    animation: blobMorph4 12s ease-in-out infinite, blobDrift1 20s ease-in-out infinite;
    animation-delay: -5s;
}

.blob-5 {
    width: 300px;
    height: 280px;
    top: 65%;
    left: 5%;
    animation: blobMorph1 20s ease-in-out infinite, blobDrift2 26s ease-in-out infinite;
    animation-delay: -10s;
}

.blob-6 {
    width: 220px;
    height: 240px;
    top: 78%;
    right: 15%;
    animation: blobMorph2 15s ease-in-out infinite, blobDrift3 23s ease-in-out infinite;
    animation-delay: -2s;
}

.blob-7 {
    width: 160px;
    height: 150px;
    top: 90%;
    left: 40%;
    animation: blobMorph3 13s ease-in-out infinite, blobDrift1 19s ease-in-out infinite;
    animation-delay: -8s;
}

/* Blob Morph Keyframes */
@keyframes blobMorph1 {
    0%, 100% { border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%; }
    14% { border-radius: 50% 50% 30% 70% / 50% 70% 30% 50%; }
    28% { border-radius: 70% 30% 50% 50% / 30% 50% 70% 50%; }
    42% { border-radius: 40% 60% 60% 40% / 60% 40% 40% 60%; }
    57% { border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%; }
    71% { border-radius: 35% 65% 55% 45% / 45% 55% 65% 35%; }
    85% { border-radius: 50% 50% 40% 60% / 35% 65% 50% 50%; }
}

@keyframes blobMorph2 {
    0%, 100% { border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%; }
    16% { border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%; }
    33% { border-radius: 50% 50% 50% 50% / 40% 60% 40% 60%; }
    50% { border-radius: 40% 60% 70% 30% / 50% 50% 30% 70%; }
    66% { border-radius: 70% 30% 40% 60% / 30% 70% 60% 40%; }
    83% { border-radius: 45% 55% 55% 45% / 65% 35% 45% 55%; }
}

@keyframes blobMorph3 {
    0%, 100% { border-radius: 40% 60% 60% 40% / 60% 40% 40% 60%; }
    12% { border-radius: 70% 30% 30% 70% / 40% 60% 60% 40%; }
    25% { border-radius: 55% 45% 50% 50% / 35% 65% 50% 50%; }
    37% { border-radius: 30% 70% 60% 40% / 50% 50% 40% 60%; }
    50% { border-radius: 65% 35% 45% 55% / 55% 45% 55% 45%; }
    62% { border-radius: 45% 55% 35% 65% / 40% 60% 65% 35%; }
    75% { border-radius: 50% 50% 70% 30% / 60% 40% 30% 70%; }
    87% { border-radius: 35% 65% 45% 55% / 50% 50% 55% 45%; }
}

@keyframes blobMorph4 {
    0%, 100% { border-radius: 50% 50% 40% 60% / 40% 60% 50% 50%; }
    20% { border-radius: 60% 40% 50% 50% / 55% 45% 45% 55%; }
    40% { border-radius: 35% 65% 65% 35% / 45% 55% 35% 65%; }
    60% { border-radius: 55% 45% 35% 65% / 60% 40% 55% 45%; }
    80% { border-radius: 40% 60% 55% 45% / 35% 65% 60% 40%; }
}

/* Blob Drift Keyframes */
@keyframes blobDrift1 {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(15px, -10px); }
    50% { transform: translate(-10px, 15px); }
    75% { transform: translate(12px, 8px); }
}

@keyframes blobDrift2 {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(-12px, 15px); }
    50% { transform: translate(15px, -8px); }
    75% { transform: translate(-8px, -15px); }
}

@keyframes blobDrift3 {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(10px, 12px); }
    50% { transform: translate(-15px, -10px); }
    75% { transform: translate(8px, -15px); }
}

/* --- Hero Section --- */
.hero {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1;
    overflow: hidden;
}

.hero-blob {
    position: absolute;
    width: clamp(280px, 50vw, 500px);
    height: clamp(260px, 45vw, 460px);
    border-radius: 40% 60% 55% 45% / 50% 45% 55% 50%;
    background: radial-gradient(ellipse at center, rgba(232, 145, 58, 0.35) 0%, rgba(194, 80, 106, 0.15) 50%, transparent 75%);
    filter: blur(60px);
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 2s cubic-bezier(0.25, 0.46, 0.45, 0.94), transform 2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    animation: heroBlob 20s ease-in-out infinite;
    z-index: -1;
}

.hero-blob.visible {
    opacity: 0.3;
    transform: scale(1);
}

@keyframes heroBlob {
    0%, 100% { border-radius: 40% 60% 55% 45% / 50% 45% 55% 50%; transform: scale(1) translateY(0); }
    25% { border-radius: 55% 45% 40% 60% / 45% 55% 50% 50%; }
    50% { border-radius: 45% 55% 60% 40% / 55% 45% 45% 55%; transform: scale(1) translateY(-30px); }
    75% { border-radius: 60% 40% 45% 55% / 50% 50% 55% 45%; }
}

.hero-content {
    text-align: center;
    z-index: 2;
    position: relative;
}

.domain-title {
    font-family: 'Playfair Display', 'Georgia', serif;
    font-weight: 900;
    font-size: clamp(3rem, 8vw, 6rem);
    color: var(--warm-parchment);
    letter-spacing: 0.03em;
    text-shadow: 0 2px 24px rgba(232, 145, 58, 0);
    line-height: 1.1;
    overflow: hidden;
}

.domain-title .letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.domain-title .letter.visible {
    opacity: 1;
    transform: translateY(0);
    text-shadow: 0 2px 24px rgba(232, 145, 58, 0.25);
}

.tagline {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: clamp(0.8rem, 1.5vw, 1rem);
    color: var(--dusty-coral);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    font-variant: small-caps;
    margin-top: 1rem;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.tagline.visible {
    opacity: 1;
}

/* Scroll Lottie placeholder */
.scroll-lottie {
    position: absolute;
    bottom: 10vh;
    left: 50%;
    transform: translateX(-50%);
    width: clamp(160px, 40vw, 320px);
    height: auto;
    opacity: 0;
    transition: opacity 1s ease;
}

.scroll-lottie.visible {
    opacity: 1;
}

/* --- Vine Spine --- */
.vine-spine {
    position: absolute;
    top: 100vh;
    left: 0;
    width: 100%;
    height: calc(100% - 100vh);
    z-index: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.vine-spine.visible {
    opacity: 1;
}

#vine-path {
    stroke-dasharray: 0;
    stroke-dashoffset: 0;
    stroke-linecap: round;
}

/* --- Timeline Content --- */
.timeline-content {
    position: relative;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 10vh 2rem 20vh;
    z-index: 1;
}

/* --- Content Nodes --- */
.content-node {
    position: relative;
    margin-bottom: 18vh;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
    display: flex;
    align-items: flex-start;
}

.content-node.visible {
    opacity: 1;
    transform: translateY(0);
}

.node-left {
    justify-content: flex-start;
    padding-left: 5%;
}

.node-right {
    justify-content: flex-end;
    padding-right: 5%;
}

.node-content {
    max-width: 520px;
    width: 45%;
    min-width: 280px;
}

.node-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--amber-glow);
    box-shadow: 0 0 16px rgba(232, 145, 58, 0.5), 0 0 4px rgba(232, 145, 58, 0.8);
    position: absolute;
    left: 50%;
    top: 10px;
    transform: translateX(-50%);
    z-index: 2;
    animation: dotPulse 4s ease-in-out infinite;
}

@keyframes dotPulse {
    0%, 100% { box-shadow: 0 0 16px rgba(232, 145, 58, 0.5), 0 0 4px rgba(232, 145, 58, 0.8); }
    50% { box-shadow: 0 0 24px rgba(232, 145, 58, 0.7), 0 0 8px rgba(232, 145, 58, 1); }
}

.connector-line {
    position: absolute;
    top: 16px;
    height: 1px;
    z-index: 1;
}

.node-left .connector-line {
    left: calc(5% + 45% + 10px);
    right: 50%;
    background: linear-gradient(to right, transparent, var(--dusty-coral));
}

.node-right .connector-line {
    left: 50%;
    right: calc(5% + 45% + 10px);
    background: linear-gradient(to left, transparent, var(--dusty-coral));
}

.date-marker {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: clamp(0.7rem, 1.2vw, 0.85rem);
    color: var(--dusty-coral);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-variant: small-caps;
    display: block;
    margin-bottom: 0.5rem;
}

.epoch-heading {
    font-family: 'Playfair Display', 'Georgia', serif;
    font-weight: 700;
    font-size: clamp(1.6rem, 3.5vw, 2.8rem);
    color: var(--warm-parchment);
    letter-spacing: 0.03em;
    text-shadow: 0 2px 24px rgba(232, 145, 58, 0.25);
    line-height: 1.2;
    margin-bottom: 0.75rem;
}

.narrative-text {
    color: rgba(240, 220, 192, 0.9);
    font-family: 'Source Serif 4', 'Georgia', serif;
    font-weight: 400;
    line-height: 1.78;
}

/* --- Epoch Transitions (Flow Fields) --- */
.epoch-transition {
    width: 100vw;
    height: 200px;
    margin: 8vh 0;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
    overflow: hidden;
    opacity: 0;
    transition: opacity 1s ease;
}

.epoch-transition.visible {
    opacity: 1;
}

.flow-field-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* --- Lottie Containers --- */
.lottie-container {
    width: clamp(200px, 40vw, 400px);
    height: clamp(200px, 40vw, 400px);
    margin: 6vh auto;
    position: relative;
    opacity: 0;
    transition: opacity 1s ease;
}

.lottie-container.visible {
    opacity: 1;
}

/* Lottie placeholder SVG animations */
.lottie-container svg {
    width: 100%;
    height: 100%;
}

/* --- The Fade Section --- */
.fade-section {
    padding: 20vh 2rem 30vh;
    text-align: center;
    opacity: 0;
    transition: opacity 2s ease;
}

.fade-section.visible {
    opacity: 1;
}

.final-text {
    font-family: 'Source Serif 4', 'Georgia', serif;
    font-style: italic;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    color: rgba(240, 220, 192, 0.7);
    letter-spacing: 0.05em;
    line-height: 1.6;
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    .organic-blob,
    .hero-blob {
        animation: none !important;
        opacity: 0.15 !important;
    }

    .content-node {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }

    .tagline,
    .domain-title .letter {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }

    .hero-blob {
        opacity: 0.2 !important;
        transform: scale(1) !important;
    }

    .vine-spine {
        opacity: 1 !important;
    }

    .epoch-transition {
        opacity: 0.8 !important;
    }

    .fade-section {
        opacity: 0.7 !important;
    }

    @keyframes dotPulse {
        0%, 100% { box-shadow: 0 0 16px rgba(232, 145, 58, 0.5), 0 0 4px rgba(232, 145, 58, 0.8); }
    }
}

/* --- Mobile / Responsive --- */
@media (max-width: 768px) {
    .content-node {
        margin-bottom: 12vh;
    }

    .node-left,
    .node-right {
        justify-content: flex-start;
        padding-left: 2rem;
        padding-right: 2rem;
    }

    .node-content {
        width: 100%;
        max-width: 100%;
    }

    .node-dot {
        left: 1rem;
        transform: translateX(0);
    }

    .node-left .connector-line,
    .node-right .connector-line {
        display: none;
    }

    .timeline-content {
        padding: 5vh 1rem 15vh;
    }

    .organic-blob {
        filter: blur(50px);
    }

    .blob-1 { width: 200px; height: 180px; }
    .blob-2 { width: 150px; height: 170px; }
    .blob-3 { width: 250px; height: 220px; }
    .blob-4 { width: 120px; height: 130px; }
    .blob-5 { width: 180px; height: 170px; }
    .blob-6 { width: 140px; height: 150px; }
    .blob-7 { width: 100px; height: 100px; }

    .epoch-transition {
        height: 120px;
    }
}

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

    .epoch-heading {
        font-size: clamp(1.3rem, 5vw, 2rem);
    }

    .node-left,
    .node-right {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

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

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

::-webkit-scrollbar-thumb {
    background: var(--dusk-violet);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--twilight-rose);
}

/* --- Selection --- */
::selection {
    background: rgba(194, 80, 106, 0.4);
    color: var(--warm-parchment);
}
