/* ============================================================
   Docs chrome (unlayered → always wins over the framework).
   Shared by index.html and extensions.html.
   ============================================================ */
html {
  scroll-behavior: smooth;
}

/* The dark base must live on the document itself so it shows through every
   gutter and reflow gap, ensuring no stray light colors leak between cards. */
html,
body {
  background: var(--bg-void);
}

/* ---------- Main column ----------
   Horizontal padding is the page gutter. It never drops below 20px, so on the
   smallest phone the content always keeps a margin from the screen edge. */
.doc-main > * {
  max-inline-size: 1080px;
}

/* ---------- Floating-toolbar search ----------
   A quick-jump field pinned in the floating dock. The results listbox is a
   sibling of the toolbar (never a child) so the toolbar's clip-path can't clip
   it; JS positions it fixed, just above the dock, aligned to the toolbar. */
.doc-search {
  inline-size: clamp(9rem, 34vw, 15rem);
  margin-inline-end: 4px;
  padding-block: 8px;
  font-size: var(--fs-xs);
}

.doc-search__results {
  z-index: 31;
  position: fixed;
  margin: 0;
  padding: 6px;
  list-style: none;
  border: 1px solid var(--hairline-strong);
  background-color: var(--surface-panel);
  background-image: var(--scanlines);
  box-shadow: var(--shadow-raised);
  clip-path: var(--clip-notch);
  --bevel-sm: 8px;
}

/* Kill the framework's list-marker chevron (::before) on the result rows. */
.doc-search__opt::before,
.doc-search__empty::before {
  content: none;
}

.doc-search__opt {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-inline: 12px;
  padding-block: 8px;
  cursor: pointer;
  color: var(--text-secondary);
}

.doc-search__opt.is-active,
.doc-search__opt:hover {
  background-color: var(--surface-panel-2);
  color: var(--text-primary);
}

.doc-search__opt-title {
  font-family: var(--font-display);
  letter-spacing: var(--ls-wide);
}

.doc-search__opt-title mark {
  background: transparent;
  color: var(--cyan-400);
}

.doc-search__opt-group {
  flex: none;
  color: var(--text-muted);
  font-size: var(--fs-2xs);
  font-family: var(--font-display);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
}

.doc-search__empty {
  padding-inline: 12px;
  padding-block: 10px;
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

/* ---------- Hero ---------- */
.doc-hero {
  position: relative;
  padding: clamp(var(--space-8), 6vw, var(--space-11)) clamp(var(--space-6), 5vw, var(--space-8))
    clamp(var(--space-7), 5vw, var(--space-10));
  overflow: hidden;
  border: 1px solid var(--hairline);
  --bevel-md: 16px;
  /* shape from the .vui-chamfer class in markup */
  margin-block-end: var(--space-9);
  background-image: var(--grid-fine);
  background-size: var(--grid-fine-size);
  background-color: var(--bg-void);
}

.doc-hero::after {
  position: absolute;
  inset: 0;
  background: var(--vignette);
  content: '';
  pointer-events: none;
}

.doc-hero__in {
  z-index: 1;
  position: relative;
}

.doc-hero h1 {
  margin: 0 0 16px;
  font-size: var(--fs-5xl);
  text-wrap: balance;
}

.doc-hero h1 b {
  color: var(--cyan-400);
  text-shadow: var(--text-glow-cyan);
}

.doc-hero p {
  max-inline-size: 56ch;
  margin: 0 0 24px;
  color: var(--text-secondary);
  font-size: var(--fs-md);
  text-wrap: pretty;
}

.doc-hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ---------- Sections ----------
   The whole reference is ONE neutral <article> (v3.0) holding a bare
   <section> per topic (the framework styles the section: hairline divider,
   block rhythm, scroll anchor, first-child reset) composed with .vui-prose
   for the measure (see gallery.js render()). The docs only widen the
   measure/bleed, set the grid's row rhythm, and size the lead .blurb;
   everything else is inherited from the framework, so the section chrome
   matches the rest of the library. */
:is(#doc-main > article, #doc-main, #compat-main) > section {
  --prose-width: 72ch;
  --bleed-width: 1100px;
  row-gap: var(--space-7);
}

:is(#doc-main > article, #doc-main, #compat-main) > section > * {
  margin-block: 0;
}

:is(#doc-main > article, #doc-main, #compat-main) > section > .blurb {
  font-size: var(--fs-base);
}

:is(#doc-main > article, #doc-main, #compat-main) > section > .blurb code {
  font-size: 0.85em;
}

/* ---------- Example: live demo + code ----------
   The demo wrapper is an `<article class="vui-panel stage">` (v3.0: the
   panel is a named word): the library paints the chamfered plate, the
   recessed ink + scanlines body, and the surface footer bar. We only zero
   the panel padding (children are full-bleed here) and keep
   overflow:hidden so demo content is clipped to the plate in both corner
   mechanisms (the static .doc-example.vui-chamfer code snippet, the
   noDemo path, is a plain div and still needs this border + shape). */
.doc-example {
  margin-block-end: var(--space-6);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--hairline);
}

.doc-demo {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: clamp(var(--space-5), 3vw, var(--space-7));
  gap: 14px;
}

.doc-demo > * {
  max-inline-size: 100%;
}

/* Full-bleed chrome (header/footer) must stretch to a definite width:
   the demo column is align-items:flex-start, and a header is a size
   container (container-type:inline-size), so without a definite width it
   would collapse while its content overflows. Stretch fixes both. */
.doc-demo > header,
.doc-demo > footer,
.doc-demo > .vui-prose,
.doc-demo > nav,
/* Disclosure widgets shrink-wrap in this flex-start column, so opening one
   resizes its width instantly (only block-size transitions). Stretching them
   to a definite width keeps the open/close animation purely vertical. The
   dropdown is an inline-block menu trigger, so it stays out. */
.doc-demo > details:not(.dropdown),
.doc-demo > ul.tree {
  align-self: stretch;
  inline-size: auto;
}

/* Any bare card cluster a demo drops in flows responsively by default:
   as many ~13rem cards as fit, collapsing to a single full-width card. */
.doc-demo .vui-autogrid {
  inline-size: 100%;
  --vui-min: 13rem;
}

.doc-demo--frame {
  display: block;
  padding: 0;
}

.doc-demo--frame .vui {
  block-size: 440px;
  min-block-size: 0;
}

.doc-code {
  position: relative;
  border-block-start: 1px solid var(--hairline);
}

.doc-code pre {
  max-block-size: 360px;
  margin: 0;
  overflow: auto;
  border: 0;
  border-radius: 0;
  background: var(--ink-1000);
  clip-path: none;
}

/* Inline copy button: the framework's `button.icon small` supplies the
   square notched control + hover; we only place it and tint when copied. */
.doc-copy {
  z-index: 2;
  position: absolute;
  inset-block-start: 10px;
  inset-inline-end: 10px;
}

.doc-copy.is-copied {
  border-color: var(--green-500);
  color: var(--green-500);
}

/* ---------- Syntax highlight (tactical palette) ---------- */
.doc-code .tk-tag {
  color: var(--cyan-400);
}

.doc-code .tk-attr {
  color: var(--amber-400);
}

.doc-code .tk-str {
  color: var(--green-400);
}

.doc-code .tk-com {
  color: var(--text-faint);
  font-style: italic;
}

.doc-code .tk-pun {
  color: var(--text-muted);
}

.doc-code .tk-kw {
  color: var(--cyan-400);
  font-weight: 600;
}

.doc-code .tk-num {
  color: var(--amber-400);
}

/* ---------- Token galleries ---------- */
.doc-tok-h {
  margin: var(--space-6) 0 10px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  font-family: var(--font-display);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.doc-tokens .doc-tok-h:first-child {
  margin-block-start: 0;
}

.doc-swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(110px, 100%), 1fr));
  gap: 8px;
}

.doc-swatch {
  display: flex;
  align-items: flex-end;
  block-size: 72px;
  padding: 8px;
  border: 1px solid var(--hairline);
  --bevel-md: 7px;
  /* shape from the .vui-chamfer class in markup */
}

.doc-swatch__name {
  font-size: 10px;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

.doc-spaces {
  display: flex;
  flex-direction: column;
  margin-block-end: var(--space-7);
  gap: 6px;
}

.doc-space {
  display: flex;
  align-items: center;
  gap: 14px;
}

.doc-space__bar {
  flex: none;
  block-size: 14px;
  background: var(--cyan-400);
  box-shadow: var(--glow-cyan-sm);
}

.doc-space__tag {
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--font-mono);
}

.doc-geo {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.doc-geo__plate {
  display: grid;
  place-items: center;
  inline-size: 150px;
  block-size: 84px;
  border: 1px solid var(--hairline-strong);
  background: var(--surface-panel);
  color: var(--cyan-400);
  font-size: 12px;
  font-family: var(--font-display);
  letter-spacing: 0.16em;
}

/* Phones: tighten the rhythm so content breathes without ever shrinking type
   into illegibility. Layout reflows; gutters stay. */
@media (max-width: 40rem) {
  :is(#doc-main > article, #doc-main, #compat-main) > section {
    padding-block: var(--space-7);
  }

  .doc-geo {
    gap: 10px;
  }

  .doc-geo__plate {
    flex: 1 1 130px;
    inline-size: 100%;
  }

  .doc-hero__meta {
    gap: 8px;
  }
}
