/* ========================================
   hangeul.day - Generative Forestcore Hangeul
   ======================================== */

:root {
    --forest-floor: #0B1A0F;
    --canopy-shadow: #132B1A;
    --emerald-heartwood: #2D7A4F;
    --biolume: #5EFAA0;
    --lichen-gold: #C4A84D;
    --mist-white: #E8F0EA;
    --fern-gray: #8BA898;
    --autumn-persimmon: #D4693A;
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    background: linear-gradient(180deg, #0B1A0F 0%, #132B1A 40%, #1A3D25 100%);
    color: var(--mist-white);
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    line-height: 1.85;
    overflow-x: hidden;
    position: relative;
}

/* --- Grid Points Background --- */
.grid-points {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background-image: radial-gradient(circle, #1A3D25 1px, transparent 1px);
    background-size: 40px 40px;
}

/* --- Shape Field --- */
.shape-field {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.shape-field .drift-shape {
    position: absolute;
    will-change: transform;
}

@keyframes drift {
    0% { transform: translate(0, 0); }
    50% { transform: translate(var(--dx), var(--dy)); }
    100% { transform: translate(0, 0); }
}

/* --- Typography --- */
h2 {
    font-family: 'Commissioner', sans-serif;
    font-weight: 200;
    font-size: clamp(2rem, 5vw, 3.5rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1.3;
    color: var(--mist-white);
}

p {
    font-size: clamp(1rem, 2vw, 1.15rem);
    line-height: 1.85;
    letter-spacing: 0.01em;
    margin-bottom: 1.5rem;
    color: var(--mist-white);
}

.meta-date {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8rem;
    color: var(--lichen-gold);
    letter-spacing: 0.06em;
}

/* --- Sections --- */
.section {
    position: relative;
    z-index: 1;
    max-width: 680px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* --- Section 1: Clearing --- */
.section-clearing {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: none;
    text-align: center;
}

.biolume-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 400px;
    height: 400px;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(94, 250, 160, 0.15) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.hero-hangeul {
    width: clamp(200px, 40vw, 300px);
    height: clamp(200px, 40vw, 300px);
    position: relative;
    z-index: 1;
}

.stroke {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    animation: drawStroke 1s ease forwards;
}

.stroke-1 { animation-delay: 0s; }
.stroke-2 { animation-delay: 0.6s; }
.stroke-3 { stroke-dasharray: 80; stroke-dashoffset: 80; animation-delay: 1.2s; }
.stroke-4 { animation-delay: 1.8s; }
.stroke-5 { animation-delay: 2.4s; }
.stroke-6 { stroke-dasharray: 300; stroke-dashoffset: 300; animation-delay: 3.0s; }

@keyframes drawStroke {
    to { stroke-dashoffset: 0; }
}

.hero-hangeul .stroke {
    animation-fill-mode: forwards;
}

.clearing-subtitle {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: clamp(0.95rem, 1.8vw, 1.15rem);
    color: var(--fern-gray);
    margin-top: 2rem;
    opacity: 0;
    animation: fadeIn 0.8s ease 4s forwards;
    position: relative;
    z-index: 1;
}

@keyframes fadeIn {
    to { opacity: 1; }
}

.scroll-indicator {
    margin-top: 3rem;
    animation: scrollPulse 2s ease-in-out infinite;
    position: relative;
    z-index: 1;
}

@keyframes scrollPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.7; }
}

/* --- Card Flip System --- */
.card-flip {
    perspective: 1000px;
    position: relative;
}

.card-flip .card-back,
.card-flip .card-front {
    backface-visibility: hidden;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-flip .card-back {
    position: relative;
    background: linear-gradient(135deg, #132B1A 0%, #0B1A0F 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.card-flip .card-front {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: rotateY(180deg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    padding: 1.5rem;
}

.card-flip.flipped .card-back {
    transform: rotateY(180deg);
}

.card-flip.flipped .card-front {
    transform: rotateY(0deg);
}

.shape-hint {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 300;
    font-size: 3rem;
    color: var(--biolume);
    opacity: 0.15;
}

/* --- Section 2: Undergrowth --- */
.section-undergrowth {
    padding-top: 6rem;
    padding-bottom: 6rem;
}

.section-title {
    margin-bottom: 3rem;
    will-change: transform;
}

.section-title .card-back {
    padding: 1.5rem;
    text-align: center;
}

.section-title .card-front {
    background: transparent;
}

.section-title .card-front span {
    font-family: 'Commissioner', sans-serif;
    font-weight: 200;
    font-size: clamp(2rem, 5vw, 3.5rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--mist-white);
}

.jamo-gallery {
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

.jamo-card {
    will-change: transform;
}

.jamo-card .card-back {
    aspect-ratio: 1 / 1.2;
    position: relative;
    overflow: hidden;
}

.jamo-card .card-front {
    background: var(--canopy-shadow);
    text-align: center;
}

.scan-rings {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: 80%;
}

.scan-rings::before,
.scan-rings::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 1px dashed rgba(94, 250, 160, 0.15);
}

.scan-rings::before {
    width: 60%;
    height: 60%;
    animation: scanRotate 12s linear infinite;
}

.scan-rings::after {
    width: 90%;
    height: 90%;
    animation: scanRotate 18s linear infinite reverse;
}

@keyframes scanRotate {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

.jamo-preview {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 300;
    font-size: 4rem;
    color: var(--biolume);
    opacity: 0.2;
    position: relative;
    z-index: 1;
}

.jamo-display {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 300;
    font-size: 6rem;
    color: var(--mist-white);
    display: block;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.jamo-roman {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: 1rem;
    color: var(--lichen-gold);
    display: block;
    margin-bottom: 0.25rem;
}

.jamo-meta {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--fern-gray);
    display: block;
}

/* --- Section 3: Canopy --- */
.section-canopy {
    min-height: 120vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: none;
    padding-top: 6rem;
    padding-bottom: 6rem;
}

.convergence-area {
    position: relative;
    width: 300px;
    height: 300px;
    margin: 3rem auto;
}

.converge-jamo {
    position: absolute;
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 700;
    font-size: 4rem;
    color: var(--mist-white);
    transition: transform 1s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.6s ease;
}

.jamo-initial {
    top: 0;
    left: 0;
    transform: translate(-60px, -40px);
}

.jamo-vowel {
    top: 0;
    right: 0;
    transform: translate(60px, -40px);
}

.jamo-final {
    bottom: 0;
    left: 50%;
    transform: translate(-50%, 60px);
}

.convergence-area.converged .jamo-initial {
    transform: translate(40px, 40px);
    opacity: 0.3;
}

.convergence-area.converged .jamo-vowel {
    transform: translate(-40px, 40px);
    opacity: 0.3;
}

.convergence-area.converged .jamo-final {
    transform: translate(-50%, -20px);
    opacity: 0.3;
}

.convergence-result {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 700;
    font-size: 6rem;
    color: var(--biolume);
    opacity: 0;
    transition: opacity 0.8s ease 0.5s;
}

.convergence-area.converged .convergence-result {
    opacity: 1;
    text-shadow: 0 0 40px rgba(94, 250, 160, 0.3);
}

.canopy-note {
    text-align: center;
    max-width: 40ch;
    color: var(--fern-gray);
    font-size: clamp(0.85rem, 1.4vw, 1rem);
}

/* --- Section 4: Roots --- */
.section-roots {
    padding-top: 6rem;
    padding-bottom: 6rem;
}

.roots-content {
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

.text-card {
    will-change: transform;
}

.text-card .card-back {
    min-height: 120px;
    padding: 2rem;
}

.text-card .card-front {
    background: transparent;
    padding: 2rem;
    align-items: flex-start;
    justify-content: flex-start;
}

.roots-heading {
    font-weight: 200;
    margin-bottom: 0.5rem;
}

.roots-kr {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 300;
    font-size: 1.5rem;
    color: var(--biolume);
    margin-bottom: 0;
}

.pull-quote {
    font-family: 'Commissioner', sans-serif;
    font-weight: 700;
    font-size: clamp(1.4rem, 3vw, 2rem);
    line-height: 1.4;
    color: var(--mist-white);
    border-left: 3px solid var(--emerald-heartwood);
    padding-left: 1.5rem;
    margin-bottom: 1rem;
    font-style: italic;
}

.quote-source {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: 0.9rem;
    color: var(--fern-gray);
}

/* --- Section 5: Mycelium --- */
.section-mycelium {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: none;
    padding: 4rem 2rem;
}

.mycelium-canvas {
    width: min(80vw, 600px);
    height: min(80vw, 600px);
    display: block;
}

.mycelium-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--lichen-gold);
    margin-top: 2rem;
    text-align: center;
}

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

    .stroke {
        stroke-dashoffset: 0;
    }

    .clearing-subtitle {
        opacity: 1;
    }

    .card-flip .card-back {
        transform: rotateY(180deg);
    }

    .card-flip .card-front {
        transform: rotateY(0deg);
    }

    .drift-shape {
        animation: none !important;
    }
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .section {
        padding: 0 1.5rem;
    }

    .jamo-card .card-back {
        aspect-ratio: 1 / 1;
    }

    .convergence-area {
        width: 240px;
        height: 240px;
    }

    .converge-jamo {
        font-size: 3rem;
    }

    .convergence-result {
        font-size: 4.5rem;
    }

    .shape-field {
        display: none;
    }
}
