/* ============================================================================
   Part IV — STRONGROOM. The ledger and the sealed dossier.
   Identity layer loaded after book.css; overrides reading furniture only.
   Curriculum spine invariant: .book-nav (Playfair + DM Mono + gold), glossary
   tooltips, fullscreen chrome, resume/sync chips — the gold thread.

   Subject → form: Part IV is bytes at rest — stored so they can be queried
   (the relational model is double-entry bookkeeping made mathematical),
   sealed so they cannot be read. Ledger stock and double-rule columns carry
   the data half; rubber stamps, redaction bars and typewritten exhibit labels
   carry the security half. The only part with a serif body: the archive
   reads like a document that has been kept.

   Motif evolution (cyclic, hand-set — see UNDER.md §8): the dossier
   declassifies as the reader learns. Chapter stamps land at different angles
   (ch13 −2° / ch14 +1.2° / ch15 −1°); each hero carries a redaction row that
   loses bars chapter by chapter (3 → 1 → 0, "nothing remains redacted" at
   Attack & Defense); the closer stamp reads at the opposite tilt of the
   opener's.
   ========================================================================== */

:root {
  --dark: #171008;            /* dossier plates, chapter-nav, code ground */
  --dark-card: #241a10;
  --warm-white: #f1e9d6;      /* ledger stock */
  --warm-light: #e9dfc6;
  --warm-mid: #c9bb9c;
  --accent: #c05a48;          /* burnt seal — readable on both grounds */
  --accent-dim: #8a2332;      /* oxblood — light-ground text */
  --text-dark: #241a12;
  --text-body: #3a2c20;
  --text-muted: #857258;
  --sans: 'Spectral', Georgia, serif;    /* the body role: serif, deliberate */
  --mono: 'Courier Prime', monospace;
  /* part-local */
  --sr-disp: 'Fraunces', Georgia, serif;
  --sr-stamp: #b8372f;
  --sr-parch: #e6d9bd;
  --sr-seal: #cf8d78;
  --sr-rule: rgba(36, 26, 18, 0.3);
}

/* --- spine re-pins ---------------------------------------------------------- */
.book-title { font-family: 'Playfair Display', Georgia, serif; }
.book-title em { color: #d4a853; }
.glossary-tip-term, .glossary-tip-link { color: #d4a853; }
.resume-title, .resume-arrow { color: #d4a853; }
.sync-chip-link { color: #d4a853; }
.glossary-footer-link, .account-footer-link { color: #d4a853; }
.book-progress { font-family: 'DM Mono', monospace; }
.glossary-tip-term, .resume-title, .sync-chip-link { font-family: 'Playfair Display', Georgia, serif; }
.glossary-tip-def { font-family: 'DM Sans', sans-serif; }
.glossary-tip-link, .resume-eyebrow, .resume-meta, .sync-chip-eyebrow,
.glossary-footer-link, .account-footer-link { font-family: 'DM Mono', monospace; }
.colophon-pane__name { font-family: 'Playfair Display', Georgia, serif; }
.colophon summary, .colophon-pane__role, .colophon-pane__note,
.colophon-pane__links { font-family: 'DM Mono', monospace; }

/* --- body: the kept document ------------------------------------------------ */
body { font-weight: 400; }          /* Spectral 300 is too thin at 1.05rem */
p { font-size: 1.08rem; }

/* --- openers: the sealed file ------------------------------------------------ */
.part-opener { background: var(--dark); }
.part-opener::before {
  content: '';
  position: absolute;
  inset: 18px;
  background: none;
  border: 1px solid rgba(230, 217, 189, 0.25);
  pointer-events: none;
}
.part-opener::after {
  content: '';
  position: absolute;
  inset: 26px;
  border: 1px solid rgba(230, 217, 189, 0.1);
  pointer-events: none;
}
@media (max-width: 700px) {
  .part-opener::before, .part-opener::after { display: none; }
}
/* the part label is a rubber stamp; the closer lands at the opposite tilt */
.part-label {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--sr-stamp);
  border: 2.5px solid var(--sr-stamp);
  border-radius: 2px;
  padding: 9px 18px 7px;
  transform: rotate(-2.2deg);
  letter-spacing: 0.32em;
}
.part-opener:last-of-type .part-label { transform: rotate(1.6deg); }
.part-opener h1 {
  font-family: var(--sr-disp);
  font-weight: 900;
  letter-spacing: -0.015em;
  line-height: 1.02;
  color: #f3ecd9;
}
.part-opener h1 em { font-style: italic; font-weight: 400; color: var(--sr-seal); }
.part-tagline {
  font-family: var(--sans);
  color: rgba(230, 217, 189, 0.55);
}

.chapter-hero { background: var(--dark); }
.chapter-hero::before {
  background: radial-gradient(ellipse at 70% 50%, rgba(230, 217, 189, 0.05) 0%, transparent 60%);
}
.chapter-label {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--sr-stamp);
  border: 2px solid var(--sr-stamp);
  border-radius: 2px;
  padding: 7px 14px 5px;
  display: inline-flex;
  letter-spacing: 0.28em;
}
.chapter-label::before { display: none; }
/* stamp angles land differently on every file — hand-set per chapter */
#ch13 .chapter-label { transform: rotate(-2deg); }
#ch14 .chapter-label { transform: rotate(1.2deg); }
#ch15 .chapter-label { transform: rotate(-1deg); }
.chapter-hero h1 {
  font-family: var(--sr-disp);
  font-weight: 900;
  letter-spacing: -0.015em;
  color: #f3ecd9;
}
.chapter-hero h1 em { font-style: italic; font-weight: 400; color: var(--sr-seal); }
.meta-value { color: rgba(230, 217, 189, 0.72); }

/* the declassification row: bars disappear as the part teaches (3 → 1 → 0) */
.sr-redact {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 28px;
}
.sr-redact i { display: block; height: 9px; background: rgba(230, 217, 189, 0.55); }
.sr-redact span {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: rgba(230, 217, 189, 0.45);
  text-transform: uppercase;
}

.toc-card {
  background: #1f1810;
  border: 1px solid rgba(230, 217, 189, 0.22);
  border-left: 4px double rgba(230, 217, 189, 0.4);
  border-radius: 2px;
}
.toc-card:hover { border-color: rgba(230, 217, 189, 0.5); border-left-color: var(--sr-seal); }
.toc-num { color: var(--sr-seal); font-weight: 700; }
.toc-title { font-family: var(--sr-disp); font-weight: 600; }

.chapter-nav { --nav-bg: #100b06; background: #100b06; border-bottom: 1px solid rgba(230, 217, 189, 0.14); }
.nav-item:hover, .nav-item.active { color: var(--sr-seal); border-bottom-color: var(--sr-stamp); }

/* --- reading furniture: the ledger page -------------------------------------- */
.content > .section {
  border-left: 4px double var(--sr-rule);
  padding-left: 36px;
}
@media (max-width: 768px) {
  .content > .section { border-left: none; padding-left: 0; }
}
h2 {
  font-family: var(--sr-disp);
  font-weight: 600;
  font-size: 2.5rem;
  letter-spacing: -0.01em;
  line-height: 1.15;
}
h3 {
  font-family: var(--sr-disp);
  font-weight: 400;
  font-style: italic;
  font-size: 1.5rem;
}
h4 { font-family: var(--sans); font-weight: 500; }
.section-number { font-weight: 700; }
.section-number::before {
  border-radius: 1px;
  box-shadow: 0 0 8px rgba(192, 90, 72, 0.45);
}
.lead { font-family: var(--sans); font-size: 1.32rem; line-height: 1.65; }
.lead::first-letter {
  font-family: var(--sr-disp);
  font-weight: 900;
  font-size: 4.4rem;
  line-height: 0.8;
  margin: 10px 14px 0 0;
  color: var(--accent-dim);
}

.pull-quote {
  border: 1px solid var(--sr-rule);
  border-left: 4px double var(--accent-dim);
  background: var(--warm-light);
  border-radius: 0 2px 2px 0;
}
.pull-quote p {
  font-family: var(--sr-disp);
  font-style: italic;
  font-weight: 400;
  font-size: 1.3rem;
  line-height: 1.55;
}

.section-intro { border-left-color: var(--accent-dim); }

/* --- figures: dossier plates -------------------------------------------------- */
.diagram-card {
  background: var(--dark);
  border: 1px solid rgba(230, 217, 189, 0.3);
  outline: 1px solid rgba(230, 217, 189, 0.13);
  outline-offset: 5px;
  border-radius: 2px;
}
.diagram-card::before {
  background: radial-gradient(ellipse at 50% 0%, rgba(230, 217, 189, 0.045) 0%, transparent 60%);
}
.diagram-label { color: rgba(230, 217, 189, 0.5); font-weight: 700; }
.diagram-caption {
  color: rgba(230, 217, 189, 0.55);
  border-top: 1px solid rgba(230, 217, 189, 0.2);
  padding-top: 14px;
}
.diagram-caption strong { color: var(--sr-parch); font-weight: 700; }
.diagram-caption a, .diagram-caption a:visited { color: var(--sr-seal); }

.light-diagram {
  background: var(--warm-light);
  border: 1px solid var(--sr-rule);
  outline: 1px solid rgba(36, 26, 18, 0.12);
  outline-offset: 4px;
  border-radius: 2px;
}
.scale-shock {
  background: var(--dark);
  border: 1px solid rgba(230, 217, 189, 0.3);
  border-radius: 2px;
}
.scale-shock::before {
  background: radial-gradient(ellipse at 50% 0%, rgba(230, 217, 189, 0.045) 0%, transparent 60%);
}

.code-block { background: #140e07; border-radius: 2px; border: 1px solid rgba(230, 217, 189, 0.16); }
.code-block .kw { color: var(--sr-seal); }

.insight-strip { border-radius: 2px; border-left: 3px solid var(--sr-stamp); }
/* Takeaway emphasis is weight-400, so colour is the only signal: --sr-seal (~6.9:1
   on the dossier plate) read dimmer than the body. Lift it to a brighter seal
   (~9:1, matching the body) for comfortable reading. Strip-scoped; token unchanged. */
.insight-icon { color: #e6a892; }
.insight-text strong { color: #e6a892; }

.math-callout {
  background: linear-gradient(135deg, var(--warm-light), #e2d5b5);
  border-left-color: var(--accent-dim);
  border-radius: 0 2px 2px 0;
}

.key-term { background: var(--dark-card); color: var(--sr-seal); border-radius: 2px; }

.timeline-item::before { border-radius: 1px; box-shadow: 0 0 12px rgba(192, 90, 72, 0.4); }
.timeline-title { font-family: var(--sr-disp); font-weight: 600; font-size: 1.08rem; }

.step-title { font-family: var(--sr-disp); font-weight: 600; }
.process-step { border: 1px solid rgba(230, 217, 189, 0.24); border-radius: 2px; }

.bit { border-radius: 2px; }
.bit.on { background: var(--sr-seal); color: var(--dark); }

.truth-table { border-radius: 2px; }
.concept-card { border-radius: 2px; }
.concept-title { font-family: var(--sr-disp); font-weight: 600; }
.memory-diagram { border-radius: 2px; }
.summary-table.dark { border-radius: 2px; }

h3 { background-image: linear-gradient(to right, rgba(138, 35, 50, 0.4), rgba(138, 35, 50, 0)); }

.chapter-end { background: var(--dark); }
.next-btn {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 12px;
  border-radius: 2px;
  background: var(--accent-dim);
  color: var(--warm-white);
}

.divider {
  background: none;
  border-top: 3px double var(--sr-rule);
  height: 0;
  width: 90px;
  opacity: 1;
}

/* stamps land on scroll — deliberate, single settle (progressive enhancement) */
@supports (animation-timeline: view()) {
  .chapter-label, .part-label {
    animation: srStamp 0.6s cubic-bezier(0.2, 0.9, 0.3, 1) both;
    animation-timeline: view();
    animation-range: entry 0% entry 30%;
  }
}
@keyframes srStamp {
  from { scale: 1.12; opacity: 0; }
  to   { scale: 1; opacity: 1; }
}

@media print {
  .part-opener::before, .part-opener::after { display: none !important; }
  .sr-redact i { background: #333 !important; }
}
