/* ============================================================
   LEDGER OVERLAYS — production rules layered on top of the
   canonical Hepburn Advisory design tokens (colors_and_type.css).
   Ledger-side only. Do not modify colors_and_type.css to add
   Ledger-specific rules; put them here.

   Owner: wq-033 Phase 1 (V2 launch).
   ============================================================ */

/* ============================================================
   1. PROVENANCE / CONFIDENCE PILL
   Single-axis V2 mapping (per cross-launch contract wq-035 §4.6
   and brief 2026-04-27-ha-references-design.md §4.2):

     site-data.json "confidence" : pill class       : pill text
     "High"                      : .pill.tier-1     : T1 High
     "Med"                       : .pill.tier-2     : T2 Med
     "Low"                       : .pill.tier-3     : T3 Low

   Two-axis (Sourced/Derived/Modeled separated from confidence)
   is V1.1 work, deferred.
   ============================================================ */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.pill.tier-1 { background: var(--green-tint);  color: var(--green);  }
.pill.tier-2 { background: var(--amber-tint);  color: var(--amber);  }
.pill.tier-3 { background: var(--violet-tint); color: var(--violet); }

/* Smaller pill for inline cells / table chips. */
.pill-mini {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: var(--weight-semi);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pill-mini.tier-1 { background: var(--green-tint);  color: var(--green);  }
.pill-mini.tier-2 { background: var(--amber-tint);  color: var(--amber);  }
.pill-mini.tier-3 { background: var(--violet-tint); color: var(--violet); }

/* ============================================================
   2. NUMERIC HYGIENE
   Every numeric span on the Ledger renders with tabular nums.
   This is a hard rule from SKILL.md §9.
   ============================================================ */

.surface-dark .num,
.surface-dark .num-display,
.surface-dark .mega,
.surface-dark .h1,
.surface-dark .h2 {
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   3. SHARED HEADER (wq-033 Phase 2)
   Brand mark + wordmark + 7-item nav + HA reciprocal CTA.
   Sticky top bar across every public Ledger page.
   ============================================================ */

.ds-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-dark);
  padding: 14px 32px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.ds-header__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.ds-header__brand img {
  width: 26px;
  height: 26px;
  display: block;
}

.ds-header__brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ds-header__brand-name {
  font: var(--weight-bold) 15px/1.1 var(--font-sans);
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, var(--blue), var(--violet));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.ds-header__brand-sub {
  font: var(--weight-medium) 10px/1 var(--font-sans);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg-dark-3);
}

.ds-header__nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}

.ds-header__nav::-webkit-scrollbar { display: none; }

.ds-header__nav-link {
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font: var(--weight-medium) 13px/1 var(--font-sans);
  color: var(--fg-dark-2);
  text-decoration: none;
  border: 1px solid transparent;
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}

.ds-header__nav-link:hover {
  color: var(--fg-dark-1);
  background: rgba(255, 255, 255, 0.04);
}

.ds-header__nav-link.is-active {
  background: rgba(59, 130, 246, 0.12);
  color: var(--blue);
  border-color: rgba(59, 130, 246, 0.3);
}

/* ── Ledger rail ────────────────────────────────────────────────────────────
   The six ledgers are one thing with six surfaces, not six peers of
   Methodology and About. Enclosing them makes the nav say so: a single
   recessed rail reads as one object, and the reference pages sit outside it,
   quieter — pages *about* the data rather than pages *of* it.

   The rail is a single flex child, so on mobile it scrolls as one unit rather
   than fragmenting. A divider or a per-item marker comes apart at exactly the
   point the grouping most needs to hold. */
.ds-header__nav-group {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
  padding: 3px;
  border-radius: calc(var(--radius-md) + 3px);
  border: 1px solid var(--border-dark);
  background: rgba(255, 255, 255, 0.025);
}

/* Reference pages: same link, lower voice. Smaller, dimmer, no hover fill —
   available without competing with the six. */
.ds-header__nav-link--ref {
  font-size: 12px;
  padding: 8px 10px;
  color: var(--fg-dark-3);
}

.ds-header__nav-link--ref:hover {
  background: transparent;
  color: var(--fg-dark-1);
}

.ds-header__nav-group + .ds-header__nav-link--ref { margin-left: 10px; }

@media (max-width: 768px) {
  .ds-header__nav-group { padding: 2px; gap: 0; }
  .ds-header__nav-group + .ds-header__nav-link--ref { margin-left: 6px; }
  .ds-header__nav-link--ref { font-size: 11.5px; padding: 8px 8px; }
}

/* The rail is decoration, not information. At raised contrast the faint fill
   and hairline border are the first things a reader loses, so drop them and
   let the size and colour split carry the grouping on its own. */
@media (prefers-contrast: more) {
  .ds-header__nav-group { background: transparent; border-color: transparent; padding-left: 0; }
  .ds-header__nav-link--ref { color: var(--fg-dark-2); }
}

.ds-header__cta {
  margin-left: auto;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font: var(--weight-semi) 13px/1 var(--font-sans);
  color: var(--fg-dark-1);
  text-decoration: none;
  border: 1px solid var(--border-dark);
  background: var(--surface-dark);
  transition: border-color var(--duration-fast) var(--ease-out);
}

.ds-header__cta:hover { border-color: var(--blue); }

@media (max-width: 768px) {
  /* Two-row header on mobile portrait so the Hepburn Advisory CTA can't sit
     over the nav. Brand + CTA share row 1; nav gets its own full-width row 2
     so all 7 links are reachable via horizontal scroll without overlap.
     Simon flagged this 2026-05-07 — at 375px only "Capital" was visible. */
  .ds-header { padding: 10px 14px; gap: 8px 12px; flex-wrap: wrap; }
  .ds-header__brand { order: 1; }
  .ds-header__brand-sub { display: none; }
  .ds-header__cta { order: 2; margin-left: auto; font-size: 12px; padding: 8px 10px; }
  .ds-header__nav {
    order: 3;
    flex: 0 0 100%;
    width: 100%;
    -webkit-overflow-scrolling: touch;
    mask-image: linear-gradient(to right, black 95%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, black 95%, transparent 100%);
  }
  .ds-header__nav-link { font-size: 12px; padding: 8px 10px; min-height: 36px; display: inline-flex; align-items: center; }
}

/* ============================================================
   2a. PRIMARY BUTTON (wq-034 Phase 1)
   Solid-blue primary CTA for dark surface, per SKILL.md component
   reference ("Button (dark, primary) → blue bg, #fff text").
   Used by the index.html subscribe CTA card and any other
   future link-out / form-replacement buttons.
   ============================================================ */

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 22px;
  border-radius: var(--radius-md);
  background: var(--blue);
  color: var(--ink-0);
  font: var(--weight-semi) var(--text-base)/1 var(--font-sans);
  text-decoration: none;
  border: 1px solid var(--blue);
  transition: background var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}

.btn-primary:hover {
  background: var(--blue-600);
  border-color: var(--blue-600);
}

.btn-primary:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

/* ============================================================
   3a. METHODOLOGY CAVEAT (wq-033 Phase 3, GUIDELINES §2.4)
   Required collapsible caveat at the top of any page with
   derived numbers. <details> + <summary> markup.
   ============================================================ */

.methodology-caveat {
  background: var(--bg-dark-alt);
  border: 1px solid var(--border-dark);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin: 24px 0 32px;
  font: var(--type-body);
  color: var(--fg-dark-2);
}

.methodology-caveat > summary {
  cursor: pointer;
  font: var(--weight-semi) var(--text-sm)/1.4 var(--font-sans);
  text-transform: uppercase;
  letter-spacing: var(--tracking-eyebrow);
  color: var(--amber);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.methodology-caveat > summary::-webkit-details-marker { display: none; }

.methodology-caveat > summary::before {
  content: "▸";
  font-size: 10px;
  transition: transform var(--duration-fast) var(--ease-out);
}

.methodology-caveat[open] > summary::before { transform: rotate(90deg); }

.methodology-caveat > p {
  margin-top: 10px;
  font: var(--weight-regular) var(--text-base)/var(--leading-relaxed) var(--font-sans);
  color: var(--fg-dark-2);
}

/* ============================================================
   3b. PAGE TOOLBAR (wq-033 Phase 2 cleanup)
   Thin sub-bar below the shared header, used where a page has
   functional controls (scenario toggle, etc.). Reuses existing
   per-page .nav-scenario / .scenario-btn styles for the inner
   buttons so the JS hooks (querySelectorAll('.scenario-btn'))
   keep working without modification.
   ============================================================ */

.ds-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 8px 32px;
  background: var(--bg-dark-alt);
  border-bottom: 1px solid var(--border-dark);
}

@media (max-width: 768px) {
  .ds-toolbar { padding: 8px 14px; }
}

/* ============================================================
   4. PER-PAGE BYLINE (wq-033 Phase 2 §4.8)
   Drops in below the methodology block. One line, restrained.
   ============================================================ */

.byline {
  max-width: 1200px;
  margin: 32px auto 0;
  padding: 18px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  font: var(--weight-medium) 12px/1.5 var(--font-sans);
  color: var(--fg-dark-3);
  border-top: 1px solid var(--border-dark);
}

.byline a {
  color: var(--fg-dark-1);
  text-decoration: none;
  font-weight: var(--weight-semi);
  border-bottom: 1px solid transparent;
  transition: border-color var(--duration-fast) var(--ease-out);
}

.byline a:hover { border-bottom-color: var(--blue); }

.byline .meta {
  color: var(--fg-dark-3);
  font-weight: var(--weight-regular);
}

/* ============================================================
   5. SHARED FOOTER (wq-033 Phase 2 §4.4)
   Logo + desc + 4 columns + base line.
   Disclosure column (privacy / conflicts) deferred to V1.1
   pending source pages.
   ============================================================ */

.ds-footer {
  margin-top: 48px;
  padding: 48px 32px 32px;
  border-top: 1px solid var(--border-dark);
  background: var(--bg-dark-alt);
  color: var(--fg-dark-2);
  font: var(--type-body);
}

.ds-footer__inner {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) repeat(4, 1fr);
  gap: 32px;
}

.ds-footer__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.ds-footer__brand-lockup {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ds-footer__brand img {
  width: 32px;
  height: 32px;
  display: block;
}

.ds-footer__brand-name {
  font: var(--weight-bold) 14px/1.3 var(--font-sans);
  color: var(--fg-dark-1);
}

.ds-footer__brand-desc {
  text-align: center;
  font: var(--weight-regular) 12px/1.5 var(--font-sans);
  color: var(--fg-dark-3);
}

.ds-footer__col-title {
  font: var(--weight-semi) 10px/1.2 var(--font-sans);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-dark-3);
  margin: 0 0 12px;
}

.ds-footer__col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ds-footer__col a {
  color: var(--fg-dark-2);
  text-decoration: none;
  font: var(--weight-medium) 12px/1.4 var(--font-sans);
  transition: color var(--duration-fast) var(--ease-out);
}

.ds-footer__col a:hover { color: var(--fg-dark-1); }

.ds-footer__base {
  max-width: 1200px;
  margin: 32px auto 0;
  padding-top: 20px;
  border-top: 1px solid var(--border-dark);
  font: var(--weight-regular) 11px/1.6 var(--font-mono);
  color: var(--fg-dark-3);
}

.ds-footer__base a {
  color: var(--fg-dark-2);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.ds-footer__base a:hover { border-bottom-color: var(--fg-dark-3); }

@media (max-width: 768px) {
  .ds-footer { padding: 32px 16px 24px; }
  .ds-footer__inner { grid-template-columns: 1fr; gap: 24px; }
  .ds-footer__base { font-size: 10px; }
}

/* ── Section sub-nav ──────────────────────────────────────────────────────
   The AI Companies section carries one primary nav button and three
   surfaces beneath it. This is the row that moves between them. Added
   2026-08-26 (wq-137): the three surfaces previously each held a primary
   nav slot, which read as three unrelated pages rather than one section.
   Distinct from companies.html's in-page .band-switch, which slices the
   Applications table and is not navigation. */
.section-subnav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
  margin: 0 0 20px;
  padding: 3px;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  width: fit-content;
  max-width: 100%;
}
.section-subnav__link {
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text-dim);
  text-decoration: none;
  white-space: nowrap;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
}
.section-subnav__link:hover { color: var(--text-bright); background: rgba(255, 255, 255, 0.05); }
.section-subnav__link.is-active { background: var(--accent); color: #fff; }
.section-subnav__link.is-active:hover { background: var(--accent); color: #fff; }
.section-subnav__link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 560px) {
  .section-subnav { width: 100%; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .section-subnav::-webkit-scrollbar { display: none; }
  .section-subnav__link { padding: 7px 11px; font-size: 12px; }
}
