/* =====================================================
   hangul.day — Ink Well palette, kinetic typography
   ===================================================== */

:root {
    /* Ink Well palette */
    --ink: #0A0A0A;             /* soybean ink black */
    --paper: #F4EFE6;           /* hanji cream */
    --vermillion: #9C1F1F;      /* seal red */
    --brass: #C8B47A;           /* antique brass — annotations */
    --cypress: #1F2A2E;         /* dark cypress — secondary panels */
    --hanji-hi: #E8DDC4;        /* aged hanji highlight */

    /* Hangul em-square base unit (square syllable block) */
    --em: clamp(14px, 1.6vw, 22px);

    /* Easing tokens */
    --ease-ink: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-out: cubic-bezier(0.7, 0, 0.84, 0);

    /* Stroke timing — heartbeat ~ 60bpm == 1000ms per stroke */
    --stroke-dur: 1000ms;
    --stroke-delay: 600ms;

    /* Type scale */
    --t-display: clamp(8rem, 22vw, 24rem);
    --t-anatomy: clamp(14rem, 36vw, 28rem);
    --t-spread: clamp(10rem, 18vw, 22rem);
    --t-h: clamp(1.6rem, 2.4vw, 2.6rem);
    --t-body: 1.0625rem;
    --t-mono: 0.75rem;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: "IBM Plex Sans KR", "IBM Plex Sans", system-ui, sans-serif;
    font-weight: 300;
    font-size: var(--t-body);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html {
    scroll-behavior: smooth;
}

body {
    /* faint hanji noise — generative SVG noise overlay */
    background-image:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.05 0 0 0 0 0.05 0 0 0 0 0.05 0 0 0 0.6 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.18'/></svg>");
    background-repeat: repeat;
    overflow-x: hidden;
}

::selection {
    background: var(--vermillion);
    color: var(--paper);
}

a {
    color: inherit;
    text-decoration: none;
}

/* =====================================================
   Custom cursor ring (pointer:fine only)
   ===================================================== */
.cursor-ring {
    position: fixed;
    top: 0; left: 0;
    width: 14px; height: 14px;
    border: 1px solid var(--paper);
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
    transform: translate3d(-50%, -50%, 0);
    mix-blend-mode: difference;
    transition: width 360ms var(--ease-ink), height 360ms var(--ease-ink), opacity 240ms var(--ease-ink), border-color 240ms var(--ease-ink);
    opacity: 0;
}
.cursor-ring.active { opacity: 1; }
.cursor-ring.expanded {
    width: 24px; height: 24px;
}

@media (pointer: coarse) {
    .cursor-ring { display: none; }
}

/* =====================================================
   Sprocket strip — left vertical rule
   ===================================================== */
.sprocket {
    position: fixed;
    top: 0; left: 0;
    width: 64px;
    height: 100vh;
    z-index: 30;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    font-family: "JetBrains Mono", monospace;
    font-size: var(--t-mono);
    color: var(--paper);
    mix-blend-mode: difference;
}

.sprocket::before {
    content: "";
    position: absolute;
    left: 32px;
    top: 0; bottom: 0;
    width: 1px;
    background: currentColor;
    opacity: 0.55;
}

.sprocket-mark {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 22px 0;
    pointer-events: auto;
    cursor: pointer;
    opacity: 0.55;
    transition: opacity 280ms var(--ease-ink);
}
.sprocket-mark:hover,
.sprocket-mark.is-active { opacity: 1; }

.sprocket-mark::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 9px; height: 9px;
    background: currentColor;
    border-radius: 0;
}

.sprocket-num,
.sprocket-label {
    background: transparent;
    padding: 2px 6px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-weight: 500;
    z-index: 1;
}

.sprocket-mark .sprocket-num,
.sprocket-mark .sprocket-label {
    /* clip the rule behind text using paper bg block */
    background: var(--ink);
}

.sprocket-mark.is-active .sprocket-num,
.sprocket-mark.is-active .sprocket-label {
    color: var(--vermillion);
}

.sprocket-bar {
    position: absolute;
    left: 32px;
    top: 0;
    width: 1px;
    background: var(--vermillion);
    height: 0%;
    transition: height 320ms var(--ease-ink);
    opacity: 0.85;
}

/* =====================================================
   Audio toggle (opt-in)
   ===================================================== */
.audio-toggle {
    position: fixed;
    top: 24px;
    right: 32px;
    z-index: 50;
    background: transparent;
    border: 1px solid currentColor;
    padding: 8px 14px;
    color: var(--paper);
    mix-blend-mode: difference;
    font-family: "JetBrains Mono", monospace;
    font-size: var(--t-mono);
    letter-spacing: 0.22em;
    text-transform: uppercase;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: background 240ms var(--ease-ink), color 240ms var(--ease-ink);
}
.audio-toggle:hover { background: var(--paper); color: var(--ink); mix-blend-mode: normal; }

.audio-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.4;
}
.audio-toggle[aria-pressed="true"] .audio-dot { opacity: 1; background: var(--vermillion); }
.audio-toggle[aria-pressed="true"] .audio-label::before { content: "ON  "; }

/* =====================================================
   Square syllable-block grid overlay
   ===================================================== */
.syllable-grid {
    position: fixed;
    top: 0; left: 0;
    right: 0; bottom: 0;
    pointer-events: none;
    z-index: 5;
    opacity: 0;
    background-image:
        linear-gradient(to right, currentColor 1px, transparent 1px),
        linear-gradient(to bottom, currentColor 1px, transparent 1px);
    background-size: calc(var(--em) * 6) calc(var(--em) * 6);
    color: var(--paper);
    transition: opacity 1200ms var(--ease-ink);
}
.syllable-grid.is-on { opacity: 0.06; }

/* =====================================================
   Movements — shared
   ===================================================== */
.movement {
    position: relative;
    width: 100%;
}

.movement-header {
    position: relative;
    padding: clamp(28px, 4vw, 64px) clamp(80px, 8vw, 120px);
    z-index: 10;
}

.movement-eyebrow {
    font-family: "JetBrains Mono", monospace;
    font-size: var(--t-mono);
    letter-spacing: 0.28em;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 14px;
}

.eyebrow-divider { opacity: 0.4; }

/* =====================================================
   MOVEMENT ONE — 초성
   ===================================================== */
.movement-one {
    background: var(--ink);
    color: var(--paper);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.movement-one .movement-eyebrow { color: var(--paper); opacity: 0.7; }

.cho-stage {
    position: relative;
    flex: 1;
    display: grid;
    place-items: center;
    padding: clamp(20px, 4vw, 60px);
}

.hero-glyph {
    width: min(80vw, 80vh);
    height: min(80vw, 80vh);
    max-width: 720px;
    max-height: 720px;
    overflow: visible;
    display: block;
}

.hero-glyph .stroke {
    /* dasharray + offset set in JS via getTotalLength() */
    opacity: 1;
}

/* fallback: in case JS hasn't run, show static glyph */
.hero-glyph.no-anim .stroke {
    stroke-dasharray: none;
    stroke-dashoffset: 0;
}

.cho-caption {
    position: absolute;
    left: 50%;
    bottom: clamp(80px, 14vh, 180px);
    transform: translateX(-50%);
    margin: 0;
    font-family: "Gowun Batang", "IBM Plex Sans KR", serif;
    font-weight: 400;
    font-size: clamp(1.1rem, 1.6vw, 1.6rem);
    letter-spacing: -0.01em;
    color: var(--paper);
    opacity: 0;
    text-align: center;
    transition: opacity 1800ms var(--ease-ink);
    white-space: nowrap;
}
.cho-caption.is-visible { opacity: 0.92; }

.cho-subtitle {
    position: absolute;
    right: clamp(20px, 4vw, 60px);
    bottom: clamp(20px, 3vw, 40px);
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-family: "IBM Plex Sans KR", sans-serif;
    font-size: 0.75rem;
    color: var(--brass);
    opacity: 0;
    transition: opacity 1400ms var(--ease-ink);
    text-align: right;
    max-width: 320px;
}
.cho-subtitle.is-visible { opacity: 0.8; }

.subtitle-tag {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.65rem;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--brass);
    opacity: 0.6;
}

.subtitle-text {
    color: var(--paper);
    font-style: italic;
}

.cho-year {
    position: absolute;
    left: clamp(80px, 8vw, 120px);
    top: clamp(28px, 5vw, 80px);
    font-family: "Gowun Batang", serif;
    font-weight: 700;
    font-size: clamp(2.4rem, 4vw, 4rem);
    color: var(--vermillion);    /* vermillion #1 of 3 */
    letter-spacing: -0.02em;
    opacity: 0;
    transition: opacity 1200ms var(--ease-ink) 800ms;
}
.cho-year.is-visible { opacity: 1; }

.scroll-cue {
    position: absolute;
    left: 50%;
    bottom: 30px;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    font-family: "JetBrains Mono", monospace;
    font-size: var(--t-mono);
    letter-spacing: 0.28em;
    color: var(--paper);
    opacity: 0.5;
}

.scroll-cue-line {
    display: block;
    width: 1px;
    height: 40px;
    background: currentColor;
    animation: scrollCueLine 2.4s var(--ease-ink) infinite;
}

@keyframes scrollCueLine {
    0% { transform: scaleY(0.1); transform-origin: top; }
    50% { transform: scaleY(1); transform-origin: top; }
    51% { transform: scaleY(1); transform-origin: bottom; }
    100% { transform: scaleY(0.1); transform-origin: bottom; }
}

/* =====================================================
   MOVEMENT TWO — 중성 — horizontal scroll anatomy
   ===================================================== */
.movement-two {
    background: var(--cypress);
    color: var(--paper);
    /* outer height drives horizontal scroll */
    height: 600vh;
    position: relative;
}

.jung-sticky {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.movement-two .movement-eyebrow { color: var(--paper); opacity: 0.7; }
.jung-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.jung-progress {
    font-family: "JetBrains Mono", monospace;
    font-size: var(--t-mono);
    letter-spacing: 0.2em;
    color: var(--brass);
}
.jung-progress-current { color: var(--paper); font-weight: 500; }
.jung-progress-total { opacity: 0.6; margin-left: 6px; }

.jung-strip {
    flex: 1;
    display: flex;
    align-items: stretch;
    will-change: transform;
}

.jung-panel {
    flex: 0 0 100vw;
    width: 100vw;
    height: 100%;
    padding: 0 clamp(80px, 10vw, 180px);
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    align-items: center;
    gap: clamp(40px, 6vw, 120px);
    position: relative;
}

.panel-glyph-wrap {
    position: relative;
    height: 70vh;
    display: grid;
    place-items: center;
}

.anatomy-glyph {
    width: 100%;
    height: 100%;
    max-width: clamp(40vh, 60vw, 90vh);
    max-height: clamp(40vh, 60vw, 90vh);
    overflow: visible;
}

.anatomy-stroke {
    /* set length-based dasharray in JS */
    opacity: 1;
}

.anatomy-lines {
    opacity: 0;
    transition: opacity 1100ms var(--ease-ink) 350ms;
}
.is-active-panel .anatomy-lines { opacity: 1; }

.anatomy-label {
    position: absolute;
    font-family: "JetBrains Mono", monospace;
    font-size: 0.7rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--brass);
    line-height: 1.55;
    max-width: 200px;
    opacity: 0;
    transition: opacity 1100ms var(--ease-ink) 500ms, color 240ms var(--ease-ink);
}
.is-active-panel .anatomy-label { opacity: 1; }

.anatomy-label:hover { color: var(--hanji-hi); }

.label-tl { top: 6%; left: -4%; text-align: left; }
.label-br { bottom: 6%; right: -2%; text-align: right; }

.label-sub {
    display: block;
    font-family: "IBM Plex Sans KR", sans-serif;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    text-transform: none;
    color: var(--paper);
    opacity: 0.6;
    margin-top: 4px;
}

.panel-meta {
    max-width: 32ch;
    transform: translateY(20px);
    opacity: 0;
    transition: transform 900ms var(--ease-ink) 250ms, opacity 900ms var(--ease-ink) 250ms;
}
.is-active-panel .panel-meta {
    opacity: 1;
    transform: translateY(0);
}

.panel-name {
    font-family: "Gowun Batang", serif;
    font-size: clamp(2.4rem, 5vw, 4.6rem);
    line-height: 1;
    margin: 0 0 18px;
    color: var(--paper);
    letter-spacing: -0.02em;
}

.panel-romanization {
    display: inline-block;
    margin-left: 20px;
    font-family: "JetBrains Mono", monospace;
    font-size: 0.85rem;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--brass);
    vertical-align: middle;
}

.panel-essay {
    margin: 0;
    color: var(--paper);
    opacity: 0.85;
    font-size: 1rem;
    line-height: 1.75;
}

.jung-dots {
    position: absolute;
    bottom: 38px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 14px;
    z-index: 10;
}
.jung-dot {
    width: 22px;
    height: 1px;
    background: var(--paper);
    opacity: 0.3;
    transition: opacity 320ms var(--ease-ink), width 320ms var(--ease-ink), background 320ms var(--ease-ink);
    cursor: pointer;
}
.jung-dot.is-on { opacity: 1; width: 38px; background: var(--brass); }

.jung-hint {
    position: absolute;
    bottom: 32px;
    right: clamp(40px, 5vw, 100px);
    margin: 0;
    font-family: "JetBrains Mono", monospace;
    font-size: var(--t-mono);
    letter-spacing: 0.32em;
    color: var(--brass);
    opacity: 0.6;
}

/* =====================================================
   MOVEMENT THREE — 종성 — magazine spread
   ===================================================== */
.movement-three {
    background: var(--paper);
    color: var(--ink);
    padding-bottom: clamp(60px, 10vh, 160px);
}

.movement-three .movement-eyebrow { color: var(--ink); opacity: 0.7; }
.movement-three .eyebrow-divider { color: var(--ink); }

.jong-header {
    border-bottom: 1px solid rgba(10,10,10,0.12);
    margin-bottom: clamp(40px, 6vh, 100px);
}

.spread {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: auto;
    gap: clamp(2rem, 4vw, 6rem);
    padding: 0 clamp(80px, 8vw, 120px);
    margin-bottom: clamp(80px, 14vh, 220px);
    position: relative;
}

/* Spread 1 — glyph 글 with essay top-right */
.spread-one {
    grid-template-rows: auto auto auto;
}
.spread-one .spread-glyph {
    grid-column: 1 / span 6;
    grid-row: 1 / span 3;
}
.spread-one .spread-essay-1 {
    grid-column: 8 / span 5;
    grid-row: 1 / span 1;
}
.spread-one .spread-marginal-1 {
    grid-column: 9 / span 4;
    grid-row: 3 / span 1;
    align-self: end;
}

/* Spread 2 — pull quote left, glyph 민 right (Black Han Sans, vermillion) */
.spread-two {
    grid-template-rows: auto auto;
    align-items: center;
}
.spread-two .spread-pullquote {
    grid-column: 1 / span 6;
    grid-row: 1 / span 1;
}
.spread-two .spread-glyph-bold {
    grid-column: 8 / span 5;
    grid-row: 1 / span 2;
}
.spread-two .spread-marginal-2 {
    grid-column: 1 / span 4;
    grid-row: 2 / span 1;
}

/* Spread 3 — glyph 날 left, essay right, stat block bottom */
.spread-three {
    grid-template-rows: auto auto;
}
.spread-three .spread-glyph-tall {
    grid-column: 1 / span 5;
    grid-row: 1 / span 2;
}
.spread-three .spread-essay-3 {
    grid-column: 7 / span 6;
    grid-row: 1 / span 1;
}
.spread-three .spread-stat {
    grid-column: 9 / span 4;
    grid-row: 2 / span 1;
    align-self: end;
}

.spread-glyph {
    font-family: "Gowun Batang", serif;
    font-weight: 700;
    line-height: 0.85;
    letter-spacing: -0.04em;
    color: var(--ink);
    display: flex;
    align-items: flex-start;
    overflow: hidden;
}

.spread-glyph-han {
    font-size: var(--t-spread);
    display: inline-block;
}

.spread-glyph-bold .spread-glyph-han {
    font-family: "Black Han Sans", sans-serif;
    font-weight: 400;
    color: var(--ink);
    letter-spacing: 0;
    line-height: 1;
}

.spread-glyph-tall .spread-glyph-han {
    font-size: clamp(12rem, 22vw, 28rem);
    line-height: 0.85;
}

.spread-h {
    font-family: "Gowun Batang", serif;
    font-size: var(--t-h);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0 0 0.6em;
    color: var(--ink);
}

.spread-essay p {
    margin: 0 0 1em;
    color: rgba(10,10,10,0.84);
    max-width: 36ch;
}

.spread-essay em {
    font-style: italic;
    color: var(--ink);
}

.spread-meta {
    font-family: "JetBrains Mono", monospace;
    font-size: var(--t-mono);
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--brass);
    margin-top: 1.4em;
}

.spread-marginal {
    border-top: 1px solid var(--brass);
    padding-top: 12px;
    font-family: "Gowun Batang", serif;
    font-size: 1.05rem;
    color: var(--ink);
    opacity: 0.78;
}

.spread-pullquote p {
    font-family: "Gowun Batang", serif;
    font-size: clamp(1.6rem, 2.6vw, 2.8rem);
    font-weight: 400;
    line-height: 1.35;
    letter-spacing: -0.02em;
    margin: 0 0 0.6em;
    color: var(--ink);
}

.spread-quote-attr {
    font-family: "JetBrains Mono", monospace !important;
    font-size: var(--t-mono) !important;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--brass) !important;
    font-weight: 500;
}

.spread-stat {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-left: 1px solid var(--ink);
    padding-left: 24px;
}

.spread-stat-num {
    font-family: "Gowun Batang", serif;
    font-weight: 700;
    font-size: clamp(2.6rem, 4.6vw, 4.6rem);
    color: var(--ink);
    line-height: 1;
    letter-spacing: -0.02em;
}

.spread-stat-label {
    font-family: "Gowun Batang", serif;
    font-size: 1.4rem;
    color: var(--ink);
}

/* =====================================================
   Colophon — vermillion seal #3
   ===================================================== */
.colophon {
    margin-top: clamp(120px, 20vh, 240px);
    padding: clamp(60px, 10vh, 160px) clamp(80px, 8vw, 120px);
    text-align: center;
    border-top: 1px solid rgba(10,10,10,0.12);
}

.colophon-line {
    font-family: "Gowun Batang", serif;
    font-size: clamp(1.6rem, 3vw, 3rem);
    font-weight: 400;
    letter-spacing: -0.02em;
    margin: 0 0 12px;
}

.colophon-translation {
    font-family: "IBM Plex Sans KR", sans-serif;
    font-style: italic;
    font-size: 1rem;
    color: rgba(10,10,10,0.6);
    margin: 0 0 60px;
}

.seal {
    width: 120px;
    height: 120px;
    margin: 0 auto 40px;
    transform: rotate(-3deg) scale(0.92);
    opacity: 0;
    transition: opacity 1400ms var(--ease-ink), transform 1400ms var(--ease-ink);
    filter: drop-shadow(0 0 0 transparent);
}
.seal.is-stamped {
    opacity: 1;
    transform: rotate(-3deg) scale(1);
}
.seal svg { width: 100%; height: 100%; display: block; }

.colophon-stamp {
    font-family: "JetBrains Mono", monospace;
    font-size: var(--t-mono);
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--brass);
    margin: 0;
}

/* =====================================================
   Responsive
   ===================================================== */
@media (max-width: 900px) {
    .sprocket { width: 44px; }
    .sprocket::before { left: 22px; }
    .sprocket-bar { left: 22px; }
    .sprocket-mark { padding: 14px 0; }

    .movement-header { padding: 24px 20px 20px 56px; }

    .audio-toggle { right: 16px; top: 16px; padding: 6px 10px; }

    .cho-caption {
        font-size: 1rem;
        padding: 0 24px;
        white-space: normal;
        bottom: 14vh;
    }
    .cho-subtitle { right: 16px; bottom: 14px; max-width: 70%; }
    .cho-year { left: 56px; top: 22px; }

    .movement-two { height: 500vh; }
    .jung-panel {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr auto;
        padding: 80px 24px 80px 56px;
        gap: 24px;
    }
    .panel-glyph-wrap { height: 50vh; }
    .label-tl { top: 0; left: 0; }
    .label-br { bottom: 0; right: 0; }
    .panel-meta { max-width: 100%; }

    .spread { padding: 0 24px 0 56px; gap: 32px; }
    .spread-one,
    .spread-two,
    .spread-three {
        grid-template-columns: 1fr;
    }
    .spread-one .spread-glyph,
    .spread-one .spread-essay-1,
    .spread-one .spread-marginal-1,
    .spread-two .spread-pullquote,
    .spread-two .spread-glyph-bold,
    .spread-two .spread-marginal-2,
    .spread-three .spread-glyph-tall,
    .spread-three .spread-essay-3,
    .spread-three .spread-stat {
        grid-column: 1 / -1;
        grid-row: auto;
    }
}
