/* causality.club - Motion Heavy Interactive */
/* Palette: #f8f7f4, #2d3748, #e53e3e, #3182ce, #805ad5, #a0aec0, #f7fafc, #1a202c */

:root {
    --bg: #f8f7f4;
    --node: #2d3748;
    --cause: #e53e3e;
    --effect: #3182ce;
    --active: #805ad5;
    --neutral: #a0aec0;
    --text-light: #f7fafc;
    --text-dark: #1a202c;
    --ripple: rgba(128, 90, 213, 0.15);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg);
    color: var(--text-dark);
    font-family: 'Merriweather Sans', sans-serif;
    font-weight: 400;
    line-height: 1.7;
    overflow-x: hidden;
}

/* ================================================
   PERSISTENT CAUSAL WEB SVG OVERLAY
   ================================================ */
.causal-web-svg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
    opacity: 0.15;
}

/* ================================================
   SECTIONS
   ================================================ */
.section {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    position: relative;
    overflow: hidden;
}

/* ================================================
   HERO SECTION
   ================================================ */
.hero-section {
    background: var(--bg);
    z-index: 1;
}

/* Domino */
.domino-container {
    margin-bottom: 2rem;
    perspective: 600px;
    z-index: 3;
}

.domino {
    width: 28px;
    height: 60px;
    background: var(--node);
    border-radius: 4px;
    transform-origin: bottom right;
    transition: transform 1.2s cubic-bezier(0.23, 1, 0.32, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
    padding: 6px 4px;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.2);
}

.domino.tipped {
    transform: rotate(90deg);
}

.domino-dots {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    justify-content: center;
}

.domino-dots span {
    width: 4px;
    height: 4px;
    background: var(--text-light);
    border-radius: 50%;
}

.domino-divider {
    width: 18px;
    height: 1px;
    background: rgba(247, 250, 252, 0.3);
}

/* Energy lines radiating from domino */
.energy-lines {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    z-index: 2;
    pointer-events: none;
}

.energy-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--active), transparent);
    transform-origin: 0 50%;
    transform: rotate(var(--angle));
    opacity: 0;
    transition: width 0.8s ease-out, opacity 0.3s ease;
}

.energy-lines.active .energy-line {
    width: 300px;
    opacity: 0.5;
    animation: energyPulse 2s ease-out forwards;
}

@keyframes energyPulse {
    0% { width: 0; opacity: 0.8; }
    60% { width: 350px; opacity: 0.4; }
    100% { width: 400px; opacity: 0; }
}

/* Ripple rings */
.ripple-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid var(--active);
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    pointer-events: none;
    z-index: 2;
}

.ripple-ring.pulse {
    animation: ripple 2.5s ease-out forwards;
}

.r2.pulse { animation-delay: 0.2s; }
.r3.pulse { animation-delay: 0.4s; }
.r4.pulse { animation-delay: 0.6s; }
.r5.pulse { animation-delay: 0.8s; }

@keyframes ripple {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0.5; }
    100% { transform: translate(-50%, -50%) scale(8); opacity: 0; }
}

/* Brand name letters */
.brand {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(2.2rem, 7vw, 4.5rem);
    color: var(--node);
    display: flex;
    position: relative;
    z-index: 3;
    letter-spacing: -0.02em;
}

.letter {
    display: inline-block;
    opacity: 0;
    transition: transform 0.9s cubic-bezier(0.175, 0.885, 0.32, 1.275),
                opacity 0.6s ease;
}

.letter.scattered {
    transform: translate(var(--dx), var(--dy));
}

.letter.placed {
    transform: translate(0, 0);
    opacity: 1;
}

.dot {
    color: var(--active);
}

/* Scroll hint */
.scroll-hint {
    position: absolute;
    bottom: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    opacity: 0;
    animation: scrollHintAppear 1s ease 3s forwards;
    z-index: 3;
}

.scroll-hint-text {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 400;
    font-size: 12px;
    color: var(--neutral);
    text-transform: lowercase;
    letter-spacing: 0.15em;
}

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

@keyframes scrollHintAppear {
    to { opacity: 1; }
}

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

/* ================================================
   SECTION RIPPLES (entry effect)
   ================================================ */
.section-ripple {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid var(--active);
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    pointer-events: none;
}

.section-ripple.active {
    animation: sectionRipple 2s ease-out forwards;
}

.sr2.active { animation-delay: 0.2s; }
.sr3.active { animation-delay: 0.4s; }

@keyframes sectionRipple {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0.3; border-color: var(--active); }
    100% { transform: translate(-50%, -50%) scale(10); opacity: 0; border-color: var(--active); }
}

/* ================================================
   THEREFORE SYMBOL
   ================================================ */
.therefore {
    font-size: 2.5rem;
    color: var(--active);
    margin-bottom: 1.5rem;
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.therefore.visible {
    opacity: 0.6;
    transform: scale(1);
}

.therefore-large {
    font-size: clamp(5rem, 15vw, 10rem);
    color: var(--active);
    opacity: 0;
    transform: scale(0.3);
    transition: opacity 1.5s ease, transform 1.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.therefore-large.visible {
    opacity: 0.8;
    transform: scale(1);
}

/* ================================================
   EVENT NODES
   ================================================ */
.event-node {
    width: 280px;
    height: 280px;
    border-radius: 50%;
    background: var(--node);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    position: relative;
    margin: 1.5rem 0;
    box-shadow: 0 8px 32px rgba(45, 55, 72, 0.3);
    overflow: hidden;
}

.event-node-sm {
    width: 200px;
    height: 200px;
    padding: 1.5rem;
}

/* Animated border that draws on activation */
.node-border-anim {
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border-radius: 50%;
    border: 3px solid transparent;
    pointer-events: none;
}

.node-border-anim.drawing {
    animation: drawNodeBorder 1.2s ease-out forwards;
}

.node-border-anim.small.drawing {
    animation: drawNodeBorder 0.8s ease-out forwards;
}

@keyframes drawNodeBorder {
    0% {
        border-color: transparent;
        clip-path: polygon(50% 0%, 50% 0%, 50% 50%, 50% 50%);
    }
    100% {
        border-color: var(--active);
        clip-path: polygon(50% 0%, 100% 0%, 100% 100%, 0% 100%, 0% 0%, 50% 0%);
    }
}

.event-num {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--active);
    letter-spacing: 0.12em;
    margin-bottom: 0.5rem;
}

.event-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-light);
    margin-bottom: 0.75rem;
}

.event-text {
    font-family: 'Merriweather Sans', sans-serif;
    font-size: 0.82rem;
    color: rgba(247, 250, 252, 0.7);
    line-height: 1.65;
}

/* Active state for event nodes */
.event-node.node-active {
    box-shadow: 0 8px 32px rgba(45, 55, 72, 0.3),
                0 0 0 4px rgba(128, 90, 213, 0.3);
    transition: box-shadow 0.8s ease;
}

/* ================================================
   ARROWS
   ================================================ */
.arrow-container {
    position: relative;
    margin: 1rem 0;
}

.arrow-svg {
    width: 240px;
    height: 80px;
}

.arrow-path {
    fill: none;
    stroke-width: 2;
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    transition: stroke-dashoffset 1.5s ease;
}

.arrow-path.drawn {
    stroke-dashoffset: 0;
}

.cause-arrow { stroke: var(--cause); }
.effect-arrow { stroke: var(--effect); }

.arrow-label {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 400;
    font-size: 12px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.5s ease 0.8s;
}

.arrow-label.shown {
    opacity: 1;
}

.cause-label { color: var(--cause); }
.effect-label { color: var(--effect); }

/* ================================================
   MINI DOMINOS (cascade along arrows)
   ================================================ */
.domino-cascade {
    display: flex;
    gap: 6px;
    align-items: flex-end;
    margin: 0.5rem 0;
    height: 24px;
}

.mini-domino {
    width: 8px;
    height: 18px;
    background: var(--node);
    border-radius: 2px;
    transform-origin: bottom right;
    transform: rotate(0deg);
    transition: transform 0.4s cubic-bezier(0.55, 0.06, 0.68, 0.19);
    transition-delay: var(--delay);
    opacity: 0.7;
}

.domino-cascade.tipping .mini-domino {
    transform: rotate(90deg);
}

/* ================================================
   BRANCH SECTION
   ================================================ */
.branch-arrows {
    margin: 1rem 0;
}

.branch-arrow-svg {
    width: 400px;
    height: 100px;
}

.branch-path-1, .branch-path-2, .branch-path-3,
.converge-path-1, .converge-path-2, .converge-path-3 {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    transition: stroke-dashoffset 1.2s ease;
}

.branch-path-1.drawn, .converge-path-1.drawn { stroke-dashoffset: 0; transition-delay: 0s; }
.branch-path-2.drawn, .converge-path-2.drawn { stroke-dashoffset: 0; transition-delay: 0.2s; }
.branch-path-3.drawn, .converge-path-3.drawn { stroke-dashoffset: 0; transition-delay: 0.4s; }

.converge-arrows {
    margin: 1rem 0;
}

.converge-arrows .branch-arrow-svg {
    height: 80px;
}

.branch-container {
    display: flex;
    gap: 3rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
    justify-content: center;
}

.branch-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}

.branch-label {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 400;
    font-size: 12px;
}

.branch-circle {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: var(--node);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 4px 16px rgba(45, 55, 72, 0.25);
    overflow: hidden;
}

.branch-text {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-light);
}

/* Branch ripples */
.branch-ripple {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1.5px solid var(--active);
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    pointer-events: none;
}

.branch-ripple.active {
    animation: branchRipple 1.5s ease-out forwards;
}

.br2.active { animation-delay: 0.2s; }

@keyframes branchRipple {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0.4; }
    100% { transform: translate(-50%, -50%) scale(5); opacity: 0; }
}

/* ================================================
   LOOP ARROW
   ================================================ */
.loop-arrow {
    margin: 1.5rem 0;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.loop-svg {
    width: 300px;
    height: 160px;
}

.loop-path {
    transition: stroke-dashoffset 3s ease;
}

.loop-path.drawn {
    stroke-dashoffset: 0;
}

.loop-label {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 400;
    font-size: 13px;
    color: var(--active);
    margin-top: 0.5rem;
    opacity: 0;
    transition: opacity 0.8s ease 2.5s;
}

.loop-label.shown {
    opacity: 0.7;
}

/* ================================================
   INDIRECT CONNECTIONS
   ================================================ */
.indirect-connections {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 2rem;
}

.indirect-svg {
    width: 300px;
    height: 40px;
}

.dashed-line {
    stroke: var(--neutral);
    stroke-width: 1.5;
    stroke-dasharray: 6, 4;
    opacity: 0.5;
}

.indirect-label {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 400;
    font-size: 11px;
    color: var(--neutral);
    margin-top: 0.25rem;
    letter-spacing: 0.08em;
}

/* ================================================
   TIMELINE STRIP
   ================================================ */
.timeline-strip {
    display: flex;
    align-items: center;
    gap: 0;
    margin-top: 2.5rem;
}

.tl-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--neutral);
    flex-shrink: 0;
    transition: background 0.5s ease, box-shadow 0.5s ease;
}

.tl-done {
    background: var(--node);
}

.tl-active {
    background: var(--active);
    animation: tlPulse 2s ease-in-out infinite;
}

@keyframes tlPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(128, 90, 213, 0); }
    50% { box-shadow: 0 0 12px 3px rgba(128, 90, 213, 0.4); }
}

.tl-connector {
    width: 40px;
    height: 2px;
    background: var(--neutral);
    transition: background 0.5s ease;
}

.tl-filled {
    background: var(--node);
}

.timeline-loop {
    position: relative;
}

/* ================================================
   CLOSING SECTION
   ================================================ */
.closing-section {
    min-height: 60vh;
    position: relative;
}

.closing-ripple {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 2px solid var(--active);
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    pointer-events: none;
}

.closing-ripple.active {
    animation: closingRipple 3s ease-out forwards;
}

.cr2.active { animation-delay: 0.3s; }
.cr3.active { animation-delay: 0.6s; }
.cr4.active { animation-delay: 0.9s; }
.cr5.active { animation-delay: 1.2s; }

@keyframes closingRipple {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0.3; }
    100% { transform: translate(-50%, -50%) scale(12); opacity: 0; }
}

/* ================================================
   FADE IN (scroll-triggered)
   ================================================ */
.fade-in {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

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

/* ================================================
   RESPONSIVE
   ================================================ */
@media (max-width: 768px) {
    .event-node {
        width: 220px;
        height: 220px;
        padding: 1.5rem;
    }

    .event-node-sm {
        width: 170px;
        height: 170px;
    }

    .event-title {
        font-size: 1.05rem;
    }

    .event-text {
        font-size: 0.75rem;
    }

    .branch-container {
        flex-direction: column;
        align-items: center;
        gap: 2rem;
    }

    .branch-circle {
        width: 110px;
        height: 110px;
    }

    .branch-arrow-svg {
        width: 280px;
    }

    .arrow-svg {
        width: 200px;
    }

    .loop-svg {
        width: 240px;
        height: 130px;
    }

    .energy-lines.active .energy-line {
        width: 200px;
    }
}

@media (max-width: 480px) {
    .event-node {
        width: 190px;
        height: 190px;
        padding: 1.2rem;
    }

    .event-node-sm {
        width: 150px;
        height: 150px;
    }

    .brand {
        font-size: clamp(1.6rem, 8vw, 2.5rem);
    }

    .branch-arrow-svg {
        width: 220px;
    }
}
