/* ===== CUSTOM PROPERTIES ===== */
:root {
    --void: #0d1117;
    --amethyst: #7b2d8e;
    --emerald: #1a6b4a;
    --ruby: #8e2d3a;
    --amber: #c4882f;
    --sapphire: #2d4a8e;
    --bone: #e8e0d4;
    --lichen: #8a8578;
    --dark1: #1a1a1a;
    --dark2: #0f0f0f;

    --hex-size-lg: 180px;
    --hex-size-md: 100px;
    --hex-size-sm: 50px;
    --hex-gap: 6px;
    --hex-clip: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--void);
    color: var(--bone);
    font-family: 'Lora', serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.2vw, 1.15rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    background-image:
        repeating-linear-gradient(90deg, rgba(26,26,26,0.03) 0px, rgba(26,26,26,0.03) 1px, transparent 1px, transparent 4px),
        repeating-linear-gradient(0deg, rgba(15,15,15,0.02) 0px, rgba(15,15,15,0.02) 1px, transparent 1px, transparent 6px);
}

/* ===== JAMO BACKGROUND ===== */
.jamo-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.jamo {
    position: absolute;
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    font-size: clamp(15rem, 30vw, 40rem);
    opacity: 0.03;
    color: var(--bone);
    line-height: 1;
    user-select: none;
}

.jamo-1 { top: 5%; left: -5%; }
.jamo-2 { top: 25%; right: -8%; }
.jamo-3 { top: 55%; left: 10%; }
.jamo-4 { top: 75%; right: 5%; }

/* ===== SECTIONS ===== */
.section {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.section--root {
    min-height: 200vh;
    align-items: flex-start;
    padding-top: 10vh;
}

.section--trunk {
    min-height: 200vh;
    flex-direction: column;
}

.section--crown {
    min-height: 200vh;
    align-items: flex-start;
    padding-top: 10vh;
}

.section--ceiling {
    min-height: 100vh;
}

.section-label {
    position: absolute;
    top: 2rem;
    left: 2rem;
    z-index: 10;
}

.section-label span {
    font-family: 'DM Mono', monospace;
    font-weight: 300;
    font-size: clamp(0.7rem, 0.9vw, 0.85rem);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--lichen);
    opacity: 0.5;
}

/* ===== HEXAGONS ===== */
.hex {
    clip-path: var(--hex-clip);
    position: relative;
    transition: transform 0.8s cubic-bezier(0.23, 1, 0.32, 1),
                opacity 0.6s ease,
                box-shadow 0.6s ease;
    background-color: var(--void);
    border: none;
    contain: layout style paint;
    flex-shrink: 0;
}

.hex::before {
    content: '';
    position: absolute;
    inset: 0;
    clip-path: var(--hex-clip);
    box-shadow: inset 0 0 20px rgba(0,0,0,0.3);
    pointer-events: none;
    z-index: 2;
}

.hex--large {
    width: var(--hex-size-lg);
    height: calc(var(--hex-size-lg) * 1.1547);
}

.hex--medium {
    width: var(--hex-size-md);
    height: calc(var(--hex-size-md) * 1.1547);
}

.hex--small {
    width: var(--hex-size-sm);
    height: calc(var(--hex-size-sm) * 1.1547);
}

.hex--amethyst { background-color: var(--amethyst); }
.hex--emerald { background-color: var(--emerald); }
.hex--ruby { background-color: var(--ruby); }
.hex--amber { background-color: var(--amber); }
.hex--sapphire { background-color: var(--sapphire); }

.hex--empty {
    background-color: var(--void);
    box-shadow: inset 0 0 0 1px rgba(123,45,142,0.15);
}

.hex-inner {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    text-align: center;
    z-index: 1;
}

.hex--text .hex-inner {
    overflow: hidden;
}

.hex--vertical .hex-inner {
    writing-mode: vertical-rl;
}

/* ===== HEXAGON ANIMATIONS ===== */
@keyframes pulse-hex-amethyst {
    0%, 100% { box-shadow: inset 0 0 20px rgba(123,45,142,0.1); }
    50% { box-shadow: inset 0 0 40px rgba(123,45,142,0.35), 0 0 15px rgba(123,45,142,0.1); }
}

@keyframes pulse-hex-emerald {
    0%, 100% { box-shadow: inset 0 0 20px rgba(26,107,74,0.1); }
    50% { box-shadow: inset 0 0 40px rgba(26,107,74,0.35), 0 0 15px rgba(26,107,74,0.1); }
}

@keyframes pulse-hex-ruby {
    0%, 100% { box-shadow: inset 0 0 20px rgba(142,45,58,0.1); }
    50% { box-shadow: inset 0 0 40px rgba(142,45,58,0.35), 0 0 15px rgba(142,45,58,0.1); }
}

@keyframes pulse-hex-amber {
    0%, 100% { box-shadow: inset 0 0 20px rgba(196,136,47,0.1); }
    50% { box-shadow: inset 0 0 40px rgba(196,136,47,0.35), 0 0 15px rgba(196,136,47,0.1); }
}

@keyframes pulse-hex-sapphire {
    0%, 100% { box-shadow: inset 0 0 20px rgba(45,74,142,0.1); }
    50% { box-shadow: inset 0 0 40px rgba(45,74,142,0.35), 0 0 15px rgba(45,74,142,0.1); }
}

.hex--pulse.hex--amethyst { animation: pulse-hex-amethyst 3s ease-in-out infinite; }
.hex--pulse.hex--emerald { animation: pulse-hex-emerald 3s ease-in-out infinite; }
.hex--pulse.hex--ruby { animation: pulse-hex-ruby 3s ease-in-out infinite; }
.hex--pulse.hex--amber { animation: pulse-hex-amber 3s ease-in-out infinite; }
.hex--pulse.hex--sapphire { animation: pulse-hex-sapphire 3s ease-in-out infinite; }

/* ===== TYPOGRAPHY ===== */
.korean {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    letter-spacing: 0.05em;
    line-height: 1.2;
    word-break: keep-all;
    color: var(--bone);
}

.korean--hero {
    font-size: clamp(6rem, 15vw, 20rem);
    line-height: 0.9;
}

.korean--again {
    font-size: clamp(3rem, 8vw, 6rem);
}

.body-text {
    font-family: 'Lora', serif;
    font-weight: 400;
    font-size: clamp(0.75rem, 1vw, 0.95rem);
    line-height: 1.6;
    color: var(--bone);
}

.trunk-word {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: clamp(1rem, 2vw, 1.5rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--bone);
}

/* ===== CANOPY OPENING GRID ===== */
.hex-grid--canopy {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-content: center;
    gap: 4px;
    width: 100%;
    max-width: 900px;
    padding: 2rem;
}

.hex-grid--canopy .hex {
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.6s ease, transform 0.6s ease, background-color 0.6s ease;
}

.hex-grid--canopy .hex.hex--revealed {
    opacity: 1;
    transform: scale(1);
}

/* ===== ROOT SECTION ===== */
.root-content {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: flex-start;
    justify-content: flex-start;
    max-width: 700px;
    padding: 2rem;
    padding-left: 5vw;
}

.section--root .hex {
    opacity: 0;
    transform: translateX(60px);
    transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.23, 1, 0.32, 1);
}

.section--root.in-view .hex {
    opacity: 1;
    transform: translateX(0);
}

/* ===== TRUNK SECTION ===== */
.trunk-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    max-width: 400px;
    margin: 0 auto;
    padding: 4rem 2rem;
}

.trunk-column .hex {
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

.section--trunk.in-view .trunk-column .hex {
    opacity: 1;
    transform: scale(1);
}

/* Growth Rings */
.growth-rings {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    height: 500px;
    opacity: 0.15;
    pointer-events: none;
}

.ring {
    position: absolute;
    border-radius: 50%;
    border: 2px solid;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.ring--1 { width: 100%; height: 100%; border-color: var(--amethyst); animation: pulse-ring 4s ease-in-out infinite 0s; }
.ring--2 { width: 80%; height: 80%; border-color: var(--emerald); animation: pulse-ring 4s ease-in-out infinite 0.5s; }
.ring--3 { width: 60%; height: 60%; border-color: var(--ruby); animation: pulse-ring 4s ease-in-out infinite 1s; }
.ring--4 { width: 40%; height: 40%; border-color: var(--amber); animation: pulse-ring 4s ease-in-out infinite 1.5s; }
.ring--5 { width: 20%; height: 20%; border-color: var(--sapphire); animation: pulse-ring 4s ease-in-out infinite 2s; }

.ring-core {
    position: absolute;
    width: 30px;
    height: 30px;
    background: var(--amber);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

@keyframes pulse-ring {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* ===== CROWN SECTION ===== */
.crown-scatter {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 4rem 2rem;
}

.section--crown .hex {
    opacity: 0;
    transform: translate(var(--scatter-x, 0px), var(--scatter-y, 0px)) scale(0.7);
    transition: opacity 0.8s ease, transform 1s cubic-bezier(0.23, 1, 0.32, 1);
}

.section--crown.in-view .hex {
    opacity: 1;
    transform: translate(0, 0) scale(1);
}

/* ===== CEILING SECTION ===== */
.hex-grid--ceiling {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-content: flex-start;
    gap: 3px;
    width: 100%;
    max-width: 1000px;
    padding: 2rem;
}

.hex-grid--ceiling .hex {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.5s ease, transform 0.6s ease;
}

.hex-grid--ceiling .hex.hex--revealed {
    opacity: 1;
    transform: translateY(0);
}

.return-hex {
    position: absolute;
    bottom: 15vh;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    cursor: pointer;
}

.return-hex .hex {
    opacity: 0;
    transition: opacity 1s ease 0.5s;
}

.section--ceiling.in-view .return-hex .hex {
    opacity: 1;
}

/* ===== SPRAY PARTICLES ===== */
.spray-cluster {
    position: absolute;
    pointer-events: none;
    z-index: 3;
}

.spray-dot {
    position: absolute;
    border-radius: 50%;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
    :root {
        --hex-size-lg: 120px;
        --hex-size-md: 75px;
        --hex-size-sm: 40px;
    }

    .growth-rings {
        width: 280px;
        height: 280px;
    }

    .root-content {
        padding-left: 2vw;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
