/* ============================================
   계엄령.com - Terracotta Editorial Design
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --bg-primary: #F5EDE0;
    --bg-secondary: #8B5E3C;
    --text-primary: #2C2418;
    --text-secondary: #6B5B4F;
    --accent-primary: #C4663A;
    --accent-secondary: #7A3B2E;
    --grid-line: #C4A882;
    --highlight: #D4956B;
    --dark-bg: #3A2E26;
    --dark-text: #EDE4D6;
    --font-headline: 'Space Mono', monospace;
    --font-body: 'Source Serif 4', 'Noto Serif KR', serif;
    --font-caption: 'IBM Plex Mono', monospace;
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
    position: relative;
    /* Paper grain texture */
    background-image: repeating-conic-gradient(var(--text-primary) 0% 25%, transparent 0% 50%);
    background-size: 3px 3px;
    background-blend-mode: overlay;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: repeating-conic-gradient(var(--text-primary) 0% 25%, transparent 0% 50%);
    background-size: 3px 3px;
    opacity: 0.03;
    pointer-events: none;
    z-index: 9999;
}

/* --- Scroll Progress Bar --- */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    width: 0%;
    background-color: var(--accent-primary);
    z-index: 10001;
    transition: width 50ms linear;
}

/* --- Top Navigation --- */
.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    z-index: 10000;
    background-color: rgba(245, 237, 224, 0.95);
    border-bottom: 1px solid var(--grid-line);
    transition: height 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                border-bottom-color 0.4s ease,
                background-color 0.4s ease;
}

.top-nav.scrolled {
    height: 32px;
    border-bottom-color: transparent;
}

.top-nav.dark-mode {
    background-color: rgba(58, 46, 38, 0.95);
}

.nav-label {
    font-family: var(--font-caption);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
    transition: color 0.4s ease;
}

.top-nav.dark-mode .nav-label {
    color: var(--dark-text);
}

.nav-chapter {
    font-family: var(--font-caption);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    color: var(--accent-primary);
}

/* --- Left Margin Notebook Line --- */
.margin-line {
    position: fixed;
    left: calc(50% - 340px);
    top: 0;
    width: 1px;
    height: 100%;
    background: linear-gradient(to bottom, transparent, var(--grid-line) 10%, var(--accent-primary));
    z-index: 100;
    transform-origin: top;
    transform: scaleY(0);
    transition: transform 0.1s linear;
    opacity: 0.5;
}

@media (max-width: 768px) {
    .margin-line {
        left: 16px;
    }
}

/* --- Chapter Base Styles --- */
.chapter {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 120px 32px;
}

.chapter--light {
    background-color: var(--bg-primary);
}

.chapter--dark {
    background-color: var(--dark-bg);
}

.chapter--hero {
    background-color: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chapter--closing {
    background-color: var(--dark-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
}

/* --- Grid Lines (Structural Ornaments) --- */
.grid-line {
    position: absolute;
    top: 0;
    width: 1px;
    height: 100%;
    background-color: var(--grid-line);
    opacity: 0;
    transform: scaleY(0);
    transform-origin: top;
    transition: opacity 0.6s ease, transform 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.grid-line--left {
    left: calc(50% - 340px);
}

.grid-line--right {
    right: calc(50% - 340px);
}

.grid-line.visible {
    opacity: 0.4;
    transform: scaleY(1);
}

/* Grid line small square terminals */
.grid-line::before,
.grid-line::after {
    content: '';
    position: absolute;
    width: 4px;
    height: 4px;
    background-color: var(--grid-line);
    left: -1.5px;
}

.grid-line::before {
    top: 0;
}

.grid-line::after {
    bottom: 0;
}

@media (max-width: 768px) {
    .grid-line--left {
        left: 16px;
    }
    .grid-line--right {
        right: 16px;
    }
}

/* --- Hero Section --- */
.hero-content {
    text-align: center;
    z-index: 2;
}

.hero-headline {
    font-family: var(--font-headline);
    font-size: clamp(2.5rem, 5vw, 4.5rem);
    letter-spacing: -0.03em;
    color: var(--dark-text);
    text-transform: uppercase;
    line-height: 1.1;
    margin-bottom: 24px;
}

.hero-subtitle {
    font-family: var(--font-body);
    font-size: clamp(1rem, 2vw, 1.5rem);
    color: var(--highlight);
    line-height: 1.6;
    margin-bottom: 40px;
}

/* --- Reveal Animations --- */
.reveal-container {
    overflow: hidden;
}

.reveal-container > * {
    transform: translateY(100%);
    transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transition-delay: var(--delay, 0ms);
}

.reveal-container.revealed > * {
    transform: translateY(0);
}

.reveal-item {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

/* --- Stamp Date --- */
.stamp-date {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 120px;
    height: 120px;
    border: 2px dashed var(--highlight);
    border-radius: 50%;
}

.stamp-date--inline {
    width: 72px;
    height: 72px;
    border-width: 1px;
    flex-shrink: 0;
}

.stamp-inner {
    font-family: var(--font-caption);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--highlight);
}

.chapter--light .stamp-inner,
.chapter--light .stamp-date {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

/* --- Chapter Header --- */
.chapter-header {
    max-width: 640px;
    margin: 0 auto 60px;
    width: 100%;
}

.chapter-label {
    font-family: var(--font-caption);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-primary);
    display: block;
    margin-bottom: 16px;
}

.grid-ornament {
    width: 100%;
    height: 1px;
    background-color: var(--grid-line);
    position: relative;
}

.grid-ornament::before,
.grid-ornament::after {
    content: '';
    position: absolute;
    width: 4px;
    height: 4px;
    background-color: var(--grid-line);
    top: -1.5px;
}

.grid-ornament::before {
    left: 0;
}

.grid-ornament::after {
    right: 0;
}

/* --- Text Column --- */
.text-column {
    max-width: 640px;
    margin: 0 auto;
    width: 100%;
}

/* --- Section Headlines --- */
.section-headline {
    font-family: var(--font-body);
    font-weight: 700;
    font-size: clamp(1.75rem, 3vw, 2.5rem);
    color: var(--text-primary);
    line-height: 1.3;
    margin-bottom: 40px;
}

.section-headline--light {
    color: var(--dark-text);
}

/* --- Body Text --- */
.body-text {
    font-family: var(--font-body);
    font-size: 1.125rem;
    line-height: 1.75;
    color: var(--text-primary);
    margin-bottom: 24px;
}

.body-text--light {
    color: var(--dark-text);
}

/* --- Bracket Quote --- */
.bracket-quote {
    position: relative;
    padding: 32px 24px;
    margin: 48px 0;
    border: 1px solid var(--grid-line);
}

/* Corner brackets */
.bracket-quote::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    width: 20px;
    height: 20px;
    border-top: 2px solid var(--accent-primary);
    border-left: 2px solid var(--accent-primary);
}

.bracket-quote::after {
    content: '';
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 20px;
    height: 20px;
    border-bottom: 2px solid var(--accent-primary);
    border-right: 2px solid var(--accent-primary);
}

.bracket-quote--light {
    border-color: rgba(196, 168, 130, 0.3);
}

.bracket-quote--light::before {
    border-top-color: var(--highlight);
    border-left-color: var(--highlight);
}

.bracket-quote--light::after {
    border-bottom-color: var(--highlight);
    border-right-color: var(--highlight);
}

.quote-text {
    font-family: var(--font-body);
    font-size: 1.25rem;
    font-style: italic;
    color: var(--text-primary);
    line-height: 1.6;
    margin-bottom: 12px;
}

.quote-text--light {
    color: var(--dark-text);
}

.quote-source {
    font-family: var(--font-caption);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    display: block;
}

.quote-source--light {
    color: var(--highlight);
}

/* --- Timeline Markers --- */
.timeline-marker {
    display: flex;
    align-items: center;
    gap: 24px;
    margin: 32px 0;
}

.timeline-text {
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--dark-text);
    line-height: 1.5;
}

.chapter--dark .stamp-date {
    border-color: var(--highlight);
}

.chapter--dark .stamp-inner {
    color: var(--highlight);
}

/* --- Collage Breaks --- */
.collage-break {
    position: relative;
    min-height: 60vh;
    overflow: hidden;
    background-color: var(--bg-primary);
}

.collage-break--dark {
    background-color: var(--dark-bg);
}

.collage-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: repeat(6, 1fr);
    width: 100%;
    height: 60vh;
    gap: 0;
}

/* --- Collage Pieces --- */
.collage-piece {
    position: relative;
    overflow: hidden;
}

.collage-piece--1 {
    grid-column: 1 / 6;
    grid-row: 1 / 4;
    background-color: var(--dark-bg);
}

.collage-piece--2 {
    grid-column: 5 / 10;
    grid-row: 2 / 5;
    background-color: var(--bg-secondary);
    z-index: 1;
}

.collage-piece--3 {
    grid-column: 8 / 13;
    grid-row: 3 / 7;
    background-color: var(--accent-secondary);
}

.collage-piece--4 {
    grid-column: 2 / 7;
    grid-row: 4 / 7;
    background-color: var(--text-primary);
    z-index: 2;
}

.collage-piece--5 {
    grid-column: 3 / 8;
    grid-row: 1 / 4;
    background-color: var(--accent-primary);
}

.collage-piece--6 {
    grid-column: 6 / 13;
    grid-row: 2 / 6;
    background-color: var(--text-primary);
    z-index: 1;
}

.collage-piece--7 {
    grid-column: 1 / 5;
    grid-row: 3 / 7;
    background-color: var(--bg-secondary);
}

.collage-piece--8 {
    grid-column: 2 / 8;
    grid-row: 1 / 5;
    background-color: var(--dark-bg);
}

.collage-piece--9 {
    grid-column: 7 / 12;
    grid-row: 2 / 6;
    background-color: var(--accent-secondary);
    z-index: 1;
}

.collage-piece--10 {
    grid-column: 1 / 6;
    grid-row: 4 / 7;
    background-color: var(--bg-secondary);
}

.collage-piece--11 {
    grid-column: 1 / 8;
    grid-row: 1 / 5;
    background-color: var(--dark-bg);
}

.collage-piece--12 {
    grid-column: 6 / 13;
    grid-row: 3 / 7;
    background-color: var(--accent-secondary);
    z-index: 1;
}

/* --- Halftone Overlay --- */
.halftone-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(circle, var(--highlight) 1px, transparent 1px);
    background-size: 4px 4px;
    opacity: 0.3;
}

/* --- Redaction Bars --- */
.redaction-bar {
    position: absolute;
    left: 10%;
    top: 30%;
    width: 60%;
    height: 16px;
    background-color: var(--text-primary);
}

.redaction-bar--2 {
    top: 50%;
    left: 15%;
    width: 45%;
}

.redaction-bar--3 {
    top: 70%;
    left: 8%;
    width: 70%;
}

/* --- Torn Paper Effects --- */
.torn-paper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    clip-path: polygon(0% 5%, 8% 0%, 15% 7%, 25% 2%, 35% 8%, 45% 1%, 55% 6%, 65% 0%, 75% 5%, 85% 1%, 95% 7%, 100% 3%, 100% 95%, 92% 100%, 85% 93%, 75% 98%, 65% 92%, 55% 99%, 45% 94%, 35% 100%, 25% 93%, 15% 98%, 8% 92%, 0% 97%);
    background-color: var(--bg-primary);
    opacity: 0.15;
}

.torn-paper--2 {
    clip-path: polygon(0% 3%, 12% 0%, 20% 5%, 30% 1%, 40% 6%, 50% 0%, 60% 4%, 70% 1%, 80% 6%, 90% 2%, 100% 5%, 100% 97%, 88% 100%, 78% 95%, 68% 99%, 58% 94%, 48% 100%, 38% 96%, 28% 100%, 18% 94%, 8% 99%, 0% 95%);
    background-color: var(--highlight);
    opacity: 0.1;
}

.torn-paper--3 {
    clip-path: polygon(2% 0%, 10% 4%, 22% 0%, 33% 6%, 44% 1%, 56% 5%, 67% 0%, 78% 4%, 88% 1%, 100% 6%, 100% 94%, 90% 100%, 80% 95%, 68% 100%, 56% 96%, 44% 100%, 33% 94%, 22% 100%, 10% 96%, 0% 100%);
    background-color: var(--dark-text);
    opacity: 0.12;
}

/* --- Slide-in Animations --- */
.slide-in {
    opacity: 0;
    transition: opacity 1s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 1s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.slide-in--left {
    transform: translateX(-80px);
}

.slide-in--right {
    transform: translateX(80px);
}

.slide-in--bottom {
    transform: translateY(80px);
}

.slide-in.revealed {
    opacity: 1;
    transform: translate(0, 0);
}

/* --- Closing Section --- */
.closing-content {
    text-align: center;
}

.closing-text {
    font-family: var(--font-body);
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    font-weight: 700;
    color: var(--dark-text);
    line-height: 1.4;
    margin-bottom: 40px;
}

/* --- Link Underline Animation --- */
a {
    color: var(--accent-primary);
    text-decoration: none;
    position: relative;
}

a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background-color: var(--accent-primary);
    transition: width 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

a:hover::after {
    width: 100%;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .chapter {
        padding: 80px 20px;
    }

    .top-nav {
        padding: 0 20px;
    }

    .text-column {
        max-width: 100%;
    }

    .stamp-date {
        width: 90px;
        height: 90px;
    }

    .stamp-date--inline {
        width: 56px;
        height: 56px;
    }

    .collage-grid {
        height: 40vh;
    }

    .timeline-marker {
        gap: 16px;
    }

    .bracket-quote {
        padding: 24px 16px;
        margin: 32px 0;
    }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    .reveal-container > *,
    .reveal-item,
    .slide-in,
    .grid-line,
    .margin-line {
        transition: none;
        transform: none;
        opacity: 1;
    }

    .reveal-container > * {
        transform: none;
    }
}
