/* ============================================
   iggi.boo — Wabi-sabi Moss Terrarium
   ============================================ */

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

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

body {
    background-color: #0A120C;
    color: #A8B89C;
    font-family: 'Newsreader', serif;
    font-weight: 300;
    line-height: 2.0;
    font-size: clamp(0.9rem, 1.1vw, 1.05rem);
    overflow-x: hidden;
    min-height: 500vh;
}

/* --- Terrarium Vignette --- */
.terrarium-vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-shadow: inset 0 0 120px 60px rgba(10, 18, 12, 0.5);
    pointer-events: none;
    z-index: 20;
}

/* --- Spore Particle Layer --- */
.spore-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    overflow: hidden;
}

.spore {
    position: absolute;
    border-radius: 50%;
    background: #C4D4B0;
    filter: blur(1px);
    mix-blend-mode: screen;
    animation: spore-drift linear infinite;
}

@keyframes spore-drift {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: var(--spore-opacity);
    }
    25% {
        transform: translate(calc(var(--spore-dx) * 0.3), calc(var(--spore-dy) * -0.25)) scale(1.1);
    }
    50% {
        transform: translate(calc(var(--spore-dx) * 0.6), calc(var(--spore-dy) * -0.5)) scale(0.9);
        opacity: calc(var(--spore-opacity) * 1.3);
    }
    75% {
        transform: translate(calc(var(--spore-dx) * 0.8), calc(var(--spore-dy) * -0.75)) scale(1.05);
    }
    100% {
        transform: translate(var(--spore-dx), var(--spore-dy)) scale(1);
        opacity: 0;
    }
}

/* --- Stem Navigation --- */
.stem-nav {
    position: fixed;
    left: 24px;
    top: 20vh;
    height: 60vh;
    width: 20px;
    z-index: 15;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
}

.stem-line {
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    width: 2px;
    height: 100%;
    background: #2A3A28;
    border-radius: 1px;
    overflow: hidden;
}

.stem-fill {
    width: 100%;
    height: 0%;
    background: #7BA370;
    border-radius: 1px;
    transition: height 0.8s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.stem-node {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4A6741;
    position: relative;
    z-index: 2;
    transition: background 0.6s ease, transform 0.6s ease;
    cursor: pointer;
}

.stem-node.active {
    background: #7BA370;
    animation: spore-pulse 3s ease-in-out infinite;
}

@keyframes spore-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(123, 163, 112, 0.4);
    }
    50% {
        transform: scale(1.3);
        box-shadow: 0 0 8px 2px rgba(123, 163, 112, 0.2);
    }
}

/* --- Phase I: The Glass --- */
.phase-glass {
    position: relative;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.phase-glass-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 50% 30%, #1A2A1C, #0A120C);
    z-index: 0;
}

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

.domain-title {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: clamp(2.5rem, 6vw, 5rem);
    letter-spacing: 0.12em;
    text-transform: lowercase;
    color: #C4D4B0;
    opacity: 0;
    transition: opacity 2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

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

.domain-hangul {
    font-family: 'Nanum Myeongjo', serif;
    font-weight: 400;
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    color: #8B9E80;
    opacity: 0;
    margin-top: 0.5em;
    transition: opacity 1.5s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.domain-hangul.visible {
    opacity: 0.6;
}

/* Kintsugi lead line below title */
.kintsugi-lead {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 200px;
    z-index: 2;
}

/* --- Hangul Watermarks --- */
.hangul-watermark {
    position: absolute;
    font-family: 'Nanum Myeongjo', serif;
    font-weight: 400;
    font-size: clamp(4rem, 12vw, 10rem);
    color: #A8B89C;
    opacity: 0.04;
    pointer-events: none;
    z-index: 1;
    user-select: none;
}

.wm-1 {
    top: 15%;
    right: 8%;
}

.wm-2 {
    bottom: 20%;
    left: 5%;
}

.wm-3 {
    top: 30%;
    left: 10%;
}

/* --- Kintsugi Connectors --- */
.kintsugi-connector {
    display: block;
    width: 2px;
    margin: 0 auto;
    height: 150px;
    position: relative;
    z-index: 2;
}

.kintsugi-1 {
    height: 200px;
    width: 100px;
}

.kintsugi-2,
.kintsugi-3 {
    height: 150px;
    width: 100px;
}

.kintsugi-4 {
    height: 200px;
    width: 100px;
}

.kintsugi-path {
    stroke: #C4A86C;
    stroke-dasharray: var(--path-length, 500);
    stroke-dashoffset: var(--path-length, 500);
    transition: stroke-dashoffset 2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

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

/* --- Phase II: The Colonies --- */
.phase-colonies {
    position: relative;
    padding: 8vh 0;
}

.colony {
    position: relative;
    max-width: 680px;
    padding: 4rem 3rem;
    background: #1A2A1C;
    backdrop-filter: blur(1px);
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 1.8s cubic-bezier(0.25, 0.1, 0.25, 1),
                transform 1.8s cubic-bezier(0.25, 0.1, 0.25, 1);
    overflow: hidden;
}

.colony.visible {
    opacity: 1;
    transform: translateY(0);
}

.colony-inner {
    position: relative;
    z-index: 2;
}

/* Colony 1 — offset right */
.colony-1 {
    margin-left: 15%;
    margin-right: auto;
    border-radius: 60% 40% 55% 45% / 45% 60% 40% 55%;
    clip-path: polygon(5% 0%, 95% 3%, 98% 45%, 100% 92%, 90% 100%, 8% 97%, 0% 55%, 2% 8%);
}

/* Colony 2 — offset left */
.colony-2 {
    margin-left: auto;
    margin-right: 12%;
    margin-top: 12vh;
    border-radius: 45% 55% 40% 60% / 55% 40% 60% 45%;
    clip-path: polygon(3% 5%, 92% 0%, 100% 48%, 97% 95%, 85% 100%, 5% 98%, 0% 50%, 2% 12%);
}

/* Colony 3 — offset slightly right-center */
.colony-3 {
    margin-left: 20%;
    margin-right: auto;
    margin-top: 14vh;
    border-radius: 55% 45% 60% 40% / 40% 55% 45% 60%;
    clip-path: polygon(8% 2%, 96% 5%, 100% 52%, 95% 98%, 88% 100%, 3% 95%, 0% 45%, 4% 6%);
}

/* Moss texture border effect via pseudo-element */
.colony::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    background: repeating-linear-gradient(
        135deg,
        #4A6741 0px,
        transparent 1px,
        transparent 4px,
        #7BA370 5px,
        transparent 6px,
        transparent 10px,
        #2A3A28 11px,
        transparent 12px,
        transparent 18px
    );
    opacity: 0.3;
    z-index: 0;
    pointer-events: none;
    clip-path: inherit;
}

.colony-heading {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 500;
    font-size: clamp(1.6rem, 3.5vw, 2.8rem);
    letter-spacing: 0.08em;
    text-transform: lowercase;
    color: #C4D4B0;
    margin-bottom: 1.5rem;
    line-height: 1.3;
}

.colony-text {
    font-family: 'Newsreader', serif;
    font-weight: 300;
    font-size: clamp(0.9rem, 1.1vw, 1.05rem);
    line-height: 2.0;
    color: #A8B89C;
    margin-bottom: 1rem;
}

.colony-hangul {
    font-family: 'Nanum Myeongjo', serif;
    font-weight: 400;
    color: #8B9E80;
    font-size: clamp(0.85rem, 1vw, 1rem);
    opacity: 0.7;
    margin-top: 1rem;
}

/* --- Haeckel SVG Decorations --- */
.haeckel-svg {
    position: absolute;
    width: 200px;
    height: 200px;
    z-index: 0;
    animation: slow-drift 90s linear infinite;
}

.haeckel-frond {
    top: -20px;
    right: -30px;
}

.haeckel-rosette {
    bottom: -40px;
    left: -20px;
}

.haeckel-rhizoid {
    top: -30px;
    right: -40px;
}

@keyframes slow-drift {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- Phase III: The Network --- */
.phase-network {
    position: relative;
    min-height: 100vh;
    padding: 10vh 5% 15vh;
    background: #0A120C;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.mycelium-map {
    width: 90%;
    max-width: 1000px;
    height: auto;
    position: relative;
    z-index: 2;
}

.mycelium-path {
    stroke-dasharray: var(--path-length, 600);
    stroke-dashoffset: var(--path-length, 600);
    transition: stroke-dashoffset 3s cubic-bezier(0.25, 0.1, 0.25, 1);
}

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

.mycelium-nodes circle {
    opacity: 0;
    transition: opacity 1.5s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.mycelium-nodes.visible circle {
    opacity: 0.5;
}

.network-labels {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
}

.node-label {
    position: absolute;
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: clamp(0.8rem, 1.4vw, 1.2rem);
    letter-spacing: 0.08em;
    text-transform: lowercase;
    color: #C4D4B0;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 2s cubic-bezier(0.25, 0.1, 0.25, 1),
                transform 2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.node-label.visible {
    opacity: 0.7;
    transform: translateY(0);
}

.node-label:hover {
    color: #D8E8D0;
}

.network-close {
    margin-top: 8vh;
    text-align: center;
    position: relative;
    z-index: 2;
}

.domain-return {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: clamp(2rem, 4vw, 3.5rem);
    letter-spacing: 0.12em;
    text-transform: lowercase;
    color: #C4D4B0;
    opacity: 0;
    transition: opacity 2.5s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.domain-return.visible {
    opacity: 0.3;
}

/* --- Condensation Droplets --- */
.condensation-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 11;
}

.droplet {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(200, 220, 200, 0.15), transparent);
    opacity: 0.5;
}

/* Spore Dust warm accent for decorative elements */
.wm-2 {
    color: #E8DCC8;
}

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

::-webkit-scrollbar-track {
    background: #0A120C;
}

::-webkit-scrollbar-thumb {
    background: #2A3A28;
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: #4A6741;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .stem-nav {
        left: 12px;
    }

    .colony {
        margin-left: 5% !important;
        margin-right: 5% !important;
        padding: 3rem 2rem;
    }

    .colony-1,
    .colony-2,
    .colony-3 {
        clip-path: polygon(3% 2%, 97% 2%, 98% 98%, 2% 98%);
        border-radius: 30% 25% 30% 25% / 25% 30% 25% 30%;
    }

    .haeckel-svg {
        width: 120px;
        height: 120px;
        opacity: 0.5;
    }

    .hangul-watermark {
        font-size: clamp(3rem, 10vw, 6rem);
    }

    .network-labels .node-label {
        font-size: clamp(0.7rem, 2.5vw, 1rem);
    }
}

@media (max-width: 480px) {
    .stem-nav {
        display: none;
    }

    .colony {
        padding: 2.5rem 1.5rem;
    }
}
