/* ---------------------------------------------------------------------
   Near-black, not pure black. #0b0b0c reads as truly dark while keeping a
   trace of warmth, so it doesn't glare the way #000 does against bright
   text. Surfaces step up in small increments (0b -> 121214 -> 17171a) to
   give depth without ever becoming grey.
   --------------------------------------------------------------------- */
:root {
  color-scheme: dark;

  --bg:          #0b0b0c;
  --surface:     #121214;
  --surface-2:   #17171a;
  --surface-3:   #1e1e22;

  --ink:         #f2f2f0;
  --ink-2:       #a8a8a3;
  --ink-3:       #6f6f6b;

  --line:        #232327;
  --line-2:      #2e2e33;

  --accent:      #3987e5;  /* overridden per mindmap */

  --radius:      10px;
  --maxw:        1080px;

  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

::selection { background: color-mix(in srgb, var(--accent) 32%, transparent); }

/* --- shell ---------------------------------------------------------- */

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
}

header.top {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.top-in {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
}

/* The dot is decorative only - it echoes the active mindmap's accent, and
   never carries meaning on its own. */
.brand .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
  transition: background 0.25s ease;
}

.brand .sub { color: var(--ink-3); font-weight: 400; }

.spacer { flex: 1 1 auto; }

/* --- search --------------------------------------------------------- */

.search {
  position: relative;
  flex: 0 1 320px;
  min-width: 0;
}

.search input {
  width: 100%;
  font-family: var(--sans);
  font-size: 13.5px;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: 7px;
  padding: 7px 11px 7px 30px;
  outline: none;
  transition: border-color 0.15s ease;
}

.search input::placeholder { color: var(--ink-3); }
.search input:focus { border-color: color-mix(in srgb, var(--accent) 60%, var(--line-2)); }

.search svg {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  width: 13px;
  height: 13px;
  stroke: var(--ink-3);
  fill: none;
  stroke-width: 2;
  pointer-events: none;
}

/* --- buttons -------------------------------------------------------- */

.btn {
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--line-2);
  border-radius: 7px;
  padding: 6px 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.btn:hover { color: var(--ink); background: var(--surface-2); border-color: #3a3a40; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.btnrow { display: flex; gap: 7px; }

/* --- home ----------------------------------------------------------- */

.hero { padding: 64px 0 40px; }

.hero h1 {
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1.08;
  letter-spacing: -0.03em;
  font-weight: 640;
  margin: 0 0 14px;
}

.hero p {
  color: var(--ink-2);
  font-size: 16px;
  max-width: 56ch;
  margin: 0;
}

.hero .stats {
  margin-top: 26px;
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-3);
}

.hero .stats b {
  display: block;
  font-family: var(--sans);
  font-size: 21px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  gap: 13px;
  padding-bottom: 80px;
}

/* Each card carries its mindmap's accent, but the NAME is the identifier -
   colour is a secondary cue only, which is what keeps an 8-hue set legible
   here (see build.py's palette note). */
.card {
  position: relative;
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 19px 18px 17px;
  overflow: hidden;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 2px;
  background: var(--card-accent);
  opacity: 0.75;
  transition: opacity 0.18s ease, width 0.18s ease;
}

.card:hover {
  background: var(--surface-2);
  border-color: var(--line-2);
  transform: translateY(-1px);
}

.card:hover::before { opacity: 1; width: 3px; }
.card:focus-visible { outline: 2px solid var(--card-accent); outline-offset: 2px; }

.card h2 {
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0 0 5px;
}

.card .root {
  font-size: 12.5px;
  color: var(--ink-3);
  margin: 0 0 15px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card .meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  display: flex;
  gap: 12px;
}

.card .meta span { display: flex; align-items: center; gap: 5px; }

.card .meta i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--card-accent);
  display: inline-block;
}

/* --- mindmap view --------------------------------------------------- */

.mm-head {
  padding: 34px 0 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}

.back {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-3);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  transition: color 0.15s ease;
}

.back:hover { color: var(--accent); }

.mm-head h1 {
  font-size: clamp(24px, 4vw, 33px);
  letter-spacing: -0.025em;
  font-weight: 640;
  margin: 0 0 8px;
}

.mm-head .meta {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-3);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 0;
  flex-wrap: wrap;
}

/* --- tree ----------------------------------------------------------- */

#tree { padding-bottom: 90px; }

ul.kids {
  list-style: none;
  margin: 0;
  padding-left: 19px;
  border-left: 1px solid var(--line);
}

ul.kids.top { padding-left: 0; border-left: none; }

li.node { position: relative; }

.row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 8px 4px 5px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s ease;
}

.row:hover { background: var(--surface); }
.row:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }

.tw {
  flex: none;
  width: 15px;
  height: 21px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
  transition: transform 0.15s ease, color 0.15s ease;
}

.tw svg { width: 9px; height: 9px; fill: currentColor; }
.tw.open { transform: rotate(90deg); color: var(--accent); }
.row:hover .tw { color: var(--accent); }

.tw.leaf { color: transparent; }

/* Depth 1-2 are structural headings: the accent bar marks them so the
   skeleton of a mindmap is scannable without reading every leaf. */
.lbl { flex: 1 1 auto; min-width: 0; }

.d0 > .row .lbl { font-size: 19px; font-weight: 650; letter-spacing: -0.02em; }
.d1 > .row .lbl { font-size: 15.5px; font-weight: 620; color: var(--accent); letter-spacing: -0.01em; }
.d2 > .row .lbl { font-size: 14.5px; font-weight: 600; color: var(--ink); }
.d3 > .row .lbl { font-size: 14.5px; font-weight: 550; color: var(--ink-2); }
.d4 > .row .lbl,
.d5 > .row .lbl,
.d6 > .row .lbl { font-size: 14.5px; font-weight: 400; color: var(--ink-2); }

/* A leaf's opening clause up to the first ':' or '—' is the term being
   defined; brightening it turns a wall of prose into scannable entries. */
.term { color: var(--ink); font-weight: 550; }

.count {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
  margin-left: 7px;
  font-weight: 400;
  letter-spacing: 0;
}

.leafdot {
  flex: none;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--line-2);
  margin-top: 9px;
}

mark {
  background: color-mix(in srgb, var(--accent) 26%, transparent);
  color: var(--ink);
  border-radius: 3px;
  padding: 0 2px;
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 0.05em 0.32em;
  border-radius: 4px;
}

.empty {
  color: var(--ink-3);
  padding: 56px 0;
  text-align: center;
  font-size: 14px;
}

.empty b { color: var(--ink-2); font-weight: 500; }

/* --- misc ----------------------------------------------------------- */

footer {
  border-top: 1px solid var(--line);
  padding: 22px 0 34px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-3);
}

.hidden { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

@media (max-width: 640px) {
  .top-in { flex-wrap: wrap; gap: 10px; }
  .search { flex: 1 1 100%; order: 3; }
  .hero { padding: 40px 0 30px; }
  ul.kids { padding-left: 13px; }
}
