/* Blocks: charts, tables and diagrams rendered from fenced code blocks.
 *
 * The three series colours are the first three slots of a palette validated
 * for colour-vision deficiency against both surfaces this app uses
 * (#ffffff and #0d1117). Three, not more: past the third slot the all-pairs
 * separation floors stop holding, and a fourth hue would be decoration bought
 * with legibility. The dark column is the same three hues re-stepped for the
 * dark surface, not an automatic flip.
 *
 * On the light surface the aqua slot sits below 3:1 against white, which the
 * palette rule allows only with relief — so every chart ships direct labels
 * where they fit and a table view always. Do not remove either. */

.nt-block {
  margin: 1.75rem 0;

  /* The data series are a palette of their own — CVD-checked, and not a
   * thing a page theme may change. Everything else the block draws reads
   * the semantic layer through a component token, so a themed page recolours
   * a chart by redefining `--nt-color-*` once, with no bridge. */
  --nt-chart-series-1: #2a78d6;
  --nt-chart-series-2: #eb6834;
  --nt-chart-series-3: #1baf7a;

  --nt-chart-ink: var(--nt-color-foreground, #24292f);
  --nt-chart-ink-muted: var(--nt-color-muted-foreground, #6b7280);
  --nt-chart-grid: var(--nt-color-border-muted, #e6e8eb);
  --nt-chart-axis: var(--nt-color-border, #c3c2b7);
  --nt-chart-surface: var(--nt-color-background, #ffffff);
  --nt-chart-surface-sunken: var(--nt-color-surface, #f6f8fa);
  --nt-chart-border: var(--nt-color-border, #d0d7de);
}

[data-theme="dark"] .nt-block,
.mark-dark .nt-block,
.content.nt-themed[data-nt-scheme="dark"] .nt-block {
  --nt-chart-series-1: #3987e5;
  --nt-chart-series-2: #d95926;
  --nt-chart-series-3: #199e70;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .nt-block {
    --nt-chart-series-1: #3987e5;
    --nt-chart-series-2: #d95926;
    --nt-chart-series-3: #199e70;
  }
}

.nt-chart-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--nt-chart-ink);
  margin: 0 0 0.75rem;
  line-height: 1.4;
}

.nt-chart-plot {
  position: relative;
}

.nt-chart-plot svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

/* Chrome recedes: the data is the only thing meant to be seen first. */
.nt-chart-gridline {
  stroke: var(--nt-chart-grid);
  stroke-width: 1;
}

.nt-chart-baseline {
  stroke: var(--nt-chart-axis);
  stroke-width: 1;
}

.nt-chart-tick,
.nt-chart-category {
  fill: var(--nt-chart-ink-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.nt-chart-category {
  font-variant-numeric: normal;
}

/* Values wear ink, never the series colour — the mark beside them already
 * carries identity, and coloured text on a light surface is where contrast
 * quietly fails. */
.nt-chart-value {
  fill: var(--nt-chart-ink);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.nt-chart-bar {
  transition: opacity 120ms ease;
}

.nt-chart-line {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* A 2px ring in the surface colour so a marker crossing a line, or two markers
 * meeting, still read as separate marks. */
.nt-chart-marker {
  stroke: var(--nt-chart-surface);
  stroke-width: 2;
  transition: opacity 120ms ease;
}

.nt-chart-bar:hover,
.nt-chart-marker:hover,
.nt-chart-bar:focus-visible,
.nt-chart-marker:focus-visible {
  opacity: 0.75;
  outline: none;
}

.nt-chart-tooltip {
  position: absolute;
  z-index: 2;
  padding: 0.375rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--nt-chart-border);
  background: var(--nt-chart-surface);
  color: var(--nt-chart-ink);
  font-size: 0.8125rem;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.12);
}

.nt-chart-tooltip[hidden] {
  display: none;
}

.nt-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
}

.nt-chart-legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8125rem;
  color: var(--nt-chart-ink-muted);
}

.nt-chart-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: none;
}

.nt-chart-table-toggle {
  margin-top: 0.75rem;
}

.nt-chart-table-toggle > summary {
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--nt-chart-ink-muted);
  user-select: none;
}

.nt-chart-table-toggle > summary:hover {
  color: var(--nt-chart-ink);
}

.nt-block-table {
  width: 100%;
  margin-top: 0.75rem;
  border-collapse: collapse;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.nt-block-table th,
.nt-block-table td {
  padding: 0.375rem 0.75rem;
  border-bottom: 1px solid var(--nt-chart-grid);
  text-align: right;
  color: var(--nt-chart-ink);
}

.nt-block-table thead th,
.nt-block-table tbody th {
  color: var(--nt-chart-ink-muted);
  font-weight: 600;
}

.nt-block-table tbody th,
.nt-block-table thead th:first-child {
  text-align: left;
}

/* Wide tables scroll inside themselves rather than pushing the page sideways. */
.nt-chart-table-toggle,
.nt-block.nt-chart > .nt-block-table {
  overflow-x: auto;
}

.nt-diagram {
  overflow-x: auto;
}

.nt-diagram svg {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

/* A block that could not render keeps its source on screen and says why. */
.nt-block-error {
  margin: 1.5rem 0 0.25rem;
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--nt-chart-series-2);
  background: var(--nt-chart-surface-sunken);
  color: var(--nt-chart-ink-muted);
  font-size: 0.8125rem;
}

@media (prefers-reduced-motion: reduce) {
  .nt-chart-bar,
  .nt-chart-marker {
    transition: none;
  }
}

/* An artifact: a whole HTML document, framed from the sandbox origin.
 * The frame is sized by its own document over postMessage, so the height here
 * is only what it starts at before the first report arrives. */
.nt-artifact {
  margin: 1.75rem 0;
}

.nt-artifact-frame {
  display: block;
  width: 100%;
  height: 480px;
  border: 1px solid var(--nt-chart-border, #d0d7de);
  border-radius: 8px;
  background: var(--nt-chart-surface, #ffffff);
  color-scheme: normal;
}

/* Heading anchors.
 *
 * Present in the delivered HTML so a shared `#section` link lands where it
 * says, but out of the way until the heading is hovered or focused — a row of
 * hashes down the left of every page is noise for the 99% of readers who never
 * want one. */
.mark-preview h1,
.mark-preview h2,
.mark-preview h3,
.mark-preview h4,
.mark-preview h5,
.mark-preview h6 {
  scroll-margin-top: 5rem;
}

.nt-anchor {
  margin-left: 0.4ch;
  color: var(--nt-chart-ink-muted, #6b7280);
  text-decoration: none;
  font-weight: 400;
  opacity: 0;
  transition: opacity 120ms ease;
}

h1:hover > .nt-anchor,
h2:hover > .nt-anchor,
h3:hover > .nt-anchor,
h4:hover > .nt-anchor,
h5:hover > .nt-anchor,
h6:hover > .nt-anchor,
.nt-anchor:focus-visible {
  opacity: 1;
}

/* Never invisible to the keyboard: opacity 0 still takes focus, so without
 * this the tab order passes through something nobody can see. */
.nt-anchor:focus-visible {
  outline: 2px solid var(--nt-chart-series-1, #2a78d6);
  outline-offset: 2px;
  border-radius: 3px;
}

.nt-anchor.nt-anchor-copied::after {
  content: attr(data-nt-copied);
  margin-left: 0.5ch;
  font-size: 0.75rem;
  color: var(--nt-chart-series-3, #1baf7a);
}

@media (prefers-reduced-motion: reduce) {
  .nt-anchor { transition: none; }
}

/* ============================================================ copy button
 * Every code block that stayed a code block gets one, added by the blocks
 * controller after the upgrades — a fence that became a chart never has one.
 *
 * Top right, over the block's own padding, so it never sits on the first
 * line of code.
 *
 * ALWAYS PRESENT, dimmed, and full on hover or keyboard focus. The first
 * version revealed it on hover and restored it for `pointer: coarse`, which
 * is the usual recipe and which I could not verify: this Chrome does not
 * emulate that media feature, so the touch branch was a claim, not a
 * measurement. One state that works for a mouse, a finger and a keyboard is
 * both simpler and checkable — measured visible at 390px and at 1280px with
 * no pointer anywhere near it. */
.nt-code {
  position: relative;
}

.nt-code-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--nt-color-border, #d0d7de);
  border-radius: calc(var(--nt-radius, 6px) / 1.5);
  background: var(--nt-color-background, #ffffff);
  color: var(--nt-color-muted-foreground, #586069);
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 120ms ease, color 120ms ease;
}

.nt-code:hover .nt-code-copy,
.nt-code-copy:hover,
.nt-code-copy:focus-visible,
.nt-code-copy.is-copied {
  opacity: 1;
}

.nt-code-copy:hover {
  color: var(--nt-color-foreground, #24292f);
  border-color: var(--nt-color-accent, #007acc);
}

.nt-code-copy.is-copied {
  color: var(--nt-color-accent, #007acc);
  border-color: var(--nt-color-accent, #007acc);
}

.nt-code-copy:focus-visible {
  outline: 2px solid var(--nt-color-accent, #007acc);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .nt-code-copy { transition: none; }
}
