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

:root {
    --midnight-heartwood: #0d1127;
    --twilight-sapwood: #1a1a2e;
    --bark-brown: #3d2b1f;
    --aged-linen: #f5f0e8;
    --dried-bark: #e8e0d0;
    --moss-canopy: #7a8b6d;
    --morning-sap: #c8a96e;
    --moonlit-bark: #c8bfa8;
    --soil-dark: #2a1f14;
    --scroll: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--aged-linen);
    color: var(--bark-brown);
    font-family: 'EB Garamond', serif;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.85;
    letter-spacing: 0.01em;
    overflow: hidden;
    margin-left: 8vw;
    margin-right: 16vw;
}

body.scrollable {
    overflow-y: auto;
}

/* === Watermark === */
.watermark {
    position: fixed;
    top: -10vh;
    right: -15vw;
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(40rem, 70vw, 60rem);
    font-weight: 300;
    color: rgba(61, 43, 31, 0.025);
    line-height: 1;
    pointer-events: none;
    z-index: -2;
    will-change: transform;
}

/* === Bubble Canvas === */
#sap-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

/* === Root Arrival === */
.arrival {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.trunk {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 70vh;
    display: flex;
    align-items: flex-start;
}

.trunk-line {
    width: 2px;
    height: 0;
    background: linear-gradient(to top, var(--bark-brown), var(--moss-canopy));
    animation: grow-trunk 3s cubic-bezier(0.16, 1, 0.3, 1) 0.5s forwards;
    position: relative;
}

.trunk-line::before,
.trunk-line::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 1.5px;
    height: 0;
    background: var(--moss-canopy);
    transform-origin: bottom center;
    animation: grow-branch 1s ease 3.5s forwards;
}

.trunk-line::before {
    transform: rotate(-30deg);
}

.trunk-line::after {
    transform: rotate(40deg);
}

@keyframes grow-trunk {
    to { height: 70vh; }
}

@keyframes grow-branch {
    to { height: 30px; }
}

.arrival-text {
    position: relative;
    text-align: center;
    z-index: 1;
    margin-top: -15vh;
}

.hero-namu {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: clamp(8rem, 18vw, 22rem);
    color: var(--bark-brown);
    line-height: 1;
    opacity: 0;
    animation: fade-in 1.5s ease 3.5s forwards;
}

.hero-quest {
    font-family: 'EB Garamond', serif;
    font-style: italic;
    font-size: clamp(1.3rem, 3vw, 3.5rem);
    color: var(--moss-canopy);
    opacity: 0;
    animation: fade-in 1s ease 4.9s forwards;
}

@keyframes fade-in {
    to { opacity: 1; }
}

/* === Ring Section === */
.rings {
    padding: 10vh 0;
}

.ring-grid {
    display: grid;
    grid-template-columns: repeat(11, 1fr);
    gap: clamp(1rem, 2vw, 2rem);
}

/* === Blocks === */
.block {
    padding: clamp(2rem, 4vw, 4rem);
    border-radius: 2px;
    transition: background-color 0.3s ease;
    opacity: 0;
    transform: translateY(30px);
    position: relative;
    overflow: hidden;
}

.block:hover {
    filter: brightness(1.02);
}

.block.visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.block--light {
    background: var(--aged-linen);
}

.block--mid {
    background: var(--dried-bark);
}

.block--dark {
    background: var(--twilight-sapwood);
    color: var(--moonlit-bark);
}

.block-hanja {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: clamp(3rem, 6vw, 5rem);
    opacity: 0.08;
    position: absolute;
    top: 0.5rem;
    right: 1rem;
    line-height: 1;
}

.block--dark .block-hanja {
    color: var(--moonlit-bark);
    opacity: 0.1;
}

.block-word {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 500;
    font-size: clamp(1.8rem, 3.5vw, 3rem);
    margin-bottom: 0.75rem;
    line-height: 1.2;
}

.block-text {
    max-width: 45ch;
}

.block-text.kr-text {
    font-family: 'Noto Serif KR', serif;
    margin-bottom: 0.5rem;
}

/* === Ring Circles Decoration === */
.ring-circles {
    position: absolute;
    bottom: -20%;
    right: -10%;
    width: 200px;
    height: 200px;
}

.ring-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 1px solid rgba(61, 43, 31, 0.06);
}

.ring-circle:nth-child(1) { width: 48px; height: 48px; }
.ring-circle:nth-child(2) { width: 96px; height: 96px; }
.ring-circle:nth-child(3) { width: 144px; height: 144px; }
.ring-circle:nth-child(4) { width: 192px; height: 192px; }

.block--dark .ring-circle {
    border-color: rgba(200, 191, 168, 0.08);
}

/* === CSS Branch Drawing === */
.css-branch {
    height: 120px;
    position: relative;
    display: flex;
    justify-content: center;
}

.branch-line {
    position: absolute;
    width: 2px;
    height: 80px;
    background: var(--bark-brown);
    bottom: 0;
    left: 50%;
    opacity: 0.3;
}

.branch-line--2 {
    height: 50px;
    transform: rotate(-35deg);
    transform-origin: bottom center;
    bottom: 40px;
    left: calc(50% - 15px);
}

.branch-line--3 {
    height: 40px;
    transform: rotate(30deg);
    transform-origin: bottom center;
    bottom: 55px;
    left: calc(50% + 10px);
}

/* === CSS Roots Drawing === */
.css-roots {
    height: 100px;
    position: relative;
}

.root-line {
    position: absolute;
    width: 1.5px;
    height: 60px;
    background: var(--bark-brown);
    top: 0;
    left: 50%;
    opacity: 0.2;
}

.root-line--2 {
    height: 45px;
    transform: rotate(20deg);
    transform-origin: top center;
    top: 10px;
    left: calc(50% + 20px);
}

.root-line--3 {
    height: 50px;
    transform: rotate(-25deg);
    transform-origin: top center;
    top: 5px;
    left: calc(50% - 25px);
}

.root-line--4 {
    height: 35px;
    transform: rotate(40deg);
    transform-origin: top center;
    top: 20px;
    left: calc(50% + 40px);
}

/* === Sap Flow === */
.sap-flow {
    height: 200vh;
    position: relative;
}

.sap-sticky {
    position: sticky;
    top: 0;
    height: 100vh;
    width: 100%;
}

/* === Gradient Transition === */
.gradient-transition {
    height: 200vh;
    background: linear-gradient(180deg, var(--aged-linen) 0%, var(--twilight-sapwood) 40%, var(--midnight-heartwood) 100%);
}

/* === Canopy Terminus === */
.canopy {
    min-height: 100vh;
    background: var(--midnight-heartwood);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: -8vw;
    margin-right: -16vw;
    padding: 0 16vw 0 8vw;
}

.canopy-domain {
    font-family: 'EB Garamond', serif;
    font-size: 0.9rem;
    color: var(--moonlit-bark);
    opacity: 0.6;
    letter-spacing: 0.05em;
}

/* === Floating Leaves === */
.floating-leaves {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.leaf {
    position: absolute;
    width: 8px;
    height: 16px;
    background: var(--moss-canopy);
    opacity: 0.4;
    border-radius: 0 80% 0 80%;
    left: var(--x);
    top: var(--y);
    will-change: transform;
    animation: leaf-drift var(--duration) ease-in-out var(--delay) infinite;
}

@keyframes leaf-drift {
    0% {
        transform: rotate(0deg) translateX(0) translateY(0);
    }
    50% {
        transform: rotate(180deg) translateX(20px) translateY(-30px);
    }
    100% {
        transform: rotate(360deg) translateX(40px) translateY(0);
    }
}
