/* Writ architecture site. Single deliberate light theme: these pages are meant
   to be shared, projected, and printed, so one high-contrast rendering wins. */

:root {
  --bg: #FFFFFF;
  --chrome: #F3F6F5;
  --ink: #16242A;
  --muted: #5A6C70;
  --line: #DDE5E1;
  --line-soft: #EAEFEC;
  --accent: #0B5E55;
  --accent-ink: #08453F;
  --accent-soft: #E4F0ED;
  --warm: #9A5218;
  --warm-soft: #F8EEE2;
  --code-bg: #EFF3F1;
  --shadow: 0 1px 2px rgba(22, 36, 42, 0.06), 0 8px 24px rgba(22, 36, 42, 0.06);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16.5px;
  line-height: 1.68;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0.65rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.brand {
  font-weight: 700;
  text-decoration: none;
  color: var(--ink);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand .dot { color: var(--accent); }
.topbar nav { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.topbar nav a {
  text-decoration: none;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 500;
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
}
.topbar nav a:hover { color: var(--accent-ink); background: var(--accent-soft); }
.topbar nav a[aria-current="page"] { color: var(--accent-ink); background: var(--accent-soft); }

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

.page { max-width: 1240px; margin: 0 auto; padding: 0 1.5rem 5rem; }
.prose { max-width: 780px; }
.prose p { margin: 0.75rem 0; }

/* ---------- hero ---------- */

.hero { padding: 3.2rem 0 1.4rem; }
.eyebrow {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.7rem;
}
h1 {
  font-size: clamp(1.9rem, 4vw, 2.7rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin: 0 0 0.7rem;
  text-wrap: balance;
  max-width: 22ch;
}
.lede { font-size: 1.14rem; color: var(--muted); max-width: 46rem; margin: 0; }
.stamp {
  display: inline-block;
  margin-top: 1.2rem;
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
  font-size: 0.76rem;
  color: var(--muted);
  background: var(--chrome);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.35rem 0.7rem;
}

/* ---------- headings + text ---------- */

h2 {
  font-size: 1.42rem;
  letter-spacing: -0.015em;
  margin: 3rem 0 0.6rem;
  text-wrap: balance;
}
h3 { font-size: 1.08rem; margin: 1.8rem 0 0.4rem; }
h2 .sec-num {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  margin-right: 0.45rem;
}
code, .path {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
  font-size: 0.84em;
  background: var(--code-bg);
  border-radius: 4px;
  padding: 0.08em 0.35em;
}
ul, ol { max-width: 780px; padding-left: 1.25rem; }
li { margin: 0.4rem 0; }
li::marker { color: var(--accent); font-weight: 600; }
a { color: var(--accent-ink); }

/* ---------- answers box ---------- */

.answers {
  background: var(--chrome);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.1rem 1.4rem;
  margin: 1.8rem 0;
  max-width: 780px;
}
.answers .label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.answers ul { margin: 0.3rem 0 0; }

/* ---------- figures (diagrams) ---------- */

figure.fig {
  margin: 2rem 0 2.6rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
figure.fig > figcaption {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  flex-wrap: wrap;
  padding: 0.75rem 1.2rem;
  border-bottom: 1px solid var(--line-soft);
  background: var(--chrome);
  font-size: 0.92rem;
}
.fig-num {
  font-weight: 700;
  color: var(--accent-ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.fig-title { font-weight: 600; }
.fig-hint {
  margin-left: auto;
  font-size: 0.76rem;
  color: var(--muted);
  white-space: nowrap;
}
.fig-body {
  padding: 1.4rem 1.2rem;
  overflow-x: auto;
  cursor: zoom-in;
}
.fig-body pre.mermaid {
  margin: 0;
  background: transparent;
  display: flex;
  justify-content: center;
  min-width: min-content;
}
/* pre-render state: hide raw mermaid text flash */
pre.mermaid:not([data-processed="true"]) { visibility: hidden; min-height: 120px; }

/* ---------- link cards (index) ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  margin: 2rem 0;
}
a.card {
  display: block;
  text-decoration: none;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.2rem 1.3rem 1.1rem;
  background: var(--bg);
  box-shadow: var(--shadow);
  transition: border-color 120ms ease, transform 120ms ease;
}
a.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card .card-part {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.card h3 { margin: 0.35rem 0 0.35rem; font-size: 1.06rem; }
.card p { margin: 0; font-size: 0.88rem; color: var(--muted); line-height: 1.55; }
.card .go { display: inline-block; margin-top: 0.7rem; font-size: 0.84rem; font-weight: 600; color: var(--accent-ink); }

/* ---------- tables ---------- */

.tablewrap { overflow-x: auto; margin: 1rem 0 1.6rem; max-width: 100%; }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td {
  text-align: left;
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}
thead th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
tbody tr:hover { background: var(--chrome); }
td.num {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.83rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- callouts ---------- */

.callout {
  border: 1px solid var(--line);
  border-left: 4px solid var(--warm);
  background: var(--warm-soft);
  border-radius: 0 10px 10px 0;
  padding: 1rem 1.3rem;
  margin: 1.6rem 0;
  max-width: 780px;
}
.callout.note { border-left-color: var(--accent); background: var(--accent-soft); }
.callout .label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--warm);
  margin-bottom: 0.3rem;
}
.callout.note .label { color: var(--accent-ink); }
.callout p { margin: 0.45rem 0; }

/* ---------- prev / next footer nav ---------- */

.pagenav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.pagenav a {
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.8rem 1.1rem;
  min-width: 220px;
  background: var(--bg);
}
.pagenav a:hover { border-color: var(--accent); }
.pagenav .dir { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
.pagenav .dest { display: block; font-weight: 600; color: var(--ink); margin-top: 0.15rem; }
.pagenav a.next { margin-left: auto; text-align: right; }

footer.site {
  margin-top: 3rem;
  color: var(--muted);
  font-size: 0.84rem;
  max-width: 780px;
}

/* ---------- fullscreen diagram viewer ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  /* fully opaque: a translucent backdrop lets the page's own diagram ghost
     through behind the fullscreen copy, which reads as duplicated boxes */
  background: #0E1619;
  display: none;
}
.lightbox.open { display: block; }
.lightbox .stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
}
.lightbox .stage.dragging { cursor: grabbing; }
.lightbox .canvas {
  position: absolute;
  top: 50%;
  left: 50%;
  transform-origin: 0 0;
}
.lightbox .canvas svg { display: block; }
.lightbox .toolbar {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  gap: 0.5rem;
  z-index: 2;
}
.lightbox .toolbar button {
  background: rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  font-size: 1rem;
  line-height: 1;
  padding: 0.55rem 0.8rem;
  cursor: pointer;
  font-family: inherit;
}
.lightbox .toolbar button:hover { background: rgba(255, 255, 255, 0.25); }
.lightbox .caption {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  color: #DCE6E2;
  font-size: 0.85rem;
  background: rgba(14, 22, 25, 0.7);
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- knowledge-graph explorer ---------- */

.controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 1.4rem 0 0.9rem;
}
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button {
  background: var(--bg);
  border: 0;
  border-right: 1px solid var(--line);
  padding: 0.45rem 0.85rem;
  font: inherit;
  font-size: 0.84rem;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--accent-ink); }
.seg button[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
}
.controls label.chk {
  font-size: 0.84rem;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}
.controls input[type="search"] {
  font: inherit;
  font-size: 0.86rem;
  padding: 0.42rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  min-width: 220px;
}
.controls input[type="search"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.controls .ghost {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.42rem 0.8rem;
  font: inherit;
  font-size: 0.84rem;
  color: var(--muted);
  cursor: pointer;
}
.controls .ghost:hover { color: var(--accent-ink); border-color: var(--accent); }

.graph-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1rem;
  align-items: stretch;
}
@media (max-width: 900px) { .graph-layout { grid-template-columns: 1fr; } }

.graph-canvas-wrap {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #FDFEFC;
  box-shadow: var(--shadow);
  overflow: hidden;
  height: 76vh;
  min-height: 480px;
}
.graph-canvas-wrap canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.graph-canvas-wrap canvas.dragging { cursor: grabbing; }
.graph-tip {
  position: absolute;
  pointer-events: none;
  background: rgba(22, 36, 42, 0.92);
  color: #F2F6F4;
  font-size: 0.78rem;
  line-height: 1.4;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  max-width: 300px;
  display: none;
  z-index: 5;
}
.graph-stats {
  position: absolute;
  left: 0.8rem;
  bottom: 0.7rem;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.72rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.25rem 0.6rem;
}

.graph-aside {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  overflow-y: auto;
  max-height: 76vh;
}
.graph-aside h3 { margin: 0 0 0.3rem; font-size: 1rem; overflow-wrap: anywhere; }
.graph-aside .meta { font-size: 0.78rem; color: var(--muted); margin-bottom: 0.6rem; }
.graph-aside .field { margin: 0.55rem 0; font-size: 0.86rem; }
.graph-aside .field .k {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.graph-aside .empty { color: var(--muted); font-size: 0.88rem; }
.graph-aside .edgegroup { margin-top: 0.7rem; }
.graph-aside .edgegroup .k {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.graph-aside button.nb {
  display: inline-block;
  margin: 0.15rem 0.25rem 0.15rem 0;
  font: inherit;
  font-size: 0.76rem;
  font-family: ui-monospace, Consolas, monospace;
  background: var(--chrome);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.12rem 0.4rem;
  cursor: pointer;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.graph-aside button.nb:hover { border-color: var(--accent); color: var(--accent-ink); }

.legend { display: flex; flex-wrap: wrap; gap: 0.4rem 0.9rem; margin: 0.9rem 0 0; }
.legend .chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.legend .chip .swatch {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid rgba(0, 0, 0, 0.15);
}
.legend .chip .swatch.line { width: 1.1rem; height: 3px; border-radius: 2px; border: 0; }
.legend .chip .swatch.line.thin { height: 2px; opacity: 0.55; }
.sw-declared { background: #0B4A42; }
.sw-belongs { background: #DFC49E; }
.sw-related { background: #AFC2BB; }
.sw-abstracts { background: #C9B8E8; }
.legend .legend-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 0.3rem;
}

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

.kbd-hint { color: var(--muted); font-size: 0.8rem; }

@media (max-width: 640px) {
  .hero { padding-top: 2rem; }
  .fig-body { padding: 0.9rem 0.6rem; }
}

@media print {
  .topbar, .pagenav, .fig-hint { display: none; }
  figure.fig { box-shadow: none; break-inside: avoid; }
  body { font-size: 12.5px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  a.card { transition: none; }
}
