@v11g/agents-rock 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. package/README.md +65 -0
  2. package/bin/agents-rock.mjs +4 -0
  3. package/package.json +13 -0
  4. package/plugins/solution-architect/.claude-plugin/plugin.json +9 -0
  5. package/plugins/solution-architect/skills/analyze-requirements/README.md +75 -0
  6. package/plugins/solution-architect/skills/analyze-requirements/SKILL.md +31 -0
  7. package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/OFL.txt +98 -0
  8. package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-mono-latin-400-normal.woff2 +0 -0
  9. package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-mono-latin-600-normal.woff2 +0 -0
  10. package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-sans-latin-400-normal.woff2 +0 -0
  11. package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-sans-latin-500-normal.woff2 +0 -0
  12. package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-sans-latin-600-normal.woff2 +0 -0
  13. package/plugins/solution-architect/skills/analyze-requirements/assets/mermaid-theme.json +52 -0
  14. package/plugins/solution-architect/skills/analyze-requirements/assets/section-help.json +101 -0
  15. package/plugins/solution-architect/skills/analyze-requirements/assets/viewer-template.html +2389 -0
  16. package/plugins/solution-architect/skills/analyze-requirements/references/interview.md +53 -0
  17. package/plugins/solution-architect/skills/analyze-requirements/references/likec4.md +157 -0
  18. package/plugins/solution-architect/skills/analyze-requirements/references/project-types.md +60 -0
  19. package/plugins/solution-architect/skills/analyze-requirements/references/research.md +78 -0
  20. package/plugins/solution-architect/skills/analyze-requirements/references/viewer.md +772 -0
  21. package/plugins/solution-architect/skills/analyze-requirements/references/writing.md +206 -0
  22. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/cdp.mjs +74 -0
  23. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/chrome.mjs +66 -0
  24. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/companion-links.mjs +20 -0
  25. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-kinds.mjs +37 -0
  26. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-links.mjs +26 -0
  27. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-routes.mjs +27 -0
  28. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-sections.mjs +78 -0
  29. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/embed.mjs +8 -0
  30. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/er-entities.mjs +16 -0
  31. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/fonts.mjs +39 -0
  32. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/frontmatter.mjs +17 -0
  33. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/inputs.mjs +41 -0
  34. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/likec4-config.mjs +41 -0
  35. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/likec4-extract.mjs +29 -0
  36. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/likec4-steps.mjs +22 -0
  37. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-defs.mjs +20 -0
  38. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-flows.mjs +46 -0
  39. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-inline.mjs +31 -0
  40. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-links.mjs +7 -0
  41. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-list.mjs +64 -0
  42. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-render.mjs +127 -0
  43. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-shape.mjs +19 -0
  44. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-tables.mjs +30 -0
  45. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-views.mjs +48 -0
  46. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-wide.mjs +44 -0
  47. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/nav.mjs +72 -0
  48. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/offline.mjs +19 -0
  49. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/port.mjs +13 -0
  50. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/quality-gate.mjs +113 -0
  51. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/section-help.mjs +49 -0
  52. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/slug-registry.mjs +11 -0
  53. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-clusters.mjs +15 -0
  54. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-deployment.mjs +8 -0
  55. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-elections.mjs +20 -0
  56. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-links.mjs +23 -0
  57. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-model-tables.mjs +24 -0
  58. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-palette.mjs +34 -0
  59. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-provenance.mjs +20 -0
  60. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-tree.mjs +16 -0
  61. package/plugins/solution-architect/skills/analyze-requirements/scripts/likec4-config.mjs +19 -0
  62. package/plugins/solution-architect/skills/analyze-requirements/scripts/likec4-export.mjs +35 -0
  63. package/plugins/solution-architect/skills/analyze-requirements/scripts/likec4-gen.mjs +39 -0
  64. package/plugins/solution-architect/skills/analyze-requirements/scripts/render.mjs +130 -0
  65. package/plugins/solution-architect/skills/analyze-requirements/scripts/serve.mjs +71 -0
  66. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/browser.test.mjs +553 -0
  67. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/companion-links.test.mjs +60 -0
  68. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-kinds.test.mjs +41 -0
  69. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-links.test.mjs +104 -0
  70. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-routes.test.mjs +54 -0
  71. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-sections.test.mjs +197 -0
  72. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/embed.test.mjs +28 -0
  73. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/er-entities.test.mjs +14 -0
  74. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/ARCHITECTURE.md +47 -0
  75. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/c4-src/broken/model.c4 +27 -0
  76. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/c4-src/pass/model.c4 +29 -0
  77. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/docs/adr/0001-sample.md +18 -0
  78. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/docs/estimate.html +2 -0
  79. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/docs/estimation.md +8 -0
  80. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/model-broken.json +1 -0
  81. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/model.json +1 -0
  82. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/threat-model.md +8 -0
  83. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/sample-model.json +1 -0
  84. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/sample.c4 +28 -0
  85. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fonts.test.mjs +38 -0
  86. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/frontmatter.test.mjs +27 -0
  87. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/inputs.test.mjs +72 -0
  88. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-config-cli.test.mjs +26 -0
  89. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-config.test.mjs +74 -0
  90. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-export-cli.test.mjs +61 -0
  91. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-extract.test.mjs +37 -0
  92. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-gen-cli.test.mjs +73 -0
  93. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-steps.test.mjs +32 -0
  94. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-flows.test.mjs +82 -0
  95. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-links.test.mjs +16 -0
  96. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-provenance.test.mjs +42 -0
  97. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-render.test.mjs +226 -0
  98. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-tables.test.mjs +30 -0
  99. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-views.test.mjs +76 -0
  100. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-wide.test.mjs +76 -0
  101. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/nav.test.mjs +236 -0
  102. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/offline.test.mjs +37 -0
  103. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/quality-gate.test.mjs +86 -0
  104. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/quality-gates.test.mjs +20 -0
  105. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/render.test.mjs +171 -0
  106. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/research-workflow.test.mjs +38 -0
  107. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/section-help.test.mjs +101 -0
  108. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/serve.test.mjs +48 -0
  109. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-clusters.test.mjs +46 -0
  110. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-deployment.test.mjs +23 -0
  111. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-elections.test.mjs +30 -0
  112. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-links.test.mjs +38 -0
  113. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-model-tables.test.mjs +51 -0
  114. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-provenance.test.mjs +28 -0
  115. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-tree.test.mjs +43 -0
  116. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/viewer-template.test.mjs +1206 -0
  117. package/plugins/solution-architect/skills/analyze-requirements/scripts/validate.mjs +88 -0
  118. package/plugins/solution-architect/skills/analyze-requirements/workflows/research.js +57 -0
  119. package/plugins/solution-architect/skills/estimate/README.md +67 -0
  120. package/plugins/solution-architect/skills/estimate/SKILL.md +64 -0
  121. package/plugins/solution-architect/skills/estimate/assets/estimate-template.html +1128 -0
  122. package/plugins/solution-architect/skills/estimate/references/ai-multipliers.md +95 -0
  123. package/plugins/solution-architect/skills/estimate/references/interview.md +80 -0
  124. package/plugins/solution-architect/skills/estimate/references/slicing.md +55 -0
  125. package/plugins/solution-architect/skills/estimate/references/techniques.md +111 -0
  126. package/plugins/solution-architect/skills/estimate/references/writing.md +211 -0
  127. package/plugins/solution-architect/skills/estimate/scripts/compute.mjs +23 -0
  128. package/plugins/solution-architect/skills/estimate/scripts/lib/checks.mjs +128 -0
  129. package/plugins/solution-architect/skills/estimate/scripts/lib/components.mjs +19 -0
  130. package/plugins/solution-architect/skills/estimate/scripts/lib/estimate-math.mjs +85 -0
  131. package/plugins/solution-architect/skills/estimate/scripts/lib/inline.mjs +10 -0
  132. package/plugins/solution-architect/skills/estimate/scripts/lib/redact.mjs +30 -0
  133. package/plugins/solution-architect/skills/estimate/scripts/lib/roadmap.mjs +32 -0
  134. package/plugins/solution-architect/skills/estimate/scripts/lib/rollup.mjs +122 -0
  135. package/plugins/solution-architect/skills/estimate/scripts/lib/schema.mjs +128 -0
  136. package/plugins/solution-architect/skills/estimate/scripts/render.mjs +65 -0
  137. package/plugins/solution-architect/skills/estimate/scripts/test/browser.test.mjs +623 -0
  138. package/plugins/solution-architect/skills/estimate/scripts/test/compute.test.mjs +88 -0
  139. package/plugins/solution-architect/skills/estimate/scripts/test/e2e.test.mjs +34 -0
  140. package/plugins/solution-architect/skills/estimate/scripts/test/estimate-math.test.mjs +112 -0
  141. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/booking-inputs.json +58 -0
  142. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/estimation-fail.md +30 -0
  143. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/estimation-pass.md +60 -0
  144. package/plugins/solution-architect/skills/estimate/scripts/test/quality-gates.test.mjs +20 -0
  145. package/plugins/solution-architect/skills/estimate/scripts/test/references.test.mjs +71 -0
  146. package/plugins/solution-architect/skills/estimate/scripts/test/render.test.mjs +121 -0
  147. package/plugins/solution-architect/skills/estimate/scripts/test/schema.test.mjs +129 -0
  148. package/plugins/solution-architect/skills/estimate/scripts/test/validate.test.mjs +72 -0
  149. package/plugins/solution-architect/skills/estimate/scripts/validate.mjs +20 -0
  150. package/plugins/solution-architect/skills/new-lead/README.md +48 -0
  151. package/plugins/solution-architect/skills/new-lead/SKILL.md +113 -0
  152. package/plugins/solution-architect/skills/new-lead/assets/dashboard/detail.html +842 -0
  153. package/plugins/solution-architect/skills/new-lead/assets/dashboard/index.html +655 -0
  154. package/plugins/solution-architect/skills/new-lead/assets/dashboard/start.sh +3 -0
  155. package/plugins/solution-architect/skills/new-lead/assets/dashboard/stats.mjs +98 -0
  156. package/plugins/solution-architect/skills/new-lead/assets/dashboard/vendor/reactflow-bundle.js +473 -0
  157. package/plugins/solution-architect/skills/new-lead/assets/vendor-build/entry.jsx +33 -0
  158. package/plugins/solution-architect/skills/new-lead/assets/vendor-build/package-lock.json +1055 -0
  159. package/plugins/solution-architect/skills/new-lead/assets/vendor-build/package.json +19 -0
  160. package/plugins/solution-architect/skills/new-lead/scripts/init-root.mjs +73 -0
  161. package/plugins/solution-architect/skills/new-lead/scripts/lead-upsert.mjs +31 -0
  162. package/plugins/solution-architect/skills/new-lead/scripts/lib/enrich.mjs +20 -0
  163. package/plugins/solution-architect/skills/new-lead/scripts/lib/map-nodes.mjs +124 -0
  164. package/plugins/solution-architect/skills/new-lead/scripts/lib/map.mjs +117 -0
  165. package/plugins/solution-architect/skills/new-lead/scripts/lib/port.mjs +15 -0
  166. package/plugins/solution-architect/skills/new-lead/scripts/lib/registry.mjs +116 -0
  167. package/plugins/solution-architect/skills/new-lead/scripts/serve.mjs +163 -0
  168. package/plugins/solution-architect/skills/new-lead/scripts/test/e2e-workspace.test.mjs +59 -0
  169. package/plugins/solution-architect/skills/new-lead/scripts/test/enrich.test.mjs +16 -0
  170. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/ARCHITECTURE.md +16 -0
  171. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/brief.md +4 -0
  172. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/dist/index.html +11 -0
  173. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/dist/proposal-non-tech.html +2 -0
  174. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/dist/threat-model.html +2 -0
  175. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/estimation-inputs.json +6 -0
  176. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/estimation.json +10 -0
  177. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/notes.md +3 -0
  178. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/proposal-non-tech.md +3 -0
  179. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/rfp.md +3 -0
  180. package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads.json +25 -0
  181. package/plugins/solution-architect/skills/new-lead/scripts/test/init-root.test.mjs +81 -0
  182. package/plugins/solution-architect/skills/new-lead/scripts/test/lead-upsert.test.mjs +67 -0
  183. package/plugins/solution-architect/skills/new-lead/scripts/test/map.test.mjs +72 -0
  184. package/plugins/solution-architect/skills/new-lead/scripts/test/port.test.mjs +31 -0
  185. package/plugins/solution-architect/skills/new-lead/scripts/test/registry-io.test.mjs +57 -0
  186. package/plugins/solution-architect/skills/new-lead/scripts/test/registry.test.mjs +49 -0
  187. package/plugins/solution-architect/skills/new-lead/scripts/test/serve.test.mjs +205 -0
  188. package/plugins/solution-architect/skills/new-lead/scripts/test/stats.test.mjs +92 -0
  189. package/plugins/solution-architect/skills/new-lead/scripts/test/validate-cli.test.mjs +24 -0
  190. package/plugins/solution-architect/skills/new-lead/scripts/test/vendor-bundle.test.mjs +9 -0
  191. package/plugins/solution-architect/skills/new-lead/scripts/validate.mjs +9 -0
  192. package/plugins/solution-architect/skills/proposal/README.md +36 -0
  193. package/plugins/solution-architect/skills/proposal/SKILL.md +58 -0
  194. package/plugins/solution-architect/skills/proposal/assets/proposal-template.html +82 -0
  195. package/plugins/solution-architect/skills/proposal/references/interview.md +63 -0
  196. package/plugins/solution-architect/skills/proposal/references/review.md +28 -0
  197. package/plugins/solution-architect/skills/proposal/references/writing.md +102 -0
  198. package/plugins/solution-architect/skills/proposal/scripts/derive.mjs +22 -0
  199. package/plugins/solution-architect/skills/proposal/scripts/lib/checks-client.mjs +75 -0
  200. package/plugins/solution-architect/skills/proposal/scripts/lib/checks-doc.mjs +54 -0
  201. package/plugins/solution-architect/skills/proposal/scripts/lib/checks.mjs +17 -0
  202. package/plugins/solution-architect/skills/proposal/scripts/lib/figures.mjs +43 -0
  203. package/plugins/solution-architect/skills/proposal/scripts/lib/jargon.mjs +9 -0
  204. package/plugins/solution-architect/skills/proposal/scripts/lib/sections.mjs +32 -0
  205. package/plugins/solution-architect/skills/proposal/scripts/render.mjs +60 -0
  206. package/plugins/solution-architect/skills/proposal/scripts/test/checks-client.test.mjs +144 -0
  207. package/plugins/solution-architect/skills/proposal/scripts/test/checks-doc.test.mjs +93 -0
  208. package/plugins/solution-architect/skills/proposal/scripts/test/docs.test.mjs +51 -0
  209. package/plugins/solution-architect/skills/proposal/scripts/test/e2e.test.mjs +30 -0
  210. package/plugins/solution-architect/skills/proposal/scripts/test/figures.test.mjs +81 -0
  211. package/plugins/solution-architect/skills/proposal/scripts/test/fixtures/proposal-fail.md +22 -0
  212. package/plugins/solution-architect/skills/proposal/scripts/test/fixtures/proposal-pass.md +55 -0
  213. package/plugins/solution-architect/skills/proposal/scripts/test/quality-gates.test.mjs +20 -0
  214. package/plugins/solution-architect/skills/proposal/scripts/test/render.test.mjs +70 -0
  215. package/plugins/solution-architect/skills/proposal/scripts/test/validate.test.mjs +40 -0
  216. package/plugins/solution-architect/skills/proposal/scripts/validate.mjs +20 -0
  217. package/src/cli/agents.mjs +12 -0
  218. package/src/cli/args.mjs +46 -0
  219. package/src/cli/install.mjs +68 -0
  220. package/src/cli/main.mjs +124 -0
  221. package/src/cli/picker.mjs +78 -0
  222. package/src/cli/registry.mjs +26 -0
  223. package/src/cli/uninstall.mjs +38 -0
@@ -0,0 +1,2389 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <!-- Declared, not merely implemented in CSS: the browser paints the canvas
7
+ before the boot script runs, so without this a dark-mode reader gets a white
8
+ flash — and the UA scrollbar and the search field's own clear button stay
9
+ light inside a dark page. -->
10
+ <meta name="color-scheme" content="light dark">
11
+ <meta name="description" content="Architecture documentation — one self-contained page, no network.">
12
+ <!-- The rail's own mark, inline. A linked file would be a second request from a
13
+ viewer whose whole premise is one offline file. -->
14
+ <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%230f766e' stroke-width='1.6' stroke-linejoin='round'%3E%3Cpath d='M10 1.8 18 6v8l-8 4.2L2 14V6z'/%3E%3Cpath d='M10 10.2 18 6M10 10.2v8M10 10.2 2 6'/%3E%3C/svg%3E">
15
+ <title><!-- slot:TITLE --></title>
16
+ <style>
17
+ /* The two faces the stacks below name and could not rely on, embedded as base64
18
+ woff2 by scripts/lib/fonts.mjs — nothing is fetched, and the bytes are not in
19
+ this file. Declared first, before anything names them. */
20
+ <!-- slot:FONTS -->
21
+
22
+ /* Still no network: what the slot embeds is IBM Plex Sans and Mono, the two
23
+ stacks whose fallback crosses a genre boundary. The display serif is left to
24
+ the platform on purpose — Iowan → Charter → Georgia is a book serif the whole
25
+ way down, so it degrades rather than substitutes. */
26
+ :root {
27
+ --font-display: 'Iowan Old Style', 'Charter', 'Bitstream Charter', 'Sitka Text',
28
+ 'Palatino Linotype', Palatino, Georgia, serif;
29
+ --font-body: 'IBM Plex Sans', 'Source Sans 3', 'Segoe UI Variable Text', 'Segoe UI',
30
+ Cantarell, Ubuntu, system-ui, sans-serif;
31
+ --font-mono: 'IBM Plex Mono', 'JetBrains Mono', 'SF Mono', 'Cascadia Code',
32
+ 'DejaVu Sans Mono', ui-monospace, monospace;
33
+
34
+ --bg: #fbfaf7; --surface: #ffffff; --surface-2: #f4f2ec; --surface-3: #edeae1;
35
+ --border: #e3dfd5; --border-strong: #cec8b9;
36
+ --text: #1c1b18; --text-dim: #6b675e; --text-faint: #938f84;
37
+ --accent: #0f766e; --accent-soft: rgba(15, 118, 110, .09); --accent-line: rgba(15, 118, 110, .35);
38
+ --shadow: 0 1px 2px rgba(28, 27, 24, .04), 0 8px 24px -12px rgba(28, 27, 24, .12);
39
+
40
+ /* State is its own scale, deliberately not the accent: teal already means
41
+ "link, brand, this diagram's elements" everywhere else, and a status that
42
+ borrows it says nothing. Ochre for a decision still open, brick for one
43
+ rejected — both warm, so they sit in the same world as the neutrals rather
44
+ than arriving from a UI kit. */
45
+ --state-open: #8a5a09; --state-open-soft: rgba(138, 90, 9, .11);
46
+ --state-stop: #a1322c; --state-stop-soft: rgba(161, 50, 44, .11);
47
+
48
+ /* One column, one width. A diagram or a wide table used to take a 1080px
49
+ track centred on the prose axis, which put its left edge ~190px outside
50
+ the paragraph above it — the reader re-found the margin on every block.
51
+ A block may now be narrower than the measure; none may be wider. */
52
+ --rail-w: 292px; --topbar-h: 52px;
53
+ /* 96ch, capped by the column it sits in. 74ch is the classic prose measure and
54
+ it was too tight once every table and diagram had to live inside it — three
55
+ of eighteen tables still cannot fit and scroll in their card. Widen this one
56
+ value to trade reading comfort for table room.
57
+ `100%`, not `calc(100vw - rail - 80px)`: .main is already offset by the rail
58
+ and its own padding, so subtracting them again restates the layout in a
59
+ second place — and 100vw counts the scrollbar gutter, which clipped ~15px
60
+ off every block on the platforms that reserve one. It also makes the cap
61
+ self-correcting below 960px, where the rail leaves the flow entirely. */
62
+ --measure: min(96ch, 100%);
63
+ /* The pinned diagram's gutter. Wide enough for a container view to stay
64
+ readable, narrow enough that the column keeps its full measure at 1440px —
65
+ which is why the pin is withdrawn below 1200px rather than shrunk. */
66
+ --pin-w: 380px;
67
+ /* One track, not two. A second `--prose` cap at 72ch was tried and reverted.
68
+ The number is right in isolation — measured on a real set, 96ch renders
69
+ ~108 characters a line against the 66-75 the convention asks for — but this
70
+ document is not isolated prose. Every h2 carries a full-width rule and the
71
+ sections are dense with full-width tables, so capping only the paragraphs
72
+ left the text ending ~240px short of the rule above it and the table below
73
+ it, and pushed the trailing provenance marker onto a line of its own. It
74
+ reads as one column or it does not read as a column. To bring the line
75
+ length down, `--measure` itself has to come down and the tables need
76
+ somewhere else to go. */
77
+ }
78
+ /* Dark palette is applied by both the media query and the explicit attribute so
79
+ the toggle wins in either direction. */
80
+ @media (prefers-color-scheme: dark) {
81
+ :root:not([data-theme="light"]) {
82
+ --bg: #0c1211; --surface: #121a19; --surface-2: #0f1716; --surface-3: #16211f;
83
+ --border: #22302e; --border-strong: #354743;
84
+ --text: #e9e7e1; --text-dim: #97a29e; --text-faint: #6d7772;
85
+ --accent: #2dd4bf; --accent-soft: rgba(45, 212, 191, .12); --accent-line: rgba(45, 212, 191, .4);
86
+ --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px -14px rgba(0, 0, 0, .7);
87
+ --state-open: #e0b567; --state-open-soft: rgba(224, 181, 103, .15);
88
+ --state-stop: #ef8f88; --state-stop-soft: rgba(239, 143, 136, .15);
89
+ }
90
+ }
91
+ :root[data-theme="dark"] {
92
+ --bg: #0c1211; --surface: #121a19; --surface-2: #0f1716; --surface-3: #16211f;
93
+ --border: #22302e; --border-strong: #354743;
94
+ --text: #e9e7e1; --text-dim: #97a29e; --text-faint: #6d7772;
95
+ --accent: #2dd4bf; --accent-soft: rgba(45, 212, 191, .12); --accent-line: rgba(45, 212, 191, .4);
96
+ --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px -14px rgba(0, 0, 0, .7);
97
+ --state-open: #e0b567; --state-open-soft: rgba(224, 181, 103, .15);
98
+ --state-stop: #ef8f88; --state-stop-soft: rgba(239, 143, 136, .15);
99
+ }
100
+
101
+ * { box-sizing: border-box; }
102
+ html { scroll-behavior: smooth; }
103
+ body {
104
+ margin: 0; background: var(--bg); color: var(--text);
105
+ font-family: var(--font-body); font-size: 16.5px; line-height: 1.7;
106
+ -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
107
+ overflow-wrap: break-word;
108
+ /* Belt to the braces of the single column: nothing is laid out wider than the
109
+ measure, so a sideways page scroll can only ever be a bug. Set on body
110
+ rather than html so it propagates to the viewport without making body a
111
+ clipping context — an expanded diagram is position: fixed inside it. */
112
+ overflow-x: clip;
113
+ }
114
+ ::selection { background: var(--accent-soft); }
115
+
116
+ /* The same ring the buttons and the rail heads already carry, extended to the
117
+ rest of what a keyboard reader can land on. These were falling through to the
118
+ UA default — visible, but a different object on every platform, and this page
119
+ has ten kinds of interactive surface. Named here rather than folded into each
120
+ component's block so there is one place that says what focus looks like.
121
+ Inset on the rail link, which sits in a padded well whose edge a 2px outer
122
+ ring would collide with; outside on the rest, which have room. */
123
+ .nav-link:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
124
+ .view-tab:focus-visible,
125
+ .page-chip:focus-visible,
126
+ .record-row:focus-visible,
127
+ .record-hit:focus-visible,
128
+ .help-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
129
+
130
+ /* One scrollbar treatment for every scroll container: the rail, a code block, a
131
+ wide table, a tab strip. The platform default is a ~15px grey slab, which
132
+ inside a table card is an object heavier than the hairline around it — and a
133
+ real set has a dozen of them. */
134
+ * { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
135
+ ::-webkit-scrollbar { width: 9px; height: 9px; }
136
+ ::-webkit-scrollbar-track { background: transparent; }
137
+ /* The transparent border plus content-box clip insets the thumb inside its
138
+ gutter, so it reads as a 5px pill floating in the padding rather than a bar
139
+ welded to the edge of the box. */
140
+ ::-webkit-scrollbar-thumb {
141
+ background: var(--border-strong); background-clip: content-box;
142
+ border: 2px solid transparent; border-radius: 20px;
143
+ }
144
+ ::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: content-box; }
145
+ ::-webkit-scrollbar-corner { background: transparent; }
146
+
147
+ /* ---------- skip link ---------- */
148
+ /* DOM order is topbar, rail, prose — which is the right reading order and the
149
+ wrong tab order: a real set puts ~120 rail links between the two, and a
150
+ keyboard reader had to walk every one of them to reach a sentence. Parked
151
+ above the viewport rather than clipped to a pixel, so when it takes focus it
152
+ lands over the bar it is offering to skip. */
153
+ .skip {
154
+ position: fixed; top: 10px; left: 10px; z-index: 200;
155
+ padding: 9px 14px; border-radius: 8px;
156
+ font-family: var(--font-mono); font-size: 10px; font-weight: 600;
157
+ text-transform: uppercase; letter-spacing: .12em;
158
+ color: var(--bg); background: var(--accent); text-decoration: none;
159
+ translate: 0 -300%; transition: translate .16s cubic-bezier(.2, 0, 0, 1);
160
+ }
161
+ /* :focus, not :focus-visible — a link this size is worth showing to whoever
162
+ reaches it, however they got there. */
163
+ .skip:focus { translate: 0 0; outline: 2px solid var(--text); outline-offset: 2px; }
164
+ /* The target takes focus programmatically and should not draw a ring for it. */
165
+ .main:focus { outline: none; }
166
+
167
+ /* Micro-label: the recurring texture for every piece of metadata. */
168
+ .eyebrow {
169
+ font-family: var(--font-mono); font-size: 10px; font-weight: 600;
170
+ text-transform: uppercase; letter-spacing: .18em; color: var(--text-faint);
171
+ }
172
+
173
+ /* ---------- reading progress ---------- */
174
+ /* Sits on the bottom edge of the top bar rather than above it: the bar it
175
+ belongs to is the one showing which section you are in, and the number
176
+ beside it. Across the whole 21-document set the line barely moved. */
177
+ /* Scaled from a full-width track rather than sized by percentage: the line is
178
+ inset by the rail, and a percentage width would resolve against the viewport
179
+ and run off the right edge at 100%. */
180
+ #progress {
181
+ position: fixed; top: calc(var(--topbar-h) - 2px); left: var(--rail-w); right: 0;
182
+ height: 2px; z-index: 60; background: var(--accent);
183
+ transform-origin: left; scale: 0 1; transition: scale .1s linear;
184
+ }
185
+
186
+ /* ---------- top bar ---------- */
187
+ .topbar {
188
+ position: fixed; top: 0; right: 0; left: var(--rail-w); height: var(--topbar-h);
189
+ display: flex; align-items: center; gap: 12px; padding: 0 24px; z-index: 40;
190
+ background: color-mix(in srgb, var(--bg) 88%, transparent);
191
+ backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
192
+ border-bottom: 1px solid var(--border);
193
+ }
194
+ .crumb {
195
+ font-family: var(--font-mono); font-size: 11px; letter-spacing: .04em;
196
+ color: var(--text-dim); white-space: nowrap; overflow: hidden;
197
+ text-overflow: ellipsis; flex: 1; min-width: 0;
198
+ }
199
+ .crumb b { color: var(--text); font-weight: 600; }
200
+ .crumb span { color: var(--text-faint); padding: 0 6px; }
201
+ /* Tabular figures and a fixed box: this number changes on every scroll event,
202
+ and proportional digits would shove the theme toggle sideways as it counts. */
203
+ .route-pos {
204
+ flex-shrink: 0; min-width: 40px; text-align: right;
205
+ font-family: var(--font-mono); font-size: 10px; font-weight: 600;
206
+ text-transform: uppercase; letter-spacing: .12em;
207
+ font-variant-numeric: tabular-nums; color: var(--text-faint);
208
+ }
209
+
210
+ .icon-btn {
211
+ position: relative;
212
+ display: inline-flex; align-items: center; justify-content: center; gap: 6px;
213
+ height: 32px; min-width: 32px; padding: 0 8px; flex-shrink: 0;
214
+ background: transparent; border: 1px solid var(--border); border-radius: 8px;
215
+ color: var(--text-dim); cursor: pointer;
216
+ transition: color .15s, border-color .15s, background .15s,
217
+ scale .12s cubic-bezier(.2, 0, 0, 1);
218
+ }
219
+ /* The visible chip stays 32px so the bar keeps its scale; the target is 40px.
220
+ The topbar gap is 12px, so the extended areas never touch. */
221
+ .icon-btn::after { content: ''; position: absolute; inset: -4px; }
222
+ .icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
223
+ .icon-btn:active { scale: .96; }
224
+ .icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
225
+ .icon-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6;
226
+ stroke-linecap: round; stroke-linejoin: round; }
227
+ #nav-toggle { display: none; }
228
+
229
+ /* Both icons stay in the DOM and cross-fade, so the theme switch reads as one
230
+ object turning over rather than two elements popping in and out. */
231
+ #theme-toggle { width: 32px; padding: 0; }
232
+ #theme-toggle svg {
233
+ position: absolute; top: 50%; left: 50%; margin: -7.5px 0 0 -7.5px;
234
+ transition: opacity .24s cubic-bezier(.2, 0, 0, 1), scale .24s cubic-bezier(.2, 0, 0, 1),
235
+ filter .24s cubic-bezier(.2, 0, 0, 1);
236
+ }
237
+ .i-sun { opacity: 1; scale: 1; filter: blur(0px); }
238
+ .i-moon { opacity: 0; scale: .25; filter: blur(4px); }
239
+ :root[data-theme="dark"] .i-sun { opacity: 0; scale: .25; filter: blur(4px); }
240
+ :root[data-theme="dark"] .i-moon { opacity: 1; scale: 1; filter: blur(0px); }
241
+ @media (prefers-color-scheme: dark) {
242
+ :root:not([data-theme="light"]) .i-sun { opacity: 0; scale: .25; filter: blur(4px); }
243
+ :root:not([data-theme="light"]) .i-moon { opacity: 1; scale: 1; filter: blur(0px); }
244
+ :root[data-theme="light"] .i-sun { opacity: 1; scale: 1; filter: blur(0px); }
245
+ :root[data-theme="light"] .i-moon { opacity: 0; scale: .25; filter: blur(4px); }
246
+ }
247
+
248
+ /* ---------- rail ---------- */
249
+ .sidebar {
250
+ position: fixed; inset: 0 auto 0 0; width: var(--rail-w); z-index: 50;
251
+ display: flex; flex-direction: column;
252
+ background: var(--surface-2); border-right: 1px solid var(--border);
253
+ }
254
+ .rail-head { padding: 18px 20px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
255
+ .rail-mark { display: flex; align-items: center; gap: 9px; margin-bottom: 14px; }
256
+ .rail-mark svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--accent); }
257
+ .rail-title {
258
+ font-family: var(--font-display); font-size: 15px; font-weight: 600; line-height: 1.25;
259
+ letter-spacing: -.01em; color: var(--text);
260
+ display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
261
+ }
262
+ .filter-wrap { position: relative; }
263
+ .filter-wrap svg {
264
+ position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
265
+ width: 13px; height: 13px; fill: none; stroke: var(--text-faint); stroke-width: 1.7;
266
+ pointer-events: none;
267
+ }
268
+ #nav-filter {
269
+ width: 100%; height: 32px; padding: 0 10px 0 28px;
270
+ font-family: var(--font-mono); font-size: 11.5px; color: var(--text);
271
+ background: var(--bg); border: 1px solid var(--border); border-radius: 7px;
272
+ transition: border-color .15s, box-shadow .15s;
273
+ }
274
+ #nav-filter::placeholder { color: var(--text-faint); }
275
+ #nav-filter:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
276
+
277
+ .rail-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 10px 12px 40px; }
278
+
279
+ .nav-chevron {
280
+ width: 11px; height: 11px; flex-shrink: 0; color: var(--text-faint);
281
+ transition: rotate .18s cubic-bezier(.2, 0, 0, 1);
282
+ }
283
+ .nav-sec[open] > .nav-sec__head .nav-chevron,
284
+ .nav-group[open] > .nav-group__head .nav-chevron { rotate: 90deg; }
285
+
286
+ /* Level 1 — one row per source directory. A 17-ADR run collapses to this row. */
287
+ .nav-sec + .nav-sec { margin-top: 3px; }
288
+ .nav-sec__head, .nav-group__head {
289
+ display: flex; align-items: center; gap: 8px; cursor: pointer;
290
+ list-style: none; user-select: none; transition: background .13s;
291
+ }
292
+ .nav-sec__head::-webkit-details-marker,
293
+ .nav-group__head::-webkit-details-marker { display: none; }
294
+ .nav-sec__head:hover, .nav-group__head:hover { background: var(--surface-3); }
295
+ .nav-sec__head:focus-visible, .nav-group__head:focus-visible {
296
+ outline: 2px solid var(--accent); outline-offset: -2px;
297
+ }
298
+ .nav-sec__head { min-height: 34px; padding: 0 9px; border-radius: 11px; }
299
+ .nav-sec__title {
300
+ flex: 1; min-width: 0; font-family: var(--font-mono); font-size: 10px; font-weight: 600;
301
+ text-transform: uppercase; letter-spacing: .16em; color: var(--text-dim);
302
+ white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
303
+ }
304
+ .nav-sec[open] > .nav-sec__head .nav-sec__title { color: var(--text); }
305
+ .nav-sec.is-current > .nav-sec__head .nav-sec__title { color: var(--accent); }
306
+ /* Recessed well: 11px outer radius less its 3px padding gives the 8px document
307
+ rows inside it — concentric, so the corners nest instead of fighting. */
308
+ .nav-sec[open] > .nav-sec__body {
309
+ margin-top: 2px; padding: 3px; border-radius: 11px;
310
+ background: var(--bg); border: 1px solid var(--border);
311
+ }
312
+
313
+ /* Level 2 — one row per document. */
314
+ .nav-group + .nav-group { margin-top: 1px; }
315
+ .nav-group__head { min-height: 32px; padding: 6px 9px; border-radius: 8px; }
316
+ .nav-group__title {
317
+ flex: 1; min-width: 0; font-size: 12px; font-weight: 600; letter-spacing: .005em;
318
+ color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
319
+ }
320
+ /* Tabular figures: the filter rewrites these counts live, and proportional
321
+ digits make the whole rail twitch sideways on every keystroke. */
322
+ .nav-sec__count, .nav-group__count {
323
+ font-family: var(--font-mono); font-size: 9.5px; font-weight: 600;
324
+ font-variant-numeric: tabular-nums; text-align: center; min-width: 22px;
325
+ color: var(--text-faint); background: var(--surface-3);
326
+ border-radius: 20px; padding: 2px 6px; flex-shrink: 0;
327
+ }
328
+ .nav-sec.is-current > .nav-sec__head .nav-sec__count,
329
+ .nav-group.is-current > .nav-group__head .nav-group__count {
330
+ background: var(--accent-soft); color: var(--accent);
331
+ }
332
+ .nav-group.is-current > .nav-group__head .nav-group__title { color: var(--accent); }
333
+
334
+ /* Hairline spine so nested links read as one run, like an index. */
335
+ .nav-group__body { margin: 2px 0 6px; padding-left: 15px; border-left: 1px solid var(--border); }
336
+ .nav-link {
337
+ display: block; position: relative; padding: 5px 9px; margin-left: -1px;
338
+ border-left: 2px solid transparent; border-radius: 0 6px 6px 0;
339
+ font-size: 12.5px; line-height: 1.4; color: var(--text-dim); text-decoration: none;
340
+ transition: color .13s, background .13s, border-color .13s;
341
+ }
342
+ .nav-link:hover { color: var(--text); background: var(--surface-3); }
343
+ .nav-link--sub { padding-left: 20px; font-size: 11.5px; color: var(--text-faint); }
344
+ .nav-link--sub::before {
345
+ content: ''; position: absolute; left: 9px; top: 50%; width: 5px; height: 1px;
346
+ background: var(--border-strong);
347
+ }
348
+ .nav-link.is-active {
349
+ color: var(--accent); background: var(--accent-soft);
350
+ border-left-color: var(--accent); font-weight: 600;
351
+ }
352
+ .nav-empty {
353
+ display: none; padding: 20px 10px; text-align: center;
354
+ font-family: var(--font-mono); font-size: 11px; color: var(--text-faint);
355
+ }
356
+ .sidebar.is-filtering :is(.nav-sec__count, .nav-group__count) { display: none; }
357
+ /* A document the filter promoted on its text rather than on any of its headings.
358
+ Without the marker the reader types a phrase and gets a row whose every
359
+ visible label lacks it, which reads as a bug in the filter. It takes the slot
360
+ the count badge vacates while filtering, so the row keeps its shape. */
361
+ .nav-group.is-body-hit > .nav-group__head::after {
362
+ content: 'in text'; flex-shrink: 0;
363
+ font-family: var(--font-mono); font-size: 9px; font-weight: 600;
364
+ text-transform: uppercase; letter-spacing: .1em;
365
+ color: var(--accent); background: var(--accent-soft);
366
+ border-radius: 20px; padding: 2px 6px;
367
+ }
368
+
369
+ /* One staggered reveal on load beats a dozen scattered micro-interactions. */
370
+ @keyframes rail-in { from { opacity: 0; translate: 0 6px; } to { opacity: 1; translate: 0 0; } }
371
+ .nav-sec { animation: rail-in .32s cubic-bezier(.2, 0, 0, 1) both; }
372
+ .nav-sec:nth-child(2) { animation-delay: .06s; }
373
+ .nav-sec:nth-child(3) { animation-delay: .12s; }
374
+ .nav-sec:nth-child(4) { animation-delay: .18s; }
375
+ .nav-sec:nth-child(n + 5) { animation-delay: .24s; }
376
+
377
+ .scrim { display: none; }
378
+
379
+ /* ---------- content ---------- */
380
+ .main {
381
+ margin-left: var(--rail-w); padding: calc(var(--topbar-h) + 40px) 40px 25vh;
382
+ }
383
+ .doc { max-width: var(--measure); margin: 0 auto; }
384
+ .main :is(h1, h2, h3, h4, h5, h6) { scroll-margin-top: calc(var(--topbar-h) + 20px); }
385
+ .diagram-shell, .table-wrap { scroll-margin-top: calc(var(--topbar-h) + 20px); }
386
+
387
+ /* The document title. It used to carry a "Document 07" eyebrow and a hairline
388
+ above it, both of which separated one document from the next in a single
389
+ scroll. With one document on screen there is nothing above to separate it
390
+ from, and a CSS counter cannot count pages that are not in the layout — it
391
+ read "Document 01" on every one. The page bar carries "7 / 15" instead. */
392
+ .doc-head {
393
+ position: relative; margin: 0 0 28px;
394
+ font-family: var(--font-display); font-weight: 600;
395
+ font-size: clamp(30px, 3.4vw, 43px); line-height: 1.12; letter-spacing: -.022em;
396
+ text-wrap: balance;
397
+ }
398
+ .doc-head + p { color: var(--text-dim); font-size: 17.5px; }
399
+
400
+ /* ---------- page routes ---------- */
401
+ /* One document in the layout at a time, addressed by its own route. Sections
402
+ are the grouping the rail shows; the page is what the reader opens. */
403
+ .doc-section[hidden], .page[hidden] { display: none; }
404
+
405
+ .main h2 {
406
+ margin: 58px 0 18px; font-family: var(--font-display); font-weight: 600;
407
+ font-size: 27px; line-height: 1.25; letter-spacing: -.014em;
408
+ padding-bottom: 9px; border-bottom: 1px solid var(--border);
409
+ }
410
+ /* h3 was 16px against 16.5px body text, so sub-sections read as bold
411
+ paragraphs. It has to outrank the prose to be a level at all. */
412
+ .main h3 {
413
+ margin: 40px 0 12px; font-family: var(--font-display);
414
+ font-size: 19.5px; font-weight: 600; line-height: 1.3; letter-spacing: -.008em;
415
+ color: var(--text);
416
+ }
417
+ .main h4, .main h5, .main h6 {
418
+ margin: 28px 0 8px; font-family: var(--font-mono); font-size: 11.5px; font-weight: 600;
419
+ text-transform: uppercase; letter-spacing: .11em; color: var(--text-dim);
420
+ }
421
+ .main :is(h2, h3) + p, .main :is(h4, h5, h6) + p { margin-top: 0; }
422
+ /* One line of air between paragraphs; anything less and the column reads as a
423
+ single block with bold interruptions. */
424
+ .main p { margin: 0 0 24px; text-wrap: pretty; }
425
+ /* Underline with an offset instead of a border: the border sat on the
426
+ descenders of g, y and p in every inline link. */
427
+ .main a {
428
+ color: var(--accent); text-decoration: underline;
429
+ text-decoration-color: var(--accent-line); text-decoration-thickness: 1px;
430
+ text-underline-offset: .18em; transition: text-decoration-color .15s;
431
+ }
432
+ .main a:hover { text-decoration-color: var(--accent); }
433
+ /* Block links — index rows, search hits, page-bar chips — are surfaces, not
434
+ words in a sentence. `.main a` outranks a bare class, so they have to be named
435
+ against it or every one of them grows a prose underline. */
436
+ .main :is(.record-row, .record-hit, .page-chip) { text-decoration: none; }
437
+
438
+ /* Landing from a deep link in a 21-document page gives no sense of arrival.
439
+ The mark fades but the rule stays until the reader moves on. */
440
+ @keyframes landed { from { background: var(--accent-soft); } to { background: transparent; } }
441
+ .main :is(h2, h3):target {
442
+ animation: landed 1.6s cubic-bezier(.2, 0, 0, 1) both;
443
+ box-shadow: -14px 0 0 -12px var(--accent);
444
+ }
445
+
446
+ /* Hover-revealed deep link — this is a reference document people cite. */
447
+ .anchor {
448
+ position: absolute; left: -1.05em; width: 1em; text-align: center;
449
+ border: none !important; color: var(--text-faint) !important;
450
+ opacity: 0; transition: opacity .13s; font-weight: 400;
451
+ }
452
+ .main :is(h2, h3):hover .anchor, .anchor:focus-visible { opacity: 1; }
453
+ .main :is(h2, h3) {
454
+ position: relative;
455
+ text-wrap: balance;
456
+ }
457
+
458
+ /* The section explains the system; this explains the section. Click, not hover:
459
+ the text is too long for a tooltip, and a hover-only control is unreachable
460
+ from a keyboard and on a touch screen. */
461
+ .help-btn {
462
+ position: relative; margin-left: .4em; padding: 0;
463
+ width: 1.15em; height: 1.15em; vertical-align: .06em;
464
+ border: 1px solid var(--border); border-radius: 50%;
465
+ background: none; color: var(--text-faint);
466
+ font: 600 .62em/1.15 var(--font-body); cursor: pointer;
467
+ transition: color .13s, border-color .13s;
468
+ }
469
+ .help-btn:hover { color: var(--text); border-color: var(--text-faint); }
470
+ .help-btn::after { content: ''; position: absolute; inset: -12px; }
471
+ .help-btn[aria-expanded="true"] { color: var(--accent); border-color: var(--accent); }
472
+ details.help { margin: 0 0 18px; }
473
+ details.help > summary { display: none; }
474
+ .help__body {
475
+ border-left: 2px solid var(--border); padding: 2px 0 2px 14px;
476
+ color: var(--text-dim); font-size: .94em;
477
+ }
478
+ .help__body p { margin: 0 0 6px; }
479
+ .help__body b { color: var(--text); font-weight: 600; }
480
+
481
+ code {
482
+ font-family: var(--font-mono); font-size: .855em;
483
+ background: var(--surface-3); border-radius: 4px; padding: .1em .38em;
484
+ color: var(--text); word-break: break-word;
485
+ }
486
+ /* The prose chip is sized for 16.5px body text. On a display heading it
487
+ becomes a grey box heavier than the words beside it — keep the monospace,
488
+ drop the container. */
489
+ :is(.doc-head, .main h2, .main h3) code {
490
+ background: none; padding: 0; font-size: .82em; font-weight: inherit;
491
+ }
492
+ /* Strict `pre`, not `pre-wrap`: these blocks carry directory trees whose
493
+ ├── └── │ connectors only line up while the source line breaks are the only
494
+ line breaks. Long lines scroll sideways instead of reflowing. */
495
+ pre {
496
+ font-family: var(--font-mono); font-size: 12.8px; line-height: 1.62;
497
+ background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
498
+ padding: 16px 18px; margin: 24px 0; max-height: 30rem; overflow: auto;
499
+ white-space: pre; box-shadow: var(--shadow);
500
+ }
501
+ pre code { white-space: inherit; background: none; padding: 0; font-size: inherit; }
502
+ blockquote {
503
+ margin: 24px 0; padding: 14px 18px; border-left: 2px solid var(--accent);
504
+ border-radius: 0 8px 8px 0; background: var(--surface-2); color: var(--text-dim);
505
+ }
506
+ blockquote > :last-child { margin-bottom: 0; }
507
+ hr { border: none; height: 1px; background: var(--border); margin: 48px 0; }
508
+
509
+ /* ---------- tables ---------- */
510
+ /* The card hugs its table up to the column and no further: a 3x15 index needing
511
+ 523px stays 523px wide, and a 15-column risk register stops at the measure
512
+ and scrolls inside itself. */
513
+ .table-wrap {
514
+ margin: 22px 0; border: 1px solid var(--border); border-radius: 10px;
515
+ overflow: hidden; background: var(--surface); box-shadow: var(--shadow);
516
+ width: 100%;
517
+ }
518
+ /* The height is what makes the sticky header below work at all. `overflow-x:
519
+ auto` computes the other axis from `visible` to `auto` — the same rule the tab
520
+ bar's own comment records — so this box is a scrollport on both axes. Left
521
+ unbounded it never scrolls vertically, the header sticks to a box that cannot
522
+ move, and a 40-row table scrolls its own column labels away under the top bar.
523
+ Capped, a tall table scrolls inside its card the way a long `pre` already does. */
524
+ .table-scroll {
525
+ overflow-x: auto; -webkit-overflow-scrolling: touch;
526
+ max-height: min(70vh, 40rem);
527
+ }
528
+ /* One width for every table, because content width gave each one its own and a
529
+ page of them read as a ragged right edge against a fixed prose column. The cap
530
+ stays: full width is a floor too, and without a ceiling a wide table pushes
531
+ past the column instead of wrapping its cells — 15 of the 18 tables in a real
532
+ set grew their own sideways scrollbar inside a vertical read. */
533
+ table {
534
+ border-collapse: collapse; width: 100%; max-width: 100%;
535
+ font-size: 13.5px; line-height: 1.55;
536
+ }
537
+ th {
538
+ position: sticky; top: 0; z-index: 1; text-align: left;
539
+ font-family: var(--font-mono); font-size: 10px; font-weight: 600;
540
+ text-transform: uppercase; letter-spacing: .13em; color: var(--text-dim);
541
+ background: var(--surface-2); padding: 11px 15px;
542
+ border-bottom: 1px solid var(--border-strong);
543
+ }
544
+ td {
545
+ padding: 11px 15px; border-bottom: 1px solid var(--border); vertical-align: top;
546
+ font-variant-numeric: tabular-nums;
547
+ }
548
+ /* Seven or more columns in an 891px measure is ~110px each, which is narrower
549
+ than the words going into it. Tried `overflow-wrap: anywhere` first — it does
550
+ remove the sideways scroll, because it is the only value min-content sizing
551
+ reads, but it breaks every cell mid-word ("TypeScri pt", "obs erv ed") and a
552
+ table nobody can read is worse than one that scrolls. A tighter scale buys the
553
+ columns real width instead, and md-render.mjs marks the table that needs it. */
554
+ .table--wide { font-size: 12px; }
555
+ .table--wide :is(th, td) { padding: 9px 11px; }
556
+ tbody tr:last-child td { border-bottom: none; }
557
+ tbody tr { transition: background .13s; }
558
+ tbody tr:hover { background: var(--surface-2); }
559
+ td code { background: var(--accent-soft); color: var(--accent); font-size: 11.5px; }
560
+
561
+ ul, ol { margin: 0 0 24px; padding-left: 1.4em; }
562
+ li { margin-bottom: 8px; }
563
+ li:last-child { margin-bottom: 0; }
564
+ li > :is(ul, ol) { margin: 8px 0 0; }
565
+ li::marker { color: var(--text-faint); }
566
+
567
+ /* ---------- definition grids ---------- */
568
+ /* A two-column table whose right column runs to prose is a definition list, and
569
+ 19 rows of hairline dividers is the worst way to show one. Cards stay at the
570
+ prose measure: the win here is scanning, not height, and a third column would
571
+ cost the reading edge. */
572
+ .def-grid {
573
+ display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
574
+ gap: 10px; margin: 22px 0;
575
+ }
576
+ .def {
577
+ padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px;
578
+ background: var(--surface); transition: border-color .15s, background .15s;
579
+ }
580
+ .def:hover { border-color: var(--border-strong); background: var(--surface-2); }
581
+ .def dt {
582
+ margin-bottom: 6px; font-family: var(--font-display); font-size: 15px;
583
+ font-weight: 600; letter-spacing: -.006em; color: var(--text); text-wrap: balance;
584
+ }
585
+ .def dd {
586
+ margin: 0; font-size: 14px; line-height: 1.6; color: var(--text-dim); text-wrap: pretty;
587
+ }
588
+ .def dd code { font-size: 12px; }
589
+
590
+ /* A wide table with two or three rows (§9 External Integrations is eight columns
591
+ describing one integration) is a record, not a comparison, and md-wide.mjs
592
+ turns it sideways. One card per row: the first column names it, the rest are
593
+ label/value pairs stacked so a long value has the whole column to wrap in
594
+ instead of a 1/8th cell. Two columns of pairs above 640px, one below. */
595
+ .rec-cards { display: grid; gap: 12px; margin: 22px 0; }
596
+ .rec-card {
597
+ padding: 16px 18px; border: 1px solid var(--border); border-radius: 12px;
598
+ background: var(--surface); box-shadow: var(--shadow);
599
+ }
600
+ .rec-card__name {
601
+ margin: 0 0 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border);
602
+ font-family: var(--font-display); font-size: 16px; font-weight: 600;
603
+ letter-spacing: -.008em; color: var(--text);
604
+ }
605
+ .rec-card__fields {
606
+ display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
607
+ gap: 12px 24px; margin: 0;
608
+ }
609
+ .rec-field dt {
610
+ margin-bottom: 3px; font-size: 11.5px; font-weight: 600; letter-spacing: .06em;
611
+ text-transform: uppercase; color: var(--text-faint);
612
+ }
613
+ .rec-field dd {
614
+ margin: 0; font-size: 14px; line-height: 1.6; color: var(--text); text-wrap: pretty;
615
+ }
616
+ .rec-field dd code { font-size: 12px; }
617
+
618
+ /* A reference to a file the viewer does not contain. Rendered as text rather
619
+ than a link that goes nowhere; mono marks it as a path without borrowing the
620
+ link colour and promising a destination. */
621
+ .ext-ref {
622
+ font-family: var(--font-mono); font-size: .88em; color: var(--text-dim);
623
+ border-bottom: 1px dotted var(--border-strong);
624
+ }
625
+
626
+ /* ---------- view tabs ---------- */
627
+ .view-tabs { margin: 26px 0; }
628
+ /* overflow-y: hidden is not decoration. overflow-x: auto computes the other
629
+ axis from visible to auto, so the bar grew a vertical scrollbar — arrows and
630
+ all — for the 5px its tabs' hit areas stuck out of a 3px padding. */
631
+ .view-tabs__bar {
632
+ display: flex; gap: 2px; padding: 5px; margin-bottom: 10px;
633
+ overflow-x: auto; overflow-y: hidden;
634
+ background: var(--surface-2); border: 1px solid var(--border); border-radius: 13px;
635
+ }
636
+ /* 13px bar radius less its 5px padding gives 8px tabs — concentric, so the
637
+ selected chip nests instead of fighting the corner it sits in. */
638
+ .view-tab {
639
+ position: relative; flex: 0 0 auto; height: 30px; padding: 0 13px;
640
+ font-family: var(--font-mono); font-size: 11px; font-weight: 600;
641
+ letter-spacing: .04em; color: var(--text-dim); white-space: nowrap;
642
+ background: transparent; border: none; border-radius: 8px; cursor: pointer;
643
+ transition: color .15s, background .15s, scale .12s cubic-bezier(.2, 0, 0, 1);
644
+ }
645
+ /* 30px chip, 40px target. Extended vertically only, so neighbours 2px apart
646
+ never overlap. */
647
+ .view-tab::after { content: ''; position: absolute; inset: -5px 0; }
648
+ .view-tab:hover { color: var(--text); }
649
+ .view-tab:active { scale: .96; }
650
+ .view-tab[aria-selected="true"] {
651
+ color: var(--text); background: var(--surface);
652
+ box-shadow: 0 1px 2px rgb(0 0 0 / .07), 0 0 0 1px var(--border);
653
+ }
654
+ .view-panel[hidden] { display: none; }
655
+ /* Vertical margins only: the shorthand would also reset the breakout's negative
656
+ left margin, pushing a 1068px diagram off the right edge of the viewport. */
657
+ .view-tabs .diagram-shell { margin-top: 0; margin-bottom: 0; }
658
+
659
+ /* The page bar sits above the document's title, so the scroll target has to be
660
+ the page, not its heading, or prev/next lands off screen. */
661
+ .page { scroll-margin-top: calc(var(--topbar-h) + 20px); }
662
+ .page-bar {
663
+ display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
664
+ margin-bottom: 28px; padding-bottom: 14px; border-bottom: 1px solid var(--border);
665
+ }
666
+ .page-chip {
667
+ position: relative; display: inline-flex; align-items: center; gap: 6px;
668
+ height: 30px; padding: 0 11px; flex-shrink: 0;
669
+ font-family: var(--font-mono); font-size: 10.5px; font-weight: 600;
670
+ text-transform: uppercase; letter-spacing: .11em;
671
+ color: var(--text-dim); text-decoration: none; cursor: pointer;
672
+ background: transparent; border: 1px solid var(--border); border-radius: 8px;
673
+ transition: color .15s, border-color .15s, background .15s,
674
+ scale .12s cubic-bezier(.2, 0, 0, 1);
675
+ }
676
+ .page-chip::after { content: ''; position: absolute; inset: -5px 0; }
677
+ .page-chip:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
678
+ .page-chip:active { scale: .96; }
679
+ .page-chip[aria-disabled="true"] { opacity: .35; pointer-events: none; }
680
+ .page-pos {
681
+ font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .11em;
682
+ font-variant-numeric: tabular-nums; color: var(--text-faint);
683
+ }
684
+ .page-steps { display: flex; gap: 6px; margin-left: auto; }
685
+
686
+ /* ---------- index pages ---------- */
687
+ .record-summary {
688
+ margin: 0 0 18px; font-family: var(--font-mono); font-size: 11px; font-weight: 600;
689
+ letter-spacing: .1em; text-transform: uppercase;
690
+ font-variant-numeric: tabular-nums; color: var(--text-faint);
691
+ }
692
+ /* The generated list, shown only when the author's own index does not link every
693
+ record. Rows rather than cards: this is an index of 15 things, and the reader
694
+ is scanning one column of titles for a name they already half-remember. */
695
+ .record-list { display: grid; gap: 4px; margin: 0 0 28px; }
696
+ .record-list > .eyebrow { margin-bottom: 4px; }
697
+ .record-row {
698
+ display: grid; grid-template-columns: 2.4em 1fr auto; align-items: baseline; gap: 12px;
699
+ padding: 10px 13px; text-decoration: none; color: inherit;
700
+ border: 1px solid transparent; border-radius: 9px;
701
+ transition: border-color .15s, background .15s;
702
+ }
703
+ .record-row:hover { border-color: var(--border); background: var(--surface); }
704
+ .record-row__n {
705
+ font-family: var(--font-mono); font-size: 11px; font-weight: 600;
706
+ font-variant-numeric: tabular-nums; color: var(--text-faint);
707
+ }
708
+ .record-row b { font-size: 14.5px; font-weight: 600; color: var(--text); text-wrap: pretty; }
709
+ /* Accepted is the quiet default — most records are settled, and colouring the
710
+ majority tells the reader nothing. What earns a colour is a decision still open
711
+ and one that was rejected. Superseded is struck rather than tinted: the point is
712
+ not severity, it is "this is no longer the answer", and a line says that where a
713
+ third hue would just be a third hue. An absent status gets an outline, because
714
+ nothing was recorded and a filled pill would claim a value. */
715
+ .record-row__s {
716
+ font-family: var(--font-mono); font-size: 9.5px; font-weight: 600;
717
+ text-transform: uppercase; letter-spacing: .1em; color: var(--text-dim);
718
+ background: var(--surface-3); border: 1px solid transparent;
719
+ border-radius: 20px; padding: 3px 8px; white-space: nowrap;
720
+ }
721
+ .record-row__s[data-status="proposed"],
722
+ .record-row__s[data-status="draft"] {
723
+ color: var(--state-open); background: var(--state-open-soft);
724
+ }
725
+ .record-row__s[data-status="rejected"] {
726
+ color: var(--state-stop); background: var(--state-stop-soft);
727
+ }
728
+ .record-row__s[data-status="superseded"],
729
+ .record-row__s[data-status="deprecated"] {
730
+ color: var(--text-faint); text-decoration: line-through;
731
+ }
732
+ .record-row__s[data-status="unrecorded"] {
733
+ color: var(--text-faint); background: none; border-color: var(--border-strong);
734
+ border-style: dashed;
735
+ }
736
+
737
+ /* The four provenance words are a closed vocabulary, not code. They used to
738
+ render as <code>, which put them in accent teal — the same chip as `org_id` —
739
+ so the most repeated element in the set read as a snippet. Small caps in the
740
+ utility face, no fill: a footnote about where the sentence came from, sitting
741
+ beside the sentence rather than competing with it. */
742
+ .prov {
743
+ font-family: var(--font-mono); font-size: 9.5px; font-weight: 600;
744
+ text-transform: uppercase; letter-spacing: .1em; color: var(--text-faint);
745
+ border: 1px solid var(--border); border-radius: 3px; padding: .15em .4em;
746
+ vertical-align: .1em; white-space: nowrap;
747
+ }
748
+ .prov[data-prov="proposed"] { color: var(--state-open); border-color: var(--state-open-soft); }
749
+
750
+ /* Hiding the records takes them out of reach of the browser's own find, so the
751
+ index searches their text directly. They are still in the DOM — only hidden —
752
+ so this reads the same characters Ctrl+F would have, and can say which
753
+ record matched instead of dropping the reader into an unlabelled slab. */
754
+ .record-search { margin: 0 0 14px; }
755
+ .record-search input {
756
+ width: 100%; height: 40px; padding: 0 14px;
757
+ font-family: var(--font-body); font-size: 14px; color: var(--text);
758
+ background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
759
+ transition: border-color .15s, box-shadow .15s;
760
+ }
761
+ .record-search input::placeholder { color: var(--text-faint); }
762
+ .record-search input:focus {
763
+ outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
764
+ }
765
+ .record-empty {
766
+ margin: 0; padding: 16px 14px; text-align: center;
767
+ font-family: var(--font-mono); font-size: 11.5px; color: var(--text-faint);
768
+ background: var(--surface-2); border: 1px dashed var(--border-strong);
769
+ border-radius: 9px;
770
+ }
771
+ .record-hits { display: grid; gap: 6px; margin: 0 0 24px; }
772
+ .record-hits:empty { margin: 0; }
773
+ .record-hit {
774
+ display: block; padding: 11px 14px; text-decoration: none; color: inherit;
775
+ background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
776
+ transition: border-color .15s, background .15s;
777
+ }
778
+ .record-hit:hover { border-color: var(--accent-line); background: var(--surface-2); }
779
+ .record-hit b {
780
+ display: block; margin-bottom: 3px; font-size: 14px; font-weight: 600; color: var(--text);
781
+ }
782
+ .record-hit span { font-size: 12.5px; line-height: 1.55; color: var(--text-dim); }
783
+ .record-hit mark {
784
+ background: var(--accent-soft); color: var(--accent); border-radius: 3px; padding: 0 2px;
785
+ }
786
+
787
+ /* ---------- diagrams ---------- */
788
+ .diagram-shell {
789
+ position: relative; margin: 26px 0; border: 1px solid var(--border); border-radius: 12px;
790
+ background: var(--surface); box-shadow: var(--shadow);
791
+ }
792
+ .diagram-shell:fullscreen { width: 100vw; height: 100vh; margin: 0; border: none;
793
+ border-radius: 0; background: var(--bg); }
794
+ .diagram-toolbar {
795
+ position: absolute; top: 8px; right: 8px; z-index: 5; display: flex; gap: 1px;
796
+ background: color-mix(in srgb, var(--surface) 82%, transparent);
797
+ backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
798
+ border: 1px solid var(--border); border-radius: 8px; padding: 3px;
799
+ }
800
+ .diagram-toolbar button {
801
+ display: inline-flex; align-items: center; justify-content: center;
802
+ width: 27px; height: 27px; padding: 0; border: none; background: transparent;
803
+ color: var(--text-dim); cursor: pointer; border-radius: 5px;
804
+ font-family: var(--font-mono); font-size: 9.5px; font-weight: 600; letter-spacing: .02em;
805
+ transition: background .13s, color .13s;
806
+ }
807
+ /* The one control carrying a value rather than an icon. Tabular figures and a
808
+ floor on the width, because it rewrites on every zoom step and proportional
809
+ digits would shove the three buttons beside it sideways as it counted. */
810
+ .diagram-toolbar [data-zoom-reset] {
811
+ width: auto; min-width: 38px; padding: 0 6px;
812
+ font-variant-numeric: tabular-nums;
813
+ }
814
+ .diagram-toolbar button:hover { background: var(--surface-3); color: var(--text); }
815
+ .diagram-toolbar button:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }
816
+ .diagram-toolbar svg { width: 14px; height: 14px; fill: none; stroke: currentColor;
817
+ stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
818
+ .diagram-toolbar [data-exit-fullscreen] { display: none; }
819
+ .diagram-shell:fullscreen [data-exit-fullscreen] { display: inline-flex; }
820
+ .diagram-viewport {
821
+ overflow: hidden; min-height: 320px; display: flex; align-items: center;
822
+ justify-content: center; padding: 20px;
823
+ }
824
+ .diagram-shell:fullscreen .diagram-viewport { height: 100vh; }
825
+ .diagram-viewport:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
826
+ /* Panning is offered only once there is something to pan — zoomed in, expanded,
827
+ or fullscreen. Two reasons it is a state rather than the default: at 1:1 the
828
+ whole diagram is already in the box, so a grab cursor promises movement that
829
+ cannot happen; and `touch-action: none` there would swallow the page scroll of
830
+ any reader whose finger lands on a diagram on the way down the document. */
831
+ .diagram-viewport.is-pannable { cursor: grab; touch-action: none; }
832
+ .diagram-viewport.is-pannable.is-panning { cursor: grabbing; user-select: none; }
833
+ .diagram-canvas { transform-origin: center; }
834
+ .diagram-shell.is-expanded {
835
+ position: fixed; inset: 20px; width: auto; margin: 0; z-index: 100;
836
+ box-shadow: 0 24px 70px -18px rgba(0, 0, 0, .5);
837
+ }
838
+ .diagram-shell.is-expanded .diagram-viewport { height: calc(100% - 12px); }
839
+
840
+ /* ---------- pinning ---------- */
841
+ /* Diagrams are what an architecture set is for, and they sit inline: scrolling
842
+ to the paragraph explaining a container scrolls the container view off the
843
+ screen, so the reader holds it in their head or scrolls back. Expand and
844
+ fullscreen both answer a different question — they cover the prose.
845
+ A pin docks the diagram in its own gutter and leaves the column readable. */
846
+ .diagram-shell.is-pinned {
847
+ position: fixed; z-index: 90; margin: 0;
848
+ top: calc(var(--topbar-h) + 16px); right: 16px; bottom: 16px;
849
+ width: var(--pin-w);
850
+ display: flex; flex-direction: column;
851
+ box-shadow: 0 24px 70px -18px rgba(0, 0, 0, .5);
852
+ }
853
+ /* min-height: 0 because the viewport carries its own 320px floor, which in a
854
+ flex column is a floor on the item too — the pane would overflow its own
855
+ bottom edge on a short window instead of the diagram shrinking. */
856
+ .diagram-shell.is-pinned .diagram-viewport { flex: 1; min-height: 0; }
857
+ /* The pane is fixed, so it is out of flow and cannot push anything. Without a
858
+ reserved gutter it sits over the column it was pinned to be read beside. */
859
+ body.has-pin .main { padding-right: calc(var(--pin-w) + 56px); }
860
+ /* Holds the height the shell had, so taking it out of the flow does not shorten
861
+ the document under a reader whose scroll offset the browser is keeping. */
862
+ .diagram-slot { margin: 26px 0; }
863
+
864
+ /* A diagram mermaid could not parse. Named as a failure rather than left to show
865
+ its own source: an unhandled render puts a slab of DSL inside a diagram frame,
866
+ which reads as a code block somebody meant to put there. Brick, because this is
867
+ the same "something is wrong" the rejected-status pill means. */
868
+ .diagram-error {
869
+ margin: 0; padding: 16px 18px;
870
+ font-family: var(--font-mono); font-size: 12px; line-height: 1.6;
871
+ color: var(--state-stop); background: var(--state-stop-soft);
872
+ border-radius: 8px; white-space: pre-wrap; overflow-wrap: anywhere;
873
+ }
874
+
875
+ /* LikeC4 fits its view to the box it is given. Without an explicit one the
876
+ webcomponent collapses to a thumbnail in the middle of an empty shell. */
877
+ .diagram-shell.is-c4 .diagram-canvas,
878
+ .diagram-shell.is-mermaid .diagram-canvas { width: 100%; }
879
+ .diagram-shell.is-mermaid .mermaid-canvas { display: flex; justify-content: center; }
880
+ .diagram-shell.is-c4 .diagram-viewport { padding: 0; }
881
+
882
+ /* A relation label is a word on a line, not a component. Mermaid draws it as an
883
+ opaque chip and locks its text to primaryTextColor — the light ink solid teal
884
+ fills need — so every chip it can paint has to be dark to stay legible, which
885
+ on a cream page is a dark blob. No theme variable can say "no chip".
886
+ Mermaid's SVG is in the page's own DOM, unlike LikeC4's shadow root, so the
887
+ viewer takes the label back: the page surface behind it (which masks the line
888
+ the label sits on — transparent would let it strike through the text) and the
889
+ page's own ink in front. Both already flip with the theme, so there is no
890
+ per-mode hex left to state. `!important` because mermaid injects its own
891
+ rules into the SVG and wins on specificity otherwise.
892
+
893
+ All three layers, because mermaid paints the chip on a different one per
894
+ diagram type: the ER label colours the wrapping div, the flowchart label the
895
+ innermost paragraph. Miss one and that diagram type keeps its blob. */
896
+ .diagram-canvas .labelBkg,
897
+ .diagram-canvas span.edgeLabel,
898
+ .diagram-canvas span.edgeLabel p {
899
+ background-color: var(--surface) !important;
900
+ color: var(--text) !important;
901
+ }
902
+ c4-view { display: block; width: 100%; height: 460px; }
903
+ .diagram-shell.is-c4:fullscreen c4-view,
904
+ .diagram-shell.is-c4.is-expanded c4-view { height: 100%; }
905
+
906
+ /* ---------- record drawer ---------- */
907
+
908
+ /* §14 Decisions already tables every ADR, so a Decision Records rail section was
909
+ the same set a second time — and the reader was looking at §14 when they
910
+ clicked, so replacing the page threw away the row they came from. A record opens
911
+ over it instead, and closing puts them back exactly where they were with no
912
+ scroll to re-find. */
913
+ #drawer {
914
+ position: fixed; top: 0; right: 0; bottom: 0; z-index: 120;
915
+ display: flex; flex-direction: column;
916
+ width: min(720px, 100%); background: var(--bg);
917
+ border-left: 1px solid var(--border);
918
+ box-shadow: -24px 0 60px -20px rgba(0, 0, 0, .35);
919
+ transform: translateX(100%); transition: transform .26s cubic-bezier(.2, 0, 0, 1);
920
+ /* Not display:none when shut: a panel that pops in has no direction, and the
921
+ slide is what says "this is over the page, not instead of it". */
922
+ visibility: hidden;
923
+ }
924
+ #drawer.is-open { transform: translateX(0); visibility: visible; }
925
+ .drawer-scrim {
926
+ position: fixed; inset: 0; z-index: 110; background: rgba(12, 18, 17, .38);
927
+ opacity: 0; pointer-events: none; transition: opacity .26s;
928
+ }
929
+ .drawer-scrim.is-open { opacity: 1; pointer-events: auto; }
930
+ .drawer__bar {
931
+ display: flex; align-items: center; gap: 12px; flex: none;
932
+ height: var(--topbar-h); padding: 0 12px 0 22px;
933
+ border-bottom: 1px solid var(--border); background: var(--surface-2);
934
+ }
935
+ /* Names the record, does not repeat its title. The bar carried the whole 90-char
936
+ ADR heading in 10.5px uppercase letter-spaced mono — an eyebrow treatment
937
+ applied to a paragraph — while the H1 two lines below said the same thing. */
938
+ .drawer__label {
939
+ font-family: var(--font-mono); font-size: 10.5px;
940
+ font-weight: 600; text-transform: uppercase; letter-spacing: .13em;
941
+ color: var(--text-dim); white-space: nowrap;
942
+ }
943
+ .drawer__bar #drawer-status { margin-right: auto; }
944
+ .drawer__body { flex: 1; overflow-y: auto; padding: 30px 34px 60px; }
945
+ /* The record is the whole panel, so it drops the page's own measure: 720px of
946
+ drawer capped at 96ch would leave the text in a column of its own inside it. */
947
+ .drawer__body .page { max-width: none; }
948
+ .drawer__body .doc-head { margin-top: 0; }
949
+ @media (max-width: 760px) {
950
+ .drawer__body { padding: 22px 20px 48px; }
951
+ }
952
+
953
+ /* ---------- responsive ---------- */
954
+ /* Above this the column keeps its 96ch beside a 380px pane; below it, one of the
955
+ two has to give, and a diagram squeezed into 240px is not a diagram. The
956
+ control is withdrawn rather than shrunk — and a pin already taken before a
957
+ resize is released, or it stays welded to a viewport with no gutter left. */
958
+ @media (max-width: 1200px) {
959
+ .diagram-toolbar [data-pin] { display: none; }
960
+ .diagram-shell.is-pinned {
961
+ position: relative; inset: auto; width: auto; margin: 26px 0;
962
+ display: block; box-shadow: var(--shadow);
963
+ }
964
+ .diagram-slot { display: none; }
965
+ body.has-pin .main { padding-right: 40px; }
966
+ }
967
+ /* No narrow-desktop breakpoint, and no --measure override below either: the
968
+ measure resolves against the column the rail has already left, so it gives up
969
+ width on its own before the 96ch cap ever binds. */
970
+ @media (max-width: 960px) {
971
+ :root { --rail-w: 300px; }
972
+ .topbar { left: 0; padding: 0 14px; }
973
+ #progress { left: 0; }
974
+ .route-pos { min-width: 0; letter-spacing: .06em; }
975
+ #nav-toggle { display: inline-flex; }
976
+ .sidebar {
977
+ transform: translateX(-100%); transition: transform .26s cubic-bezier(.4, 0, .2, 1);
978
+ box-shadow: none;
979
+ }
980
+ .sidebar.is-open { transform: translateX(0); box-shadow: 0 0 60px rgba(0, 0, 0, .3); }
981
+ .scrim {
982
+ display: block; position: fixed; inset: 0; z-index: 45; background: rgba(10, 12, 12, .5);
983
+ opacity: 0; pointer-events: none; transition: opacity .26s;
984
+ backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
985
+ }
986
+ .scrim.is-open { opacity: 1; pointer-events: auto; }
987
+ .main { margin-left: 0; padding: calc(var(--topbar-h) + 26px) 18px 20vh; }
988
+ .doc-head { font-size: clamp(26px, 7vw, 34px); }
989
+ .main h2 { font-size: 21px; margin-top: 40px; }
990
+ body { font-size: 16px; }
991
+ }
992
+ @media (prefers-reduced-motion: reduce) {
993
+ html { scroll-behavior: auto; }
994
+ *, *::before, *::after {
995
+ animation-duration: .01ms !important; transition-duration: .01ms !important;
996
+ }
997
+ }
998
+ @media print {
999
+ .sidebar, .topbar, .scrim, #progress, .diagram-toolbar,
1000
+ .skip, .drawer-scrim, .drawer__bar, .page-bar { display: none; }
1001
+ .main { margin: 0; padding: 0; }
1002
+ /* Paper has no viewport to pin against: a fixed pane prints once, over page
1003
+ one, and the place it was pinned from prints as a gap. Back in the flow. */
1004
+ .diagram-shell.is-pinned {
1005
+ position: static; inset: auto; width: auto; margin: 26px 0;
1006
+ display: block; box-shadow: none;
1007
+ }
1008
+ .diagram-slot { display: none; }
1009
+ /* The cap that lets the sticky header work is a screen affordance. Paper has
1010
+ no scrollport, so a table taller than it would simply lose its last rows.
1011
+ (`pre` carries a 30rem cap with the same consequence — untouched here
1012
+ because it predates this rule and is its own call.) */
1013
+ .table-scroll { max-height: none; overflow: visible; }
1014
+ /* Printing printed whichever document the router had in the layout — one of
1015
+ twenty-one, and inside a routed section one record of fifteen. Paper has no
1016
+ router and every page is already in the DOM, only hidden, so it can have the
1017
+ whole set. Which is what somebody printing an architecture document meant. */
1018
+ .doc-section[hidden], .page[hidden] { display: block; }
1019
+ /* An open record has been moved into the drawer, so it prints from there or
1020
+ not at all. Static rather than the fixed panel it is on screen: in flow it
1021
+ lands at the end of the set instead of over the first page of it. */
1022
+ #drawer {
1023
+ position: static; transform: none; visibility: visible;
1024
+ width: auto; border: none; box-shadow: none;
1025
+ }
1026
+ .drawer__body { overflow: visible; padding: 0; }
1027
+ /* A control on paper is a control nobody can press. The panel is a closed
1028
+ <details> and prints closed, which leaves the document as authored — but
1029
+ the <details> itself still carries its margin, so it must hide too or
1030
+ every heading leaves a blank box the height of a collapsed panel. */
1031
+ .help-btn, details.help { display: none; }
1032
+ }
1033
+ </style>
1034
+ </head>
1035
+ <body>
1036
+ <script>
1037
+ /* Guarded, because this runs before the body paints and localStorage is not
1038
+ always readable: blocked site data throws SecurityError, and so does a
1039
+ file:// origin in some browsers — which is exactly how a single-file offline
1040
+ viewer gets opened. Unguarded, the throw takes the theme and every script
1041
+ after it, so the page renders in the wrong mode or not at all. Losing the
1042
+ stored preference is the correct failure; losing the page is not. */
1043
+ (function () {
1044
+ var stored = null;
1045
+ try { stored = localStorage.getItem('arch-docs-theme'); } catch (e) { /* no store */ }
1046
+ if (stored) document.documentElement.setAttribute('data-theme', stored);
1047
+ })();
1048
+ </script>
1049
+
1050
+ <a class="skip" href="#main-content">Skip to content</a>
1051
+
1052
+ <div id="progress"></div>
1053
+
1054
+ <header class="topbar">
1055
+ <button class="icon-btn" id="nav-toggle" type="button" aria-label="Toggle navigation"
1056
+ aria-controls="sidebar" aria-expanded="false">
1057
+ <svg viewBox="0 0 20 20"><path d="M3 5h14M3 10h14M3 15h14"/></svg>
1058
+ </button>
1059
+ <div class="crumb" id="crumb"></div>
1060
+ <span class="route-pos" id="route-pos" aria-live="off"
1061
+ title="How far through this section you have read"></span>
1062
+ <button class="icon-btn" id="theme-toggle" type="button" aria-label="Toggle dark and light theme">
1063
+ <svg class="i-sun" viewBox="0 0 20 20"><circle cx="10" cy="10" r="3.6"/><path d="M10 1.6v2M10 16.4v2M3.1 3.1l1.4 1.4M15.5 15.5l1.4 1.4M1.6 10h2M16.4 10h2M3.1 16.9l1.4-1.4M15.5 4.5l1.4-1.4"/></svg>
1064
+ <svg class="i-moon" viewBox="0 0 20 20"><path d="M17.3 11.1A7.6 7.6 0 0 1 8.9 2.7a7.6 7.6 0 1 0 8.4 8.4z"/></svg>
1065
+ </button>
1066
+ </header>
1067
+
1068
+ <div class="scrim" id="scrim"></div>
1069
+
1070
+ <nav class="sidebar" id="sidebar" aria-label="Document sections">
1071
+ <div class="rail-head">
1072
+ <div class="rail-mark">
1073
+ <svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.5"
1074
+ stroke-linejoin="round" aria-hidden="true">
1075
+ <path d="M10 1.8 18 6v8l-8 4.2L2 14V6z"/><path d="M10 10.2 18 6M10 10.2v8M10 10.2 2 6"/>
1076
+ </svg>
1077
+ <div class="rail-title" id="rail-title"></div>
1078
+ </div>
1079
+ <div class="filter-wrap">
1080
+ <svg viewBox="0 0 16 16"><circle cx="7" cy="7" r="4.4"/><path d="m10.4 10.4 3.1 3.1"/></svg>
1081
+ <input id="nav-filter" type="search" placeholder="Filter sections…"
1082
+ autocomplete="off" spellcheck="false" aria-label="Filter sections">
1083
+ </div>
1084
+ </div>
1085
+ <div class="rail-scroll" id="rail-scroll">
1086
+ <!-- slot:NAV -->
1087
+ <div class="nav-empty" id="nav-empty">No matching sections</div>
1088
+ </div>
1089
+ </nav>
1090
+ <script>
1091
+ /* Mirrors <title> into the rail so TITLE stays a single template slot, and so
1092
+ the rail is labelled even if the diagram bundles below fail to boot. */
1093
+ document.getElementById('rail-title').textContent = document.title;
1094
+ </script>
1095
+
1096
+ <!-- tabindex="-1" so the skip link can actually put focus here. Without it the
1097
+ link moves the viewport and leaves the tab position back up in the rail, so
1098
+ the next Tab returns the reader to the row they were escaping. -->
1099
+ <main class="main" id="main-content" tabindex="-1">
1100
+ <article class="doc"><!-- slot:DOC --></article>
1101
+ </main>
1102
+
1103
+ <div class="drawer-scrim" id="drawer-scrim"></div>
1104
+ <aside class="drawer" id="drawer" role="dialog" aria-modal="true" aria-labelledby="drawer-title"
1105
+ aria-hidden="true">
1106
+ <header class="drawer__bar">
1107
+ <span class="drawer__label" id="drawer-title">Decision record</span>
1108
+ <span class="record-row__s" id="drawer-status" hidden></span>
1109
+ <button class="icon-btn" id="drawer-close" type="button" aria-label="Close record" title="Close">
1110
+ <svg viewBox="0 0 18 18" aria-hidden="true" fill="none" stroke="currentColor"
1111
+ stroke-width="1.6" stroke-linecap="round"><path d="M4.5 4.5l9 9M13.5 4.5l-9 9"/></svg>
1112
+ </button>
1113
+ </header>
1114
+ <div class="drawer__body" id="drawer-body"></div>
1115
+ </aside>
1116
+
1117
+ <script type="module"><!-- slot:LIKEC4_BUNDLE --></script>
1118
+
1119
+ <script type="module">
1120
+ window.ARCH_DOCS_THEME = <!-- slot:THEME -->;
1121
+ /* Guidance about the template, not claims about the documented system, so it
1122
+ sits outside the observed/stated/researched/proposed provenance rules. Data
1123
+ only: the loop below decides what to render from it. */
1124
+ window.ARCH_DOCS_HELP = <!-- slot:SECTION_HELP -->;
1125
+ <!-- slot:MERMAID_BUNDLE -->
1126
+ var root = document.documentElement;
1127
+ /* Live, not sampled once: a reader can turn reduced motion on mid-session and
1128
+ the router reads this on every jump. */
1129
+ var reduced = matchMedia('(prefers-reduced-motion: reduce)');
1130
+
1131
+ function isDark() {
1132
+ var set = root.getAttribute('data-theme');
1133
+ return set ? set === 'dark' : matchMedia('(prefers-color-scheme: dark)').matches;
1134
+ }
1135
+
1136
+ /* Mermaid bakes colours into the SVG at render time, so the palette has to be
1137
+ chosen before rendering and the diagrams re-rendered whenever it changes.
1138
+
1139
+ Merged over the shared palette, not swapped for it. `themeVariables` holds the
1140
+ elements: solid fills carrying their own text colour, which is what makes them
1141
+ legible either way — and it is what LikeC4 does, whose node fill samples as the
1142
+ same hex in light and dark with only the canvas flipping. `light` and `dark`
1143
+ hold the chrome that sits against that canvas and therefore has to flip with
1144
+ it: subgraph panels, edge-label chips, prose ink. Both blocks state the same
1145
+ keys, so a palette edit cannot land in one mode and leave a stale hex in the
1146
+ other — which is exactly how a cream page ended up with black boundary
1147
+ panels. */
1148
+ function initMermaid() {
1149
+ var t = window.ARCH_DOCS_THEME;
1150
+ var vars = Object.assign({}, t.themeVariables, isDark() ? t.dark : t.light);
1151
+ mermaid.initialize({ theme: 'base', themeVariables: vars, layout: 'elk' });
1152
+ }
1153
+ /* LikeC4 renders its own SVG in a shadow root and takes light/dark from a
1154
+ color-scheme attribute — outer CSS custom properties reach the host and stop
1155
+ there, which is why the fill hue has to come from the model instead. Without
1156
+ this the toggle re-rendered mermaid and left every diagram in the mode it
1157
+ booted in: a light diagram sitting on a dark page. */
1158
+ function syncDiagramTheme() {
1159
+ var mode = isDark() ? 'dark' : 'light';
1160
+ document.querySelectorAll('c4-view').forEach(function (v) {
1161
+ v.setAttribute('color-scheme', mode);
1162
+ });
1163
+ }
1164
+
1165
+ mermaid.registerLayoutLoaders(elkLayouts);
1166
+ initMermaid();
1167
+ syncDiagramTheme();
1168
+
1169
+ var sidebar = document.getElementById('sidebar');
1170
+ var scrim = document.getElementById('scrim');
1171
+ var navToggle = document.getElementById('nav-toggle');
1172
+
1173
+ document.getElementById('theme-toggle').addEventListener('click', function () {
1174
+ var next = isDark() ? 'light' : 'dark';
1175
+ root.setAttribute('data-theme', next);
1176
+ /* Same guard as the boot script: the toggle still has to work for this session
1177
+ even where the preference cannot be kept for the next one. */
1178
+ try { localStorage.setItem('arch-docs-theme', next); } catch (e) { /* no store */ }
1179
+ /* One call per renderer, in one place. Split across two handlers is how the
1180
+ two diagram systems drifted out of step to begin with. */
1181
+ initMermaid();
1182
+ rerenderDiagrams();
1183
+ syncDiagramTheme();
1184
+ });
1185
+
1186
+ function setDrawer(open) {
1187
+ sidebar.classList.toggle('is-open', open);
1188
+ scrim.classList.toggle('is-open', open);
1189
+ navToggle.setAttribute('aria-expanded', String(open));
1190
+ }
1191
+ navToggle.addEventListener('click', function () { setDrawer(!sidebar.classList.contains('is-open')); });
1192
+ scrim.addEventListener('click', function () { setDrawer(false); });
1193
+ addEventListener('keydown', function (e) { if (e.key === 'Escape') setDrawer(false); });
1194
+
1195
+ /* ---- reading progress ----
1196
+ Scoped to the open document, not to the whole set. Against 21 documents the
1197
+ line barely left the left edge while the reader worked through one of them,
1198
+ which is the unit they are actually reading. */
1199
+ var progress = document.getElementById('progress');
1200
+ var routePos = document.getElementById('route-pos');
1201
+ var activePage = null;
1202
+
1203
+ function tick() {
1204
+ if (!activePage) return;
1205
+ var box = activePage.getBoundingClientRect();
1206
+ var span = box.height - innerHeight;
1207
+ var done = span > 0 ? Math.min(1, Math.max(0, -box.top / span)) : 1;
1208
+ progress.style.scale = done + ' 1';
1209
+ /* A section shorter than the viewport has nothing to scroll, and "100%" on a
1210
+ page the reader has not touched yet reads as a bug. The full line already
1211
+ says the whole section is on screen. */
1212
+ routePos.textContent = span > 0 ? Math.round(done * 100) + '%' : '';
1213
+ }
1214
+ addEventListener('scroll', tick, { passive: true });
1215
+
1216
+ /* ---- deep-link anchors and section explainers on every heading ---- */
1217
+ /* One pass, and the order inside it matters: the anchor prepends a '#' to the
1218
+ heading, so the title has to be read before that happens or every lookup
1219
+ misses by one character. */
1220
+ function helpPanel(entry) {
1221
+ var d = document.createElement('details');
1222
+ d.className = 'help';
1223
+ var body = document.createElement('div');
1224
+ body.className = 'help__body';
1225
+ body.appendChild(helpRow('What goes here', entry.what));
1226
+ body.appendChild(helpRow('Why it matters', entry.why));
1227
+ body.appendChild(helpRow('What good looks like', entry.good));
1228
+ d.appendChild(document.createElement('summary'));
1229
+ d.appendChild(body);
1230
+ return d;
1231
+ }
1232
+
1233
+ function helpRow(label, text) {
1234
+ var p = document.createElement('p');
1235
+ var b = document.createElement('b');
1236
+ b.textContent = label + ' — ';
1237
+ p.appendChild(b);
1238
+ p.appendChild(document.createTextNode(text));
1239
+ return p;
1240
+ }
1241
+
1242
+ var helpSeq = 0;
1243
+ var helpSpine = null;
1244
+
1245
+ /* The markdown is the source of truth and it varies: a real set writes
1246
+ "## 1 Goals and Scope" where the asset's key is "Goals & Scope". Matched raw,
1247
+ all sixteen lookups missed and the page drew no buttons at all. Mirrors
1248
+ normTitle in scripts/lib/section-help.mjs — the leading number is dropped
1249
+ rather than matched on, because §3 is brownfield-only and a greenfield set
1250
+ renumbers everything after it. */
1251
+ function helpKey(title) {
1252
+ return String(title)
1253
+ .replace(/^\s*\d+[.)]?\s+/, '')
1254
+ .replace(/&/g, 'and')
1255
+ .replace(/\s+/g, ' ')
1256
+ .trim()
1257
+ .toLowerCase();
1258
+ }
1259
+
1260
+ function spineEntry(title) {
1261
+ if (!helpSpine) {
1262
+ helpSpine = {};
1263
+ var src = (window.ARCH_DOCS_HELP || {}).spine || {};
1264
+ for (var k in src) if (Object.prototype.hasOwnProperty.call(src, k)) {
1265
+ helpSpine[helpKey(k)] = src[k];
1266
+ }
1267
+ }
1268
+ return helpSpine[helpKey(title)];
1269
+ }
1270
+
1271
+ /* Keyed on heading text, not on the id: slugify keeps both spaces around a
1272
+ stripped "&", and subheadings share one dedupe registry with h2, so the slug
1273
+ can shift under a heading without anything failing. Which heading levels get
1274
+ an explainer is settled at the heading loop below. */
1275
+ function helpEntryFor(h, title) {
1276
+ var help = window.ARCH_DOCS_HELP || {};
1277
+ var page = h.closest('.page');
1278
+ var kind = page && page.dataset.kind;
1279
+ if (h.tagName === 'H1') return (help.companions || {})[kind];
1280
+ return h.tagName === 'H2' && kind === 'spine' ? spineEntry(title) : null;
1281
+ }
1282
+
1283
+ /* aria-expanded says a state; aria-controls says what is in that state. The
1284
+ panel's summary is hidden because the button drives it, so this pairing is
1285
+ the only thing connecting the two for a screen reader. */
1286
+ function helpButton(panel, title) {
1287
+ var btn = document.createElement('button');
1288
+ btn.type = 'button';
1289
+ btn.className = 'help-btn';
1290
+ btn.textContent = '?';
1291
+ btn.setAttribute('aria-expanded', 'false');
1292
+ btn.setAttribute('aria-controls', panel.id);
1293
+ btn.setAttribute('aria-label', 'What belongs in ' + title);
1294
+ return btn;
1295
+ }
1296
+
1297
+ /* Read from the <details> element's own event rather than set inside the click
1298
+ handler, so anything that opens the panel without a click — not just this
1299
+ button — still leaves aria-expanded matching panel.open. */
1300
+ function wireHelpToggle(btn, panel) {
1301
+ btn.addEventListener('click', function () {
1302
+ panel.open = !panel.open;
1303
+ });
1304
+ panel.addEventListener('toggle', function () {
1305
+ btn.setAttribute('aria-expanded', String(panel.open));
1306
+ /* Reading progress is measured from scroll offsets, so the panel changing
1307
+ the section's height leaves the readout stale until the next scroll. */
1308
+ tick();
1309
+ });
1310
+ }
1311
+
1312
+ function injectSectionHelp(h, title) {
1313
+ var entry = helpEntryFor(h, title);
1314
+ if (!entry) return;
1315
+ var panel = helpPanel(entry);
1316
+ helpSeq += 1;
1317
+ panel.id = 'help-' + helpSeq;
1318
+ var btn = helpButton(panel, title);
1319
+ h.appendChild(btn);
1320
+ h.after(panel);
1321
+ wireHelpToggle(btn, panel);
1322
+ }
1323
+
1324
+ /* h1 for a companion document's single explainer, h2 for the spine's sixteen.
1325
+ h3 is out of scope, and only the spine gets per-heading explainers: §14
1326
+ Decisions is itself a spine section and already the home for what a decision
1327
+ record is, so a per-record explainer would be that guidance seventeen times. */
1328
+ document.querySelectorAll('.doc h1.doc-head, .doc h2[id], .doc h3[id]').forEach(function (h) {
1329
+ var title = h.textContent.trim();
1330
+ injectSectionHelp(h, title);
1331
+ if (h.tagName === 'H1') return;
1332
+ var a = document.createElement('a');
1333
+ a.className = 'anchor';
1334
+ a.href = '#' + h.id;
1335
+ a.textContent = '#';
1336
+ a.setAttribute('aria-label', 'Link to ' + title);
1337
+ h.prepend(a);
1338
+ });
1339
+
1340
+ /* ---- tables get a scroll container so wide rows never blow out the column ---- */
1341
+ document.querySelectorAll('.doc table').forEach(function (t) {
1342
+ var wrap = document.createElement('div');
1343
+ wrap.className = 'table-wrap';
1344
+ var scroll = document.createElement('div');
1345
+ scroll.className = 'table-scroll';
1346
+ t.replaceWith(wrap);
1347
+ wrap.appendChild(scroll);
1348
+ scroll.appendChild(t);
1349
+ });
1350
+
1351
+ /* ---- view tabs: one system at several zoom levels, one panel at a time ---- */
1352
+ document.querySelectorAll('.view-tabs').forEach(function (group) {
1353
+ var tabs = [].slice.call(group.querySelectorAll('.view-tab'));
1354
+ var panels = [].slice.call(group.querySelectorAll('.view-panel'));
1355
+ function select(n, focus) {
1356
+ tabs.forEach(function (t, i) {
1357
+ t.setAttribute('aria-selected', String(i === n));
1358
+ t.tabIndex = i === n ? 0 : -1;
1359
+ });
1360
+ panels.forEach(function (p, i) { p.hidden = i !== n; });
1361
+ if (focus) tabs[n].focus();
1362
+ dispatchEvent(new Event('resize'));
1363
+ }
1364
+ tabs.forEach(function (tab, i) {
1365
+ tab.addEventListener('click', function () { select(i, false); });
1366
+ tab.addEventListener('keydown', function (e) {
1367
+ var step = e.key === 'ArrowRight' ? 1 : (e.key === 'ArrowLeft' ? -1 : 0);
1368
+ if (!step) return;
1369
+ e.preventDefault();
1370
+ select((i + step + tabs.length) % tabs.length, true);
1371
+ });
1372
+ });
1373
+ });
1374
+
1375
+ /* ---- rail: filter ---- */
1376
+ var filter = document.getElementById('nav-filter');
1377
+ var sections = [].slice.call(document.querySelectorAll('.nav-sec'));
1378
+ var groups = [].slice.call(document.querySelectorAll('.nav-group'));
1379
+ var navEmpty = document.getElementById('nav-empty');
1380
+
1381
+ function titleOf(el, cls) { return el.querySelector(cls).textContent.toLowerCase(); }
1382
+
1383
+ /* Filtering force-opens whatever it hits, so the reader's own open/closed
1384
+ layout is stashed on the elements and restored when the box is cleared. */
1385
+ function stashOpen() {
1386
+ sections.concat(groups).forEach(function (d) { d.dataset.wasOpen = d.open ? '1' : '0'; });
1387
+ }
1388
+ function restoreOpen(d) {
1389
+ if ('wasOpen' in d.dataset) d.open = d.dataset.wasOpen === '1';
1390
+ }
1391
+
1392
+ /* Every document's own text, keyed by route. Filled once the router has sorted
1393
+ records from pages — see the note where it is populated. */
1394
+ var docText = new Map();
1395
+ function bodyHas(g, q) {
1396
+ var text = docText.get(g.dataset.route);
1397
+ return Boolean(text) && text.indexOf(q) !== -1;
1398
+ }
1399
+
1400
+ /* The filter used to match heading labels and nothing else, which is wayfinding
1401
+ rather than search: a reader looking for "row-level security" found it only if
1402
+ somebody had made it a heading. Every page is already in the DOM, so matching
1403
+ the body costs an indexOf per document and no index at all.
1404
+ A body match promotes the whole document rather than any one heading — the
1405
+ phrase is somewhere in it, and Ctrl+F finds the line once the page is open. */
1406
+ function filterGroup(g, q) {
1407
+ var links = [].slice.call(g.querySelectorAll('.nav-link'));
1408
+ var inTitle = Boolean(q) && titleOf(g, '.nav-group__title').indexOf(q) !== -1;
1409
+ var labelled = links.some(function (a) { return q && a.dataset.label.indexOf(q) !== -1; });
1410
+ var inBody = Boolean(q) && !inTitle && !labelled && bodyHas(g, q);
1411
+ var hit = inTitle || inBody;
1412
+ var found = 0;
1413
+ links.forEach(function (a) {
1414
+ var show = !q || hit || a.dataset.label.indexOf(q) !== -1;
1415
+ a.style.display = show ? '' : 'none';
1416
+ if (show) found += 1;
1417
+ });
1418
+ g.classList.toggle('is-body-hit', inBody);
1419
+ g.style.display = !q || found || hit ? '' : 'none';
1420
+ if (q) g.open = Boolean(found || hit); else restoreOpen(g);
1421
+ return found || (hit ? 1 : 0);
1422
+ }
1423
+
1424
+ function filterSection(sec, q) {
1425
+ var hit = Boolean(q) && titleOf(sec, '.nav-sec__title').indexOf(q) !== -1;
1426
+ var found = 0;
1427
+ [].slice.call(sec.querySelectorAll('.nav-group')).forEach(function (g) {
1428
+ found += filterGroup(g, hit ? '' : q);
1429
+ });
1430
+ sec.style.display = !q || found || hit ? '' : 'none';
1431
+ if (q) sec.open = Boolean(found || hit); else restoreOpen(sec);
1432
+ return found;
1433
+ }
1434
+
1435
+ /* The filter is the viewer's only wayfinding control and it was reachable by Tab
1436
+ or by mouse alone — from the bottom of a document that is a long way back.
1437
+ `/` is the convention in every documentation reader; ⌘K is the convention
1438
+ everywhere else, so both work. On a phone the rail has to come out first, or
1439
+ focus lands in a panel that is off screen. */
1440
+ addEventListener('keydown', function (e) {
1441
+ var el = e.target;
1442
+ var typing = /^(INPUT|TEXTAREA|SELECT)$/.test(el.tagName) || el.isContentEditable;
1443
+ var slash = e.key === '/' && !e.metaKey && !e.ctrlKey && !e.altKey;
1444
+ var palette = e.key === 'k' && (e.metaKey || e.ctrlKey);
1445
+ if (typing || !(slash || palette)) return;
1446
+ e.preventDefault();
1447
+ if (innerWidth <= 960) setDrawer(true);
1448
+ filter.focus();
1449
+ filter.select();
1450
+ });
1451
+
1452
+ /* Escape clears the box and stops there. The same key closes the mobile rail and
1453
+ any open record, and a reader clearing a search asked for neither — so the
1454
+ event does not reach those handlers. An already-empty box hands focus back
1455
+ instead, which is the second press doing what the reader meant. */
1456
+ filter.addEventListener('keydown', function (e) {
1457
+ if (e.key !== 'Escape') return;
1458
+ e.stopPropagation();
1459
+ if (!filter.value) { filter.blur(); return; }
1460
+ filter.value = '';
1461
+ filter.dispatchEvent(new Event('input'));
1462
+ });
1463
+
1464
+ var stashed = false;
1465
+ filter.addEventListener('input', function () {
1466
+ var q = filter.value.trim().toLowerCase();
1467
+ if (q && !stashed) { stashOpen(); stashed = true; }
1468
+ sidebar.classList.toggle('is-filtering', Boolean(q));
1469
+ var hits = 0;
1470
+ sections.forEach(function (sec) { hits += filterSection(sec, q); });
1471
+ navEmpty.style.display = q && !hits ? 'block' : 'none';
1472
+ if (!q) stashed = false;
1473
+ });
1474
+
1475
+ /* ---- rail: scroll spy ---- */
1476
+ var links = [].slice.call(document.querySelectorAll('.nav-link'));
1477
+ var byId = {};
1478
+ var targets = [];
1479
+ links.forEach(function (a) {
1480
+ var el = document.getElementById(decodeURIComponent(a.getAttribute('href').slice(1)));
1481
+ if (!el) return;
1482
+ byId[el.id] = a;
1483
+ targets.push(el);
1484
+ });
1485
+ document.querySelectorAll('.doc .doc-head[id]').forEach(function (el) { targets.push(el); });
1486
+
1487
+ var crumb = document.getElementById('crumb');
1488
+ var current = null;
1489
+
1490
+ function setCrumb(parts) {
1491
+ crumb.innerHTML = '';
1492
+ parts.filter(Boolean).forEach(function (part, i) {
1493
+ if (i) crumb.appendChild(Object.assign(document.createElement('span'), { textContent: '/' }));
1494
+ crumb.appendChild(part.strong
1495
+ ? Object.assign(document.createElement('b'), { textContent: part.text })
1496
+ : document.createTextNode(part.text));
1497
+ });
1498
+ }
1499
+
1500
+ function clearActive() {
1501
+ links.forEach(function (l) { l.classList.remove('is-active'); });
1502
+ groups.forEach(function (g) { g.classList.remove('is-current'); });
1503
+ sections.forEach(function (s) { s.classList.remove('is-current'); });
1504
+ }
1505
+
1506
+ // A hit inside a collapsed section is invisible, so open both levels.
1507
+ function revealIn(sec, group) {
1508
+ if (sec) { sec.classList.add('is-current'); if (!filter.value) sec.open = true; }
1509
+ if (group) {
1510
+ group.classList.add('is-current');
1511
+ if (!filter.value) group.open = true;
1512
+ }
1513
+ }
1514
+
1515
+ function activate(el) {
1516
+ if (el === current) return;
1517
+ current = el;
1518
+ var a = byId[el.id];
1519
+ clearActive();
1520
+
1521
+ var group = a ? a.closest('.nav-group')
1522
+ : document.querySelector('.nav-group[data-doc="' + CSS.escape(el.id) + '"]');
1523
+ var sec = group ? group.closest('.nav-sec') : null;
1524
+ revealIn(sec, group);
1525
+ if (a) {
1526
+ a.classList.add('is-active');
1527
+ if (innerWidth > 960) a.scrollIntoView({ block: 'nearest' });
1528
+ }
1529
+ setCrumb([
1530
+ sec && { text: sec.querySelector('.nav-sec__title').textContent },
1531
+ group && { text: group.querySelector('.nav-group__title').textContent, strong: true },
1532
+ a && { text: a.textContent },
1533
+ ]);
1534
+ }
1535
+
1536
+ var visible = new Set();
1537
+ /* The spy's top edge is the bar the reader is looking under, plus the 8px the
1538
+ headings already clear it by. Read from the property the bar is sized by
1539
+ rather than restated as a literal that goes stale the moment it changes. */
1540
+ var topbarH = parseFloat(getComputedStyle(root).getPropertyValue('--topbar-h')) || 52;
1541
+ var spy = new IntersectionObserver(function (entries) {
1542
+ entries.forEach(function (e) {
1543
+ if (e.isIntersecting) visible.add(e.target); else visible.delete(e.target);
1544
+ });
1545
+ if (!visible.size) return;
1546
+ var ordered = targets.filter(function (t) { return visible.has(t); });
1547
+ if (ordered.length) activate(ordered[0]);
1548
+ }, { rootMargin: '-' + (topbarH + 8) + 'px 0px -72% 0px', threshold: 0 });
1549
+ targets.forEach(function (t) { spy.observe(t); });
1550
+
1551
+ links.forEach(function (a) {
1552
+ a.addEventListener('click', function () { if (innerWidth <= 960) setDrawer(false); });
1553
+ });
1554
+
1555
+ /* ---- page bars ----
1556
+ Every document gets a bar: where it sits in its section, and prev/next across
1557
+ the section's other documents. A document inside a section that ships an index
1558
+ also gets a link back to it. The pages stay in the DOM whether shown or not,
1559
+ which is what lets an index search their text after hiding them from the
1560
+ browser's own find. */
1561
+ var routed = [].slice.call(document.querySelectorAll('.doc-section[data-routed]'));
1562
+ var bodyText = new Map();
1563
+
1564
+ function pagesOf(sec) { return [].slice.call(sec.children); }
1565
+
1566
+ function recordsOf(sec) {
1567
+ var landing = document.getElementById(sec.dataset.landing);
1568
+ return pagesOf(sec).filter(function (p) { return p !== landing; });
1569
+ }
1570
+
1571
+ function chip(label, href, flag) {
1572
+ var a = document.createElement('a');
1573
+ a.className = 'page-chip';
1574
+ a.textContent = label;
1575
+ if (href) a.href = '#' + href;
1576
+ else a.setAttribute('aria-disabled', 'true');
1577
+ if (flag) a.setAttribute(flag, '');
1578
+ return a;
1579
+ }
1580
+
1581
+ function stepsEl(siblings, i) {
1582
+ var steps = document.createElement('div');
1583
+ steps.className = 'page-steps';
1584
+ steps.appendChild(chip('‹ Prev', siblings[i - 1] && siblings[i - 1].id, 'data-prev'));
1585
+ steps.appendChild(chip('Next ›', siblings[i + 1] && siblings[i + 1].id, 'data-next'));
1586
+ return steps;
1587
+ }
1588
+
1589
+ function barEl(siblings, i, landingId) {
1590
+ var bar = document.createElement('div');
1591
+ bar.className = 'page-bar';
1592
+ if (landingId) bar.appendChild(chip('‹ All records', landingId, 'data-back'));
1593
+ var pos = document.createElement('span');
1594
+ pos.className = 'page-pos';
1595
+ pos.textContent = (i + 1) + ' / ' + siblings.length;
1596
+ bar.append(pos, stepsEl(siblings, i));
1597
+ return bar;
1598
+ }
1599
+
1600
+ function snippetEl(text, q) {
1601
+ var at = text.toLowerCase().indexOf(q);
1602
+ var body = document.createElement('span');
1603
+ var mark = document.createElement('mark');
1604
+ mark.textContent = text.slice(at, at + q.length);
1605
+ body.append('…' + text.slice(Math.max(0, at - 55), at), mark,
1606
+ text.slice(at + q.length, at + q.length + 95) + '…');
1607
+ return body;
1608
+ }
1609
+
1610
+ function hitEl(page, q) {
1611
+ var a = document.createElement('a');
1612
+ a.className = 'record-hit';
1613
+ a.href = '#' + page.id;
1614
+ var title = document.createElement('b');
1615
+ title.textContent = page.dataset.title;
1616
+ a.append(title, snippetEl(bodyText.get(page), q));
1617
+ return a;
1618
+ }
1619
+
1620
+ /* An empty result used to be indistinguishable from a query too short to run,
1621
+ from a broken search, and from a section with no records — all four rendered
1622
+ as nothing at all. */
1623
+ function emptyEl(q) {
1624
+ var el = document.createElement('p');
1625
+ el.className = 'record-empty';
1626
+ el.textContent = 'No record contains “' + q + '”';
1627
+ return el;
1628
+ }
1629
+
1630
+ function searchEl(records, hits) {
1631
+ var box = document.createElement('div');
1632
+ box.className = 'record-search';
1633
+ var input = document.createElement('input');
1634
+ input.type = 'search';
1635
+ input.setAttribute('aria-label', 'Search the full text of every record');
1636
+ input.placeholder = 'Search all ' + records.length + ' records…';
1637
+ box.appendChild(input);
1638
+ input.addEventListener('input', function () {
1639
+ var q = input.value.trim().toLowerCase();
1640
+ hits.textContent = '';
1641
+ if (q.length < 2) return;
1642
+ var found = 0;
1643
+ records.forEach(function (p) {
1644
+ if (bodyText.get(p).toLowerCase().indexOf(q) === -1) return;
1645
+ hits.appendChild(hitEl(p, q));
1646
+ found += 1;
1647
+ });
1648
+ if (!found) hits.appendChild(emptyEl(input.value.trim()));
1649
+ });
1650
+ return box;
1651
+ }
1652
+
1653
+ /* Each record states its own status under a Status heading, so the index can
1654
+ total them without the renderer having to parse anything. The deep-link
1655
+ anchor prepends a '#' to every heading, hence the strip. */
1656
+ /* Only the leading word. A real status line carries its qualifiers with it —
1657
+ "Accepted — partially supersedes ADR-0008 (the src/kit/ line only)" — and
1658
+ tallying the whole string gives one bucket per record instead of a total. */
1659
+ function statusHeadOf(page) {
1660
+ var head = [].slice.call(page.querySelectorAll('h2')).filter(function (h) {
1661
+ return h.textContent.replace('#', '').trim().toLowerCase() === 'status';
1662
+ })[0];
1663
+ var body = head && head.nextElementSibling;
1664
+ return body && body.tagName === 'P' ? body.textContent.trim() : '';
1665
+ }
1666
+
1667
+ function statusOf(page) {
1668
+ var text = statusHeadOf(page);
1669
+ if (text) return (text.match(/^[A-Za-z]+/) || [''])[0].toLowerCase();
1670
+ /* Not every record uses a Status heading: one writes "**Status:** Accepted" as
1671
+ an inline label in its header block. Only the opening of the record is
1672
+ searched, so a later mention of the word cannot be mistaken for the field. */
1673
+ var label = page.textContent.slice(0, 700).match(/Status:\s*([A-Za-z]+)/);
1674
+ return label ? label[1].toLowerCase() : '';
1675
+ }
1676
+
1677
+ function summaryEl(records) {
1678
+ var tally = new Map();
1679
+ records.forEach(function (p) {
1680
+ var status = statusOf(p) || 'unrecorded';
1681
+ tally.set(status, (tally.get(status) || 0) + 1);
1682
+ });
1683
+ var parts = Array.from(tally).sort(function (a, b) { return b[1] - a[1]; });
1684
+ var el = document.createElement('p');
1685
+ el.className = 'record-summary';
1686
+ el.textContent = records.length + ' records · ' + parts.map(function (e) {
1687
+ return e[1] + ' ' + e[0];
1688
+ }).join(' · ');
1689
+ return el;
1690
+ }
1691
+
1692
+ /* The author's own index is prose, and prose goes stale. This set's
1693
+ docs/adr/README.md lists four records by filenames the repository never had —
1694
+ behind an index-routed section that hides the other eleven completely. So the
1695
+ links are counted, and the list is generated only when they fall short. */
1696
+ function linksAll(landing, records) {
1697
+ var seen = {};
1698
+ var found = 0;
1699
+ landing.querySelectorAll('a[href^="#"]').forEach(function (a) {
1700
+ /* Resolved through the element, not string-matched: a rewritten link points
1701
+ at the target's H1 id, which is the page id without its page- prefix. */
1702
+ var el = document.getElementById(decodeURIComponent(a.getAttribute('href').slice(1)));
1703
+ var page = el && el.closest('.page');
1704
+ if (page && !seen[page.id] && records.indexOf(page) !== -1) {
1705
+ seen[page.id] = 1;
1706
+ found += 1;
1707
+ }
1708
+ });
1709
+ return found >= records.length;
1710
+ }
1711
+
1712
+ function rowEl(page, i) {
1713
+ var a = document.createElement('a');
1714
+ a.className = 'record-row';
1715
+ a.href = '#' + page.id;
1716
+ var n = document.createElement('span');
1717
+ n.className = 'record-row__n';
1718
+ n.textContent = i + 1;
1719
+ var title = document.createElement('b');
1720
+ title.textContent = page.dataset.title;
1721
+ var status = document.createElement('span');
1722
+ status.className = 'record-row__s';
1723
+ status.textContent = statusOf(page) || 'unrecorded';
1724
+ /* The pill is painted from the status it shows, so the two records still open in
1725
+ a set of fifteen stop looking like the thirteen that are settled. */
1726
+ status.dataset.status = status.textContent;
1727
+ a.append(n, title, status);
1728
+ return a;
1729
+ }
1730
+
1731
+ function listEl(records) {
1732
+ var list = document.createElement('div');
1733
+ list.className = 'record-list';
1734
+ var label = document.createElement('div');
1735
+ label.className = 'eyebrow';
1736
+ label.textContent = 'Every record';
1737
+ list.appendChild(label);
1738
+ records.forEach(function (p, i) { list.appendChild(rowEl(p, i)); });
1739
+ return list;
1740
+ }
1741
+
1742
+ function equipSection(sec) {
1743
+ var records = recordsOf(sec);
1744
+ records.forEach(function (p) { bodyText.set(p, p.textContent.replace(/\s+/g, ' ')); });
1745
+ var landing = document.getElementById(sec.dataset.landing);
1746
+ var hits = document.createElement('div');
1747
+ hits.className = 'record-hits';
1748
+ /* The index's own opening paragraph explains what the records are, so it keeps
1749
+ its place directly under the title; the controls go below it. */
1750
+ var head = landing.querySelector('.doc-head');
1751
+ var lead = head.nextElementSibling;
1752
+ var at = lead && lead.tagName === 'P' ? lead : head;
1753
+ if (!linksAll(landing, records)) at.after(listEl(records));
1754
+ at.after(hits);
1755
+ at.after(searchEl(records, hits));
1756
+ at.after(summaryEl(records));
1757
+ }
1758
+
1759
+ /* ---- page routes ----
1760
+ A 21-document scroll is not a page. Every document is its own page with its
1761
+ own route and its own progress. Sections are the grouping the rail shows;
1762
+ prev/next walks the section, and a section that ships an index is browsed
1763
+ from it.
1764
+
1765
+ Two hash forms, because every anchor the renderer writes is a bare element id
1766
+ and rewriting them all would be the same work twice. A leading slash names a
1767
+ route; anything else is an id, and the router opens whichever page holds it. */
1768
+ var docSections = [].slice.call(document.querySelectorAll('.doc-section'));
1769
+ var docPages = [].slice.call(document.querySelectorAll('.page[data-route]'));
1770
+ var byRoute = {};
1771
+ docPages.forEach(function (p) { byRoute[p.dataset.route] = p; });
1772
+
1773
+ function routeParts() {
1774
+ var raw = decodeURIComponent((location.hash || '').slice(1));
1775
+ return raw.charAt(0) === '/' ? { slug: raw.slice(1), id: '' } : { slug: '', id: raw };
1776
+ }
1777
+
1778
+ function landingFor(sec) {
1779
+ return sec.dataset.landing ? document.getElementById(sec.dataset.landing) : pagesOf(sec)[0];
1780
+ }
1781
+
1782
+ /* A record is not a page of the document — it opens over whichever page referenced
1783
+ it (§14 Decisions, in practice) and closing puts the reader back on the row they
1784
+ clicked. So its section never becomes the layout, and the page router has to
1785
+ leave its pages alone: hiding one would open an empty drawer. */
1786
+ var drawerSections = docSections.filter(function (s) { return 'drawer' in s.dataset; });
1787
+ var pageSections = docSections.filter(function (s) { return !('drawer' in s.dataset); });
1788
+ var recordHome = new Map();
1789
+ drawerSections.forEach(function (sec) {
1790
+ pagesOf(sec).forEach(function (p) { recordHome.set(p, sec); });
1791
+ });
1792
+ var isRecord = function (page) { return recordHome.has(page); };
1793
+
1794
+ function pageFor(parts) {
1795
+ var el = parts.id && document.getElementById(parts.id);
1796
+ var owner = el && el.closest('.page');
1797
+ if (owner && !isRecord(owner)) return owner;
1798
+ var routed = byRoute[parts.slug];
1799
+ if (routed && !isRecord(routed)) return routed;
1800
+ return activePage || landingFor(pageSections[0]);
1801
+ }
1802
+
1803
+ function recordFor(parts) {
1804
+ var el = parts.id && document.getElementById(parts.id);
1805
+ var owner = el && el.closest('.page');
1806
+ if (owner && isRecord(owner)) return owner;
1807
+ var routed = byRoute[parts.slug];
1808
+ return routed && isRecord(routed) ? routed : null;
1809
+ }
1810
+
1811
+ function showPage(page) {
1812
+ var sec = page.parentNode;
1813
+ docSections.forEach(function (s) { s.hidden = s !== sec; });
1814
+ docPages.forEach(function (p) { if (!isRecord(p)) p.hidden = p !== page; });
1815
+ /* The rail is the only way to change document, so the router owns which rows
1816
+ are open. A row expanded over a page that is not in the layout is a lie. */
1817
+ sections.forEach(function (n) { n.open = n.dataset.sec === sec.dataset.slug; });
1818
+ groups.forEach(function (g) { g.open = g.dataset.route === page.dataset.route; });
1819
+ activePage = page;
1820
+ /* A <c4-view> revealed from display:none has never had a box to fit itself
1821
+ into, and the webcomponent only refits on resize. */
1822
+ dispatchEvent(new Event('resize'));
1823
+ if (window.pinEdgeChips) setTimeout(window.pinEdgeChips, 300);
1824
+ }
1825
+
1826
+ var drawerEl = document.getElementById('drawer');
1827
+ var drawerScrim = document.getElementById('drawer-scrim');
1828
+ var drawerBody = document.getElementById('drawer-body');
1829
+ var drawerTitle = document.getElementById('drawer-title');
1830
+ var drawerStatus = document.getElementById('drawer-status');
1831
+ var drawerClose = document.getElementById('drawer-close');
1832
+ var openRecord = null;
1833
+ var returnFocus = null;
1834
+
1835
+ /* "ADR-0002", not "ADR-0002: Multi-tenancy via shared database with row-level
1836
+ org_id and Postgres RLS". The record's own H1 is two lines below the bar. */
1837
+ function recordLabel(title) {
1838
+ var head = (title || 'Record').split(':')[0].trim();
1839
+ return head.length > 40 ? head.slice(0, 39) + '…' : head;
1840
+ }
1841
+
1842
+ /* `inert` rather than a hand-rolled tab trap: it takes the page out of the tab
1843
+ order and the accessibility tree in one property, which is what aria-modal was
1844
+ claiming and nothing was enforcing. */
1845
+ /* The skip link is in the list because it sits outside .main and would otherwise
1846
+ stay reachable from behind the scrim — a skip link that fires while a record
1847
+ is open lands the reader on a page they cannot see. */
1848
+ function setBehindInert(on) {
1849
+ [document.querySelector('.main'), sidebar, document.querySelector('.topbar'),
1850
+ document.querySelector('.skip')]
1851
+ .forEach(function (el) { if (el) el.inert = on; });
1852
+ }
1853
+
1854
+ /* Moved, not cloned. A clone duplicates every heading id inside the record, and
1855
+ from then on getElementById resolves to whichever copy comes first in the
1856
+ document — so half the anchors in the drawer would scroll the page behind it. */
1857
+ function openDrawer(page) {
1858
+ if (openRecord === page) return;
1859
+ var from = openRecord ? returnFocus : document.activeElement;
1860
+ closeDrawer();
1861
+ returnFocus = from;
1862
+ page.hidden = false;
1863
+ drawerBody.appendChild(page);
1864
+ drawerBody.scrollTop = 0;
1865
+ drawerTitle.textContent = recordLabel(page.dataset.title);
1866
+ var status = statusOf(page);
1867
+ drawerStatus.hidden = !status;
1868
+ drawerStatus.textContent = status;
1869
+ drawerStatus.dataset.status = status;
1870
+ drawerEl.setAttribute('aria-label', page.dataset.title || 'Record');
1871
+ drawerEl.classList.add('is-open');
1872
+ drawerEl.setAttribute('aria-hidden', 'false');
1873
+ drawerScrim.classList.add('is-open');
1874
+ openRecord = page;
1875
+ setBehindInert(true);
1876
+ drawerClose.focus();
1877
+ }
1878
+
1879
+ function closeDrawer() {
1880
+ drawerEl.classList.remove('is-open');
1881
+ drawerEl.setAttribute('aria-hidden', 'true');
1882
+ drawerScrim.classList.remove('is-open');
1883
+ setBehindInert(false);
1884
+ if (!openRecord) return;
1885
+ openRecord.hidden = true;
1886
+ recordHome.get(openRecord).appendChild(openRecord);
1887
+ openRecord = null;
1888
+ /* Back to the row that opened it. Without this the reader is returned to the top
1889
+ of the document by the browser's own fallback, having lost the list they were
1890
+ working through. */
1891
+ if (returnFocus && returnFocus.isConnected) returnFocus.focus();
1892
+ returnFocus = null;
1893
+ }
1894
+
1895
+ /* Closing goes through the hash, so the panel and the address never disagree:
1896
+ Escape, the scrim and the × all land on the page's own route, and Back does the
1897
+ same thing by the ordinary route. */
1898
+ function leaveRecord() {
1899
+ var route = activePage && activePage.dataset.route;
1900
+ closeDrawer();
1901
+ if (route) location.hash = '#/' + route;
1902
+ }
1903
+
1904
+ /* The browser scrolls to a fragment before the router can reveal it, so a deep
1905
+ link into a hidden page lands nowhere. Re-run the jump once it is shown. */
1906
+ function navigate(jump) {
1907
+ var parts = routeParts();
1908
+ var record = recordFor(parts);
1909
+ var page = pageFor(parts);
1910
+ /* Before showPage, which is what assigns activePage. A route that resolves to
1911
+ the page already on screen is not a move, and starting it at the top is how
1912
+ closing a record threw the reader from §14 back to §1 — the drawer leaves by
1913
+ the host page's own route, and Back does the same. */
1914
+ var moved = page !== activePage;
1915
+ showPage(page);
1916
+ tick();
1917
+ /* Order matters: the host page has to be in the layout before the record goes
1918
+ over it, or a cold load at #/0002 opens the drawer onto nothing. */
1919
+ if (record) { openDrawer(record); return; }
1920
+ closeDrawer();
1921
+ if (!jump) return;
1922
+ var el = parts.id && document.getElementById(parts.id);
1923
+ /* Instant when the router changed the page, smooth when it did not.
1924
+ `scroll-behavior: smooth` cannot tell the two apart, so a deep link into
1925
+ another document used to animate the whole way there — through content the
1926
+ reader never asked to see, and past the top of the document they did. An
1927
+ anchor inside the page already on screen is a short deliberate move and
1928
+ keeps its glide. Reduced motion takes even that back: passing `behavior`
1929
+ explicitly outranks the CSS rule that used to cover this. */
1930
+ var how = (moved || reduced.matches) ? 'instant' : 'smooth';
1931
+ if (!el) { if (moved) scrollTo({ top: 0, behavior: 'instant' }); return; }
1932
+ /* A link to a document scrolls to the page so its prev/next bar stays on
1933
+ screen. A link to a heading inside it still lands on that heading. */
1934
+ (el.classList.contains('doc-head') ? page : el).scrollIntoView({ behavior: how });
1935
+ }
1936
+
1937
+ function goTo(route) {
1938
+ if (innerWidth <= 960) setDrawer(false);
1939
+ if (routeParts().slug !== route) location.hash = '#/' + route;
1940
+ }
1941
+
1942
+ /* preventDefault also stops <summary> toggling, which is the point: the row for
1943
+ the page on screen cannot be collapsed, because collapsing it would leave the
1944
+ reader no way back into the document they are looking at. */
1945
+ function wireRow(row, head) {
1946
+ row.querySelector(head).addEventListener('click', function (e) {
1947
+ e.preventDefault();
1948
+ goTo(row.dataset.route);
1949
+ });
1950
+ }
1951
+
1952
+ sections.forEach(function (n) { wireRow(n, '.nav-sec__head'); });
1953
+ groups.forEach(function (g) { if (g.dataset.route) wireRow(g, '.nav-group__head'); });
1954
+
1955
+ /* Index pages first: the generated list reads each record's status out of its
1956
+ text, and the search stashes that text. A bar prepended before either would
1957
+ put "‹ ALL RECORDS 3 / 15 ‹ PREV NEXT ›" at the head of every record — inside
1958
+ the 700 characters the status is looked for, and inside every search hit. */
1959
+ /* Before the bars, for the same reason the index search is: a bar contributes
1960
+ "‹ All records 3 / 15 ‹ Prev Next ›" to every page, and captured after it those
1961
+ become words the filter matches in every document at once.
1962
+ Records are left out — they have no rail row to promote, and their section's
1963
+ own index already searches them. Between the two, nothing in the set is
1964
+ unsearchable. */
1965
+ docPages.forEach(function (p) {
1966
+ if (isRecord(p)) return;
1967
+ docText.set(p.dataset.route, p.textContent.replace(/\s+/g, ' ').toLowerCase());
1968
+ });
1969
+
1970
+ routed.forEach(equipSection);
1971
+
1972
+ docSections.forEach(function (sec) {
1973
+ /* An index is not part of its own walk: it is the thing prev/next comes back
1974
+ to, so the records number 1..15 rather than the index numbering itself 1. */
1975
+ var landing = sec.dataset.landing;
1976
+ var walk = landing ? recordsOf(sec) : pagesOf(sec);
1977
+ walk.forEach(function (p, i) { p.prepend(barEl(walk, i, landing || '')); });
1978
+ });
1979
+ drawerClose.addEventListener('click', leaveRecord);
1980
+ drawerScrim.addEventListener('click', leaveRecord);
1981
+ addEventListener('keydown', function (e) {
1982
+ if (e.key === 'Escape' && openRecord) leaveRecord();
1983
+ });
1984
+
1985
+ /* A link to a record could be left to the id form — the router resolves it either
1986
+ way — but then the address bar says #doc-adr-0002-multi-tenancy while the panel
1987
+ says ADR 0002, and neither is the route somebody would paste. Listening on
1988
+ document rather than .doc because an open record is no longer inside it, and one
1989
+ record links to another. */
1990
+ addEventListener('click', function (e) {
1991
+ var a = e.target.closest && e.target.closest('a[href^="#"]');
1992
+ if (!a) return;
1993
+ var el = document.getElementById(decodeURIComponent(a.getAttribute('href').slice(1)));
1994
+ var page = el && el.closest('.page');
1995
+ if (!page || !isRecord(page)) return;
1996
+ e.preventDefault();
1997
+ if (routeParts().slug === page.dataset.route) openDrawer(page);
1998
+ else location.hash = '#/' + page.dataset.route;
1999
+ });
2000
+
2001
+ addEventListener('hashchange', function () { navigate(true); });
2002
+ addEventListener('resize', tick);
2003
+ navigate(Boolean(location.hash));
2004
+
2005
+ /* ---- diagrams ---- */
2006
+ var mermaidEls = [];
2007
+ function rerenderDiagrams() { mermaidEls.forEach(renderMermaid); }
2008
+
2009
+ /* mermaid measures a diagram in a scratch div it appends to the body under
2010
+ 'd' + id, and leaves it there when the parse throws. */
2011
+ function dropScratch(id) {
2012
+ var junk = document.getElementById('d' + id);
2013
+ if (junk) junk.remove();
2014
+ }
2015
+
2016
+ /* Left alone, a rejected render is silent: the element keeps the source text it
2017
+ was seeded with, so a syntax error renders as a slab of mermaid DSL inside a
2018
+ diagram frame — which reads as a code block somebody meant to put there. */
2019
+ function showDiagramError(el, err) {
2020
+ var msg = document.createElement('p');
2021
+ msg.className = 'diagram-error';
2022
+ msg.textContent = 'Diagram failed to render — ' + ((err && err.message) || err);
2023
+ el.replaceChildren(msg);
2024
+ }
2025
+
2026
+ // Mermaid pins the SVG to its natural width (~300px for an ER diagram), which
2027
+ // leaves labels unreadable in a full-width shell. The viewBox lets it scale.
2028
+ function fitSvg(svg) {
2029
+ if (!svg.getAttribute('viewBox')) return;
2030
+ svg.removeAttribute('width');
2031
+ svg.removeAttribute('height');
2032
+ svg.style.width = '100%';
2033
+ svg.style.height = 'auto';
2034
+ svg.style.maxWidth = '100%';
2035
+ svg.style.maxHeight = '72vh';
2036
+ }
2037
+
2038
+ async function renderMermaid(el) {
2039
+ var code = el.dataset.src || el.textContent.trim();
2040
+ if (!code) return;
2041
+ el.dataset.src = code;
2042
+ var id = 'd' + Math.random().toString(36).slice(2);
2043
+ var out;
2044
+ try {
2045
+ out = await mermaid.render(id, code);
2046
+ } catch (err) {
2047
+ dropScratch(id);
2048
+ showDiagramError(el, err);
2049
+ return;
2050
+ }
2051
+ var svg = new DOMParser().parseFromString(out.svg, 'text/html').body.querySelector('svg');
2052
+ if (!svg) return;
2053
+ fitSvg(svg);
2054
+ el.replaceChildren(svg);
2055
+ }
2056
+
2057
+ var ICONS = {
2058
+ 'zoom-in': '<svg viewBox="0 0 18 18"><circle cx="7.8" cy="7.8" r="5"/><path d="M11.4 11.4 16 16M7.8 5.8v4M5.8 7.8h4"/></svg>',
2059
+ 'zoom-out': '<svg viewBox="0 0 18 18"><circle cx="7.8" cy="7.8" r="5"/><path d="M11.4 11.4 16 16M5.8 7.8h4"/></svg>',
2060
+ 'expand': '<svg viewBox="0 0 18 18"><path d="M11 2h5v5M7 16H2v-5M16 2l-6 6M2 16l6-6"/></svg>',
2061
+ 'fullscreen': '<svg viewBox="0 0 18 18"><path d="M2 6.5V2h4.5M11.5 2H16v4.5M16 11.5V16h-4.5M6.5 16H2v-4.5"/></svg>',
2062
+ 'exit': '<svg viewBox="0 0 18 18"><path d="M6.5 2v4.5H2M16 6.5h-4.5V2M11.5 16v-4.5H16M2 11.5h4.5V16"/></svg>',
2063
+ /* A pushpin rather than the usual "dock to side" bracket: the bracket is the
2064
+ same shape as expand and exit-fullscreen already in this bar, and three
2065
+ rectangles-with-arrows is a toolbar nobody can read at 14px. */
2066
+ 'pin': '<svg viewBox="0 0 18 18"><path d="M11.2 2.4 15.6 6.8M12.4 3.6 8.6 6 4.9 7.1l6 6L12 9.4l2.4-3.8M6.2 11.8 2.6 15.4"/></svg>',
2067
+ };
2068
+
2069
+ function buildToolbar() {
2070
+ var t = document.createElement('div');
2071
+ t.className = 'diagram-toolbar';
2072
+ t.innerHTML =
2073
+ '<button type="button" data-zoom-in aria-label="Zoom in" title="Zoom in">' + ICONS['zoom-in'] + '</button>' +
2074
+ '<button type="button" data-zoom-out aria-label="Zoom out" title="Zoom out">' + ICONS['zoom-out'] + '</button>' +
2075
+ '<button type="button" data-zoom-reset aria-label="Reset zoom, currently 100%" title="Reset zoom">100%</button>' +
2076
+ '<button type="button" data-pin aria-pressed="false" aria-label="Pin beside the text" title="Pin beside the text">' + ICONS.pin + '</button>' +
2077
+ '<button type="button" data-expand aria-pressed="false" aria-label="Expand" title="Expand">' + ICONS.expand + '</button>' +
2078
+ '<button type="button" data-fullscreen aria-label="Fullscreen" title="Fullscreen">' + ICONS.fullscreen + '</button>' +
2079
+ '<button type="button" data-exit-fullscreen aria-label="Exit fullscreen" title="Exit fullscreen">' + ICONS.exit + '</button>';
2080
+ return t;
2081
+ }
2082
+
2083
+ /* Pinning reserves a 380px gutter, so the column narrows and every paragraph in
2084
+ the document reflows. The placeholder keeps the *diagram's* space, but nothing
2085
+ keeps the reader's: on the 20-document EOS set the text under the cursor moved
2086
+ 48px — two lines — which on a page whose whole job is being read is the change
2087
+ arriving as a jolt. The fixture set is too short to show it; it took a real
2088
+ render to measure. So the first block below the top bar is treated as the
2089
+ anchor and its position restored afterwards.
2090
+ `behavior: 'instant'` because html sets scroll-behavior: smooth, and a
2091
+ correction that animates is the jump plus a slide. */
2092
+ function readingAnchor() {
2093
+ var els = document.querySelectorAll('.main p, .main li, .main h2, .main h3');
2094
+ for (var i = 0; i < els.length; i += 1) {
2095
+ var r = els[i].getBoundingClientRect();
2096
+ if (r.height && r.top > 60) return els[i];
2097
+ }
2098
+ return null;
2099
+ }
2100
+
2101
+ function keepingPlace(change) {
2102
+ var el = readingAnchor();
2103
+ var before = el && el.getBoundingClientRect().top;
2104
+ change();
2105
+ if (!el) return;
2106
+ scrollBy({ top: el.getBoundingClientRect().top - before, behavior: 'instant' });
2107
+ }
2108
+
2109
+ /* Measured while the shell is still in flow, because once it is fixed its
2110
+ offsetHeight is the pane's, not the space it left behind. */
2111
+ function slotFor(shell) {
2112
+ var slot = document.createElement('div');
2113
+ slot.className = 'diagram-slot';
2114
+ slot.style.height = shell.offsetHeight + 'px';
2115
+ shell.parentNode.insertBefore(slot, shell);
2116
+ }
2117
+
2118
+ /* Returns the shell it released, which is how pinDiagram tells "pin this one"
2119
+ from "the reader clicked the pin that is already down". Focus is deliberately
2120
+ not moved: the pin button may be a screen away by now, and focusing it would
2121
+ drag the viewport back there — the opposite of what a reader pressing Escape
2122
+ over the prose was asking for. */
2123
+ function unpinDiagram() {
2124
+ var shell = document.querySelector('.diagram-shell.is-pinned');
2125
+ if (!shell) return null;
2126
+ shell.classList.remove('is-pinned');
2127
+ document.body.classList.remove('has-pin');
2128
+ var slot = shell.previousElementSibling;
2129
+ if (slot && slot.classList.contains('diagram-slot')) slot.remove();
2130
+ shell.querySelector('[data-pin]').setAttribute('aria-pressed', 'false');
2131
+ if (shell.archDocsSync) shell.archDocsSync();
2132
+ return shell;
2133
+ }
2134
+
2135
+ /* One pane, so pinning a second diagram releases the first. Two would need two
2136
+ gutters, and the column has one to give. */
2137
+ function pinDiagram(shell) {
2138
+ if (unpinDiagram() === shell) return;
2139
+ slotFor(shell);
2140
+ shell.classList.add('is-pinned');
2141
+ document.body.classList.add('has-pin');
2142
+ shell.querySelector('[data-pin]').setAttribute('aria-pressed', 'true');
2143
+ if (shell.archDocsSync) shell.archDocsSync();
2144
+ }
2145
+
2146
+ /* There is something to pan once the diagram is bigger than its box, or once the
2147
+ box is the whole screen. Below that, panning is a promise the diagram cannot
2148
+ keep — and claiming the touch gesture for it costs the reader their scroll. */
2149
+ function pannable(shell, zoom) {
2150
+ return zoom > 1 || shell.classList.contains('is-expanded')
2151
+ || document.fullscreenElement === shell;
2152
+ }
2153
+
2154
+ var PAN_KEYS = { ArrowLeft: [1, 0], ArrowRight: [-1, 0], ArrowUp: [0, 1], ArrowDown: [0, -1] };
2155
+
2156
+ /* How far the canvas may travel: the overhang, meaning how far the scaled canvas
2157
+ sticks out past the viewport on each side. So the content edges can be brought
2158
+ to the frame edges and no further. Below zoom 1 there is no overhang, the
2159
+ limit is zero, and the diagram stays parked in the middle — which is right,
2160
+ because at that size there is nothing off screen to go and look at. */
2161
+ function panLimit(viewport, canvas, zoom) {
2162
+ return {
2163
+ x: Math.max(0, (canvas.offsetWidth * zoom - viewport.clientWidth) / 2),
2164
+ y: Math.max(0, (canvas.offsetHeight * zoom - viewport.clientHeight) / 2),
2165
+ };
2166
+ }
2167
+
2168
+ /* Pointer events, not the mouse pair: the mouse events never fire for touch, so
2169
+ a diagram on a phone could be zoomed and then not moved. Capture keeps the
2170
+ drag bound to the element it started in, which also retires the two
2171
+ document-level listeners this used to add once per diagram — a page with a
2172
+ dozen diagrams was running a dozen mousemove handlers on every move. */
2173
+ function wirePan(viewport, ctl) {
2174
+ var drag = null;
2175
+ var end = function () { drag = null; viewport.classList.remove('is-panning'); };
2176
+ viewport.addEventListener('pointerdown', function (e) {
2177
+ if (e.target.closest('.diagram-toolbar')) return;
2178
+ if (!viewport.classList.contains('is-pannable')) return;
2179
+ drag = { x: e.clientX, y: e.clientY };
2180
+ viewport.setPointerCapture(e.pointerId);
2181
+ viewport.classList.add('is-panning');
2182
+ });
2183
+ viewport.addEventListener('pointermove', function (e) {
2184
+ if (!drag) return;
2185
+ ctl.panBy(e.clientX - drag.x, e.clientY - drag.y);
2186
+ drag = { x: e.clientX, y: e.clientY };
2187
+ });
2188
+ viewport.addEventListener('pointerup', end);
2189
+ viewport.addEventListener('pointercancel', end);
2190
+ }
2191
+
2192
+ /* A zoomed diagram was reachable by keyboard and then frozen: the toolbar takes
2193
+ focus and zooms, and nothing moved the canvas afterwards. */
2194
+ function wireKeys(viewport, ctl) {
2195
+ viewport.addEventListener('keydown', function (e) {
2196
+ var step = PAN_KEYS[e.key];
2197
+ /* Not pannable means the whole diagram is already in its box, so the arrows
2198
+ belong to the page. Taking them anyway traps a reader who tabbed in here
2199
+ on their way down the document. */
2200
+ if (step && !viewport.classList.contains('is-pannable')) return;
2201
+ if (step) ctl.panBy(step[0] * 48, step[1] * 48);
2202
+ else if (e.key === '+' || e.key === '=') ctl.zoomBy(1.2);
2203
+ else if (e.key === '-') ctl.zoomBy(1 / 1.2);
2204
+ else if (e.key === '0') ctl.reset();
2205
+ else return;
2206
+ e.preventDefault();
2207
+ });
2208
+ }
2209
+
2210
+ /* The shell arrives holding the raw diagram; it leaves holding a toolbar over a
2211
+ viewport over a canvas over that same content, so the pan/zoom transform has a
2212
+ single element to write to. */
2213
+ function buildStage(shell) {
2214
+ var toolbar = buildToolbar();
2215
+ var viewport = document.createElement('div');
2216
+ viewport.className = 'diagram-viewport';
2217
+ viewport.tabIndex = 0;
2218
+ viewport.setAttribute('role', 'group');
2219
+ viewport.setAttribute('aria-label',
2220
+ 'Diagram. Arrow keys pan, plus and minus zoom, 0 resets.');
2221
+ var canvas = document.createElement('div');
2222
+ canvas.className = 'diagram-canvas';
2223
+ var content = shell.firstElementChild;
2224
+ shell.replaceChildren(toolbar, viewport);
2225
+ viewport.appendChild(canvas);
2226
+ canvas.appendChild(content);
2227
+ return { toolbar: toolbar, viewport: viewport, canvas: canvas };
2228
+ }
2229
+
2230
+ // The readout doubles as the reset button, so its accessible name has to carry
2231
+ // the live value as well as the action.
2232
+ function showZoom(readout, zoom) {
2233
+ var pct = Math.round(zoom * 100) + '%';
2234
+ readout.textContent = pct;
2235
+ readout.setAttribute('aria-label', 'Reset zoom, currently ' + pct);
2236
+ }
2237
+
2238
+ /* Owns the zoom and pan state. */
2239
+ function makeControls(stage, shell) {
2240
+ var viewport = stage.viewport, canvas = stage.canvas;
2241
+ var readout = stage.toolbar.querySelector('[data-zoom-reset]');
2242
+ var zoom = 1, panX = 0, panY = 0;
2243
+ /* Clamped here rather than in each of zoom, pan and reset: this is the one
2244
+ place the transform is written, so it is the one place that cannot be
2245
+ forgotten. Zooming back out re-centres for free. */
2246
+ function clampPan() {
2247
+ var lim = panLimit(viewport, canvas, zoom);
2248
+ panX = Math.min(lim.x, Math.max(-lim.x, panX));
2249
+ panY = Math.min(lim.y, Math.max(-lim.y, panY));
2250
+ }
2251
+ function apply() {
2252
+ clampPan();
2253
+ canvas.style.transform = 'translate(' + panX + 'px,' + panY + 'px) scale(' + zoom + ')';
2254
+ showZoom(readout, zoom);
2255
+ }
2256
+ function sync() { viewport.classList.toggle('is-pannable', pannable(shell, zoom)); }
2257
+ return {
2258
+ sync: sync,
2259
+ zoomBy: function (f) { zoom = Math.min(4, Math.max(0.25, zoom * f)); apply(); sync(); },
2260
+ panBy: function (dx, dy) { panX += dx; panY += dy; apply(); },
2261
+ reset: function () { zoom = 1; panX = 0; panY = 0; apply(); sync(); },
2262
+ };
2263
+ }
2264
+
2265
+ function wireToolbar(stage, shell, ctl) {
2266
+ var toolbar = stage.toolbar;
2267
+ toolbar.querySelector('[data-zoom-in]').onclick = function () { ctl.zoomBy(1.2); };
2268
+ toolbar.querySelector('[data-zoom-out]').onclick = function () { ctl.zoomBy(1 / 1.2); };
2269
+ toolbar.querySelector('[data-zoom-reset]').onclick = ctl.reset;
2270
+ toolbar.querySelector('[data-pin]').onclick = function () {
2271
+ keepingPlace(function () { pinDiagram(shell); });
2272
+ };
2273
+ toolbar.querySelector('[data-expand]').onclick = function () {
2274
+ var on = !shell.classList.contains('is-expanded');
2275
+ shell.classList.toggle('is-expanded', on);
2276
+ this.setAttribute('aria-pressed', String(on));
2277
+ ctl.sync();
2278
+ };
2279
+ toolbar.querySelector('[data-fullscreen]').onclick = function () { shell.requestFullscreen().catch(function () {}); };
2280
+ toolbar.querySelector('[data-exit-fullscreen]').onclick = function () { document.exitFullscreen(); };
2281
+ shell.addEventListener('fullscreenchange', ctl.sync);
2282
+ }
2283
+
2284
+ // Ctrl/Cmd held: the gesture is a zoom, not a page scroll.
2285
+ function wireWheel(viewport, ctl) {
2286
+ viewport.addEventListener('wheel', function (e) {
2287
+ if (!(e.ctrlKey || e.metaKey)) return;
2288
+ e.preventDefault();
2289
+ ctl.zoomBy(e.deltaY < 0 ? 1.1 : 1 / 1.1);
2290
+ }, { passive: false });
2291
+ }
2292
+
2293
+ function markDiagramKind(shell, canvas) {
2294
+ if (canvas.querySelector('c4-view')) shell.classList.add('is-c4');
2295
+ var mermaidEl = canvas.querySelector('.mermaid-canvas');
2296
+ if (!mermaidEl) return;
2297
+ shell.classList.add('is-mermaid');
2298
+ mermaidEls.push(mermaidEl);
2299
+ renderMermaid(mermaidEl);
2300
+ }
2301
+
2302
+ function wireDiagram(shell) {
2303
+ var stage = buildStage(shell);
2304
+ var ctl = makeControls(stage, shell);
2305
+ /* Escape is handled once for the whole page rather than per shell, and it needs
2306
+ to put each shell's pannable state back the way its own zoom says. */
2307
+ shell.archDocsSync = ctl.sync;
2308
+ wireToolbar(stage, shell, ctl);
2309
+ wireWheel(stage.viewport, ctl);
2310
+ wirePan(stage.viewport, ctl);
2311
+ wireKeys(stage.viewport, ctl);
2312
+ markDiagramKind(shell, stage.canvas);
2313
+ }
2314
+
2315
+ document.querySelectorAll('.diagram-shell').forEach(wireDiagram);
2316
+
2317
+ /* The fullscreen path gets Escape from the browser. Expand is an ordinary fixed
2318
+ overlay covering the whole viewport, and had no way out but the button that
2319
+ opened it — which is under the reader's cursor only if they remember where it
2320
+ was. Focus goes back to that button, since it is what they left. */
2321
+ addEventListener('keydown', function (e) {
2322
+ if (e.key !== 'Escape') return;
2323
+ keepingPlace(unpinDiagram);
2324
+ document.querySelectorAll('.diagram-shell.is-expanded').forEach(function (shell) {
2325
+ shell.classList.remove('is-expanded');
2326
+ var btn = shell.querySelector('[data-expand]');
2327
+ if (btn) { btn.setAttribute('aria-pressed', 'false'); btn.focus(); }
2328
+ if (shell.archDocsSync) shell.archDocsSync();
2329
+ });
2330
+ });
2331
+
2332
+ /* LikeC4 fits a view to its box when the element boots, and only refits on
2333
+ resize. The router reveals a section before <c4-view> is upgraded, so that
2334
+ first fit is measured against a box of zero — the view then renders at its
2335
+ natural layout size and runs off the right edge of a 689px column. Nudging it
2336
+ once the element is defined is what makes it fit the column it landed in. */
2337
+ /* Same treatment as the mermaid relation label, for the renderer whose DOM the
2338
+ page cannot select. LikeC4 draws div.likec4-edge-label with a translucent dark
2339
+ background in both modes, so §10 kept a chip that §12 had lost. Its shadow root
2340
+ is open, so a style element pushed inside reaches it — and because custom
2341
+ properties inherit across the shadow boundary, var(--surface) resolves against
2342
+ the host and flips with the toggle on its own.
2343
+
2344
+ Every nested root, because the label is not in the one c4-view opens: that root
2345
+ holds a div which opens another. Injecting once at the top silently styles
2346
+ nothing. Styling a root before its labels exist is fine — CSS is not applied
2347
+ once. */
2348
+ /* transparent, where the mermaid rule needs var(--surface): LikeC4 breaks its
2349
+ edge line around the label, so nothing has to be masked, and an opaque chip
2350
+ would read as a white blob wherever the label sits over a compound panel.
2351
+ Mermaid routes the line straight through its label and needs the mask. */
2352
+ var CHIP_CSS = '.likec4-edge-label{background:transparent !important;'
2353
+ + 'color:var(--text) !important;}';
2354
+
2355
+ function stripEdgeChips(view) {
2356
+ var walk = function (root) {
2357
+ if (!root) return;
2358
+ if (!root.archDocsChip) {
2359
+ root.archDocsChip = 1;
2360
+ var style = document.createElement('style');
2361
+ style.textContent = CHIP_CSS;
2362
+ root.appendChild(style);
2363
+ }
2364
+ /* Descend every time, not only on first sight: the inner root is opened by a
2365
+ div this root creates later, so the walk that styles the outer one always
2366
+ runs too early to see it. */
2367
+ root.querySelectorAll('*').forEach(function (el) { walk(el.shadowRoot); });
2368
+ };
2369
+ walk(view.shadowRoot);
2370
+ }
2371
+
2372
+ /* A shadow root cannot be observed into existence — MutationObserver does not
2373
+ cross the boundary and there is no event for "root opened". So this re-walks on
2374
+ a short ladder, which is idempotent, and again whenever the router reveals a
2375
+ page, since a hidden view defers its render until it has a box. */
2376
+ function pinEdgeChips() {
2377
+ document.querySelectorAll('c4-view').forEach(stripEdgeChips);
2378
+ }
2379
+ window.pinEdgeChips = pinEdgeChips;
2380
+
2381
+ if (window.customElements) {
2382
+ customElements.whenDefined('c4-view').then(function () {
2383
+ requestAnimationFrame(function () { dispatchEvent(new Event('resize')); });
2384
+ });
2385
+ [0, 200, 600, 1500, 3000].forEach(function (t) { setTimeout(pinEdgeChips, t); });
2386
+ }
2387
+ </script>
2388
+ </body>
2389
+ </html>