/* ==========================================================
   diplomatic.quest -- Cartographic Situation Room
   ========================================================== */

/* --- CSS Custom Properties (Palette from DESIGN.md) --- */
:root {
    --archive-parchment: #f0ead6;
    --ink-black: #1c1a17;
    --diplomatic-sepia: #6b4c3a;
    --contested-red: #8f3b2c;
    --treaty-blue: #2d3e50;
    --buffer-grey: #3a3d42;
    --dispatch-olive: #4a5a3a;
    --brass-highlight: #a08c5a;
}

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

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

body {
    background-color: var(--archive-parchment);
    color: var(--ink-black);
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.1vw, 1.15rem);
    line-height: 1.72;
    overflow-x: hidden;
    border-radius: 0;
}

/* Zero border-radius everywhere */
* {
    border-radius: 0 !important;
}

/* --- Coordinate Grid Underlay --- */
#coordinate-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 600ms ease-out;
}

#coordinate-grid.visible {
    opacity: 1;
}

#coordinate-grid line {
    stroke: var(--buffer-grey);
    stroke-width: 1px;
    opacity: 0.12;
}

/* --- Document Container --- */
#document-container {
    position: relative;
    z-index: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 clamp(24px, 4vw, 64px);
}

/* --- Thread Lines Overlay --- */
#thread-lines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 2;
    pointer-events: none;
}

/* ==========================================================
   TYPOGRAPHY
   ========================================================== */

h1, h2 {
    font-family: 'DM Serif Display', serif;
    font-weight: 400;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--ink-black);
}

h1 {
    font-size: clamp(2.2rem, 5vw, 4.8rem);
    line-height: 1.05;
    margin-bottom: 1.5rem;
}

h2 {
    font-size: clamp(1.4rem, 2.8vw, 2.2rem);
    margin-bottom: 1rem;
}

/* Annotation / metadata monospace */
.annotation-date,
.annotation-class,
.annotation-ref,
.section-ref,
.classification-metadata span,
.classification-stamp {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    letter-spacing: 0.08em;
}

/* ==========================================================
   OPENING ZONE
   ========================================================== */

#opening-zone {
    display: grid;
    grid-template-columns: 58% 42%;
    min-height: 100vh;
    padding-top: clamp(48px, 8vh, 120px);
    position: relative;
}

#opening-content {
    grid-column: 1;
    padding-left: calc(100% * 3 / 12);
    padding-right: clamp(24px, 3vw, 48px);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.premise-text {
    max-width: 38em;
    margin-bottom: 1.5rem;
    color: var(--ink-black);
}

.premise-sub {
    max-width: 38em;
    color: var(--ink-black);
    opacity: 0.7;
    font-size: clamp(0.85rem, 0.95vw, 1rem);
}

.horizontal-rule {
    width: 100%;
    height: 1px;
    background-color: var(--diplomatic-sepia);
    margin: 1.5rem 0;
}

/* Situation Map Container */
#situation-map-container {
    grid-column: 2;
    position: relative;
    overflow: hidden;
    margin-right: -15%;
}

#situation-map {
    width: 100%;
    height: 100%;
    max-height: 80vh;
}

/* --- Primary Rule (full viewport width at 62% height) --- */
#primary-rule {
    position: absolute;
    top: 62vh;
    left: -100vw;
    width: 300vw;
    height: 1px;
    background-color: var(--diplomatic-sepia);
    z-index: 3;
    pointer-events: none;
}

/* ==========================================================
   CLASSIFICATION STAMPS
   ========================================================== */

.classification-stamp {
    display: inline-block;
    border: 2px solid var(--diplomatic-sepia);
    padding: 4px 12px;
    font-size: clamp(0.7rem, 0.8vw, 0.85rem);
    text-transform: uppercase;
    color: var(--diplomatic-sepia);
    opacity: 0;
    margin-bottom: 1rem;
    transition: border-color 200ms ease, opacity 300ms ease-out;
    cursor: default;
}

.classification-stamp.visible {
    opacity: 0.5;
}

.classification-stamp:hover {
    opacity: 1;
    border-color: var(--brass-highlight);
}

/* ==========================================================
   DISPATCH SECTIONS
   ========================================================== */

/* --- Template A (Field Report) --- */
.dispatch-a {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 0 16px;
    margin-top: 64px;
    position: relative;
}

.dispatch-a .dispatch-body {
    grid-column: 2 / 7;
    max-width: 38em;
    opacity: 0;
    transform: translateX(-12px);
    transition: opacity 400ms ease-out, transform 400ms ease-out;
}

.dispatch-a .dispatch-body.visible {
    opacity: 1;
    transform: translateX(0);
}

.dispatch-a .annotation-column {
    grid-column: 8 / 9;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 2.5rem;
}

.annotation-date {
    font-size: clamp(0.7rem, 0.8vw, 0.85rem);
    color: var(--diplomatic-sepia);
    opacity: 0.6;
}

.annotation-class {
    font-size: clamp(0.65rem, 0.75vw, 0.8rem);
    color: var(--contested-red);
    opacity: 0.7;
}

.annotation-ref {
    font-size: clamp(0.65rem, 0.75vw, 0.8rem);
    color: var(--diplomatic-sepia);
    opacity: 0.6;
}

/* --- Template B (Situation Assessment) --- */
.dispatch-b {
    margin-top: 48px;
    position: relative;
}

.dispatch-b-border {
    border: 1px solid var(--diplomatic-sepia);
    display: grid;
    grid-template-columns: 65% 35%;
    gap: 0;
    padding: clamp(24px, 3vw, 48px);
    margin: 0 calc(100% * 1 / 12);
    max-width: calc(100% * 11 / 12);
}

.dispatch-b-text {
    max-width: 38em;
    opacity: 0;
    transform: translateX(-12px);
    transition: opacity 400ms ease-out, transform 400ms ease-out;
}

.dispatch-b-text.visible {
    opacity: 1;
    transform: translateX(0);
}

.dispatch-b-diagram {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-left: clamp(16px, 2vw, 32px);
}

.mini-network,
.resource-chart {
    width: 100%;
    max-width: 240px;
    height: auto;
}

/* ==========================================================
   TRANSITION STRIPS
   ========================================================== */

.transition-strip {
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin-top: 32px;
    width: 100%;
}

.strip-line {
    position: absolute;
    top: 50%;
    left: -4vw;
    width: 108vw;
    height: 2px;
    transform: translateY(-50%);
}

.strip-line line {
    stroke: var(--buffer-grey);
    stroke-width: 2;
    stroke-dasharray: 2 4;
    opacity: 0.3;
    stroke-dashoffset: 1200;
    transition: stroke-dashoffset 800ms ease-out;
}

.strip-line.drawn line {
    stroke-dashoffset: 0;
}

.section-ref {
    position: relative;
    z-index: 1;
    font-size: clamp(0.65rem, 0.75vw, 0.8rem);
    color: var(--buffer-grey);
    opacity: 0.5;
    background-color: var(--archive-parchment);
    padding: 0 12px;
}

/* ==========================================================
   FOLD MARKS
   ========================================================== */

.fold-mark {
    position: absolute;
    left: 0;
    right: 0;
    pointer-events: none;
}

.fold-mark::before,
.fold-mark::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-style: solid;
}

.fold-mark::before {
    left: -clamp(24px, 4vw, 64px);
    border-width: 4px 4px 0 0;
    border-color: var(--diplomatic-sepia) transparent transparent transparent;
}

.fold-mark::after {
    right: -clamp(24px, 4vw, 64px);
    border-width: 0 0 4px 4px;
    border-color: transparent transparent var(--diplomatic-sepia) transparent;
}

.fold-mark-25 { top: 25%; }
.fold-mark-50 { top: 50%; }
.fold-mark-75 { top: 75%; }

/* ==========================================================
   REDACTION BARS
   ========================================================== */

.redaction-bar {
    display: inline;
    background-color: var(--ink-black);
    opacity: 0.85;
    color: transparent;
    padding: 2px 0;
    user-select: none;
}

/* ==========================================================
   TERMINAL ZONE
   ========================================================== */

#terminal-zone {
    margin-top: 64px;
    padding-bottom: 120px;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 0 16px;
}

.terminal-statement {
    grid-column: 2 / 6;
    max-width: 38em;
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 600;
    margin-bottom: 3rem;
}

.classification-metadata {
    grid-column: 2 / 6;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.classification-metadata span {
    font-size: 10px;
    color: var(--ink-black);
    opacity: 0.4;
    letter-spacing: 0.08em;
}

/* ==========================================================
   PARAGRAPH SPACING
   ========================================================== */

.dispatch-body p,
.dispatch-b-text p {
    margin-bottom: 1rem;
    max-width: 38em;
}

.dispatch-heading {
    color: var(--treaty-blue);
}

/* ==========================================================
   LINKS
   ========================================================== */

a {
    color: var(--ink-black);
    text-decoration: none;
    position: relative;
    display: inline;
}

a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 1px;
    background-color: var(--contested-red);
    transition: width 200ms ease-out;
}

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

a:visited::after,
a:active::after {
    background-color: var(--dispatch-olive);
}

/* ==========================================================
   SVG NODE STYLES
   ========================================================== */

.map-node {
    fill: var(--archive-parchment);
    stroke: var(--diplomatic-sepia);
    stroke-width: 1.5;
    cursor: pointer;
    transition: fill 200ms ease;
}

.map-node:hover {
    fill: var(--brass-highlight);
}

.map-node.active {
    fill: var(--brass-highlight);
}

.map-connection {
    fill: none;
    stroke-width: 1;
    stroke-linecap: round;
}

.map-connection.treaty {
    stroke: var(--treaty-blue);
}

.map-connection.adversarial {
    stroke: var(--contested-red);
    stroke-dasharray: 6 4;
}

.map-connection.neutral {
    stroke: var(--dispatch-olive);
    stroke-dasharray: 2 3;
}

.map-connection.dimmed {
    opacity: 0.2;
    transition: opacity 200ms ease;
}

.map-connection.highlighted {
    opacity: 1;
    stroke-width: 1.5;
    transition: opacity 200ms ease;
}

/* Node tooltip */
.node-tooltip {
    position: absolute;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: var(--ink-black);
    background: var(--archive-parchment);
    border: 1px solid var(--diplomatic-sepia);
    padding: 4px 8px;
    pointer-events: none;
    z-index: 10;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 150ms ease;
}

.node-tooltip.visible {
    opacity: 1;
}

/* ==========================================================
   RESPONSIVE
   ========================================================== */

@media (max-width: 900px) {
    #opening-zone {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    #opening-content {
        padding-left: 0;
        padding-right: 0;
    }

    #situation-map-container {
        margin-right: 0;
        max-height: 50vh;
        margin-top: 2rem;
    }

    .dispatch-a {
        grid-template-columns: 1fr;
    }

    .dispatch-a .dispatch-body {
        grid-column: 1;
    }

    .dispatch-a .annotation-column {
        grid-column: 1;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px 16px;
        padding-top: 1rem;
        border-top: 1px solid var(--diplomatic-sepia);
        margin-top: 1rem;
        opacity: 0.7;
    }

    .dispatch-b-border {
        grid-template-columns: 1fr;
        margin: 0;
        max-width: 100%;
    }

    .dispatch-b-diagram {
        padding-left: 0;
        padding-top: 1.5rem;
    }

    #terminal-zone {
        grid-template-columns: 1fr;
    }

    .terminal-statement,
    .classification-metadata {
        grid-column: 1;
    }

    .fold-mark::before {
        left: -24px;
    }
    .fold-mark::after {
        right: -24px;
    }

    #primary-rule {
        display: none;
    }
}
