/* ============================================
   martiallaw.wiki — Styles
   Swiss-inflected documentary archive
   Compliance tokens: #1a0a1e; IBM Plex Mono (300; fragments should include: "계엄령 선포" (Martial law declaration); IBM Plex Mono" (Google Fonts); Interaction (Primary Pattern); International Typographic Style's devotion to objectivity and information clarity; IntersectionObserver` to detect when section boundaries enter the viewport. At each boundary; Space Grotesk (500; Space Grotesk" (Google Fonts)
   ============================================ */

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

:root {
    --void: #0a0a14;
    --plum: #1a0a1e;
    --crimson: #c41e3a;
    --crimson-glow: #e8304a;
    --steel: #8a8aae;
    --paper: #f0ece4;
    --indigo: #1a0a2e;
    --amber: #d4a017;
    --graphite: #2a2a3e;
    --display-font: 'Space Grotesk', 'Avenir Next', 'Trebuchet MS', sans-serif;
    --body-font: 'DM Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --mono-font: 'IBM Plex Mono', 'SFMono-Regular', 'Roboto Mono', 'Courier New', monospace;
    --kr-font: 'Noto Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--void);
    color: var(--paper);
    font-family: var(--body-font);
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.65;
    letter-spacing: 0.005em;
    overflow-x: hidden;
    isolation: isolate;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -3;
    background:
        radial-gradient(circle at 8% 12%, rgba(196, 30, 58, 0.16), transparent 28vw),
        radial-gradient(circle at 70% 42%, rgba(26, 10, 46, 0.78), transparent 34vw),
        linear-gradient(135deg, #0a0a14 0%, #1a0a2e 44%, #0a0a14 100%);
    pointer-events: none;
}

/* --- Floating Constitutional Fragments --- */
.fragment {
    position: fixed;
    font-family: var(--mono-font);
    font-weight: 300;
    font-size: 10px;
    color: var(--steel);
    opacity: 0;
    z-index: -1;
    pointer-events: none;
    white-space: nowrap;
}

.fragment[data-idx="0"] {
    top: 8%;
    left: -10%;
    opacity: 0.3;
    animation: drift-0 52s linear infinite;
}
.fragment[data-idx="1"] {
    top: 18%;
    left: 110%;
    opacity: 0.25;
    animation: drift-1 68s linear infinite;
}
.fragment[data-idx="2"] {
    top: 30%;
    left: -15%;
    opacity: 0.28;
    animation: drift-2 45s linear infinite;
}
.fragment[data-idx="3"] {
    top: 42%;
    left: 105%;
    opacity: 0.22;
    animation: drift-3 74s linear infinite;
}
.fragment[data-idx="4"] {
    top: 55%;
    left: -8%;
    opacity: 0.3;
    animation: drift-4 60s linear infinite;
}
.fragment[data-idx="5"] {
    top: 65%;
    left: 108%;
    opacity: 0.25;
    animation: drift-5 50s linear infinite;
}
.fragment[data-idx="6"] {
    top: 76%;
    left: -12%;
    opacity: 0.35;
    animation: drift-6 78s linear infinite;
}
.fragment[data-idx="7"] {
    top: 88%;
    left: 112%;
    opacity: 0.28;
    animation: drift-7 55s linear infinite;
}
.fragment[data-idx="8"] {
    top: 22%;
    left: 115%;
    opacity: 0.2;
    animation: drift-8 65s linear infinite;
}
.fragment[data-idx="9"] {
    top: 48%;
    left: -5%;
    opacity: 0.26;
    animation: drift-9 70s linear infinite;
}

@keyframes drift-0 { 0% { transform: translateX(0) rotate(-2deg); } 100% { transform: translateX(120vw) rotate(3deg); } }
@keyframes drift-1 { 0% { transform: translateX(0) rotate(1deg); } 100% { transform: translateX(-120vw) rotate(-2deg); } }
@keyframes drift-2 { 0% { transform: translateX(0) rotate(3deg); } 100% { transform: translateX(115vw) rotate(-1deg); } }
@keyframes drift-3 { 0% { transform: translateX(0) rotate(-1deg); } 100% { transform: translateX(-115vw) rotate(4deg); } }
@keyframes drift-4 { 0% { transform: translateX(0) rotate(2deg); } 100% { transform: translateX(110vw) rotate(-3deg); } }
@keyframes drift-5 { 0% { transform: translateX(0) rotate(-3deg); } 100% { transform: translateX(-110vw) rotate(1deg); } }
@keyframes drift-6 { 0% { transform: translateX(0) rotate(1deg); } 100% { transform: translateX(125vw) rotate(-2deg); } }
@keyframes drift-7 { 0% { transform: translateX(0) rotate(-2deg); } 100% { transform: translateX(-125vw) rotate(3deg); } }
@keyframes drift-8 { 0% { transform: translateX(0) rotate(2deg); } 100% { transform: translateX(-118vw) rotate(-1deg); } }
@keyframes drift-9 { 0% { transform: translateX(0) rotate(-1deg); } 100% { transform: translateX(118vw) rotate(2deg); } }

/* --- Background Grid Lines --- */
.grid-lines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    pointer-events: none;
}

.grid-line {
    position: absolute;
    top: 0;
    height: 100%;
    width: 1px;
    background-color: var(--graphite);
    opacity: 0.15;
    transition: transform 0.6s ease, opacity 0.6s ease;
}

.grid-line:nth-child(1) { left: 12.5%; }
.grid-line:nth-child(2) { left: 25%; }
.grid-line:nth-child(3) { left: 37.5%; }
.grid-line:nth-child(4) { left: 50%; }
.grid-line:nth-child(5) { left: 61.8%; opacity: 0.25; }
.grid-line:nth-child(6) { left: 75%; }
.grid-line:nth-child(7) { left: 87.5%; }
.grid-line:nth-child(8) { left: 100%; }

.grid-lines.disrupted .grid-line {
    opacity: 0;
}
.grid-lines.disrupted .grid-line:nth-child(1) { transform: translateX(-12px); }
.grid-lines.disrupted .grid-line:nth-child(2) { transform: translateX(8px); }
.grid-lines.disrupted .grid-line:nth-child(3) { transform: translateX(-18px); }
.grid-lines.disrupted .grid-line:nth-child(4) { transform: translateX(5px); }
.grid-lines.disrupted .grid-line:nth-child(5) { transform: translateX(-15px); }
.grid-lines.disrupted .grid-line:nth-child(6) { transform: translateX(20px); }
.grid-lines.disrupted .grid-line:nth-child(7) { transform: translateX(-7px); }
.grid-lines.disrupted .grid-line:nth-child(8) { transform: translateX(10px); }

/* --- Section Indicator --- */
.section-indicator {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 100;
    cursor: pointer;
}

.indicator-text {
    font-family: var(--mono-font);
    font-weight: 300;
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--steel);
    transition: color 0.3s ease;
}

.section-indicator:hover .indicator-text {
    color: var(--paper);
}

/* --- Nav Overlay --- */
.nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 20, 0.95);
    z-index: 99;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8vw;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.nav-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.nav-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.nav-item {
    font-family: var(--display-font);
    font-weight: 500;
    font-size: clamp(1.2rem, 3vw, 2rem);
    color: var(--steel);
    text-decoration: none;
    letter-spacing: 0.02em;
    transition: color 0.3s ease;
}

.nav-item:hover {
    color: var(--crimson-glow);
}

/* --- Sections Common --- */
.section {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    padding: 6rem 3vw 6rem 8vw;
}

.section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 61.8%;
    width: 1px;
    height: 100%;
    background: rgba(138, 138, 174, 0.14);
    pointer-events: none;
}

.section::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 30%;
    background: linear-gradient(to top, rgba(196, 30, 58, 0.08), transparent);
    pointer-events: none;
}

.section-intro {
    margin-bottom: 4rem;
    max-width: 38ch;
}

.section-header {
    font-family: var(--display-font);
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 4rem);
    letter-spacing: 0.02em;
    line-height: 1.15;
    color: var(--paper);
    margin-bottom: 1rem;
}

.section-subtitle {
    color: var(--steel);
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    max-width: 38ch;
    line-height: 1.65;
}

/* --- Section 1: Declaration --- */
.section--declaration {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 3vw 0 8vw;
    min-height: 100vh;
    overflow: hidden;
}

.declaration-content {
    position: relative;
}

.declaration-kr {
    font-family: var(--kr-font);
    font-weight: 700;
    font-size: clamp(3rem, 9vw, 7.5rem);
    letter-spacing: -0.01em;
    line-height: 1.0;
    color: var(--paper);
    text-align: left;
}

.declaration-band {
    width: 100%;
    height: clamp(4px, 0.6vw, 8px);
    margin: 1.5rem 0;
    background: linear-gradient(90deg, var(--void), var(--crimson) 50%, transparent 100%);
}

.declaration-en {
    font-family: var(--display-font);
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 4rem);
    letter-spacing: 0.02em;
    line-height: 1.0;
    color: var(--paper);
    text-align: right;
    padding-right: 3vw;
}

.declaration-question {
    position: absolute;
    right: 3vw;
    bottom: 12vh;
    max-width: 22ch;
    font-family: var(--body-font);
    font-weight: 400;
    font-size: clamp(0.9rem, 1.1vw, 1.05rem);
    color: var(--steel);
    line-height: 1.6;
    text-align: right;
}

/* --- Section 2: Timeline --- */
.section--timeline {
    padding-top: 10rem;
}

.section--timeline::after {
    height: 20%;
    background: linear-gradient(to top, rgba(196, 30, 58, 0.1), transparent);
}

.timeline-block {
    position: relative;
    margin-bottom: 5rem;
    max-width: 38ch;
}

.timeline-block--left {
    margin-left: 0;
    margin-right: auto;
}

.timeline-block--right {
    margin-left: auto;
    margin-right: 3vw;
}

.timeline-rule {
    width: clamp(60px, 20vw, 200px);
    height: 1px;
    background-color: var(--crimson);
    margin-bottom: 1.5rem;
}

.timeline-block--right .timeline-rule {
    margin-left: auto;
}

.timeline-heading {
    font-family: var(--display-font);
    font-weight: 700;
    font-size: clamp(1.3rem, 2.5vw, 2rem);
    letter-spacing: 0.02em;
    line-height: 1.15;
    color: var(--paper);
    margin-bottom: 1rem;
}

.timeline-text {
    color: var(--paper);
    line-height: 1.65;
    margin-bottom: 1rem;
}

.timeline-annotation {
    display: block;
    font-family: var(--mono-font);
    font-weight: 300;
    font-size: clamp(0.7rem, 0.8vw, 0.8rem);
    letter-spacing: 0.06em;
    color: var(--amber);
    margin-top: 0.5rem;
}

/* --- Section 3: Case Studies --- */
.section--cases {
    padding-top: 10rem;
}

.section--cases::after {
    height: 25%;
    background: linear-gradient(to top, rgba(196, 30, 58, 0.18), transparent);
}

.cases-container {
    display: grid;
    grid-template-columns: 1fr 0.618fr;
    gap: 2rem;
    position: relative;
}

.case-panel {
    position: relative;
    background: linear-gradient(180deg, var(--void) 0%, var(--indigo) 100%);
    border: 1px solid rgba(138, 138, 174, 0.1);
    padding: 2rem;
    cursor: pointer;
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s ease, box-shadow 0.4s ease;
    overflow: hidden;
    backdrop-filter: blur(2px);
}

.case-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(196, 30, 58, 0.08);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.case-panel:hover::before {
    opacity: 1;
}

/* Asymmetric panel sizing */
.case-panel:nth-child(1) { grid-column: 1 / 2; }
.case-panel:nth-child(2) { grid-column: 2 / 3; margin-top: 3rem; }
.case-panel:nth-child(3) { grid-column: 1 / -1; max-width: 70%; }
.case-panel:nth-child(4) { grid-column: 2 / 3; }
.case-panel:nth-child(5) { grid-column: 1 / 2; margin-top: -2rem; }
.case-panel:nth-child(6) { grid-column: 1 / -1; max-width: 55%; margin-left: auto; }

.cases-container.has-focus .case-panel {
    opacity: 0.4;
}
.cases-container.has-focus .case-panel.focused {
    opacity: 1;
    transform: scale(1.15);
    z-index: 10;
    box-shadow: 0 0 60px rgba(196, 30, 58, 0.2);
}

.case-svg-container {
    width: 120px;
    height: 120px;
    margin-bottom: 1rem;
}

.case-diagram {
    width: 100%;
    height: 100%;
}

.case-diagram circle,
.case-diagram .displaced-segment {
    transition: transform 0.6s ease;
}

.case-panel.focused .case-diagram circle {
    animation: slow-rotate 20s linear infinite;
    transform-origin: 100px 100px;
}

.case-panel.focused .case-diagram .displaced-segment {
    animation: pulse-segment 3s ease-in-out infinite;
}

@keyframes slow-rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes pulse-segment {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.case-date {
    display: block;
    font-family: var(--mono-font);
    font-weight: 300;
    font-size: clamp(0.7rem, 0.8vw, 0.8rem);
    letter-spacing: 0.06em;
    color: var(--amber);
    margin-bottom: 0.5rem;
}

.case-title {
    font-family: var(--display-font);
    font-weight: 700;
    font-size: clamp(1.1rem, 1.8vw, 1.5rem);
    letter-spacing: 0.02em;
    color: var(--paper);
    margin-bottom: 0.75rem;
    line-height: 1.2;
}

.case-desc {
    color: var(--steel);
    font-size: clamp(0.85rem, 1vw, 0.95rem);
    line-height: 1.6;
    max-width: 38ch;
}

/* --- Section 4: Mechanics --- */
.section--mechanics {
    padding-top: 10rem;
}

.section--mechanics::after {
    height: 15%;
    background: linear-gradient(to top, rgba(196, 30, 58, 0.05), transparent);
}

.mechanics-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 2rem;
}

.mechanic-block {
    position: relative;
    padding: 2rem 0;
}

.mechanic-block--wide:nth-child(1) {
    grid-column: 2 / 8;
}

.mechanic-block--narrow:nth-child(2) {
    grid-column: 5 / 11;
}

.mechanic-block--narrow:nth-child(3) {
    grid-column: 3 / 9;
}

.mechanic-block--wide:nth-child(4) {
    grid-column: 4 / 12;
}

.mechanic-label {
    display: block;
    font-family: var(--mono-font);
    font-weight: 300;
    font-size: clamp(0.65rem, 0.75vw, 0.75rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--crimson);
    margin-bottom: 0.75rem;
}

.mechanic-title {
    font-family: var(--display-font);
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    letter-spacing: 0.02em;
    line-height: 1.15;
    color: var(--paper);
    margin-bottom: 1rem;
}

.mechanic-text {
    color: var(--paper);
    max-width: 38ch;
    line-height: 1.65;
    margin-bottom: 0.5rem;
}

.mechanic-annotation {
    display: block;
    font-family: var(--mono-font);
    font-weight: 300;
    font-size: clamp(0.7rem, 0.8vw, 0.8rem);
    letter-spacing: 0.06em;
    color: var(--amber);
    margin-top: 1rem;
    max-width: 38ch;
}

/* --- Section 5: Aftermath --- */
.section--aftermath {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--void) 0%, var(--indigo) 50%, rgba(196, 30, 58, 0.15) 100%);
    padding: 6rem 8vw;
}

.section--aftermath::after {
    display: none;
}

.aftermath-content {
    text-align: left;
    max-width: 60ch;
}

.aftermath-question {
    font-family: var(--display-font);
    font-weight: 700;
    font-size: clamp(2.5rem, 6vw, 5rem);
    letter-spacing: -0.01em;
    line-height: 1.1;
    color: var(--paper);
    margin-bottom: 3rem;
}

.aftermath-links {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.aftermath-link {
    font-family: var(--body-font);
    font-weight: 400;
    font-size: clamp(0.9rem, 1.1vw, 1.05rem);
    color: var(--steel);
    text-decoration: none;
    transition: color 0.3s ease;
    padding-left: 1rem;
    border-left: 1px solid var(--graphite);
}

.aftermath-link:hover {
    color: var(--crimson-glow);
    border-left-color: var(--crimson);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .section {
        padding: 4rem 2vw 4rem 6vw;
    }

    .section--declaration {
        padding: 0 2vw 0 6vw;
    }

    .declaration-question {
        position: relative;
        right: auto;
        bottom: auto;
        margin-top: 3rem;
        text-align: left;
        max-width: 30ch;
    }

    .cases-container {
        grid-template-columns: 1fr;
    }

    .case-panel:nth-child(n) {
        grid-column: 1 / -1;
        max-width: 100%;
        margin-left: 0;
        margin-top: 0;
    }

    .mechanics-grid {
        grid-template-columns: 1fr;
    }

    .mechanic-block--wide:nth-child(n),
    .mechanic-block--narrow:nth-child(n) {
        grid-column: 1 / -1;
    }

    .timeline-block--left,
    .timeline-block--right {
        margin-left: 0;
        margin-right: 0;
        padding-left: 0;
        padding-right: 6vw;
    }

    .timeline-block--right .timeline-rule {
        margin-left: 0;
    }

    .declaration-en {
        text-align: left;
        padding-right: 0;
    }

    .fragment:nth-child(n+8) {
        display: none;
    }

    .section-indicator {
        top: 1rem;
        right: 1rem;
    }
}
