/* The Toolbar Script Reference (bundleware.net/doc), after the Figma Docs section (257:1996): the B2/Docs banner
   (269:58) and footer (269:127), the tree pane and the content column of the Functions index (271:8759) and the
   function page (273:10619). It builds on tokens.css, which the generator copies beside it. The few values only
   the docs use are named below. */

@font-face { font-family: "Bundleware Tinos"; src: url("fonts/tinos-regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Bundleware Tinos"; src: url("fonts/tinos-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Bundleware Tinos"; src: url("fonts/tinos-bold.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Bundleware Tinos"; src: url("fonts/tinos-bold-italic.woff2") format("woff2"); font-weight: 700; font-style: italic; font-display: swap; }

:root {
  color-scheme: light;
  /* The banner's 6 % drafting grid and 30° sheen, the yellowed tree paper, the pane strip, the callout panel. */
  --doc-grid: rgba(255, 255, 255, .06);
  --doc-sheen: rgba(255, 255, 255, .22);
  --doc-toplink-highlight: inset 0 -1px 0 rgba(255, 255, 255, .18);
  --doc-updated: rgba(255, 255, 255, .85);
  --doc-tree-paper: linear-gradient(#FFFFFF, #FAFDE3);
  --doc-pane-strip: #DDDDEE;
  --doc-callout: #F3F4FC;
  --doc-reading: 800px;
  --doc-wide: 920px;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--b2-window); }
body { display: flex; flex-direction: column; min-height: 100vh; margin: 0; background: var(--b2-window); color: var(--b2-text); font: 400 13px/20px var(--b2-sans); }
a { color: var(--ink-steel-deep); text-underline-offset: 2px; }
code, pre { font-family: var(--b2-mono); }
img { max-width: 100%; }

/* ─── Masthead: the steel banner, its links and the index tabs ───────────── */

.doc-banner {
  position: relative; height: 104px; overflow: hidden;
  background:
    repeating-linear-gradient(90deg, var(--doc-grid) 0 1px, transparent 1px 16px),
    repeating-linear-gradient(180deg, var(--doc-grid) 0 1px, transparent 1px 16px),
    var(--ink-steel-plate);
  box-shadow: var(--b2-ink-highlight);
}
/* The sheen: transparent → 22 % white → transparent across x 700–930, cut to a band slanted 30° (60px over 104). */
.doc-banner::before {
  content: ''; position: absolute; top: 0; left: 700px; width: 230px; height: 104px; pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--doc-sheen), transparent);
  clip-path: polygon(60px 0, 100% 0, 170px 100%, 0 100%);
}
/* The shelf the tabs stand on. */
.doc-banner::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--b2-shelf); }
.doc-masthead::after { content: ''; display: block; height: var(--b2-strip-height); background: var(--b2-strip); }

.doc-wordmark {
  position: absolute; left: 24px; top: 18px; display: flex; align-items: center; gap: 10px;
  color: var(--ink-steel-label); text-decoration: none; white-space: nowrap;
  font: var(--b2-font-wordmark-masthead); text-shadow: var(--b2-type-shadow);
}
.doc-wordmark img { width: 24px; height: 24px; }
.doc-toplinks { position: absolute; top: 0; right: 24px; display: flex; gap: 3px; }
.doc-toplink {
  padding: 3px 9px 4px; border-radius: 0 0 var(--b2-radius-3) var(--b2-radius-3); background: var(--ink-steel-edge); box-shadow: var(--doc-toplink-highlight);
  color: var(--ink-steel-label); font: 500 11px/14px var(--b2-sans); text-decoration: none; white-space: nowrap;
}
.doc-toplink:hover { text-decoration: underline; }
.doc-updated { position: absolute; top: 32px; right: 8px; margin: 0; color: var(--doc-updated); font: var(--b2-font-note); white-space: nowrap; }

/* B2/Tab, label only: the cap is the ink's Fill under the top border, as Figma draws it; Pressed joins the strip. */
.doc-tabs { position: absolute; left: 24px; bottom: 0; display: flex; align-items: flex-end; gap: 3px; z-index: 1; }
.doc-tab, .doc-renders__stage .b2-tab {
  display: inline-flex; align-items: center; height: var(--b2-tab-height); padding: 2px 9px 0 8px;
  border: 1px solid var(--b2-part-border); border-radius: var(--b2-radius-tab);
  background: var(--ink-fill) top / 100% var(--b2-cap) no-repeat border-box, var(--b2-part) border-box;
  color: var(--b2-text); font: 500 12px/16px var(--b2-sans); text-decoration: none; white-space: nowrap;
}
.doc-tab:hover { border-color: var(--b2-part-border-hover); background: var(--ink-fill) top / 100% var(--b2-cap) no-repeat border-box, var(--b2-part-hover) border-box; }
.doc-tab[aria-current] {
  border-bottom-width: 0; border-color: var(--b2-part-border);
  background: var(--ink-fill) top / 100% var(--b2-cap-open) no-repeat border-box, var(--b2-part-open) border-box; font-weight: 600;
}
.doc-tab:focus-visible, .doc-toplink:focus-visible { outline: 1px dotted var(--b2-focus); outline-offset: var(--b2-focus-offset); }

/* ─── Body: the tree pane, its strip, the content column ─────────────────── */

.doc-body { display: flex; flex: 1; }
.doc-tree { flex: 0 0 280px; padding: 16px 12px 32px 14px; border-right: 8px solid var(--doc-pane-strip); background: var(--doc-tree-paper); }
.doc-content { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 14px; padding: 24px 40px 48px; }
.doc-content > * { max-width: var(--doc-wide); margin: 0; }
.doc-content > p, .doc-content > ul, .doc-content > ol, .doc-lede, .doc-note { max-width: var(--doc-reading); }

/* B2/Tree row: 18px rows, a 9px box, 13px indents on a guide under the box. */
.doc-tree__list { margin: 0; padding: 0; list-style: none; }
.doc-tree__group > .doc-tree__list { margin-left: 4px; padding-left: 9px; border-left: 1px solid var(--b2-tree-guide); }
.doc-tree__row { display: flex; align-items: center; gap: 5px; min-height: var(--b2-tree-row-height); font: 400 13px/18px var(--b2-sans); }
summary.doc-tree__row { list-style: none; cursor: default; }
summary.doc-tree__row::-webkit-details-marker { display: none; }
summary.doc-tree__row:focus-visible { outline: 1px dotted var(--b2-focus); outline-offset: 0; }
.doc-tree__box { position: relative; flex: none; width: 9px; height: 9px; border: 1px solid var(--b2-tree-box-border); background: var(--b2-tree-box); }
.doc-tree__box::before, .doc-tree__box::after { content: ''; position: absolute; background: var(--b2-text); }
.doc-tree__box::before { left: 1px; top: 3px; width: 5px; height: 1px; }
.doc-tree__box::after { left: 3px; top: 1px; width: 1px; height: 5px; }
.doc-tree__group[open] > summary > .doc-tree__box::after { display: none; }
.doc-tree__box--none { visibility: hidden; }
.doc-tree__label { color: var(--b2-title); text-decoration: none; white-space: nowrap; }
a.doc-tree__label:hover { text-decoration: underline; }
.doc-tree__label.is-path { color: var(--b2-tree-path); }
.doc-tree__label.is-current { padding: 0 3px; background: var(--b2-select); color: var(--b2-select-text); }

/* ─── Content: breadcrumb, headings, reading text ────────────────────────── */

.doc-content .doc-crumbs ol { display: flex; flex-wrap: wrap; align-items: baseline; margin: 0; padding: 0; list-style: none; color: var(--b2-text-2); font: 600 10px/14px var(--b2-sans); letter-spacing: .06em; text-transform: uppercase; }
.doc-content .doc-crumbs li { margin: 0; }
.doc-crumbs li + li::before { content: '›'; margin: 0 7px; letter-spacing: 0; }
.doc-crumbs a { color: inherit; text-decoration: none; }
.doc-crumbs a:hover { text-decoration: underline; }
.doc-crumbs code { color: var(--b2-text); font: 700 11px/14px var(--b2-mono); letter-spacing: 0; text-transform: none; }
.doc-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.doc-content h1 { margin: 0; color: var(--b2-title); font: var(--b2-font-heading); }
.doc-content h2 { margin: 18px 0 0; color: var(--b2-title); font: var(--b2-font-title); }
.doc-content h3, .doc-content h4, .doc-content h5, .doc-content h6 { margin: 8px 0 0; color: var(--b2-title); font: 600 13px/20px var(--b2-sans); }
.doc-lede { display: flex; flex-direction: column; gap: 14px; }
.doc-content p, .doc-lede p { margin: 0; }
/* Inline code takes its line's height: Courier's taller box would add a pixel to every row. */
.doc-content :not(pre) > code { font-size: 12px; line-height: 0; }
.doc-content ul, .doc-content ol { padding-left: 20px; }
.doc-content li + li { margin-top: 4px; }
.doc-content strong { font-weight: 600; }
.doc-content blockquote { margin: 0; padding-left: 12px; border-left: 2px solid var(--b2-hairline); color: var(--b2-text-2); }
.doc-content hr { width: 100%; border: 0; border-top: 1px solid var(--b2-hairline); }
.doc-note { color: var(--b2-text-2); font: 400 12px/18px var(--b2-sans); }
.doc-note strong { color: var(--b2-text); }

/* B2/Badge: Inter Bold 8 capitals on an ink. Copy is typed in any case. */
.doc-badge {
  display: inline-flex; align-items: center; height: var(--b2-badge-height); padding: 0 5px; border: 1px solid var(--ink-edge); border-radius: var(--b2-radius-2);
  background: var(--ink-fill); box-shadow: var(--b2-badge-highlight); color: var(--ink-label);
  font: var(--b2-font-caps); letter-spacing: var(--b2-caps-tracking); text-transform: uppercase; white-space: nowrap; vertical-align: middle;
}
/* The ink tile: a 20px square of Fill with its Edge and a white highlight, holding a 16px glyph. */
.doc-tile {
  display: inline-flex; flex: none; align-items: center; justify-content: center; width: 20px; height: 20px; border: 1px solid var(--ink-edge); border-radius: var(--b2-radius-3);
  background: var(--ink-fill); box-shadow: var(--b2-ink-highlight); color: var(--ink-label);
}
.doc-tile svg { width: 16px; height: 16px; flex: none; }

/* ─── Hairline tables (cellspacing=1) ────────────────────────────────────── */

.doc-table { width: 100%; border-collapse: separate; border-spacing: 1px; background: var(--b2-hairline); }
.doc-table:has(colgroup) { table-layout: fixed; }
/* Three-column tables written in Markdown line up with the generated ones, as Play Options does on useSound. */
.doc-table:not(:has(colgroup)):has(thead th:nth-child(3):last-child) { table-layout: fixed; }
.doc-table:not(:has(colgroup)) thead th:first-child:nth-last-child(3) { width: 218px; }
.doc-table:not(:has(colgroup)) thead th:nth-child(2):nth-last-child(2) { width: 268px; }
.doc-table th, .doc-table td { padding: 8px 10px; text-align: left; vertical-align: middle; overflow-wrap: anywhere; }
.doc-table thead th { padding: 7px 10px; background: var(--b2-cell-head); color: var(--b2-text); font: 500 12px/16px var(--b2-sans); }
.doc-table td { background: var(--b2-cell-value); color: var(--b2-text); font: 400 12px/18px var(--b2-sans); }
.doc-table td code { font-size: 11px; }
/* Names in a first column: Cousine Bold 13. Links are Steel Deep, except in the index, which names them in navy. */
.doc-name, .doc-table td:first-child > code { color: var(--b2-text); font: 700 13px/0 var(--b2-mono); overflow-wrap: normal; }
.doc-table .doc-name code { color: inherit; font: inherit; }
a.doc-name { color: var(--ink-steel-deep); }
.doc-index a.doc-name { color: var(--b2-text); text-decoration: none; }
.doc-index a.doc-name:hover { text-decoration: underline; }
.doc-index { margin-top: 16px; }
/* Types: Cousine 12. */
.doc-members td:nth-child(2) code { font-size: 12px; }
.doc-index td { height: 34px; padding-top: 0; padding-bottom: 0; }
.doc-facts th[scope='row'] { width: 132px; padding: 6px 8px; background: var(--b2-cell-label); color: var(--b2-text-2); font: 400 12px/16px var(--b2-sans); text-align: left; vertical-align: middle; }
.doc-facts td { padding: 6px 8px; font: 400 12px/16px var(--b2-sans); }
.doc-signatures td { padding: 6px 8px; }
.doc-signature { display: block; color: var(--b2-code-plain); font: 400 13px/18px var(--b2-mono); white-space: pre-wrap; }
.doc-signatures td code { font-size: 13px; line-height: 18px; }
.doc-limits td:first-child { background: var(--b2-cell-label); color: var(--b2-text-2); }
.doc-limits td strong { font-weight: 600; }
.doc-availability th[scope='row'] { width: 150px; }

/* ─── Code ───────────────────────────────────────────────────────────────── */

.doc-code { width: 100%; margin: 0; border: 1px solid var(--b2-hairline); background: var(--b2-window); }
.doc-code__file {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 26px; padding: 0 10px;
  border-bottom: 1px solid var(--b2-hairline); background: var(--b2-cell-head);
}
.doc-code__name { color: var(--b2-text); font: 700 12px/16px var(--b2-mono); }
.doc-code__body { display: flex; }
.doc-code__lines {
  flex: none; min-width: 33px; margin: 0; padding: 10px 8px 10px 10px; border-right: 1px solid var(--b2-cell-head); background: var(--b2-cell-label);
  color: var(--b2-code-line-number); font: 400 11px/18px var(--b2-mono); text-align: right; user-select: none;
}
.doc-code__source { flex: 1; min-width: 0; margin: 0; padding: 10px 14px; overflow-x: auto; color: var(--b2-code-plain); font: 400 12px/18px var(--b2-mono); tab-size: 2; }
.code-keyword { color: var(--b2-code-keyword); font-weight: 700; }
.code-string { color: var(--b2-code-string); }
.code-comment { color: var(--b2-code-comment); }
.code-tag { color: var(--b2-code-tag); }
.code-attribute { color: var(--b2-code-attribute); }
.code-number { color: var(--b2-code-number); }
.code-name { font-weight: 700; }

/* ─── Callouts: an ink rule, a tile and a title, then text and facts ─────── */

.doc-callout {
  position: relative; width: 100%; display: flex; flex-direction: column; gap: 10px; margin-top: 18px; padding: 12px 16px 14px 18px;
  border: 1px solid var(--b2-hairline); border-left: 0; background: var(--doc-callout);
}
.doc-callout::before { content: ''; position: absolute; top: -1px; bottom: -1px; left: 0; width: 4px; background: var(--ink-fill); }
.doc-content .doc-callout__title { display: flex; align-items: center; gap: 8px; margin: 0; }
.doc-callout p { margin: 0; }

/* ─── "What it renders": the parts the host draws, on the page stage ─────── */

.doc-renders { width: 100%; display: flex; flex-direction: column; gap: 8px; padding: 14px 16px 12px; border: 1px solid var(--b2-hairline); background: var(--b2-page); }
.doc-content .doc-renders h2 { margin: 0; }
.doc-renders__caption { margin: 0; color: var(--b2-text-2); font: var(--b2-font-note); }
/* These rules draw the host's bar parts for the strip, until the site copies the host's own sheets. */
.doc-renders__stage .bundle-bar { position: relative; display: flex; align-items: stretch; gap: var(--b2-gap); width: 640px; max-width: 100%; height: var(--b2-bar-height); padding: 0 8px 0 0; background: var(--b2-bar); box-shadow: var(--b2-bar-highlight); color: var(--b2-text); font: 500 12px/16px var(--b2-sans); }
.doc-renders__stage .bundle-bar::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--b2-shelf); }
.doc-renders__stage .bundle-plate { position: relative; flex: none; display: flex; align-items: center; gap: 7px; margin-right: 10px; padding: 0 8px 0 10px; background: var(--ink-plate); box-shadow: var(--b2-plate-highlight); color: var(--ink-label); z-index: 1; }
.doc-renders__stage .bundle-plate::before { content: ''; position: absolute; inset: 0; background: var(--b2-plate-sheen); pointer-events: none; }
.doc-renders__stage .bundle-plate-logo { display: flex; filter: var(--b2-mark-shadow); }
.doc-renders__stage .bundle-plate-logo svg { width: 16px; height: 16px; }
.doc-renders__stage .bundle-plate-wordmark { font: var(--b2-font-wordmark-small); text-shadow: var(--b2-type-shadow); white-space: nowrap; }
.doc-renders__stage .bundle-plate-tail { position: absolute; top: 0; right: -10px; width: 10px; height: 100%; background: var(--ink-deep); clip-path: polygon(0 0, 100% 0, 0 100%); }
.doc-renders__stage .bundle-command-strip { flex: 1; display: flex; align-items: stretch; gap: var(--b2-gap); }
.doc-renders__stage .bundle-command-slot { display: flex; align-items: flex-end; position: relative; z-index: 1; }
.doc-renders__stage .bundle-command-trailing { margin-left: auto; }
.doc-renders__stage .bundle-widget, .doc-renders__stage .bundle-status { align-self: center; display: flex; align-items: center; }
.doc-renders__stage .bundle-command-slot:has(.bundle-widget), .doc-renders__stage .bundle-command-slot:has(.bundle-status) { align-items: center; }
.doc-renders__stage .bundle-readout { display: inline-flex; height: var(--b2-readout-height); padding: 1px; gap: 1px; background: var(--b2-hairline); }
.doc-renders__stage .bundle-readout-label { display: flex; align-items: center; padding: 0 6px; background: var(--b2-readout-label); color: var(--b2-text-2); font: 600 9px/12px var(--b2-sans); letter-spacing: .08em; text-transform: uppercase; }
.doc-renders__stage .bundle-readout-value { display: flex; align-items: center; padding: 0 8px; background: var(--b2-cell-value); color: var(--b2-text); font: 500 12px/16px var(--b2-sans); white-space: pre; }
.doc-renders__stage .bundle-status { gap: 6px; padding-right: 2px; }
.doc-renders__stage .b2-lamp { width: 8px; height: 8px; border: 1px solid var(--ink-edge); border-radius: 50%; background: var(--ink-fill); box-shadow: var(--b2-ink-highlight); }

/* ─── Footer ─────────────────────────────────────────────────────────────── */

.doc-footer {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 36px; padding: 0 24px;
  border-top: 1px solid var(--b2-shelf); background: var(--b2-bar); color: var(--b2-text-2); font: var(--b2-font-note);
}
.doc-footer img { width: 16px; height: 16px; }
.doc-footer__name { color: var(--b2-text); font: var(--b2-font-label); }
.doc-footer__sources { margin-left: auto; }
.doc-footer code { color: var(--b2-text); font: 400 11px/14px var(--b2-mono); }

/* ─── Narrow windows: the tree above the content, the banner stacked ─────── */

@media (max-width: 900px) {
  .doc-banner { height: auto; min-height: 104px; padding: 18px 24px 40px; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 24px; }
  .doc-wordmark, .doc-toplinks, .doc-updated { position: static; }
  .doc-wordmark { white-space: normal; font-size: 24px; line-height: 28px; }
  .doc-toplinks { order: -1; width: 100%; margin-top: -18px; }
  .doc-body { flex-direction: column; }
  .doc-tree { flex: none; border-right: 0; border-bottom: 8px solid var(--doc-pane-strip); }
  .doc-content { padding: 24px 16px 40px; }
}
