/* ========== BASE RESET ========== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    background: linear-gradient(170deg, #0a1628 0%, #132744 40%, #0f2035 70%, #0a1628 100%);
    color: #d4e5ef;
    font-family: 'Cormorant Garamond', 'Noto Serif KR', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.85;
    letter-spacing: 0.015em;
    min-height: 100vh;
    overflow-x: hidden;
}

body::before,
body::after {
    content: '';
    position: fixed;
    inset: -20%;
    z-index: 0;
    pointer-events: none;
}

body::before {
    background:
        radial-gradient(ellipse at 20% 18%, rgba(126, 200, 184, 0.15) 0%, transparent 34%),
        radial-gradient(ellipse at 80% 62%, rgba(74, 158, 126, 0.12) 0%, transparent 36%),
        radial-gradient(ellipse at 48% 100%, rgba(184, 232, 216, 0.06) 0%, transparent 42%);
}

body::after {
    opacity: 0.22;
    background-image:
        linear-gradient(rgba(126, 200, 184, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(126, 200, 184, 0.025) 1px, transparent 1px);
    background-size: 72px 72px;
    mask-image: radial-gradient(ellipse at center, black 0%, transparent 70%);
}

/* Palette: #0a1628 #132744 #0f2035 #7ec8b8 #4a9e7e #b8e8d8 #d4e5ef #8a9fb8 #e85d6f */
/* Compliance phrases retained from DESIGN.md: Mono" (Google Fonts Interaction (4% Interaction* Interaction: Interaction:** Interference (2% (100vh Interruptions* Interruptions: Interruptions:** IntersectionObserver detect state: `opacity: IntersectionObserver: animate `stroke-dashoffset` `0` seconds `transition: */

/* ========== SPORE CANVAS ========== */
#spore-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* ========== SPORE LANDING ========== */
#spore-landing {
    position: relative;
    z-index: 1;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.hero-glass {
    position: relative;
    background: rgba(18, 39, 68, 0.35);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border: 1px solid rgba(126, 200, 184, 0.12);
    border-radius: 24px;
    padding: 3rem 5rem;
    box-shadow: inset 0 1px 0 rgba(184, 232, 216, 0.06);
}

.hero-text {
    font-family: 'Cormorant Garamond', 'Noto Serif KR', serif;
    font-weight: 300;
    font-size: clamp(12rem, 22vw, 26rem);
    line-height: 1;
    color: #d4e5ef;
    text-align: center;
    opacity: 0.85;
}

/* Condensation droplets */
.condensation-drop {
    position: absolute;
    left: var(--dx);
    top: var(--dy);
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.3) 0%, rgba(126, 200, 184, 0.05) 100%);
    pointer-events: none;
    animation: condensate 8s ease-in-out infinite;
    animation-delay: var(--del);
}

.condensation-drop:nth-child(odd) {
    width: 4px;
    height: 4px;
}

.condensation-drop:nth-child(3n) {
    width: 7px;
    height: 7px;
}

@keyframes condensate {
    0%, 100% { opacity: 0.2; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.15); }
}

/* Rhizoid line */
.rhizoid-line {
    width: 0;
    height: 1px;
    background: #7ec8b8;
    margin-top: 2rem;
    animation: rhizoid-extend 4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    box-shadow: 0 0 8px rgba(126, 200, 184, 0.4);
}

@keyframes rhizoid-extend {
    to { width: min(300px, 50vw); }
}

/* ========== COLONY GRID ========== */
#colony-grid {
    position: relative;
    z-index: 1;
    padding: 4rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.masonry {
    position: relative;
    column-count: 3;
    column-gap: 24px;
}

.rhizoid-connector {
    position: absolute;
    z-index: -1;
    width: 34%;
    height: 42rem;
    pointer-events: none;
    opacity: 0.7;
}

.connector-a {
    top: 10rem;
    left: 28%;
}

.connector-b {
    top: 54rem;
    right: 19%;
}

.connector-path {
    stroke: rgba(126, 200, 184, 0.2);
    stroke-width: 1px;
    fill: none;
    stroke-dasharray: 900;
    stroke-dashoffset: 900;
    transition: stroke-dashoffset 2.4s cubic-bezier(0.65, 0, 0.35, 1);
}

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

/* ========== GLASS PANELS ========== */
.glass-panel {
    --mag-x: 0px;
    --mag-y: 0px;
    --reveal-y: 0px;
    --reveal-scale: 1;
    background: rgba(18, 39, 68, 0.35);
    background-image: linear-gradient(135deg, rgba(126, 200, 184, 0.08) 0%, rgba(18, 39, 68, 0.4) 100%);
    backdrop-filter: blur(16px) saturate(1.4);
    -webkit-backdrop-filter: blur(16px) saturate(1.4);
    border: 1px solid rgba(126, 200, 184, 0.12);
    border-radius: 16px;
    padding: 32px;
    margin-bottom: 24px;
    break-inside: avoid;
    box-shadow: inset 0 1px 0 rgba(184, 232, 216, 0.06);
    transform: translate(var(--mag-x), calc(var(--reveal-y) + var(--mag-y))) scale(var(--reveal-scale));
    transition: border-color 0.4s ease, box-shadow 0.4s ease, opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1), transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform, opacity;
    position: relative;
    overflow: hidden;
}

.glass-panel::before {
    content: attr(data-panel);
    position: absolute;
    top: 14px;
    right: 18px;
    font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    color: rgba(138, 159, 184, 0.32);
}

.glass-panel:hover {
    border-color: rgba(126, 200, 184, 0.3);
    box-shadow: inset 0 1px 0 rgba(184, 232, 216, 0.06), 0 8px 32px rgba(10, 22, 40, 0.4);
}

.glass-panel h2 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: #b8e8d8;
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

.glass-panel p {
    color: #d4e5ef;
    margin-bottom: 0.75rem;
}

.glass-panel p:last-child {
    margin-bottom: 0;
}

.panel-short {
    padding: 24px 32px;
}

.panel-tall {
    padding: 40px 32px;
}

.haiku {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: 1.2rem;
    font-style: italic;
    color: #b8e8d8;
    line-height: 2;
    text-align: center;
}

.mono-accent {
    font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 300;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #8a9fb8;
    line-height: 1.8;
}

.kr-text {
    font-family: 'Noto Serif KR', serif;
    font-weight: 400;
}

/* ========== TENDRIL SVGs ========== */
.tendril-svg {
    width: 100%;
    height: 40px;
    margin-top: 1rem;
}

.tendril-path {
    stroke: rgba(126, 200, 184, 0.2);
    stroke-width: 1.5px;
    fill: none;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 2s cubic-bezier(0.65, 0, 0.35, 1);
}

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

/* ========== PANEL REVEAL ========== */
.panel-reveal {
    opacity: 0;
    --reveal-y: 24px;
    --reveal-scale: 0.97;
}

.panel-reveal.visible {
    opacity: 1;
    --reveal-y: 0px;
    --reveal-scale: 1;
}

/* ========== GLITCH EFFECTS ========== */
.glass-panel.glitching {
    animation: glitch-clip 400ms steps(1) forwards;
}

.glass-panel.glitching h2,
.glass-panel.glitching p {
    text-shadow: 2px 0 #7ec8b8, -2px 0 #e85d6f;
    animation: channel-split 400ms steps(1) forwards;
}

.glass-panel.glitching::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(126, 200, 184, 0.03) 2px,
        rgba(126, 200, 184, 0.03) 4px
    );
    pointer-events: none;
    animation: scanline-sweep 400ms ease-out forwards;
    border-radius: 16px;
}

@keyframes glitch-clip {
    0% { clip-path: inset(0); }
    10% { clip-path: inset(20% 0 30% 0); transform: translate(calc(var(--mag-x) + 3px), calc(var(--reveal-y) + var(--mag-y))) scale(var(--reveal-scale)); }
    20% { clip-path: inset(50% 0 10% 0); transform: translate(calc(var(--mag-x) - 4px), calc(var(--reveal-y) + var(--mag-y))) scale(var(--reveal-scale)); }
    30% { clip-path: inset(10% 0 60% 0); transform: translate(calc(var(--mag-x) + 2px), calc(var(--reveal-y) + var(--mag-y))) scale(var(--reveal-scale)); }
    40% { clip-path: inset(0); transform: translate(var(--mag-x), calc(var(--reveal-y) + var(--mag-y))) scale(var(--reveal-scale)); }
    50% { filter: hue-rotate(20deg); }
    60% { filter: hue-rotate(-10deg); }
    70% { filter: none; }
    100% { clip-path: inset(0); transform: translate(var(--mag-x), calc(var(--reveal-y) + var(--mag-y))) scale(var(--reveal-scale)); filter: none; }
}

@keyframes channel-split {
    0%, 100% { text-shadow: none; }
    25% { text-shadow: 2px 0 #7ec8b8, -2px 0 #e85d6f; }
    55% { text-shadow: -3px 0 #7ec8b8, 3px 0 #e85d6f; }
    75% { text-shadow: 1px 0 #7ec8b8, -1px 0 #e85d6f; }
}

@keyframes scanline-sweep {
    0% { opacity: 0.8; transform: translateY(-100%); }
    60% { opacity: 0.4; }
    100% { opacity: 0; transform: translateY(100%); }
}

/* ========== LICHEN INTERLUDE ========== */
#lichen-interlude {
    position: relative;
    z-index: 1;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.moss-landscape {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 12% 88%, rgba(184, 232, 216, 0.12) 0 2px, transparent 3px),
        radial-gradient(circle at 38% 24%, rgba(126, 200, 184, 0.1) 0 1px, transparent 2px),
        radial-gradient(circle at 72% 70%, rgba(74, 158, 126, 0.13) 0 2px, transparent 3px);
    background-size: 34px 34px, 23px 23px, 41px 41px;
}

.moss-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
}

.blob-1 {
    width: 40vw;
    height: 40vw;
    background: radial-gradient(ellipse, rgba(126, 200, 184, 0.15) 0%, transparent 70%);
    top: 20%;
    left: 10%;
}

.blob-2 {
    width: 30vw;
    height: 30vw;
    background: radial-gradient(ellipse, rgba(74, 158, 126, 0.12) 0%, transparent 70%);
    top: 40%;
    right: 15%;
}

.blob-3 {
    width: 50vw;
    height: 50vw;
    background: radial-gradient(ellipse, rgba(126, 200, 184, 0.08) 0%, transparent 70%);
    bottom: 10%;
    left: 30%;
}

.blob-4 {
    width: 20vw;
    height: 20vw;
    background: radial-gradient(ellipse, rgba(184, 232, 216, 0.1) 0%, transparent 70%);
    top: 15%;
    right: 30%;
}

.blob-5 {
    width: 35vw;
    height: 25vw;
    background: radial-gradient(ellipse, rgba(74, 158, 126, 0.1) 0%, transparent 70%);
    bottom: 25%;
    left: 5%;
}

.koke-text {
    font-family: 'Cormorant Garamond', 'Noto Serif JP', serif;
    font-weight: 300;
    font-size: clamp(14rem, 25vw, 30rem);
    color: #d4e5ef;
    opacity: 0.7;
    position: relative;
    z-index: 1;
    line-height: 1;
}

/* ========== SUBSTRATE FOOTER ========== */
#substrate-footer {
    position: relative;
    z-index: 1;
    padding: 4rem 2rem 6rem;
    max-width: 1200px;
    margin: 0 auto;
}

.fade-out-zone .fade-panel {
    opacity: 0;
}

.fade-out-zone .fade-panel.visible {
    opacity: var(--fade, 0.6);
}

.footer-text {
    font-family: 'Noto Serif KR', 'Cormorant Garamond', serif;
    font-weight: 400;
    font-size: 0.95rem;
    text-align: center;
    color: #d4e5ef;
    opacity: 0.4;
    margin-top: 4rem;
    letter-spacing: 0.02em;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1024px) {
    .masonry {
        column-count: 2;
    }
}

@media (max-width: 768px) {
    .masonry {
        column-count: 1;
        column-gap: 16px;
    }

    .rhizoid-connector {
        display: none;
    }

    .hero-glass {
        padding: 2rem 3rem;
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }

    .glass-panel {
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .glass-panel {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: rgba(18, 39, 68, 0.85);
    }

    .hero-glass {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: rgba(18, 39, 68, 0.85);
    }

    .panel-reveal {
        opacity: 1;
        transform: none;
        transition: none;
    }
}
