/* hangeul.day - The Computed Alphabet */

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

:root {
    --obsidian: #0D0D0F;
    --graphite: #1A1A1E;
    --deep-indigo: #141825;
    --charcoal: #121215;
    --scholar-cream: #F5F0E4;
    --rubbing-glow: #F0EDE6;
    --warm-ash: #B8B0A4;
    --ink-stone: #2A2520;
    --sejong-gold: #C9A84C;
    --observatory-blue: #4A7A9A;
    --slate-annotation: #8A9AAA;
    --vermillion: #C24438;
    --faint-rule: #3A3A40;
    --muted-steel: #4A5A6A;
    --vocal-teal: #3A8A7A;
    --heaven-gold: #C9A84C;
    --earth-umber: #7A6B5A;
    --human-white: #F0EDE6;
}

body {
    font-family: 'Crimson Pro', serif;
    font-weight: 400;
    background-color: var(--obsidian);
    color: var(--warm-ash);
    overflow-x: hidden;
    line-height: 1.85;
    font-size: 17px;
}

/* Section Nav */
.section-nav {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-item {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: var(--muted-steel);
    cursor: pointer;
    transition: color 0.3s ease;
    letter-spacing: 0.05em;
}

.nav-item.active {
    color: var(--sejong-gold);
}

/* ==================== RUBBING SURFACE (HERO) ==================== */
.section {
    position: relative;
    min-height: 100vh;
}

.section-rubbing {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--obsidian);
}

.rubbing-reveal {
    display: flex;
    gap: 0.5vw;
    align-items: center;
}

.rubbing-char {
    font-family: 'Noto Serif KR', serif;
    font-weight: 900;
    font-size: clamp(5rem, 15vw, 12rem);
    color: var(--rubbing-glow);
    filter: url(#rubbing-texture);
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 1.4s ease, transform 1.4s ease;
}

.rubbing-char.visible {
    opacity: 1;
    transform: scale(1);
}

.romanization {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 14px;
    color: #6B7B8A;
    letter-spacing: 0.35em;
    margin-top: 24px;
    min-height: 1.2em;
}

/* Rubbing text class */
.rubbing-text {
    filter: url(#rubbing-texture);
    color: var(--rubbing-glow);
}

.rubbing-text-sm {
    font-family: 'Noto Serif KR', serif;
    font-weight: 900;
    filter: url(#rubbing-texture);
    color: var(--rubbing-glow);
    font-size: 2.5rem;
}

/* ==================== DERIVATION LAB ==================== */
.section-derivation {
    background: var(--graphite);
    padding: 80px 20px;
    min-height: 240vh;
    position: relative;
    background-image: repeating-linear-gradient(
        30deg,
        transparent,
        transparent 47px,
        rgba(42, 42, 48, 0.4) 47px,
        rgba(42, 42, 48, 0.4) 48px
    );
}

/* Vowel Tree Background */
.vowel-tree-bg {
    position: absolute;
    top: 10%;
    left: 5%;
    width: 50%;
    max-width: 600px;
    opacity: 0.3;
    z-index: 0;
    pointer-events: none;
}

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

.vowel-label {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 10px;
    fill: var(--slate-annotation);
    text-anchor: middle;
    letter-spacing: 0.08em;
}

.vowel-derived {
    font-family: 'Noto Serif KR', serif;
    font-weight: 900;
    font-size: 28px;
    fill: var(--rubbing-glow);
    opacity: 0.6;
}

.primitive-pulse {
    animation: primPulse 3s ease-in-out infinite;
}

@keyframes primPulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* Tablets */
.tablet-container {
    position: relative;
    z-index: 2;
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 40px;
}

.tablet {
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.5s cubic-bezier(0.22, 0.61, 0.36, 1), transform 0.5s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.tablet.visible {
    opacity: 1;
}

.tablet-dark {
    background: var(--charcoal);
}

.tablet:nth-child(odd) {
    margin-left: 5%;
    margin-right: -3%;
}

.tablet:nth-child(even) {
    margin-left: -3%;
    margin-right: 5%;
}

.tablet-inner {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    padding: 40px;
}

.tablet-glyph-area {
    display: flex;
    align-items: center;
    gap: 16px;
}

.tablet-glyph {
    font-family: 'Noto Serif KR', serif;
    font-weight: 900;
    font-size: clamp(4rem, 12vw, 8rem);
}

.vocal-tract {
    width: 80px;
    height: 80px;
}

.tract-highlight {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 0.6s ease;
}

.tablet.visible .tract-highlight {
    stroke-dashoffset: 0;
}

.tablet-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.tablet-label {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--slate-annotation);
    letter-spacing: 0.12em;
    margin-bottom: 8px;
}

.derivation-notation {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    color: #6B7B8A;
    line-height: 1.6;
}

/* ==================== COMPOSITION ENGINE ==================== */
.section-composition {
    background: var(--obsidian);
    padding: 80px 20px;
    min-height: 120vh;
}

.section-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    color: var(--sejong-gold);
    letter-spacing: 0.12em;
    text-align: center;
    margin-bottom: 8px;
}

.section-subtitle {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    color: var(--muted-steel);
    text-align: center;
    margin-bottom: 60px;
}

.assembler {
    display: flex;
    gap: 60px;
    align-items: center;
    justify-content: center;
    max-width: 800px;
    margin: 0 auto;
    flex-wrap: wrap;
}

.jamo-panels {
    display: flex;
    gap: 16px;
}

.jamo-panel {
    background: var(--charcoal);
    border: 1px solid var(--faint-rule);
    border-radius: 4px;
    padding: 16px;
    width: 80px;
    text-align: center;
}

.panel-label {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 10px;
    color: var(--slate-annotation);
    letter-spacing: 0.1em;
    display: block;
    margin-bottom: 12px;
}

.jamo-scroll {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
    scroll-snap-type: y mandatory;
}

.jamo-item {
    font-family: 'Noto Serif KR', serif;
    font-weight: 900;
    font-size: 1.5rem;
    color: var(--warm-ash);
    padding: 8px;
    scroll-snap-align: center;
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease;
    border-radius: 2px;
}

.jamo-item:hover {
    background: rgba(74, 122, 154, 0.1);
}

.jamo-item.selected {
    color: var(--sejong-gold);
    background: rgba(201, 168, 76, 0.1);
}

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

.block-grid {
    width: 140px;
    height: 140px;
    border: 1px dashed var(--faint-rule);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.block-char {
    font-family: 'Noto Serif KR', serif;
    font-weight: 900;
    font-size: 5rem;
    color: var(--rubbing-glow);
    filter: url(#rubbing-texture);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.block-annotation {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: var(--muted-steel);
    display: block;
    margin-top: 12px;
}

/* ==================== HISTORICAL STRATA ==================== */
.section-strata {
    background: var(--deep-indigo);
    padding: 80px 20px;
    min-height: 100vh;
}

.strata-container {
    max-width: 700px;
    margin: 40px auto 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.stratum {
    padding: 32px 40px;
    position: relative;
    display: flex;
    align-items: center;
    gap: 24px;
    opacity: 0;
    transform: translateX(-5vw);
    transition: opacity 0.4s ease, transform 0.4s ease;
    clip-path: polygon(0 4px, 5% 0, 15% 3px, 25% 1px, 40% 4px, 55% 0, 70% 3px, 85% 1px, 95% 3px, 100% 0, 100% 100%, 0 100%);
}

.stratum.visible {
    opacity: 1;
    transform: translateX(0);
}

.stratum[data-era="1"] { background: #141825; }
.stratum[data-era="2"] { background: #181D2A; }
.stratum[data-era="3"] { background: #1C222F; }
.stratum[data-era="4"] { background: #202735; }
.stratum[data-era="5"] { background: #242C3A; }

.stratum-date {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: var(--sejong-gold);
    min-width: 80px;
}

.stratum-desc {
    font-family: 'Crimson Pro', serif;
    font-weight: 400;
    font-size: 0.95rem;
    color: var(--warm-ash);
    line-height: 1.7;
    flex: 1;
}

.stratum-icon {
    flex-shrink: 0;
}

.icon-draw {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 0.8s ease;
}

.stratum.visible .icon-draw {
    stroke-dashoffset: 0;
}

/* ==================== LIVING GRID ==================== */
.section-grid {
    background: #1E1E20;
    padding: 80px 20px;
    min-height: 100vh;
}

.specimen-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    max-width: 900px;
    margin: 0 auto;
}

.specimen-cell {
    background: var(--obsidian);
    border-bottom: 3px solid;
    padding: 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 140px;
    opacity: 0;
    transition: opacity 0.4s ease, transform 0.2s ease, background-color 0.2s ease;
    cursor: default;
}

.specimen-cell.visible {
    opacity: 1;
}

.specimen-cell:hover {
    transform: scale(1.05);
    background: #2A2A30;
}

.specimen-char {
    font-family: 'Noto Serif KR', serif;
    font-weight: 900;
    font-size: 2.5rem;
    color: var(--rubbing-glow);
    display: block;
    margin-bottom: 8px;
}

.specimen-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    color: var(--muted-steel);
    letter-spacing: 0.08em;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.specimen-cell:hover .specimen-label {
    opacity: 1;
}

/* ==================== FINAL INSCRIPTION ==================== */
.section-inscription {
    background: var(--obsidian);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px 180px;
}

.inscription-text {
    max-width: 90%;
    text-align: center;
}

.inscription-wrap {
    font-family: 'Noto Serif KR', serif;
    font-weight: 900;
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    color: var(--rubbing-glow);
    filter: url(#rubbing-texture);
    line-height: 1.6;
}

.inscription-wrap .ins-char {
    display: inline;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.inscription-wrap .ins-char.rubbed {
    opacity: 1;
    transform: scale(1);
}

.inscription-divider {
    width: 40vw;
    height: 1px;
    background: var(--faint-rule);
    margin: 40px auto;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.inscription-divider.visible {
    opacity: 1;
}

.inscription-date {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--muted-steel);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.inscription-date.visible {
    opacity: 1;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .tablet-inner {
        grid-template-columns: 1fr;
        padding: 24px;
    }

    .tablet:nth-child(odd),
    .tablet:nth-child(even) {
        margin-left: 0;
        margin-right: 0;
        transform: none !important;
    }

    .specimen-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .assembler {
        flex-direction: column;
    }

    .section-nav {
        bottom: 10px;
        left: 10px;
    }

    .stratum {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .vowel-tree-bg {
        display: none;
    }
}
