/* Palette and type: Barlow Semi Condensed headings, IBM Plex text and mono. */
:root {
  --ground: #f7f8fa;
  --surface: #ffffff;
  --sunken: #eef1f4;
  --ink: #16202b;
  --muted: #5b6876;
  --faint: #8b97a3;
  --rule: #dde3e9;
  --accent: #0e6e6e;
  --accent-soft: #e2efee;

  --display: "Barlow Semi Condensed", "Arial Narrow", sans-serif;
  --body: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Courier New", monospace;
  --topbar: 3.25rem;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #11171d;
    --surface: #182028;
    --sunken: #1d262f;
    --ink: #e6ecf1;
    --muted: #a0adb9;
    --faint: #74828f;
    --rule: #2a343e;
    --accent: #4fc3bd;
    --accent-soft: #16302f;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 16px/1.6 var(--body);
}
a { color: var(--accent); }

/* ---- frame ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 1;
  height: var(--topbar);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
}
.brand {
  font: 700 1.2rem var(--display);
  letter-spacing: 0.02em;
  color: var(--ink);
  text-decoration: none;
}

.layout {
  display: grid;
  grid-template-columns: 16rem minmax(0, 1fr) 15rem;
  gap: 3rem;
  max-width: 92rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}
.layout.solo { grid-template-columns: minmax(0, 1fr); max-width: 64rem; }

main { min-width: 0; padding-block: 2rem 5rem; }

.sidebar, .toc {
  position: sticky;
  top: var(--topbar);
  align-self: start;
  max-height: calc(100vh - var(--topbar));
  overflow-y: auto;
  padding-block: 1.25rem 2rem;
  font-size: 0.85rem;
}
.sidebar h2, .toc h2 {
  margin: 1.25rem 0 0.4rem;
  font: 500 0.7rem var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
}
.sidebar a {
  display: block;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  line-height: 1.35;
  color: var(--muted);
  text-decoration: none;
}
.sidebar a:hover { background: var(--sunken); color: var(--ink); }
.sidebar a[aria-current] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar code { font-family: var(--mono); font-size: 0.9em; }

.toc a {
  display: block;
  padding: 0.2rem 0 0.2rem 0.75rem;
  border-left: 2px solid var(--rule);
  line-height: 1.35;
  color: var(--muted);
  text-decoration: none;
}
.toc a:hover { color: var(--accent); border-left-color: var(--accent); }
.toc a.h3 { padding-left: 1.5rem; font-size: 0.8rem; }

.crumbs {
  margin-bottom: 1.25rem;
  font: 0.8rem var(--mono);
  color: var(--faint);
}
.crumbs a { color: var(--muted); }

/* ---- rendered markdown ---- */
.doc { max-width: 48rem; }
.doc h1, .doc h2, .doc h3, .doc h4 {
  font-family: var(--display);
  line-height: 1.2;
  scroll-margin-top: calc(var(--topbar) + 1rem);
}
.doc h1 { margin: 0 0 1.25rem; font-size: 2.4rem; }
.doc h2 { margin: 2.75rem 0 0.75rem; padding-bottom: 0.3rem; font-size: 1.65rem; border-bottom: 1px solid var(--rule); }
.doc h3 { margin: 2rem 0 0.5rem; font-size: 1.25rem; }
.doc h4 { margin: 1.5rem 0 0.4rem; font-size: 1.05rem; }
.doc li + li { margin-top: 0.25rem; }
.doc hr { margin: 2.5rem 0; border: 0; border-top: 1px solid var(--rule); }
.doc img { max-width: 100%; }

.doc code {
  padding: 0.1em 0.35em;
  font: 0.86em var(--mono);
  background: var(--sunken);
  border-radius: 4px;
}
.doc pre {
  padding: 1rem;
  overflow-x: auto;
  line-height: 1.45;
  background: var(--sunken);
  border: 1px solid var(--rule);
  border-radius: 8px;
}
.doc pre code { padding: 0; font-size: 0.85rem; background: none; }

.doc table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  margin: 1.25rem 0;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.doc th, .doc td {
  padding: 0.45rem 0.7rem;
  text-align: left;
  vertical-align: top;
  border: 1px solid var(--rule);
}
.doc th { background: var(--sunken); }
.doc tbody tr { background: var(--surface); }

.doc blockquote {
  margin: 1.25rem 0;
  padding: 0.6rem 1rem;
  color: var(--muted);
  background: var(--surface);
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
}
.doc blockquote > :first-child { margin-top: 0; }
.doc blockquote > :last-child { margin-bottom: 0; }

.doc .contains-task-list { padding-left: 1.25rem; }
.doc .task-list-item { list-style: none; }
.doc .task-list-item-checkbox { margin: 0 0.5rem 0 -1.25rem; }

/* ---- embedded HTML / PDF ---- */
.embed-bar { margin: 0 0 0.75rem; font-size: 0.875rem; }
.embed {
  display: block;
  width: 100%;
  height: calc(100vh - var(--topbar) - 8rem);
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
}

/* ---- listings ---- */
.intro { margin: 0 0 0.5rem; color: var(--muted); }
.listing-title { margin: 0 0 1rem; font: 700 2.4rem/1.2 var(--display); }
main section h2 {
  margin: 2rem 0 0.75rem;
  font: 500 0.75rem var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
}
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 0.75rem;
}
.card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.9rem 1rem;
  color: var(--ink);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 10px;
}
.card:hover { border-color: var(--accent); }
.card .title { font-weight: 500; line-height: 1.35; }
.card .file { font: 0.75rem var(--mono); color: var(--faint); }
.card code { font-family: var(--mono); font-size: 0.9em; }

/* ---- product base ---- */
[hidden] { display: none !important; }
.topnav { display: flex; gap: 1.25rem; margin-left: 2rem; font-size: 0.9rem; }
.topnav a { color: var(--muted); text-decoration: none; }
.topnav a:hover { color: var(--accent); }

.catalog-tools {
  position: sticky;
  top: var(--topbar);
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-block: 0.75rem;
  background: var(--ground);
}
.catalog-tools input {
  flex: 1 1 16rem;
  padding: 0.55rem 0.8rem;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
}
.catalog-tools button {
  padding: 0.55rem 1rem;
  font: 500 0.9rem var(--body);
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.compare-all { margin-left: 0.75rem; font: 0.75rem var(--body); text-transform: none; letter-spacing: 0; }
.pcard-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; }
.pcard .title { color: var(--ink); text-decoration: none; font-weight: 600; }
.pcard .title:hover { color: var(--accent); }
.pcard input { accent-color: var(--accent); }
.pcard .what { font-size: 0.85rem; line-height: 1.4; color: var(--muted); }
.tag {
  align-self: flex-start;
  padding: 0.05rem 0.45rem;
  font: 500 0.7rem var(--mono);
  color: var(--muted);
  background: var(--sunken);
  border-radius: 4px;
}
.tag.warn { color: #a85a08; }
.note { color: var(--faint); font-size: 0.85em; }

.entity-meta { margin: -0.5rem 0 0.5rem; color: var(--muted); }
.aka { margin: 0 0 0.5rem; }
.entity-links { margin: 0 0 1rem; font-size: 0.9rem; }
.doc.entity h2 { font-size: 1.35rem; }
.facts { width: 100%; }
.facts th { width: 11rem; background: var(--sunken); }
.facts .value { font-weight: 500; }
.facts .quote { margin-top: 0.25rem; font-size: 0.8rem; color: var(--muted); }
.facts q { font-style: italic; }
.relations { display: grid; grid-template-columns: 9rem 1fr; gap: 0.4rem 1rem; }
.relations dt { font-weight: 600; }
.relations dd { margin: 0; }

.table-scroll { max-width: 100%; overflow-x: auto; }
.compare { border-collapse: collapse; font-size: 0.9rem; background: var(--surface); }
.compare th, .compare td { padding: 0.45rem 0.7rem; text-align: left; vertical-align: top; border: 1px solid var(--rule); }
.compare thead th { background: var(--sunken); }
.compare thead th .file { display: block; font-weight: 400; }
.compare tbody th { background: var(--sunken); white-space: nowrap; }
.compare tr.differs td { background: var(--accent-soft); }
.compare td.na { color: var(--faint); font-style: italic; }
.compare .cite { font-size: 0.75rem; color: var(--faint); }

.jump { display: flex; flex-wrap: wrap; gap: 0.6rem; font: 500 0.9rem var(--mono); }
.terms { padding-left: 0; list-style: none; }
.terms li { display: grid; grid-template-columns: 17rem 1fr; gap: 1rem; padding: 0.2rem 0; }
.terms .term { font-weight: 600; }
.terms .file, .facts .file, .doc .file { font: 0.75rem var(--mono); color: var(--faint); }

/* ---- narrow screens: drop the TOC, then the sidebar (the home page lists everything) ---- */
@media (max-width: 75rem) {
  .layout { grid-template-columns: 15rem minmax(0, 1fr); gap: 2rem; }
  .toc { display: none; }
}
@media (max-width: 50rem) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 0 1rem; }
  .sidebar { display: none; }
  .doc h1, .listing-title { font-size: 1.9rem; }
  .topnav { gap: 0.9rem; margin-left: 1rem; }
  .facts th { width: 7rem; }
  .relations { grid-template-columns: 1fr; }
  .terms li { grid-template-columns: 1fr; gap: 0; padding: 0.35rem 0; }
}

/* Site-wide provenance footer */
.sitefoot {
  grid-column: 1 / -1;
  border-top: 1px solid var(--rule);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  max-width: 64rem;
  color: var(--faint);
  font-size: 0.8rem;
  line-height: 1.55;
}
.sitefoot p { margin: 0; }
.sitefoot b { color: var(--muted); }
