/* blueprint.css — the interactive blueprint page (blueprint.html). Tokens come from site.css. */

body { font-family: "Inter Variable", var(--sans); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: -9999px; top: 0; z-index: 100; background: var(--accent); color: #fff; padding: 8px 14px; }
.skip-link:focus { left: 8px; top: 8px; }
.sec, .ch-head { scroll-margin-top: calc(var(--header-h, 56px) + var(--toolbar-h, 0px) + 12px); }

/* ---- Layout ---- */
.bp-layout {
  display: grid; grid-template-columns: 272px minmax(0, 1fr); gap: var(--s5);
  max-width: 1280px; margin: 0 auto; padding: var(--s4) var(--s4) 0;
}
.bp-main { min-width: 0; max-width: 880px; }

/* ---- Table of contents ---- */
.bp-toc {
  position: sticky; top: calc(var(--header-h, 56px) + 16px); align-self: start;
  max-height: calc(100vh - var(--header-h, 56px) - 32px); overflow: auto; overscroll-behavior: contain;
  padding: 0 12px 16px 0; border-right: 1px solid var(--line);
  font-size: 14px;
}
.toc-top { display: flex; align-items: center; justify-content: space-between; }
.toc-title { margin: 0 0 10px; font-weight: 700; font-size: 12.5px; letter-spacing: .05em; text-transform: uppercase; }
.toc-close { display: none; }
.bp-toc ol { list-style: none; margin: 0; padding: 0; }
.toc-ch { margin: 0 0 10px; }
.toc-ch-link { display: flex; gap: 8px; color: var(--ink); font-weight: 650; line-height: 1.35; padding: 3px 4px; border-radius: 6px; }
.toc-ch-link:hover { color: var(--accent); text-decoration: none; background: var(--brand-light); }
.toc-ch-link[aria-current] { color: var(--accent); }
.secno { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.toc-ch-link .secno { min-width: 1.1em; }
.toc-ch-meta { display: flex; align-items: center; gap: 8px; margin: 3px 4px 0 calc(1.1em + 12px); font-size: 11.5px; color: var(--muted); }
.toc-ch-n { font-variant-numeric: tabular-nums; white-space: nowrap; }
.toc-ch-n .n-f { color: var(--st-formalized); }
.toc-ch-n .n-a { color: var(--st-assumed); }
.toc-ch-n .n-e { color: var(--st-excluded); }
.toc-secs { display: none; margin: 6px 0 4px 10px !important; padding-left: 8px !important; border-left: 2px solid var(--line); }
.toc-ch.open .toc-secs { display: block; }
.toc-secs a {
  display: flex; gap: 6px; align-items: baseline; padding: 3px 6px; border-radius: 6px;
  color: var(--muted); font-size: 13px; line-height: 1.35;
}
.toc-secs a .secno { font-weight: 600; font-size: 12px; min-width: 2.2em; }
.toc-sec-title { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.toc-sec-n { flex: 0 0 auto; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; opacity: .8; }
.toc-secs a:hover { color: var(--accent); background: var(--brand-light); text-decoration: none; }
.toc-secs a[aria-current="location"] { color: var(--accent); font-weight: 650; background: var(--brand-light); }
.toc-legend { margin: 14px 4px 0; font-size: 11.5px; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.lg { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-left: 4px; }
.lg-f { background: var(--st-formalized); } .lg-a { background: var(--st-assumed); } .lg-e { background: #9a9a9a; }

/* Status bars */
.sbar { display: inline-flex; width: 64px; height: 6px; border-radius: 3px; overflow: hidden; background: #eee; flex: 0 0 auto; }
.sbar-wide { width: 120px; height: 8px; border-radius: 4px; }
.sbar-formalized { background: var(--st-formalized); }
.sbar-assumed { background: #e08a00; }
.sbar-excluded { background: #9a9a9a; }

/* ---- Intro ---- */
.bp-intro h1 { font-size: clamp(30px, 4.2vw, 44px); line-height: 1.12; margin: 8px 0 16px; }
.bp-lead { color: var(--muted); max-width: 640px; margin: 0 0 22px; }
.bp-intro-btns { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 22px; }
.bp-intro-btns .btn { padding: 8px 18px; font-size: 14px; }
.bp-stats { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 14px; }
.stat {
  display: flex; flex-direction: column; min-width: 110px; padding: 10px 14px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid #e3eafc;
}
.stat-n { font-family: var(--serif); font-size: 24px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-l { font-size: 12.5px; color: var(--muted); }
.stat.st-formalized .stat-n { color: var(--st-formalized); }
.stat.st-assumed .stat-n { color: var(--st-assumed); }
.stat.st-excluded .stat-n { color: var(--st-excluded); }
.bp-help { margin: 0 0 22px; font-size: 14px; color: var(--muted); }
.bp-help summary { cursor: pointer; color: var(--accent); font-weight: 600; width: fit-content; }
.bp-help ul { margin: 8px 0 0; padding-left: 20px; }
kbd {
  font-family: var(--mono); font-size: 12px; padding: 1px 5px; border: 1px solid #c8cfdc; border-bottom-width: 2px;
  border-radius: 4px; background: #fff; color: var(--ink);
}

/* ---- Toolbar ---- */
.bp-toolbar {
  position: sticky; top: var(--header-h, 56px); z-index: 40;
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line); padding: 10px 0 8px; margin-bottom: 8px;
}
.tb-row { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; }
.tb-filters { margin-top: 8px; font-size: 13px; }
.tb-toc-btn { display: none; }
.ch-switch { display: flex; gap: 4px; flex-wrap: wrap; }
.ch-pill {
  display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 34px; padding: 0 6px;
  border-radius: 999px; border: 1px solid var(--line); color: var(--ink); font-weight: 650; font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.ch-pill:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.ch-pill[aria-current] { background: var(--accent); border-color: var(--accent); color: #fff; }
.search { position: relative; flex: 1 1 240px; min-width: 0; }
.search input {
  width: 100%; height: 36px; padding: 0 34px 0 12px; border: 1px solid #b7c6e6; border-radius: 999px;
  font: inherit; font-size: 14px; background: #fff; color: var(--ink);
}
.search input:focus { border-color: var(--accent); outline: 2px solid var(--focus); outline-offset: 1px; }
.search-key { position: absolute; right: 10px; top: 8px; pointer-events: none; opacity: .7; }
.search input:focus ~ .search-key { display: none; }
.results {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 60; min-width: min(520px, calc(100vw - 32px));
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 14px 34px rgba(0, 30, 90, .18);
  max-height: min(60vh, 520px); overflow: auto;
}
.results-count { margin: 0; padding: 8px 12px 6px; font-size: 12px; color: var(--muted); border-bottom: 1px solid #edf1fa; }
.results ul { list-style: none; margin: 0; padding: 4px; }
.results li a {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 7px 9px; border-radius: 7px;
  color: var(--ink); font-size: 14px; line-height: 1.4;
}
.results li a:hover { text-decoration: none; background: var(--panel); }
.results li[aria-selected="true"] a { background: var(--brand-light); box-shadow: inset 3px 0 0 var(--accent); }
.r-main { min-width: 0; overflow-wrap: anywhere; }
.r-num { font-weight: 700; }
.r-meta { grid-column: 1 / -1; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results .status { align-self: start; }

.chips { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.chips-label { font-weight: 600; color: var(--muted); margin-right: 2px; font-size: 12.5px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span {
  display: inline-block; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--brand-light); color: var(--ink); font-weight: 600; font-size: 12.5px; user-select: none;
}
.chip-formalized span { background: var(--st-formalized-bg); border-color: #b9e0cb; color: var(--st-formalized); }
.chip-assumed span { background: var(--st-assumed-bg); border-color: #f2d3a6; color: var(--st-assumed); }
.chip-excluded span { background: var(--st-excluded-bg); border-color: #d6d6d6; color: #555; }
.chip.off span { background: #fff; color: #767676; border-color: #d9d9d9; text-decoration: line-through; }
.chip input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.tb-btn {
  font: inherit; font-size: 12.5px; font-weight: 650; padding: 3px 12px; border-radius: 999px;
  border: 1px solid var(--accent); background: #fff; color: var(--accent); cursor: pointer;
}
.tb-btn[aria-pressed="true"] { background: var(--accent); color: #fff; }
.shown-count { margin-left: auto; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }

/* ---- Chapter and sections ---- */
.bp-chapter:focus { outline: none; }
.bp-loading, .bp-error { padding: var(--s4) 0; }
.ch-head { margin: 28px 0 8px; padding-bottom: 12px; border-bottom: 2px solid var(--accent); }
.ch-head h2 { display: flex; gap: 18px; align-items: baseline; font-size: clamp(28px, 3.4vw, 36px); line-height: 1.15; margin: 0 0 10px; }
.ch-no { color: var(--accent); font-weight: 700; font-family: var(--serif); }
.ch-meta { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; color: var(--muted); font-size: 13.5px; }
.sec { margin-top: 36px; }
.sec-h {
  display: flex; gap: 12px; align-items: baseline; margin: 0 0 14px; padding-bottom: 6px;
  font-family: var(--serif); font-weight: 400; font-size: 24px; line-height: 1.25; border-bottom: 1px solid var(--line);
}
.sec-h .secno { font-family: var(--sans); font-size: 17px; }
.sec-empty { color: var(--muted); font-style: italic; font-size: 14px; }
.filtering .prose { display: none; }

.prose { margin: 14px 0; line-height: 1.65; }
.prose p { margin: 0 0 .75em; }
.prose code, .ent code { overflow-wrap: anywhere; }

/* ---- Entity cards ---- */
.ent {
  position: relative; margin: 18px 0; padding: 12px 16px 10px; background: #fff;
  border: 1px solid #e3eafc; border-left: 4px solid var(--accent); border-radius: 0 var(--radius) var(--radius) 0;
  box-shadow: 0 6px 14px rgba(0, 54, 163, .05); scroll-margin-top: calc(var(--header-h, 56px) + var(--toolbar-h, 0px) + 12px);
}
.ent.k-definition { border-left-color: #5b84d6; }
.ent.st-assumed { border-left-color: #e08a00; }
.ent.st-excluded { border-left-color: #a0a0a0; background: #fcfcfc; }
.ent:focus { outline: none; }
.ent.flash { animation: flash 2.2s ease-out; }
@keyframes flash {
  0%, 30% { box-shadow: 0 0 0 4px rgba(0, 95, 204, .45), 0 6px 14px rgba(0, 54, 163, .05); background: #f2f7ff; }
  100% { box-shadow: 0 6px 14px rgba(0, 54, 163, .05); background: #fff; }
}
.ent-head { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.ent-h { margin: 0; font-size: 16px; font-weight: 400; line-height: 1.45; font-family: var(--sans); min-width: 0; overflow-wrap: anywhere; }
.ent-num { color: var(--ink); font-weight: 700; }
.ent-num:hover { color: var(--accent); }
.ent-title { color: var(--ink); }
.ent-badges { flex: 0 0 auto; display: flex; gap: 4px; margin-top: 2px; }
.ent-statement { margin: 6px 0 8px; line-height: 1.65; overflow-wrap: break-word; }
.ent-statement p, .ent-proof p { margin: 0 0 .6em; }
.ent-statement > :last-child { margin-bottom: 0; }
.ent-statement ol, .ent-statement ul, .ent-proof ol, .ent-proof ul { margin: .3em 0 .6em; padding-left: 1.4em; }
.ent-statement ol li > strong:first-child, .ent-proof ol li > strong:first-child { font-weight: 600; }
.ent-statement ol, .ent-proof ol { list-style: none; padding-left: .4em; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 2px 0; margin: .6em 0; }
.lazy-math .katex-display, .lazy-math { min-width: 0; }
.ent table, .prose table { border-collapse: collapse; display: block; overflow-x: auto; max-width: 100%; }
.ent td, .ent th, .prose td, .prose th { border: 1px solid #e3e3e3; padding: 2px 8px; }

.ent-note { margin: 0 0 8px; padding: 6px 10px; border-radius: 6px; font-size: 13.5px; line-height: 1.5; }
.note-assumed { background: var(--st-assumed-bg); color: #6b3d00; }
.note-excluded { background: var(--st-excluded-bg); color: #444; }
.note-proved { background: var(--st-formalized-bg); color: #155c39; }
.note-src { display: block; margin-top: 2px; font-size: 12.5px; opacity: .9; }

.ent-row { display: flex; gap: 10px; margin: 3px 0; font-size: 13.5px; line-height: 1.55; }
.ent-key { flex: 0 0 auto; min-width: 64px; font-weight: 700; color: var(--muted); font-size: 12px; letter-spacing: .03em; text-transform: uppercase; padding-top: 2px; }
.ent-refs { min-width: 0; overflow-wrap: anywhere; }
.ent-refs a.ref { white-space: nowrap; }
.lean-item { display: inline-flex; align-items: baseline; flex-wrap: wrap; gap: 4px; margin-right: 12px; max-width: 100%; }
.lean-link code { font-size: 12.5px; color: var(--accent); overflow-wrap: anywhere; word-break: break-word; }
.tag { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 0 5px; border-radius: 4px; line-height: 1.6; }
.tag-draft { color: #6a4a00; background: #fff1cc; }
.tag-axiom { color: var(--st-assumed); background: var(--st-assumed-bg); }

.ent-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 8px; padding-top: 6px; border-top: 1px solid #edf1fa; font-size: 13px; }
.ent-tog {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px 2px 4px; border: 0; border-radius: 6px;
  background: none; color: var(--accent); font: inherit; font-weight: 650; cursor: pointer;
}
.ent-tog:hover { background: var(--brand-light); }
.ent-tog .cnt { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.caret { width: 0; height: 0; border-left: 5px solid currentColor; border-top: 4px solid transparent; border-bottom: 4px solid transparent; transition: transform .15s; }
.ent-tog[aria-expanded="true"] .caret { transform: rotate(90deg); }
.ent-unused { color: var(--muted); font-size: 12.5px; }
.ent-actions { margin-left: auto; display: inline-flex; align-items: center; gap: 12px; }
.ent-graph { font-weight: 600; }
.ent-copy {
  display: inline-flex; align-items: center; gap: 5px; border: 0; background: none; padding: 2px 4px; border-radius: 6px;
  font: inherit; font-size: 12.5px; color: var(--muted); cursor: pointer;
}
.ent-copy:hover { color: var(--accent); background: var(--brand-light); }
.ent-copy.copied { color: var(--st-formalized); }
.ent-proof {
  margin: 8px 0 4px; padding: 10px 14px; background: var(--panel); border-left: 3px solid var(--line);
  border-radius: 0 8px 8px 0; font-size: 15px; line-height: 1.65; overflow-wrap: break-word;
}
.proof-label { margin: 0 0 .3em !important; }
.proof-uses { margin-top: 10px; padding-top: 6px; border-top: 1px solid var(--line); }
.ent-usedby { margin: 6px 0 2px; }

/* ---- Previous/next chapter ---- */
.ch-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 48px 0 0; }
.ch-nav a { display: block; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); font-weight: 600; }
.ch-nav a span { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.ch-nav a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.ch-nav-next { text-align: right; }

.bp-fab { display: none; }
.toc-backdrop[hidden] { display: none; }

/* ---- Narrow screens: TOC becomes a drawer, toolbar scrolls with the page ---- */
@media (max-width: 899px) {
  .bp-layout { display: block; padding: var(--s3) 16px 0; }
  .bp-toc {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 120; width: min(88vw, 340px); max-height: none;
    background: #fff; border-right: 1px solid var(--line); padding: 14px 14px 24px; box-shadow: 8px 0 24px rgba(0, 0, 0, .15);
    transform: translateX(-105%); transition: transform .2s ease; visibility: hidden;
  }
  body.toc-open .bp-toc { transform: none; visibility: visible; }
  .toc-backdrop { position: fixed; inset: 0; z-index: 110; background: rgba(10, 20, 40, .35); }
  .toc-close {
    display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 0; border-radius: 50%;
    background: var(--panel); font-size: 22px; cursor: pointer; color: var(--ink);
  }
  .toc-secs { display: block; }
  .toc-ch:not(.open) .toc-secs { display: none; }
  .bp-toolbar { position: static; }
  .tb-toc-btn {
    display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px;
    border: 1px solid var(--accent); background: #fff; color: var(--accent); font: inherit; font-size: 14px; font-weight: 650; cursor: pointer;
  }
  .search { flex-basis: 100%; order: 3; }
  .search-key { display: none; }
  .search input { padding-right: 12px; }
  .shown-count { margin-left: 0; flex-basis: 100%; }
  .bp-fab {
    display: flex; gap: 8px; position: fixed; right: 12px; bottom: 14px; z-index: 90;
  }
  .bp-fab button {
    border: 0; border-radius: 999px; padding: 10px 16px; background: var(--accent); color: #fff; font: inherit; font-size: 14px;
    font-weight: 650; box-shadow: 0 6px 18px rgba(0, 30, 90, .3); cursor: pointer;
  }
  .bp-fab #fab-search { background: #fff; color: var(--accent); border: 1px solid var(--accent); }
  .site-footer { padding-bottom: 80px; }
}
@media (max-width: 640px) {
  /* On phones the two-line site header would take a sixth of the screen: let it scroll away. */
  .bp-page .site-header { position: relative; }
}
@media (max-width: 560px) {
  .ent { padding: 10px 12px 8px; margin: 14px 0; }
  .ent-head { flex-direction: column; gap: 4px; }
  .ent-row { flex-direction: column; gap: 0; }
  .ent-key { min-width: 0; }
  .ent-actions { margin-left: 0; }
  .ch-nav { grid-template-columns: 1fr; }
  .ch-head h2 { gap: 12px; }
  .sec-h { font-size: 21px; }
  .stat { min-width: calc(50% - 5px); flex: 1 1 calc(50% - 5px); }
  .results { min-width: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .ent.flash { animation: none; box-shadow: 0 0 0 3px rgba(0, 95, 204, .45); }
  .bp-toc { transition: none; }
}

/* A link that names nothing in the blueprint (see route() in blueprint.js) */
.bp-notice {
  margin: 16px 0 0; padding: 8px 12px; border-radius: 8px; background: #fff7e0; border: 1px solid #f0d28a;
  color: #5c4200; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere;
}
.bp-notice[hidden] { display: none; }
