/* Article figures. Loaded only on pages that contain one. Colours: the site's dark surface; the three
   series hues pass the colour-vision and 3:1 contrast checks against #0D1B2A, and every coloured mark
   also has a text label or a line style. */
.tgx-figure {
  --tgx-s1: #3987e5;
  --tgx-s2: #d95926;
  --tgx-s3: #199e70;
  --tgx-s4: #d28e05;
  --tgx-s5: #e24d8b;
  --tgx-s6: #9887ef;
  --tgx-text: #E0E1DD;
  --tgx-muted: rgba(224, 225, 221, 0.74);
  --tgx-line: rgba(224, 225, 221, 0.20);
  --tgx-focus: #00B4D8;
  margin: 28px 0;
  padding: 16px;
  border: 1px solid var(--tgx-line);
  border-radius: 10px;
  background: rgba(20, 32, 48, 0.55);
  color: var(--tgx-text);
  font-size: 0.9rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.tgx-figure [hidden] { display: none !important; }
.tgx-figure p, .article-markdown .tgx-figure p { margin: 0 0 10px; }
.tgx-figure .tgx-fig-title { font-weight: 600; font-size: 1rem; }
.tgx-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tgx-figure code, .article-markdown .tgx-figure code { font-size: 0.84em; padding: 0 3px; color: var(--tgx-text); }
.tgx-figure figcaption { margin-top: 12px; color: var(--tgx-muted); font-size: 0.82rem; }
.tgx-fig-note { display: block; margin-top: 6px; padding-left: 10px; border-left: 3px solid var(--tgx-line); }
.tgx-figure .tgx-fig-status { margin-top: 10px; padding: 8px 10px; border-radius: 6px; background: rgba(0, 180, 216, 0.08); min-height: 3.1em; }
.tgx-figure .tgx-step { margin-top: 12px; }

/* controls */
.tgx-fig-controls { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: flex-end; margin: 4px 0 14px; }
.tgx-group { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-end; }
.tgx-group-label { flex-basis: 100%; font-size: 0.75rem; color: var(--tgx-muted); }
.tgx-figure button, .tgx-figure input, .tgx-figure select { font: inherit; color: var(--tgx-text); }
.tgx-figure button, .tgx-figure select, .tgx-figure input[type="number"] {
  min-height: 34px;
  border: 1px solid rgba(224, 225, 221, 0.36);
  border-radius: 6px;
  background: #13263a;
}
.tgx-figure button { min-width: 34px; padding: 4px 11px; cursor: pointer; }
.tgx-figure button[aria-pressed="true"] { border-color: var(--tgx-focus); background: #0f4254; box-shadow: inset 0 -3px 0 var(--tgx-focus); }
.tgx-figure button:disabled, .tgx-figure input:disabled, .tgx-figure select:disabled { opacity: 0.55; cursor: default; }
.tgx-figure button:focus-visible, .tgx-figure input:focus-visible, .tgx-figure select:focus-visible,
.tgx-figure .tgx-scroll:focus-visible { outline: 2px solid var(--tgx-focus); outline-offset: 2px; }
.tgx-figure input[type="number"] { width: 6.5em; padding: 4px 6px; }
.tgx-figure td input[type="number"] { width: 4.6em; }
.tgx-figure .tgx-coord input[type="number"] { width: 4.9em; }
.tgx-figure .tgx-long input[type="number"] { width: 11em; }
.tgx-figure select { padding: 4px 6px; }
.tgx-field { display: inline-flex; flex-direction: column; gap: 2px; font-size: 0.75rem; color: var(--tgx-muted); }
.tgx-slider { display: flex; margin-top: 6px; }
.tgx-figure input[type="range"] { width: 100%; min-height: 28px; accent-color: var(--tgx-focus); }
.tgx-check { display: inline-flex; gap: 6px; align-items: center; min-height: 34px; }
.tgx-check input { width: 18px; height: 18px; accent-color: var(--tgx-focus); }
.tgx-hint { font-size: 0.8rem; color: var(--tgx-muted); }
/* Without JavaScript the figure is complete as built; controls that cannot work are not shown. */
@media (scripting: none) {
  .tgx-fig-controls, .tgx-neighbour .tgx-slider, .tgx-hint { display: none; }
}

/* tables */
.tgx-scroll { overflow-x: auto; margin: 10px 0; }
.tgx-figure table { border-collapse: collapse; width: 100%; margin: 0; font-size: 0.82rem; }
.tgx-figure caption { text-align: left; padding: 0 0 6px; color: var(--tgx-muted); font-size: 0.78rem; }
.tgx-figure th, .tgx-figure td { padding: 5px 7px; border-bottom: 1px solid var(--tgx-line); text-align: left; vertical-align: top; overflow-wrap: normal; }
.tgx-figure thead th { color: var(--tgx-muted); font-weight: 600; }
.tgx-figure tbody th { font-weight: 500; overflow-wrap: break-word; }
.tgx-figure td { font-variant-numeric: tabular-nums; }
.tgx-figure tr.is-on > th, .tgx-figure tr.is-on > td { background: rgba(0, 180, 216, 0.14); }
.tgx-figure tr.is-on > th:first-child { box-shadow: inset 3px 0 0 var(--tgx-focus); }
.tgx-rule { display: block; margin-top: 2px; font-size: 0.76rem; font-weight: 400; color: var(--tgx-muted); }
.tgx-total > * { border-top: 2px solid var(--tgx-line); }
.tgx-nowrap { white-space: nowrap; }

/* tensors, tiles, facts, bars */
.tgx-tiles { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0; }
.tgx-tile { border: 1px solid var(--tgx-line); border-radius: 8px; padding: 8px 10px; }
.tgx-tile-result { border-color: var(--tgx-focus); }
.tgx-figure .tgx-tile-title { margin: 0 0 5px; font-size: 0.76rem; color: var(--tgx-muted); }
.tgx-figure table.tgx-tensor { width: auto; font-family: var(--font-mono, monospace); }
.tgx-figure .tgx-tensor td { min-width: 2.6em; text-align: right; border: 1px solid var(--tgx-line); }
.tgx-tiles-wide .tgx-tile { flex: 1 1 220px; }
.tgx-figure .tgx-series { margin: 4px 0 2px; }
.tgx-swatch { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 2px; }
.tgx-s1 { background: var(--tgx-s1); }
.tgx-s2 { background: var(--tgx-s2); }
.tgx-s3 { background: var(--tgx-s3); }
.tgx-s4 { background: var(--tgx-s4); }
.tgx-s5 { background: var(--tgx-s5); }
.tgx-s6 { background: var(--tgx-s6); }
.tgx-bar { display: block; width: 100%; height: 8px; margin: 3px 0; }
.tgx-bar-track { fill: rgba(224, 225, 221, 0.10); }
.tgx-fill-s1 { fill: var(--tgx-s1); }
.tgx-fill-s2 { fill: var(--tgx-s2); }
.tgx-figure .tgx-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin: 10px 0 0; }
.tgx-facts div { border: 1px solid var(--tgx-line); border-radius: 8px; padding: 6px 10px; }
.tgx-facts dt { font-size: 0.74rem; color: var(--tgx-muted); }
.tgx-facts dd { margin: 0; font-weight: 600; }

/* drawings */
.tgx-svg { display: block; width: 100%; max-width: 420px; height: auto; margin: 0 auto 8px; }
.tgx-svg text { fill: var(--tgx-text); font-family: var(--font-mono, monospace); font-size: 11px; }
.tgx-edge line { stroke: rgba(224, 225, 221, 0.34); stroke-width: 1.5; }
.tgx-edge polygon { fill: rgba(224, 225, 221, 0.50); }
.tgx-edge.is-on line { stroke: var(--tgx-focus); stroke-width: 3; }
.tgx-edge.is-on polygon { fill: var(--tgx-focus); }
.tgx-node circle { fill: #13263a; stroke: rgba(224, 225, 221, 0.50); stroke-width: 1.5; }
.tgx-node.is-source circle { stroke: var(--tgx-focus); stroke-dasharray: 4 3; stroke-width: 2.5; }
.tgx-node.is-on circle { fill: #0f4254; stroke: var(--tgx-focus); stroke-dasharray: none; stroke-width: 3.5; }
.tgx-cat[data-cat="seed"] circle, .tgx-cat[data-cat="in"] circle { stroke: var(--tgx-s1); stroke-width: 4; }
.tgx-cat[data-cat="hop1"] circle { stroke: var(--tgx-s2); stroke-width: 3.5; stroke-dasharray: 7 2; }
.tgx-cat[data-cat="hop2"] circle { stroke: var(--tgx-s3); stroke-width: 3.5; stroke-dasharray: 2 2; }
.tgx-cat[data-cat="out"] circle { stroke: rgba(224, 225, 221, 0.28); stroke-width: 1; }
.tgx-key { display: inline-block; width: 12px; height: 12px; margin-right: 6px; border-radius: 50%; border: 3px solid transparent; vertical-align: -1px; }
.tgx-key[data-cat="seed"] { border-color: var(--tgx-s1); }
.tgx-key[data-cat="hop1"] { border-color: var(--tgx-s2); border-style: dashed; }
.tgx-key[data-cat="hop2"] { border-color: var(--tgx-s3); border-style: dotted; }
.tgx-box rect { fill: #13263a; stroke: rgba(224, 225, 221, 0.40); }
.tgx-box.is-on rect { fill: #0f4254; stroke: var(--tgx-focus); stroke-width: 3; }

/* flow, timeline, series, bars, iou, bbox_formats */
.tgx-svg text.tgx-small { font-size: 10px; }
.tgx-svg text.tgx-halo { paint-order: stroke; stroke: #11202f; stroke-width: 3; }
.tgx-boundary rect { fill: rgba(224, 225, 221, 0.03); stroke: var(--tgx-muted); stroke-width: 1.2; stroke-dasharray: 5 4; }
.tgx-track { fill: rgba(224, 225, 221, 0.07); }
.tgx-span rect, .tgx-span polygon { fill: var(--tgx-s3); fill-opacity: 0.45; stroke: var(--tgx-s3); stroke-width: 1.5; }
.tgx-span.tgx-visual rect, .tgx-span.tgx-visual polygon { fill: var(--tgx-s1); stroke: var(--tgx-s1); }
.tgx-span.is-on rect, .tgx-span.is-on polygon { stroke: var(--tgx-text); stroke-width: 2.5; }
.tgx-frame line { stroke: var(--tgx-text); stroke-width: 1.5; }
.tgx-frame circle { fill: var(--tgx-text); }
.tgx-frame.is-on line { stroke: var(--tgx-focus); stroke-width: 3; }
.tgx-frame.is-on circle { fill: var(--tgx-focus); }
.tgx-missed { fill: none; stroke: var(--tgx-s2); stroke-width: 1.8; stroke-dasharray: 3 2; }
.tgx-axis line { stroke: var(--tgx-line); stroke-width: 1; }
.tgx-cursor { stroke: var(--tgx-focus); stroke-width: 1.5; stroke-dasharray: 4 3; }
.tgx-threshold { stroke: var(--tgx-text); stroke-width: 1.5; stroke-dasharray: 6 4; }
.tgx-window line { stroke: var(--tgx-muted); stroke-width: 1.2; }
.tgx-line1 line { stroke: var(--tgx-s1); stroke-width: 2; }
.tgx-line2 line { stroke: var(--tgx-s2); stroke-width: 2; stroke-dasharray: 5 3; }
.tgx-pt1 circle { fill: var(--tgx-s1); }
.tgx-pt2 rect { fill: var(--tgx-s2); }
.tgx-pt1.is-on circle, .tgx-pt2.is-on rect { stroke: var(--tgx-text); stroke-width: 2; }
.tgx-figure .tgx-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.78rem; color: var(--tgx-muted); }
.tgx-figure p.tgx-barname, .article-markdown .tgx-figure p.tgx-barname { margin: 14px 0 0; }
.tgx-stack { height: 14px; }
.tgx-stack rect:not(.tgx-bar-track) { stroke: #11202f; stroke-width: 1px; vector-effect: non-scaling-stroke; }
.tgx-fill-s3 { fill: var(--tgx-s3); }
.tgx-fill-s4 { fill: var(--tgx-s4); }
.tgx-fill-s5 { fill: var(--tgx-s5); }
.tgx-fill-s6 { fill: var(--tgx-s6); }
.tgx-stack rect.is-on { opacity: 0.2; }
.tgx-stack rect.tgx-limit { fill: var(--tgx-text); stroke: none; }
.tgx-figure td.is-on { background: rgba(0, 180, 216, 0.14); }
.tgx-canvas { fill: rgba(224, 225, 221, 0.05); stroke: var(--tgx-line); stroke-width: 1; }
.tgx-boxa { fill: rgba(57, 135, 229, 0.16); stroke: var(--tgx-s1); stroke-width: 2; }
.tgx-boxb { fill: rgba(217, 89, 38, 0.10); stroke: var(--tgx-s2); stroke-width: 2; stroke-dasharray: 6 3; }
.tgx-inter { fill: var(--tgx-s3); fill-opacity: 0.6; }

/* grid: one blue ramp, dark (low) to light (high); the picked cell has a two tone outline */
.tgx-grid { shape-rendering: crispEdges; }
.tgx-v0 { fill: #142b45; background: #142b45; }
.tgx-v1 { fill: #0f4a96; background: #0f4a96; }
.tgx-v2 { fill: #1b64be; background: #1b64be; }
.tgx-v3 { fill: #257de0; background: #257de0; }
.tgx-v4 { fill: #519ced; background: #519ced; }
.tgx-v5 { fill: #84b9f3; background: #84b9f3; }
.tgx-v6 { fill: #b6d5f8; background: #b6d5f8; }
.tgx-v7 { fill: #e6f0fd; background: #e6f0fd; }
.tgx-grid rect[data-flag]:not(.is-on) { opacity: 0.22; }
.tgx-grid rect[data-cat="none"] { fill: rgba(224, 225, 221, 0.08); }
.tgx-grid rect[data-cat="a"] { fill: var(--tgx-s1); }
.tgx-grid rect[data-cat="b"] { fill: var(--tgx-s2); }
.tgx-grid rect[data-cat="both"] { fill: var(--tgx-s3); }
.tgx-grid rect.tgx-pick-edge, .tgx-grid rect.tgx-pick { fill: none; vector-effect: non-scaling-stroke; }
.tgx-pick-edge { stroke: #000; stroke-width: 4px; }
.tgx-pick { stroke: #fff; stroke-width: 2px; }
.tgx-ramp .tgx-swatch { margin: 0; border-radius: 0; width: 14px; }
.tgx-figure p.tgx-gridname, .article-markdown .tgx-figure p.tgx-gridname { margin: 12px 0 4px; font-size: 0.8rem; color: var(--tgx-muted); }
.tgx-tall { max-height: 300px; overflow: auto; }

/* patch_graph, connectivity: edges are SVG paths; a patch image is 16 grey levels */
.tgx-pix { shape-rendering: crispEdges; }
.tgx-pix rect[data-cat="0"] { fill: #000000; }
.tgx-pix rect[data-cat="1"] { fill: #111111; }
.tgx-pix rect[data-cat="2"] { fill: #222222; }
.tgx-pix rect[data-cat="3"] { fill: #333333; }
.tgx-pix rect[data-cat="4"] { fill: #444444; }
.tgx-pix rect[data-cat="5"] { fill: #555555; }
.tgx-pix rect[data-cat="6"] { fill: #666666; }
.tgx-pix rect[data-cat="7"] { fill: #777777; }
.tgx-pix rect[data-cat="8"] { fill: #888888; }
.tgx-pix rect[data-cat="9"] { fill: #999999; }
.tgx-pix rect[data-cat="10"] { fill: #aaaaaa; }
.tgx-pix rect[data-cat="11"] { fill: #bbbbbb; }
.tgx-pix rect[data-cat="12"] { fill: #cccccc; }
.tgx-pix rect[data-cat="13"] { fill: #dddddd; }
.tgx-pix rect[data-cat="14"] { fill: #eeeeee; }
.tgx-pix rect[data-cat="15"] { fill: #ffffff; }
.tgx-svg path { fill: none; stroke-linecap: round; }
.tgx-under { stroke: #0d1b2a; stroke-width: 4; }
.tgx-links { stroke: #E0E1DD; stroke-width: 1.4; }
.tgx-cuts { stroke: var(--tgx-s4); stroke-width: 1.5; stroke-dasharray: 4 3; }
.tgx-into { stroke: var(--tgx-focus); stroke-width: 3; }
.tgx-outof { stroke: var(--tgx-s2); stroke-width: 2; stroke-dasharray: 5 3; }
.tgx-svg path.tgx-head-link { fill: #E0E1DD; }
.tgx-svg path.tgx-head-into { fill: var(--tgx-focus); stroke: #0d1b2a; stroke-width: 0.8; }
.tgx-svg path.tgx-head-outof { fill: var(--tgx-s2); }
.tgx-reach { fill: none; stroke: var(--tgx-muted); stroke-width: 1; stroke-dasharray: 3 4; }
.tgx-range { flex: 1 1 200px; }

/* flatten (cells), gradient_flow (a dashed tile is frozen) */
.tgx-vector { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
.tgx-cell { display: inline-flex; flex-direction: column; align-items: center; min-width: 2.8em; padding: 2px 4px; border: 1px solid var(--tgx-line); font-variant-numeric: tabular-nums; }
.tgx-idx { font-size: 0.68rem; color: var(--tgx-muted); }
.tgx-figure .tgx-tensor td.tgx-moved { border: 2px solid var(--tgx-s2); }
.tgx-figure .tgx-tensor td.is-on, .tgx-cell.is-on { background: #0f4254; box-shadow: inset 0 0 0 2px var(--tgx-focus); }
.tgx-figure .tgx-tensor td.is-source, .tgx-cell.is-source { outline: 2px dashed var(--tgx-focus); outline-offset: -3px; }
.tgx-tile.is-on { border: 2px dashed var(--tgx-muted); }

@media (prefers-reduced-motion: no-preference) {
  .tgx-edge line, .tgx-node circle, .tgx-box rect { transition: stroke 140ms, stroke-width 140ms, fill 140ms; }
  .tgx-bar rect { transition: width 180ms ease-out; }
}
@media (max-width: 600px) {
  .tgx-figure { padding: 12px 10px; margin-left: -6px; margin-right: -6px; }
  .tgx-figure th, .tgx-figure td { padding: 5px 4px; font-size: 0.78rem; }
}
@media print {
  .tgx-fig-controls, .tgx-fig-status { display: none; }
}
