lagrange-library 0.3.3

A WASI-rendered Markdown static site facility — multilingual out of the box
// 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;
}

.lagrange-docs-search-busy {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  padding: 0.5rem 0.7rem;
  border-radius: var(--hk-radius-surface, 10px);
  background: rgb(var(--hk-color-surface, 255 255 255));
  border: 1px solid color-mix(in srgb, rgb(var(--hk-color-text, 30 30 30) / 0.12), transparent);
  font-size: 0.8rem;
  opacity: 0.85;
}

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

.lagrange-docs-search-results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: min(420px, 90vw);
  max-height: 60vh;
  overflow: auto;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  border-radius: var(--hk-radius-surface, 10px);
  background: rgb(var(--hk-color-surface, 255 255 255));
  border: 1px solid color-mix(in srgb, rgb(var(--hk-color-text, 30 30 30) / 0.12), transparent);
  box-shadow: 0 8px 28px rgb(0 0 0 / 0.18);
}

.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;
  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;
}

.lagrange-docs-search-hit-snippet {
  font-size: 0.78rem;
  opacity: 0.6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

// 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;
  width: min(360px, 86vw);

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

  .lagrange-docs-search-results {
    // In flow inside the panel: the popover owns the surface.
    position: static;
    width: 100%;
    max-height: 55vh;
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0;
  }

  .lagrange-docs-search-busy {
    position: static;
    padding: 0.4rem 0;
  }
}


// ── 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;
}