/* ========================================
   domain - Blobitecture Fluid Layout
   ======================================== */

/* --- CSS Custom Properties --- */
:root {
    --deep-aubergine: #2B1D3A;
    --membrane-white: #F0EDE5;
    --bioluminescent-teal: #5ECFB1;
    --lavender-membrane: #9B8EC4;
    --coral-pulse: #E8845C;
    --void-black: #1A1128;
    --pale-lilac: #D4C9E8;
    --spore-gold: #F7C948;

    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Fraunces', serif;
    --font-mono: 'Azeret Mono', monospace;
}

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

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

body {
    background-color: var(--void-black);
    color: var(--membrane-white);
    font-family: var(--font-body);
    font-optical-sizing: auto;
    overflow-x: hidden;
    min-height: 100vh;
}

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

/* --- Background gradient scroll --- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom,
        var(--void-black) 0%,
        var(--deep-aubergine) 40%,
        var(--deep-aubergine) 60%,
        var(--void-black) 100%
    );
    z-index: -10;
    pointer-events: none;
}

/* --- Interstitial Filament Mesh --- */
.filament-mesh {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1s ease;
}

.filament-mesh.visible {
    opacity: 1;
}

.filament {
    fill: none;
    stroke: var(--bioluminescent-teal);
    stroke-width: 1;
    opacity: 0.08;
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    animation: filamentFlow 8s ease-in-out infinite alternate;
}

.filament:nth-child(2) { animation-delay: -1s; opacity: 0.06; }
.filament:nth-child(3) { animation-delay: -2s; opacity: 0.1; }
.filament:nth-child(4) { animation-delay: -3s; opacity: 0.07; }
.filament:nth-child(5) { animation-delay: -4s; opacity: 0.09; }
.filament:nth-child(6) { animation-delay: -0.5s; opacity: 0.11; }
.filament:nth-child(7) { animation-delay: -1.5s; opacity: 0.06; }
.filament:nth-child(8) { animation-delay: -2.5s; opacity: 0.08; }
.filament:nth-child(9) { animation-delay: -3.5s; opacity: 0.1; }
.filament:nth-child(10) { animation-delay: -4.5s; opacity: 0.07; }
.filament:nth-child(11) { animation-delay: -5s; opacity: 0.12; }
.filament:nth-child(12) { animation-delay: -5.5s; opacity: 0.06; }
.filament:nth-child(13) { animation-delay: -6s; opacity: 0.09; }
.filament:nth-child(14) { animation-delay: -6.5s; opacity: 0.08; }
.filament:nth-child(15) { animation-delay: -7s; opacity: 0.1; }
.filament:nth-child(16) { animation-delay: -7.5s; opacity: 0.07; }
.filament:nth-child(17) { animation-delay: -8s; opacity: 0.11; }

@keyframes filamentFlow {
    0% {
        stroke-dashoffset: 300;
    }
    50% {
        stroke-dashoffset: 0;
    }
    100% {
        stroke-dashoffset: -300;
    }
}

/* --- Breathing mesh animation --- */
@keyframes meshBreathe {
    0%, 100% { transform: scale(1) translateY(0); }
    50% { transform: scale(1.01) translateY(-5px); }
}

/* --- Floating Spores --- */
.spores-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
}

.spore {
    position: absolute;
    border-radius: 50%;
    background-color: var(--spore-gold);
    pointer-events: none;
}

@keyframes sporeDrift1 {
    0% { transform: translate(0, 0); }
    25% { transform: translate(30px, -50px); }
    50% { transform: translate(-20px, -100px); }
    75% { transform: translate(40px, -150px); }
    100% { transform: translate(0, -200px); }
}

@keyframes sporeDrift2 {
    0% { transform: translate(0, 0); }
    25% { transform: translate(-40px, -60px); }
    50% { transform: translate(25px, -120px); }
    75% { transform: translate(-30px, -180px); }
    100% { transform: translate(10px, -240px); }
}

@keyframes sporeDrift3 {
    0% { transform: translate(0, 0); }
    25% { transform: translate(50px, -40px); }
    50% { transform: translate(-35px, -80px); }
    75% { transform: translate(20px, -130px); }
    100% { transform: translate(-15px, -170px); }
}

@keyframes sporeDrift4 {
    0% { transform: translate(0, 0); }
    33% { transform: translate(-25px, -70px); }
    66% { transform: translate(35px, -140px); }
    100% { transform: translate(-10px, -210px); }
}

@keyframes sporeDrift5 {
    0% { transform: translate(0, 0); }
    33% { transform: translate(45px, -55px); }
    66% { transform: translate(-20px, -110px); }
    100% { transform: translate(30px, -165px); }
}

/* --- Heartbeat Blob --- */
.heartbeat {
    position: fixed;
    bottom: 8vh;
    right: 8vw;
    width: 80px;
    height: 80px;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.6s ease;
    pointer-events: none;
}

.heartbeat.visible {
    opacity: 1;
}

.heartbeat-inner {
    width: 100%;
    height: 100%;
    border-radius: 42% 58% 55% 45% / 48% 42% 58% 52%;
    background: radial-gradient(circle at 40% 40%, var(--coral-pulse), var(--deep-aubergine));
    animation: heartbeat 4s ease-in-out infinite;
}

@keyframes heartbeat {
    0%, 100% {
        transform: scale(1);
        background: radial-gradient(circle at 40% 40%, var(--coral-pulse), var(--deep-aubergine));
    }
    50% {
        transform: scale(1.06);
        background: radial-gradient(circle at 40% 40%, var(--coral-pulse), #3D2850);
    }
}

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

.hero-blob {
    position: relative;
    width: min(75vw, 650px);
    height: min(75vw, 650px);
    max-width: 650px;
    max-height: 650px;
    opacity: 0;
    transform: scale(0.01);
    transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.hero-blob-border {
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    clip-path: url(#hero-blob-clip);
    background: var(--lavender-membrane);
    opacity: 0.4;
    transition: opacity 0.3s ease, background-color 0.3s ease;
}

.hero-blob:hover .hero-blob-border {
    background: var(--bioluminescent-teal);
    opacity: 0.8;
}

.hero-blob-fill {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    clip-path: url(#hero-blob-clip);
    background: radial-gradient(
        ellipse at 45% 40%,
        rgba(240, 237, 229, 0.12) 0%,
        rgba(43, 29, 58, 0.85) 60%,
        var(--deep-aubergine) 100%
    );
}

.hero-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    clip-path: url(#hero-blob-clip);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 3;
}

.hero-domain {
    font-family: var(--font-mono);
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    font-weight: 400;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--spore-gold);
    opacity: 0;
    transition: opacity 0.6s ease, letter-spacing 0.4s ease;
}

.hero-domain.visible {
    opacity: 1;
}

.hero-tagline {
    font-family: var(--font-body);
    font-style: italic;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.5vw, 1.2rem);
    color: var(--lavender-membrane);
    margin-top: 0.8rem;
    opacity: 0;
    transition: opacity 0.6s ease 0.2s;
}

.hero-domain.visible ~ .hero-tagline {
    opacity: 1;
}

.hero-tagline.visible {
    opacity: 1;
}

/* --- Chambers Section --- */
.chambers {
    position: relative;
    z-index: 2;
    padding-bottom: 20vh;
}

/* --- Chamber Base --- */
.chamber {
    position: relative;
    opacity: 0;
    transform: translateY(60px);
    transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: default;
}

.chamber.revealed {
    opacity: 1;
    transform: translateY(0);
}

.chamber-blob-border {
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    opacity: 0.4;
    background: var(--lavender-membrane);
    transition: opacity 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.3s ease;
}

.chamber:hover .chamber-blob-border {
    background: var(--bioluminescent-teal);
    opacity: 0.8;
}

.chamber-blob-fill {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.chamber:hover {
    transform: translateY(0) scale(1.025);
}

.chamber-content {
    position: relative;
    z-index: 3;
    padding: clamp(2rem, 4vw, 3.5rem);
}

.chamber-label {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--bioluminescent-teal);
    display: block;
    margin-bottom: 1.2rem;
}

.chamber-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 1.1rem;
    line-height: 1.7;
    color: var(--membrane-white);
    max-width: 42ch;
    font-optical-sizing: auto;
}

/* --- Chamber 1: Membrane - tall narrow, left-of-center --- */
.chamber-membrane {
    width: min(380px, 80vw);
    min-height: 480px;
    margin: 8vh auto 0 12vw;
    clip-path: url(#membrane-blob-clip);
}

.chamber-membrane .chamber-blob-border {
    clip-path: url(#membrane-blob-clip);
}

.chamber-membrane .chamber-blob-fill {
    clip-path: url(#membrane-blob-clip);
    background: radial-gradient(
        ellipse at 50% 40%,
        rgba(212, 201, 232, 0.15) 0%,
        rgba(43, 29, 58, 0.9) 70%
    );
}

.chamber-membrane .chamber-content {
    clip-path: url(#membrane-blob-clip);
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 480px;
    padding: 3.5rem 2.5rem;
}

/* --- Chamber 2: Topology - wide low, right-of-center --- */
.chamber-topology {
    width: min(600px, 85vw);
    min-height: 380px;
    margin: -4vh 8vw 0 auto;
    clip-path: url(#topology-blob-clip);
}

.chamber-topology .chamber-blob-border {
    clip-path: url(#topology-blob-clip);
}

.chamber-topology .chamber-blob-fill {
    clip-path: url(#topology-blob-clip);
    background: radial-gradient(
        ellipse at 55% 45%,
        rgba(212, 201, 232, 0.12) 0%,
        rgba(43, 29, 58, 0.9) 70%
    );
}

.chamber-topology .chamber-content {
    clip-path: url(#topology-blob-clip);
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 380px;
    padding: 3rem 3rem;
}

/* --- Network Graph --- */
.network-graph {
    width: 180px;
    height: 110px;
    margin-top: 1.5rem;
}

.graph-edge {
    stroke: var(--bioluminescent-teal);
    stroke-width: 1;
    opacity: 0.4;
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
}

.chamber-topology.revealed .graph-edge {
    animation: drawEdge 2s ease forwards;
}

.graph-edge:nth-child(2) { animation-delay: 0.15s; }
.graph-edge:nth-child(3) { animation-delay: 0.3s; }
.graph-edge:nth-child(4) { animation-delay: 0.45s; }
.graph-edge:nth-child(5) { animation-delay: 0.6s; }
.graph-edge:nth-child(6) { animation-delay: 0.75s; }
.graph-edge:nth-child(7) { animation-delay: 0.9s; }

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

.graph-node {
    fill: var(--spore-gold);
    opacity: 0;
}

.chamber-topology.revealed .graph-node {
    animation: nodeAppear 0.5s ease forwards;
}

.graph-node:nth-child(8) { animation-delay: 0.3s; }
.graph-node:nth-child(9) { animation-delay: 0.5s; }
.graph-node:nth-child(10) { animation-delay: 0.7s; }
.graph-node:nth-child(11) { animation-delay: 0.9s; }
.graph-node:nth-child(12) { animation-delay: 1.1s; }

@keyframes nodeAppear {
    to {
        opacity: 0.8;
    }
}

/* --- Chamber 3: Surface - roughly circular, centered --- */
.chamber-surface {
    width: min(500px, 80vw);
    min-height: 480px;
    margin: 2vh auto 0;
    clip-path: url(#surface-blob-clip);
    transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chamber-surface.revealed {
    transform: scale(1);
}

.chamber-surface .chamber-blob-border {
    clip-path: url(#surface-blob-clip);
}

.chamber-surface .chamber-blob-fill {
    clip-path: url(#surface-blob-clip);
    background: radial-gradient(
        ellipse at 48% 45%,
        rgba(212, 201, 232, 0.14) 0%,
        rgba(43, 29, 58, 0.9) 70%
    );
}

.chamber-surface .chamber-content {
    clip-path: url(#surface-blob-clip);
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 480px;
    padding: 4rem 3rem;
}

/* --- Chamber 4: Signal - bottom --- */
.chamber-signal {
    width: min(550px, 85vw);
    min-height: 320px;
    margin: 4vh auto 0;
    clip-path: url(#signal-blob-clip);
}

.chamber-signal .chamber-blob-border {
    clip-path: url(#signal-blob-clip);
}

.chamber-signal .chamber-blob-fill {
    clip-path: url(#signal-blob-clip);
    background: radial-gradient(
        ellipse at 50% 50%,
        rgba(94, 207, 177, 0.08) 0%,
        rgba(43, 29, 58, 0.9) 70%
    );
}

.chamber-signal .chamber-content {
    clip-path: url(#signal-blob-clip);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 320px;
    padding: 3rem 2.5rem;
    text-align: center;
}

.signal-statement {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: clamp(2.8rem, 6vw, 5.2rem);
    letter-spacing: -0.02em;
    color: var(--bioluminescent-teal);
    line-height: 1.1;
}

/* Signal pulse animation on reveal */
.chamber-signal.pulse-once {
    animation: signalPulse 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes signalPulse {
    0% { transform: translateY(0) scale(1); }
    50% { transform: translateY(0) scale(1.08); }
    100% { transform: translateY(0) scale(1); }
}

/* --- Click Ripple --- */
.ripple {
    position: absolute;
    border-radius: 50%;
    border: 2px solid var(--bioluminescent-teal);
    opacity: 0.2;
    pointer-events: none;
    animation: rippleExpand 0.5s ease-out forwards;
    z-index: 10;
}

@keyframes rippleExpand {
    0% {
        width: 0;
        height: 0;
        opacity: 0.2;
    }
    100% {
        width: 200px;
        height: 200px;
        opacity: 0;
    }
}

/* --- Pale Lilac Background Blobs --- */
body::after {
    content: '';
    position: fixed;
    top: 10%;
    left: -10%;
    width: 60%;
    height: 50%;
    background: radial-gradient(ellipse, var(--pale-lilac), transparent 70%);
    opacity: 0.06;
    border-radius: 50%;
    z-index: -5;
    pointer-events: none;
    animation: bgBlobFloat1 20s ease-in-out infinite alternate;
}

@keyframes bgBlobFloat1 {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 30px) scale(1.1); }
}

/* Second background blob via an extra element */
.bg-blob-2 {
    position: fixed;
    bottom: 5%;
    right: -15%;
    width: 55%;
    height: 45%;
    background: radial-gradient(ellipse, var(--pale-lilac), transparent 70%);
    opacity: 0.05;
    border-radius: 50%;
    z-index: -5;
    pointer-events: none;
    animation: bgBlobFloat2 25s ease-in-out infinite alternate;
}

@keyframes bgBlobFloat2 {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(-40px, -20px) scale(1.05); }
}

/* --- Responsive Adjustments --- */
@media (max-width: 768px) {
    .chamber-membrane {
        margin: 8vh auto 0;
        width: min(340px, 88vw);
    }

    .chamber-topology {
        margin: 4vh auto 0;
        width: min(360px, 88vw);
    }

    .chamber-surface {
        width: min(340px, 88vw);
    }

    .chamber-signal {
        width: min(340px, 88vw);
    }

    .hero-blob {
        width: min(85vw, 400px);
        height: min(85vw, 400px);
    }

    .heartbeat {
        bottom: 4vh;
        right: 4vw;
        width: 60px;
        height: 60px;
    }
}

@media (max-width: 480px) {
    .chamber-content {
        padding: clamp(1.5rem, 3vw, 2.5rem);
    }

    .chamber-text {
        font-size: 1rem;
    }

    .signal-statement {
        font-size: clamp(2rem, 8vw, 3.5rem);
    }
}
