/* ============================================
   hangeul.day — Styles
   Editorial Folio / Gold-Black-Luxury
   Typography: Playfair Display, Cormorant Garamond,
   IBM Plex Mono, Noto Serif KR
   Palette: #0A0A0A, #1A1714, #C9A243, #D4BF8A,
   #F0E8D4, #7A6530, #8B2020, #FAF6EE
   ============================================ */

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

:root {
    /* Color Palette */
    --ink-night: #0A0A0A;
    --charcoal-silk: #1A1714;
    --museum-gold: #C9A243;
    --parchment-gold: #D4BF8A;
    --hanji-cream: #F0E8D4;
    --antique-bronze: #7A6530;
    --stamp-red: #8B2020;
    --rice-paper: #FAF6EE;

    /* Typography */
    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'Cormorant Garamond', Garamond, serif;
    --font-mono: 'IBM Plex Mono', 'Courier New', monospace;
    --font-korean: 'Noto Serif KR', serif;

    /* Layout */
    --mat-margin: 48px;
    --inner-margin: 24px;
    --gutter-position: 52%;
}

html {
    scroll-behavior: auto;
    overflow-x: hidden;
}

body {
    background-color: var(--ink-night);
    color: var(--hanji-cream);
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(1rem, 1.2vw, 1.25rem);
    line-height: 1.85;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* --- Keyframe Animations --- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes strokeDraw {
    from { stroke-dashoffset: 300; }
    to { stroke-dashoffset: 0; }
}

@keyframes sealPulse {
    0%, 100% { border-color: var(--stamp-red); }
    50% { border-color: rgba(139, 32, 32, 0.4); }
}

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

@keyframes inkShimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* --- Colophon Bar (persistent, fixed) --- */
#colophon-bar {
    position: fixed;
    bottom: 32px;
    left: var(--mat-margin);
    z-index: 100;
    opacity: 0;
    transition: opacity 600ms cubic-bezier(0.25, 0.1, 0.25, 1.0);
    pointer-events: none;
}

#colophon-bar.visible {
    opacity: 1;
}

.colophon-line {
    width: 40vw;
    height: 1px;
    background-color: var(--museum-gold);
}

.colophon-number {
    display: block;
    margin-top: 8px;
    font-family: var(--font-mono);
    font-weight: 300;
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--antique-bronze);
}

/* --- Spread Layout --- */
.spread {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--mat-margin);
    overflow: hidden;
}

.spread-inner {
    display: grid;
    grid-template-columns: var(--gutter-position) 1fr;
    gap: 0;
    width: 100%;
    max-width: 100%;
    min-height: calc(100vh - var(--mat-margin) * 2);
    align-items: center;
}

/* Plate Side (left) */
.plate {
    position: relative;
    padding-right: 48px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    min-height: calc(100vh - var(--mat-margin) * 2);
}

/* Text Side (right) */
.text-side {
    padding-left: var(--inner-margin);
    padding-right: var(--inner-margin);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1.5rem;
}

/* --- Transition Zones (ink wash / sumukhwa) --- */
.transition-zone {
    height: 20vh;
    position: relative;
    background: radial-gradient(ellipse at 30% 50%, rgba(10,10,10,0.0) 0%, var(--ink-night) 70%),
                radial-gradient(ellipse at 70% 40%, rgba(10,10,10,0.0) 0%, var(--ink-night) 80%);
}

.transition-zone::before,
.transition-zone::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.transition-zone::before {
    background: radial-gradient(ellipse at 25% 30%, rgba(26,23,20,0.4) 0%, transparent 60%);
}

.transition-zone::after {
    background: radial-gradient(ellipse at 75% 70%, rgba(26,23,20,0.3) 0%, transparent 50%);
}

/* --- Typography --- */
.section-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.5rem, 2.5vw, 2.5rem);
    color: var(--museum-gold);
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
    transition: color 300ms ease;
}

.section-title:hover {
    color: var(--parchment-gold);
}

.body-text {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(1rem, 1.2vw, 1.25rem);
    line-height: 1.85;
    color: var(--hanji-cream);
}

.body-text strong,
.body-text b {
    font-weight: 600;
    color: var(--parchment-gold);
}

.mono-annotation {
    font-family: var(--font-mono);
    font-weight: 300;
    font-size: clamp(0.65rem, 0.8vw, 0.8rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--antique-bronze);
}

/* --- Fade Reveal Animation --- */
.fade-reveal {
    opacity: 0;
    transition: opacity 800ms cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.fade-reveal.revealed {
    opacity: 1;
}

/* --- Dojang Seal (one per spread, lower-right of plate) --- */
.dojang {
    position: absolute;
    bottom: 24px;
    right: 48px;
    width: 32px;
    height: 32px;
    border: 1px solid var(--stamp-red);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-korean);
    font-size: 14px;
    font-weight: 400;
    color: var(--stamp-red);
    cursor: default;
    transition: transform 200ms ease, border-color 200ms ease;
    user-select: none;
}

.dojang:hover {
    transform: scale(0.95);
    border-color: rgba(139, 32, 32, 0.8);
}

/* ============================================ */
/* SPREAD 1: Title                             */
/* ============================================ */
#spread-1 .plate {
    align-items: flex-start;
    justify-content: center;
}

.title-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 0.85;
}

.title-char {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(4rem, 12vw, 12rem);
    color: var(--rice-paper);
    letter-spacing: 0.04em;
    display: block;
    line-height: 0.85;
}

.title-dot-wrap {
    display: block;
    line-height: 0.85;
    padding: 0.15em 0;
}

.title-dot {
    display: inline-block;
    width: clamp(1.5rem, 4vw, 5rem);
    height: clamp(1.5rem, 4vw, 5rem);
    background-color: var(--museum-gold);
    border-radius: 50%;
    animation: goldGlow 4s ease-in-out infinite;
}

.date-reveal {
    margin-top: 2rem;
}

.date-reveal .mono-annotation {
    font-size: clamp(1.5rem, 3vw, 3rem);
    color: var(--museum-gold);
    letter-spacing: 0.12em;
    opacity: 0;
    transition: opacity 2000ms cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.date-reveal.revealed .mono-annotation {
    opacity: 1;
}

/* ============================================ */
/* SPREAD 2: Origin / Jamo Grid                */
/* ============================================ */
.jamo-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 12px;
    width: 100%;
    max-width: 520px;
}

.jamo-char {
    font-family: var(--font-korean);
    font-weight: 200;
    font-size: clamp(1.8rem, 3.5vw, 3rem);
    color: var(--museum-gold);
    text-align: center;
    padding: 8px 0;
    transition: color 300ms ease;
}

.jamo-char:hover {
    color: var(--parchment-gold);
}

.jamo-vowel {
    color: var(--parchment-gold);
}

.jamo-vowel:hover {
    color: var(--rice-paper);
}

/* ============================================ */
/* SPREAD 3: Geometry                          */
/* ============================================ */
.geometry-canvas {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
}

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

.construction-line {
    stroke: var(--antique-bronze);
    stroke-width: 0.5;
    opacity: 0.3;
}

.geo-shape {
    fill: none;
    stroke: var(--museum-gold);
    stroke-width: 2;
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    transition: stroke-dashoffset 1200ms cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.geo-shape.drawn {
    stroke-dashoffset: 0;
}

.geo-circle {
    stroke-dasharray: 252;
    stroke-dashoffset: 252;
}

.geo-circle.drawn {
    stroke-dashoffset: 0;
}

.geo-hline {
    stroke-dasharray: 160;
    stroke-dashoffset: 160;
}

.geo-hline.drawn {
    stroke-dashoffset: 0;
}

.geo-vline {
    stroke-dasharray: 120;
    stroke-dashoffset: 120;
}

.geo-vline.drawn {
    stroke-dashoffset: 0;
}

.geo-label {
    font-family: var(--font-mono);
    font-size: 10px;
    fill: var(--antique-bronze);
    letter-spacing: 0.08em;
    opacity: 0;
    transition: opacity 800ms cubic-bezier(0.25, 0.1, 0.25, 1.0) 600ms;
}

.geo-label.revealed {
    opacity: 1;
}

.vowel-result {
    font-family: var(--font-korean);
    font-size: 36px;
    fill: var(--parchment-gold);
    opacity: 0;
    transition: opacity 800ms cubic-bezier(0.25, 0.1, 0.25, 1.0) 1400ms;
}

.vowel-result.revealed {
    opacity: 1;
}

/* ============================================ */
/* SPREAD 4: Specimen                          */
/* ============================================ */
.specimen-sheet {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.specimen-row {
    display: flex;
    align-items: baseline;
    gap: 16px;
    padding: 4px 0;
    border-bottom: 1px solid rgba(122, 101, 48, 0.1);
}

.specimen-row:last-child {
    border-bottom: none;
}

.specimen-line {
    font-family: var(--font-korean);
    font-size: clamp(1rem, 1.8vw, 1.6rem);
    color: var(--hanji-cream);
    line-height: 1.6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.specimen-weight-label {
    flex-shrink: 0;
    white-space: nowrap;
    font-size: clamp(0.55rem, 0.7vw, 0.7rem);
}

/* ============================================ */
/* SPREAD 5: Combination                       */
/* ============================================ */
.combination-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 40px;
    width: 100%;
    min-height: 60vh;
}

.combination-demo {
    display: flex;
    align-items: center;
    gap: 16px;
    opacity: 0;
    transition: opacity 800ms cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.combination-demo.revealed {
    opacity: 1;
}

.jamo-piece {
    font-family: var(--font-korean);
    font-weight: 200;
    font-size: clamp(2.5rem, 5vw, 4.5rem);
    color: var(--museum-gold);
    position: relative;
    transition: transform 600ms cubic-bezier(0.17, 0.67, 0.38, 1.2),
                color 300ms ease;
}

/* Spring easing for jamo combination animation (tension: 170, friction: 26) */
.jamo-piece.spring-animate {
    color: var(--parchment-gold);
}

.jamo-plus,
.jamo-equals {
    font-family: var(--font-mono);
    font-weight: 300;
    font-size: clamp(1rem, 1.5vw, 1.5rem);
    color: var(--antique-bronze);
}

.syllable-result {
    font-family: var(--font-korean);
    font-weight: 700;
    font-size: clamp(3rem, 6vw, 5.5rem);
    color: var(--rice-paper);
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 500ms cubic-bezier(0.25, 0.1, 0.25, 1.0),
                transform 600ms cubic-bezier(0.17, 0.67, 0.38, 1.2);
}

.syllable-result.revealed {
    opacity: 1;
    transform: scale(1);
}

.final-word {
    font-family: var(--font-korean);
    font-weight: 900;
    font-size: clamp(4rem, 10vw, 9rem);
    color: var(--museum-gold);
    letter-spacing: 0.08em;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 800ms cubic-bezier(0.25, 0.1, 0.25, 1.0),
                transform 800ms cubic-bezier(0.17, 0.67, 0.38, 1.2);
}

.final-word.revealed {
    opacity: 1;
    transform: scale(1);
}

/* ============================================ */
/* SPREAD 6: Living Script                     */
/* ============================================ */
.living-collage {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 32px;
    width: 100%;
    max-width: 480px;
    align-items: center;
    justify-items: center;
}

.living-svg {
    width: 100%;
    height: auto;
    transition: opacity 300ms ease;
}

.living-svg:hover {
    opacity: 0.85;
}

.neon-sign {
    grid-column: 1 / -1;
    max-width: 280px;
}

.phone-screen {
    max-width: 120px;
    justify-self: end;
}

.book-spine {
    max-width: 50px;
    justify-self: start;
}

.street-sign {
    grid-column: 1 / -1;
    max-width: 300px;
}

/* ============================================ */
/* SPREAD 7: Colophon                          */
/* ============================================ */
.colophon-plate {
    align-items: center;
    justify-content: center;
}

.dojang-large {
    position: relative;
    bottom: auto;
    right: auto;
    width: 120px;
    height: 120px;
    font-size: 48px;
    border-width: 2px;
    margin: 0 auto;
    animation: sealPulse 6s ease-in-out infinite;
}

.dojang-large:hover {
    transform: scale(0.95);
}

.colophon-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.colophon-details {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.colophon-label {
    margin-top: 0.5rem;
}

.colophon-label .mono-annotation {
    color: var(--museum-gold);
}

.colophon-korean {
    margin-top: 2rem;
    font-family: var(--font-mono);
    font-weight: 300;
    font-size: 10px;
    letter-spacing: 0.04em;
    color: var(--antique-bronze);
}

/* ============================================ */
/* Selection Styles                            */
/* ============================================ */
::selection {
    background-color: rgba(201, 162, 67, 0.3);
    color: var(--rice-paper);
}

::-moz-selection {
    background-color: rgba(201, 162, 67, 0.3);
    color: var(--rice-paper);
}

/* ============================================ */
/* Scrollbar Styling                           */
/* ============================================ */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--ink-night);
}

::-webkit-scrollbar-thumb {
    background: var(--antique-bronze);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--museum-gold);
}

/* ============================================ */
/* Responsive Adjustments                      */
/* ============================================ */
@media (max-width: 900px) {
    :root {
        --mat-margin: 24px;
        --inner-margin: 16px;
    }

    .spread-inner {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        gap: 2rem;
    }

    .plate {
        padding-right: 0;
        min-height: auto;
        align-items: center;
    }

    .text-side {
        padding-left: 0;
        padding-right: 0;
    }

    .title-stack {
        align-items: center;
    }

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

    .jamo-grid {
        max-width: 100%;
    }

    .colophon-line {
        width: 60vw;
    }

    .living-collage {
        max-width: 100%;
    }

    .combination-stage {
        min-height: 40vh;
    }

    .dojang {
        right: 24px;
        bottom: 16px;
    }

    .geometry-canvas {
        max-width: 300px;
    }
}

@media (max-width: 600px) {
    :root {
        --mat-margin: 16px;
        --inner-margin: 12px;
    }

    .title-char {
        font-size: clamp(2.5rem, 18vw, 6rem);
    }

    .jamo-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 8px;
    }

    .combination-demo {
        gap: 8px;
    }

    .jamo-piece {
        font-size: clamp(1.8rem, 8vw, 3rem);
    }

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

    .final-word {
        font-size: clamp(3rem, 16vw, 6rem);
    }

    .specimen-row {
        flex-direction: column;
        gap: 4px;
    }

    .specimen-line {
        font-size: clamp(0.8rem, 3vw, 1.2rem);
        white-space: normal;
    }

    .dojang-large {
        width: 80px;
        height: 80px;
        font-size: 32px;
    }

    .section-title {
        font-size: clamp(1.2rem, 5vw, 2rem);
    }
}
