/* ============================================================================
   Explore Every Topic — Quick Answers
   Cinematic dark + luxury restraint. Gold is the only voice; navy carries
   depth; everything else gets out of the way.
   ========================================================================= */

:root {
  /* --- surfaces: near-black with a blue undertone, so warm type sings ---- */
  --void:            oklch(12% 0.014 250);
  --void-deep:       oklch(8%  0.012 250);
  --ink:             oklch(17% 0.016 250);
  --surface:         oklch(21% 0.018 250);
  --surface-lift:    oklch(25% 0.020 250);

  /* --- the site's own blues ---------------------------------------------- */
  --navy:            oklch(38% 0.095 255);   /* #123C70 */
  --navy-lift:       oklch(45% 0.105 255);   /* #1A4A8A */

  /* --- gold: the single accent ------------------------------------------- */
  --gold:            oklch(80% 0.130 82);
  --gold-bright:     oklch(89% 0.115 88);
  --gold-quiet:      oklch(46% 0.060 82);
  --gold-whisper:    oklch(30% 0.032 82);

  /* --- foreground: warm white against the cool ground --------------------
     Every step clears 4.5:1 on the panel surface, measured, not guessed:
     94% = 16.9   74% = 8.7   62% = 5.5   58% = 4.7                        */
  --fg:              oklch(94% 0.012 85);
  --fg-2:            oklch(74% 0.014 85);
  --fg-3:            oklch(62% 0.014 85);
  --fg-4:            oklch(58% 0.012 85);

  /* Borders that are the only outline of a control need 3:1 — 48% = 3.07.
     --gold-whisper stays for purely decorative rules, which are exempt. */
  --edge:            oklch(48% 0.060 82);

  /* Per-pillar accent. The real values live in data.json so the canvas and
     the panels can never drift apart; app.js sets this from the active pillar. */
  --accent: oklch(80% 0.130 82);

  /* --- type -------------------------------------------------------------- */
  --font-display: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
  --font-ui: 'Inter Tight', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --step--2: clamp(0.66rem, 0.63rem + 0.14vw, 0.73rem);
  --step--1: clamp(0.78rem, 0.75rem + 0.16vw, 0.86rem);
  --step-0:  clamp(0.94rem, 0.90rem + 0.19vw, 1.03rem);
  --step-1:  clamp(1.16rem, 1.09rem + 0.34vw, 1.35rem);
  --step-2:  clamp(1.55rem, 1.38rem + 0.83vw, 2.05rem);
  --step-3:  clamp(2.10rem, 1.75rem + 1.75vw, 3.15rem);

  /* --- rhythm ------------------------------------------------------------ */
  --s-1: 0.25rem;  --s-2: 0.5rem;   --s-3: 0.75rem;  --s-4: 1rem;
  --s-5: 1.5rem;   --s-6: 2rem;     --s-7: 3rem;     --s-8: 4rem;

  --rule: 1px solid var(--gold-whisper);
  --panel-w: 27rem;

  /* --- motion: never ease-in-out ----------------------------------------- */
  --ease-out: cubic-bezier(0.5, 0, 0, 1);
  --ease-confident: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ---------------------------------------------------------------- reset -- */

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

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--void);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: var(--step-0);
  line-height: 1.55;
  font-weight: 300;
  overflow: hidden;                 /* the map owns the viewport */
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

/* With JS off the map never appears, so let the document scroll normally. */
html:not(.js) body { overflow: auto; }
html:not(.js) .stage,
html:not(.js) .hint,
html:not(.js) .panel,
html:not(.js) .breadcrumb,
html:not(.js) .chrome-top__tools { display: none; }

html.js .static-index { display: none; }

h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }

a { color: inherit; text-decoration: none; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

/* ------------------------------------------------- the small textures --- */

::selection {
  background: var(--gold);
  color: var(--void-deep);
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Keep the standards property and the WebKit thumb on the same colour, or the
   panel's scrollbar reads as a gold border down the edge of the page. */
* { scrollbar-width: thin; scrollbar-color: var(--gold-whisper) transparent; }
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gold-whisper); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-quiet); }

input { caret-color: var(--gold); }
::placeholder { color: var(--fg-3); }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  top: var(--s-3); left: var(--s-3);
  z-index: 100;
  transform: translateY(-250%);
  background: var(--gold);
  color: var(--void-deep);
  padding: var(--s-2) var(--s-4);
  font-size: var(--step--1);
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: transform 200ms var(--ease-out);
}
.skip-link:focus { transform: none; }

/* --------------------------------------------------------------- stage -- */

.stage {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 70% 55% at 18% 22%, oklch(38% 0.095 255 / 0.30), transparent 62%),
    radial-gradient(ellipse 60% 50% at 82% 78%, oklch(30% 0.070 275 / 0.26), transparent 60%),
    radial-gradient(ellipse 90% 70% at 50% 50%, oklch(16% 0.020 250 / 0.85), transparent 75%),
    var(--void-deep);
}

#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#map.is-dragging { cursor: grabbing; }
#map.is-over-node { cursor: pointer; }

/* Film grain — the thing that stops a dark page looking flat. */
.grain {
  position: absolute;
  inset: -50%;
  pointer-events: none;
  opacity: 0.16;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)' opacity='0.42'/%3E%3C/svg%3E");
}

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 78% 72% at 50% 48%, transparent 42%, oklch(6% 0.01 250 / 0.72) 100%);
}

/* ---------------------------------------------------------- top chrome -- */

.chrome-top {
  position: fixed;
  z-index: 20;
  top: 0; left: 0; right: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
  padding-top: max(var(--s-4), env(safe-area-inset-top));
  background: linear-gradient(oklch(8% 0.012 250 / 0.94), oklch(8% 0.012 250 / 0.55) 62%, transparent);
  backdrop-filter: blur(3px);
}

.home-link {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  justify-self: start;
  font-size: var(--step--1);
  color: var(--fg-2);
  padding: var(--s-2) var(--s-3);
  margin-left: calc(var(--s-3) * -1);
  border-radius: 2px;
  transition: color 220ms var(--ease-out);
}
.home-link__mark { color: var(--gold-quiet); transition: transform 260ms var(--ease-confident), color 220ms var(--ease-out); }
.home-link:hover { color: var(--gold-bright); }
.home-link:hover .home-link__mark { transform: translateX(-4px); color: var(--gold); }

.wordmark {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  justify-self: center;
}
.wordmark__label {
  font-family: var(--font-display);
  font-size: var(--step-1);
  letter-spacing: 0.02em;
  color: var(--fg);
}
.wordmark__rule {
  width: 2.5rem;
  height: 1px;
  background: linear-gradient(90deg, var(--gold-quiet), var(--gold));
}
.wordmark__count {
  font-size: var(--step--2);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-3);
  white-space: nowrap;
}

.chrome-top__tools {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  justify-self: end;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
}
.search__icon {
  position: absolute;
  left: 0.7rem;
  width: 15px; height: 15px;
  fill: none;
  stroke: var(--fg-4);
  stroke-width: 1.6;
  stroke-linecap: round;
  pointer-events: none;
  transition: stroke 220ms var(--ease-out);
}
.search:focus-within .search__icon { stroke: var(--gold); }

#search-input {
  width: 15rem;
  padding: 0.5rem 2rem 0.5rem 2.1rem;
  font: inherit;
  font-size: var(--step--1);
  color: var(--fg);
  background: oklch(17% 0.016 250 / 0.72);
  border: 1px solid var(--edge);
  border-radius: 2px;
  transition: border-color 220ms var(--ease-out), background 220ms var(--ease-out), width 320ms var(--ease-confident);
}
#search-input:focus {
  outline: none;
  border-color: var(--gold-quiet);
  background: oklch(19% 0.018 250 / 0.92);
}
#search-input::-webkit-search-cancel-button { display: none; }

.search__clear {
  position: absolute;
  right: 0.35rem;
  width: 1.4rem; height: 1.4rem;
  display: grid;
  place-items: center;
  color: var(--fg-3);
  font-size: 1.1rem;
  line-height: 1;
  border-radius: 2px;
  transition: color 200ms var(--ease-out);
}
.search__clear:hover { color: var(--gold); }

.view-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 0.5rem 0.85rem;
  font-size: var(--step--2);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-2);
  border: 1px solid var(--edge);
  border-radius: 2px;
  transition: color 220ms var(--ease-out), border-color 220ms var(--ease-out), background 220ms var(--ease-out);
}
.view-toggle:hover { color: var(--gold-bright); border-color: var(--gold-quiet); }
.view-toggle[aria-pressed="true"] {
  color: var(--void-deep);
  background: var(--gold);
  border-color: var(--gold);
}
.view-toggle__icon {
  width: 12px; height: 10px;
  border-top: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  position: relative;
}
.view-toggle__icon::after {
  content: '';
  position: absolute;
  left: 0; top: 3px;
  width: 100%;
  border-top: 2px solid currentColor;
}

/* ---------------------------------------------------------- breadcrumb -- */

.breadcrumb {
  position: fixed;
  z-index: 15;
  top: 4.6rem;
  top: calc(4.6rem + env(safe-area-inset-top));
  left: var(--s-5);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 var(--s-2);
  max-width: min(38rem, calc(100vw - var(--panel-w) - var(--s-8)));
  font-size: var(--step--2);
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.breadcrumb__item {
  color: var(--fg-3);
  padding: var(--s-1) 0;
  transition: color 200ms var(--ease-out);
}
.breadcrumb__item:hover { color: var(--gold-bright); }
.breadcrumb__item[aria-current] { color: var(--gold); cursor: default; }
.breadcrumb__sep { color: var(--fg-4); }

/* --------------------------------------------------------------- panel -- */

.panel {
  position: fixed;
  z-index: 18;
  top: 0; right: 0;
  width: var(--panel-w);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: linear-gradient(200deg, oklch(15% 0.018 250 / 0.97), oklch(11% 0.014 250 / 0.97));
  border-left: var(--rule);
  backdrop-filter: blur(14px);
  transform: translateX(0);
  transition: transform 460ms var(--ease-confident);
}
.panel[data-collapsed="true"] { transform: translateX(calc(100% - 1.1rem)); }
.panel:focus { outline: none; }

.panel__grip { display: none; }

.panel__scroll {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6.2rem var(--s-6) var(--s-7);
  padding-top: calc(6.2rem + env(safe-area-inset-top));
}

/* --- panel content ------------------------------------------------------ */

.eyebrow {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-size: var(--step--2);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent, var(--gold));
  margin-bottom: var(--s-3);
}
.eyebrow::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, currentColor, transparent);
  opacity: 0.42;
}

.panel-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--step-2);
  line-height: 1.1;
  letter-spacing: 0.005em;
  color: var(--fg);
  margin-bottom: var(--s-3);
  text-wrap: balance;
}

.panel-tagline {
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--step-1);
  line-height: 1.35;
  color: var(--accent, var(--gold));
  margin-bottom: var(--s-4);
}

.panel-blurb {
  color: var(--fg-2);
  font-size: var(--step-0);
  line-height: 1.65;
  max-width: 34ch;
}

.panel-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-4);
  margin-top: var(--s-5);
  padding-top: var(--s-4);
  border-top: var(--rule);
  font-size: var(--step--2);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-3);
}
.panel-meta strong {
  color: var(--accent, var(--gold));
  font-weight: 500;
}

.section-label {
  margin: var(--s-6) 0 var(--s-3);
  font-size: var(--step--2);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--fg-3);
}

/* The list-as-design pattern: rules, not boxes. */
.node-list > li { border-bottom: 1px solid oklch(30% 0.016 250 / 0.7); }
.node-list > li:first-child { border-top: 1px solid oklch(30% 0.016 250 / 0.7); }

.node-link {
  display: grid;
  grid-template-columns: 1.6rem 1fr;
  gap: var(--s-3);
  align-items: baseline;
  width: 100%;
  padding: var(--s-3) 0;
  text-align: left;
  transition: padding-left 300ms var(--ease-confident);
}
.node-link:hover { padding-left: var(--s-2); }

.node-link__index {
  font-family: var(--font-display);
  font-size: var(--step--1);
  color: var(--fg-4);
  font-variant-numeric: tabular-nums;
  transition: color 220ms var(--ease-out);
}
.node-link:hover .node-link__index { color: var(--accent, var(--gold)); }

.node-link__title {
  display: block;
  font-size: var(--step-0);
  color: var(--fg);
  line-height: 1.4;
  transition: color 220ms var(--ease-out);
}
.node-link:hover .node-link__title { color: var(--gold-bright); }

.node-link__count {
  display: block;
  font-size: var(--step--2);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-4);
  margin-top: 3px;
}

.node-link__blurb {
  font-size: var(--step--1);
  color: var(--fg-3);
  line-height: 1.5;
  margin-top: var(--s-1);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- the article card --------------------------------------------------- */

.summary-box {
  margin: var(--s-5) 0;
  padding: var(--s-4) var(--s-5);
  background: oklch(20% 0.020 250 / 0.66);
  border-left: 2px solid var(--accent, var(--gold));
}
.summary-box__label {
  font-size: var(--step--2);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent, var(--gold));
  margin-bottom: var(--s-2);
}
.summary-box p {
  color: var(--fg-2);
  font-size: var(--step-0);
  line-height: 1.65;
}
.summary-box__none {
  color: var(--fg-4);
  font-style: italic;
}

.read-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  margin-top: var(--s-4);
  padding: 0.8rem 1.4rem;
  background: var(--gold);
  color: var(--void-deep);
  font-size: var(--step--1);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: 2px;
  transition: background 240ms var(--ease-out), gap 300ms var(--ease-confident);
}
.read-cta:hover { background: var(--gold-bright); gap: var(--s-4); }

.ghost-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  margin-top: var(--s-4);
  padding: 0.7rem 1.2rem;
  font-size: var(--step--2);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-2);
  border: 1px solid var(--edge);
  border-radius: 2px;
  transition: color 220ms var(--ease-out), border-color 220ms var(--ease-out);
}
.ghost-cta:hover { color: var(--gold-bright); border-color: var(--gold-quiet); }

.article-date {
  margin-top: var(--s-5);
  font-size: var(--step--2);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-4);
}

.empty-note {
  color: var(--fg-3);
  font-style: italic;
  font-size: var(--step--1);
  padding: var(--s-4) 0;
}

/* --------------------------------------------------------------- hint --- */

.hint {
  position: fixed;
  z-index: 12;
  bottom: var(--s-5);
  bottom: max(var(--s-5), env(safe-area-inset-bottom));
  left: var(--s-5);
  max-width: 36rem;
  font-size: var(--step--2);
  letter-spacing: 0.1em;
  color: var(--fg-4);
  pointer-events: none;
  transition: opacity 700ms var(--ease-out);
}
.hint[data-faded="true"] { opacity: 0; }
.hint kbd {
  font: inherit;
  border: 1px solid var(--edge);
  border-radius: 2px;
  padding: 1px 5px;
}
.hint__touch { display: none; }

/* ----------------------------------------------------------- list view -- */

/* The list is a full replacement for the map, not an overlay on top of it. */
html[data-list="open"] .panel,
html[data-list="open"] .breadcrumb,
html[data-list="open"] .hint { display: none; }

.listview {
  position: fixed;
  inset: 0;
  z-index: 16;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 7.5rem var(--s-6) var(--s-8);
  padding-top: calc(7.5rem + env(safe-area-inset-top));
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%, oklch(38% 0.095 255 / 0.22), transparent 60%),
    var(--void-deep);
}

.listview__inner {
  max-width: 62rem;
  margin: 0 auto;
}

.listview__pillar { margin-bottom: var(--s-8); }

.listview__pillar-head {
  display: flex;
  align-items: baseline;
  gap: var(--s-4);
  padding-bottom: var(--s-3);
  border-bottom: 1px solid var(--accent, var(--gold));
  margin-bottom: var(--s-5);
}
.listview__pillar-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--step-2);
  color: var(--fg);
}
.listview__pillar-count {
  font-size: var(--step--2);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent, var(--gold));
  margin-left: auto;
  white-space: nowrap;
}

.listview__chapter { margin-bottom: var(--s-6); }

.listview__chapter-title {
  font-size: var(--step-0);
  font-weight: 500;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--accent, var(--gold));
  margin-bottom: var(--s-1);
}
.listview__chapter-blurb {
  font-size: var(--step--1);
  color: var(--fg-3);
  line-height: 1.6;
  max-width: 68ch;
  margin-bottom: var(--s-3);
}

.listview__articles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr));
  gap: 0 var(--s-6);
}
.listview__articles > li { border-top: 1px solid oklch(28% 0.016 250 / 0.8); }

.listview__article {
  display: block;
  padding: var(--s-3) 0;
  transition: padding-left 300ms var(--ease-confident);
}
.listview__article:hover { padding-left: var(--s-2); }
.listview__article-title {
  font-size: var(--step-0);
  color: var(--fg);
  line-height: 1.4;
  transition: color 220ms var(--ease-out);
}
.listview__article:hover .listview__article-title { color: var(--gold-bright); }
.listview__article-excerpt {
  font-size: var(--step--1);
  color: var(--fg-3);
  line-height: 1.5;
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.listview__empty {
  padding: var(--s-8) 0;
  text-align: center;
  color: var(--fg-3);
  font-style: italic;
}

/* --------------------------------------------- static / noscript index -- */

.static-index,
.noscript-note {
  position: relative;
  z-index: 5;
  max-width: 62rem;
  margin: 0 auto;
  padding: var(--s-6) var(--s-5) var(--s-8);
}
.noscript-note p {
  padding: var(--s-4);
  border-left: 2px solid var(--gold);
  background: var(--ink);
  color: var(--fg-2);
}
.static-index h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--step-2);
  margin: var(--s-7) 0 var(--s-2);
  padding-bottom: var(--s-2);
  border-bottom: 1px solid var(--gold-quiet);
}
.static-index h3 {
  font-size: var(--step-0);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  margin: var(--s-5) 0 var(--s-2);
}
.static-index li { padding: var(--s-1) 0; }
.static-index a { color: var(--fg-2); border-bottom: 1px solid transparent; }
.static-index a:hover { color: var(--gold-bright); border-bottom-color: var(--gold-quiet); }

/* ---------------------------------------------------- touch ergonomics -- */

/* On a touch device every control gets a 44px hit area. The visual size is
   unchanged — the target grows via padding and a pseudo-element, so the
   design does not get heavier just because the finger needs more room. */
@media (pointer: coarse), (max-width: 900px) {
  .home-link,
  .view-toggle,
  .breadcrumb__item,
  .read-cta,
  .ghost-cta { position: relative; min-height: 44px; }

  .home-link,
  .view-toggle,
  /* Without this the text sits at the top of its 44px box while the "/"
     separators centre, and the trail reads as two crooked lines. */
  .breadcrumb__item { display: inline-flex; align-items: center; }

  /* Stays absolutely positioned inside the field — it just gets bigger, so
     the field needs matching room or the text runs under it. */
  .search__clear { width: 2.75rem; height: 2.75rem; right: 0.1rem; }
  #search-input { padding-right: 2.9rem; }

  .breadcrumb__item::after {
    content: '';
    position: absolute;
    inset: -11px -6px;
  }
}

/* ============================== responsive =============================== */

@media (max-width: 1180px) {
  :root { --panel-w: 23rem; }
  #search-input { width: 11rem; }
}

@media (max-width: 900px) {
  .chrome-top {
    grid-template-columns: auto 1fr;
    grid-template-areas: 'home tools' 'mark mark';
    gap: var(--s-2) var(--s-3);
    padding: var(--s-3) var(--s-4);
    padding-top: max(var(--s-3), env(safe-area-inset-top));
  }
  .home-link { grid-area: home; }
  .chrome-top__tools { grid-area: tools; }
  .wordmark { grid-area: mark; justify-self: start; }
  .wordmark__rule { width: 1.75rem; }

  #search-input { width: 100%; min-width: 0; }
  .search { flex: 1; }
  .view-toggle__text { display: none; }
  .view-toggle { padding: 0.55rem 0.7rem; }

  /* On a phone the map has little room, so the chrome moves out of it:
     breadcrumb to the top under the header, hint to a single quiet line
     resting just above the sheet. */
  .breadcrumb {
    top: 6.7rem;
    top: calc(6.7rem + env(safe-area-inset-top));
    left: var(--s-4);
    right: var(--s-4);
    max-width: none;
    flex-wrap: nowrap;
    white-space: nowrap;
  }
  .breadcrumb__item {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 11rem;
  }

  .hint__desktop { display: none; }
  .hint__touch { display: inline; }
  .hint {
    left: 0;
    right: 0;
    bottom: calc(46svh + var(--s-2));
    max-width: none;
    padding: var(--s-2) var(--s-4);
    text-align: center;
    background: linear-gradient(transparent, oklch(8% 0.012 250 / 0.72));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* The panel becomes a bottom sheet. */
  .panel {
    top: auto;
    bottom: 0;
    left: 0; right: 0;
    width: auto;
    height: 46svh;
    border-left: 0;
    border-top: var(--rule);
    border-radius: 6px 6px 0 0;
    transform: none;
    transition: height 420ms var(--ease-confident);
  }
  .panel[data-collapsed="true"] { height: 3.4rem; }

  .panel__grip {
    display: grid;
    place-items: center;
    width: 100%;
    height: 3.4rem;
    flex: 0 0 auto;
  }
  .panel__grip-bar {
    width: 2.75rem;
    height: 3px;
    border-radius: 2px;
    background: var(--gold-quiet);
    transition: background 220ms var(--ease-out), width 300ms var(--ease-confident);
  }
  .panel__grip:hover .panel__grip-bar { background: var(--gold); width: 3.5rem; }

  .panel__scroll {
    padding: 0 var(--s-5) var(--s-6);
    padding-bottom: max(var(--s-6), env(safe-area-inset-bottom));
  }

  .listview { padding: 9rem var(--s-4) var(--s-7); }
  .listview__articles { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .wordmark__count,
  .wordmark__rule { display: none; }   /* a rule leading nowhere reads as a bug */
  .panel-blurb { max-width: none; }
  .breadcrumb__item { max-width: 8rem; }
}

/* ============================== motion =================================== */

@media (prefers-reduced-motion: no-preference) {
  .panel__scroll > * {
    animation: riseIn 520ms var(--ease-confident) both;
  }
  .panel__scroll > *:nth-child(2) { animation-delay: 60ms; }
  .panel__scroll > *:nth-child(3) { animation-delay: 120ms; }
  .panel__scroll > *:nth-child(4) { animation-delay: 180ms; }
  .panel__scroll > *:nth-child(n+5) { animation-delay: 240ms; }
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(14px); filter: blur(5px); }
  to   { opacity: 1; transform: none; filter: blur(0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  /* The grain stays. It is a static texture, not movement — reduced motion is
     about things that move, and removing it would only flatten the page. */
}


/* ============================================================================
   THE LIBRARY — "The Reading Room" (variant A from the claude.ai round-trip),
   integrated as the default mode. The dark map above is untouched; one mode is
   on screen at a time, and the variant's tokens are scoped to library mode so
   they can never collide with the dark tokens of the same names.
   ========================================================================= */

/* one mode on screen at a time */
html[data-mode="library"] .stage,
html[data-mode="library"] .chrome-top,
html[data-mode="library"] .breadcrumb,
html[data-mode="library"] .panel,
html[data-mode="library"] .hint { display: none; }
html[data-mode="map"] #qa-root { display: none; }

/* The map locks the page to the viewport; the library is a document. */
html[data-mode="library"],
html[data-mode="library"] body {
  height: auto;
  min-height: 100%;
  overflow: visible;
  overscroll-behavior: auto;
}


/* ============================================================================
   VARIANT A — "The Reading Room"
   Paper and ink as the original, but opened up: a centred, generous hero with
   the real brand mark, and a sticky ribbon of section chips so the five
   shelves are always one tap away — the exploration aid the long page needed.
   ========================================================================= */
html[data-mode="library"] {
  --paper: #FFFFFF;  --paper-2: #F5F4F0;  --card: #FFFFFF;
  --band: #14181D;   --band-fg: #F2EFE7;
  --ink: #141B24;    --ink2: #46515F;     --ink3: #5F6975;
  --rule: #E2DFD8;   --rule-soft: #EEECE6;
  --gold: #96681C;   --gold-deep: #7A5416;
  --shadow: 0 1px 2px rgba(20,27,36,.05), 0 10px 30px rgba(20,27,36,.07);
  --serif: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
  --sans: 'Inter Tight', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --ease: cubic-bezier(.2,.8,.2,1);
}
html[data-mode="library"] { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html[data-mode="library"] { scroll-behavior: auto; } }
html[data-mode="library"] body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* paper tooth */
html[data-mode="library"] body::before {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .3;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='190' height='190'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='190' height='190' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
}
html[data-mode="library"] a { color: var(--ink); text-decoration: none; }
html[data-mode="library"] a:hover { color: var(--gold-deep); }
img { max-width: 100%; height: auto; }
html[data-mode="library"] ::selection { background: var(--gold-deep); color: var(--paper); }
html[data-mode="library"] :focus-visible { outline: 2px solid var(--gold-deep); outline-offset: 3px; border-radius: 2px; }
html[data-mode="library"] input { caret-color: var(--gold-deep); }
html[data-mode="library"] ::placeholder { color: var(--ink3); }
.vh { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.qa-skip {
  position: absolute; top: .75rem; left: .75rem; z-index: 100;
  transform: translateY(-250%);
  background: var(--gold-deep); color: var(--paper);
  padding: .5rem 1rem; font-size: .85rem; font-weight: 500; letter-spacing: .02em;
  transition: transform 200ms var(--ease);
}
.qa-skip:focus { transform: none; color: var(--paper); }

/* ------------------------------------------------------------- masthead -- */
.mast {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  max-width: 68rem; margin: 0 auto;
  padding: .9rem clamp(1.1rem, 4vw, 2.4rem);
  padding-top: max(.9rem, env(safe-area-inset-top));
  border-bottom: 1px solid var(--rule);
}
.mast__home {
  display: inline-flex; align-items: center; gap: .7rem; min-height: 44px;
  font-family: var(--serif); font-size: 1.15rem; letter-spacing: .01em;
}
.mast__home img { width: 34px; height: 34px; }
.mast__back {
  display: inline-flex; align-items: center; gap: .4rem; min-height: 44px;
  font-size: .72rem; font-weight: 500; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink2);
}
.mast__back:hover { color: var(--gold-deep); }

/* ----------------------------------------------------------------- hero -- */
.hero {
  position: relative; z-index: 1;
  max-width: 46rem; margin: 0 auto;
  padding: clamp(2.4rem, 7vh, 4.5rem) clamp(1.1rem, 4vw, 2rem) clamp(1.8rem, 4vh, 2.6rem);
  text-align: center;
}
.hero__mark { width: clamp(64px, 12vw, 84px); height: auto; margin: 0 auto 1.1rem; display: block; }
.hero__kicker {
  font-size: .7rem; font-weight: 600; letter-spacing: .24em; text-transform: uppercase;
  color: var(--gold-deep); margin-bottom: .8rem;
}
.hero__title {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(2.2rem, 6vw, 3.4rem); line-height: 1.03; letter-spacing: -.005em;
  text-wrap: balance; margin-bottom: .8rem;
}
.hero__sub { color: var(--ink2); font-size: 1.02rem; line-height: 1.65; max-width: 46ch; margin: 0 auto 1.5rem; text-wrap: pretty; }
.qa-search { position: relative; display: flex; align-items: center; max-width: 28rem; margin: 0 auto; }
.qa-search__ic {
  position: absolute; left: .9rem; width: 16px; height: 16px;
  fill: none; stroke: var(--ink3); stroke-width: 1.7; stroke-linecap: round; pointer-events: none;
}
.qa-search:focus-within .qa-search__ic { stroke: var(--gold-deep); }
.qa-search-in {
  width: 100%; min-height: 50px;
  padding: .7rem 3rem .7rem 2.6rem;
  font: inherit; font-size: .98rem; color: var(--ink);
  background: var(--card); border: 1px solid var(--rule); border-radius: 999px;
  box-shadow: var(--shadow);
  transition: border-color 200ms var(--ease);
}
.qa-search-in:focus { outline: none; border-color: var(--gold); }
.qa-search-in::-webkit-search-cancel-button { display: none; }
.qa-search-x {
  position: absolute; right: .3rem; width: 44px; height: 44px;
  display: grid; place-items: center;
  color: var(--ink3); font-size: 1.25rem; border-radius: 999px;
  transition: color 180ms var(--ease);
}
.qa-search-x[hidden] { display: none; }
.qa-search-x:hover { color: var(--gold-deep); }
.hero__meta { margin-top: 1rem; font-size: .7rem; letter-spacing: .15em; text-transform: uppercase; color: var(--ink3); }
.hero__meta b { color: var(--gold-deep); font-weight: 600; }

/* --------------------------------------------------- sticky section chips -- */
.chips {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--rule-soft);
  border-bottom: 1px solid var(--rule);
}
#qa-nav {
  display: flex; gap: .4rem;
  max-width: 68rem; margin: 0 auto;
  padding: .45rem clamp(1.1rem, 4vw, 2.4rem);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
#qa-nav::-webkit-scrollbar { display: none; }
.qa-nav__item {
  display: inline-flex; align-items: center; gap: .5rem;
  flex: 0 0 auto; min-height: 44px;
  padding: .4rem .95rem;
  font-size: .8rem; font-weight: 500; color: var(--ink2);
  border: 1px solid transparent; border-radius: 999px;
  transition: color 180ms var(--ease), border-color 180ms var(--ease), background 180ms var(--ease);
}
.qa-nav__item:hover { color: var(--ink); background: rgba(20,27,36,.045); }
.qa-nav__item.on { color: var(--ink); border-color: var(--hue); background: color-mix(in srgb, var(--hue) 8%, transparent); }
.qa-nav__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--hue); flex: 0 0 auto; }
.qa-nav__body { display: inline-flex; align-items: baseline; gap: .45rem; white-space: nowrap; }
.qa-nav__tag { display: none; }
.qa-nav__count { display: none; }

/* --------------------------------------------------------------- library -- */
.qa-wrap {
  position: relative; z-index: 1;
  max-width: 68rem; margin: 0 auto;
  padding: 0 clamp(1.1rem, 4vw, 2.4rem) 4rem;
}
#qa-main { outline: none; }
.qa-sec { padding-top: 2.6rem; margin-top: 1.4rem; }
.qa-sec + .qa-sec { border-top: 1px solid var(--rule); }
.qa-sec__num { display: none; }
.qa-sec__head { display: flex; align-items: baseline; flex-wrap: wrap; gap: .35rem .9rem; }
.qa-sec__bullet { width: 12px; height: 12px; border-radius: 50%; background: var(--hue); align-self: center; flex: 0 0 auto; }
.qa-sec__title {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(1.65rem, 3.4vw, 2.1rem); line-height: 1.08;
}
.qa-sec__tag { font-family: var(--serif); font-style: italic; font-size: 1.02rem; color: var(--hue); }
.qa-sec__count { margin-left: auto; font-size: .66rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink3); white-space: nowrap; }
.qa-sec__blurb { margin-top: .6rem; max-width: 64ch; color: var(--ink2); font-size: .94rem; line-height: 1.62; text-wrap: pretty; }

.qa-sec__chapters {
  margin-top: 1.2rem;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr));
  gap: 0 2.4rem; align-items: start;
}
.qa-ch.open { grid-column: 1 / -1; }
.qa-ch { border-top: 1px solid var(--rule-soft); }
.qa-ch__h { margin: 0; font-size: inherit; font-weight: inherit; }
.qa-ch__head {
  display: flex; align-items: center; gap: .6rem;
  width: 100%; min-height: 48px; padding: .5rem .3rem;
  border-radius: 4px; text-align: left;
  transition: background 180ms var(--ease);
}
.qa-ch__head:hover { background: rgba(20,27,36,.035); }
.qa-ch__num { display: none; }
.qa-ch__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--hue); flex: 0 0 auto; }
.qa-ch__name { font-size: .97rem; font-weight: 500; }
.qa-ch__head:hover .qa-ch__name { color: var(--hue); }
.qa-ch__count { margin-left: auto; font-size: .72rem; color: var(--ink3); font-variant-numeric: tabular-nums; }
.qa-ch__chev {
  width: 7px; height: 7px;
  border-right: 1.6px solid var(--ink3); border-bottom: 1.6px solid var(--ink3);
  transform: rotate(-45deg); flex: 0 0 auto;
  transition: transform 240ms var(--ease);
}
.qa-ch.open .qa-ch__chev { transform: rotate(45deg); border-color: var(--hue); }
.qa-ch__blurb { display: none; margin: .1rem 0 .4rem 1.3rem; max-width: 66ch; color: var(--ink2); font-size: .88rem; line-height: 1.55; }
.qa-ch.open .qa-ch__blurb { display: block; }
.qa-ch__body { overflow: hidden; max-height: 0; transition: max-height 360ms var(--ease); }
.qa-ch__list {
  margin: .3rem 0 1rem .5rem; padding: 0 0 0 1.1rem;
  border-left: 2px solid color-mix(in srgb, var(--hue) 38%, transparent);
}

.qa-q__link {
  display: flex; min-height: 44px; align-items: baseline; gap: .6rem;
  padding: .45rem .5rem .45rem .3rem; border-radius: 4px;
  transition: background 160ms var(--ease);
}
.qa-q__link:hover { background: rgba(20,27,36,.035); }
.qa-q__dot { width: 6px; height: 6px; border-radius: 50%; background: color-mix(in srgb, var(--hue) 65%, transparent); flex: 0 0 auto; align-self: center; }
.qa-q__text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.qa-q__title { font-size: .95rem; line-height: 1.4; }
.qa-q__link:hover .qa-q__title { color: var(--hue); }
.qa-q__excerpt {
  font-size: .83rem; color: var(--ink3); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
.qa-q.sel .qa-q__title { font-weight: 500; }
.qa-q.sel .qa-q__dot { background: var(--gold); box-shadow: 0 0 0 3px rgba(150,104,28,.22); }
.qa-q.sel .qa-q__excerpt { display: none; }

/* ----------------------------------------------------------- answer card -- */
.qa-card {
  margin: .35rem 0 .9rem .5rem;
  padding: 1.05rem 1.2rem 1.15rem;
  background: var(--card); border: 1px solid var(--rule); border-radius: 6px;
  box-shadow: var(--shadow); max-width: 44rem;
}
@media (prefers-reduced-motion: no-preference) {
  .qa-card { animation: qaCardIn 320ms var(--ease) both; }
  @keyframes qaCardIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: none; } }
}
.qa-card__bubble {
  padding: .75rem .95rem .85rem;
  background: rgba(150,104,28,.07);
  border-left: 3px solid var(--gold);
  border-radius: 0 6px 6px 6px;
}
.qa-card__label { font-size: .62rem; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: var(--gold-deep); margin-bottom: .3rem; }
.qa-card__text { font-size: .93rem; line-height: 1.62; }
.qa-card__text--none { color: var(--ink3); font-style: italic; }
.qa-card__actions { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem 1rem; margin-top: .85rem; }
.qa-card__read {
  display: inline-flex; align-items: center; gap: .35rem; min-height: 44px;
  padding: .6rem 1.2rem; background: var(--gold-deep); color: var(--paper);
  font-size: .7rem; font-weight: 600; letter-spacing: .13em; text-transform: uppercase;
  border-radius: 999px;
  transition: background 200ms var(--ease);
}
.qa-card__read:hover { background: #63430F; color: var(--paper); }
.qa-card__date { font-size: .66rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink3); }
.qa-card__rel-label { margin: 1rem 0 .15rem; font-size: .62rem; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: var(--ink3); }
.qa-card__rel {
  display: flex; align-items: baseline; gap: .6rem; min-height: 44px;
  padding: .45rem .25rem; border-top: 1px solid var(--rule-soft); border-radius: 3px;
  transition: background 160ms var(--ease);
}
.qa-card__rel:hover { background: rgba(20,27,36,.035); }
.qa-card__rel-dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; align-self: center; }
.qa-card__rel-text { display: flex; flex-direction: column; min-width: 0; }
.qa-card__rel-title { font-size: .88rem; line-height: 1.35; }
.qa-card__rel:hover .qa-card__rel-title { color: var(--gold-deep); }
.qa-card__rel-sec { font-size: .6rem; font-weight: 600; letter-spacing: .13em; text-transform: uppercase; }

/* ------------------------------------------------------- empty + footer -- */
.qa-empty {
  margin: 2.4rem 0 0; padding: 1.2rem 1.3rem;
  border: 1px dashed var(--rule); border-radius: 6px;
  color: var(--ink2); font-size: .95rem;
}
.qa-foot {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .6rem 1.5rem;
  max-width: 68rem; margin: 0 auto;
  padding: 1.2rem clamp(1.1rem, 4vw, 2.4rem) 2.4rem;
  padding-bottom: max(2.4rem, env(safe-area-inset-bottom));
  border-top: 1px solid var(--rule);
  font-size: .7rem; letter-spacing: .13em; text-transform: uppercase; color: var(--ink3);
}
.qa-foot__brand { display: inline-flex; align-items: center; gap: .55rem; min-height: 44px; color: var(--ink2); }
.qa-foot__brand img { width: 22px; height: 22px; }
.qa-foot__brand:hover { color: var(--gold-deep); }
#qa-sections.searching .qa-sec__blurb,
#qa-sections.searching .qa-ch__blurb { display: none; }

/* --------------------------------------------------------------- mobile -- */
@media (max-width: 700px) {
  .qa-sec__chapters { grid-template-columns: 1fr; gap: 0; }
  .qa-sec__count { margin-left: 0; flex-basis: 100%; }
  .qa-card { margin-left: .1rem; }
  .qa-ch__list { margin-left: .2rem; padding-left: .85rem; }
  .mast__back span { display: none; }
  .hero { text-align: left; }
  .hero__mark { margin: 0 0 1rem; }
  .hero__sub { margin: 0 0 1.4rem; }
  .qa-search { margin: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}


/* ----------------------------------------------- integration additions -- */

/* The brand mark, drawn inline — one SVG instead of three embedded PNGs. */
.mast__mark { width: 30px; height: 22px; color: var(--ink); flex: 0 0 auto; }
.hero__mark { width: clamp(72px, 12vw, 96px); height: auto; margin: 0 auto 1.1rem; display: block; color: var(--ink); }
.qa-foot__mark { width: 26px; height: 19px; color: currentColor; flex: 0 0 auto; }
.mast__mark text, .hero__mark text, .qa-foot__mark text { font-family: var(--serif); }
@media (max-width: 700px) { .hero__mark { margin: 0 0 1rem; } }

/* The doorway to the dark map, sitting beside the back-link. */
.mast__nav { display: inline-flex; align-items: center; gap: 1.1rem; }
.mast__map {
  display: inline-flex; align-items: center; gap: .45rem; min-height: 44px;
  padding: .4rem .9rem;
  font-size: .72rem; font-weight: 500; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink2);
  border: 1px solid var(--rule); border-radius: 999px;
  transition: color 180ms var(--ease), border-color 180ms var(--ease);
}
.mast__map:hover { color: var(--gold-deep); border-color: var(--gold-deep); }
.mast__map-icon {
  position: relative; width: 12px; height: 12px;
  border: 1px solid currentColor; border-radius: 50%;
}
.mast__map-icon::before {
  content: ''; position: absolute; top: 50%; left: 50%;
  width: 4px; height: 4px; transform: translate(-50%, -50%);
  border-radius: 50%; background: currentColor;
}
@media (max-width: 700px) { .mast__map > span:last-child { display: none; } .mast__map { padding: .4rem .6rem; } }

/* If boot fails with the library attribute present — or scripts are off —
   the static index must read as ink on paper. */
html[data-mode="library"] .static-index { color: var(--ink); }
html[data-mode="library"] .static-index h2 { color: var(--ink); border-bottom-color: var(--rule); }
html[data-mode="library"] .static-index h3 { color: var(--gold-deep); }
html[data-mode="library"] .static-index a { color: var(--ink2); }
html[data-mode="library"] .static-index a:hover { color: var(--gold-deep); border-bottom-color: var(--gold-deep); }
html[data-mode="library"] .noscript-note p {
  background: var(--card); border-left-color: var(--gold-deep); color: var(--ink2);
}

/* Library chrome that only works with scripts is hidden without them. */
html:not(.js) #qa-root .qa-search,
html:not(.js) #qa-root .chips,
html:not(.js) #qa-root .mast__map,
html:not(.js) #qa-root .hero__meta,
html:not(.js) #qa-root .qa-foot { display: none; }
