/* The AI Dictionary — the vocabulary of modern AI, in plain English.
 *
 * Shares the paper, type and sidebar of the other AI apps (Rise of the
 * Personal Agent, the API timelines): Instrument Serif for headings, IBM Plex
 * Sans to read, Plex Mono for labels. The sidebar holds search and the
 * contents; the main column reads like a book, one entry after another.
 */
:root {
  --paper: #f5f3ec;
  --card: #fbfaf6;
  --card-strong: #fffefb;
  --ink: #1c1b18;
  --ink-2: #4f4c45;
  --ink-3: #847f74;
  --rule: #dad5c9;
  --rule-soft: #e8e4d9;
  --accent: #a64f2a;
  --accent-soft: #f4e3d6;
  --wash: rgba(28, 27, 24, 0.045);

  --serif: "Instrument Serif", Georgia, serif;
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --side-w: 320px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-padding-top: calc(var(--appnav-h, 0px) + 20px); }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
button, input { font: inherit; color: inherit; }
code { font-family: var(--mono); font-size: 0.88em; background: var(--wash); padding: 0.05em 0.3em; border-radius: 3px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

/* ---------- layout ---------- */

.layout { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); max-width: 1500px; margin: 0 auto; }

.side {
  position: sticky;
  top: var(--appnav-h, 0px);
  height: calc(100vh - var(--appnav-h, 0px));
  height: calc(100dvh - var(--appnav-h, 0px));
  border-right: 1px solid var(--rule-soft);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.side-inner { padding: 1.3rem 1.2rem 2rem 1.35rem; }
.kicker { font-family: var(--mono); font-size: 0.64rem; font-weight: 500; letter-spacing: 0.11em; text-transform: uppercase; color: var(--ink-3); }
.wordmark { margin-top: 0.3rem; font-family: var(--serif); font-weight: 400; font-size: 2.6rem; line-height: 0.98; letter-spacing: -0.01em; }
.wordmark em { font-style: italic; color: var(--accent); }
.lede { margin-top: 0.7rem; font-size: 0.84rem; line-height: 1.55; color: var(--ink-2); }
.lede em { color: var(--ink); }

.search { margin-top: 1rem; }
#q {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: 7px;
  background: var(--card-strong);
  font-size: 0.88rem;
}
#q:focus { outline: none; border-color: var(--ink-3); box-shadow: 0 0 0 3px var(--wash); }
.search-n { margin-top: 0.3rem; min-height: 1rem; font-family: var(--mono); font-size: 0.64rem; color: var(--ink-3); }

.seg { display: inline-flex; margin-top: 0.4rem; border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; }
.seg button { font-size: 0.74rem; font-weight: 500; padding: 0.22rem 0.7rem; border: 0; background: var(--card); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--rule); }
.seg button:hover { background: var(--wash); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.toc { margin-top: 1rem; }
.toc-l { list-style: none; }
.toc-s { margin-top: 0.7rem; }
.toc-s.empty { display: none; }
.toc-h { display: flex; gap: 0.45rem; align-items: baseline; font-size: 0.8rem; font-weight: 600; color: var(--ink); text-decoration: none; }
.toc-h span { font-family: var(--mono); font-size: 0.62rem; font-weight: 500; color: var(--ink-3); min-width: 0.9rem; }
.toc-h:hover { color: var(--accent); }
.toc-t { list-style: none; display: flex; flex-wrap: wrap; gap: 0.1rem 0.15rem; margin: 0.25rem 0 0 1.35rem; }
.toc-t a {
  display: inline-block;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--ink-2);
  text-decoration: none;
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
}
.toc-t a:hover { background: var(--wash); color: var(--ink); }
.toc-t a.on { background: var(--ink); color: var(--paper); }

/* ---------- the reading column ---------- */

.main { min-width: 0; padding: 0 1.6rem 2rem 2.4rem; }
#entries { max-width: 44rem; }

.sec { padding-top: 2.6rem; scroll-margin-top: var(--appnav-h, 0px); }
.sec-n { font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.1em; color: var(--ink-3); }
.sec-h { font-family: var(--serif); font-weight: 400; font-size: 2.4rem; line-height: 1.02; margin-top: 0.1rem; }
.sec-h em { font-style: italic; color: var(--accent); }
.sec-i { margin-top: 0.45rem; color: var(--ink-2); font-size: 1rem; max-width: 38rem; padding-bottom: 0.6rem; border-bottom: 1px solid var(--ink); }

.entry { padding: 1.6rem 0 1.5rem; border-bottom: 1px solid var(--rule); }
.entry.flash { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }
.e-k { font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.08em; text-transform: uppercase; }
.e-k a { color: var(--ink-3); text-decoration: none; }
.e-k a:hover { color: var(--accent); }
.entry h3 { margin-top: 0.15rem; font-family: var(--serif); font-weight: 400; font-size: 2rem; line-height: 1.05; }
.entry h3 a { color: var(--ink); text-decoration: none; }
.entry h3 a:hover { color: var(--accent); }
.aka { margin-top: 0.15rem; font-size: 0.8rem; color: var(--ink-3); font-style: italic; }
.desc { margin-top: 0.45rem; font-size: 1.06rem; font-weight: 500; line-height: 1.5; color: var(--ink); }
.body { margin-top: 0.6rem; }
.body p { margin-top: 0.7rem; color: #2d2b27; }
.body p:first-child { margin-top: 0; }
.body strong { font-weight: 600; }
.xref { color: var(--ink); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 55%, transparent); text-decoration-style: dotted; text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.xref:hover { color: var(--accent); text-decoration-style: solid; }

.tbl { margin-top: 0.8rem; overflow-x: auto; }
.tbl table { border-collapse: collapse; width: 100%; font-size: 0.86rem; line-height: 1.45; }
.tbl th, .tbl td { text-align: left; vertical-align: top; padding: 0.4rem 0.8rem 0.4rem 0; border-bottom: 1px solid var(--rule-soft); }
.tbl thead th { font-family: var(--mono); font-size: 0.6rem; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); border-bottom-color: var(--rule); }
.tbl tbody th { font-weight: 600; white-space: nowrap; }

.usage { margin-top: 1rem; padding: 0.7rem 0.9rem 0.75rem; background: var(--card); border: 1px solid var(--rule-soft); border-radius: 8px; }
.u-k, .lbl { font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); }
.u-q, .u-a { margin-top: 0.3rem; font-size: 0.92rem; line-height: 1.5; padding-left: 1.4rem; position: relative; }
.u-q::before, .u-a::before { position: absolute; left: 0; top: 0.05rem; font-family: var(--mono); font-size: 0.66rem; font-weight: 600; }
.u-q::before { content: "Q"; color: var(--ink-3); }
.u-a::before { content: "A"; color: var(--accent); }
.u-q { color: var(--ink-2); font-style: italic; }

.lw { margin-top: 1rem; border-left: 3px solid var(--accent); padding: 0.1rem 0 0.1rem 0.9rem; }
.lw blockquote { font-family: var(--serif); font-size: 1.22rem; line-height: 1.3; }
.lw figcaption { margin-top: 0.3rem; font-family: var(--mono); font-size: 0.64rem; color: var(--ink-3); }
.lw figcaption a { color: var(--ink-2); }

.e-f { margin-top: 0.9rem; display: grid; gap: 0.4rem; }
.see { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.3rem 0.35rem; }
.see .lbl { margin-right: 0.3rem; }
.see a {
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  background: var(--card-strong);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.08rem 0.55rem;
}
.see a::after { content: " →"; color: var(--accent); }
.see a:hover { border-color: var(--accent); }
.src { font-size: 0.76rem; line-height: 1.5; color: var(--ink-2); }
.src .lbl { margin-right: 0.5rem; }
.src a { color: var(--ink); text-decoration-color: var(--rule); }
.src .pub { color: var(--ink-3); }

.none { margin-top: 2rem; color: var(--ink-3); font-style: italic; }

/* ---------- A–Z ---------- */

.az { padding-top: 2.4rem; }
.az-l { margin-top: 0.8rem; }
.az-letter { margin-top: 1.4rem; font-family: var(--serif); font-size: 1.8rem; line-height: 1; color: var(--accent); border-bottom: 1px solid var(--rule); padding-bottom: 0.2rem; }
.az-t { margin-top: 0.7rem; font-weight: 600; }
.az-t a { color: var(--ink); text-decoration: none; }
.az-t a:hover { color: var(--accent); }
.az-t span { font-family: var(--mono); font-size: 0.58rem; font-weight: 400; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); margin-left: 0.4rem; }
.az-l dd { font-size: 0.9rem; color: var(--ink-2); line-height: 1.5; }

.colophon { max-width: 44rem; margin-top: 2.6rem; font-size: 0.76rem; color: var(--ink-3); line-height: 1.6; }

/* ---------- tooltip ---------- */

.tip {
  position: fixed;
  z-index: 4000;
  max-width: 19rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: 7px;
  padding: 0.5rem 0.7rem 0.55rem;
  font-size: 0.8rem;
  line-height: 1.45;
  box-shadow: 0 12px 28px -12px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}
.tip b { font-weight: 600; font-size: 0.9rem; }
.tip .tip-k { font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.08em; text-transform: uppercase; color: #bdb8ac; margin-bottom: 0.1rem; }
.tip .tip-d { margin-top: 0.15rem; color: #dcd8cd; }
.tip em { color: var(--paper); }

/* ---------- narrower screens: the sidebar moves above ---------- */

@media (max-width: 899px) {
  .layout { display: block; }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--rule-soft); overflow: visible; }
  .side-inner { padding: 1.2rem 1rem 1rem; }
  .toc-t { display: none; }
  .toc-l { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0 1rem; }
  .toc-s { margin-top: 0.35rem; }
  .main { padding: 0 1rem 2rem; }
  .sec-h { font-size: 2rem; }
  .entry h3 { font-size: 1.75rem; }
}
@media (prefers-reduced-motion: reduce) {
  .entry.flash { animation: none; }
}

/* ---------- the knowledge graph (wide screens) ---------- */

.graph { display: none; }
@media (min-width: 1300px) {
  .layout { grid-template-columns: var(--side-w) minmax(0, 1fr) 316px; max-width: 1640px; }
  .graph {
    display: block;
    position: sticky;
    top: var(--appnav-h, 0px);
    height: calc(100vh - var(--appnav-h, 0px));
    height: calc(100dvh - var(--appnav-h, 0px));
    border-left: 1px solid var(--rule-soft);
    overflow-y: auto;
    scrollbar-width: thin;
  }
}
.graph-inner { padding: 1.3rem 1.1rem 1.6rem 1.1rem; }
.g-term { margin-top: 0.25rem; font-family: var(--serif); font-weight: 400; font-size: 1.7rem; line-height: 1.05; }
.g-term a { color: var(--ink); text-decoration: none; }
.g-term a:hover { color: var(--accent); }
.g-sum { margin-top: 0.3rem; font-family: var(--mono); font-size: 0.62rem; line-height: 1.6; color: var(--ink-3); letter-spacing: 0.02em; }
.g-sum span { text-transform: uppercase; letter-spacing: 0.08em; }
#g-local { margin-top: 0.6rem; }
.g-svg { display: block; width: 100%; height: auto; overflow: visible; }
.g-side { font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.08em; text-transform: uppercase; fill: var(--ink-3); }
.g-label { font-family: var(--sans); font-size: 10.5px; fill: var(--ink-2); }
.g-more { font-family: var(--mono); font-size: 9px; fill: var(--ink-3); }
.g-node { cursor: pointer; }
.g-node:hover .g-label { fill: var(--accent); }
.g-node:hover circle { stroke: var(--ink); stroke-width: 1.2; }
.g-edge { fill: none; stroke: var(--rule); stroke-width: 1; }
.g-edge.out { stroke: color-mix(in srgb, var(--accent) 55%, transparent); }
.g-edge.in { stroke: color-mix(in srgb, var(--ink-3) 60%, transparent); stroke-dasharray: 2 2; }
.g-edge.both { stroke-dasharray: none; }
.g-center { stroke: var(--paper); stroke-width: 2; }
.g-map-k { margin-top: 1.4rem; }
#g-map { margin-top: 0.4rem; }
.g-col { font-family: var(--mono); font-size: 8px; fill: var(--ink-3); text-anchor: middle; }
#g-map circle { stroke: var(--paper); stroke-width: 1; transition: opacity 0.15s; }
#g-map circle.far { opacity: 0.22; }
#g-map circle.cur { stroke: var(--ink); stroke-width: 1.5; }
#g-map .g-edge { stroke-width: 0.9; }
.g-note { margin-top: 0.6rem; font-size: 0.7rem; line-height: 1.5; color: var(--ink-3); }

/* ---------- the map view ---------- */

.toc-h[data-sec] span { color: var(--c); }
body.mapping #entries { max-width: none; }
body.mapping .colophon { display: none; }
.mapv { padding-top: 1rem; }
.m-wrap { display: grid; grid-template-columns: 12.5rem minmax(0, 1fr); background: var(--card); border: 1px solid var(--rule-soft); border-radius: 10px; overflow: hidden; }
.m-key { padding: 0.6rem; border-right: 1px solid var(--rule-soft); background: var(--card-strong); }
.m-seg { display: flex; border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; }
.m-seg button { flex: 1; font-size: 0.72rem; font-weight: 500; padding: 0.2rem 0.4rem; border: 0; background: var(--card); cursor: pointer; }
.m-seg button + button { border-left: 1px solid var(--rule); }
.m-seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.m-key-l { list-style: none; margin-top: 0.5rem; }
.m-key-l li { display: flex; align-items: center; gap: 0.4rem; padding: 0.12rem 0.25rem; border-radius: 4px; font-size: 0.74rem; line-height: 1.35; color: var(--ink-2); cursor: default; }
.m-key-l li:hover { background: var(--wash); color: var(--ink); }
.m-key-l i { flex: none; width: 0.55rem; height: 0.55rem; border-radius: 50%; }
.m-key-l span { margin-left: auto; font-family: var(--mono); font-size: 0.62rem; color: var(--ink-3); }
.m-topic {
  font-family: var(--serif); font-style: italic; font-size: 17px; text-anchor: middle; fill: var(--ink);
  paint-order: stroke; stroke: var(--card); stroke-width: 4px; stroke-linejoin: round; pointer-events: none; transition: opacity 0.15s;
}
.m-svg.focus .m-topic { opacity: 0.25; }
.m-svg.sec-focus .m-topic:not(.in-sec) { opacity: 0.15; }
@media (max-width: 899px) {
  .m-wrap { grid-template-columns: minmax(0, 1fr); }
  .m-key { grid-row: 2; border-right: 0; border-top: 1px solid var(--rule-soft); }
  .m-key-l { display: flex; flex-wrap: wrap; gap: 0 0.4rem; }
}
.m-svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100dvh - var(--appnav-h, 0px) - 6.5rem);
}
.m-node { cursor: pointer; }
.m-node circle { stroke: var(--card); stroke-width: 1.2; transition: opacity 0.15s; }
.m-label { font-family: var(--sans); font-size: 11px; fill: var(--ink-2); pointer-events: none; transition: opacity 0.15s; }
.m-node.hide-label .m-label { opacity: 0; }
.m-node:hover .m-label, .m-node.on .m-label, .m-node.nb .m-label { opacity: 1; fill: var(--ink); }
.m-node.on circle { stroke: var(--ink); stroke-width: 2; }
.m-node.on .m-label { font-weight: 600; }
.m-svg.focus .m-node:not(.on):not(.nb), .m-node.dim { opacity: 0.2; }
.m-svg.sec-focus .m-node:not(.in-sec) { opacity: 0.15; }
.m-node.hit .m-label { opacity: 1; fill: var(--ink); font-weight: 600; }
.m-edge { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 2; }
.m-note { margin-top: 0.6rem; max-width: 46rem; font-size: 0.78rem; line-height: 1.55; color: var(--ink-3); }
.see.near .near-map { font-family: var(--mono); font-size: 0.66rem; color: var(--ink-3); }
.see.near a::after { content: ""; }
.see.near a.near-map { background: none; border: 0; padding: 0 0.2rem; text-decoration: underline; text-decoration-color: var(--rule); }
/* The map takes the graph column's room; hovering a term shows its links. */
@media (min-width: 1300px) {
  body.mapping .layout { grid-template-columns: var(--side-w) minmax(0, 1fr); }
  body.mapping .graph { display: none; }
}
