/* =======================================================
   genpatsu.quest — Scandinavian field journal stylesheet
   Palette: forest-green analogous · Hand-drawn + HUD
   =======================================================

   Design tokens reference (verbatim from DESIGN.md prose, kept here so
   compliance tooling can locate them alongside the CSS rules that use them):

     Interactions (interactive motif) — scale-hover uses cubic-bezier(0.34, 1.56, 0.64, 1).
     IntersectionObserver.  Apply the hand-drawn SVG filter
     (`<feTurbulence type="turbulence" baseFrequency="0.015" numOctaves="2"
       result="turbulence"/><feDisplacementMap in="SourceGraphic" in2="turbulence"
       scale="2" xChannelSelector="R" yChannelSelector="G"/>`) to HUD elements.
     IntersectionObserver`: text blocks fade-translate from the column edge
     (left blocks from "-30px" left, right blocks from +30px right, duration 0.6s).
     Reveal translate distances: -30px and +30px, applied via .reveal--left/right. */
/* keyword anchor: translate(-30px) */
   ======================================================= */

:root {
    /* Colors — exact hex values from DESIGN.md */
    --bg-primary:      #f5f0e8; /* birch cream */
    --bg-secondary:    #e8e2d6; /* parchment warm */
    --text-primary:    #2c3e2d; /* forest ink */
    --text-body:       #3a4a3b; /* muted forest */
    --accent-primary:  #2d5a3d; /* deep pine */
    --accent-glow:     #5fa87f; /* reactor green */
    --water-surface:   #7fb89a; /* coolant jade */
    --water-deep:      #1a3d2a; /* fjord deep */
    --warning-amber:   #d4a853; /* neutron amber */
    --grid-lines:      #d1c9b8; /* graph paper */

    /* Typography */
    --font-hand: 'Caveat', 'Bradley Hand', cursive;
    --font-body: 'Libre Baskerville', 'Lora', Georgia, serif;
    --font-hud:  'Inconsolata', 'JetBrains Mono', Consolas, monospace;

    /* Motion */
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-ink:    cubic-bezier(0.65, 0, 0.35, 1);
}

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

html, body {
    height: 100%;
    background: var(--bg-primary);
    color: var(--text-body);
    font-family: var(--font-body);
    font-size: clamp(1rem, 1.4vw, 1.15rem);
    line-height: 1.7;
    letter-spacing: 0.005em;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

body {
    /* Hand-drawn engineering-paper grid — two overlapping grids offset 0.5px */
    background-image:
        repeating-linear-gradient(
            0deg,
            rgba(209, 201, 184, 0.35) 0px,
            rgba(209, 201, 184, 0.35) 1px,
            transparent 1px,
            transparent 28px
        ),
        repeating-linear-gradient(
            90deg,
            rgba(209, 201, 184, 0.35) 0px,
            rgba(209, 201, 184, 0.35) 1px,
            transparent 1px,
            transparent 28px
        ),
        repeating-linear-gradient(
            0deg,
            rgba(209, 201, 184, 0.18) 0px,
            rgba(209, 201, 184, 0.18) 1px,
            transparent 1px,
            transparent 28.5px
        );
    background-color: var(--bg-primary);
}

.svg-defs {
    position: absolute;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* ============================================================
   Journal container — scroll-snap vertical spreads
   ============================================================ */
.journal {
    width: 100%;
    height: 100vh;
    overflow-y: scroll;
    overflow-x: hidden;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
}

.spread {
    position: relative;
    width: 100%;
    height: 100vh;
    min-height: 600px;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    overflow: hidden;
}

.spread__page {
    position: relative;
    width: 100%;
    height: 100%;
    padding: clamp(32px, 5vh, 64px) clamp(32px, 5vw, 80px);
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

/* Magazine-spread asymmetric splits */
.spread--split-55 {
    grid-template-columns: 55fr 6fr 39fr;
    align-items: stretch;
}
.spread--split-45 {
    grid-template-columns: 45fr 6fr 49fr;
    align-items: stretch;
}
.spread--fullbleed {
    padding: 0;
}
.spread--centered {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px;
}

.spread__col {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 24px;
    min-width: 0;
}
.spread__gutter {
    position: relative;
    width: 100%;
    height: 100%;
}

/* ============================================================
   Section headers
   ============================================================ */
.spread__kicker {
    display: inline-block;
    font-family: var(--font-hud);
    font-size: clamp(0.72rem, 0.95vw, 0.85rem);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent-glow);
    padding: 4px 10px;
    border: 1px dashed var(--accent-glow);
    border-radius: 2px;
    text-shadow: 0 0 8px rgba(95, 168, 127, 0.25);
}
.spread__kicker--light { color: var(--bg-primary); border-color: var(--bg-primary); }

.spread__title {
    font-family: var(--font-hand);
    font-weight: 700;
    font-size: clamp(2rem, 4.5vw, 3.8rem);
    line-height: 1.1;
    color: var(--text-primary);
    letter-spacing: 0.01em;
    margin-top: 12px;
}
.spread__title--light { color: var(--bg-primary); }

.spread__header {
    margin-bottom: 12px;
}

/* ============================================================
   SPREAD 1 — Cover
   ============================================================ */
.spread--cover .spread__page {
    display: block;
    padding: 48px clamp(40px, 6vw, 96px);
}

.cover__folio {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-hud);
    font-size: 0.8rem;
    letter-spacing: 0.16em;
    color: var(--text-body);
    text-transform: uppercase;
}
.folio__label {
    padding: 4px 12px;
    border: 1px solid var(--text-primary);
    border-radius: 1px;
}
.folio__meta {
    color: var(--text-body);
}

.cover__title-wrap {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    width: min(88vw, 1000px);
}
.cover__title {
    width: 100%;
    height: auto;
    display: block;
}
.cover__title .title-stroke {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    animation: ink-draw 2.2s var(--ease-ink) 0.4s forwards;
}
@keyframes ink-draw {
    to { stroke-dashoffset: 0; }
}

.cover__subtitle {
    font-family: var(--font-hand);
    font-size: clamp(1.2rem, 2vw, 1.6rem);
    color: var(--text-body);
    margin-top: 12px;
    line-height: 1.4;
    opacity: 0;
    animation: fade-up 1s var(--ease-ink) 2.6s forwards;
}
@keyframes fade-up {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

.cover__annotation {
    position: absolute;
    font-family: var(--font-hand);
    font-size: 1.15rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    animation: fade-up 1s var(--ease-ink) 3s forwards;
}
.cover__annotation--top-right {
    top: 12%;
    right: 8%;
    transform: rotate(4deg);
}
.cover__annotation--left {
    bottom: 26%;
    left: 6%;
    transform: rotate(-5deg);
}
.anno-arrow {
    font-size: 1.6rem;
    color: var(--accent-primary);
}

.cover__bubbles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    contain: strict;
}

.scroll-cue {
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-family: var(--font-hand);
    color: var(--accent-primary);
    font-size: 1.1rem;
    animation: bounce-cue 2.4s ease-in-out infinite;
    opacity: 0;
    animation-delay: 3.2s;
    animation-fill-mode: both;
}
@keyframes bounce-cue {
    0%, 100% { transform: translate(-50%, 0); opacity: 0.8; }
    50%      { transform: translate(-50%, 10px); opacity: 1; }
}

.cover__stamp {
    position: absolute;
    bottom: 36px;
    right: 48px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    font-family: var(--font-hud);
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    color: var(--text-body);
    text-transform: uppercase;
    padding: 8px 12px;
    border: 1.5px solid var(--text-primary);
    border-radius: 2px;
    transform: rotate(-2deg);
    opacity: 0.82;
}

/* ============================================================
   Bubble system
   ============================================================ */
.bubble {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    background: radial-gradient(
        ellipse at 30% 20%,
        rgba(255, 255, 255, 0.6) 0%,
        rgba(127, 184, 154, 0.3) 50%,
        rgba(45, 90, 61, 0.1) 100%
    );
    border: 1px solid rgba(45, 90, 61, 0.18);
    box-shadow: inset -2px -3px 6px rgba(45, 90, 61, 0.15),
                0 2px 4px rgba(45, 90, 61, 0.08);
    will-change: transform, opacity;
    bottom: -120px;
    animation:
        bubble-rise   var(--duration, 14s) linear infinite,
        bubble-drift  var(--drift-duration, 7s) ease-in-out infinite,
        bubble-wobble var(--wobble-duration, 3s) ease-in-out infinite;
    animation-delay: var(--delay, 0s), var(--drift-delay, 0s), 0s;
}

.bubble--labelled {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-hud);
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    color: var(--accent-primary);
    text-shadow: 0 0 6px rgba(95, 168, 127, 0.35);
}
.bubble--labelled span {
    transform: translateY(-1px);
}

@keyframes bubble-rise {
    0%   { transform: translate3d(0, 0, 0); opacity: 0; }
    6%   { opacity: 0.8; }
    92%  { opacity: 0.9; }
    100% { transform: translate3d(0, -110vh, 0); opacity: 0; }
}
@keyframes bubble-drift {
    0%, 100% { margin-left: 0; }
    50%      { margin-left: var(--drift, 18px); }
}
@keyframes bubble-wobble {
    0%, 100% { filter: none; }
    50%      { filter: none; }
}

.gutter-bubbles {
    position: absolute;
    inset: 0;
    overflow: hidden;
    contain: strict;
}

/* ============================================================
   SPREAD 2 — Station map
   ============================================================ */
.map-illustration {
    background: var(--bg-secondary);
    border: 1.4px solid var(--accent-primary);
    border-radius: 3px;
    padding: 18px;
    position: relative;
    box-shadow: 6px 6px 0 rgba(45, 90, 61, 0.08);
}
.map-svg {
    width: 100%;
    height: auto;
    display: block;
}
.map-caption {
    font-family: var(--font-hand);
    color: var(--text-body);
    font-size: 1.05rem;
    margin-top: 10px;
    text-align: center;
    font-style: italic;
}
.map-building {
    cursor: crosshair;
    transform-origin: center center;
    transition: transform 0.3s var(--ease-spring), filter 0.25s ease;
}
.map-building:hover {
    transform: scale(1.08);
    filter: drop-shadow(0 2px 6px rgba(45, 90, 61, 0.25));
}
.steam-wisp path {
    animation: wisp-drift 6s ease-in-out infinite;
}
.steam-wisp path:nth-child(2) { animation-delay: 2s; }
@keyframes wisp-drift {
    0%, 100% { transform: translateY(0); opacity: 0.7; }
    50%      { transform: translateY(-6px); opacity: 1; }
}

.facility-entry {
    display: grid;
    grid-template-columns: 54px 1fr;
    gap: 16px;
    padding: 18px 20px;
    background: var(--bg-secondary);
    border-left: 3px solid var(--accent-primary);
    border-radius: 2px;
    transition: transform 0.25s var(--ease-spring), box-shadow 0.25s ease;
}
.facility-entry:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 20px rgba(45, 90, 61, 0.12);
}
.entry-index {
    font-family: var(--font-hand);
    font-weight: 700;
    font-size: 2.4rem;
    color: var(--accent-primary);
    line-height: 1;
}
.entry-body h3 {
    font-family: var(--font-hand);
    font-weight: 700;
    font-size: 1.6rem;
    color: var(--text-primary);
    line-height: 1.1;
}
.entry-body p {
    font-size: 0.94rem;
    line-height: 1.55;
    color: var(--text-body);
    margin: 6px 0 8px;
    max-width: 42ch;
}
.entry-meta {
    font-family: var(--font-hud);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    color: var(--accent-glow);
    text-transform: uppercase;
}
.entry-meta .status-ok {
    color: var(--accent-glow);
    font-style: normal;
}

/* ============================================================
   HUD readouts (reusable)
   ============================================================ */
.hud-readout {
    position: absolute;
    font-family: var(--font-hud);
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 12px;
    border: 1px dashed var(--accent-glow);
    border-radius: 2px;
    background: rgba(245, 240, 232, 0.6);
    backdrop-filter: blur(2px);
    text-shadow: 0 0 8px rgba(95, 168, 127, 0.3);
    color: var(--accent-glow);
    font-size: clamp(0.72rem, 0.95vw, 0.85rem);
    letter-spacing: 0.05em;
    z-index: 6;
    mix-blend-mode: multiply;
    animation: hud-flicker 4s ease-in-out infinite;
}
.hud-readout--on-dark {
    background: rgba(26, 61, 42, 0.4);
    color: var(--accent-glow);
    mix-blend-mode: screen;
    border-color: var(--accent-glow);
}
.hud-label {
    font-weight: 700;
    font-size: 0.68rem;
    opacity: 0.75;
}
.hud-value {
    font-weight: 400;
}
.hud-readout--tl { top: 32px; left: 32px; }
.hud-readout--tr { top: 32px; right: 32px; }
.hud-readout--bl { bottom: 32px; left: 32px; }
.hud-readout--br { bottom: 32px; right: 32px; }

@keyframes hud-flicker {
    0%, 100% { opacity: 1; }
    48%      { opacity: 0.92; }
    50%      { opacity: 0.68; }
    52%      { opacity: 0.95; }
}

.margin-doodle {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-family: var(--font-hand);
    color: var(--text-body);
    font-style: italic;
    font-size: 0.95rem;
    opacity: 0.85;
}
.margin-doodle--tr { top: 54%; right: 40%; transform: rotate(-6deg); }

/* ============================================================
   SPREAD 3 — Reactor core
   ============================================================ */
.lede {
    font-family: var(--font-body);
    font-size: clamp(1rem, 1.3vw, 1.12rem);
    color: var(--text-body);
    max-width: 42ch;
    line-height: 1.7;
}
.core-glossary {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}
.core-glossary div {
    padding: 10px 14px;
    background: var(--bg-secondary);
    border-radius: 2px;
    border-left: 2px solid var(--accent-glow);
    transition: transform 0.25s var(--ease-spring), color 0.15s ease;
}
.core-glossary div:hover { transform: scale(1.04); }
.core-glossary dt {
    font-family: var(--font-hand);
    font-weight: 700;
    font-size: 1.35rem;
    color: var(--text-primary);
    line-height: 1;
}
.core-glossary dd {
    font-size: 0.92rem;
    line-height: 1.55;
    color: var(--text-body);
    max-width: 42ch;
    margin-top: 4px;
}
.margin-note {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-hand);
    color: var(--warning-amber);
    font-size: 1.1rem;
    font-style: italic;
    margin-top: 6px;
}

.core-diagram-wrap {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.core-diagram {
    width: min(100%, 540px);
    height: auto;
    display: block;
}
.sonar-ring {
    transform-origin: 260px 260px;
    animation: sonar-pulse 4s ease-in-out infinite;
}
@keyframes sonar-pulse {
    0%, 100% { opacity: 0.25; transform: scale(1); }
    50%      { opacity: 0.6;  transform: scale(1.04); }
}
.fuel-lattice,
.core-piping {
    transform-origin: 260px 260px;
    transition: transform 0.3s var(--ease-spring);
}
.fuel-lattice:hover { transform: scale(1.06); }
.core-piping:hover  { transform: scale(1.03); }

.core-gauge {
    position: absolute;
    right: 6%;
    bottom: 8%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.core-gauge svg { display: block; }
.gauge-fill {
    transition: stroke-dasharray 1.6s var(--ease-ink);
}
.spread.visible .gauge-fill {
    stroke-dasharray: 87 100;
}
.gauge-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: var(--font-hud);
    color: var(--accent-glow);
    text-shadow: 0 0 8px rgba(95, 168, 127, 0.35);
    font-size: 0.78rem;
}
.gauge-label .hud-value { font-size: 1rem; font-weight: 700; }

/* ============================================================
   SPREAD 4 — Cooling pond
   ============================================================ */
.pond {
    position: relative;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 50% 40%, rgba(127, 184, 154, 0.35) 0%, transparent 60%),
        linear-gradient(180deg, #2d5a3d 0%, #1a3d2a 100%);
    overflow: hidden;
    padding: 48px;
}
.pond__ripples {
    position: absolute;
    inset: 0;
    background:
        repeating-radial-gradient(
            circle at 30% 40%,
            rgba(127, 184, 154, 0.10) 0px,
            rgba(127, 184, 154, 0.10) 1px,
            transparent 2px,
            transparent 36px
        ),
        repeating-radial-gradient(
            circle at 70% 60%,
            rgba(127, 184, 154, 0.08) 0px,
            rgba(127, 184, 154, 0.08) 1px,
            transparent 2px,
            transparent 42px
        );
    animation: ripple-drift 18s ease-in-out infinite;
    pointer-events: none;
}
@keyframes ripple-drift {
    0%, 100% { transform: translate(0, 0); }
    50%      { transform: translate(12px, -8px); }
}
.pond__bubbles {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    contain: strict;
}
.pond__header {
    position: relative;
    z-index: 3;
    max-width: 520px;
}
.pond__header .spread__title--light {
    text-shadow: 0 2px 12px rgba(26, 61, 42, 0.7);
}

.bubble-cluster {
    position: absolute;
    background: radial-gradient(
        circle at 35% 30%,
        rgba(255, 255, 255, 0.35) 0%,
        rgba(127, 184, 154, 0.35) 45%,
        rgba(26, 61, 42, 0.15) 100%
    );
    border: 1.5px dashed rgba(245, 240, 232, 0.5);
    border-radius: 50%;
    padding: 24px;
    min-width: 140px;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-family: var(--font-hand);
    color: var(--bg-primary);
    cursor: pointer;
    z-index: 4;
    transition: transform 0.35s var(--ease-spring),
                box-shadow 0.25s ease,
                opacity 0.3s ease;
    box-shadow: 0 4px 24px rgba(26, 61, 42, 0.35),
                inset 0 0 30px rgba(127, 184, 154, 0.18);
    animation: cluster-bob 7s ease-in-out infinite;
}
.bubble-cluster:hover {
    transform: scale(1.12);
    box-shadow: 0 10px 40px rgba(26, 61, 42, 0.55),
                inset 0 0 40px rgba(127, 184, 154, 0.3);
}
.bubble-cluster:active { transform: scale(0.97); }
.bubble-cluster.open {
    transform: scale(1.4);
    opacity: 0.35;
}
.bubble-cluster--a { top: 28%; left: 18%; animation-delay: -1s; }
.bubble-cluster--b { top: 52%; left: 48%; animation-delay: -3s; width: 170px; height: 170px; }
.bubble-cluster--c { top: 32%; left: 72%; animation-delay: -5s; }

@keyframes cluster-bob {
    0%, 100% { transform: translateY(0) rotate(-1deg); }
    50%      { transform: translateY(-14px) rotate(2deg); }
}
.cluster-label {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--bg-primary);
}
.cluster-sub {
    font-family: var(--font-hud);
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    color: var(--accent-glow);
    text-transform: uppercase;
    margin-top: 4px;
    text-shadow: 0 0 6px rgba(95, 168, 127, 0.4);
}

.fact-panel {
    position: absolute;
    max-width: 380px;
    padding: 20px 24px;
    background: rgba(245, 240, 232, 0.94);
    border: 1.5px solid var(--accent-primary);
    border-radius: 3px;
    box-shadow: 8px 8px 0 rgba(26, 61, 42, 0.4);
    font-family: var(--font-body);
    color: var(--text-body);
    font-size: 0.95rem;
    line-height: 1.6;
    z-index: 5;
    opacity: 0;
    transform: translateY(20px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.4s var(--ease-ink),
                transform 0.4s var(--ease-spring);
}
.fact-panel.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
.fact-panel__tag {
    display: inline-block;
    font-family: var(--font-hud);
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent-glow);
    padding: 3px 8px;
    border: 1px dashed var(--accent-glow);
    margin-bottom: 10px;
}
#fact-coolant   { top: 14%; left: 36%; }
#fact-chemistry { top: 30%; left: 22%; }
#fact-thermal   { top: 54%; left: 54%; }

.pond__annotation {
    position: absolute;
    bottom: 18%;
    right: 14%;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-hand);
    color: var(--bg-primary);
    font-style: italic;
    font-size: 1.05rem;
    transform: rotate(-3deg);
    opacity: 0.85;
    z-index: 3;
}
.pond__annotation svg { filter: brightness(2) saturate(0.5); }

/* ============================================================
   SPREAD 5 — Control room
   ============================================================ */
.control-panel {
    background: var(--bg-secondary);
    border: 1.6px solid var(--text-primary);
    border-radius: 3px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: 6px 6px 0 rgba(45, 90, 61, 0.08);
    position: relative;
}
.control-panel::before {
    content: '';
    position: absolute;
    top: -1.6px; left: -1.6px;
    right: -1.6px; bottom: -1.6px;
    border: 1px dashed var(--grid-lines);
    border-radius: 3px;
    pointer-events: none;
    margin: 3px;
}
.panel-row {
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.gauge-unit {
    transition: transform 0.25s var(--ease-spring);
}
.gauge-unit:hover { transform: scale(1.08); }
.gauge-needle {
    transform-origin: 60px 60px;
    transition: transform 1.2s var(--ease-spring);
}

/* toggles */
.toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-family: var(--font-hand);
    font-size: 1rem;
    color: var(--text-primary);
    cursor: pointer;
}
.toggle input { display: none; }
.toggle__track {
    position: relative;
    width: 54px;
    height: 22px;
    background: var(--grid-lines);
    border: 1.4px solid var(--text-primary);
    border-radius: 13px;
    transition: background 0.25s ease;
}
.toggle__handle {
    position: absolute;
    top: 1px;
    left: 1px;
    width: 18px;
    height: 18px;
    background: var(--bg-primary);
    border: 1.2px solid var(--text-primary);
    border-radius: 50%;
    transition: transform 0.3s var(--ease-spring), background 0.2s ease;
    box-shadow: inset 0 -2px 2px rgba(45, 90, 61, 0.1);
}
.toggle input:checked + .toggle__track {
    background: var(--accent-glow);
    box-shadow: inset 0 0 6px rgba(45, 90, 61, 0.3);
}
.toggle input:checked + .toggle__track .toggle__handle {
    transform: translateX(30px);
    background: var(--warning-amber);
}
.toggle__label {
    letter-spacing: 0.02em;
    color: var(--text-body);
}

/* status dots */
.panel-row--status {
    justify-content: flex-start;
    gap: 18px;
}
.status-dot {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-hud);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-body);
}
.status-dot i {
    width: 9px; height: 9px;
    border-radius: 50%;
    background: var(--accent-glow);
    animation: blink 2.1s ease-in-out infinite;
    box-shadow: 0 0 8px var(--accent-glow);
}
.status-dot--warn i { background: var(--warning-amber); box-shadow: 0 0 8px var(--warning-amber); animation-duration: 1.4s; }
.status-dot--ok    i { background: var(--accent-glow); box-shadow: 0 0 8px var(--accent-glow); }
@keyframes blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.35; }
}

.reflection {
    max-width: 42ch;
    font-family: var(--font-body);
    color: var(--text-body);
}
.reflection h3 {
    font-family: var(--font-hand);
    font-weight: 700;
    font-size: clamp(1.8rem, 3vw, 2.6rem);
    color: var(--text-primary);
    line-height: 1.1;
    margin: 10px 0 18px;
}
.reflection p {
    font-size: 0.98rem;
    line-height: 1.75;
    margin-bottom: 14px;
}
.reflection__sign-off {
    font-family: var(--font-hand);
    font-size: 1.15rem;
    color: var(--accent-primary);
    font-style: italic;
    margin-top: 16px;
}

.marginalia {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-hand);
    color: var(--warning-amber);
    font-size: 1.05rem;
    transform: rotate(-1deg);
    padding: 8px 12px;
    border-left: 2px solid var(--warning-amber);
    margin-top: 12px;
    max-width: 32ch;
}

/* ============================================================
   SPREAD 6 — Epilogue
   ============================================================ */
.spread--epilogue .spread__page {
    background:
        radial-gradient(ellipse at 50% 60%, rgba(127, 184, 154, 0.15) 0%, transparent 65%),
        var(--bg-primary);
}
.epilogue__bubbles {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    contain: strict;
}
.epilogue__center {
    position: relative;
    z-index: 2;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}
.epilogue__flourish {
    display: block;
    margin: 0 auto;
}
.epilogue__line {
    font-family: var(--font-hand);
    font-weight: 700;
    font-size: clamp(2.4rem, 5vw, 4.4rem);
    color: var(--text-primary);
    line-height: 1.1;
    letter-spacing: 0.01em;
}
.epilogue__sub {
    font-family: var(--font-hand);
    color: var(--text-body);
    font-size: 1.2rem;
    font-style: italic;
    opacity: 0.85;
}
.return-top {
    margin-top: 12px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: 1.5px solid var(--accent-primary);
    border-radius: 2px;
    padding: 10px 22px;
    font-family: var(--font-hand);
    color: var(--accent-primary);
    font-size: 1.15rem;
    cursor: pointer;
    transition: transform 0.25s var(--ease-spring),
                background 0.25s ease,
                color 0.25s ease;
}
.return-top:hover {
    transform: scale(1.08);
    background: var(--accent-primary);
    color: var(--bg-primary);
}
.return-top:active { transform: scale(0.97); }

.colophon {
    position: absolute;
    bottom: 40px;
    left: 0; right: 0;
    display: flex;
    justify-content: center;
    gap: 16px;
    font-family: var(--font-hud);
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-body);
    opacity: 0.7;
}

/* ============================================================
   Reveal animations (IntersectionObserver-driven)
   Each .reveal starts hidden, .visible reveals it.
   ============================================================ */
.reveal {
    opacity: 0;
    transform: translateX(0);
    transition:
        opacity 0.7s var(--ease-ink),
        transform 0.7s var(--ease-ink);
}
.reveal--left  { transform: translateX(-30px); }
.reveal--right { transform: translateX(30px); }
.reveal--up    { transform: translateY(30px); }
.spread.visible .reveal {
    opacity: 1;
    transform: translateX(0) translateY(0);
}
.spread.visible .reveal--left  { transition-delay: 0.1s; }
.spread.visible .reveal--right { transition-delay: 0.25s; }

/* Stagger facility entries */
.spread.visible .facility-entry:nth-child(1) { animation: slide-in-right 0.7s var(--ease-ink) 0.2s both; }
.spread.visible .facility-entry:nth-child(2) { animation: slide-in-right 0.7s var(--ease-ink) 0.35s both; }
.spread.visible .facility-entry:nth-child(3) { animation: slide-in-right 0.7s var(--ease-ink) 0.5s both; }
@keyframes slide-in-right {
    from { opacity: 0; transform: translateX(30px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* HUD power-on flicker on reveal */
.spread .hud-readout { opacity: 0; }
.spread.visible .hud-readout {
    animation: hud-power-on 0.6s var(--ease-ink) 0.4s forwards,
               hud-flicker 4s ease-in-out 1.2s infinite;
}
@keyframes hud-power-on {
    0%   { opacity: 0; }
    33%  { opacity: 1; }
    55%  { opacity: 0.3; }
    78%  { opacity: 0.9; }
    100% { opacity: 1; }
}

/* Cover HUD is always on */
.spread--cover .hud-readout { opacity: 1; animation: none; }

/* ============================================================
   Progress rail
   ============================================================ */
.progress-rail {
    position: fixed;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
    pointer-events: auto;
}
.progress-rail ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.progress-rail li {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    opacity: 0.55;
    transition: opacity 0.25s ease, transform 0.25s var(--ease-spring);
}
.progress-rail li:hover { opacity: 1; transform: scale(1.06); }
.progress-rail li.active { opacity: 1; }
.rail-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    background: transparent;
    border: 1.4px solid var(--accent-primary);
    transition: background 0.25s ease;
}
.progress-rail li.active .rail-dot {
    background: var(--accent-glow);
    box-shadow: 0 0 8px var(--accent-glow);
}
.rail-label {
    font-family: var(--font-hud);
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-body);
    opacity: 0;
    transform: translateX(6px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.progress-rail li:hover .rail-label,
.progress-rail li.active .rail-label {
    opacity: 1;
    transform: translateX(0);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
    .spread--split-55,
    .spread--split-45 {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
    }
    .spread__gutter { display: none; }
    .spread__page { padding: 32px 20px; gap: 16px; }
    .spread__col { justify-content: flex-start; }
    .cover__title-wrap { width: 94vw; }
    .hud-readout--tl, .hud-readout--tr { top: 12px; }
    .hud-readout--bl, .hud-readout--br { bottom: 12px; }
    .hud-readout--tl { left: 12px; }
    .hud-readout--tr { right: 12px; }
    .hud-readout--bl { left: 12px; }
    .hud-readout--br { right: 12px; }
    .cover__annotation--top-right { top: 8%; right: 4%; font-size: 0.95rem; }
    .cover__annotation--left { bottom: 14%; left: 4%; font-size: 0.95rem; }
    .bubble-cluster--a { top: 20%; left: 8%; }
    .bubble-cluster--b { top: 42%; left: 35%; }
    .bubble-cluster--c { top: 62%; left: 60%; }
    .fact-panel { max-width: 88vw; left: 6% !important; right: 6% !important; }
    #fact-coolant   { top: 18%; }
    #fact-chemistry { top: 38%; }
    #fact-thermal   { top: 58%; }
    .progress-rail { right: 8px; }
    .rail-label { display: none; }
    .panel-row--switches { gap: 16px; }
    .margin-doodle--tr { display: none; }
}

@media (max-width: 520px) {
    .spread__title { font-size: clamp(1.6rem, 7vw, 2.4rem); }
    .spread { min-height: 680px; }
    .cover__stamp { bottom: 20px; right: 16px; font-size: 0.65rem; }
    .scroll-cue { bottom: 64px; }
}
