/* ─────────────────────────────────────────────────────────────────────────
   Open Brain — Ask
   The approved direction is docs/ux/design-3-ask.html ("the ledger as a
   reference work"): editorial serif display, hairline rules, near-no cards,
   one cobalt accent spent on action and citation only. The tokens below are
   the SAME tokens the shell (app.html) and the docs handbook (docs/docs.css)
   declare, so the three surfaces read as one system. Self-contained — no
   external fonts, no CDN, nothing fetched at render time but our own JSON.
   ───────────────────────────────────────────────────────────────────────── */

:root {
  --ground:  #f8f8f7;
  --panel:   #ffffff;
  --sunk:    #efefee;
  --ink:     #111113;
  --ink-2:   #35363a;
  --muted:   #63656a;
  /* --faint is text, not decoration: eyebrows, .empty, .rnum, .rprov, .lensbody h4, .colmeta —
     every one under 13px, so normal text at 4.5:1. The old #8e9095 was 2.78:1 on --sunk. These
     values are the closest points on the same gray's hue line clearing 4.5:1 against the worst
     background in each theme (--sunk light, --panel dark). Mirrored in docs/docs.css + app.html. */
  --faint:   #6b6d72;
  --rule:    #e4e4e2;
  --rule-2:  #cfcfcc;
  --accent:  #1b4de4;
  --on-accent: #ffffff;
  --good:    #2e7346;
  --warn:    #8a6410;
  --crit:    #a8332a;

  --ff-display: "Hoefler Text", "Iowan Old Style", "Palatino Linotype", Palatino, Charter, Cambria, Georgia, serif;
  --ff-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ff-num: ui-monospace, "SF Mono", SFMono-Regular, "Cascadia Mono", "Liberation Mono", Menlo, Consolas, monospace;

  --col: 1084px;
  --read: 68ch;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0c0d10; --panel: #15171b; --sunk: #111318;
    --ink: #e9eaee; --ink-2: #c3c5cb; --muted: #8b8e96; --faint: #7d8088;
    --rule: #22252b; --rule-2: #333740;
    --accent: #7e9bff; --on-accent: #0c0d10;
    --good: #4fa96d; --warn: #c79a3e; --crit: #de6a60;
  }
}
:root[data-theme="dark"] {
  --ground: #0c0d10; --panel: #15171b; --sunk: #111318;
  --ink: #e9eaee; --ink-2: #c3c5cb; --muted: #8b8e96; --faint: #7d8088;
  --rule: #22252b; --rule-2: #333740;
  --accent: #7e9bff; --on-accent: #0c0d10;
  --good: #4fa96d; --warn: #c79a3e; --crit: #de6a60;
}
:root[data-theme="light"] {
  --ground: #f8f8f7; --panel: #ffffff; --sunk: #efefee;
  --ink: #111113; --ink-2: #35363a; --muted: #63656a; --faint: #6b6d72;
  --rule: #e4e4e2; --rule-2: #cfcfcc;
  --accent: #1b4de4; --on-accent: #ffffff;
  --good: #2e7346; --warn: #8a6410; --crit: #a8332a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--ff-ui);
  font-size: 15px;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
[hidden] { display: none !important; }
code, .num { font-family: var(--ff-num); font-variant-numeric: tabular-nums; }
code { font-size: .88em; }

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

/* ── shell ───────────────────────────────────────────────────────────── */
.wrap { max-width: var(--col); margin: 0 auto; padding: 0 28px; }

.masthead {
  border-bottom: 1px solid var(--rule);
  background: var(--ground);
  position: sticky; top: 0; z-index: 30;
}
.mastinner {
  max-width: var(--col); margin: 0 auto; padding: 0 28px;
  display: flex; align-items: center; gap: 26px; min-height: 62px; flex-wrap: wrap;
}
.wordmark { display: flex; align-items: baseline; gap: 9px; text-decoration: none; color: var(--ink); }
.wordmark b { font-family: var(--ff-display); font-size: 21px; font-weight: 600; letter-spacing: -.015em; }
.wordmark span {
  font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--faint); font-weight: 600;
}

.dest { display: flex; gap: 4px; margin-left: 6px; flex-wrap: wrap; }
.dest a {
  font-family: var(--ff-display); font-size: 17px; letter-spacing: -.01em;
  color: var(--muted); text-decoration: none;
  padding: 6px 12px 5px; border-bottom: 2px solid transparent; line-height: 1.3;
}
.dest a:hover { color: var(--ink); }
.dest a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

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

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11.5px; color: var(--muted); background: none;
  border: 1px solid var(--rule-2); border-radius: 2px;
  padding: 4px 9px; cursor: pointer; white-space: nowrap;
}
.chip:hover { border-color: var(--faint); color: var(--ink); }
.chip.plain { cursor: default; }
.chip.plain:hover { border-color: var(--rule-2); color: var(--muted); }

.ghost {
  background: none; border: 1px solid var(--rule-2); border-radius: 2px;
  padding: 4px 9px; font-size: 11.5px; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.ghost:hover { border-color: var(--faint); color: var(--ink); }

main { padding: 0 0 96px; min-height: 62vh; }

/* ── editorial typography ────────────────────────────────────────────── */
.eyebrow {
  font-family: var(--ff-num); font-size: 10.5px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--faint);
}
h2.opener {
  font-family: var(--ff-display); font-weight: 600;
  font-size: clamp(1.35rem, 2.6vw, 1.78rem); line-height: 1.15;
  letter-spacing: -.02em; margin: 0 0 6px; overflow-wrap: anywhere;
}
p.body { font-size: 15px; color: var(--ink-2); max-width: var(--read); margin: 0 0 12px; }
p.note { font-size: 13px; color: var(--muted); max-width: var(--read); margin: 0; }

section.sec { padding-top: 40px; }
section.sec > .sechead {
  border-top: 1px solid var(--rule-2); padding-top: 14px; margin-bottom: 20px;
}
section.sec > .sechead .eyebrow { display: block; margin-bottom: 9px; }

.empty { color: var(--faint); font-style: italic; }

/* ── the prompt ──────────────────────────────────────────────────────── */
.askzone { padding: clamp(34px, 7vw, 74px) 0 0; }
.prompt-label { display: block; margin-bottom: 14px; }
.askwrap { position: relative; }
.askline {
  display: flex; align-items: flex-end; gap: 14px;
  border-bottom: 2px solid var(--ink); padding-bottom: 12px;
}
.askline input {
  flex: 1; min-width: 0; border: 0; background: none; outline: none;
  font-family: var(--ff-display); font-weight: 500;
  font-size: clamp(1.5rem, 3.9vw, 2.4rem); line-height: 1.18;
  letter-spacing: -.022em; color: var(--ink); padding: 0;
}
.askline input::placeholder { color: var(--rule-2); }
/* once a question is in the field it settles to a readable size so long
   questions are never clipped mid-word by the action buttons */
.askline.has-q input { font-size: clamp(1.1rem, 2.35vw, 1.6rem); font-weight: 500; }
.askline .ghost { padding: 9px 14px; }
.askbtn {
  flex: none; border: 0; background: var(--accent); color: var(--on-accent);
  border-radius: 2px; padding: 9px 20px; font-size: 14px; font-weight: 600;
  cursor: pointer; letter-spacing: .01em;
}
.askbtn:hover { filter: brightness(1.08); }
.askhint {
  margin-top: 11px; display: flex; gap: 8px 18px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--faint);
}
.askhint kbd {
  font-family: var(--ff-num); font-size: 10.5px; border: 1px solid var(--rule-2);
  border-radius: 2px; padding: 0 4px; color: var(--muted);
}

/* ── symbol autocomplete ─────────────────────────────────────────────── */
.acbox {
  position: absolute; left: 0; right: 0; top: calc(100% + 2px); z-index: 20;
  margin: 0; padding: 4px 0; list-style: none;
  max-height: 320px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--rule-2); border-radius: 2px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .10);
}
.acbox li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 14px; align-items: baseline;
  padding: 7px 14px; cursor: pointer;
}
.acbox li[aria-selected="true"] { background: var(--sunk); }
.acbox .acname {
  font-family: var(--ff-num); font-size: 13px; color: var(--ink); overflow-wrap: anywhere;
}
.acbox .ackind {
  font-family: var(--ff-num); font-size: 10.5px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--faint); white-space: nowrap;
}
.acbox .acfile {
  grid-column: 1 / -1; font-family: var(--ff-num); font-size: 11px;
  color: var(--muted); overflow-wrap: anywhere;
}

/* ── answer ──────────────────────────────────────────────────────────── */
.answer { max-width: var(--read); }
.answer p { font-size: 16px; line-height: 1.65; color: var(--ink); margin: 0 0 14px; }
/* declared after `.answer p` on purpose — equal specificity, so source order decides */
.answer p.note { font-size: 13px; color: var(--muted); }
.answermeta {
  margin-top: 4px; font-family: var(--ff-num); font-size: 11.5px;
  color: var(--faint); letter-spacing: .02em;
}

/* ── results ─────────────────────────────────────────────────────────── */
.results { border-top: 1px solid var(--rule-2); }
.res { border-bottom: 1px solid var(--rule); padding: 18px 0 14px; }
.reshead { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 4px; }
.rnum { font-family: var(--ff-num); font-size: 11.5px; color: var(--faint); padding-top: 4px; }
.rpath {
  font-family: var(--ff-num); font-size: 12.5px;
  overflow-wrap: anywhere; line-height: 1.45;
}
.rpath a { color: var(--accent); text-decoration: none; }
.rpath a:hover { text-decoration: underline; }
.rpath .lines { color: var(--muted); }
.rint { margin: 5px 0 9px; font-size: 14.5px; color: var(--ink); max-width: 64ch; line-height: 1.55; }
.rmeta { display: flex; flex-wrap: wrap; gap: 6px; }
.rprov {
  margin-top: 8px; font-family: var(--ff-num); font-size: 11.5px;
  color: var(--faint); display: flex; flex-wrap: wrap; gap: 4px 14px;
}

.tag {
  font-family: var(--ff-num); font-size: 10.5px; letter-spacing: .03em;
  padding: 2px 7px; border: 1px solid var(--rule); border-radius: 2px;
  color: var(--muted); background: var(--panel); white-space: nowrap;
}
.tag.good { color: var(--good); border-color: var(--good); }
.tag.warn { color: var(--warn); border-color: var(--warn); }
.tag.crit { color: var(--crit); border-color: var(--crit); }
.tag.sans { font-family: var(--ff-ui); font-size: 11.5px; letter-spacing: 0; }

.lenses {
  margin: 12px 0 0 34px; display: flex; flex-wrap: wrap; gap: 2px;
  border-top: 1px solid var(--rule); padding-top: 8px;
}
.lens {
  background: none; border: 0; cursor: pointer; padding: 4px 10px 3px;
  font-size: 12px; color: var(--muted); border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.lens:first-child { padding-left: 0; }
.lens:hover { color: var(--ink); }
.lens[aria-expanded="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.lensbody {
  margin: 0 0 2px 34px; background: var(--sunk); border: 1px solid var(--rule);
  border-radius: 2px; padding: 15px 17px; font-size: 13.5px; color: var(--ink-2);
}
.lensbody h4 {
  margin: 0 0 8px; font-size: 11px; letter-spacing: .13em; text-transform: uppercase;
  color: var(--faint); font-family: var(--ff-num); font-weight: 500;
}
.lensbody p { margin: 0 0 9px; max-width: 62ch; line-height: 1.55; }
.lensbody p:last-child { margin-bottom: 0; }
.lensbody pre {
  margin: 0; background: var(--panel); border: 1px solid var(--rule); border-radius: 2px;
  padding: 11px 13px; font-family: var(--ff-num); font-size: 12px; line-height: 1.55;
  overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink-2);
}
.edge {
  display: grid; grid-template-columns: 116px minmax(0, 1fr); gap: 10px;
  padding: 5px 0; border-bottom: 1px dotted var(--rule-2); align-items: baseline;
}
.edge:last-of-type { border-bottom: 0; }
.edge .ek {
  font-family: var(--ff-num); font-size: 10.5px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--faint);
}
.edge .ev { font-family: var(--ff-num); font-size: 12px; overflow-wrap: anywhere; }

/* ── starters ────────────────────────────────────────────────────────── */
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 26px 34px; }
.gcard { border-top: 2px solid var(--ink); padding-top: 12px; }
.gcard .gname { font-family: var(--ff-display); font-size: 1.18rem; letter-spacing: -.015em; margin: 0 0 3px; font-weight: 600; }
.gcard p { font-size: 13.5px; color: var(--ink-2); margin: 0 0 12px; line-height: 1.55; }

/* ── colophon ────────────────────────────────────────────────────────── */
.colophon { border-top: 1px solid var(--rule-2); background: var(--ground); padding: 26px 0 54px; }
.colinner {
  max-width: var(--col); margin: 0 auto; padding: 0 28px;
  display: flex; gap: 14px 28px; flex-wrap: wrap; align-items: baseline;
}
.colinner .util { display: flex; gap: 4px; flex-wrap: wrap; }
.colinner .util a {
  font-size: 13px; color: var(--muted); text-decoration: none;
  padding: 3px 9px; border-right: 1px solid var(--rule);
}
.colinner .util a:last-child { border-right: 0; }
.colinner .util a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.colmeta {
  margin-left: auto; font-family: var(--ff-num); font-size: 11.5px;
  font-variant-numeric: tabular-nums; color: var(--faint); text-align: right;
}

/* ── responsive ──────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .two { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .wrap, .mastinner, .colinner { padding-left: 18px; padding-right: 18px; }
  .mastinner { min-height: 0; padding-top: 12px; padding-bottom: 10px; gap: 12px; }
  .dest { margin-left: 0; order: 3; width: 100%; border-top: 1px solid var(--rule); padding-top: 4px; }
  .dest a { padding-left: 0; padding-right: 18px; }
  .mastright { margin-left: auto; }
  .lenses, .lensbody { margin-left: 0; }
  .reshead { grid-template-columns: 1fr; }
  .rnum { padding-top: 0; }
  .edge { grid-template-columns: 1fr; gap: 1px; }
  .colmeta { margin-left: 0; text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}
