/* ============================================
   causality.club - Watercolor Circuitry
   ============================================ */

/* --- Color Reference ---
   Evergreen Depth:    #1B3A2A
   Canopy Green:       #2D6B4F
   Fern Mist:          #7BAF8E
   Burnt Sienna Wash:  #B5654A
   Sap Yellow:         #C8A84E
   Deckle Cream:       #F4F1EC
   Forest Ink:         #2A3E2A
   Umber Annotation:   #6B5B4B
   Humus Dark:         #0F1F15
   Deep Bark:          #1B2E1B
--- */

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

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

body {
    font-family: 'Source Serif 4', 'Georgia', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.15vw, 1.2rem);
    line-height: 1.72;
    color: #2A3E2A;
    background: #F4F1EC;
    overflow-x: hidden;
}

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

/* --- Typography --- */
h1, h2 {
    font-family: 'Playfair Display', 'Georgia', serif;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1.18;
}

.annotation {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: clamp(0.85rem, 1.1vw, 1.1rem);
    color: #6B5B4B;
    opacity: 0.8;
}

p {
    max-width: 42ch;
}

/* ============================================
   SECTION 1: THE ORIGIN NODE
   ============================================ */
.section-origin {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 6vw;
    overflow: hidden;
    background: #F4F1EC;
}

/* Watercolor wash base */
.watercolor-wash {
    position: relative;
}

.wash-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

/* Origin wash layers */
.wash-layer-origin {
    background:
        radial-gradient(ellipse at 25% 35%, rgba(45, 107, 79, 0.27) 0%, transparent 65%),
        radial-gradient(ellipse at 70% 60%, rgba(181, 101, 74, 0.2) 0%, transparent 55%),
        radial-gradient(ellipse at 55% 20%, rgba(123, 175, 142, 0.13) 0%, transparent 70%),
        radial-gradient(ellipse at 40% 80%, rgba(200, 168, 78, 0.13) 0%, transparent 50%);
    filter: url(#watercolor-turbulence);
    mix-blend-mode: multiply;
    opacity: 0.45;
}

.origin-content {
    position: relative;
    z-index: 2;
    padding-left: 32%;
    padding-top: 5%;
    max-width: 55ch;
}

.annotation-origin {
    display: block;
    margin-bottom: 1rem;
    transform: rotate(-2deg);
}

.origin-title {
    font-size: clamp(2.8rem, 6.5vw, 5.5rem);
    color: #1B2E1B;
    margin-bottom: 1.5rem;
    opacity: 0;
    animation: titleReveal 2s cubic-bezier(0.22, 1, 0.36, 1) 0.5s forwards;
}

.origin-statement {
    font-weight: 300;
    color: #2A3E2A;
    margin-bottom: 2.5rem;
    opacity: 0;
    animation: fadeIn 1.8s ease 1.2s forwards;
}

.origin-indicator {
    display: flex;
    align-items: center;
    gap: 1rem;
    opacity: 0;
    animation: fadeIn 1.5s ease 2s forwards;
}

.origin-pulse {
    width: 80px;
    height: 80px;
}

.pulse-ring {
    transform-origin: center;
}

.pulse-ring-1 {
    animation: pulseExpand 3s ease-in-out infinite;
}

.pulse-ring-2 {
    animation: pulseExpand 3s ease-in-out 1s infinite;
}

.scroll-hint {
    display: inline-block;
    animation: gentleBob 3s ease-in-out infinite;
}

/* Decorative circuit - Origin */
.circuit-decoration {
    position: absolute;
    pointer-events: none;
    z-index: 1;
}

.circuit-origin {
    right: 4vw;
    top: 10%;
    width: 22vw;
    max-width: 300px;
    height: auto;
    opacity: 0.25;
}

/* ============================================
   CONNECTORS
   ============================================ */
.connector-container {
    position: relative;
    width: 100%;
    height: 15vh;
    min-height: 100px;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.connector-svg {
    width: 60%;
    height: 100%;
    overflow: visible;
}

.connector-label {
    position: absolute;
    bottom: 15%;
    left: 50%;
    transform: translateX(-50%) rotate(-3deg);
    white-space: nowrap;
}

.connector-label-right {
    left: auto;
    right: 15%;
    transform: rotate(2deg);
}

/* Connector line animation states */
.connector-line {
    transition: stroke-dashoffset 1.2s ease-in-out;
}

.connector-main-line {
    stroke-dasharray: var(--line-length, 1000);
    stroke-dashoffset: var(--line-length, 1000);
}

.connector-main-line.drawn {
    stroke-dashoffset: 0;
}

.connector-glow-line {
    stroke-dasharray: var(--line-length, 1000);
    stroke-dashoffset: var(--line-length, 1000);
}

.connector-glow-line.drawn {
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1.4s ease-in-out;
}

/* ============================================
   SECTION 2: THE BRANCHING FIELD
   ============================================ */
.section-branching {
    position: relative;
    min-height: 150vh;
    padding: 6vw;
    padding-bottom: 10vh;
}

/* Content Nodes */
.content-node {
    position: relative;
    width: clamp(320px, 50vw, 600px);
    padding: 0;
    margin-bottom: 2vh;
    perspective: 1200px;
    z-index: 2;
}

/* Deckled paper edge clip-paths */
.node-inner {
    position: relative;
    z-index: 2;
    padding: clamp(2rem, 3vw, 3.5rem);
    background: rgba(244, 241, 236, 0.92);
    clip-path: polygon(
        2% 4%, 6% 1%, 12% 3%, 18% 0%, 24% 2%, 30% 1%, 36% 3%, 42% 0%,
        48% 2%, 54% 1%, 60% 3%, 66% 0%, 72% 2%, 78% 1%, 84% 3%, 90% 0%,
        96% 2%, 100% 5%,
        99% 12%, 100% 20%, 98% 28%, 100% 36%, 99% 44%, 100% 52%,
        98% 60%, 100% 68%, 99% 76%, 100% 84%, 98% 92%, 100% 100%,
        96% 98%, 90% 100%, 84% 97%, 78% 100%, 72% 98%, 66% 100%,
        60% 97%, 54% 100%, 48% 98%, 42% 100%, 36% 97%, 30% 100%,
        24% 98%, 18% 100%, 12% 97%, 6% 100%, 2% 97%, 0% 95%,
        1% 88%, 0% 80%, 2% 72%, 0% 64%, 1% 56%, 0% 48%,
        2% 40%, 0% 32%, 1% 24%, 0% 16%, 2% 8%, 0% 0%
    );
    transition: transform 0.15s ease-out, box-shadow 0.3s ease;
    transform-style: preserve-3d;
}

/* Node blooming animation */
.content-node {
    opacity: 0;
    transform: scale(0.1);
    border-radius: 50%;
    transition: opacity 0.9s cubic-bezier(0.22, 1, 0.36, 1),
                transform 0.9s cubic-bezier(0.22, 1, 0.36, 1),
                border-radius 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}

.content-node.bloomed {
    opacity: 1;
    transform: scale(1) rotate(var(--node-rotation, 0deg));
    border-radius: 0;
}

.content-node.bloomed .node-inner {
    opacity: 1;
}

.node-inner {
    opacity: 0;
    transition: opacity 0.5s ease 0.3s;
}

.content-node.bloomed .node-inner {
    transition: opacity 0.5s ease 0.3s;
}

/* Node wash layers */
.wash-layer-node-1,
.wash-layer-node-2,
.wash-layer-node-3,
.wash-layer-node-4,
.wash-layer-node-5 {
    filter: url(#watercolor-turbulence-2);
    mix-blend-mode: multiply;
    border-radius: inherit;
    pointer-events: none;
}

.wash-layer-node-1 {
    background:
        radial-gradient(ellipse at 30% 40%, rgba(123, 175, 142, 0.2) 0%, transparent 70%),
        radial-gradient(ellipse at 70% 60%, rgba(200, 168, 78, 0.1) 0%, transparent 60%);
    opacity: 0.5;
}

.wash-layer-node-2 {
    background:
        radial-gradient(ellipse at 60% 30%, rgba(45, 107, 79, 0.25) 0%, transparent 65%),
        radial-gradient(ellipse at 30% 70%, rgba(181, 101, 74, 0.15) 0%, transparent 55%);
    opacity: 0.5;
}

.wash-layer-node-3 {
    background:
        radial-gradient(ellipse at 40% 50%, rgba(45, 107, 79, 0.3) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 30%, rgba(200, 168, 78, 0.2) 0%, transparent 50%);
    opacity: 0.55;
}

.wash-layer-node-4 {
    background:
        radial-gradient(ellipse at 50% 40%, rgba(27, 58, 42, 0.2) 0%, transparent 65%),
        radial-gradient(ellipse at 25% 70%, rgba(181, 101, 74, 0.2) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 60%, rgba(123, 175, 142, 0.15) 0%, transparent 55%);
    opacity: 0.55;
}

.wash-layer-node-5 {
    background:
        radial-gradient(ellipse at 35% 45%, rgba(27, 58, 42, 0.3) 0%, transparent 55%),
        radial-gradient(ellipse at 65% 35%, rgba(200, 168, 78, 0.25) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 75%, rgba(45, 107, 79, 0.2) 0%, transparent 60%);
    opacity: 0.6;
}

/* Node positioning - organic flow, staggered */
.node-1 {
    margin-left: 8vw;
    --node-rotation: -1.2deg;
}

.node-2 {
    margin-left: 42vw;
    --node-rotation: 1.8deg;
}

.node-3 {
    margin-left: 6vw;
    --node-rotation: -0.8deg;
}

.node-4 {
    margin-left: 35vw;
    --node-rotation: 2.0deg;
}

.node-5 {
    margin-left: 15vw;
    --node-rotation: -1.5deg;
}

/* Node typography */
.node-figure {
    display: block;
    font-family: 'Playfair Display', 'Georgia', serif;
    font-weight: 400;
    font-size: 0.9rem;
    color: #B5654A;
    margin-bottom: 0.5rem;
    letter-spacing: 0.06em;
}

.node-title {
    font-size: clamp(1.6rem, 3vw, 2.8rem);
    color: #1B2E1B;
    margin-bottom: 1rem;
}

.node-text {
    font-weight: 300;
    margin-bottom: 1.2rem;
}

.node-annotation {
    display: block;
    margin-top: 0.5rem;
    transform: rotate(-1.5deg);
}

/* Tilt-3D hover effect on nodes */
.content-node.bloomed .node-inner {
    transform-style: preserve-3d;
    will-change: transform;
}

.content-node.bloomed:hover .node-inner {
    box-shadow: 0 15px 40px rgba(15, 31, 21, 0.15),
                0 4px 12px rgba(15, 31, 21, 0.08);
}

/* Humus Dark (#0F1F15) overlay for dramatic depth */
.section-convergence::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 50%, transparent 40%, #0F1F15 100%);
    pointer-events: none;
    z-index: 1;
    opacity: 0.4;
}

/* Canopy Green (#2D6B4F) accent line */
.content-node::before {
    content: '';
    position: absolute;
    top: 0;
    left: 8%;
    right: 8%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #2D6B4F, transparent);
    opacity: 0;
    transition: opacity 0.9s ease 0.4s;
    z-index: 3;
}

.content-node.bloomed::before {
    opacity: 0.35;
}

/* Decorative circuit elements in branching field */
.circuit-branch-left {
    left: -2vw;
    top: 10%;
    width: 15vw;
    max-width: 200px;
    height: auto;
}

.circuit-branch-right {
    right: -2vw;
    top: 30%;
    width: 15vw;
    max-width: 200px;
    height: auto;
}

/* ============================================
   SECTION 3: THE CONVERGENCE
   ============================================ */
.section-convergence {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6vw;
    overflow: hidden;
    background: #1B3A2A;
}

.wash-layer-convergence {
    background:
        radial-gradient(ellipse at 50% 50%, rgba(45, 107, 79, 0.5) 0%, transparent 60%),
        radial-gradient(ellipse at 30% 30%, rgba(123, 175, 142, 0.2) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 70%, rgba(200, 168, 78, 0.25) 0%, transparent 45%),
        radial-gradient(ellipse at 50% 50%, rgba(27, 58, 42, 0.4) 0%, transparent 80%);
    filter: url(#watercolor-turbulence);
    mix-blend-mode: screen;
    opacity: 0.5;
}

.convergence-content {
    position: relative;
    z-index: 2;
    text-align: center;
    max-width: 60ch;
}

.annotation-convergence {
    display: block;
    margin-bottom: 1rem;
    color: #7BAF8E;
    opacity: 0.7;
}

.convergence-title {
    font-size: clamp(2.2rem, 5vw, 4.5rem);
    color: #F4F1EC;
    margin-bottom: 1.5rem;
    opacity: 0;
    transition: opacity 1.2s ease;
}

.convergence-title.visible {
    opacity: 1;
}

.convergence-text {
    font-weight: 300;
    color: #F4F1EC;
    opacity: 0.9;
    max-width: 48ch;
    margin: 0 auto 3rem;
    line-height: 1.8;
}

.convergence-pool {
    display: flex;
    justify-content: center;
    margin-bottom: 2.5rem;
}

.convergence-pool-svg {
    width: clamp(200px, 30vw, 300px);
    height: auto;
    animation: poolPulse 6s ease-in-out infinite;
}

.convergence-coda {
    display: block;
    color: #C8A84E;
    font-size: clamp(1rem, 1.3vw, 1.3rem);
    opacity: 0.8;
    letter-spacing: 0.02em;
}

/* Decorative circuit - Convergence */
.circuit-convergence {
    bottom: 5%;
    left: 50%;
    transform: translateX(-50%);
    width: 35vw;
    max-width: 400px;
    height: auto;
    opacity: 0.18;
}

/* ============================================
   SCROLL-DRIVEN WASH INTENSIFICATION
   ============================================ */
.section-origin {
    --wash-intensity: var(--scroll-intensity, 0.35);
}

.section-branching {
    --wash-intensity: var(--scroll-intensity, 0.5);
}

.section-convergence {
    --wash-intensity: var(--scroll-intensity, 0.7);
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes titleReveal {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
        filter: blur(8px);
    }
    60% {
        filter: blur(0);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

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

@keyframes pulseExpand {
    0%, 100% {
        transform: scale(1);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.4);
        opacity: 0;
    }
}

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

@keyframes poolPulse {
    0%, 100% {
        transform: scale(1);
        filter: brightness(1);
    }
    50% {
        transform: scale(1.05);
        filter: brightness(1.1);
    }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .origin-content {
        padding-left: 6vw;
        padding-top: 20vh;
    }

    .circuit-origin {
        width: 35vw;
        opacity: 0.15;
    }

    .content-node {
        width: clamp(280px, 85vw, 500px);
    }

    .node-1,
    .node-2,
    .node-3,
    .node-4,
    .node-5 {
        margin-left: 4vw;
    }

    .connector-svg {
        width: 90%;
    }

    .circuit-branch-left,
    .circuit-branch-right {
        display: none;
    }

    .section-convergence {
        padding: 10vw 6vw;
    }
}

@media (max-width: 480px) {
    .origin-title {
        font-size: clamp(2rem, 8vw, 3rem);
    }

    .content-node {
        width: 90vw;
    }

    .node-inner {
        padding: 1.5rem;
    }

    .convergence-title {
        font-size: clamp(1.8rem, 7vw, 3rem);
    }
}
