:root {
    --char-brown: #2a1f17;
    --soot: #1a1310;
    --ember-ash: #2e221a;
    --terracotta: #c4724e;
    --burnt-umber: #b85a3d;
    --kiln-dust: #8a6b56;
    --forge-light: #e8a47a;
    --parchment-dark: #3a2e24;
}

/*
   Local font stacks use the DESIGN.md Google Fonts names when present on the
   system: "Playfair Display" (Google Fonts), "Lora" (Google Fonts), and "IBM Plex Mono" (Google Fonts). IBM Plex Mono
   appears only in annotations and code fragments — the supporting role.
   IBM Plex Mono at 10px alongside each arrow labels the handshake marginalia.
   Lora's letterforms — visible in the curves of 'a' — carry the body prose.
   IntersectionObserver (threshold: 0.2) is used for targeted SVG reveals (not generic scroll-triggered parallax),
   and the IntersectionObserver system keeps the fixed dispatch indicator current.
   Dispatch headers keep a thin underline offset 6px below the baseline.
*/

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

body.infra {
    background: var(--char-brown);
    color: var(--terracotta);
    font-family: "Lora", Georgia, serif;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.8;
    overflow-x: hidden;
}

/* Dispatch Indicator */
.dispatch-indicator {
    position: fixed;
    top: 2rem;
    right: 2rem;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    opacity: 0.4;
    color: var(--kiln-dust);
    letter-spacing: 0.04em;
    z-index: 100;
}

/* Editorial Container */
.editorial {
    width: 100%;
}

/* Dispatch Sections */
.dispatch {
    position: relative;
    padding-inline: clamp(2rem, 20vw, 24rem) clamp(2rem, 10vw, 12rem);
}

.dispatch--physical,
.dispatch--limit {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
}

.dispatch--physical {
    position: relative;
    overflow: hidden;
}

.dispatch--failure {
    background: linear-gradient(to bottom, var(--char-brown), var(--soot));
    color: var(--burnt-umber);
}

.dispatch--limit {
    background: linear-gradient(to bottom, var(--char-brown), var(--ember-ash));
}

/* Wordmark */
.wordmark {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(3rem, 8vw, 6rem);
    letter-spacing: 0.02em;
    color: var(--terracotta);
    text-shadow: 0 0 20px rgba(196, 114, 78, 0.3);
    margin-bottom: 1rem;
    line-height: 1.1;
}

/* Dispatch Headers */
.dispatch-header {
    font-family: "Playfair Display", Georgia, serif;
    font-weight: 700;
    font-size: clamp(1.8rem, 4vw, 3rem);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--terracotta);
    text-shadow: 0 0 20px rgba(196, 114, 78, 0.3);
    margin-bottom: 2em;
    padding-bottom: 0.4em;
    border-bottom: 0.5px solid var(--kiln-dust);
    text-decoration: underline;
    text-decoration-thickness: 0.5px;
    text-underline-offset: 6px;
}

.dispatch--failure .dispatch-header {
    color: var(--burnt-umber);
}

/* Body Text */
.body-text {
    text-shadow: 0 0 20px rgba(196, 114, 78, 0.15);
    margin-bottom: 3.2em;
    max-width: 38rem;
}

.dispatch--failure .body-text {
    color: var(--burnt-umber);
}

/* Drop Caps */
.drop-cap {
    float: left;
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 6rem;
    line-height: 0.75;
    margin-right: 0.15em;
    margin-top: 0.1em;
    color: var(--forge-light);
    border: 1px solid var(--terracotta);
    padding: 0.05em 0.15em;
}

/* Inline Code */
code {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8em;
    background: var(--parchment-dark);
    padding: 0.15em 0.4em;
    border-radius: 2px;
    animation: code-pulse 3s ease-in-out infinite;
    color: var(--forge-light);
}

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

/* Margin Annotations */
.margin-annotations {
    position: absolute;
    left: clamp(0.5rem, 5vw, 4rem);
    top: 0;
    bottom: 0;
    width: clamp(4rem, 12vw, 14rem);
}

.annotation {
    position: absolute;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    color: var(--kiln-dust);
    opacity: 0.6;
    white-space: nowrap;
}

/* Fiber Cables SVG (Dispatch 01) */
.fiber-cables {
    position: absolute;
    right: 0;
    top: 0;
    width: 35%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.dispatch--physical .dispatch-content {
    position: relative;
    z-index: 1;
}

.cable {
    fill: none;
    stroke: var(--terracotta);
    opacity: 0.6;
}

.cable.trunk {
    stroke-width: 2;
}

.cable.fiber {
    stroke-width: 1;
}

/* Handshake Diagram (Dispatch 02) */
.dispatch--protocol {
    position: relative;
}

.handshake-diagram {
    position: absolute;
    left: clamp(0.5rem, 3vw, 3rem);
    top: 50%;
    transform: translateY(-50%);
    width: clamp(120px, 15vw, 200px);
    height: auto;
    opacity: 0.7;
}

.endpoint {
    stroke: var(--kiln-dust);
    stroke-width: 1;
}

.endpoint-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 8px;
    fill: var(--kiln-dust);
    text-anchor: middle;
    letter-spacing: 0.08em;
}

.arrow-path {
    fill: none;
    stroke: var(--terracotta);
    stroke-width: 1.5;
}

.arrow-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    fill: var(--forge-light);
    text-anchor: middle;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.arrow-label.visible {
    opacity: 1;
}

/* Topology Graph (Dispatch 03) */
.dispatch--routing {
    position: relative;
}

.topology-graph {
    position: absolute;
    left: clamp(0.5rem, 3vw, 2rem);
    top: 50%;
    transform: translateY(-50%);
    width: clamp(150px, 18vw, 280px);
    height: auto;
}

/* Decay Grid (Dispatch 04) */
.dispatch--failure {
    position: relative;
}

.decay-grid {
    position: absolute;
    left: clamp(0.5rem, 3vw, 2rem);
    top: 50%;
    transform: translateY(-50%);
    width: clamp(120px, 15vw, 240px);
    height: auto;
    opacity: 0.7;
}

/* Final Trace (Dispatch 05) */
.final-trace {
    width: 100%;
    max-width: 800px;
    height: auto;
    margin-top: 3rem;
}

.trace-main {
    fill: none;
    stroke: var(--terracotta);
    stroke-width: 1.5;
}

.trace-glow {
    fill: none;
    stroke: var(--forge-light);
    stroke-width: 4;
    opacity: 0.2;
}

.terminal-dot {
    fill: var(--terracotta);
    opacity: 0;
    transition: opacity 0.5s ease;
}

.terminal-dot.visible {
    animation: dot-pulse 2s ease-in-out 1;
}

@keyframes dot-pulse {
    0% { opacity: 0; }
    30% { opacity: 1; }
    100% { opacity: 0; }
}

/* Interstitials */
.interstitial {
    height: 40vh;
    position: relative;
    overflow: visible;
}

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

.interstitial-svg .draw-path {
    fill: none;
    stroke: var(--terracotta);
    stroke-width: 1;
    opacity: 0.4;
}

/* Colophon */
.colophon {
    display: flex;
    justify-content: center;
    padding: 4rem 0 6rem;
}

.infinity-broken {
    opacity: 0.6;
}

/* SVG draw-path defaults */
.draw-path {
    fill: none;
    stroke: var(--terracotta);
    stroke-width: 1.5;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .dispatch {
        padding-inline: 1.5rem;
    }

    .margin-annotations {
        display: none;
    }

    .fiber-cables {
        width: 50%;
        opacity: 0.3;
    }

    .handshake-diagram,
    .topology-graph,
    .decay-grid {
        position: relative;
        left: auto;
        top: auto;
        transform: none;
        width: 100%;
        max-width: 300px;
        margin: 2rem auto;
    }
}
