/* ==========================================================================
   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;
  }
  /* Each row is a label and a descriptor held apart by space-between. A flex item will not
     shrink below its own content, so on a 374px panel the pair simply ran past the edge and the
     descriptor was clipped — measured on the résumé, 21px of "investor research" was gone. It
     wraps to a second line now, and only when it has to: the descriptor is the half a reader
     chooses by, so truncating it with an ellipsis would have been the wrong trade. */
  .aa-nav__menu a { flex-wrap: wrap; gap: 2px 12px; }
}

/* ==========================================================================
   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; }

/* Skill / company chips. Small, reusable on story cards, article headers, and /tags/. */
.ab7-tags { display: flex; flex-wrap: wrap; gap: 6px; list-style: none;
  margin: 10px 0 0; padding: 0; }
.ab7-tag { display: inline-block; font: 600 11px/1 var(--aa-sans);
  letter-spacing: .03em; padding: 5px 9px; border-radius: 999px;
  border: 1px solid var(--aa-rule); background: #fff; color: var(--aa-ink);
  text-decoration: none; }
a.ab7-tag { border-bottom: 0; color: inherit; }
.ab7-tag--skill { border-color: color-mix(in srgb, var(--aa-accent) 30%, var(--aa-rule));
  color: var(--aa-accent); }
.ab7-tag--co { color: var(--aa-muted); }
a.ab7-tag:hover { border-color: var(--aa-accent); color: var(--aa-accent); }
.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); }

/* Phone width. Measured 2026-08-06 by loading every page in a 390px iframe and comparing
   scrollWidth against it: five pages pushed the document sideways — /method/ by 86px,
   /news/triage/ by 90px, /cases/moon-arena/ by 158px — and the culprit was a table every time
   except one long unbreakable token on /verification/. A page that scrolls horizontally on a
   phone reads as broken regardless of what it says, and this is a link someone will open on a
   phone first.

   A table becomes its own scroll container rather than reflowing into stacked rows. These are
   comparison tables — two standards side by side, eight scoring components — and a stacked
   card loses the column alignment that is the entire reason the data is in a table. Swiping a
   table sideways is understood; a comparison you can no longer compare is not. */
@media (max-width: 640px) {
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  /* `anywhere` and not `break-word`: the strings that overflow here are hashes, commit ids and
     bare URLs with no space in them, which is exactly the case `break-word` declines to break. */
  code, pre, .aa-mono { overflow-wrap: anywhere; }
  pre { overflow-x: auto; }
  /* And the same for prose, because the worst offender was not in a code span at all: a bare
     citation URL sitting in an ordinary <li> on the Moon Arena page pushed the document to 548px.
     A source is cited by its full address on purpose, so the fix is to let it wrap, not to
     shorten it. This only ever fires on a word that would otherwise overflow the line. */
  p, li, dd, td, th, blockquote, figcaption { overflow-wrap: break-word; }
}

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

/* ---- Read next (apply_readnext.py) ------------------------------------
   The standard end of every essay and case page: a banner to the next part
   when one exists, then the other essays and cases. Markup is generated —
   edit the script, not the pages. */
.aa-next{max-width:880px;margin:72px auto 40px;padding:0 24px;font-family:var(--aa-sans)}
.aa-next__banner{display:block;padding:26px 28px;border:1px solid var(--aa-rule-strong);
  border-radius:16px;background:var(--aa-surface);text-decoration:none;
  box-shadow:0 14px 40px rgba(30,27,22,.08);transition:border-color .15s ease,transform .15s ease}
.aa-next__banner:hover{border-color:var(--aa-accent);transform:translateY(-2px)}
.aa-next__banner small{display:block;font:600 11px/1 var(--aa-mono);letter-spacing:.14em;
  text-transform:uppercase;color:var(--aa-accent);margin:0 0 10px}
.aa-next__banner b{display:block;font:700 22px/1.3 var(--aa-sans);color:var(--aa-ink);margin:0 0 10px}
.aa-next__cta{font:600 14px/1 var(--aa-sans);color:var(--aa-accent)}
.aa-next__t{font:600 11px/1 var(--aa-mono);letter-spacing:.14em;text-transform:uppercase;
  color:var(--aa-faint);margin:34px 0 14px}
.aa-next__banner+.aa-next__more .aa-next__t{margin-top:30px}
.aa-next__grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(230px,1fr));gap:12px}
.aa-next__grid a{display:block;padding:16px 18px;border:1px solid var(--aa-rule);border-radius:12px;
  background:var(--aa-surface);text-decoration:none;transition:border-color .15s ease}
.aa-next__grid a:hover{border-color:var(--aa-accent)}
.aa-next__grid small{display:block;font:600 10px/1 var(--aa-mono);letter-spacing:.12em;
  text-transform:uppercase;color:var(--aa-faint);margin:0 0 8px}
.aa-next__grid b{display:block;font:600 15px/1.35 var(--aa-sans);color:var(--aa-ink);margin:0 0 6px}
.aa-next__grid span{display:block;font:400 12.5px/1.5 var(--aa-sans);color:var(--aa-ink-2)}
@media (max-width:520px){.aa-next{padding:0 18px;margin-top:56px}.aa-next__banner b{font-size:19px}}
@media print{.aa-next{display:none}}
