/* hangul.dev - Avant-garde meditation on Korean writing systems */
/* Color Palette:
   Background Primary: #0D0B14 (Midnight Velvet)
   Background Secondary: #1A1332 (Deep Amethyst)
   Surface/Sidebar: #12101C (Obsidian)
   Text Primary: #F0E6D3 (Warm Parchment)
   Text Secondary: #B8A99A (Stone Dust)
   Accent Primary: #C4395A (Ruby Candlelight)
   Accent Secondary: #3A5FC4 (Sapphire Ink)
   Accent Tertiary: #2E8B6A (Emerald Stroke)
   Glow/Atmospheric: #E8A84C (Amber Flame)
   Highlight: #D4A84B (Topaz Gleam)
   Decorative: #E8D5B8 (Parchment Light)
   Code: #7B6FA3 (Dusted Amethyst)
*/

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 300;
    font-size: 18px;
    line-height: 1.75;
    color: #B8A99A;
    background-color: #0D0B14;
    overflow-x: hidden;
}

/* Grain overlay */
.grain-overlay {
    position: fixed;
    inset: 0;
    opacity: 0.04;
    filter: url(#grain);
    pointer-events: none;
    z-index: 9999;
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    background-color: #12101C;
    z-index: 100;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(232, 168, 76, 0.08);
}

.sidebar-header {
    padding: 40px 30px 30px;
}

.sidebar-title {
    font-family: 'Commissioner', serif;
    font-weight: 700;
    font-size: 24px;
    color: #F0E6D3;
    letter-spacing: -0.02em;
}

.sidebar-title-accent {
    color: #E8A84C;
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    gap: 4px;
}

.jamo-link {
    display: flex;
    align-items: center;
    padding: 12px 30px;
    text-decoration: none;
    color: #B8A99A;
    transition: all 0.3s ease;
    position: relative;
}

.jamo-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: #E8A84C;
    border-radius: 0 2px 2px 0;
    transition: height 0.3s ease;
}

.jamo-link:hover {
    transform: scale(1.02);
    box-shadow: 0 0 40px 8px rgba(232, 168, 76, 0.08);
}

.jamo-link:hover::before {
    height: 24px;
}

.jamo-link.active::before {
    height: 32px;
    background: #E8A84C;
    box-shadow: 0 0 12px rgba(232, 168, 76, 0.4);
}

.jamo-link.active {
    color: #F0E6D3;
}

.jamo-char {
    font-family: 'Noto Serif KR', serif;
    font-weight: 900;
    font-size: 28px;
    width: 44px;
    text-align: center;
    transition: all 0.3s ease;
    color: inherit;
}

.jamo-link:hover .jamo-char {
    color: #E8A84C;
    text-shadow: 0 0 20px rgba(232, 168, 76, 0.3);
    transform: scale(1.1);
}

.jamo-link.active .jamo-char {
    color: #E8A84C;
    text-shadow: 0 0 20px rgba(232, 168, 76, 0.4);
    animation: candlePulse 3s ease-in-out infinite;
}

.jamo-label {
    font-family: 'Commissioner', serif;
    font-weight: 400;
    font-size: 14px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    opacity: 0;
    transform: translateX(-8px);
    transition: all 0.3s ease;
    margin-left: 12px;
}

.jamo-link:hover .jamo-label,
.jamo-link.active .jamo-label {
    opacity: 1;
    transform: translateX(0);
}

.sidebar-footer {
    padding: 20px 30px 30px;
    border-top: 1px solid rgba(232, 168, 76, 0.06);
}

.sidebar-footer-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: #7B6FA3;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* ===== MAIN NARRATIVE ===== */
.narrative {
    margin-left: 280px;
    position: relative;
}

.section {
    min-height: 100vh;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 80px 60px 80px 100px;
    overflow: hidden;
    transition: background-color 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.section:nth-child(odd) {
    background-color: #0D0B14;
}

.section:nth-child(even) {
    background-color: #1A1332;
}

/* Background jamo watermark */
.section-bg-jamo {
    position: absolute;
    right: -40px;
    top: 50%;
    transform: translateY(-50%) scale(2);
    font-family: 'Noto Serif KR', serif;
    font-weight: 900;
    font-size: 320px;
    color: #E8D5B8;
    opacity: 0;
    mix-blend-mode: soft-light;
    pointer-events: none;
    transition: all 1s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 0;
}

.section.visible .section-bg-jamo {
    opacity: 0.06;
    transform: translateY(-50%) scale(1);
}

/* Section particles */
.section-particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

/* Section content */
.section-content {
    max-width: 640px;
    position: relative;
    z-index: 1;
}

/* Commissioner variable font animation for headlines */
.section-headline {
    font-family: 'Commissioner', serif;
    font-weight: 700;
    font-size: 56px;
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: #F0E6D3;
    margin-bottom: 40px;
    font-variation-settings: 'FLAR' 0;
    transition: font-variation-settings 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    transform: translateY(30px);
}

.section.visible .section-headline {
    font-variation-settings: 'FLAR' 100;
    opacity: 1;
    transform: translateY(0);
    transition: font-variation-settings 0.8s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Section body with staggered paragraph reveals */
.section-body p,
.section-body .consonant-grid,
.section-body .vowel-philosophy,
.section-body .block-diagram,
.section-body .code-blocks,
.section-body .code-formula,
.section-body .beauty-showcase {
    opacity: 0;
    transform: translateY(20px);
    filter: blur(4px);
    transition: opacity 0.5s ease, transform 0.5s ease, filter 0.5s ease;
}

.section.visible .section-body p,
.section.visible .section-body .consonant-grid,
.section.visible .section-body .vowel-philosophy,
.section.visible .section-body .block-diagram,
.section.visible .section-body .code-blocks,
.section.visible .section-body .code-formula,
.section.visible .section-body .beauty-showcase {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
}

/* Code specimens */
.code-specimen {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid rgba(123, 111, 163, 0.15);
}

.code-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 15px;
    color: #7B6FA3;
}

.highlight-text {
    color: #E8A84C;
    font-weight: 400;
}

.text-ruby { color: #C4395A; }
.text-sapphire { color: #3A5FC4; }
.text-emerald { color: #2E8B6A; }

/* ===== CONSONANT GRID ===== */
.consonant-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 30px 0;
    padding: 30px;
    background: rgba(18, 16, 28, 0.6);
    border-radius: 4px;
    border: 1px solid rgba(196, 57, 90, 0.12);
}

.consonant-item {
    display: flex;
    align-items: center;
    gap: 20px;
}

.consonant-jamo {
    font-family: 'Noto Serif KR', serif;
    font-weight: 900;
    font-size: 42px;
    color: #C4395A;
    width: 60px;
    text-align: center;
    flex-shrink: 0;
}

.consonant-desc {
    font-size: 16px;
    line-height: 1.5;
    color: #B8A99A;
}

/* ===== VOWEL PHILOSOPHY ===== */
.vowel-philosophy {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: 30px 0;
    padding: 30px;
    background: rgba(18, 16, 28, 0.6);
    border-radius: 4px;
    border: 1px solid rgba(58, 95, 196, 0.12);
}

.vowel-element {
    display: flex;
    align-items: center;
    gap: 16px;
}

.vowel-symbol {
    font-size: 36px;
    color: #3A5FC4;
    width: 50px;
    text-align: center;
    flex-shrink: 0;
    font-weight: 700;
}

.vowel-name {
    font-family: 'Commissioner', serif;
    font-weight: 700;
    font-size: 16px;
    color: #F0E6D3;
    min-width: 140px;
}

.vowel-desc {
    font-size: 15px;
    color: #B8A99A;
}

/* ===== BLOCK DIAGRAM ===== */
.block-diagram {
    margin: 40px 0;
}

.block-example {
    display: flex;
    align-items: center;
    gap: 60px;
    justify-content: center;
}

.block-assembled {
    text-align: center;
}

.block-result {
    font-family: 'Noto Serif KR', serif;
    font-weight: 900;
    font-size: 120px;
    color: #F0E6D3;
    text-shadow: 0 0 60px rgba(232, 168, 76, 0.15);
}

.block-exploded {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.block-component {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: 'Noto Serif KR', serif;
    font-weight: 900;
    font-size: 36px;
}

.block-initial { color: #C4395A; }
.block-medial { color: #3A5FC4; }
.block-final { color: #2E8B6A; }

.block-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.7;
}

/* ===== CODE BLOCKS ===== */
.code-blocks {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 30px 0;
}

.code-block-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 20px 24px;
    background: rgba(18, 16, 28, 0.8);
    border-radius: 4px;
    border-left: 3px solid #7B6FA3;
    transition: box-shadow 0.3s ease;
}

.code-block-item:hover {
    box-shadow: 0 0 40px 8px rgba(232, 168, 76, 0.06);
}

.code-range {
    font-family: 'JetBrains Mono', monospace;
    font-size: 15px;
    color: #7B6FA3;
    font-weight: 400;
}

.code-block-name {
    font-family: 'Commissioner', serif;
    font-weight: 700;
    font-size: 18px;
    color: #F0E6D3;
}

.code-block-desc {
    font-size: 15px;
    color: #B8A99A;
}

.code-formula {
    margin: 30px 0;
    padding: 24px 30px;
    background: rgba(18, 16, 28, 0.9);
    border-radius: 4px;
    border: 1px solid rgba(123, 111, 163, 0.2);
    text-align: center;
}

.code-formula code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px;
    color: #2E8B6A;
    letter-spacing: 0.02em;
}

/* ===== BEAUTY SHOWCASE ===== */
.beauty-showcase {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin: 50px 0 30px;
    padding: 40px 0;
}

.beauty-char {
    font-family: 'Noto Serif KR', serif;
    font-weight: 900;
    font-size: 160px;
    color: #F0E6D3;
    text-shadow: 0 0 80px rgba(232, 168, 76, 0.12);
    transition: text-shadow 0.5s ease;
}

.beauty-char:hover {
    text-shadow: 0 0 100px rgba(232, 168, 76, 0.25);
}

.closing-text {
    text-align: center;
    font-family: 'Commissioner', serif;
    font-weight: 700;
    font-size: 24px;
    color: #D4A84B;
    letter-spacing: 0.05em;
}

/* ===== INK ILLUSTRATIONS ===== */
.ink-illustration {
    position: absolute;
    pointer-events: none;
    z-index: 0;
}

.origin-ink {
    right: 40px;
    bottom: 40px;
    width: 280px;
    height: 280px;
    opacity: 0.6;
}

.consonant-waves {
    bottom: 30px;
    right: 20px;
    width: 360px;
    height: 140px;
    opacity: 0.6;
}

.vowel-cosmos {
    right: 60px;
    top: 50%;
    transform: translateY(-50%);
    width: 200px;
    height: 200px;
    opacity: 0.6;
}

.beauty-strokes {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 400px;
    height: 120px;
    opacity: 0.6;
}

/* ===== CANDLE ===== */
.candle-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 200;
    pointer-events: none;
}

.candle-body {
    position: relative;
    width: 20px;
    height: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.candle-wick {
    width: 2px;
    height: 8px;
    background: #B8A99A;
    border-radius: 1px;
}

.candle-flame {
    position: relative;
    width: 14px;
    height: 30px;
    margin-top: -4px;
}

.flame-inner {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 20px;
    background: #F0E6D3;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    animation: flameInner 1.5s ease-in-out infinite alternate;
}

.flame-outer {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 14px;
    height: 30px;
    background: radial-gradient(ellipse, #E8A84C 0%, rgba(232, 168, 76, 0.4) 50%, transparent 70%);
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    animation: flameOuter 2s ease-in-out infinite alternate;
}

.candle-glow {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 120px;
    background: radial-gradient(circle, rgba(232, 168, 76, 0.08) 0%, transparent 70%);
    pointer-events: none;
    animation: glowPulse 3s ease-in-out infinite;
}

/* ===== ANIMATIONS ===== */
@keyframes candlePulse {
    0%, 100% { text-shadow: 0 0 20px rgba(232, 168, 76, 0.4); }
    50% { text-shadow: 0 0 30px rgba(232, 168, 76, 0.6); }
}

@keyframes flameInner {
    0% { height: 18px; width: 7px; }
    50% { height: 22px; width: 9px; }
    100% { height: 16px; width: 6px; }
}

@keyframes flameOuter {
    0% { height: 28px; width: 13px; opacity: 0.8; }
    33% { height: 32px; width: 15px; opacity: 1; }
    66% { height: 26px; width: 12px; opacity: 0.7; }
    100% { height: 30px; width: 14px; opacity: 0.9; }
}

@keyframes glowPulse {
    0%, 100% { opacity: 0.8; transform: translateX(-50%) scale(1); }
    50% { opacity: 1; transform: translateX(-50%) scale(1.1); }
}

@keyframes particleRise {
    0% { transform: translateY(0) translateX(0); opacity: 0; }
    10% { opacity: 0.4; }
    90% { opacity: 0.1; }
    100% { transform: translateY(-100vh) translateX(20px); opacity: 0; }
}

/* Particle dots */
.particle {
    position: absolute;
    width: 3px;
    height: 3px;
    background: #E8A84C;
    border-radius: 50%;
    animation: particleRise linear infinite;
    pointer-events: none;
}

/* Section dividers */
.section + .section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    width: 80%;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(232, 168, 76, 0.15), transparent);
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        width: 80px;
    }
    .jamo-label {
        display: none;
    }
    .sidebar-header {
        padding: 20px 10px;
    }
    .sidebar-title {
        font-size: 14px;
    }
    .sidebar-title-accent {
        display: none;
    }
    .sidebar-footer {
        display: none;
    }
    .jamo-link {
        padding: 12px 0;
        justify-content: center;
    }
    .narrative {
        margin-left: 80px;
    }
    .section {
        padding: 60px 30px 60px 50px;
    }
    .section-headline {
        font-size: 40px;
    }
    .block-example {
        flex-direction: column;
        gap: 30px;
    }
    .block-result {
        font-size: 80px;
    }
    .beauty-char {
        font-size: 100px;
    }
}

@media (max-width: 640px) {
    .sidebar {
        width: 60px;
    }
    .jamo-char {
        font-size: 22px;
    }
    .narrative {
        margin-left: 60px;
    }
    .section {
        padding: 40px 20px;
    }
    .section-headline {
        font-size: 32px;
    }
    .section-bg-jamo {
        font-size: 180px;
    }
    body {
        font-size: 16px;
    }
    .beauty-char {
        font-size: 80px;
    }
    .block-result {
        font-size: 60px;
    }
    .consonant-jamo {
        font-size: 32px;
        width: 45px;
    }
}

/* Selection color */
::selection {
    background: rgba(212, 168, 75, 0.3);
    color: #F0E6D3;
}
