/* =============================================
   lungless.dev — Translucent Frost Membrane
   Colors: #2c3440, #4a5568, #7eb8d4, #8fa3b8, #a3c4d9, #c9a8b8, #d0dbe6, #e8ecf0, #f4f7fa
   Fonts: IBM Plex Mono, Space Mono, Cousine
   ============================================= */

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

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

body {
    font-family: 'Space Mono', monospace;
    color: #4a5568;
    background: #e8ecf0;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Texture Overlay (Layer 3) --- */
#texture-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    mix-blend-mode: overlay;
    opacity: 0.06;
    pointer-events: none;
    z-index: 1000;
    background-image:
        radial-gradient(ellipse at 20% 30%, rgba(255,255,255,0.4) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 60%, #a3c4d9 0%, transparent 40%),
        radial-gradient(ellipse at 50% 80%, #d0dbe6 0%, transparent 60%),
        radial-gradient(circle at 30% 50%, rgba(126,184,212,0.15) 0%, transparent 30%),
        radial-gradient(circle at 80% 20%, rgba(201,168,184,0.1) 0%, transparent 25%);
    background-size: 100% 100%;
}

/* --- Split Container --- */
#split-container {
    position: relative;
    width: 100vw;
    min-height: 600vh;
    display: flex;
    --split-left: 50%;
    --split-right: 50%;
    --membrane-blur: 12px;
    --membrane-opacity: 0;
    --membrane-wave: 0;
    --membrane-glow-opacity: 0;
    --stage: 1;
}

/* --- Left Panel — The Membrane (Text) --- */
#panel-left {
    width: var(--split-left);
    min-height: 600vh;
    background: rgba(232, 236, 240, 0.85);
    position: relative;
    z-index: 10;
    transition: width 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

/* --- Right Panel — The Skin (Visuals) --- */
#panel-right {
    width: var(--split-right);
    min-height: 600vh;
    position: relative;
    z-index: 5;
    transition: width 1.2s cubic-bezier(0.34, 1.56, 0.64, 1),
                background 2s ease;
    overflow: hidden;
    background: rgba(200, 215, 230, 0.4);
}

#panel-right.stage-2-active {
    background: #d0dbe6;
}

#panel-right.stage-3-active {
    background: rgba(180, 200, 220, 0.6);
}

#panel-right.stage-4-active {
    background: rgba(190, 208, 225, 0.5);
}

#panel-right.stage-5-active {
    background: rgba(232, 236, 240, 0.4);
}

/* --- Stages (Left Panel) --- */
.stage {
    min-height: 120vh;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 40px 0 80px;
    position: relative;
}

.stage-content {
    max-width: 100%;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1.2s ease, transform 1.2s ease;
}

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

/* Stage 5 dissolve effect */
.stage-5.dissolving .stage-content {
    opacity: 0.2;
    transition: opacity 2s ease;
}

.stage-5.dissolving .headline-closing {
    opacity: 1 !important;
}

/* --- Stages (Right Panel) --- */
.stage-right {
    min-height: 120vh;
    position: relative;
}

/* --- Headlines — IBM Plex Mono Light --- */
.headline-primary {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: clamp(2.4rem, 5.5vw, 4.8rem);
    letter-spacing: 0.12em;
    text-transform: lowercase;
    color: #2c3440;
    line-height: 1.2;
    margin-bottom: 1.2rem;
}

.headline-sub {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: clamp(1rem, 1.8vw, 1.4rem);
    letter-spacing: 0.08em;
    text-transform: lowercase;
    color: #4a5568;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.8s ease 0.8s, transform 0.8s ease 0.8s;
}

.stage.visible .headline-sub {
    opacity: 1;
    transform: translateY(0);
}

.headline-closing {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    letter-spacing: 0.12em;
    text-transform: lowercase;
    color: #2c3440;
    line-height: 1.3;
}

/* --- Body Text — Space Mono --- */
.body-text {
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.1vw, 1.15rem);
    line-height: 2.0;
    letter-spacing: 0.04em;
    color: #4a5568;
    max-width: 38ch;
}

.body-text.large {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: clamp(1.2rem, 1.6vw, 1.8rem);
    line-height: 1.8;
    max-width: 32ch;
}

/* --- Ambient Labels — Cousine --- */
.ambient-label {
    font-family: 'Cousine', monospace;
    font-weight: 400;
    font-size: 0.7rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #8fa3b8;
    opacity: 0.6;
}

.vertical-text {
    display: block;
    margin-bottom: 2.5rem;
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

.stage-3 .stage-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
}

/* --- Central Membrane Divider --- */
#membrane-divider {
    position: fixed;
    top: 0;
    left: var(--split-left);
    width: 60px;
    height: 100vh;
    z-index: 50;
    pointer-events: none;
    transform: translateX(-50%);
    transition: left 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    backdrop-filter: blur(var(--membrane-blur));
    -webkit-backdrop-filter: blur(var(--membrane-blur));
    border-left: 1px solid rgba(255, 255, 255, 0.15);
    border-right: 1px solid rgba(255, 255, 255, 0.15);
}

#membrane-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: var(--membrane-opacity);
    transition: opacity 1.5s ease;
}

#membrane-line {
    position: absolute;
    top: 0;
    left: 50%;
    width: 1px;
    height: 100%;
    background: #7eb8d4;
    transform: translateX(-50%);
    opacity: var(--membrane-opacity);
    transition: opacity 1.5s ease;
}

#membrane-glow {
    position: absolute;
    top: 0;
    left: 50%;
    width: 40px;
    height: 100%;
    transform: translateX(-50%);
    background: radial-gradient(ellipse at center, rgba(201, 168, 184, 0.15) 0%, transparent 70%);
    opacity: var(--membrane-glow-opacity);
    transition: opacity 1.5s ease;
}

/* --- Stage Indicators --- */
#stage-indicators {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(126, 184, 212, 0.25);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: background 0.6s ease, opacity 0.6s ease;
}

.indicator.active {
    background: #7eb8d4;
}

/* --- Bubble Layer 1 — CSS Gradient Spheres --- */
#bubble-layer-1 {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.bubble-css {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
    will-change: transform;
}

@keyframes bubbleFloat {
    0% {
        transform: translateY(0) translateX(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-120vh) translateX(var(--drift-x, 15px));
        opacity: 0;
    }
}

/* --- Bubble Layer 2 — SVG Membrane Circles --- */
#bubble-layer-2 {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
}

.bubble-svg circle {
    fill: none;
    stroke: rgba(255, 255, 255, 0.3);
    stroke-width: 0.5;
}

/* --- Ambient Organisms --- */
#ambient-organisms {
    position: absolute;
    top: 0;
    left: 0;
    width: 80px;
    height: 100%;
    pointer-events: none;
}

.organism-dot {
    position: absolute;
    border-radius: 50%;
    background: #c9a8b8;
    animation: organismPulse 6s ease-in-out infinite;
}

@keyframes organismPulse {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 0.5; }
}

/* --- Pearl white highlight accents --- */
.bubble-css::after {
    content: '';
    position: absolute;
    top: 15%;
    left: 20%;
    width: 30%;
    height: 30%;
    border-radius: 50%;
    background: radial-gradient(circle, #f4f7fa 0%, transparent 70%);
    opacity: 0.4;
}

/* --- Oxygen Blue accents on SVG bubbles --- */
#bubble-layer-2 circle {
    stroke: #a3c4d9;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    #split-container {
        flex-direction: column;
        --split-left: 100%;
        --split-right: 100%;
    }

    #panel-left, #panel-right {
        width: 100% !important;
    }

    #membrane-divider {
        display: none;
    }

    #stage-indicators {
        right: 16px;
    }

    .stage {
        padding: 0 24px;
        min-height: 100vh;
    }
}

/* --- Dissolving state for stage 5 --- */
.dissolving-membrane #membrane-line {
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    width: 60px;
    background: rgba(232, 236, 240, 0.2);
    transition: all 2s ease;
}

/* --- Breathing membrane animation --- */
@keyframes membraneBreathe {
    0%, 100% {
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }
    50% {
        backdrop-filter: blur(24px);
        -webkit-backdrop-filter: blur(24px);
    }
}

#membrane-divider.breathing {
    animation: membraneBreathe 3s ease-in-out infinite;
}
