/* ==========================================================================
   hangul.dev -- Styles
   A Typographic Exhibition of the Korean Alphabet
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Custom Properties
   -------------------------------------------------------------------------- */
:root {
    /* Palette from DESIGN.md */
    --lamp-black: #0A0A08;
    --ink-wash: #1A1814;
    --aged-leaf-gold: #C9A84C;
    --muted-brass: #8B7355;
    --pale-champagne: #D4C5A0;
    --vermillion-seal: #B83A2A;
    --charcoal-smoke: #2A2822;
    --white-hanji: #F2EDE4;

    /* Typography scale */
    --display-size: clamp(2.5rem, 6vw, 5rem);
    --body-size: clamp(1rem, 1.2vw, 1.15rem);
    --annotation-size: clamp(0.75rem, 0.9vw, 0.9rem);

    /* Spacing */
    --spine-width: 1px;
}

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

html {
    scroll-behavior: auto;
    overflow: hidden;
    height: 100%;
}

body {
    background-color: var(--lamp-black);
    color: var(--pale-champagne);
    font-family: 'Lora', serif;
    font-weight: 400;
    font-size: var(--body-size);
    line-height: 1.85;
    letter-spacing: 0.01em;
    overflow: hidden;
    height: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Hanji paper texture overlay - subtle noise at 3% opacity */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 200px 200px;
    opacity: 0.4;
}

/* --------------------------------------------------------------------------
   Main Scroll Container
   -------------------------------------------------------------------------- */
#spreads-container {
    height: 100vh;
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
}

/* --------------------------------------------------------------------------
   Spread Base
   -------------------------------------------------------------------------- */
.spread {
    width: 100%;
    height: 100vh;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    overflow: hidden;
    position: relative;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.spread.visible {
    opacity: 1;
}

.spread-inner {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: 5fr 2fr 5fr;
    position: relative;
}

/* --------------------------------------------------------------------------
   Spine Line (center gutter representing book binding)
   -------------------------------------------------------------------------- */
.spine-line {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: var(--spine-width);
    background-color: var(--muted-brass);
    opacity: 0.4;
    transform: translateX(-50%);
    z-index: 1;
}

/* --------------------------------------------------------------------------
   Pages (left and right of the open book)
   -------------------------------------------------------------------------- */
.page {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.page-left {
    grid-column: 1;
    padding: 4vh 3vw 4vh 5vw;
}

.page-right {
    grid-column: 3;
    padding: 4vh 5vw 4vh 3vw;
}

.right-content {
    max-width: 100%;
}

/* --------------------------------------------------------------------------
   Typography
   -------------------------------------------------------------------------- */

/* Display / Headlines - Cormorant Garamond SemiBold */
h1, h2, .site-title, .spread-heading {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    color: var(--aged-leaf-gold);
    letter-spacing: 0.04em;
    line-height: 1.15;
}

.site-title {
    font-size: clamp(2.5rem, 6vw, 5rem);
    letter-spacing: 0.15em;
    text-transform: lowercase;
    margin-bottom: 1.5rem;
}

.spread-heading {
    font-size: clamp(2rem, 4.5vw, 3.5rem);
    margin-bottom: 1.2rem;
}

.subtitle {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(1.1rem, 1.8vw, 1.5rem);
    color: var(--pale-champagne);
    letter-spacing: 0.06em;
    line-height: 1.5;
    margin-bottom: 2rem;
}

/* Section Labels - Spectral uppercase */
.section-label {
    display: block;
    font-family: 'Spectral', serif;
    font-weight: 200;
    font-size: var(--annotation-size);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted-brass);
    margin-bottom: 1rem;
}

/* Body Text - Lora */
.body-text {
    font-family: 'Lora', serif;
    font-weight: 400;
    font-size: var(--body-size);
    line-height: 1.85;
    letter-spacing: 0.01em;
    color: var(--pale-champagne);
    margin-bottom: 1.5rem;
}

.body-text em {
    font-style: italic;
    color: var(--white-hanji);
}

/* Annotation Text - Spectral Light */
.annotation-note {
    font-family: 'Spectral', serif;
    font-weight: 300;
    font-size: var(--annotation-size);
    letter-spacing: 0.06em;
    color: var(--muted-brass);
}

/* Intro Text */
.intro-text {
    font-family: 'Lora', serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    line-height: 1.85;
    color: var(--pale-champagne);
    max-width: 32ch;
}

/* --------------------------------------------------------------------------
   Annotation Lines (thin gold rules connecting content)
   -------------------------------------------------------------------------- */
.annotation-line {
    width: 60px;
    height: 1px;
    background-color: var(--muted-brass);
    margin-bottom: 1.8rem;
}

.annotation-connector {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--charcoal-smoke);
}

/* --------------------------------------------------------------------------
   Hangul Display Characters
   -------------------------------------------------------------------------- */
.hangul-display {
    font-family: 'Noto Serif KR', 'Batang', 'BatangChe', serif;
    font-weight: 900;
    color: var(--aged-leaf-gold);
    font-size: 40vw;
    line-height: 1;
    display: block;
    text-align: center;
    position: relative;
    z-index: 2;
    opacity: 0;
    transition: opacity 1.2s ease-out;
}

.hangul-display.revealed {
    opacity: 1;
}

/* --------------------------------------------------------------------------
   Hero Character (Spread I)
   -------------------------------------------------------------------------- */
.hero-character {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.construction-lines {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: 80%;
    z-index: 1;
    pointer-events: none;
}

.c-line {
    opacity: 0;
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 2s ease-out, opacity 0.6s ease;
}

.c-line.drawn {
    stroke-dashoffset: 0;
    opacity: 1;
}

.c-point {
    opacity: 0;
    transition: opacity 0.6s ease 2s;
}

.c-point.drawn {
    opacity: 1;
}

.hero-character .hangul-display {
    font-size: clamp(15rem, 40vw, 50vw);
    position: relative;
    z-index: 2;
}

/* --------------------------------------------------------------------------
   Specimen Grid (Spread II)
   -------------------------------------------------------------------------- */
.specimen-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 2px;
    width: 100%;
    max-width: 480px;
}

.specimen-char {
    font-family: 'Noto Serif KR', 'Batang', 'BatangChe', serif;
    font-weight: 900;
    font-size: clamp(2rem, 4vw, 3.5rem);
    color: var(--aged-leaf-gold);
    text-align: center;
    padding: 1rem 0.5rem;
    position: relative;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease, color 0.3s ease;
}

.specimen-char::after {
    content: attr(data-phonetic);
    display: block;
    font-family: 'Spectral', serif;
    font-weight: 300;
    font-size: 0.6rem;
    letter-spacing: 0.04em;
    color: var(--muted-brass);
    margin-top: 0.3rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.specimen-char:hover::after {
    opacity: 1;
}

/* Specimen annotation SVG (connecting lines from grid to right page) */
.specimen-annotation-svg {
    position: absolute;
    top: 15%;
    right: 0;
    width: 15%;
    height: 70%;
    pointer-events: none;
    opacity: 0.5;
}

/* Interactive Hangul hover effect */
.hangul-interactive {
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hangul-interactive:hover {
    transform: scale(1.05);
    box-shadow: 0 0 40px rgba(201, 168, 76, 0.15);
}

/* --------------------------------------------------------------------------
   Vowel Construction (Spread III)
   -------------------------------------------------------------------------- */
.detail-display {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.vowel-construction {
    width: 100%;
    max-width: 400px;
    height: auto;
}

.stroke-anim {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    transition: stroke-dashoffset 1.2s ease-out;
}

.stroke-anim.drawn {
    stroke-dashoffset: 0;
}

.stroke-anim-dot {
    opacity: 0;
    transform-origin: center;
    transition: opacity 0.6s ease 1s;
}

.stroke-anim-dot.drawn {
    opacity: 1;
}

.c-line-detail {
    opacity: 0;
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 1s ease-out 1.5s, opacity 0.6s ease 1.5s;
}

.c-line-detail.drawn {
    stroke-dashoffset: 0;
    opacity: 1;
}

/* Vowel specimens row */
.vowel-specimens {
    display: flex;
    gap: 1.5rem;
    margin-top: 2.5rem;
    flex-wrap: wrap;
}

.vowel-item {
    text-align: center;
    padding: 0.5rem;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.vowel-item:hover {
    transform: scale(1.05);
    box-shadow: 0 0 40px rgba(201, 168, 76, 0.15);
}

.vowel-char {
    display: block;
    font-family: 'Noto Serif KR', 'Batang', 'BatangChe', serif;
    font-weight: 900;
    font-size: clamp(1.8rem, 3vw, 2.8rem);
    color: var(--aged-leaf-gold);
    line-height: 1.2;
}

.vowel-label {
    display: block;
    font-family: 'Spectral', serif;
    font-weight: 300;
    font-size: var(--annotation-size);
    letter-spacing: 0.06em;
    color: var(--muted-brass);
    margin-top: 0.3rem;
}

/* --------------------------------------------------------------------------
   Essay Spread (Spread IV)
   -------------------------------------------------------------------------- */
.essay-content {
    padding: 6vh 0;
    max-width: 100%;
    position: relative;
    z-index: 1;
}

.pull-quote {
    margin: 2.5rem 0;
    padding: 2rem 0;
    border-top: 1px solid var(--charcoal-smoke);
    border-bottom: 1px solid var(--charcoal-smoke);
}

.quote-hangul {
    display: block;
    font-family: 'Noto Serif KR', 'Batang', 'BatangChe', serif;
    font-weight: 700;
    font-size: clamp(1.4rem, 2.5vw, 2.2rem);
    color: var(--white-hanji);
    line-height: 1.5;
    margin-bottom: 0.8rem;
}

.quote-translation {
    display: block;
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-style: italic;
    font-size: clamp(1rem, 1.5vw, 1.3rem);
    color: var(--aged-leaf-gold);
    letter-spacing: 0.02em;
    line-height: 1.5;
}

/* Syllable block background grid pattern */
.syllable-grid-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background-image:
        linear-gradient(to right, rgba(139, 115, 85, 0.05) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(139, 115, 85, 0.05) 1px, transparent 1px);
    background-size: 60px 60px;
}

/* Brush-stroke ghosts (decorative calligraphic traces) */
.spread-essay::before {
    content: '';
    position: absolute;
    top: 10%;
    left: 5%;
    width: 40%;
    height: 80%;
    background: radial-gradient(ellipse at center, rgba(139, 115, 85, 0.04) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
    transform: rotate(-5deg);
}

.spread-essay::after {
    content: '';
    position: absolute;
    bottom: 15%;
    right: 10%;
    width: 25%;
    height: 50%;
    background: radial-gradient(ellipse at center, rgba(139, 115, 85, 0.03) 0%, transparent 65%);
    pointer-events: none;
    z-index: 0;
    transform: rotate(8deg);
}

/* --------------------------------------------------------------------------
   Closing Spread (Spread V)
   -------------------------------------------------------------------------- */
.syllable-demo {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.syllable-block-display {
    text-align: center;
}

.block-frame {
    position: relative;
    display: inline-block;
    margin-bottom: 2rem;
}

.block-grid-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.block-char-assembled {
    font-family: 'Noto Serif KR', 'Batang', 'BatangChe', serif;
    font-weight: 900;
    font-size: clamp(6rem, 15vw, 14rem);
    color: var(--aged-leaf-gold);
    line-height: 1;
    position: relative;
    z-index: 1;
    padding: 1rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.block-char-assembled:hover {
    transform: scale(1.05);
    box-shadow: 0 0 40px rgba(201, 168, 76, 0.15);
}

.block-breakdown {
    display: flex;
    gap: 2rem;
    justify-content: center;
    align-items: center;
}

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

.component-char {
    display: block;
    font-family: 'Noto Serif KR', 'Batang', 'BatangChe', serif;
    font-weight: 900;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: var(--aged-leaf-gold);
    line-height: 1.2;
}

.component-arrow {
    display: block;
    font-size: 0.8rem;
    color: var(--muted-brass);
    margin: 0.3rem 0;
}

.component-role {
    display: block;
    font-family: 'Spectral', serif;
    font-weight: 300;
    font-size: var(--annotation-size);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted-brass);
}

/* Closing content layout */
.closing-content {
    display: flex;
    flex-direction: column;
}

.colophon-text {
    font-family: 'Spectral', serif;
    font-weight: 200;
    font-size: var(--annotation-size);
    letter-spacing: 0.06em;
    color: var(--muted-brass);
    margin-top: 3rem;
}

/* --------------------------------------------------------------------------
   Royal Seal
   -------------------------------------------------------------------------- */
.royal-seal {
    position: absolute;
    bottom: 5vh;
    right: 5vw;
    width: 60px;
    height: 60px;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.royal-seal.visible {
    opacity: 1;
}

.seal-svg {
    width: 100%;
    height: 100%;
}

.seal-colophon {
    position: relative;
    bottom: auto;
    right: auto;
    margin-top: 2rem;
    width: 50px;
    height: 50px;
}

/* --------------------------------------------------------------------------
   Folio Navigation
   -------------------------------------------------------------------------- */
#folio-nav {
    position: fixed;
    right: 2.5vw;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2rem;
}

.folio-numeral {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--aged-leaf-gold);
    opacity: 0.2;
    cursor: pointer;
    transition: opacity 0.3s ease;
    letter-spacing: 0.04em;
    line-height: 1;
}

.folio-numeral.active {
    opacity: 1;
}

.folio-numeral:hover {
    opacity: 0.7;
}

.folio-progress {
    width: 1px;
    height: 80px;
    background-color: var(--charcoal-smoke);
    position: relative;
    margin-top: 0.5rem;
}

.folio-progress-fill {
    width: 100%;
    height: 0%;
    background-color: var(--aged-leaf-gold);
    transition: height 0.3s ease;
    position: absolute;
    top: 0;
    left: 0;
}

/* --------------------------------------------------------------------------
   Page Turn Line Effect
   -------------------------------------------------------------------------- */
.page-turn-line {
    position: fixed;
    top: 50%;
    left: 0;
    width: 0%;
    height: 1px;
    background-color: var(--aged-leaf-gold);
    z-index: 200;
    pointer-events: none;
    transform: translateY(-50%);
    opacity: 0;
    transition: none;
}

.page-turn-line.active {
    animation: pageTurnSweep 200ms ease-out forwards;
}

@keyframes pageTurnSweep {
    0% {
        width: 0%;
        left: 0;
        opacity: 1;
    }
    100% {
        width: 100%;
        left: 0;
        opacity: 1;
    }
}

.page-turn-line.fade-out {
    opacity: 0;
    transition: opacity 200ms ease;
}

/* --------------------------------------------------------------------------
   Fade Text Animation (staggered paragraph reveal)
   -------------------------------------------------------------------------- */
.fade-text {
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

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

/* --------------------------------------------------------------------------
   Title Content Specific (Opening Spread)
   -------------------------------------------------------------------------- */
.title-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.title-content .site-title {
    opacity: 0;
    transition: opacity 0.8s ease-out;
}

.title-content .site-title.revealed {
    opacity: 1;
}

.title-content .subtitle {
    opacity: 0;
    transition: opacity 0.6s ease-out 0.2s;
}

.title-content .subtitle.revealed {
    opacity: 1;
}

.title-content .annotation-line {
    opacity: 0;
    transition: opacity 0.6s ease-out 0.4s;
}

.title-content .annotation-line.revealed {
    opacity: 1;
}

.title-content .intro-text {
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.5s ease-out 0.6s, transform 0.5s ease-out 0.6s;
}

.title-content .intro-text.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* --------------------------------------------------------------------------
   Stroke Terminal Border Pattern (decorative edge)
   -------------------------------------------------------------------------- */
.spread-specimen::before {
    content: '';
    position: absolute;
    top: 3vh;
    left: 5vw;
    right: 5vw;
    height: 1px;
    background: repeating-linear-gradient(
        90deg,
        var(--muted-brass) 0px,
        var(--muted-brass) 20px,
        transparent 20px,
        transparent 28px,
        var(--muted-brass) 28px,
        var(--muted-brass) 32px,
        transparent 32px,
        transparent 40px
    );
    opacity: 0.25;
    pointer-events: none;
    z-index: 0;
}

.spread-specimen::after {
    content: '';
    position: absolute;
    bottom: 3vh;
    left: 5vw;
    right: 5vw;
    height: 1px;
    background: repeating-linear-gradient(
        90deg,
        var(--muted-brass) 0px,
        var(--muted-brass) 20px,
        transparent 20px,
        transparent 28px,
        var(--muted-brass) 28px,
        var(--muted-brass) 32px,
        transparent 32px,
        transparent 40px
    );
    opacity: 0.25;
    pointer-events: none;
    z-index: 0;
}

/* --------------------------------------------------------------------------
   Responsive Adjustments
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
    .spread-inner {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }

    .page-left {
        grid-column: 1;
        grid-row: 1;
        padding: 3vh 5vw;
        height: 50vh;
    }

    .page-right {
        grid-column: 1;
        grid-row: 2;
        padding: 3vh 5vw;
        height: 50vh;
    }

    .spine-line {
        top: 50%;
        bottom: auto;
        left: 5%;
        right: 5%;
        width: auto;
        height: var(--spine-width);
        transform: none;
    }

    .hero-character .hangul-display {
        font-size: clamp(8rem, 30vw, 20rem);
    }

    #folio-nav {
        right: 1.5vw;
    }

    .specimen-grid {
        grid-template-columns: repeat(auto-fill, minmax(55px, 1fr));
    }

    .block-char-assembled {
        font-size: clamp(4rem, 12vw, 8rem);
    }

    .specimen-annotation-svg {
        display: none;
    }
}

@media (max-width: 600px) {
    .site-title {
        font-size: clamp(1.8rem, 8vw, 3rem);
    }

    .spread-heading {
        font-size: clamp(1.5rem, 6vw, 2.5rem);
    }

    .folio-numeral {
        font-size: 0.7rem;
    }

    #folio-nav {
        gap: 0.8rem;
    }

    .folio-progress {
        height: 50px;
    }

    .vowel-specimens {
        gap: 0.8rem;
    }

    .block-breakdown {
        gap: 1rem;
    }
}

/* --------------------------------------------------------------------------
   Selection Styles
   -------------------------------------------------------------------------- */
::selection {
    background-color: rgba(201, 168, 76, 0.3);
    color: var(--white-hanji);
}

/* --------------------------------------------------------------------------
   Scrollbar (hidden for clean presentation)
   -------------------------------------------------------------------------- */
#spreads-container::-webkit-scrollbar {
    width: 0;
    display: none;
}

#spreads-container {
    scrollbar-width: none;
    -ms-overflow-style: none;
}
