/* carbium.sh/library (library-render.js): /docs's own frame and parts (docs.css), on cui tokens, plus the few the library adds.
   Colour (operator 2026-11-22: "create each section with its own accent and run 2 accents per section combining all the ones in our
   branding in landing so its nice and smooth across", "we have it centralized so changing one should give them all"): one attribute,
   data-g, gives each collection two accents from the landing's hues, its own (a) and the next one's (b), so the five run round the
   wheel: blue, teal, gold, red, purple and back to blue. The library's own pages (landing, 404) are blue with purple. Every part reads
   --_g and --_g2 (the pair in use) or the brand tokens, which follow --_g; every second section swaps the pair. Marks take the hue,
   text its -tint (AA in both themes). The site's header and footer keep their purple: they sit outside .cw-docs-main. */
.cw-lib .cw-docs-main { --_a: var(--c-info); --_at: var(--c-ws-tint); --_b: var(--c-rpc); --_bt: var(--c-rpc-tint); }
.cw-lib [data-g="usecase"] { --_a: var(--c-info); --_at: var(--c-ws-tint); --_b: var(--c-das); --_bt: var(--c-das-tint); }
.cw-lib [data-g="howsolana"] { --_a: var(--c-das); --_at: var(--c-das-tint); --_b: var(--c-quote); --_bt: var(--c-quote-tint); }
.cw-lib [data-g="integrate"] { --_a: var(--c-quote); --_at: var(--c-quote-tint); --_b: var(--c-stream); --_bt: var(--c-stream-tint); }
.cw-lib [data-g="blockchainideas"] { --_a: var(--c-stream); --_at: var(--c-stream-tint); --_b: var(--c-rpc); --_bt: var(--c-rpc-tint); }
.cw-lib [data-g="si"] { --_a: var(--c-rpc); --_at: var(--c-rpc-tint); --_b: var(--c-info); --_bt: var(--c-ws-tint); }
.cw-lib :is(.cw-docs-main, [data-g]) { --_g: var(--_a); --_gt: var(--_at); --_g2: var(--_b); }
.cw-lib .cw-docs-body > .cw-sec:nth-of-type(even) { --_g: var(--_b); --_gt: var(--_bt); --_g2: var(--_a); }
.cw-lib :is(.cw-docs-main, [data-g], .cw-docs-body > .cw-sec:nth-of-type(even)) {
  --c-brand: var(--_g);
  --c-brand-tint: var(--_gt);
  --c-brand-wash: rgb(from var(--_g) r g b / .08);
  --c-brand-line: rgb(from var(--_g) r g b / .5);
  --c-brand-glow: rgb(from var(--_g) r g b / .35);
  --c-focus: 0 0 0 2px var(--c-bg), 0 0 0 4px var(--_g);
}
.cw-lib .cw-code2 .cw-st { color: var(--c-rpc-tint); }   /* code strings keep their colour, apart from the blue flags */
.cw-lib .cw-b-split { grid-row: 2; }   /* the fill row even when the bar above is hidden (docs.css .cw-b rows auto, 1fr): a short page's index still reaches the footer */
/* the index (operator 2026-11-22: "a bit nicer icon to start and better bullets for each section ... feels off with the # while others
   have nice colors", and "Overview, not overview"): each collection its own colour from the tokens, its group named in reading case
   beside the shelf icon, coloured dots for its categories, a chevron for its "All" */
.cw-lib .cw-fam > summary.cw-grp { font: 600 13.5px/1.2 var(--c-font-body); letter-spacing: 0; text-transform: none; color: var(--c-muted); }
.cw-lib .cw-fam[open] > summary.cw-grp { color: var(--c-text); }
.cw-lib .cw-fam > summary .cw-ico { color: var(--_g); }
.cw-lib .cw-idx-list .cw-dx-a .cw-dx-h { color: var(--_gt); font-size: 13px; }
.cw-lib .cw-idx-list .cw-dx-a .cw-dx-h.is-dot { width: 7px; height: 7px; border-radius: 50%; background: linear-gradient(135deg, var(--_g), var(--_g2)); }
.cw-lib .cw-idx-list .cw-dx-a.m .cw-dx-h.is-dot { width: 5px; height: 5px; margin: 0 1px; background: none; box-shadow: inset 0 0 0 1.5px var(--_g); }
.cw-lib .cw-kick a { color: inherit; text-decoration: none; }   /* the kicker's path reads as the kicker; its hover in the accent */
.cw-lib .cw-kick a:hover { color: var(--c-brand-tint); }
/* the page being read, marked in the index as /docs marks its active entry (docs.css .cw-dx-a.is-active) */
.cw-lib .cw-idx-list .cw-dx-a[aria-current] { color: var(--c-text); background: color-mix(in srgb, var(--_g) 14%, var(--c-raised)); border-left-color: var(--_g); }
.cw-lib .cw-idx-list .cw-dx-a[aria-current] .cw-dx-h { color: var(--c-text); }

/* the head: the search first (on the landing the name, then the large search under it, then the lede), the kicker, the name */
.cw-lib-start { text-align: left; }
.cw-lib-start .cw-lib-q { margin-bottom: var(--c-s-9); }
.cw-lib-home { padding-top: var(--c-s-8); text-align: center; }
.cw-lib-home .cw-start-h1 { font-size: clamp(36px, 4.4vw, 56px); margin-bottom: var(--c-s-8); }
.cw-lib .cw-b-ref .cw-lib-home .cw-sec-lead { max-width: 72ch; margin: 0 auto var(--c-s-9); text-align: center; text-align-last: center; hyphens: manual; -webkit-hyphens: manual; }   /* docs.css justifies a lede (its :is() weighs 0,3,1); a centred one reads even */
.cw-lib-q > .cw-q-open.cw-lib-big { height: 56px; font-size: 16px; border-color: var(--c-brand); box-shadow: 0 0 0 4px var(--c-brand-wash); }   /* the landing's field: the accent itself as its edge (8.6 dark, 3.4 light) */
.cw-lib-q.is-big { max-width: 720px; margin-bottom: var(--c-s-7); }
/* the landing's collections: one card each in a grid that adds a column as the width grows (2 at 1440 px, 3 near 1900, 4 near
   2500), the body let past the docs' 1036 px column so the extra columns have room */
.cw-b-ref > :is(.cw-lib-wide, .cw-lib-home) { max-width: none; }   /* the landing's head and grid share the full width, so the name and search centre over the cards */
.cw-lib-cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); gap: var(--c-s-8); }
.cw-lib-col { display: flex; flex-direction: column; min-width: 0; padding: var(--c-s-9) var(--c-s-9) var(--c-s-8); border: 1px solid var(--c-line); border-radius: var(--c-r-card); background: var(--c-surface); }

.cw-lib-col .cw-sec-h { margin-bottom: var(--c-s-6); }
.cw-lib-col .cw-h2 { font-size: 22px; }
.cw-lib .cw-b-ref .cw-lib-col .cw-sec-lead { margin-bottom: var(--c-s-7); }
.cw-lib-mini { list-style: none; margin: 0 0 var(--c-s-7); padding: 0; display: grid; gap: var(--c-s-6); }
.cw-lib-mini li { padding-top: var(--c-s-5); border-top: 1px solid var(--c-line-soft); }
.cw-lib-mini .cw-alink { font: 600 14.5px/1.3 var(--c-font-display); }
.cw-lib-mini .cw-lib-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cw-lib-all { margin-top: auto; align-self: flex-start; font-size: 13px; white-space: nowrap; }

.cw-lib-meta { margin: 0 0 var(--c-s-6); font-family: var(--c-font-mono); font-size: 11.5px; letter-spacing: .06em; color: var(--c-faint); }
.cw-lib-acts { display: flex; flex-wrap: wrap; gap: var(--c-s-4); }
.cw-lib-list { margin: 0 0 var(--c-s-9); padding-left: 1.3em; max-width: 66ch; color: var(--c-muted); font-size: 13.5px; line-height: 1.6; }
.cw-lib-list li + li { margin-top: var(--c-s-3); }
.cw-lib-run { margin: var(--c-s-4) 0 var(--c-s-9); font-size: 12.5px; color: var(--c-faint); }
.cw-docs-body h3.cw-subh { margin-top: var(--c-s-8); }

/* entry cards */
.cw-lib-cards { list-style: none; margin: 0 0 var(--c-s-7); padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--c-s-5); }
.cw-lib-cards li { display: flex; flex-direction: column; gap: var(--c-s-3); padding: var(--c-s-7); border: 1px solid var(--c-line); border-radius: var(--c-r-card); background: var(--c-surface); }

.cw-lib-cards .cw-alink { font: 600 15px/1.3 var(--c-font-display); letter-spacing: -.01em; }
.cw-lib-id { font-family: var(--c-font-mono); font-size: 11px; color: var(--c-faint); }
.cw-lib-desc { margin: 0; font-size: 13px; line-height: 1.5; color: var(--c-muted); }

/* softness (operator 2026-11-22: "the design system from carbium.sh so soften things a bit"): the landing's devices, in each
   collection's pair: faint washes in its corners, a surface the waves show through, a glow
   on hover (landing.css .sh-c, .sk-s.is-lit) */
.cw-lib :is(.cw-lib-col, .cw-lib-cards li) { border-color: rgb(from var(--_g) r g b / .22); box-shadow: var(--c-shadow-card, none);
  background: radial-gradient(90% 70% at 0% 0%, rgb(from var(--_g) r g b / .08), transparent 70%),
    radial-gradient(80% 60% at 100% 100%, rgb(from var(--_g2) r g b / .06), transparent 70%), rgb(from var(--c-surface) r g b / .82);
  transition: border-color var(--c-dur-3) var(--c-ease), box-shadow var(--c-dur-3) var(--c-ease); }
.cw-lib :is(.cw-lib-col, .cw-lib-cards li):is(:hover, :focus-within) { border-color: rgb(from var(--_g) r g b / .55); box-shadow: 0 0 14px rgb(from var(--_g) r g b / .25); }
.cw-lib .cw-kick b { color: var(--_gt); text-shadow: 0 0 14px rgb(from var(--_g) r g b / .35); }
/* icons that place a page: a collection's mark in a chip (its card, its page's and its entries' titles, its index group), a section's
   kind beside its number (the code, the limits, what goes wrong, questions, related) */
.cw-lib .cw-ico.is-chip { width: 30px; height: 30px; align-items: center; justify-content: center; border-radius: var(--c-r-card); color: var(--_gt);
  background: linear-gradient(135deg, rgb(from var(--_g) r g b / .18), rgb(from var(--_g2) r g b / .1));
  box-shadow: inset 0 0 0 1px rgb(from var(--_g) r g b / .38), 0 0 14px -4px rgb(from var(--_g) r g b / .5); }
.cw-lib .cw-ico.is-chip svg { width: 16px; height: 16px; }
.cw-lib .cw-start-h1:has(> .is-chip) { display: flex; align-items: center; gap: var(--c-s-6); }
.cw-lib .cw-start-h1 > .is-chip { width: 44px; height: 44px; }
.cw-lib .cw-start-h1 > .is-chip svg { width: 22px; height: 22px; }
.cw-lib .cw-sec-h > .cw-kick:has(> .cw-ico) { display: inline-flex; align-items: center; gap: var(--c-s-4); }
.cw-lib .cw-sec-h > .cw-kick > .cw-ico { order: -1; color: var(--_gt); }
.cw-lib .cw-sec-h > .cw-kick > .cw-ico:not(.is-chip) svg { width: 15px; height: 15px; }
.cw-lib .cw-idx-list .cw-dx-a.m { font-family: var(--c-font-body); font-size: 13px; }   /* an entry in the index reads in the body face (docs' .m leaves are methods, in mono) */
/* a heading's chip or icon, number and title on one centred row (operator 2026-11-22: "center the titles of each section a bit more") */
.cw-lib .cw-sec-h { align-items: center; }
/* the search field and its list (src/library.js): the field is the page's own, its results open right under it as one types */
.cw-lib-q { position: relative; width: 100%; max-width: 640px; margin: 0 auto var(--c-s-8); }
.cw-lib-q > .cw-q-open { margin: 0; max-width: none; cursor: text; border-color: var(--c-faint); }   /* a field's edge at 3:1 or more, as cui's .c-input (5.0 dark, 5.3 light) */
.cw-lib-q > .cw-q-open:focus-within { border-color: var(--c-brand-line); box-shadow: 0 0 0 4px var(--c-brand-wash); }
.cw-lib-q .cw-q-in { height: 100%; padding: 0; color: var(--c-text); }
.cw-lib-q .cw-q-in::-webkit-search-cancel-button { display: none; }
.cw-lib-ql { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; right: 0; max-height: min(60vh, 520px); overflow-y: auto; overscroll-behavior: contain;
  padding: var(--c-s-3); border: 1px solid var(--c-line); border-radius: var(--c-r-card); background: var(--c-surface); text-align: left;
  box-shadow: 0 18px 48px rgb(0 0 0 / .4), 0 0 0 1px rgb(from var(--c-brand) r g b / .08); }
.cw-lib-ql[hidden] { display: none; }
.cw-lib-qo { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: var(--c-s-5); row-gap: 2px; padding: var(--c-s-4) var(--c-s-5);
  border-radius: var(--c-r-ctl); color: inherit; text-decoration: none; }
.cw-lib-qo > .cw-ico { grid-row: span 3; align-self: center; color: var(--_g); }
.cw-lib-qo > :not(.cw-ico) { grid-column: 2; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-lib-qo-t { font: 600 14.5px/1.3 var(--c-font-body); color: var(--c-text); }
.cw-lib-qo-d { font-size: 13px; line-height: 1.4; color: var(--c-muted); }
.cw-lib-qo-p { font: 500 11px/1.4 var(--c-font-mono); color: var(--c-faint); }
.cw-lib-qo mark { background: none; color: var(--_gt); font-weight: 700; }
.cw-lib-qo[aria-selected="true"], .cw-lib-qo:hover { background: color-mix(in srgb, var(--_g) 12%, var(--c-raised)); }
.cw-lib-qn { margin: 0; padding: var(--c-s-5); font-size: 13px; color: var(--c-muted); }
/* every wall of text justified, its last line ragged, long words hyphenated (operator 2026-11-22: "justified text format for all text
   walls"); the landing's one centred line under its search stays centred */
.cw-lib .cw-b-ref :is(.cw-docs-body .cw-sec-lead, .cw-lib-col .cw-sec-lead, .cw-lib-list li, .cw-note > span, .cw-lib-desc, .cw-lib-start:not(.cw-lib-home) > .cw-sec-lead) {
  text-align: justify; text-align-last: start; hyphens: auto; -webkit-hyphens: auto; }
/* a page change between the library and the app's pages crossfades where both pages opt in (the app's side: its own @view-transition) */
@view-transition { navigation: auto; }
