/* ==========================================================================
   Babdah Directorate — shared stylesheet
   One file, no build step. Design tokens as CSS custom properties.

   Theme logic (brief §4): DARK = Babdah / institutional identity.
                           PAPER = intelligence product / analysis.
   Every section sets a theme class; components read semantic tokens
   (--surface, --text, --accent, ...) so they work on either ground.

   Naming: BEM (block, block__element, block--modifier).
   Contrast (WCAG 2.2 AA) verified for each semantic pair — see notes.
   ========================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
  /* Raw palette */
  --c-ink-950: #0f1113;   /* near-black */
  --c-ink-900: #15181b;
  --c-ink-850: #1a1e22;   /* charcoal */
  --c-ink-700: #2c3238;
  --c-slate-600: #4b545c; /* gunmetal */
  --c-slate-300: #aab0b5;
  --c-paper-50: #f4f0e8;  /* warm off-white */
  --c-paper-100: #ebe5d9;
  --c-paper-300: #c9bfae;
  --c-paper-ink: #16191c;
  --c-brass-300: #c9ab72; /* single restrained accent (dark grounds) */
  --c-brass-700: #6f5424; /* same accent, deepened for paper grounds */

  /* Type */
  --font-serif: "Source Serif 4", "Iowan Old Style", Charter, Georgia, "Times New Roman", serif;
  --font-sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --fs-xs: 0.8125rem;   /* 13px labels / metadata */
  --fs-sm: 0.9375rem;   /* 15px */
  --fs-base: 1.0625rem; /* 17px body */
  --fs-md: 1.25rem;
  --fs-lg: clamp(1.375rem, 1.1rem + 1vw, 1.625rem);
  --fs-xl: clamp(1.75rem, 1.3rem + 1.8vw, 2.375rem);
  --fs-2xl: clamp(2.125rem, 1.4rem + 3vw, 3.25rem);
  --fs-hero: clamp(2.5rem, 1.35rem + 4.8vw, 4.5rem);

  --lh-tight: 1.12;
  --lh-snug: 1.3;
  --lh-body: 1.65;
  --measure: 66ch;

  /* Space (4/8 base) */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;
  --sp-7: 3rem;
  --sp-8: 4rem;
  --section-pad: clamp(4rem, 3rem + 5vw, 7rem);
  --gutter: clamp(1.25rem, 0.8rem + 2.4vw, 2.5rem);
  --container: 74rem;

  --radius: 2px;
  --ease: cubic-bezier(0.2, 0.6, 0.2, 1);
  --dur: 180ms;
}

/* Semantic themes. Contrast notes are text-on-surface ratios. */
.theme-dark {
  --surface: var(--c-ink-950);
  --surface-raised: var(--c-ink-850);
  --text: #ece7dd;          /* 15.6:1 */
  --text-muted: var(--c-slate-300); /* 8.4:1 */
  --rule: #3a4147;          /* decorative only */
  --rule-strong: #6b747c;   /* 3.9:1 — UI boundaries */
  --accent: var(--c-brass-300); /* 8.6:1 */
  --accent-contrast: var(--c-ink-950);
  --focus: var(--c-brass-300);
  --topo-color: rgb(236 231 221 / 0.07);
  color-scheme: dark;
}
.theme-charcoal {
  --surface: var(--c-ink-850);
  --surface-raised: #22272c;
  --text: #ece7dd;          /* 14.2:1 */
  --text-muted: #b1b7bc;    /* 8.3:1 */
  --rule: #3c434a;
  --rule-strong: #737c84;   /* 3.8:1 */
  --accent: var(--c-brass-300); /* 7.9:1 */
  --accent-contrast: var(--c-ink-950);
  --focus: var(--c-brass-300);
  --topo-color: rgb(236 231 221 / 0.06);
  color-scheme: dark;
}
.theme-paper {
  --surface: var(--c-paper-50);
  --surface-raised: #fbf9f4;
  --text: var(--c-paper-ink); /* 15.9:1 */
  --text-muted: #4f565c;      /* 6.6:1 */
  --rule: var(--c-paper-300); /* decorative only */
  --rule-strong: #7a7166;     /* 4.2:1 — form borders, card edges */
  --accent: var(--c-brass-700); /* 6.2:1 */
  --accent-contrast: var(--c-paper-50);
  --focus: var(--c-brass-700);
  --topo-color: rgb(22 25 28 / 0.07);
  color-scheme: light;
}
.theme-paper-deep {
  --surface: var(--c-paper-100);
  --surface-raised: var(--c-paper-50);
  --text: var(--c-paper-ink); /* 14.2:1 */
  --text-muted: #4a5157;      /* 6.4:1 */
  --rule: #c2b7a4;
  --rule-strong: #756c61;     /* 4.0:1 */
  --accent: #684f21;          /* 6.1:1 */
  --accent-contrast: var(--c-paper-50);
  --focus: #684f21;
  --topo-color: rgb(22 25 28 / 0.08);
  color-scheme: light;
}

/* ---------- 2. Base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  background: var(--c-ink-950);
  color: #ece7dd;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; height: auto; display: block; }

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: var(--lh-tight);
  margin: 0 0 var(--sp-4);
  text-wrap: balance;
  font-optical-sizing: auto;
}
h3 { line-height: var(--lh-snug); }

p { margin: 0 0 var(--sp-4); text-wrap: pretty; }
p:last-child { margin-bottom: 0; }

a {
  color: var(--text);
  text-decoration-line: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: text-decoration-thickness var(--dur) var(--ease), color var(--dur) var(--ease);
}
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 2px solid var(--focus, var(--c-brass-300));
  outline-offset: 3px;
  border-radius: var(--radius);
}

strong { font-weight: 600; }

ul, ol { padding-left: 1.25em; margin: 0 0 var(--sp-4); }
li + li { margin-top: var(--sp-2); }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* Skip link: first focusable element on every page */
.skip-link {
  position: absolute;
  left: var(--sp-4);
  top: -100px;
  z-index: 100;
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-brass-300);
  color: var(--c-ink-950);
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius);
}
.skip-link:focus { top: var(--sp-4); outline-color: #ece7dd; }

/* ---------- 3. Layout ---------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container--narrow > * { max-width: 50rem; }

.section {
  position: relative;
  background: var(--surface);
  color: var(--text);
  padding-block: var(--section-pad);
  overflow: hidden;
  isolation: isolate;
}
.section--tight { padding-block: clamp(3rem, 2.4rem + 3vw, 4.5rem); }
.section--flush-top { padding-top: 0; }

/* Section heading group */
.eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 var(--sp-4);
}
.section-heading {
  font-size: var(--fs-2xl);
  text-transform: uppercase;
  letter-spacing: 0.015em;
  max-width: 22ch;
}
.section-heading--wide { max-width: none; }
.lede {
  font-size: var(--fs-md);
  line-height: 1.55;
  color: var(--text-muted);
  max-width: var(--measure);
}
.section-intro { margin-bottom: var(--sp-7); }

.prose { max-width: var(--measure); }
.prose h2 {
  font-size: var(--fs-xl);
  margin-top: var(--sp-7);
}
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-size: var(--fs-lg); margin-top: var(--sp-6); }
.prose ul li::marker { color: var(--accent); }

/* Horizontal document rule */
.rule {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: var(--sp-7) 0;
}

/* ---------- 4. Topographic contour layer (decorative) ---------- */
.topo::before {
  content: "";
  position: absolute;
  inset: -4%;
  z-index: -1;
  background-color: var(--topo-color);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: cover;
  mask-size: cover;
  -webkit-mask-position: center;
  mask-position: center;
  pointer-events: none;
}
.topo--sparse::before {
  -webkit-mask-image: url("../img/topo-sparse.svg");
  mask-image: url("../img/topo-sparse.svg");
}
.topo--field::before {
  -webkit-mask-image: url("../img/topo-field.svg");
  mask-image: url("../img/topo-field.svg");
}
@media (prefers-reduced-motion: no-preference) {
  .topo--drift::before {
    animation: topo-drift 80s var(--ease) infinite alternate;
  }
}
@keyframes topo-drift {
  from { transform: translate3d(0, 0, 0) scale(1.02); }
  to   { transform: translate3d(-2.5%, -1.5%, 0) scale(1.06); }
}

/* ---------- 5. Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 48px;
  padding: var(--sp-3) var(--sp-5);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  text-align: center;
  line-height: 1.25;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease),
    border-color var(--dur) var(--ease);
}
.btn--primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}
.btn--primary:hover {
  background: transparent;
  color: var(--text);
}
.btn--secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--rule-strong);
}
.btn--secondary:hover { border-color: var(--text); }
.btn--small {
  min-height: 40px;
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--fs-xs);
}
.btn__arrow { transition: transform var(--dur) var(--ease); }
.btn:hover .btn__arrow { transform: translateX(3px); }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  margin-top: var(--sp-6);
}

/* Text link with arrow (secondary navigation within content) */
.text-link {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid var(--accent);
  padding-block: var(--sp-1);
}
.text-link:hover { border-bottom-width: 2px; }

/* ---------- 6. Site header & navigation ---------- */
.site-header {
  --surface: var(--c-ink-950);
  background: var(--c-ink-950);
  border-bottom: 1px solid #262b30;
  position: relative;
  z-index: 10;
}
.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-5);
  min-height: 76px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  color: var(--text);
  text-decoration: none;
  padding-block: var(--sp-2);
}
.brand__mark { width: 34px; height: auto; }
.brand__name {
  font-family: var(--font-serif);
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  line-height: 1.1;
}

.nav { display: flex; align-items: center; }
.nav__toggle { display: none; }
.nav__panel {
  display: flex;
  align-items: center;
  gap: var(--sp-6);
}
.nav__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-5);
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav__list li + li { margin-top: 0; }
.nav__link {
  display: inline-block;
  padding: var(--sp-2) 0;
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.nav__link:hover { color: var(--text); border-bottom-color: var(--rule-strong); }
.nav__link[aria-current] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* Narrow screens: collapsible panel (only when JS is available;
   without JS the nav simply stacks and stays visible). */
@media (max-width: 62rem) {
  .site-header__inner { flex-wrap: wrap; }
  .nav { flex-basis: 100%; }
  .nav__panel {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-4);
    width: 100%;
    padding-bottom: var(--sp-5);
  }
  .nav__list { flex-direction: column; gap: 0; width: 100%; }
  .nav__link {
    display: block;
    padding: var(--sp-3) 0;
    font-size: var(--fs-sm);
    border-bottom: 1px solid var(--rule);
  }
  .nav__link[aria-current] { border-bottom-color: var(--rule); box-shadow: inset 3px 0 0 var(--accent); padding-left: var(--sp-3); }

  .js .nav { flex-basis: auto; }
  .js .nav__toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    min-height: 44px;
    padding: var(--sp-2) var(--sp-4);
    background: transparent;
    color: var(--text);
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    font: 600 var(--fs-xs) / 1 var(--font-sans);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    cursor: pointer;
  }
  .nav__toggle-icon { width: 16px; height: 12px; position: relative; }
  .nav__toggle-icon::before,
  .nav__toggle-icon::after {
    content: ""; position: absolute; left: 0; right: 0; height: 1.5px; background: currentColor;
    transition: transform var(--dur) var(--ease), top var(--dur) var(--ease);
  }
  .nav__toggle-icon::before { top: 2px; }
  .nav__toggle-icon::after { top: 8px; }
  .nav__toggle[aria-expanded="true"] .nav__toggle-icon::before { top: 5px; transform: rotate(45deg); }
  .nav__toggle[aria-expanded="true"] .nav__toggle-icon::after { top: 5px; transform: rotate(-45deg); }

  .js .nav__panel {
    display: none;
    position: absolute;
    left: 0; right: 0; top: 100%;
    padding: var(--sp-2) var(--gutter) var(--sp-6);
    background: var(--c-ink-950);
    border-bottom: 1px solid #262b30;
  }
  .js .nav--open .nav__panel { display: flex; }
}

/* ---------- 7. Hero (home) ---------- */
.hero { padding-block: clamp(4rem, 2rem + 8vw, 8.5rem); }
.hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-7);
  align-items: center;
}
.hero__mark { width: clamp(104px, 22vw, 150px); }
.hero__mark img { width: 100%; }
.hero__title {
  font-size: var(--fs-hero);
  text-transform: uppercase;
  letter-spacing: 0.01em;
  line-height: 1.04;
  margin-bottom: var(--sp-5);
}
.hero__title span { display: block; }
.hero__sub {
  font-family: var(--font-serif);
  font-size: var(--fs-lg);
  font-style: italic;
  font-weight: 400;
  color: var(--text);
  margin-bottom: var(--sp-5);
}
.hero__body { max-width: 60ch; color: var(--text-muted); }
@media (min-width: 60rem) {
  .hero__grid { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
  .hero__mark { order: 2; width: min(100%, 300px); justify-self: end; }
}

/* Inner page hero */
.page-hero { padding-block: clamp(3.5rem, 2rem + 6vw, 6.5rem); }
.page-hero__title {
  font-size: var(--fs-2xl);
  text-transform: uppercase;
  letter-spacing: 0.015em;
  max-width: 24ch;
}
.page-hero__lede {
  font-family: var(--font-serif);
  font-size: var(--fs-lg);
  line-height: 1.45;
  max-width: 44ch;
  color: var(--text);
}
.page-hero__body { max-width: var(--measure); color: var(--text-muted); margin-top: var(--sp-5); }

/* ---------- 8. Service panels (home "What are you trying to understand?") ---------- */
.panel-grid {
  display: grid;
  gap: var(--sp-5);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
  list-style: none;
  padding: 0;
  margin: 0;
}
.panel-grid > li + li { margin-top: 0; }
.panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: var(--sp-6) var(--sp-5);
  background: var(--surface-raised);
  border-top: 2px solid var(--text);
  box-shadow: 0 0 0 1px var(--rule);
}
.panel__index {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: var(--sp-4);
}
.panel__title { font-size: var(--fs-lg); margin-bottom: var(--sp-4); }
.panel__hook {
  font-family: var(--font-serif);
  font-size: var(--fs-md);
  font-style: italic;
  line-height: 1.45;
}
.panel__body { color: var(--text-muted); font-size: var(--fs-sm); }
.panel__link { margin-top: auto; padding-top: var(--sp-5); }

/* ---------- 9. Methodology: sequence, vocabulary, confidence ---------- */
.sequence {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) 0;
  list-style: none;
  padding: 0;
  margin: 0 0 var(--sp-7);
  counter-reset: step;
}
.sequence li + li { margin-top: 0; }
.sequence__step {
  counter-increment: step;
  display: flex;
  align-items: center;
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.sequence__step::before {
  content: counter(step, decimal-leading-zero);
  font-family: var(--font-mono);
  font-weight: 400;
  color: var(--accent);
  margin-right: var(--sp-2);
}
.sequence__step:not(:last-child)::after {
  content: "\2192"; /* → */
  margin-inline: var(--sp-3);
  color: var(--text-muted);
  font-weight: 400;
}

.vocab {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  gap: 0;
  margin: 0;
  border-top: 1px solid var(--rule-strong);
}
.vocab__item {
  padding: var(--sp-5) var(--sp-5) var(--sp-5) 0;
  border-bottom: 1px solid var(--rule);
}
.vocab dt {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: 0.16em;
  margin-bottom: var(--sp-2);
}
.vocab dd { margin: 0; color: var(--text-muted); font-size: var(--fs-sm); max-width: 30ch; }

.confidence {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  list-style: none;
  padding: 0;
  margin: 0;
}
.confidence li + li { margin-top: 0; }
.confidence__level {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid var(--rule-strong);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
/* Level shown by filled bars (shape), and always named in text. */
.confidence__bars { display: inline-flex; gap: 2px; }
.confidence__bars i { width: 4px; height: 12px; border: 1px solid currentColor; }
.confidence__bars i.is-on { background: currentColor; }

.statement {
  margin: var(--sp-7) 0 0;
  padding-left: var(--sp-5);
  border-left: 2px solid var(--accent);
  font-family: var(--font-serif);
  font-size: var(--fs-xl);
  line-height: 1.3;
  max-width: 34ch;
}
.statement p { margin: 0; }

.method-grid {
  display: grid;
  gap: var(--sp-7);
}
@media (min-width: 60rem) {
  .method-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
}

/* Fragments-to-structure figure (decorative). Static = resolved state.
   Progressive enhancement: scroll-driven animation where supported and
   motion is allowed. No JS. */
.resolve { width: 100%; max-width: 560px; color: var(--text); }
.resolve__link { stroke: var(--text-muted); stroke-width: 1; fill: none; }
.resolve__node { fill: var(--surface); stroke: var(--text); stroke-width: 1.25; }
.resolve__node--key { fill: var(--accent); stroke: var(--accent); }
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .resolve { view-timeline-name: --resolve; }
    .resolve__node {
      transform-box: fill-box;
      animation: resolve-node linear both;
      animation-timeline: --resolve;
      animation-range: entry 0% cover 50%;
    }
    .resolve__link {
      stroke-dasharray: 1;
      animation: resolve-link linear both;
      animation-timeline: --resolve;
      animation-range: entry 30% cover 55%;
    }
  }
}
@keyframes resolve-node {
  from { transform: translate(var(--dx, 0), var(--dy, 0)); opacity: 0.35; }
  to   { transform: translate(0, 0); opacity: 1; }
}
@keyframes resolve-link {
  from { stroke-dashoffset: 1; opacity: 0; }
  to   { stroke-dashoffset: 0; opacity: 1; }
}

/* ---------- 10. Document cards (case studies) ---------- */
.doc-grid {
  display: grid;
  gap: var(--sp-5);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  list-style: none;
  padding: 0;
  margin: 0;
}
.doc-grid > li + li { margin-top: 0; }
.doc-card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: var(--sp-6);
  background: var(--surface-raised);
  border: 1px solid var(--rule-strong);
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.doc-card--pending { border-style: dashed; }
.doc-card__meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--sp-2) var(--sp-4);
  padding-bottom: var(--sp-3);
  margin-bottom: var(--sp-5);
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.doc-card__title { font-size: var(--fs-lg); }
.doc-card__title a { text-decoration: none; }
/* Whole card clickable via stretched link; link text stays the accessible name */
.doc-card__title a::after { content: ""; position: absolute; inset: 0; }
.doc-card:has(a:hover) { border-color: var(--text); }
.doc-card:has(a:focus-visible) { outline: 2px solid var(--focus); outline-offset: 3px; }
.doc-card__title a:focus-visible { outline: none; }
.doc-card__body { color: var(--text-muted); font-size: var(--fs-sm); }
.doc-card__foot {
  margin-top: auto;
  padding-top: var(--sp-5);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.doc-card__status {
  display: inline-block;
  padding: 2px var(--sp-2);
  border: 1px solid var(--rule-strong);
  color: var(--text-muted);
}

/* ---------- 11. Capabilities (home, dark) & capability list ---------- */
.cap-grid {
  display: grid;
  gap: 0 var(--sp-7);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  list-style: none;
  padding: 0;
  margin: 0;
}
.cap-grid > li + li { margin-top: 0; }
.cap {
  padding-block: var(--sp-5);
  border-top: 1px solid var(--rule);
}
.cap__title {
  font-size: var(--fs-md);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-3);
}
.cap__body { color: var(--text-muted); font-size: var(--fs-sm); max-width: 52ch; }
.cap__note { font-size: var(--fs-xs); color: var(--text-muted); margin-top: var(--sp-3); font-style: italic; }
.cap__cert {
  margin-top: var(--sp-4);
  padding-left: var(--sp-4);
  border-left: 2px solid var(--rule-strong);
  max-width: 60ch;
}
.cap__cert-title { font-size: var(--fs-sm); margin-bottom: var(--sp-2); }
.cap__cert-body { color: var(--text-muted); font-size: var(--fs-sm); }
.cap__cert-specs { color: var(--text-muted); font-size: var(--fs-xs); margin-top: var(--sp-2); }
.cap__cert-label {
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.tag {
  display: inline-block;
  padding: 1px var(--sp-2);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
}

/* ---------- 12. Why Babdah (dark, atmospheric) ---------- */
.why__inner > * { max-width: 44rem; }
.why__lead {
  font-family: var(--font-serif);
  font-size: var(--fs-lg);
  line-height: 1.45;
}
.why p { color: var(--text-muted); }
.why .why__lead, .why .why__emph { color: var(--text); }
.why__emph {
  font-family: var(--font-serif);
  font-size: var(--fs-xl);
  font-weight: 600;
  margin-block: var(--sp-6);
}
.why__close {
  margin-top: var(--sp-7);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}
.pronounce {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.triquetra {
  width: 44px;
  color: var(--accent);
  margin-bottom: var(--sp-6);
  opacity: 0.85;
}

/* ---------- 13. CTA band ---------- */
.cta__inner > * { max-width: 46rem; }
.cta__title { font-size: var(--fs-2xl); text-transform: uppercase; letter-spacing: 0.015em; }
.cta p { color: var(--text-muted); font-size: var(--fs-md); line-height: 1.55; }

/* ---------- 14. Services page ---------- */
.service {
  display: grid;
  gap: var(--sp-6) var(--sp-8);
  scroll-margin-top: var(--sp-5);
}
@media (min-width: 60rem) {
  .service { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
}
.service__title { font-size: var(--fs-xl); }
.service__proposition {
  font-family: var(--font-serif);
  font-size: var(--fs-lg);
  font-style: italic;
  line-height: 1.4;
  color: var(--text);
}
.service__block + .service__block { margin-top: var(--sp-6); }
.service__label {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--sp-3);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--rule);
}
.service__list { list-style: none; padding: 0; }
.service__list li { padding-left: var(--sp-5); position: relative; }
.service__list li::before {
  content: "";
  position: absolute;
  left: 0; top: 0.72em;
  width: 10px; height: 1px;
  background: var(--accent);
}

.framework { margin: 0; display: grid; gap: var(--sp-4); }
.framework div { display: grid; gap: var(--sp-1); }
@media (min-width: 40rem) {
  .framework div { grid-template-columns: 9rem 1fr; gap: var(--sp-4); }
}
.framework dt { font-weight: 600; }
.framework dd { margin: 0; color: var(--text-muted); }

.ladder { list-style: none; padding: 0; margin: 0; counter-reset: tier; }
.ladder li {
  counter-increment: tier;
  padding: var(--sp-4) 0 var(--sp-4) var(--sp-7);
  border-bottom: 1px solid var(--rule);
  position: relative;
  margin: 0;
}
.ladder li::before {
  content: counter(tier, decimal-leading-zero);
  position: absolute; left: 0; top: var(--sp-4);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--accent);
}
.ladder strong { display: block; }
.ladder span { color: var(--text-muted); font-size: var(--fs-sm); }

.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-5);
  list-style: none;
  padding: 0;
  margin: var(--sp-6) 0 0;
}
.subnav li + li { margin-top: 0; }
.subnav a { font-size: var(--fs-sm); }

/* ---------- 15. Standards list ---------- */
.standards { list-style: none; padding: 0; margin: 0; counter-reset: std; border-top: 1px solid var(--rule-strong); }
.standards li {
  counter-increment: std;
  display: grid;
  grid-template-columns: 3rem 1fr;
  gap: var(--sp-3);
  padding-block: var(--sp-4);
  border-bottom: 1px solid var(--rule);
  margin: 0;
}
.standards li::before {
  content: counter(std, decimal-leading-zero);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--accent);
  padding-top: 2px;
}

.method-steps { list-style: none; padding: 0; margin: 0; counter-reset: ms; }
.method-steps > li {
  counter-increment: ms;
  display: grid;
  gap: var(--sp-2) var(--sp-5);
  padding-block: var(--sp-6);
  border-top: 1px solid var(--rule);
  margin: 0;
}
@media (min-width: 48rem) {
  .method-steps > li { grid-template-columns: 4rem minmax(0, 16rem) minmax(0, 1fr); }
}
.method-steps > li::before {
  content: counter(ms, decimal-leading-zero);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--accent);
  padding-top: 4px;
}
.method-steps h3 { font-size: var(--fs-md); margin: 0; }
.method-steps p { color: var(--text-muted); margin: 0; max-width: 58ch; }

/* ---------- 16. Case study document ---------- */
.case-doc {
  max-width: 52rem;
  margin-inline: auto;
  background: var(--surface-raised);
  border: 1px solid var(--rule-strong);
  padding: clamp(1.5rem, 1rem + 3vw, 3.5rem);
}
.case-doc__meta {
  display: grid;
  gap: var(--sp-3) var(--sp-6);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
  margin: 0 0 var(--sp-7);
  padding-bottom: var(--sp-5);
  border-bottom: 1px solid var(--rule-strong);
}
.case-doc__meta div { margin: 0; }
.case-doc__meta dt {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.case-doc__meta dd { margin: var(--sp-1) 0 0; font-weight: 600; font-size: var(--fs-sm); }
.case-doc__section + .case-doc__section { margin-top: var(--sp-7); }
.case-doc__section h2 {
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--sp-4);
}
.case-doc__section p { max-width: var(--measure); }
.case-doc__value {
  margin: var(--sp-7) 0 0;
  padding: var(--sp-5) var(--sp-5) var(--sp-5) var(--sp-6);
  border-left: 2px solid var(--accent);
  background: var(--surface);
  font-family: var(--font-serif);
  font-size: var(--fs-md);
  line-height: 1.5;
}
.case-doc__value p { margin: 0; }
.observation {
  margin: var(--sp-5) 0;
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid var(--rule-strong);
  font-size: var(--fs-sm);
}
.observation__label {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--sp-2);
}

/* ---------- 17. Notices ---------- */
.notice {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--sp-4);
  padding: var(--sp-5);
  border: 1px solid var(--rule-strong);
  border-left: 4px solid var(--accent);
  background: var(--surface-raised);
  font-size: var(--fs-sm);
}
.notice__icon { width: 22px; height: 22px; color: var(--accent); margin-top: 2px; }
.notice__title { font-weight: 600; margin-bottom: var(--sp-2); font-size: var(--fs-base); font-family: var(--font-sans); }
.notice p { margin-bottom: var(--sp-2); }
.notice--quiet { border-left-width: 1px; grid-template-columns: 1fr; font-style: italic; color: var(--text-muted); }

/* Draft/legal-review flag — visible on placeholder legal pages. */
.draft-flag {
  display: block;
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-6);
  border: 1px dashed var(--rule-strong);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  color: var(--text);
  background: var(--surface-raised);
}
.placeholder { background: rgb(111 84 36 / 0.12); padding: 0 0.2em; border-radius: var(--radius); }

/* ---------- 18. Intake form ---------- */
.intake {
  display: grid;
  gap: var(--sp-7);
}
@media (min-width: 64rem) {
  .intake { grid-template-columns: minmax(0, 7fr) minmax(0, 4fr); align-items: start; }
  .intake__aside { position: sticky; top: var(--sp-5); }
}
.form { display: grid; gap: var(--sp-6); }
.form__group {
  border: 0;
  padding: 0;
  margin: 0;
  display: grid;
  gap: var(--sp-5);
}
.form__group-title {
  font-family: var(--font-serif);
  font-size: var(--fs-lg);
  font-weight: 600;
  padding: 0 0 var(--sp-2);
  margin-bottom: var(--sp-2);
  border-bottom: 1px solid var(--rule);
  width: 100%;
}
.field { display: grid; gap: var(--sp-2); }
.field__label { font-weight: 600; font-size: var(--fs-base); }
.field__optional { font-weight: 400; color: var(--text-muted); font-size: var(--fs-sm); }
.field__req { font-weight: 400; color: var(--text-muted); font-size: var(--fs-sm); }
.field__hint { color: var(--text-muted); font-size: var(--fs-sm); margin: 0; }
.field__input {
  width: 100%;
  min-height: 48px;
  padding: var(--sp-3) var(--sp-4);
  font: inherit;
  font-size: var(--fs-base);
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
textarea.field__input { min-height: 8.5rem; resize: vertical; line-height: 1.55; }
.field__input:hover { border-color: var(--text); }
.field__input:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--text);
}
/* Only flag invalid after the person has interacted */
.field__input:user-invalid { border-color: #9b2c1f; box-shadow: inset 3px 0 0 #9b2c1f; }

.choices { display: grid; gap: var(--sp-2); border: 0; padding: 0; margin: 0; }
.choices legend { font-weight: 600; margin-bottom: var(--sp-2); padding: 0; }
.choice {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  cursor: pointer;
  min-height: 48px;
}
.choice:hover { border-color: var(--rule-strong); }
.choice:has(input:checked) { border-color: var(--text); background: var(--surface-raised); }
.choice input {
  accent-color: var(--c-paper-ink);
  width: 20px; height: 20px;
  margin: 2px 0 0;
  flex: none;
}
.choice__text span { display: block; color: var(--text-muted); font-size: var(--fs-sm); }

.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.form__actions { display: grid; gap: var(--sp-3); justify-items: start; }
.form__footnote { font-size: var(--fs-sm); color: var(--text-muted); max-width: 56ch; }

.aside-block + .aside-block { margin-top: var(--sp-6); }
.aside-block h2 { font-size: var(--fs-md); }
.aside-block p, .aside-block li { font-size: var(--fs-sm); color: var(--text-muted); }
.steps-list { padding-left: 1.25em; }
.steps-list li::marker { color: var(--accent); font-family: var(--font-mono); }

/* ---------- 19. Footer ---------- */
.site-footer {
  background: var(--c-ink-950);
  color: var(--text);
  border-top: 1px solid #262b30;
  padding-block: var(--sp-8) var(--sp-6);
  font-size: var(--fs-sm);
}
.site-footer__grid {
  display: grid;
  gap: var(--sp-7);
}
@media (min-width: 56rem) {
  .site-footer__grid { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr); }
}
.site-footer__brand { display: flex; gap: var(--sp-4); align-items: flex-start; }
.site-footer__mark { width: 48px; flex: none; }
.site-footer__name {
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0 0 var(--sp-1);
}
.site-footer__tagline {
  font-size: var(--fs-xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin: var(--sp-3) 0 0;
}
.site-footer__heading {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--sp-3);
}
.site-footer__list { list-style: none; padding: 0; margin: 0; }
.site-footer__list li + li { margin-top: 0; }
.site-footer__list a {
  display: inline-block;
  padding-block: var(--sp-1);
  min-height: 28px;
  color: var(--text);
  text-decoration: none;
}
.site-footer__list a:hover { text-decoration: underline; text-decoration-color: var(--accent); }
.site-footer__legal {
  margin-top: var(--sp-7);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--rule);
  display: grid;
  gap: var(--sp-3);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  line-height: 1.6;
}
.site-footer__legal p { max-width: 80ch; }

/* ---------- 20. Utilities ---------- */
.mt-0 { margin-top: 0; }
.mt-6 { margin-top: var(--sp-6); }
.mt-7 { margin-top: var(--sp-7); }
.muted { color: var(--text-muted); }
.center { text-align: center; }

/* ---------- 21. Print (case studies & legal pages print as documents) ---------- */
@media print {
  .site-header, .site-footer, .skip-link, .actions, .cta { display: none !important; }
  .section, .theme-dark, .theme-charcoal {
    --surface: #fff; --surface-raised: #fff; --text: #000; --text-muted: #333;
    --rule: #bbb; --rule-strong: #666; --accent: #000;
    padding-block: 1.5rem;
  }
  .topo::before { display: none; }
  a { text-decoration: none; }
}

/* Fragment offsets for the resolve figure (kept in CSS, not inline styles,
   so a strict style-src CSP needs no 'unsafe-inline'). */
.resolve__nodes circle:nth-of-type(1)  { --dx: -34px; --dy: 46px; }
.resolve__nodes circle:nth-of-type(2)  { --dx: 52px;  --dy: -38px; }
.resolve__nodes circle:nth-of-type(3)  { --dx: -48px; --dy: -52px; }
.resolve__nodes circle:nth-of-type(4)  { --dx: 40px;  --dy: 58px; }
.resolve__nodes circle:nth-of-type(5)  { --dx: -60px; --dy: 22px; }
.resolve__nodes circle:nth-of-type(6)  { --dx: 30px;  --dy: -60px; }
.resolve__nodes circle:nth-of-type(7)  { --dx: 64px;  --dy: 30px; }
.resolve__nodes circle:nth-of-type(8)  { --dx: -26px; --dy: -44px; }
.resolve__nodes circle:nth-of-type(9)  { --dx: 44px;  --dy: 40px; }
.resolve__nodes circle:nth-of-type(10) { --dx: -54px; --dy: -24px; }
.resolve__nodes circle:nth-of-type(11) { --dx: 22px;  --dy: 62px; }
.resolve__nodes circle:nth-of-type(12) { --dx: -40px; --dy: 36px; }
.resolve__nodes circle:nth-of-type(13) { --dx: 58px;  --dy: -30px; }
.resolve__nodes circle:nth-of-type(14) { --dx: -30px; --dy: -58px; }

/* Small utilities (used instead of inline styles) */
.u-text { color: var(--text); }
.u-fs-md { font-size: var(--fs-md); }
.u-fs-xl { font-size: var(--fs-xl); }
.u-inherit { color: inherit; }
main:focus { outline: none; }

/* Small screens: stacked wordmark so brand + Menu share one row at 360px */
@media (max-width: 30rem) {
  .brand__mark { width: 30px; }
  .brand__name { width: min-content; font-size: 0.9375rem; letter-spacing: 0.12em; }
}
