/* ==========================================================================
   AA light design system — shared tokens, top navigation, evidence bands.
   Single source of truth for the whole product. Every page links this file
   (relative path) BEFORE its own stylesheet; local sheets alias their
   legacy variable names to these tokens.
   Contrast: every text token passes WCAG AA (>=4.5:1) on its ground;
   body ink passes AAA (16.2:1 on --aa-ground). Verified 2026-08-04.
   ========================================================================== */

:root {
  color-scheme: light;

  /* Grounds */
  --aa-ground: #faf8f3;        /* warm off-white page ground */
  --aa-surface: #ffffff;       /* cards, panels */
  --aa-surface-2: #f2eee5;     /* recessed panels, code, table heads */

  /* Ink */
  --aa-ink: #1e1b16;           /* body text — 16.2:1 on ground */
  --aa-ink-2: #45403a;         /* secondary text — 9.7:1 */
  --aa-muted: #5f574c;         /* captions, labels — 6.7:1 */
  --aa-faint: #7a7163;         /* metadata — 4.5:1, small print floor */

  /* Rules */
  --aa-rule: #e3ddcf;          /* hairlines */
  --aa-rule-strong: #d4ccba;   /* emphatic borders */

  /* Accents — used to carry meaning, not decoration */
  --aa-accent: #4a3aa8;        /* links, interactive — 8.0:1 on ground */
  --aa-accent-2: #3a2d8c;      /* hover / deeper */
  --aa-accent-tint: #ece9f6;   /* selected nav, soft highlight */
  --aa-gold: #7a5c0d;          /* eyebrows, key figures — 5.9:1 */
  --aa-gold-tint: #f7edd5;

  /* Semantic status */
  --aa-info: #1d4fa1;
  --aa-ok: #1a7a43;
  --aa-warn: #7a5a06;
  --aa-bad: #9e2338;

  /* Evidence confidence bands — ink / tint / border per band.
     Hues stay in the original ladder order: green > teal > amber > orange > red. */
  --aa-documented: #1a7a43;
  --aa-documented-tint: #e7f3ea;
  --aa-documented-line: #a5ccb5;

  --aa-well: #0a5e6b;          /* well-supported */
  --aa-well-tint: #e1eef0;
  --aa-well-line: #9cc0c5;

  --aa-contested: #7a5a06;
  --aa-contested-tint: #f7edd5;
  --aa-contested-line: #cfbe93;

  /* Thin pushed further into orange-red so it does not collapse into contested amber. */
  --aa-thin: #a83200;
  --aa-thin-tint: #f9e6d8;
  --aa-thin-line: #e0a888;

  --aa-unsupported: #9e2338;
  --aa-unsupported-tint: #f8e4e8;
  --aa-unsupported-line: #dba6b0;

  /* Claim classes alias the ladder, as in the original dark scheme:
     FACT = supported teal, INFERENCE = contested amber, SPECULATION = unsupported red. */
  --aa-fact: var(--aa-well);
  --aa-fact-tint: var(--aa-well-tint);
  --aa-fact-line: var(--aa-well-line);
  --aa-inference: var(--aa-contested);
  --aa-inference-tint: var(--aa-contested-tint);
  --aa-inference-line: var(--aa-contested-line);
  --aa-speculation: var(--aa-unsupported);
  --aa-speculation-tint: var(--aa-unsupported-tint);
  --aa-speculation-line: var(--aa-unsupported-line);

  /* Type */
  --aa-serif: Georgia, "Times New Roman", serif;
  --aa-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  --aa-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --aa-nav-h: 52px;
}

/* Focus must be visible everywhere — these are decision surfaces. */
:focus-visible {
  outline: 2px solid var(--aa-accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ==========================================================================
   Top navigation — one product, every page.
   ========================================================================== */

.aa-nav {
  position: relative;
  z-index: 1200;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  min-height: var(--aa-nav-h);
  padding: 6px 20px;
  background: var(--aa-ground);
  border-bottom: 1px solid var(--aa-rule);
  font-family: var(--aa-sans);
  font-size: 14px;
  line-height: 1.4;
}
.aa-nav *, .aa-nav *::before, .aa-nav *::after { box-sizing: border-box; }

.aa-nav__brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-right: 14px;
  padding: 6px 8px 6px 0;
  text-decoration: none;
  color: var(--aa-ink);
  white-space: nowrap;
}
.aa-nav__mark {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--aa-rule-strong);
  border-radius: 8px;
  background: var(--aa-surface);
  color: var(--aa-gold);
  font-family: var(--aa-serif);
  font-size: 13px;
}
.aa-nav__brand b { font-size: 13.5px; font-weight: 650; letter-spacing: .01em; }
.aa-nav__brand small {
  display: block;
  color: var(--aa-muted);
  font-size: 10.5px;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.aa-nav__links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
}
.aa-nav__links > a,
.aa-nav__group > summary {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--aa-ink-2);
  font-size: 13.5px;
  text-decoration: none;
  cursor: pointer;
  list-style: none;
  user-select: none;
  background: none;
  font-family: inherit;
}
.aa-nav__links > a:hover,
.aa-nav__group > summary:hover {
  color: var(--aa-ink);
  background: var(--aa-surface-2);
}
.aa-nav__links > a[aria-current="page"],
.aa-nav__group > summary.aa-nav__current {
  color: var(--aa-accent-2);
  background: var(--aa-accent-tint);
  border-color: var(--aa-rule);
  font-weight: 600;
}
.aa-nav__group > summary::-webkit-details-marker { display: none; }
.aa-nav__group > summary::after {
  content: "";
  width: 6px; height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  opacity: .6;
}
.aa-nav__group { position: relative; }
.aa-nav__group[open] > summary {
  color: var(--aa-ink);
  background: var(--aa-surface-2);
}
.aa-nav__menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 230px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--aa-surface);
  border: 1px solid var(--aa-rule);
  border-radius: 12px;
  box-shadow: 0 14px 40px rgba(30, 27, 22, .14);
}
.aa-nav__menu a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--aa-ink-2);
  font-size: 13.5px;
  text-decoration: none;
}
.aa-nav__menu a:hover { background: var(--aa-surface-2); color: var(--aa-ink); }
.aa-nav__menu a[aria-current="page"] {
  color: var(--aa-accent-2);
  background: var(--aa-accent-tint);
  font-weight: 600;
}
.aa-nav__menu a small { color: var(--aa-faint); font-size: 11px; }

/* External + not-yet-published destinations */
.aa-nav a .aa-nav__ext { font-size: 11px; color: var(--aa-faint); }
.aa-nav a.is-missing {
  color: var(--aa-faint);
  cursor: default;
  text-decoration: none;
}
.aa-nav a.is-missing:hover { background: none; color: var(--aa-faint); }
.aa-nav a.is-missing .aa-nav__soon {
  font-size: 9.5px;
  font-family: var(--aa-mono);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--aa-faint);
  border: 1px dashed var(--aa-rule-strong);
  border-radius: 999px;
  padding: 1px 6px;
}

@media (max-width: 760px) {
  .aa-nav { padding: 6px 12px; gap: 2px 6px; }
  .aa-nav__brand { margin-right: 6px; }
  .aa-nav__brand small { display: none; }
  .aa-nav__group { position: static; }
  .aa-nav__menu {
    left: 8px;
    right: 8px;
    min-width: 0;
  }
}

/* ==========================================================================
   Evidence badges — opt-in utility for any page.
   ========================================================================== */

.aa-badge {
  display: inline-block;
  font-family: var(--aa-mono);
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 3px 9px;
  border: 1px solid;
  white-space: nowrap;
}
/* A badge is sometimes a link to the rubric that produced it. It must keep the band's
   colour rather than inherit the page link colour, or the band stops being readable at
   a glance — which is the only thing a badge is for. */
a.aa-badge { text-decoration: none; }
a.aa-badge:hover { filter: brightness(0.94); border-style: solid; }
a.aa-badge:focus-visible { outline: 2px solid var(--aa-accent); outline-offset: 2px; }
.aa-badge--documented,
.aa-badge--fact        { color: var(--aa-documented); background: var(--aa-documented-tint); border-color: var(--aa-documented-line); }
.aa-badge--well-supported { color: var(--aa-well);   background: var(--aa-well-tint);   border-color: var(--aa-well-line); }
.aa-badge--contested,
.aa-badge--inference   { color: var(--aa-contested); background: var(--aa-contested-tint); border-color: var(--aa-contested-line); }
.aa-badge--thin        { color: var(--aa-thin);      background: var(--aa-thin-tint);      border-color: var(--aa-thin-line); }
.aa-badge--unsupported,
.aa-badge--speculation { color: var(--aa-unsupported); background: var(--aa-unsupported-tint); border-color: var(--aa-unsupported-line); }

@media print {
  .aa-nav { display: none; }
}
