lagrange-library 0.3.21

A WASI-rendered Markdown static site facility — multilingual out of the box
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
// lagrange docs-shell styles. The chrome (shell, header, sidebar, menu,
// dialogs) is hikari's own SCSS — nothing here restyles it. This file
// only covers the docs-specific gaps: the app root's height chain, the
// reading column, the header search (a Search icon button opening a
// search window on every viewport), and the mermaid sub-app host. There is no
// footer band: a static docs site has no status to report.
//
// The root rule is the host's obligation, not decoration: HkFaceShell's
// `.s-admin-shell` is `height:100%` + `overflow:hidden`, so without a
// definite-height `#app` the percentage resolves to auto and the shell
// grows with the document (measured in Chrome: a 913px viewport got a
// 1972px shell, and the sidebar/header never pinned). Chest's theme.scss
// carries the same `#app{height:100dvh;overflow:hidden}` contract.
#app {
  position: relative;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

// The page canvas. hikari's components paint their own surfaces but the
// DOCUMENT behind them is the host's job: left unpainted the browser's
// default white canvas shows through, and in a dark theme the content
// reads near-white-on-white (measured in Chrome — the docs body inherits
// --color-text, so the canvas MUST follow --color-background).
html,
body {
  margin: 0;
  background: rgb(var(--color-background));
  color: rgb(var(--color-text));
}

.lagrange-docs-content {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.lagrange-docs-body {
  // The legacy body HTML ships its own typographic classes; keep the
  // reading measure stable while those rules still apply.
  line-height: 1.7;
}


// ── theme dialog ──────────────────────────────────────────────────────────
// The theme dialog's inner menu caps itself at 22rem and centers — sized
// for the account face's narrow sheet. The docs theme modal is wider, so
// the centered menu left a dead band on each side (user-reported, with the
// empty band circled). Let the docs instance use the modal's width.
.lagrange-docs-search-modal .s-theme-menu,
.hk-modal-content .s-theme-menu {
  max-width: none;
  width: 100%;
}

// ── header search ─────────────────────────────────────────────────────────

// The admin header's page title truncates at 8rem — a limit sized for the
// ACCOUNT-MENU nickname it was built for, not for page titles: a docs page
// title like "Welcome to celestia-island" needs ~11rem, and unlike the
// account face the docs header has no centre wing competing for the row.
// Widen the docs instance; hikari's account faces keep their 8rem.
// !important is load-bearing: the first draft used the selector
// `.s-admin-header .s-admin-header-title` — a class the header element does
// not wear (it is `s-glass-header s-balanced-header`) — so the rule sat in
// the stylesheet WITHOUT matching anything and the title stayed truncated at
// 8rem. Same-selector + important both wins the cascade and proves itself in
// the browser (measured: computed max-width 8rem before, 24rem after).
.s-admin-header-title {
  max-width: 24rem !important;
}

// Both viewports are trigger-first (2026-11-24): a Search icon button in
// the header's action slot, its popup — an anchored panel on desktop, a
// bottom sheet on phones — carrying the field and results in normal flow
// (the popup is the surface: no absolute positioning, no own background).
// The FIELD is hikari's HkSearchInput (2026-11-25: the hand-rolled
// input+× pair retired — it was visibly not a library component); it
// paints its own box, glyph and clear ✕, so only the modal-width fit
// rules remain here.
.lagrange-docs-search {
  position: relative;
  display: inline-flex;
  align-items: center;
}

// In-flight state: a CENTERED SPINNER, no text (2026-11-27 user direction —
// the old "Searching…" text row read as a random white block on the sheet).
.lagrange-docs-search-busy {
  position: static;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 96px;
}

.lagrange-docs-search-error {
  padding: 0.6rem 0.7rem;
  font-size: 0.85rem;
  opacity: 0.8;
}

.lagrange-docs-search-results {
  // Layout only. The anchored-popover chrome this rule used to carry
  // (absolute position, own max-height + overflow:auto, surface, border,
  // shadow, z-index) is GONE — deliberately, not just overridden: since the
  // search became a modal, the results list renders ONLY inside
  // `.lagrange-docs-search-panel`, and a scoped override can be defeated by
  // any future selector reshuffle. Keeping the scrolling chrome anywhere in
  // this sheet re-arms the exact defect this file exists to prevent (the
  // native inset scrollbar fighting the window body for the wheel).
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lagrange-docs-search-empty {
  padding: 0.6rem 0.7rem;
  font-size: 0.85rem;
  opacity: 0.7;
}

.lagrange-docs-search-hit {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0.5rem 0.6rem;
  // Uniform row height (2026-11-27 user direction: "搜索结果应当每个高度一
  // 致"). Every hit is title + heading + excerpt; the excerpt is what used to
  // vary (75px beside 267px), and it is now bounded by construction — either
  // two compacted lines or a clamped markdown window. A min-height on the row
  // keeps short hits from collapsing into slivers next to tall ones.
  min-height: 4.5rem;
  border-radius: var(--hk-radius-control, 8px);
  text-decoration: none;
  color: inherit;

  &:hover,
  &:focus-visible {
    background: color-mix(in srgb, rgb(var(--hk-color-primary, 60 120 220) / 0.1), transparent);
  }
}

.lagrange-docs-search-hit-title {
  font-weight: 600;
  font-size: 0.88rem;
}

.lagrange-docs-search-hit-heading {
  font-size: 0.75rem;
  opacity: 0.75;
}

// The magnifier snippet: markdown-rendered chunk window (tables render as
// tables), matches underlined in place, and a directional fade on each edge
// where the section text continues beyond the window — no fade at the
// section's true start/end (2026-11-27 user direction; the old one-line
// ellipsis cut showed raw pipe rows and hid deeper matches entirely).
.lagrange-docs-search-hit-snippet {
  position: relative;
  font-size: 0.78rem;
  opacity: 0.72;
  overflow: hidden;
  max-height: 13rem;

  > :first-child { margin-top: 0; }
  > :last-child { margin-bottom: 0; }

  // Rendered markdown tables inside the window: never widen the hit card.
  table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    font-size: 0.72rem;
  }

  // An excerpt is not a page: markdown structure is kept, page-scale type is
  // not. The leading heading is dropped in `snippet.ts`; this covers the ones
  // that stay. Where these rules do not out-specify the content sheet's own
  // heading selectors, the wrapper's 0.78rem still keeps the card's scale —
  // the excerpt never reaches display size either way.
  :is(h1, h2, h3, h4, h5, h6) {
    font-size: 0.85rem;
    font-weight: 600;
    margin: 0 0 0.2em;
  }

  p,
  ul,
  ol,
  blockquote {
    margin: 0.2em 0;
  }

  ul,
  ol {
    padding-inline-start: 1.2em;
  }

  pre,
  code {
    font-size: 0.72rem;
  }

  &.has-fade-above,
  &.has-fade-below {
    // mask = the TEXT dissolves toward the edge (an overlay tint would not
    // read as "there is more of the same content here").
    -webkit-mask-image: linear-gradient(
        to bottom,
        transparent 0,
        black var(--fade-top, 0%),
        black calc(100% - var(--fade-bottom, 0%)),
        transparent 100%
      );
    mask-image: linear-gradient(
        to bottom,
        transparent 0,
        black var(--fade-top, 0%),
        black calc(100% - var(--fade-bottom, 0%)),
        transparent 100%
      );
  }

  &.has-fade-above { --fade-top: 14%; }
  &.has-fade-below { --fade-bottom: 14%; }
}

// A COMPACTED excerpt: one bounded line per match, `…context[match]context…`
// (the six-character rule). No markdown block survives here, so no page-scale
// margins and no table overflow — the row is uniform by construction.
.lagrange-docs-search-hit-snippet.is-compact {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: none;
  overflow: visible;
  opacity: 0.78;

  .lagrange-docs-search-hit-excerpt {
    display: block;
    // One line each; a very long token run still clips rather than wrapping
    // the row taller than its neighbours.
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

.lagrange-docs-search-mark {
  background: none;
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: rgb(var(--color-primary) / 0.85);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

// Mobile: the trigger is one icon slot, exactly like its neighbours.
.lagrange-docs-search[data-shape="sheet"] {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.lagrange-docs-search-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  // The old min(360px, 86vw) cap was LEFT-ALIGNED inside the modal's
  // content box, so phones showed 16px of air on the left and ~42px on the
  // right. The modal owns the page gutter — the panel just fills it.
  width: 100%;

  .hk-search-input {
    width: 100%;
  }

  .lagrange-docs-search-results {
    // In flow inside the panel; the panel fills the modal's content box.
    width: 100%;
    // NO own scroller and NO own max-height. The modal BODY is the one
    // scroll container here (2026-11-27 user report: "右侧滚动条怎么是原生
    // 的…而且滚动条也没使用窗口自身的贴边的"). A nested `overflow:auto`
    // list gets the browser's native bar, inset from the window edge, and
    // two scroll containers fight over the wheel. HkModal's body already
    // carries the family's own overlay bar (`attachOverlayScrollbars`), so
    // letting the body scroll is what puts the SHARED bar on the WINDOW
    // edge — which is the shape the user asked for. Spelled out even though
    // the base rule no longer contradicts it, so a revert of either side
    // shows up as a real declaration change, not the absence of one.
    max-height: none;
    overflow: visible;
  }

  .lagrange-docs-search-busy {
    position: static;
  }
}


// ── markdown table scroll shell (build renders tables inside this host) ──
// A wide table must never widen the PAGE: the host clips it and the table
// keeps its natural width (min-width: max-content — cells stop collapsing
// into one-character columns on phones). The boot pass mounts the shared
// hk-edge-glow painter (hikari's ONE edge-glow painter — the same sheet the
// scroll containers use) on left/right and toggles the bands from sensed
// overflow: a band shows only while that edge hides content, and its ink is
// the theme primary — the "there is more beyond this edge" lamp.
.lagrange-docs-table-scroll {
  position: relative;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  // 原本写在 table 上的上下外边距(裸 table: 1.5rem 0)随包壳移到宿主,
  // 窄表不丢间距,宽表滚动时上下留白随宿主一起滚(可接受)。
  margin: 1.5rem 0;
  padding-bottom: 2px;

  // `width: 100%`(.lagrange-docs-body table)会压过这里的 min-width 并把
  // 宽表压进宿主——宿主规则必须赢:显式 width:auto + 表级特异性。
  > table {
    width: auto;
    min-width: max-content;
    max-width: none;
    margin: 0;
  }

  .hk-edge-glow {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
  }
}

// ── theme dialog: mode-extra strip (DPI block) ───────────────────────────
// The mode-extra strip is ONE menu column directly under the 主题模式
// group (the placement chest's settings window established); the DPI
// collapsible panel is its only child on docs faces. The styles port
// chest's useThemePanelSlots DPI sheet under the lagrange namespace —
// the anatomy (title+live value on the collapsed header, slider/actions/
// hints/warning in the body) is the copied contract.
.lagrange-docs-mode-extra {
  display: flex;
  flex-direction: column;
  gap: var(--space-8, 0.5rem);
}

.lagrange-dpi-panel {
  width: 100%;
}

// Auto state reads slightly emphasized on the header's subtitle (the
// live value "自动" is the state the user is back to, not a stale notch).
.lagrange-dpi-panel[data-auto] .hk-expansion-panel-subtitle {
  color: rgb(var(--color-text));
}

.lagrange-dpi-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-8, 0.5rem);
}

.lagrange-dpi-actions {
  display: flex;
  align-items: center;
  gap: var(--space-8, 0.5rem);
}

.lagrange-dpi-panel[data-auto] .lagrange-dpi-slider {
  opacity: 0.55;
}

.lagrange-dpi-warning {
  margin: 0;
  font-size: var(--text-xs, 0.75rem);
  color: rgb(var(--color-error));
  background: rgb(var(--color-error) / 8%);
  border: 1px solid rgb(var(--color-error) / 20%);
  border-radius: var(--radius-sm);
  padding: var(--space-8) var(--space-10);
}

.lagrange-dpi-hint {
  margin: 0;
  font-size: var(--text-xs, 0.75rem);
  opacity: 0.7;
}


// ── header end cluster ────────────────────────────────────────────────────
.lagrange-docs-header-end {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

// ── mermaid sub-app host ──────────────────────────────────────────────────
.lagrange-docs-mermaid {
  width: 100%;
  min-height: 120px;
}