/* Civilised Blackout: Sense Future house style, light theme:
   warm ivory paper, ink navy, institutional gold; Fraunces for headings,
   IBM Plex Sans for text; quiet layout, thin rules, a short gold rule under
   titles. Fonts are local files so the pack works with no internet. */

@font-face { font-family: 'Fraunces'; font-style: normal; font-weight: 300 700; font-display: swap; src: url('fonts/fraunces-latin.woff2') format('woff2'); }
@font-face { font-family: 'Fraunces'; font-style: italic; font-weight: 300 700; font-display: swap; src: url('fonts/fraunces-italic-latin.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 400 700; font-display: swap; src: url('fonts/ibmplexsans-latin.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Sans'; font-style: italic; font-weight: 400; font-display: swap; src: url('fonts/ibmplexsans-italic-latin.woff') format('woff'); }

:root {
  --navy: #0A1420; --ink: #0A1420; --ink-2: #22303F; --ink-3: #46525E;
  --ink-4: #78808A; --mute: #A2A7AD;
  --paper: #FBF7EC; --paper-2: #F4EEDF; --card: #FFFDF7; --surround: #E6E1D3;
  --gold: #D4AF37; --gold-deep: #9A7A22; --gold-glow: rgba(212, 175, 55, .11);
  --rule: rgba(10, 20, 32, .12); --rule-strong: rgba(10, 20, 32, .22);
  --warn: #A4520F; --warn-bg: #FBEFDF; --ok: #3F6B3F; --ok-bg: #EEF3E8;
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { background: var(--surround); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--surround); color: var(--ink-2);
  font-family: var(--sans); font-size: 16.5px; line-height: 1.6;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  font-feature-settings: "kern", "calt";
}
::selection { background: var(--gold-deep); color: var(--paper); }

/* The sheet: one long page of warm ivory on a darker surround */
main {
  max-width: 54rem; margin: 1.2rem auto; padding: 2.2rem 2.4rem 3.5rem;
  background: var(--paper); box-shadow: 0 6px 22px rgba(10, 20, 32, .12);
}

/* Headings: Fraunces, optical size large, soft */
h1, h2, h3, h4 { font-family: var(--serif); color: var(--ink); font-variation-settings: "opsz" 144, "SOFT" 40; letter-spacing: -.018em; }
h1 { font-weight: 300; font-size: clamp(2.6rem, 7vw, 4.4rem); line-height: .98; letter-spacing: -.035em; margin: 0 0 .5rem; }
h1 em, h2 em { font-style: italic; color: var(--gold-deep); }
h2 { position: relative; font-weight: 400; font-size: clamp(1.7rem, 3.6vw, 2.25rem); line-height: 1.1; margin: 3.4rem 0 1.4rem; padding-bottom: .9rem; border-bottom: 1px solid var(--rule); }
h2::after { content: ""; position: absolute; left: 0; bottom: -1px; width: 4.2rem; height: 2px; background: var(--gold); }
h3 { font-weight: 400; font-size: 1.35rem; line-height: 1.2; margin: 2.2rem 0 .6rem; }
h4 { font-family: var(--sans); font-weight: 600; font-size: 1rem; letter-spacing: 0; color: var(--ink); margin: 1.5rem 0 .4rem; font-variation-settings: normal; }
p, li { max-width: 46rem; }
li { margin: .3rem 0; }
strong, b { font-weight: 600; color: var(--ink); }
a { color: var(--gold-deep); text-decoration-thickness: 1px; text-underline-offset: 2px; }
code { font-family: var(--mono); font-size: .84em; background: var(--paper-2); border: 1px solid var(--rule); border-radius: 2px; padding: 0 .25em; color: var(--ink); }
pre { font-family: var(--mono); background: var(--card); border: 1px solid var(--rule); border-left: 2px solid var(--gold); padding: .8rem .9rem; overflow-x: auto; font-size: .8rem; line-height: 1.45; white-space: pre-wrap; word-break: break-word; color: var(--ink); }
pre code { background: none; border: 0; padding: 0; }
hr { border: 0; border-top: 1px solid var(--rule); }

/* Labels: small gold kicker */
.part-label, .label, .kicker { display: block; font-family: var(--sans); font-size: .74rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-deep); margin-bottom: .5rem; }
.meta { font-family: var(--sans); font-size: .86rem; color: var(--ink-4); }

/* Brand: the Sense Future mark and name */
.brand { display: inline-flex; align-items: center; gap: .7rem; text-decoration: none; color: var(--ink); font-family: var(--serif); font-weight: 400; font-size: 1.15rem; letter-spacing: -.012em; font-variation-settings: "opsz" 144, "SOFT" 50; }
.brand img { width: 58px; height: auto; display: block; }
.brand em { font-style: italic; color: var(--gold-deep); }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding-bottom: 1rem; margin-bottom: 1.6rem; border-bottom: 1px solid var(--rule); }
.topbar .meta { margin: 0; text-align: right; }

/* The cover */
.cover { min-height: 82vh; display: flex; flex-direction: column; padding: .5rem 0 1.5rem; margin-bottom: 1rem; }
.cover .brand img { width: 96px; }
.cover-title { margin-top: auto; }
.cover-logo { margin: 0; line-height: 0; }
.cover-logo img { display: block; width: min(100%, 27rem); height: auto; }
.cover-rule { width: 4.6rem; height: 2px; background: var(--gold); margin: 1.6rem 0 1.2rem; }
.cover .sub { font-family: var(--serif); font-style: italic; font-size: 1.35rem; line-height: 1.4; color: var(--gold-deep); max-width: 40rem; font-variation-settings: "opsz" 24, "SOFT" 0; margin: 0 0 1.2rem; }
.cover .thesis { font-family: var(--serif); font-weight: 300; font-size: 1.12rem; line-height: 1.5; color: var(--ink-2); max-width: 40rem; font-variation-settings: "opsz" 24, "SOFT" 0; }
.cover .fine { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--rule); font-size: .82rem; color: var(--ink-4); }
.footer-brand { margin-top: 3.5rem; padding-top: 1rem; border-top: 1px solid var(--rule); font-size: .8rem; color: var(--ink-4); display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }

/* Tables: quiet, ruled rows, no boxes */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; margin: 1rem 0 1.6rem; font-size: .9rem; }
th, td { padding: .55rem .6rem .55rem 0; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule); }
th { font-size: .76rem; font-weight: 600; letter-spacing: .02em; color: var(--ink-4); border-bottom: 1px solid var(--rule-strong); }
td:first-child { color: var(--ink); }

/* Callouts */
.box { background: var(--card); border: 1px solid var(--rule); padding: 1rem 1.2rem; margin: 1.5rem 0; position: relative; }
.box::before { content: ""; position: absolute; left: 1.2rem; top: -1px; width: 2.4rem; height: 2px; background: var(--gold); }
.box h3, .box h4 { margin-top: .2rem; }
.warn { background: var(--warn-bg); border-left: 3px solid var(--warn); color: #4A2A08; padding: .9rem 1.2rem; margin: 1.5rem 0; }
.warn strong:first-child { font-size: .78rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--warn); }
.good { background: var(--ok-bg); border-left: 3px solid var(--ok); padding: .8rem 1.2rem; margin: 1.3rem 0; }
.card { background: var(--card); border: 1px solid var(--rule-strong); padding: 1.2rem 1.4rem; margin: 1.8rem 0; position: relative; }
.card::before { content: ""; position: absolute; left: 1.4rem; top: -1px; width: 4.2rem; height: 2px; background: var(--gold); }
.card h3 { margin-top: .2rem; }

/* Numbered steps: small gold-ringed numerals */
.steps { counter-reset: step; list-style: none; padding-left: 0; }
.steps > li { counter-increment: step; position: relative; padding-left: 2.6rem; margin: .85rem 0; }
.steps > li::before { content: counter(step); position: absolute; left: 0; top: .1rem; width: 1.75rem; height: 1.75rem; border: 1px solid var(--gold-deep); border-radius: 50%; color: var(--gold-deep); background: var(--card); text-align: center; font: 600 .8rem/1.68rem var(--sans); font-feature-settings: "tnum"; }

/* Figures */
figure { margin: 1.7rem 0; padding: 1rem; background: var(--card); border: 1px solid var(--rule); }
figure svg { width: 100%; height: auto; display: block; }
figcaption { font-size: .82rem; color: var(--ink-4); margin-top: .6rem; padding-top: .5rem; border-top: 1px solid var(--rule); }

/* Helpers */
.toc ol { columns: 2; column-gap: 2rem; font-size: .95rem; }
.toc li { break-inside: avoid; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.6rem; }
.small { font-size: .86rem; }
.tick { list-style: none; padding-left: 0; }
.tick li::before { content: "\25A2  "; color: var(--gold-deep); }
.sources li { font-size: .84rem; word-break: break-word; color: var(--ink-3); }

/* Part labels between the two halves of the guide */
.book-label { margin: 3.5rem 0 1rem; padding: 2.2rem 0 1.4rem; border-top: 2px solid var(--gold); border-bottom: 1px solid var(--rule); }
.book-label .book-title { font-family: var(--serif); font-weight: 300; font-size: clamp(2rem, 5vw, 3rem); line-height: 1; color: var(--ink); margin: .2rem 0 .8rem; font-variation-settings: "opsz" 144, "SOFT" 40; }
.book-label p { margin: 0; color: var(--ink-3); }
h5 { font-family: var(--sans); font-weight: 600; font-size: .95rem; color: var(--ink-2); margin: 1.2rem 0 .3rem; }

/* "In detail" link block at the end of each part */
.more { margin: 1.6rem 0 .5rem; padding: .8rem 1.1rem; background: var(--paper-2); border-left: 3px solid var(--gold); }
.more-k { display: block; font-size: .72rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-deep); margin-bottom: .3rem; }

/* Footnotes: the notes are the bibliography */
sup.fn { font-size: .68em; line-height: 0; margin-left: .08em; }
sup.fn a { text-decoration: none; color: var(--gold-deep); font-weight: 600; }
.notes { margin: 2.2rem 0 0; padding-top: .8rem; border-top: 1px solid var(--rule-strong); font-size: .8rem; color: var(--ink-3); }
.notes h4 { font-size: .74rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-deep); margin: 0 0 .5rem; }
.notes ol { padding-left: 2.2rem; margin: 0; }
.notes li { margin: .25rem 0; max-width: none; word-break: break-word; }
.notes a { color: var(--ink-3); }
.notes .fn-back { color: var(--gold-deep); font-size: .9em; white-space: nowrap; }

/* Contents */
.toc-book { margin: .8rem 0 1.2rem; }
.toc-k { font-size: .74rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-deep); margin: 0 0 .3rem; }
.toc ol.toc-main { columns: 1; padding-left: 0; list-style: none; margin: 0; }
.toc ol.toc-main > li { margin: .3rem 0; font-weight: 500; }
.toc ol.toc-sub { list-style: none; padding-left: 1.2rem; margin: .2rem 0 .5rem; columns: 2; column-gap: 1.6rem; font-weight: 400; font-size: .86rem; }
.toc a { text-decoration: none; color: var(--ink-2); }
.toc a:hover { color: var(--gold-deep); }

@media (max-width: 680px) {
  .toc ol.toc-sub { columns: 1; }
  body { font-size: 16px; }
  main { margin: 0; padding: 1.2rem 1rem 2.5rem; box-shadow: none; }
  .two { grid-template-columns: 1fr; }
  .toc ol { columns: 1; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .topbar .meta { text-align: left; }
}

@page { margin: 15mm 15mm 17mm; }
@media print {
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* Print on white to save ink; the ivory stays on screen. */
  html, body { background: #fff; }
  body { font-size: 10pt; }
  main { max-width: none; margin: 0; padding: 0; box-shadow: none; background: #fff; }
  .table-wrap { overflow: visible; }
  figure, .card, .box { background: #fff; }
  /* Divider pages: the label sits a third of the way down its own page. */
  .book-label { break-before: page; margin-top: 80mm; }
  .notes { break-inside: auto; font-size: 7.5pt; line-height: 1.35; margin-top: 1.4rem; }
  .notes li { margin: .1rem 0; }
  h2 { break-before: page; margin-top: 0; }
  h2.keep { break-before: auto; }
  /* Every part, chapter and appendix starts on a new page; sections inside
     them do not. A heading never sits alone at the foot of a page. */
  h2 { break-after: avoid; }
  h3, h4 { break-after: avoid; }
  /* Diagrams, code and short notices stay whole. Tables and long boxes may
     continue on the next page (whole rows only, header row repeated), so
     they never leave a large empty space. */
  figure, pre, .warn, .good { break-inside: avoid; }
  table, .box, .card { break-inside: auto; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; }
  p, li { orphans: 3; widows: 3; }
  .card { break-before: page; }
  a { color: var(--gold-deep); text-decoration: underline; text-decoration-thickness: .5px; text-underline-offset: 1.5px; }
  .toc a, sup.fn a, a.brand, .fn-back { text-decoration: none; }
  .cover { min-height: 235mm; }
  .noprint { display: none; }
}
