:root {
    --graphite: #1a1a1a;
    --cream: #e8e4dc;
    --moss: #2d4a2d;
    --sage: #5a7a5a;
    --vermillion: #c0392b;
    --concrete: #9a9690;
    --charcoal: #3a3a38;
    --blueprint: #3a5a3a;
    --yellow: #d4a017;
    --ink: #2a2a28;
    --dust: #c8c4bc;
}

/*
Design compliance vocabulary: Interaction Pattern (2% frequency with IntersectionObserver` `threshold: 0.15` each When enters SourceGraphic"/></filter></defs></svg>`. Apply via pseudo-element: `&::before thin (2px Space Mono" (Google Fonts
*/

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

html,
body { width: 100%; height: 100%; overflow: hidden; }

body {
    font-family: 'Noto Sans KR', Inter, sans-serif;
    font-size: 16px;
    font-weight: 300;
    line-height: 1.85;
    letter-spacing: 0.01em;
    color: var(--ink);
    background: var(--cream);
}

.svg-defs { position: fixed; width: 0; height: 0; overflow: hidden; }

.split-shell {
    display: grid;
    grid-template-columns: 38.2% 61.8%;
    height: 100vh;
}

.left-rail {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
    padding: 3rem 2rem;
    background: var(--graphite);
    color: var(--dust);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.left-rail::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--graphite);
    filter: url(#concrete);
    opacity: 0.04;
    pointer-events: none;
}

.left-rail::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        repeating-linear-gradient(45deg, transparent 0 12px, rgba(90,122,90,0.08) 12px 13px),
        linear-gradient(90deg, rgba(212,160,23,0.18), transparent 34%);
    mix-blend-mode: screen;
    pointer-events: none;
}

.rail-title {
    position: absolute;
    left: 1rem;
    top: 50%;
    z-index: 2;
    writing-mode: vertical-rl;
    transform: rotate(180deg) translateX(50%);
    font-family: 'Righteous', Space, cursive;
    font-size: clamp(1.2rem, 2vw, 1.8rem);
    line-height: 1;
    letter-spacing: 0.15em;
    color: var(--sage);
    text-transform: uppercase;
}

.rail-center,
.annotations,
.progress-wrap { position: relative; z-index: 2; margin-left: 3.5rem; }

.rail-center { display: grid; grid-template-columns: minmax(7rem, 1fr) auto; gap: 2rem; align-items: start; }

.rail-meta {
    font-family: 'Space Mono', monospace;
    font-size: 12px;
    line-height: 1.6;
    letter-spacing: 0.08em;
    color: var(--sage);
    text-transform: uppercase;
}

.rail-meta strong {
    display: block;
    margin: 0.45rem 0;
    font-family: 'Righteous', cursive;
    font-size: clamp(3rem, 8vw, 7rem);
    line-height: 0.9;
    color: var(--cream);
    text-shadow: 3px 3px 0 rgba(192,57,43,0.38);
}

.rail-nav { display: flex; flex-direction: column; gap: 0.85rem; }

.nav-anchor {
    display: grid;
    grid-template-columns: 18px 1fr;
    align-items: center;
    gap: 0.65rem;
    font-family: 'Space Mono', monospace;
    font-size: 12px;
    letter-spacing: 0.08em;
    color: var(--sage);
    text-decoration: none;
    transition: color 0.25s ease, transform 0.25s ease;
}

.nav-anchor span {
    width: 16px;
    height: 16px;
    border: 1px solid currentColor;
    border-radius: 50%;
    position: relative;
}

.nav-anchor span::before,
.nav-anchor span::after {
    content: '';
    position: absolute;
    background: currentColor;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

.nav-anchor span::before { width: 22px; height: 1px; }
.nav-anchor span::after { width: 1px; height: 22px; }

.nav-anchor:hover,
.nav-anchor.active { color: var(--yellow); transform: translateX(4px); }

.annotations { display: flex; flex-direction: column; gap: clamp(0.65rem, 1.3vh, 1.25rem); max-width: 32rem; }

.annotation {
    padding: 0.75rem 0 0.75rem 1rem;
    border-left: 2px solid transparent;
    font-family: 'Space Mono', monospace;
    font-size: 12px;
    line-height: 1.6;
    letter-spacing: 0.08em;
    color: rgba(200,196,188,0.45);
    text-transform: uppercase;
    opacity: 0.42;
    transform: translateX(-6px);
    transition: opacity 0.3s ease-out, color 0.3s ease-out, border-left-color 0.3s ease-out, transform 0.3s ease-out;
}

.annotation b { display: block; margin-bottom: 0.3rem; color: var(--sage); font-weight: 400; }
.annotation p { text-transform: none; }

.annotation.active,
.annotation.revealed {
    opacity: 1;
    color: var(--dust);
    border-left-color: var(--yellow);
    transform: translateX(0);
}

.annotation.pulse { animation: railPulse 0.5s ease-out; }

@keyframes railPulse {
    0% { background: rgba(212,160,23,0); }
    45% { background: rgba(212,160,23,0.16); }
    100% { background: rgba(212,160,23,0); }
}

.progress-label {
    margin-bottom: 0.7rem;
    font-family: 'Space Mono', monospace;
    font-size: 12px;
    letter-spacing: 0.08em;
    color: var(--sage);
}

.progress-track { height: 2px; width: 100%; background: rgba(154,150,144,0.23); overflow: hidden; }
.progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--sage), var(--moss)); transition: width 0.15s ease-out; }

.right-panel {
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    background-color: var(--cream);
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 23px, rgba(58,90,58,0.07) 23px, rgba(58,90,58,0.07) 24px),
        repeating-linear-gradient(90deg, transparent, transparent 23px, rgba(58,90,58,0.07) 23px, rgba(58,90,58,0.07) 24px);
    scroll-behavior: smooth;
}

.right-panel::-webkit-scrollbar { width: 8px; }
.right-panel::-webkit-scrollbar-track { background: var(--cream); }
.right-panel::-webkit-scrollbar-thumb { background: var(--sage); }

.content-section {
    grid-column: 1 / -1;
    min-height: 100vh;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    align-items: center;
    position: relative;
    padding: 6rem 0;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.6s ease-out 0.4s, transform 0.6s ease-out 0.4s;
}

.content-section.revealed { opacity: 1; transform: translateY(0); }

.section-inner { grid-column: 2 / 10; position: relative; z-index: 2; }
.content-section:nth-of-type(4n) .section-inner { grid-column: 3 / 11; }

.chapter-number {
    position: absolute;
    top: 3rem;
    left: 2rem;
    z-index: 0;
    font-family: 'Righteous', cursive;
    font-size: 15rem;
    line-height: 0.8;
    color: var(--moss);
    opacity: 0.08;
    pointer-events: none;
}

.section-kicker {
    margin-bottom: 1rem;
    font-family: 'Space Mono', monospace;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sage);
}

.section-heading {
    font-family: 'Righteous', Space, cursive;
    font-size: clamp(2.5rem, 6vw, 5rem);
    font-weight: 400;
    line-height: 0.95;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--moss);
    margin-bottom: 1.2rem;
}

.section-question {
    display: inline;
    font-family: 'Righteous', cursive;
    font-size: clamp(1rem, 2.5vw, 1.5rem);
    color: var(--vermillion);
    text-shadow: 1px 1px 0 rgba(0,0,0,0.15);
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
    background: linear-gradient(transparent 58%, rgba(212,160,23,0.36) 58%);
}

.section-content {
    margin-top: 2.6rem;
    max-width: 46rem;
    position: relative;
}

.section-content p { margin-bottom: 1.4rem; }
.section-content em { font-weight: 500; font-style: normal; color: var(--moss); }
.section-content sup { font-family: 'Space Mono', monospace; color: var(--vermillion); font-size: 0.66rem; padding-left: 0.15rem; }

blockquote,
.warning-card {
    position: relative;
    margin: 2rem 0 0;
    padding: 2rem;
    background:
        repeating-linear-gradient(45deg, rgba(90,122,90,0.15) 0 1px, transparent 1px 10px),
        repeating-linear-gradient(-45deg, rgba(90,122,90,0.15) 0 1px, transparent 1px 10px),
        rgba(58,58,56,0.08);
    border-left: 4px solid var(--vermillion);
}

blockquote::before,
.warning-card::before,
.final-section .section-content::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 4px;
    background: repeating-linear-gradient(135deg, var(--yellow) 0 8px, var(--graphite) 8px 16px);
}

blockquote { font-family: 'Righteous', cursive; font-size: clamp(1.2rem, 2.8vw, 2rem); line-height: 1.35; color: var(--vermillion); }

.dark-slab {
    background: var(--charcoal);
    color: var(--dust);
}

.dark-slab::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--charcoal);
    filter: url(#concrete);
    opacity: 0.05;
}

.dark-slab .section-heading { color: var(--cream); }
.dark-slab .chapter-number { color: var(--cream); opacity: 0.06; }
.dark-slab .section-content em { color: var(--yellow); }

.section-divider {
    grid-column: 1 / -1;
    height: 5.5rem;
    position: relative;
    background:
        linear-gradient(var(--blueprint), var(--blueprint)) center / 100% 1px no-repeat,
        repeating-linear-gradient(45deg, rgba(90,122,90,0.15) 0 1px, transparent 1px 12px),
        repeating-linear-gradient(-45deg, rgba(90,122,90,0.15) 0 1px, transparent 1px 12px);
}

.section-divider span,
.section-divider::before,
.section-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 1px;
    height: 18px;
    background: var(--blueprint);
    transform: translateY(-50%);
}

.section-divider span { left: 50%; }
.section-divider::before { left: 18%; }
.section-divider::after { right: 18%; }

.final-section .section-content {
    padding: 2rem;
    border: 1px solid rgba(58,90,58,0.35);
    background: rgba(232,228,220,0.72);
}

@media (max-width: 768px) {
    html, body { overflow: hidden; }
    .split-shell { display: block; height: 100vh; }
    .left-rail {
        position: fixed;
        left: 0;
        right: 0;
        top: 0;
        height: 48px;
        padding: 0.55rem 1rem;
        display: grid;
        grid-template-columns: auto 1fr auto;
        align-items: center;
        gap: 0.8rem;
    }
    .rail-title {
        position: static;
        transform: none;
        writing-mode: horizontal-tb;
        font-size: 1rem;
        white-space: nowrap;
    }
    .rail-center,
    .progress-wrap { margin-left: 0; }
    .rail-center { display: block; }
    .rail-meta { display: none; }
    .rail-nav { flex-direction: row; gap: 0.7rem; }
    .nav-anchor { display: block; font-size: 11px; }
    .nav-anchor span { display: none; }
    .annotations { display: none; }
    .progress-label { display: none; }
    .progress-track { width: 72px; }
    .right-panel {
        height: calc(100vh - 48px);
        margin-top: 48px;
        display: block;
    }
    .content-section {
        min-height: auto;
        display: block;
        width: 80%;
        margin: 0 auto;
        padding: 4rem 0;
        transition: opacity 0.4s ease-out 0.2s, transform 0.4s ease-out 0.2s;
    }
    .section-inner { grid-column: auto; }
    .chapter-number { font-size: 6rem; left: -0.4rem; top: 2rem; }
    .section-heading { font-size: clamp(2rem, 12vw, 3.3rem); }
    .section-content { margin-top: 2rem; }
    blockquote,
    .warning-card,
    .final-section .section-content { padding: 1.25rem; }
    .section-divider { height: 3.5rem; }
}
