/* ============================================================
   diplomatic.day — Cartographic Instrument
   ============================================================ */

/* --- CSS Custom Properties (Palette) --- */
:root {
    --linen-draft: #F4EDE4;
    --ink-umber: #3B2F2F;
    --graphite: #5C5C5C;
    --treaty-vermillion: #C23B22;
    --sovereignty-ochre: #D4A843;
    --disputed-slate: #6B7B8D;
    --cartographer-black: #1A1612;
    --survey-sepia: #8B7355;

    /* Layout */
    --treaty-line-pos: 38%;
    --content-margin: 6%;
    --contour-offset: 0px;
}

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

html {
    scroll-behavior: auto;
    overflow-x: hidden;
}

body {
    background-color: var(--linen-draft);
    color: var(--ink-umber);
    font-family: 'Source Serif 4', 'Georgia', serif;
    font-size: 17px;
    line-height: 1.75;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Treaty Line (Persistent Spine) --- */
#treaty-line {
    position: fixed;
    top: 0;
    left: var(--treaty-line-pos);
    width: 2px;
    height: 100vh;
    background-image: repeating-linear-gradient(
        to bottom,
        var(--treaty-vermillion) 0px,
        var(--treaty-vermillion) 8px,
        transparent 8px,
        transparent 12px
    );
    background-size: 2px 12px;
    z-index: 100;
    pointer-events: none;
    transition: background-image 0.6s ease;
}

#treaty-line.color-ochre {
    background-image: repeating-linear-gradient(
        to bottom,
        var(--sovereignty-ochre) 0px,
        var(--sovereignty-ochre) 8px,
        transparent 8px,
        transparent 12px
    );
}

#treaty-line.color-slate {
    background-image: repeating-linear-gradient(
        to bottom,
        var(--disputed-slate) 0px,
        var(--disputed-slate) 8px,
        transparent 8px,
        transparent 12px
    );
}

/* --- Scale Bar Navigation --- */
#scale-bar {
    position: fixed;
    left: 1.5%;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 60vh;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scale-track {
    position: relative;
    width: 2px;
    height: 100%;
    background-color: var(--survey-sepia);
    opacity: 0.6;
}

.scale-tick {
    position: absolute;
    left: -6px;
    width: 14px;
    height: 1px;
    background-color: var(--survey-sepia);
}

.scale-tick[data-plate="0"] { top: 0%; }
.scale-tick[data-plate="1"] { top: 16.66%; }
.scale-tick[data-plate="2"] { top: 33.33%; }
.scale-tick[data-plate="3"] { top: 50%; }
.scale-tick[data-plate="4"] { top: 66.66%; }
.scale-tick[data-plate="5"] { top: 83.33%; }
.scale-tick[data-plate="6"] { top: 100%; }

.scale-marker {
    position: absolute;
    left: -8px;
    top: 0%;
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 8px solid var(--treaty-vermillion);
    transition: top 0.3s ease-out;
    z-index: 2;
}

/* --- Map Plate (Section) --- */
.map-plate {
    position: relative;
    min-height: 100vh;
    width: 100%;
    padding: 8vh var(--content-margin);
    overflow: hidden;
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.map-plate.plate-exiting {
    opacity: 0.15;
    transform: translateY(-8px);
}

/* --- Contour Fields (Background Terrain Lines) --- */
.contour-field {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.contour-field svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* --- Cartouche (Section Title Block) --- */
.cartouche {
    position: relative;
    z-index: 10;
    margin-bottom: 4vh;
    max-width: 480px;
}

.cartouche-frame {
    position: relative;
    padding: 24px 32px 20px;
    border: 1.5px solid var(--cartographer-black);
}

/* Cartouche corner ornaments */
.corner-tl, .corner-tr, .corner-bl, .corner-br {
    position: absolute;
    width: 12px;
    height: 12px;
}

.corner-tl {
    top: -3px;
    left: -3px;
    border-top: 2.5px solid var(--cartographer-black);
    border-left: 2.5px solid var(--cartographer-black);
}

.corner-tr {
    top: -3px;
    right: -3px;
    border-top: 2.5px solid var(--cartographer-black);
    border-right: 2.5px solid var(--cartographer-black);
}

.corner-bl {
    bottom: -3px;
    left: -3px;
    border-bottom: 2.5px solid var(--cartographer-black);
    border-left: 2.5px solid var(--cartographer-black);
}

.corner-br {
    bottom: -3px;
    right: -3px;
    border-bottom: 2.5px solid var(--cartographer-black);
    border-right: 2.5px solid var(--cartographer-black);
}

.cartouche-title {
    font-family: 'Bodoni Moda', 'Didot', serif;
    font-weight: 700;
    font-size: clamp(2rem, 4.5vw, 4.5rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--cartographer-black);
    line-height: 1.1;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--treaty-vermillion);
    margin-bottom: 8px;
}

.cartouche-date {
    font-family: 'Stint Ultra Condensed', serif;
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--graphite);
    margin-bottom: 4px;
}

.cartouche-scale {
    display: flex;
    align-items: center;
    gap: 8px;
}

.scale-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.04em;
    color: var(--graphite);
}

/* --- Plate Content & Column Layout --- */
.plate-content {
    position: relative;
    z-index: 5;
    width: 88%;
    margin: 0 auto;
    /* Weighted grid: offset left-of-center */
    padding-left: 2%;
}

.plate-columns {
    display: flex;
    gap: 0;
    align-items: flex-start;
}

.primary-column {
    flex: 0 0 58%;
    max-width: 58%;
}

.meridian-gutter {
    flex: 0 0 3%;
    max-width: 3%;
    min-height: 200px;
    border-left: 1px dashed var(--survey-sepia);
    opacity: 0.5;
    margin: 0 auto;
}

.annotation-column {
    flex: 0 0 25%;
    max-width: 25%;
    padding-left: 2%;
    padding-top: 1rem;
}

/* --- Body Text --- */
.body-text {
    font-family: 'Source Serif 4', 'Georgia', serif;
    font-size: 17px;
    font-weight: 400;
    line-height: 1.75;
    color: var(--ink-umber);
    text-align: justify;
    hyphens: auto;
    -webkit-hyphens: auto;
    margin-bottom: 1.25em;
}

.body-text strong, .body-text b {
    font-weight: 600;
}

/* --- Annotation Text --- */
.annotation-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.5;
    letter-spacing: 0.04em;
    color: var(--graphite);
    margin-bottom: 0.75em;
}

/* --- Legend Entries --- */
.legend-entry {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-line {
    display: inline-block;
    width: 24px;
    height: 2px;
    flex-shrink: 0;
}

.dash-vermillion {
    background-image: repeating-linear-gradient(
        to right,
        var(--treaty-vermillion) 0px,
        var(--treaty-vermillion) 6px,
        transparent 6px,
        transparent 10px
    );
}

.dash-ochre {
    background-image: repeating-linear-gradient(
        to right,
        var(--sovereignty-ochre) 0px,
        var(--sovereignty-ochre) 6px,
        transparent 6px,
        transparent 10px
    );
}

.dash-slate {
    background-image: repeating-linear-gradient(
        to right,
        var(--disputed-slate) 0px,
        var(--disputed-slate) 6px,
        transparent 6px,
        transparent 10px
    );
}

/* --- Triangulation Points --- */
.triangulation-point {
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 8px solid transparent;
    border-bottom-color: transparent;
    position: relative;
    margin: 12px 0;
    display: inline-block;
}

.triangulation-point::before {
    content: '';
    position: absolute;
    top: 3px;
    left: -4px;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 8px solid var(--treaty-vermillion);
}

.triangulation-point::after {
    content: '';
    position: absolute;
    top: 1px;
    left: -3px;
    width: 0;
    height: 0;
    border-left: 3px solid transparent;
    border-right: 3px solid transparent;
    border-bottom: 6px solid var(--linen-draft);
}

/* --- Pull Quote --- */
.pull-quote {
    position: relative;
    padding: 24px 28px;
    margin: 2em 0;
    background: none;
}

.pull-quote::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    filter: url(#stipple-filter);
    opacity: 0.12;
    z-index: -1;
}

.pull-quote p {
    font-family: 'Bodoni Moda', 'Didot', serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1.1rem, 2vw, 1.5rem);
    line-height: 1.6;
    color: var(--cartographer-black);
    letter-spacing: 0.02em;
}

/* --- Hachure Divider --- */
.hachure-divider {
    width: 100%;
    height: 40px;
    margin: 2em 0;
    background: repeating-linear-gradient(
        45deg,
        var(--survey-sepia) 0px,
        var(--survey-sepia) 1px,
        transparent 1px,
        transparent 5px
    );
    opacity: 0.35;
}

/* --- Stipple Regions --- */
.stipple-region {
    position: absolute;
    pointer-events: none;
    z-index: 1;
}

.stipple-accent {
    top: 30%;
    right: 8%;
    width: 180px;
    height: 220px;
    filter: url(#stipple-filter);
    opacity: 0.08;
    background-color: var(--survey-sepia);
}

/* --- Fade-soak Animation --- */
.fade-soak {
    opacity: 0;
    transition: opacity 600ms ease-in;
}

.fade-soak.visible {
    opacity: 1;
}

/* --- Stagger Line Animation --- */
.stagger-line {
    opacity: 0;
    transition: opacity 400ms ease-in;
}

.stagger-line.visible {
    opacity: 1;
}

/* --- Colophon Note --- */
.colophon-note {
    font-style: italic;
    color: var(--graphite);
}

/* --- SVG Defs (Hidden) --- */
#svg-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .plate-columns {
        flex-direction: column;
    }

    .primary-column,
    .annotation-column {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .meridian-gutter {
        min-height: 1px;
        height: 1px;
        width: 60%;
        border-left: none;
        border-top: 1px dashed var(--survey-sepia);
        margin: 2em 0;
    }

    .annotation-column {
        padding-left: 0;
        padding-top: 0;
    }

    .plate-content {
        width: 92%;
        padding-left: 0;
    }

    #scale-bar {
        display: none;
    }

    .cartouche-title {
        font-size: clamp(1.5rem, 5vw, 2.5rem);
    }
}

@media (max-width: 600px) {
    .map-plate {
        padding: 6vh 4%;
    }

    .body-text {
        font-size: 15px;
        text-align: left;
        hyphens: none;
    }

    .cartouche-frame {
        padding: 16px 20px 14px;
    }

    #treaty-line {
        opacity: 0.3;
    }
}
