/* ============================================
   diplomatic.wiki — Palimpsest of Contested Sovereignty
   ============================================ */

/* --- CSS Custom Properties (Palette) --- */
:root {
    --vellum-bone: #F2EDE4;
    --parchment-dust: #DDD5C6;
    --charred-umber: #3D3228;
    --treaty-ink: #1C1812;
    --bleached-linen: #EDE7DB;
    --dispute-vermillion: #A63D2F;
    --seal-indigo: #2E3A5C;
    --redaction-soot: #2C2826;
    --boundary-chalk: #B8AD9A;

    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'Source Serif 4', 'Source Serif Pro', Georgia, serif;
    --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

    --gutter-width: 22%;
    --main-start: 26%;
    --main-end: 82%;
    --main-width: 56%;
}

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

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

body {
    background-color: var(--vellum-bone);
    color: var(--treaty-ink);
    font-family: var(--font-body);
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    line-height: 1.72;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- SVG Filters (hidden) --- */
.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* --- Vertical Core Line --- */
.core-line {
    position: fixed;
    left: var(--gutter-width);
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--boundary-chalk);
    z-index: 10;
    pointer-events: none;
}

.core-tick {
    position: absolute;
    left: 0;
    width: 8px;
    height: 1px;
    background: var(--boundary-chalk);
}

.core-tick[data-stratum="1"] { top: 0; }
.core-tick[data-stratum="2"] { top: 20%; }
.core-tick[data-stratum="3"] { top: 40%; }
.core-tick[data-stratum="4"] { top: 60%; }
.core-tick[data-stratum="5"] { top: 80%; }

/* --- Stratum (General) --- */
.stratum {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* --- Stratum Grid --- */
.stratum-grid {
    display: grid;
    grid-template-columns: var(--gutter-width) 1fr 18%;
    min-height: 100vh;
    align-items: start;
    padding: 8vh 0;
}

/* --- Annotation Gutter --- */
.annotation-gutter {
    position: relative;
    padding: 4vh 1.5rem 4vh 2rem;
    background: rgba(0, 0, 0, 0.03);
    align-self: stretch;
}

.annotation-content {
    position: sticky;
    top: 10vh;
}

.gutter-label {
    display: block;
    font-family: var(--font-mono);
    font-size: clamp(0.6rem, 0.9vw, 0.72rem);
    font-weight: 400;
    letter-spacing: 0.08em;
    color: var(--seal-indigo);
    text-transform: uppercase;
    margin-top: 2rem;
    margin-bottom: 0.5rem;
}

.gutter-label:first-child {
    margin-top: 0;
}

.gutter-ref {
    display: block;
    font-family: var(--font-mono);
    font-size: clamp(0.7rem, 1.1vw, 0.85rem);
    font-weight: 300;
    letter-spacing: 0.02em;
    color: var(--treaty-ink);
    line-height: 1.5;
    margin-bottom: 0.4rem;
}

.gutter-ref.disputed {
    color: var(--dispute-vermillion);
}

.amendment-dates {
    list-style: none;
    font-family: var(--font-mono);
    font-size: clamp(0.7rem, 1.1vw, 0.85rem);
    font-weight: 300;
    letter-spacing: 0.02em;
    color: var(--seal-indigo);
    line-height: 1.8;
}

/* --- Main Column --- */
.main-column {
    padding: 4vh 3rem;
    max-width: 100%;
}

/* --- Right Margin --- */
.right-margin {
    position: relative;
    padding: 4vh 1rem;
}

/* --- Domain Inscription --- */
.domain-inscription {
    font-family: var(--font-display);
    font-size: clamp(3rem, 7vw, 8rem);
    font-weight: 900;
    letter-spacing: 0.04em;
    color: var(--treaty-ink);
    line-height: 1.05;
    margin-bottom: 3rem;
    opacity: 0;
    animation: inscriptionFadeIn 800ms ease-out forwards;
}

@keyframes inscriptionFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.entry-context {
    max-width: 38rem;
    color: var(--treaty-ink);
    font-weight: 400;
}

/* --- Stratum Titles --- */
.stratum-title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 4.5vw, 4rem);
    font-weight: 900;
    letter-spacing: 0.04em;
    color: var(--treaty-ink);
    margin-bottom: 2.5rem;
    line-height: 1.1;
}

/* --- Stratum Dividers --- */
.stratum-divider {
    width: 100%;
    height: 2px;
    position: relative;
}

.divider-line {
    width: 100%;
    height: 2px;
    display: block;
}

/* --- STRATUM 1: Surface --- */
.stratum-surface {
    background-color: var(--vellum-bone);
}

/* --- STRATUM 2: Treaty --- */
.stratum-treaty {
    background-color: var(--parchment-dust);
}

.stratum-treaty .stratum-title {
    color: var(--treaty-ink);
}

.treaty-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2.5rem;
}

.treaty-columns p {
    margin-bottom: 1.5rem;
}

.treaty-columns em {
    font-weight: 600;
    font-style: normal;
}

/* --- Redaction Bars --- */
.redacted {
    position: relative;
    cursor: pointer;
}

.redacted .visible-text {
    position: relative;
    z-index: 1;
}

.redacted .visible-text::after {
    content: '';
    position: absolute;
    left: -2px;
    right: -2px;
    top: -4px;
    bottom: -4px;
    background: var(--redaction-soot);
    z-index: 2;
    transition: opacity 150ms;
    pointer-events: none;
}

.redacted .declassified {
    display: none;
    color: var(--dispute-vermillion);
    font-weight: 600;
}

.redacted:hover .visible-text::after {
    opacity: 0.15;
}

.redacted:hover .visible-text {
    color: transparent;
}

.redacted:hover .declassified {
    display: inline;
}

/* Tap support for mobile */
.redacted.revealed .visible-text::after {
    opacity: 0.15;
}

.redacted.revealed .visible-text {
    color: transparent;
}

.redacted.revealed .declassified {
    display: inline;
}

/* --- STRATUM 3: Erosion --- */
.stratum-erosion {
    background-color: var(--parchment-dust);
}

.erosion-field {
    position: relative;
    padding: 2rem 0;
}

.ghost-text {
    opacity: 0.08;
    color: var(--vellum-bone);
    font-weight: 400;
    margin-bottom: 2rem;
    user-select: text;
}

.ghost-text::selection {
    background: var(--dispute-vermillion);
    color: var(--vellum-bone);
    opacity: 1;
}

.surviving-fragment {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: clamp(1.15rem, 2vw, 1.4rem);
    color: var(--treaty-ink);
    margin: 3rem 0;
    padding-left: 1.5rem;
    border-left: 2px solid var(--boundary-chalk);
}

/* --- STRATUM 4: Annotation (Inverted) --- */
.stratum-annotation {
    background-color: var(--charred-umber);
    color: var(--bleached-linen);
}

.stratum-grid-inverted {
    grid-template-columns: 58% 1fr 8%;
    transition: grid-template-columns 600ms ease-in-out;
}

.annotation-expanded {
    padding: 4vh 2rem 4vh 3rem;
    background: rgba(0, 0, 0, 0.15);
    align-self: stretch;
}

.annotation-expanded .annotation-content {
    position: sticky;
    top: 10vh;
}

.annotation-expanded .gutter-label {
    color: var(--boundary-chalk);
}

.annotation-expanded .gutter-ref {
    color: var(--bleached-linen);
}

.expanded-note {
    font-family: var(--font-mono);
    font-size: clamp(0.8rem, 1.2vw, 0.95rem);
    font-weight: 300;
    letter-spacing: 0.02em;
    color: var(--bleached-linen);
    line-height: 1.65;
    margin-bottom: 1.5rem;
}

.expanded-note.disputed {
    color: var(--dispute-vermillion);
}

.expanded-note em {
    font-style: italic;
    font-weight: 400;
}

.stratum-annotation .stratum-title {
    color: var(--bleached-linen);
}

.main-column-narrow {
    padding: 4vh 2rem;
}

.stratum-annotation .main-column p {
    color: var(--bleached-linen);
    margin-bottom: 1.5rem;
}

/* --- STRATUM 5: Bedrock --- */
.stratum-bedrock {
    background-color: var(--redaction-soot);
    color: var(--bleached-linen);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.stratum-grid-bedrock {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.main-column-bedrock {
    max-width: 70%;
    padding: 0 2rem;
}

.bedrock-statement {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 6vw, 6rem);
    font-weight: 900;
    letter-spacing: 0.04em;
    color: var(--bleached-linen);
    line-height: 1.15;
}

/* --- Wax Seal Fragment --- */
.wax-seal {
    position: absolute;
    bottom: 6vh;
    left: 50%;
    transform: translateX(-50%);
}

.seal-svg {
    width: 80px;
    height: 80px;
}

/* --- Amendment Stamps --- */
[data-status]::after {
    content: attr(data-status);
    position: absolute;
    right: -48px;
    top: 0.5em;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 12px;
    background: var(--seal-indigo);
    color: var(--bleached-linen);
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 400;
    letter-spacing: 0.05em;
    line-height: 1;
}

p[data-status] {
    position: relative;
}

.right-margin .amendment-stamp {
    display: block;
    width: 32px;
    height: 12px;
    background: var(--seal-indigo);
    margin-bottom: 3rem;
    position: relative;
}

.right-margin .amendment-stamp::after {
    content: attr(data-status);
    position: absolute;
    left: 0;
    top: 0;
    width: 32px;
    height: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--seal-indigo);
    color: var(--bleached-linen);
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 400;
    letter-spacing: 0.05em;
    line-height: 1;
    right: auto;
    top: 0;
}

/* --- Links --- */
a {
    color: var(--treaty-ink);
    text-decoration: none;
    transition: color 150ms;
}

a:hover {
    color: var(--dispute-vermillion);
}

/* --- Mobile Responsive (< 768px) --- */
@media (max-width: 768px) {
    .core-line {
        display: none;
    }

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

    .stratum-grid-inverted {
        grid-template-columns: 1fr;
    }

    .stratum-grid-bedrock {
        display: flex;
    }

    .annotation-gutter {
        background: transparent;
        padding: 2vh 1.5rem;
        border-left: 3px solid var(--seal-indigo);
        margin: 0 1.5rem 2rem;
    }

    .annotation-gutter .annotation-content {
        position: relative;
        top: 0;
    }

    .annotation-expanded {
        padding: 2vh 1.5rem;
        border-left: 3px solid var(--seal-indigo);
        margin: 0 1.5rem 2rem;
        background: transparent;
    }

    .annotation-expanded .annotation-content {
        position: relative;
        top: 0;
    }

    .main-column {
        padding: 2vh 1.5rem;
    }

    .main-column-narrow {
        padding: 2vh 1.5rem;
    }

    .main-column-bedrock {
        max-width: 90%;
    }

    .right-margin {
        display: none;
    }

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

    .domain-inscription {
        font-size: clamp(2.2rem, 10vw, 4rem);
    }

    .bedrock-statement {
        font-size: clamp(1.8rem, 8vw, 3.5rem);
    }

    p[data-status]::after {
        display: none;
    }
}
