/* ==============================================
   hangul.name — Surreal Calligraphic Dreamscape
   ============================================== */

/* CSS Custom Properties (Design Palette) */
:root {
    --bg-primary: #F5EDE3;
    --bg-secondary: #E8E0D0;
    --text-primary: #2B1D12;
    --text-secondary: #5E4A3A;
    --accent-primary: #8B5E3C;
    --accent-secondary: #7BA488;
    --botanical-highlight: #4A6B4A;
    --decorative-warm: #C4923A;
    --shadow-depth: #3D2E22;
    --stem-color: #4A3728;
    --label-color: #7A6655;

    --font-display: 'Playfair Display', Georgia, serif;
    --font-heading: 'Cormorant Garamond', Garamond, serif;
    --font-body: 'Lora', Georgia, serif;
    --font-korean: 'Noto Serif KR', serif;

    --column-width: 680px;
    --border-animate-duration: 1.2s;
    --border-animate-timing: cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

body {
    font-family: var(--font-body);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
    position: relative;
    min-height: 100vh;
}

/* ==============================================
   Central Stem Line
   ============================================== */
#stem-line {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 0;
    background-color: var(--stem-color);
    opacity: 0;
    z-index: 1;
    pointer-events: none;
    transition: none;
}

#stem-line.growing {
    opacity: 0.2;
}

/* ==============================================
   Navigation Indicator
   ============================================== */
#nav-indicator {
    position: fixed;
    top: 24px;
    right: 24px;
    display: flex;
    gap: 6px;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.8s ease;
}

#nav-indicator.visible {
    opacity: 1;
}

.nav-jamo {
    font-family: var(--font-korean);
    font-size: 16px;
    color: var(--stem-color);
    opacity: 0.4;
    display: inline-block;
    transition: transform 0.4s ease;
}

/* ==============================================
   Jamo Watermarks (Background)
   ============================================== */
#jamo-watermarks {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.watermark-jamo {
    position: absolute;
    font-family: var(--font-korean);
    font-size: 80px;
    font-weight: 700;
    color: var(--text-primary);
    opacity: 0.03;
    animation: jamoDrift 30s linear infinite;
}

.wm-1  { left: 5%;  top: 10%; animation-delay: 0s; }
.wm-2  { left: 15%; top: 40%; animation-delay: -4s; font-size: 100px; }
.wm-3  { left: 85%; top: 20%; animation-delay: -8s; font-size: 60px; }
.wm-4  { left: 75%; top: 60%; animation-delay: -12s; }
.wm-5  { left: 10%; top: 70%; animation-delay: -16s; font-size: 90px; }
.wm-6  { left: 90%; top: 80%; animation-delay: -20s; font-size: 70px; }
.wm-7  { left: 25%; top: 30%; animation-delay: -3s; font-size: 65px; }
.wm-8  { left: 70%; top: 45%; animation-delay: -7s; font-size: 85px; }
.wm-9  { left: 50%; top: 75%; animation-delay: -11s; font-size: 55px; }
.wm-10 { left: 35%; top: 15%; animation-delay: -15s; font-size: 75px; }
.wm-11 { left: 60%; top: 55%; animation-delay: -19s; font-size: 95px; }
.wm-12 { left: 45%; top: 85%; animation-delay: -23s; font-size: 68px; }

@keyframes jamoDrift {
    0% {
        transform: translateY(0);
    }
    100% {
        transform: translateY(-60px);
    }
}

/* ==============================================
   Scenes — General
   ============================================== */
.scene {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

.scene-content {
    position: relative;
    max-width: var(--column-width);
    width: 100%;
    margin: 0 auto;
    padding: 40px 20px;
}

/* ==============================================
   Stem Nodes (Botanical rosettes)
   ============================================== */
.stem-node {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 24px;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.stem-node.visible {
    opacity: 1;
}

#node-1 { top: auto; bottom: 40px; }
#node-2 { top: 40px; }
#node-3 { top: 40px; }
#node-4 { top: 40px; }
#node-5 { top: 20px; }

/* ==============================================
   Border Animate Frames
   ============================================== */
.border-frame {
    position: relative;
}

.border-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.border-rect {
    fill: none;
    stroke: var(--decorative-warm);
    stroke-width: 1;
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset var(--border-animate-duration) var(--border-animate-timing);
}

.border-frame.animate .border-rect {
    stroke-dashoffset: 0;
}

.frame-inner {
    position: relative;
    padding: 40px;
    z-index: 1;
}

/* Corner Botanical Flourishes */
.corner-flourish {
    position: absolute;
    width: 40px;
    height: 40px;
    opacity: 0;
    transition: opacity 0.6s ease 1.3s;
    z-index: 3;
}

.border-frame.animate .corner-flourish {
    opacity: 1;
}

.corner-tl { top: -4px; left: -4px; }
.corner-tr { top: -4px; right: -4px; }
.corner-bl { bottom: -4px; left: -4px; }
.corner-br { bottom: -4px; right: -4px; }

/* ==============================================
   Scene 1: The Root System
   ============================================== */
.scene-root {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-primary);
}

.scene-root .scene-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

#root-frame {
    display: inline-block;
    margin-bottom: 30px;
}

#root-frame .frame-inner {
    padding: 24px 60px;
}

.domain-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 64px;
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--text-primary);
    opacity: 0;
    transition: opacity 0.8s ease 0.4s;
}

.scene-root.active .domain-title {
    opacity: 1;
}

/* Root system SVG */
.root-system {
    position: relative;
    width: 600px;
    max-width: 100%;
    height: 220px;
}

.root-svg {
    width: 100%;
    height: 100%;
}

.root-line {
    stroke: var(--accent-primary);
    stroke-width: 1.2;
    fill: none;
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 2s ease;
}

.scene-root.active .root-line {
    stroke-dashoffset: 0;
}

.root-tendril {
    stroke: var(--label-color);
    stroke-width: 0.8;
}

/* Jamo at root tips */
.root-jamo {
    position: absolute;
    font-family: var(--font-korean);
    font-size: 14px;
    color: var(--accent-primary);
    opacity: 0;
    transition: opacity 0.5s ease;
}

.scene-root.active .root-jamo {
    opacity: 0.7;
}

.rj-1 { left: 28%; bottom: 22px; transition-delay: 1.5s; }
.rj-2 { left: 66%; bottom: 22px; transition-delay: 1.7s; }
.rj-3 { left: 19%; bottom: 0; transition-delay: 1.9s; }
.rj-4 { left: 75%; bottom: 0; transition-delay: 2.1s; }
.rj-5 { left: 38%; bottom: 48px; transition-delay: 2.3s; }
.rj-6 { left: 56%; bottom: 48px; transition-delay: 2.5s; }

/* ==============================================
   Branch Layout (Left/Right alternating)
   ============================================== */
.branch-left .branch-content {
    margin-right: auto;
    margin-left: 0;
    padding-right: calc(50% - var(--column-width) / 2 + 40px);
    text-align: right;
}

.branch-right .branch-content {
    margin-left: auto;
    margin-right: 0;
    padding-left: calc(50% - var(--column-width) / 2 + 40px);
    text-align: left;
}

/* ==============================================
   Scene 2: The First Specimen
   ============================================== */
.scene-specimen {
    min-height: 80vh;
    background-color: var(--bg-primary);
    padding: 60px 0;
}

.specimen-frame .frame-inner {
    padding: 30px;
}

.specimen-inner {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    flex-wrap: wrap;
    justify-content: center;
}

.specimen-illustration {
    flex: 0 0 260px;
}

.hieut-svg {
    width: 260px;
    height: auto;
}

.specimen-text {
    flex: 1;
    min-width: 200px;
    text-align: left;
}

.specimen-label {
    font-family: var(--font-heading);
    font-style: italic;
    font-weight: 300;
    font-size: 13px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--label-color);
    margin-bottom: 8px;
}

.specimen-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 36px;
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.specimen-name span {
    font-family: var(--font-korean);
}

.specimen-subtitle {
    font-family: var(--font-heading);
    font-style: italic;
    font-weight: 500;
    font-size: 20px;
    color: var(--accent-primary);
    margin-bottom: 18px;
}

.specimen-description {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 17px;
    line-height: 1.72;
    color: var(--shadow-depth);
    margin-bottom: 20px;
}

.specimen-description span {
    font-family: var(--font-korean);
}

.specimen-latin-label {
    font-family: var(--font-heading);
    font-style: italic;
    font-weight: 300;
    font-size: 13px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--label-color);
}

/* SVG specimen illustration animations */
.specimen-line,
.specimen-circle,
.specimen-root {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 1.5s ease;
}

.specimen-petal {
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    transition: stroke-dashoffset 0.8s ease;
}

.specimen-leaf {
    opacity: 0;
    transition: opacity 0.8s ease 1.2s;
}

.scene-specimen.revealed .specimen-line,
.scene-specimen.revealed .specimen-circle,
.scene-specimen.revealed .specimen-root {
    stroke-dashoffset: 0;
}

.scene-specimen.revealed .specimen-petal {
    stroke-dashoffset: 0;
}

.scene-specimen.revealed .specimen-leaf {
    opacity: 0.4;
}

.specimen-petal.p1 { transition-delay: 0.6s; }
.specimen-petal.p2 { transition-delay: 0.7s; }
.specimen-petal.p3 { transition-delay: 0.8s; }
.specimen-petal.p4 { transition-delay: 0.9s; }
.specimen-petal.p5 { transition-delay: 1.0s; }
.specimen-petal.p6 { transition-delay: 1.1s; }
.specimen-petal.p7 { transition-delay: 1.2s; }
.specimen-petal.p8 { transition-delay: 1.3s; }

/* ==============================================
   Skyline Divider
   ============================================== */
.skyline-divider {
    position: relative;
    width: 100%;
    height: 80px;
    overflow: visible;
    opacity: 0;
    transition: opacity 1s ease;
}

.skyline-divider.revealed {
    opacity: 1;
}

.skyline-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.skyline-path {
    fill: var(--text-primary);
    opacity: 0.08;
}

.tendril {
    stroke: var(--botanical-highlight);
    stroke-width: 1;
    opacity: 0;
    transition: opacity 0.8s ease 0.5s;
}

.skyline-divider.revealed .tendril {
    opacity: 0.5;
}

.tendril-bud {
    opacity: 0;
    transition: opacity 0.6s ease 1s;
}

.skyline-divider.revealed .tendril-bud {
    opacity: 0.6;
}

/* ==============================================
   Scene 3: Urban Canopy
   ============================================== */
.scene-urban {
    min-height: 60vh;
    background-color: var(--bg-secondary);
    padding: 60px 0;
}

.urban-frame .frame-inner {
    padding: 50px 40px;
}

.urban-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 48px;
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--text-primary);
    margin-bottom: 28px;
}

.urban-body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 17px;
    line-height: 1.72;
    color: var(--shadow-depth);
    margin-bottom: 24px;
}

.urban-body-ko {
    font-family: var(--font-korean);
    font-weight: 400;
    font-size: 16px;
    line-height: 1.8;
    color: var(--text-secondary);
    margin-bottom: 24px;
    padding: 20px;
    border-left: 2px solid var(--accent-primary);
    background-color: rgba(245, 237, 227, 0.5);
}

/* ==============================================
   Pressed Flower Divider
   ============================================== */
.pressed-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 40px 0;
    opacity: 0;
    transition: opacity 1s ease;
}

.pressed-divider.revealed {
    opacity: 1;
}

.pressed-jamo {
    font-family: var(--font-korean);
    font-size: 24px;
    color: var(--accent-primary);
    opacity: 0.25;
    display: inline-block;
    transform: scaleY(0.7);
}

.pressed-dot {
    font-size: 18px;
    color: var(--label-color);
    opacity: 0.3;
}

/* ==============================================
   Scene 4: The Growth Diagram
   ============================================== */
.scene-growth {
    min-height: 80vh;
    background-color: var(--bg-primary);
    padding: 60px 0;
}

.growth-frame .frame-inner {
    padding: 40px;
}

.growth-label {
    font-family: var(--font-heading);
    font-style: italic;
    font-weight: 300;
    font-size: 13px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--label-color);
    margin-bottom: 12px;
    text-align: center;
}

.growth-heading {
    font-family: var(--font-korean);
    font-weight: 700;
    font-size: 72px;
    color: var(--text-primary);
    text-align: center;
    line-height: 1.15;
    margin-bottom: 4px;
}

.growth-subtitle {
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: 24px;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 40px;
}

.growth-stages {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.growth-stage {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

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

.stage-number {
    font-family: var(--font-heading);
    font-style: italic;
    font-weight: 500;
    font-size: 20px;
    color: var(--accent-primary);
    flex-shrink: 0;
    width: 30px;
    text-align: center;
    padding-top: 10px;
}

.stage-visual {
    flex-shrink: 0;
    width: 180px;
}

.stage-visual svg {
    width: 100%;
    height: auto;
}

.jamo-seed {
    font-family: var(--font-korean);
    font-size: 28px;
    fill: var(--text-secondary);
}

.jamo-sprout {
    font-family: var(--font-korean);
    font-size: 28px;
    fill: var(--botanical-highlight);
}

.jamo-growing {
    font-family: var(--font-korean);
    font-size: 32px;
    fill: var(--text-primary);
}

.jamo-growing-small {
    font-family: var(--font-korean);
    font-size: 22px;
    fill: var(--text-primary);
}

.stage-bloom {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 120px;
    height: 120px;
}

.bloom-syllable {
    font-family: var(--font-korean);
    font-weight: 700;
    font-size: 56px;
    color: var(--text-primary);
    position: relative;
    z-index: 1;
}

.bloom-rays {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.stage-caption {
    font-family: var(--font-heading);
    font-style: italic;
    font-weight: 300;
    font-size: 14px;
    color: var(--label-color);
    flex: 1;
    padding-top: 20px;
    line-height: 1.5;
}

/* Stagger for growth stages */
.stage-1 { transition-delay: 0s; }
.stage-2 { transition-delay: 0.3s; }
.stage-3 { transition-delay: 0.6s; }
.stage-4 { transition-delay: 0.9s; }

/* ==============================================
   Scene 5: The Canopy
   ============================================== */
.scene-canopy {
    min-height: 100vh;
    background-color: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.canopy-content {
    position: relative;
    width: 100%;
    max-width: var(--column-width);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    padding: 40px 20px;
}

.canopy-leaves {
    position: relative;
    width: 400px;
    height: 300px;
    margin-bottom: 40px;
}

.canopy-leaf {
    position: absolute;
    font-family: var(--font-korean);
    font-weight: 700;
    color: var(--text-primary);
    opacity: 0;
    transition: opacity 1s ease;
}

.scene-canopy.revealed .canopy-leaf {
    opacity: var(--leaf-opacity, 0.15);
}

.cl-1 {
    font-size: 120px;
    left: 50px;
    top: 20px;
    --leaf-opacity: 0.12;
    transform: rotate(-5deg);
    transition-delay: 0.2s;
}
.cl-2 {
    font-size: 100px;
    left: 180px;
    top: 40px;
    --leaf-opacity: 0.18;
    transform: rotate(3deg);
    transition-delay: 0.4s;
}
.cl-3 {
    font-size: 80px;
    left: 100px;
    top: 120px;
    --leaf-opacity: 0.10;
    transform: rotate(8deg);
    transition-delay: 0.6s;
}
.cl-4 {
    font-size: 110px;
    left: 220px;
    top: 130px;
    --leaf-opacity: 0.15;
    transform: rotate(-3deg);
    transition-delay: 0.8s;
}
.cl-5 {
    font-size: 70px;
    left: 30px;
    top: 180px;
    --leaf-opacity: 0.08;
    transform: rotate(5deg);
    transition-delay: 1.0s;
}
.cl-6 {
    font-size: 90px;
    left: 160px;
    top: 200px;
    --leaf-opacity: 0.20;
    transform: rotate(-2deg);
    transition-delay: 1.2s;
}
.cl-7 {
    font-size: 60px;
    left: 280px;
    top: 60px;
    --leaf-opacity: 0.10;
    transform: rotate(6deg);
    transition-delay: 0.5s;
}
.cl-8 {
    font-size: 95px;
    left: 10px;
    top: 90px;
    --leaf-opacity: 0.12;
    transform: rotate(-4deg);
    transition-delay: 0.9s;
}

.canopy-text {
    text-align: center;
    position: relative;
    z-index: 2;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1s ease, transform 1s ease;
    transition-delay: 0.5s;
}

.scene-canopy.revealed .canopy-text {
    opacity: 1;
    transform: translateY(0);
}

.canopy-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 48px;
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.canopy-subtext {
    font-family: var(--font-korean);
    font-weight: 400;
    font-size: 20px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Canopy full-viewport border frame */
.canopy-frame {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 50;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.canopy-frame.visible {
    opacity: 1;
}

.border-svg-full {
    position: absolute;
    top: 10px;
    left: 10px;
    width: calc(100% - 20px);
    height: calc(100% - 20px);
}

.border-rect-full {
    fill: none;
    stroke: var(--decorative-warm);
    stroke-width: 1.5;
    stroke-dasharray: 3000;
    stroke-dashoffset: 3000;
    transition: stroke-dashoffset 2s var(--border-animate-timing);
}

.canopy-frame.animate .border-rect-full {
    stroke-dashoffset: 0;
}

/* ==============================================
   Scroll-Triggered Entry Animation (General)
   ============================================== */
.scroll-reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ==============================================
   Responsive
   ============================================== */
@media (max-width: 768px) {
    :root {
        --column-width: 100%;
    }

    .domain-title {
        font-size: 42px;
    }

    .root-system {
        width: 100%;
    }

    .branch-left .branch-content,
    .branch-right .branch-content {
        padding-left: 20px;
        padding-right: 20px;
        margin: 0 auto;
        text-align: left;
    }

    .specimen-inner {
        flex-direction: column;
        align-items: center;
    }

    .specimen-illustration {
        flex: 0 0 auto;
    }

    .hieut-svg {
        width: 200px;
    }

    .urban-heading {
        font-size: 36px;
    }

    .canopy-heading {
        font-size: 36px;
    }

    .growth-heading {
        font-size: 56px;
    }

    .growth-stage {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .stage-visual {
        width: 150px;
    }

    .canopy-leaves {
        width: 300px;
        height: 250px;
    }

    .cl-1 { font-size: 80px; left: 30px; top: 10px; }
    .cl-2 { font-size: 70px; left: 130px; top: 30px; }
    .cl-3 { font-size: 55px; left: 70px; top: 90px; }
    .cl-4 { font-size: 75px; left: 160px; top: 100px; }
    .cl-5 { font-size: 50px; left: 15px; top: 140px; }
    .cl-6 { font-size: 65px; left: 110px; top: 160px; }
    .cl-7 { font-size: 45px; left: 200px; top: 50px; }
    .cl-8 { font-size: 68px; left: 5px; top: 70px; }

    .frame-inner {
        padding: 24px 16px;
    }

    .nav-jamo {
        font-size: 14px;
    }

    #nav-indicator {
        top: 16px;
        right: 16px;
    }
}

@media (max-width: 480px) {
    .domain-title {
        font-size: 32px;
    }

    .specimen-name {
        font-size: 28px;
    }

    .urban-heading {
        font-size: 28px;
    }

    .canopy-heading {
        font-size: 28px;
    }

    .growth-heading {
        font-size: 44px;
    }

    .canopy-leaves {
        width: 260px;
        height: 200px;
    }
}
