/* ==========================================================================
   VERDICT — POLISH LAYER
   Loaded after every other stylesheet. One calm editorial system:
   - warm paper background, near-black ink, ONE accent (deep red)
   - serif for headlines, sans for everything else, mono only for IDs/dates
   - sentence-case labels, hairline borders, generous whitespace
   ========================================================================== */

:root {
  --bg: #f7f4ee;
  --bg-subtle: #efebe3;
  --surface: #fffefb;
  --surface-alt: #f3efe7;

  --ink: #1a1815;
  --ink-secondary: #47433d;
  --ink-muted: #6b665e;
  --ink-faint: #a29b90;

  --border: #ddd6ca;
  --border-subtle: #e9e3d8;
  --border-strong: #1a1815;

  --accent: #a31d2d;
  --accent-hover: #83151f;
  --accent-soft: #f7ebec;
  --accent-border: #e3bcc2;

  --font-serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --font-sans: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-display: var(--font-serif);

  --max-width: 1200px;
  --radius-xs: 3px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;

  --space-section: clamp(56px, 8vw, 104px);
  --shadow-card: 0 1px 2px rgba(26, 24, 21, 0.04), 0 4px 16px rgba(26, 24, 21, 0.04);
}

/* ---------- Base ---------- */

html { scroll-padding-top: 88px; }

body {
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
}

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  color: var(--ink);
  text-wrap: balance;
}

h1 { font-size: clamp(2.4rem, 5.2vw, 3.9rem); line-height: 1.06; letter-spacing: -0.022em; }
h2 { font-size: clamp(1.7rem, 3.2vw, 2.3rem); line-height: 1.15; letter-spacing: -0.015em; }
h3 { font-size: 1.3rem; line-height: 1.28; letter-spacing: -0.005em; }
h4 { font-size: 1.1rem; line-height: 1.3; }

p { text-wrap: pretty; }

a { text-underline-offset: 3px; text-decoration-thickness: 1px; }

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

::selection { background: #f0d3d6; color: var(--ink); }

.main-wrapper {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px 96px;
}

/* Section rhythm: one consistent gap between top-level blocks */
.main-wrapper > section,
.main-wrapper > .dossier-block {
  margin-top: var(--space-section);
}
.main-wrapper > section:first-child { margin-top: 0; }

/* Skip link */
.skip-link {
  position: fixed;
  top: -64px;
  left: 16px;
  z-index: 300;
  padding: 10px 16px;
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius-md);
  font-weight: 600;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 12px; }

/* ---------- Eyebrow / label system (replaces the mono-caps soup) ---------- */

.kicker,
.section-num,
.layer-num,
.channel-label,
.contact-kicker-row,
.protocol-num,
.trust-center-badge,
.coverage-bar-title {
  font-family: var(--font-sans) !important;
  font-size: 0.75rem !important;
  font-weight: 700 !important;
  letter-spacing: 0.1em !important;
  text-transform: uppercase !important;
  color: var(--accent) !important;
}

.section-meta,
.filter-label,
.stat-label,
.metric-lbl,
.coverage-bar-meta,
.showcase-updated,
.search-try-prompts > span:first-child {
  font-family: var(--font-sans) !important;
  font-size: 0.8125rem !important;
  letter-spacing: 0.01em !important;
  text-transform: none !important;
  font-weight: 500 !important;
  color: var(--ink-muted) !important;
}

/* ---------- Buttons ---------- */

.btn,
.btn-primary,
.btn-secondary,
.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0;
  text-transform: none;
  text-decoration: none;
  padding: 11px 20px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.btn-primary,
.btn.btn-primary {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.btn-primary:hover,
.btn.btn-primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-secondary,
.btn-outline,
.btn.btn-outline {
  background: transparent;
  color: var(--ink);
  border-color: var(--border);
}
.btn-secondary:hover,
.btn-outline:hover,
.btn.btn-outline:hover {
  border-color: var(--ink);
  background: var(--surface);
  color: var(--ink);
}

.btn-sm { padding: 8px 14px; font-size: 0.875rem; }

/* ---------- Site header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(247, 244, 238, 0.9);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.site-header.is-scrolled {
  border-bottom-color: var(--border);
  box-shadow: 0 6px 24px rgba(26, 24, 21, 0.06);
}

.site-header-inner {
  max-width: var(--max-width);
  height: 64px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 40px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  flex: 0 0 auto;
}
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: block;
}
.brand-wordmark {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  line-height: 1;
}
.brand:hover .brand-wordmark { color: var(--accent); }

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1 1 auto;
}
.site-nav a {
  position: relative;
  padding: 8px 12px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
}
.site-nav a:hover { color: var(--ink); background: rgba(26, 24, 21, 0.05); }
.site-nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.site-nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 2px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}
.nav-cta-mobile { display: none !important; }

.site-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.header-search {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 10px 0 12px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.header-search:hover { border-color: var(--ink-muted); color: var(--ink); }
.header-search kbd {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  line-height: 1;
  padding: 3px 6px;
  color: var(--ink-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
}

.header-cta { height: 38px; padding-top: 0; padding-bottom: 0; }

.nav-toggle {
  display: none;
  width: 40px;
  height: 38px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.nav-toggle span {
  display: block;
  width: 16px;
  height: 1.5px;
  background: var(--ink);
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.site-header.is-open .nav-toggle span:nth-child(1) { transform: translateY(5.5px) rotate(45deg); }
.site-header.is-open .nav-toggle span:nth-child(2) { opacity: 0; }
.site-header.is-open .nav-toggle span:nth-child(3) { transform: translateY(-5.5px) rotate(-45deg); }

@media (max-width: 860px) {
  .site-header-inner { gap: 12px; height: 58px; padding: 0 16px; }
  .nav-toggle { display: inline-flex; }
  .header-search span, .header-search kbd { display: none; }
  .header-search { width: 38px; padding: 0; justify-content: center; }

  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 8px 16px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 16px 32px rgba(26, 24, 21, 0.1);
  }
  .site-header.is-open .site-nav { display: flex; }
  .site-nav a { padding: 14px 8px; font-size: 1.05rem; border-bottom: 1px solid var(--border-subtle); border-radius: 0; }
  .site-nav a[aria-current="page"]::after { display: none; }
  .site-nav a[aria-current="page"] { color: var(--accent); }
}
@media (max-width: 520px) {
  .header-cta { display: none; }
  .nav-cta-mobile { display: block !important; color: var(--accent) !important; font-weight: 700 !important; border-bottom: 0 !important; }
}

/* Old chrome, in case any page still carries it */
.top-utility, .masthead { display: none !important; }

/* ---------- Page tools (case / dossier switchers) ---------- */

.page-tools {
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
}
.page-tools-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.page-tools .crumb {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-secondary);
  text-decoration: none;
}
.page-tools .crumb:hover { color: var(--accent); }
.page-tools-title {
  font-size: 0.875rem;
  color: var(--ink-muted);
  padding-left: 20px;
  border-left: 1px solid var(--border);
}
.page-tools-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.page-tools label { font-size: 0.85rem; color: var(--ink-muted); font-weight: 500; }
.page-tools select {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  padding: 7px 32px 7px 12px;
  max-width: min(420px, 62vw);
  color: var(--ink);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.page-tools .challenge-pill-btn {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 7px 14px;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-md);
  cursor: pointer;
}
.page-tools .challenge-pill-btn:hover { background: var(--accent-soft); border-color: var(--accent); }

@media (max-width: 640px) {
  .page-tools-inner { padding: 10px 16px; gap: 10px 14px; }
  .page-tools-title { display: none; }
  .page-tools-right { margin-left: 0; width: 100%; }
  .page-tools select { flex: 1 1 auto; max-width: none; }
}

/* ---------- Footer ---------- */

.site-footer {
  margin-top: 0;
  padding: 72px 0 0;
  background: #181613;
  color: #b9b2a7;
  border-top: 0;
}
.footer-inner { max-width: var(--max-width); margin: 0 auto; padding: 0 24px; }
.footer-top {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  gap: 48px;
  padding-bottom: 56px;
}
.footer-brand .brand-wordmark { color: #f4eee4; font-size: 1.15rem; }
.footer-brand .footer-brand-row { display: flex; align-items: center; gap: 11px; margin-bottom: 16px; }
.footer-brand p { font-size: 0.95rem; line-height: 1.6; color: #9a938a; max-width: 34ch; }
.footer-col h5 {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #f4eee4;
  margin-bottom: 16px;
}
.footer-col ul { list-style: none; display: grid; gap: 10px; }
.footer-col a {
  font-size: 0.95rem;
  color: #b9b2a7;
  text-decoration: none;
}
.footer-col a:hover { color: #fff; text-decoration: underline; }
.footer-col .footer-email {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  word-break: break-all;
}
.footer-bottom {
  display: flex;
  justify-content: space-between;
  gap: 16px 32px;
  flex-wrap: wrap;
  padding: 24px 0 32px;
  border-top: 1px solid #2c2925;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: #837c72;
}

@media (max-width: 900px) {
  .footer-top { grid-template-columns: 1fr 1fr; gap: 40px 32px; }
  .footer-brand { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  .footer-top { grid-template-columns: 1fr; }
}

/* ---------- Reading progress ---------- */
.scroll-progress-line { top: 0; z-index: 120; height: 2px; }
.scroll-progress-fill { background: var(--accent); }

/* ---------- Layout safety (all pages) ---------- */
/* Doc / case two-column layouts: the single column must be allowed to shrink */
.doc-layout > *, .case-page-layout > * { min-width: 0; }
@media (max-width: 900px) {
  .doc-layout, .case-page-layout { grid-template-columns: minmax(0, 1fr) !important; }
  .doc-layout { margin-top: 16px; }
  pre, .code-block, .endpoint-code { max-width: 100%; overflow-x: auto; }
}

@media (max-width: 700px) {
  #api-content [style*="grid-template-columns"] { grid-template-columns: minmax(0, 1fr) !important; }
  .code-param-table { display: block; max-width: 100%; overflow-x: auto; }
}

code { overflow-wrap: anywhere; }
@media (max-width: 700px) {
  .dossier-table, .ledger-table { max-width: 100%; }
  .case-content-stream .dossier-table, .dossier-shell .dossier-table { display: block; overflow-x: auto; }
  .identity-badge { white-space: normal; }
}

@media (max-width: 520px) {
  .footer-top { grid-template-columns: 1fr 1fr; gap: 36px 20px; }
  .footer-brand, .footer-col:last-child { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
  .coverage-metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Small screens: reclaim width from nested cards ---------- */
@media (max-width: 640px) {
  .main-wrapper { padding-left: 16px; padding-right: 16px; }
  .footer-inner { padding-left: 16px; padding-right: 16px; }
  .case-section { padding: 20px 16px !important; }
  .evidence-packet-card, .consistency-review-card { padding: 16px !important; }
  .packet-top-bar { flex-wrap: wrap; gap: 8px; }
  .consistency-review-card > div { flex-wrap: wrap; gap: 8px; }
  .audit-log-table, .dossier-table { display: block; max-width: 100%; overflow-x: auto; }
}

/* Dossier hero name: editorial, not billboard */
.dossier-title {
  font-size: clamp(2.4rem, 5.2vw, 3.9rem) !important;
  line-height: 1.05 !important;
  letter-spacing: -0.022em !important;
}

/* Fund page: let grid tiles shrink inside the card, scale the hero on phones */
.preset-selector-row, .preset-selector-row > * { min-width: 0; }
@media (max-width: 640px) {
  .preset-selector-row { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  .fund-hero-title { font-size: clamp(1.9rem, 9vw, 2.6rem) !important; line-height: 1.08 !important; overflow-wrap: anywhere; }
}
