/* ============================================================
   hangul.day -- Design Tokens (CSS Custom Properties)
   Palette: gold-black-luxury  |  Typography: serif-revival
   ============================================================ */
:root {
    --bg-primary: #0D0D0D;
    --bg-secondary: #1A1A1A;
    --bg-tertiary: #2A2520;
    --gold-primary: #C9A84C;
    --gold-pale: #E8D5A3;
    --text-primary: #F0E6D3;
    --text-secondary: #B8A88A;
    --vermillion: #C63E3E;
    --font-display: 'Cormorant Garamond', Georgia, serif;
    --font-body: 'Source Serif 4', Georgia, serif;
    --font-korean: 'Noto Sans KR', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --spread-gap: 15vh;
    --margin-outer: min(80px, 8vw);
    --line-height-body: 1.85;
    --transition-fade: 800ms ease-out;
}

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.25rem);
    line-height: var(--line-height-body);
    overflow-x: hidden;
}

/* ============================================================
   Progress Indicator (thin gold vertical bar, right edge)
   ============================================================ */
#progress-track {
    position: fixed;
    top: 0;
    right: 0;
    width: 3px;
    height: 100vh;
    background: rgba(201, 168, 76, 0.1);
    z-index: 1000;
}

#progress-fill {
    width: 100%;
    height: 0%;
    background: var(--gold-primary);
    transition: height 150ms ease-out;
}

/* ============================================================
   Floating Wordmark
   Appears after scrolling past Spread 1, opacity 0.3 -> 0.6 on hover.
   ============================================================ */
#wordmark {
    position: fixed;
    top: 24px;
    left: var(--margin-outer);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.12em;
    color: var(--gold-primary);
    opacity: 0;
    transition: opacity 400ms ease-out;
    z-index: 999;
    pointer-events: none;
}

#wordmark.visible {
    opacity: 0.3;
    pointer-events: auto;
}

#wordmark:hover {
    opacity: 0.6;
}

/* ============================================================
   Spread Layout (Full-Viewport Sections)
   Each spread is an independent editorial composition.
   15vh gap between spreads creates the "page-turning" sensation.
   ============================================================ */
.spread {
    position: relative;
    min-height: 100vh;
    padding: var(--spread-gap) var(--margin-outer);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.spread-inner {
    position: relative;
    width: 100%;
    max-width: 1200px;
    z-index: 2;
}

.spread-centered {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* 55/45 split two-column for Spread 2 (magazine-spread asymmetry) */
.spread-two-col {
    display: grid;
    grid-template-columns: 55fr 45fr;
    gap: 60px;
    align-items: start;
}

/* ============================================================
   Watermark Consonants (Background)
   Five root consonants at 40vw, opacity 0.04 in gold.
   ============================================================ */
.watermark {
    position: absolute;
    font-family: var(--font-korean);
    font-weight: 700;
    font-size: 40vw;
    color: var(--gold-primary);
    opacity: 0.04;
    z-index: 1;
    pointer-events: none;
    line-height: 1;
    user-select: none;
}

.watermark-ieung {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.watermark-giyeok {
    top: 10%;
    right: -5%;
}

.watermark-nieun {
    bottom: 10%;
    left: -5%;
}

.watermark-sieut {
    top: 5%;
    left: 50%;
    transform: translateX(-50%);
}

.watermark-mieum {
    bottom: 5%;
    right: -2%;
}

/* ============================================================
   Typography -- Headings
   Cormorant Garamond for display/headings.
   ============================================================ */
.spread-heading {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(2rem, 5vw, 4rem);
    letter-spacing: 0.08em;
    color: var(--gold-primary);
    margin-bottom: 0.5em;
}

.spread-subtitle {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.4vw, 1.3rem);
    color: var(--text-secondary);
    max-width: 600px;
    margin-bottom: 2em;
    font-style: italic;
}

/* ============================================================
   Spread 1 -- The Title Page
   Full-bleed black. Gold serif + Hangul at display scale.
   ============================================================ */
#spread-1 {
    background-color: var(--bg-primary);
}

#spread-1 .spread-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.title-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4em;
}

.title-hangul {
    font-family: var(--font-korean);
    font-weight: 700;
    font-size: clamp(4rem, 12vw, 10rem);
    color: var(--gold-primary);
    letter-spacing: 0.15em;
    line-height: 1.1;
}

.title-roman {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(3.5rem, 9vw, 8rem);
    color: var(--text-primary);
    letter-spacing: 0.08em;
    line-height: 1.1;
    margin-top: -0.1em;
}

.title-attribution {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.85rem, 1.2vw, 1.1rem);
    color: var(--text-secondary);
    letter-spacing: 0.25em;
    text-transform: uppercase;
    margin-top: 1.5em;
}

/* ============================================================
   Spread 2 -- The Invention
   Two-column layout. Body text left, heroic consonants right.
   ============================================================ */
#spread-2 {
    background-color: var(--bg-primary);
}

.col-text {
    padding-top: 2rem;
}

.body-text p {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.25rem);
    color: var(--text-primary);
    line-height: var(--line-height-body);
    margin-bottom: 1.5em;
}

.body-text p:last-child {
    margin-bottom: 0;
}

.consonant-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    padding-top: 2rem;
}

.consonant-glyph {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 0;
}

/* Heroic-scale consonants: clamp(6rem, 15vw, 12rem) in gold on black */
.glyph-char {
    font-family: var(--font-korean);
    font-weight: 700;
    font-size: clamp(6rem, 15vw, 12rem);
    color: var(--gold-primary);
    line-height: 1;
}

.glyph-label {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    margin-top: 0.5em;
}

/* Gold hairline rules (wonsaengi-inspired) */
.gold-rule {
    width: 60%;
    height: 1px;
    background: rgba(201, 168, 76, 0.3);
    margin: 0 auto;
}

/* ============================================================
   Spread 3 -- The Geometry
   Diagrammatic spread with SVG line drawings in gold and cream.
   ============================================================ */
#spread-3 {
    background-color: var(--bg-secondary);
}

.geometry-diagram {
    width: 100%;
    max-width: 900px;
}

.geometry-row {
    display: grid;
    grid-template-columns: 120px 1fr 160px;
    gap: 30px;
    align-items: center;
    padding: 1.5rem 0;
}

.geometry-glyph {
    display: flex;
    align-items: center;
    justify-content: center;
}

.geo-char {
    font-family: var(--font-korean);
    font-weight: 700;
    font-size: clamp(3rem, 5vw, 4.5rem);
    color: var(--gold-primary);
    line-height: 1;
}

.geometry-desc {
    display: flex;
    flex-direction: column;
    gap: 0.3em;
    text-align: left;
}

.geo-name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.3rem;
    color: var(--text-primary);
    letter-spacing: 0.05em;
}

.geo-organ {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-style: italic;
}

.geo-ipa {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.mono {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

.geometry-svg {
    display: flex;
    align-items: center;
    justify-content: center;
}

.organ-diagram {
    width: 120px;
    height: 80px;
}

.gold-rule-full {
    width: 100%;
    height: 1px;
    background: rgba(201, 168, 76, 0.2);
}

/* ============================================================
   Spread 4 -- The Vowels
   Cosmological triad: Heaven (dot), Earth (horizontal), Human (vertical).
   Warm-black (#2A2520) tertiary background for contrast.
   ============================================================ */
#spread-4 {
    background-color: var(--bg-tertiary);
}

.vowel-triad {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    max-width: 700px;
    width: 100%;
}

.vowel-element {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 3rem 2rem;
}

.vowel-symbol {
    font-family: var(--font-korean);
    font-weight: 700;
    color: var(--gold-primary);
    line-height: 1;
    margin-bottom: 0.4em;
}

.vowel-dot {
    font-size: clamp(4rem, 10vw, 8rem);
}

.vowel-horizontal {
    font-size: clamp(4rem, 10vw, 8rem);
}

.vowel-vertical {
    font-size: clamp(4rem, 10vw, 8rem);
}

.vowel-concept {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: var(--text-primary);
    letter-spacing: 0.1em;
    margin-bottom: 0.3em;
}

.vowel-name-kr {
    font-family: var(--font-korean);
    font-weight: 300;
    font-size: clamp(0.75rem, 1vw, 0.9rem);
    color: var(--text-secondary);
    margin-bottom: 1em;
}

.vowel-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.9rem, 1.1vw, 1.05rem);
    color: var(--text-secondary);
    line-height: 1.75;
    max-width: 520px;
}

/* Gold hairline vertical rule (cosmological triad separator) */
.gold-rule-vertical {
    width: 1px;
    height: 60px;
    background: rgba(201, 168, 76, 0.3);
}

/* ============================================================
   Spread 5 -- The Syllable Block
   Interactive assembly animation: jamo -> syllable block
   ============================================================ */
#spread-5 {
    background-color: var(--bg-primary);
}

.syllable-assembly {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2rem;
}

#assembly-container {
    position: relative;
    width: clamp(200px, 30vw, 350px);
    height: clamp(200px, 30vw, 350px);
    cursor: pointer;
    margin-bottom: 1rem;
}

#jamo-group {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.jamo-piece {
    font-family: var(--font-korean);
    font-weight: 700;
    font-size: clamp(3rem, 6vw, 5rem);
    color: var(--gold-primary);
    opacity: 0.6;
    transition: all 600ms ease-in-out;
    position: absolute;
}

/* Jamo starting positions (loose triangle arrangement) */
#jamo-h {
    top: 5%;
    left: 50%;
    transform: translateX(-50%);
}

#jamo-a {
    top: 40%;
    right: 5%;
    transform: translateY(-50%);
}

#jamo-n {
    bottom: 5%;
    left: 50%;
    transform: translateX(-50%);
}

/* Assembled state: jamo fade out */
.jamo-piece.assembled {
    opacity: 0;
}

/* Assembled syllable: appears with scale-up */
#assembled-syllable {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    font-family: var(--font-korean);
    font-weight: 700;
    font-size: clamp(6rem, 14vw, 12rem);
    color: var(--gold-primary);
    opacity: 0;
    transition: all 600ms ease-in-out;
    line-height: 1;
}

#assembled-syllable.visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Gold glow pulse after assembly */
#assembled-syllable.glow {
    text-shadow: 0 0 40px rgba(201, 168, 76, 0.4), 0 0 80px rgba(201, 168, 76, 0.2);
}

.assembly-instruction {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
    opacity: 0.7;
    transition: opacity 400ms ease-out;
}

.assembly-instruction.hidden {
    opacity: 0;
}

.assembly-labels {
    display: flex;
    gap: 2rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.assembly-label {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.8rem, 1vw, 0.95rem);
    color: var(--text-secondary);
}

.assembly-label .mono {
    color: var(--gold-primary);
    margin-right: 0.3em;
}

.syllable-explanation {
    max-width: 680px;
    margin-top: 1rem;
}

.syllable-explanation p {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    color: var(--text-secondary);
    line-height: 1.8;
    text-align: center;
}

/* ============================================================
   Spread 6 -- The Legacy
   Closing quotation. Gold colophon. Vermillion seal mark.
   Fades to pure black.
   ============================================================ */
#spread-6 {
    background-color: var(--bg-primary);
}

.legacy-quote {
    max-width: 800px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2em;
    margin-bottom: 3rem;
}

.quote-classical {
    font-family: var(--font-korean);
    font-weight: 300;
    font-size: clamp(1.1rem, 2vw, 1.6rem);
    color: var(--text-secondary);
    letter-spacing: 0.15em;
    line-height: 1.6;
}

.quote-hangul {
    font-family: var(--font-korean);
    font-weight: 700;
    font-size: clamp(1.3rem, 2.5vw, 2rem);
    color: var(--gold-primary);
    letter-spacing: 0.08em;
    line-height: 1.6;
}

.quote-english {
    font-family: var(--font-display);
    font-weight: 600;
    font-style: italic;
    font-size: clamp(1.2rem, 2.2vw, 1.8rem);
    color: var(--text-primary);
    line-height: 1.6;
    max-width: 600px;
}

.quote-cite {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.8rem, 1vw, 0.95rem);
    color: var(--text-secondary);
    letter-spacing: 0.1em;
    font-style: normal;
}

/* Colophon with gold wordmark and vermillion seal */
.colophon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1em;
}

.seal-mark {
    margin-bottom: 0.5em;
}

.seal-svg {
    width: 60px;
    height: 60px;
}

.colophon-text {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--gold-primary);
    letter-spacing: 0.15em;
}

.colophon-date {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--text-secondary);
    letter-spacing: 0.1em;
}

/* ============================================================
   Fade-Reveal Animation
   Core pattern: opacity 0->1, translateY(20px)->0, ease-out 800ms.
   Staggered via data-delay attributes in JS.
   ============================================================ */
.fade-reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity var(--transition-fade), transform var(--transition-fade);
}

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

/* ============================================================
   Responsive -- Tablet (max-width: 900px)
   ============================================================ */
@media (max-width: 900px) {
    .spread-two-col {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    /* On mobile, show consonants first (visual impact before text) */
    .col-right {
        order: -1;
    }

    .consonant-display {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 1rem;
    }

    .consonant-glyph {
        padding: 1rem;
    }

    .glyph-char {
        font-size: clamp(3rem, 10vw, 6rem);
    }

    .gold-rule {
        display: none;
    }

    .geometry-row {
        grid-template-columns: 80px 1fr;
        gap: 15px;
    }

    /* Hide SVG diagrams on tablet (too small to read) */
    .geometry-svg {
        display: none;
    }

    .vowel-triad {
        gap: 0;
    }

    .vowel-element {
        padding: 2rem 1rem;
    }

    .assembly-labels {
        flex-direction: column;
        align-items: center;
        gap: 0.8rem;
    }
}

/* ============================================================
   Responsive -- Mobile (max-width: 600px)
   ============================================================ */
@media (max-width: 600px) {
    :root {
        --margin-outer: 20px;
        --spread-gap: 10vh;
    }

    .spread {
        min-height: auto;
        padding-top: 8vh;
        padding-bottom: 8vh;
    }

    /* Title page always full viewport */
    #spread-1 {
        min-height: 100vh;
    }

    .title-hangul {
        font-size: clamp(3rem, 15vw, 6rem);
    }

    .title-roman {
        font-size: clamp(2rem, 10vw, 4rem);
    }

    .geometry-row {
        grid-template-columns: 60px 1fr;
        gap: 10px;
    }

    .geo-char {
        font-size: clamp(2rem, 8vw, 3rem);
    }

    .geo-name {
        font-size: 1rem;
    }

    .geo-organ {
        font-size: 0.85rem;
    }

    .vowel-dot,
    .vowel-horizontal,
    .vowel-vertical {
        font-size: clamp(3rem, 12vw, 5rem);
    }

    .vowel-concept {
        font-size: clamp(1.2rem, 4vw, 1.8rem);
    }

    #assembly-container {
        width: 200px;
        height: 200px;
    }

    .legacy-quote {
        gap: 1em;
    }
}
