/* Blueprint website. Light and dark themes follow the reader's system setting. */
:root {
  --bg: #ffffff;
  --surface: #f7f8fa;
  --card: #ffffff;
  --text: #1d2330;
  --muted: #5d6677;
  --border: #dde1e8;
  --accent: #1f5fbf;
  --accent-soft: #e8f0fc;
  --ok: #2e7d32;
  --ok-soft: #e8f5e9;
  --bad: #c62828;
  --bad-soft: #ffebee;
  --code-bg: #f6f8fa;
  --code-text: #24292f;
  --tk-k: #8250df;
  --tk-t: #0550ae;
  --tk-c: #6e7781;
  --tk-s: #0a3069;
  --tk-a: #953800;
  --tk-n: #0550ae;
  --target: #fff8c5;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218;
    --surface: #161a22;
    --card: #1a1f29;
    --text: #e3e7ee;
    --muted: #9aa4b5;
    --border: #2c3341;
    --accent: #7aa7ff;
    --accent-soft: #1c2a44;
    --ok: #81c784;
    --ok-soft: #1b2e1d;
    --bad: #ef9a9a;
    --bad-soft: #3a1d1f;
    --code-bg: #11151c;
    --code-text: #d6dbe4;
    --tk-k: #d2a8ff;
    --tk-t: #79c0ff;
    --tk-c: #8b949e;
    --tk-s: #a5d6ff;
    --tk-a: #ffa657;
    --tk-n: #79c0ff;
    --target: #3a3418;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { scroll-padding-top: 4.5rem; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre {
  font-family: "JuliaMono", "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  font-size: 0.86em;
}

/* top navigation */
nav.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; gap: 1.4rem; align-items: center;
  padding: 0.75rem 1.5rem;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
  font: 15px/1.2 -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
}
nav.top .brand { font-weight: 700; margin-right: 0.6rem; }
nav.top a { color: var(--muted); }
nav.top a.active, nav.top a:hover { color: var(--text); text-decoration: none; }

main { max-width: 74rem; margin: 0 auto; padding: 1.5rem 2rem 4rem; }
main.wide { max-width: none; }

/* introduction */
header.intro h1 { font-size: 1.75rem; line-height: 1.25; margin: 1rem 0 0.4rem; }
header.intro .authors { color: var(--muted); margin: 0 0 1rem; }
.stats { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0; }
.stats span {
  font: 13px/1 -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  padding: 0.4rem 0.7rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
}
.stats span.ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.stats span.bad { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
#filter {
  width: 100%; margin: 0.5rem 0 1rem; padding: 0.65rem 0.9rem;
  font: 15px/1.3 -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--text); background: var(--card);
  border: 1px solid var(--border); border-radius: 8px;
}
#filter:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
ul.toc { list-style: none; columns: 2; column-gap: 2rem; padding-left: 1.2rem; margin: 0 0 1rem;
         font: 15px/1.7 -apple-system, "Segoe UI", Helvetica, Arial, sans-serif; }

/* chapters and statements */
section.chapter h2 {
  font-size: 1.3rem; margin: 2.5rem 0 1rem; padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}
article.node {
  background: var(--card); border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 8px; padding: 0.9rem 1.1rem 0.7rem; margin: 0 0 1rem;
}
article.node.definition { border-left-color: #8e7cc3; }
article.node:target { box-shadow: 0 0 0 3px var(--accent-soft), 0 0 0 4px var(--accent); }
.nodehead { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem 0.8rem;
            margin-bottom: 0.35rem; }
.nodehead .kind { font-weight: 700; }
.nodehead .title { color: var(--muted); font-style: italic; flex: 1; }
.badge {
  font: 12px/1 -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  padding: 0.3rem 0.55rem; border-radius: 999px; white-space: nowrap;
}
.badge.ok { color: var(--ok); background: var(--ok-soft); }
.badge.bad { color: var(--bad); background: var(--bad-soft); }
.statement p { margin: 0.4rem 0; }
.statement ol, .statement ul, .proof ol, .proof ul { margin: 0.3rem 0; padding-left: 1.6rem; }
li.lbl { list-style: none; margin-left: -1.6rem; }
.itemlabel { display: inline-block; min-width: 1.6rem; }
.statement code, .proof code { background: var(--code-bg); padding: 0.05rem 0.3rem; border-radius: 4px; }

.deps { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem;
        margin: 0.45rem 0 0; font: 13px/1.2 -apple-system, "Segoe UI", Helvetica, Arial, sans-serif; }
.deplabel { color: var(--muted); min-width: 4.2rem; }
.chip {
  padding: 0.22rem 0.5rem; border-radius: 6px;
  background: var(--accent-soft); color: var(--accent);
}
.chip:hover { text-decoration: none; filter: brightness(0.95); }

/* collapsible panels */
details { margin-top: 0.6rem; }
details > summary {
  cursor: pointer; user-select: none; list-style: none;
  display: inline-flex; align-items: center; gap: 0.4rem;
  font: 600 14px/1 -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  padding: 0.42rem 0.75rem; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸"; font-size: 0.8em; transition: transform 0.15s; }
details[open] > summary::before { transform: rotate(90deg); }
details.lean-panel > summary { color: var(--accent); }
summary .count {
  font-weight: 500; font-size: 12px; padding: 0.1rem 0.4rem;
  border-radius: 999px; background: var(--accent-soft);
}
details + details { margin-left: 0.4rem; }
details[open] { display: block; margin-left: 0; }
.proof { margin: 0.5rem 0 0.2rem; padding: 0.2rem 0.9rem; border-left: 3px solid var(--border);
         color: var(--text); }

/* Lean source */
.decl { margin: 0.7rem 0 0.2rem; }
.declhead { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.3rem 1rem;
            font: 13px/1.3 -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
            margin-bottom: 0.25rem; }
.declhead code { font-weight: 600; color: var(--text); background: none; padding: 0; }
.declhead .where { color: var(--muted); }
.decl.missing .where { color: var(--bad); }
pre.lean {
  margin: 0; padding: 0.85rem 1rem; overflow-x: auto;
  background: var(--code-bg); color: var(--code-text);
  border: 1px solid var(--border); border-radius: 6px;
  line-height: 1.5; tab-size: 2;
}
pre.lean code { font-size: 13.5px; background: none; padding: 0; }
.tk-k { color: var(--tk-k); font-weight: 600; }
.tk-t { color: var(--tk-t); }
.tk-c { color: var(--tk-c); font-style: italic; }
.tk-s { color: var(--tk-s); }
.tk-a { color: var(--tk-a); }
.tk-n { color: var(--tk-n); }

/* references inside statements */
a.ref { white-space: nowrap; }
.hidden { display: none; }

/* dependency graph */
.zoom { display: flex; gap: 0.4rem; margin: 0.5rem 0 1rem; }
.zoom button {
  font: 600 14px/1 -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  min-width: 2.4rem; padding: 0.45rem 0.7rem; cursor: pointer;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px;
}
.graph { overflow: auto; border: 1px solid var(--border); border-radius: 8px;
         background: #ffffff; padding: 0.5rem; max-height: 80vh; }
.graph svg { display: block; height: auto; }
.graph svg a:hover polygon, .graph svg a:hover ellipse, .graph svg a:hover path { stroke-width: 3px; }

footer { margin-top: 3rem; color: var(--muted);
         font: 13px/1.5 -apple-system, "Segoe UI", Helvetica, Arial, sans-serif; }

@media (max-width: 640px) {
  body { font-size: 16px; }
  ul.toc { columns: 1; }
  nav.top { gap: 0.9rem; padding: 0.6rem 1rem; overflow-x: auto; }
  main { padding: 1rem; }
}

/* ---- 3D dependency map ----------------------------------------------------- */
.g3-wrap { display: grid; grid-template-columns: 22rem 1fr; height: calc(100vh - 3.1rem); }
.g3-side { overflow-y: auto; padding: 1rem 1.1rem 2rem; border-right: 1px solid var(--border);
           background: var(--surface);
           font: 14px/1.45 -apple-system, "Segoe UI", Helvetica, Arial, sans-serif; }
.g3-side h1 { font: 700 1.25rem/1.2 -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
              margin: 0.2rem 0 0.3rem; }
.g3-help { color: var(--muted); font-size: 12.5px; margin: 0 0 0.8rem; }
.g3-canvas { position: relative; overflow: hidden; min-height: 300px; }
.g3-error { padding: 2rem; color: var(--bad); }

.g3-search { position: relative; margin-bottom: 0.7rem; }
.g3-search input { width: 100%; padding: 0.6rem 0.75rem; font-size: 14px; color: var(--text);
                   background: var(--card); border: 1px solid var(--border); border-radius: 8px; }
.g3-search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
#g3-results { list-style: none; margin: 0.25rem 0 0; padding: 0; position: absolute; left: 0;
              right: 0; z-index: 20; background: var(--card); border-radius: 8px;
              box-shadow: 0 6px 20px rgba(0,0,0,0.18); max-height: 22rem; overflow-y: auto; }
#g3-results:empty { display: none; }
#g3-results li { padding: 0.45rem 0.7rem; cursor: pointer; border-bottom: 1px solid var(--border); }
#g3-results li:last-child { border-bottom: none; }
#g3-results li.active, #g3-results li:hover { background: var(--accent-soft); }
.g3-rnum { font-weight: 700; margin-right: 0.3rem; }
.g3-noresult { color: var(--muted); cursor: default; }

.g3-controls label { display: flex; justify-content: space-between; align-items: center;
                     gap: 0.6rem; margin: 0.35rem 0; color: var(--muted); }
.g3-controls select { flex: 1; max-width: 13rem; padding: 0.3rem; color: var(--text);
                      background: var(--card); border: 1px solid var(--border); border-radius: 6px; }
.g3-buttons { display: flex; gap: 0.5rem; margin: 0.6rem 0 0.9rem; }
.g3-buttons button { flex: 1; padding: 0.45rem; cursor: pointer; font-weight: 600; color: var(--text);
                     background: var(--card); border: 1px solid var(--border); border-radius: 6px; }

.g3-info { background: var(--card); border: 1px solid var(--border); border-radius: 8px;
           padding: 0.75rem 0.85rem; margin-bottom: 1rem; }
.g3-empty { color: var(--muted); margin: 0; }
.g3-kind { font-weight: 700; font-size: 15px; }
.g3-ok { font-weight: 600; font-size: 11.5px; color: var(--ok); background: var(--ok-soft);
         padding: 0.12rem 0.45rem; border-radius: 999px; margin-left: 0.3rem; }
.g3-title { font: italic 16px/1.35 "Iowan Old Style", Palatino, Georgia, serif; margin: 0.15rem 0; }
.g3-chap { color: var(--muted); font-size: 12.5px; }
.g3-lean { margin: 0.45rem 0; }
.g3-lean code { display: inline-block; font-size: 12px; background: var(--code-bg);
                padding: 0.1rem 0.35rem; border-radius: 4px; margin: 0.1rem 0; }
.g3-count { font-size: 12.5px; color: var(--muted); margin: 0.35rem 0 0.2rem; }
.g3-sec { font-weight: 700; margin: 0.6rem 0 0.25rem; }
.g3-chip { display: block; width: 100%; text-align: left; margin: 0.15rem 0; padding: 0.25rem 0.5rem;
           font-size: 12.5px; cursor: pointer; color: var(--text); background: var(--surface);
           border: 1px solid var(--border); border-left-width: 4px; border-radius: 5px; }
.g3-chip:hover { background: var(--accent-soft); }
.g3-none { color: var(--muted); font-size: 12.5px; margin: 0.1rem 0; }
.g3-open { display: inline-block; margin-top: 0.7rem; font-weight: 600; }

.g3-legend-head { font-weight: 700; margin-bottom: 0.3rem; }
.g3-legend-head span { font-weight: 400; color: var(--muted); font-size: 12px; }
.g3-leg { display: flex; align-items: center; gap: 0.45rem; width: 100%; text-align: left;
          padding: 0.3rem 0.4rem; margin: 0.1rem 0; font-size: 13px; cursor: pointer; color: var(--text);
          background: none; border: 1px solid transparent; border-radius: 6px; }
.g3-leg:hover { border-color: var(--border); }
.g3-leg.off { opacity: 0.4; }
.g3-sw { width: 0.85rem; height: 0.85rem; border-radius: 50%; flex: none; }
.g3-all { justify-content: center; color: var(--accent); margin-top: 0.3rem; }
.g3-tip { font: 13px/1.35 -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
          background: rgba(20,24,32,0.92); color: #fff; padding: 0.4rem 0.6rem; border-radius: 6px; }
.g3-tip span { color: #b8c2d6; font-size: 12px; }

@media (max-width: 760px) {
  .g3-wrap { grid-template-columns: 1fr; grid-template-rows: auto 70vh; height: auto; }
  .g3-side { border-right: none; border-bottom: 1px solid var(--border); }
}

/* ---- formal statements generated from Lean ----------------------------------- */
.formal, .informal { margin: 0.5rem 0 0.4rem; }
.formal { background: var(--ok-soft); border-radius: 6px; padding: 0.55rem 0.8rem 0.3rem; }
.fs-head { font: 600 12.5px/1.2 -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
           text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
           margin-bottom: 0.25rem; }
.fs-head span { text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: 0.5rem; }
.formal .fs-head { color: var(--ok); }
.fs-decl + .fs-decl { border-top: 1px solid var(--border); margin-top: 0.4rem; padding-top: 0.4rem; }
.fs-name { font: 12px/1.3 -apple-system, "Segoe UI", Helvetica, Arial, sans-serif; margin-bottom: 0.1rem; }
.fs-name code { font-weight: 600; background: none; padding: 0; }
.fs-note { margin-left: 0.6rem; color: var(--muted); font-style: italic; }
.formal p { margin: 0.3rem 0; }
.formal ul { margin: 0.2rem 0 0.4rem; padding-left: 1.4rem; }
.formal li { margin: 0.12rem 0; }
.fs-h { font: 11px/1 "SF Mono", Menlo, Consolas, monospace; color: var(--muted);
        margin-left: 0.35rem; }
.informal .statement p:first-child { margin-top: 0.15rem; }

/* ---- wide formulas never overflow their card ------------------------------ */
.statement, .formal, .informal, .proof, .g3-info { overflow-wrap: anywhere; }
mjx-container { max-width: 100%; }
mjx-container[display="true"] { overflow-x: auto; overflow-y: hidden;
                                padding-bottom: 2px; }
.formal li, .formal p, .statement p, .proof p { overflow-x: auto; overflow-y: hidden; }
.formal li mjx-container, .formal p mjx-container { display: inline-block; }
article.node { min-width: 0; }

/* ---- the library page ----------------------------------------------------- */
.lib-file { margin: 1.6rem 0 0.4rem; }
.lib-file h2 { font: 600 1.05rem/1.3 "SF Mono", Menlo, Consolas, monospace;
               margin: 0 0 0.4rem; padding-bottom: 0.25rem; border-bottom: 1px solid var(--border); }
.lib-file h2 span { font: 400 13px/1 -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
                    color: var(--muted); margin-left: 0.6rem; }
details.lib-decl { margin: 0.25rem 0; border: 1px solid var(--border); border-radius: 6px;
                   background: var(--card); }
details.lib-decl > summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.3rem 0.7rem;
                             width: 100%; border: none; background: none; border-radius: 6px;
                             padding: 0.45rem 0.7rem; font-weight: 400; }
details.lib-decl > summary::before { content: "▸"; font-size: 0.8em; color: var(--muted); }
details.lib-decl[open] > summary::before { transform: rotate(90deg); }
.lib-kind { font: 600 11px/1 -apple-system, "Segoe UI", Helvetica, Arial, sans-serif; text-transform: uppercase;
            letter-spacing: 0.04em; padding: 0.22rem 0.45rem; border-radius: 4px;
            background: var(--surface); color: var(--muted); }
.lib-kind.theorem, .lib-kind.lemma { background: var(--ok-soft); color: var(--ok); }
.lib-kind.def, .lib-kind.structure, .lib-kind.abbrev, .lib-kind.class, .lib-kind.inductive
  { background: var(--accent-soft); color: var(--accent); }
.lib-name { font: 600 13.5px/1.3 "SF Mono", Menlo, Consolas, monospace; color: var(--text); }
.lib-bp { font: 12px/1 -apple-system, "Segoe UI", Helvetica, Arial, sans-serif; margin-left: auto; }
.lib-body { padding: 0.2rem 0.9rem 0.7rem; }
.lib-body .formal { margin-top: 0.2rem; }
.lib-none { color: var(--muted); font-style: italic; margin: 0.3rem 0; }
#lib-count { color: var(--muted); font: 13px/1.4 -apple-system, "Segoe UI", Helvetica, Arial, sans-serif; }
