/* Palette: aliased to Carbon's own --cds-* custom properties (from
 * @carbon/styles, linked in index.html), never hand-copied hex. Which theme's
 * values those resolve to is decided by the cds--g100/cds--white class on
 * <html>, toggled by the inline script in index.html to track system
 * preference — so this file carries no light/dark branching of its own. */
:root {
  --bg-soft: var(--cds-layer-01);
  --line: var(--cds-border-subtle-01);
  --fg: var(--cds-text-primary);
  --muted: var(--cds-text-secondary);
  --accent: var(--cds-link-primary);
  --accent-2: var(--cds-link-primary);
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* Carbon's spacing scale ($spacing-01…13). @carbon/styles compiles it into
 * its components' rules and declares the custom properties on no element a
 * page has, so unlike the palette it is declared here, Carbon's values under
 * Carbon's names, for the layouts no cds-stack can space (a grid whose rows
 * share its columns). */
:root {
  --cds-spacing-01: 0.125rem;
  --cds-spacing-02: 0.25rem;
  --cds-spacing-03: 0.5rem;
  --cds-spacing-04: 0.75rem;
  --cds-spacing-05: 1rem;
  --cds-spacing-06: 1.5rem;
  --cds-spacing-07: 2rem;
  --cds-spacing-08: 2.5rem;
  --cds-spacing-09: 3rem;
  --cds-spacing-10: 4rem;
  --cds-spacing-11: 5rem;
  --cds-spacing-12: 6rem;
  --cds-spacing-13: 10rem;
}


/* Carbon custom elements render unstyled/unboxed until their module has
 * loaded and upgraded them — hide them until then to avoid a FOUC flash. */
cds-header:not(:defined),
cds-header-nav:not(:defined),
cds-header-nav-item:not(:defined),
cds-tile:not(:defined),
cds-clickable-tile:not(:defined),
cds-button:not(:defined),
cds-header-global-action:not(:defined),
cds-code-snippet:not(:defined),
cds-side-nav:not(:defined),
cds-side-nav-items:not(:defined),
cds-side-nav-link:not(:defined),
cds-side-nav-menu:not(:defined),
cds-side-nav-menu-item:not(:defined),
cds-toggletip:not(:defined),
cds-accordion:not(:defined),
cds-accordion-item:not(:defined),
cds-select:not(:defined),
diff-view-element:not(:defined),
zero-md:not(:defined) {
  visibility: hidden;
}

/* Carbon offsets its UI-shell content area (.cds--content) below its header
 * and beside its side nav, but only for the class-based shell
 * (.cds--header ~ .cds--content, .cds--side-nav--expanded ~ .cds--content).
 * The same offsets for the cds-header and cds-side-nav web components; the
 * side nav is a persistent 16rem rail from Carbon's lg breakpoint (66rem),
 * behind the header's menu button below it. */
cds-header ~ .cds--content { margin-block-start: 3rem; }
@media (min-width: 66rem) {
  cds-side-nav:not([is-not-persistent]) ~ .cds--content { margin-inline-start: 16rem; }
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

code { font-family: var(--mono); }

code {
  font-size: 0.875em;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

/* syntax accents */
.c-at { color: var(--accent); }
.c-kw { color: #c792ea; }
.c-fn { color: var(--accent-2); }
.c-n  { color: #f2b05e; }
.c-s  { color: #86d99a; }
.c-cm { color: var(--muted); font-style: italic; }

/* cds-header, cds-header-name, cds-header-nav-item are Carbon UI Shell
 * elements — styled entirely by the component itself via the --cds-* tokens
 * above. The "▚" brand glyph is the component's own `prefix` attribute,
 * exposed as ::part(prefix), not a CSS hack. */
cds-header-name::part(prefix) { color: var(--accent); }

/* The GitHub link is a cds-header-global-action with `href` and
 * `tooltip-text` — it extends CDSButton directly (header defaults: ghost,
 * lg, tooltip below), so it renders as a real <a>, sized/centered/tinted
 * exactly like every other header action, no extra module or custom CSS.
 * The `.cds--header__global` div is Carbon's own light-DOM slotting class
 * for right-aligning header children. */

/* A Carbon grid pads its inner grid (exposed as part "grid") by the grid
 * margin, 1rem from 42rem wide. The content area already has its padding, so
 * grids here line up with the text around them instead of sitting a margin in. */
.cds--content cds-grid::part(grid) { padding-inline: 0; }

/* The overview's tile, its intros, heat maps and sparklines, all in Carbon's
 * label-01 type. Neither @carbon/styles' CSS nor @carbon/type (Sass and JS
 * only) publishes a class or a global token for it. */
#glance cds-tile { font-size: 0.75rem; line-height: 1.33333; letter-spacing: 0.32px; }

/* A Carbon toggletip sits in the sentence it explains; Carbon displays it as
 * a block, which breaks the sentence onto its own line. */
cds-toggletip { display: inline-flex; vertical-align: middle; }

/* cds-stack lays its children out as a CSS grid, and a grid item is by
 * default at least as wide as its widest content: one wide table or chart
 * then widens the whole stack past the screen, and every paragraph in it
 * with it. Letting the items shrink keeps the stack to its container; wide
 * content scrolls in its own box instead. */
cds-stack > * { min-width: 0; }

/* The colour-scale step of the heat map square under the pointer (charts.js). */
[data-step][data-active] { outline: 2px solid var(--cds-focus, #0f62fe); outline-offset: 1px; position: relative; z-index: 1; }

/* A content switcher's hidden panel (carbon.rs ContentPanel) keeps its width,
 * at no height: what holds the panels is as wide as the widest, whichever is
 * shown. */
[data-panel][hidden] { display: block; height: 0; overflow: hidden; visibility: hidden; }

/* A sparkline's x axis keeps its title, the label Carbon's tooltip gives the
 * x value, but does not print it: the panel's heading names the dimension.
 * Every combo chart is a sparkline. */
[data-chart^='{"kind":"combo"'] .axis.bottom .axis-title { display: none; }

/* diff-view-element (https://konnorrogers.github.io/diff-view-element/) does
 * its own diffing and PrismJS highlighting in shadow DOM. Every property set
 * below is one of the component's own real, documented hooks — either a
 * :host custom property it reads in default-theme.styles.js (--syntax-*,
 * --mono-*, --hue-*), or a ::part() name it puts on specific shadow elements
 * itself (table, line, character-diff--*) — never a shadow-piercing
 * selector. --mono/--cds-code-01-font-size is the same font cds-code-snippet
 * uses elsewhere in this file; --hue-2/3/4/6 are the exact colors .c-fn/
 * .c-kw/.c-s/.c-n use for the hand-highlighted single-file pane, so the two
 * views agree; everything else (backgrounds, borders, inserted/deleted) maps
 * to the same --cds-* aliases the rest of the site uses, so it tracks
 * light/dark mode like everything else instead of PrismJS's own fixed
 * "One Light" palette. */
diff-view-element {
  --mono-1: var(--fg);
  --mono-2: var(--muted);
  --mono-3: var(--muted);
  --hue-1: var(--accent);
  --hue-2: var(--accent-2);
  --hue-3: #c792ea;
  --hue-4: #86d99a;
  --hue-5: var(--accent);
  --hue-6: #f2b05e;
  --syntax-bg: var(--bg-soft);
  --syntax-fg: var(--fg);
  --syntax-gutter: var(--muted);
  --syntax-guide: var(--line);
  --syntax-selection-color: color-mix(in srgb, var(--accent) 25%, transparent);
  --syntax-inserted-bg: color-mix(in srgb, var(--cds-support-success) 16%, transparent);
  --syntax-deleted-bg: color-mix(in srgb, var(--cds-support-error) 14%, transparent);
  display: block;
  max-height: 32rem;
  overflow: auto;
}

/* The shadow tree's own <pre>/<code> carry the browser's UA-default
 * `font-family: monospace` — an explicit rule on those exact elements always
 * beats an inherited value from outside the shadow boundary, no matter what
 * the host's own font-family is set to. ::part(pre)/::part(code) target
 * those elements directly (real part names the component renders, see
 * basic-diff-view-element.js's render()), which is real author CSS and does
 * win over that UA default. */
diff-view-element::part(pre),
diff-view-element::part(code) {
  font-family: var(--mono);
  font-size: var(--cds-code-01-font-size, 0.75rem);
  line-height: var(--cds-code-01-line-height, 1.33333);
  letter-spacing: var(--cds-code-01-letter-spacing, 0.32px);
}

diff-view-element::part(table) { border-color: var(--line); }
diff-view-element::part(line) { border-color: var(--line); }
diff-view-element::part(character-diff--inserted) { background: color-mix(in srgb, var(--cds-support-success) 32%, transparent); }
diff-view-element::part(character-diff--deleted) { background: color-mix(in srgb, var(--cds-support-error) 28%, transparent); }
