/* The route graph page (routes/graph.md), drawn by javascripts/route-graph.js.
 *
 * Three palettes, each run through a validator against both of Material's
 * surfaces (white, and slate at hsl(232 15% 14%) = #1e2129):
 *
 * - Archives, on nodes: five categorical hues in column order -- GEO orange,
 *   NCBI blue, EBI green, DDBJ violet, ArrayExpress amber -- so every pair of
 *   neighbouring columns passes the validator in both modes (worst adjacent
 *   colour-blind dE 24.7 light, 26.8 dark; worst normal-vision dE 27.5). They
 *   do NOT pass on every pair: NCBI blue and DDBJ violet are dE 1.9 apart to a
 *   protan reader, GEO orange and EBI green 3.2. Colour is therefore never the
 *   only channel: each archive is a column, and every label names its archive
 *   ("SRA run", "ENA run", "DRA run"). Amber is 2.17:1 on white, so its nodes
 *   carry their name inside them -- the relief the validator requires.
 *   Records all three INSDC archives hold, and read formats no archive owns,
 *   are neutral.
 * - Resolved share, on measured route lines and matrix cells: a five-step
 *   neutral ink ramp, so it cannot be read as the blue of an INSDC node.
 *   Ordinal checks pass in both modes: lightness monotone, every step gap at
 *   least 0.06, one hue, and the faintest step at 2.25:1 on white and 2.40:1
 *   on slate. In dark mode the ramp runs the other way -- a higher share is
 *   always the higher contrast.
 * - Outcomes, on the bars in panels: resolved is ink, empty is pale, failed is
 *   red (worst colour-blind dE 13.3 light, 20.3 dark). Empty is meant to be
 *   faint -- the archive answered and holds nothing -- and every value it
 *   carries is also in the panel and the table.
 *
 * A surveyed link is not on the ramp either: a hollow solid line -- a stroke
 * with a surface-coloured core -- of one width, in a cool grey (--rg-surveyed,
 * 5.5:1 on white, 6.8:1 on slate) that sits apart from the ramp's warm greys
 * and is far too desaturated to read as NCBI blue. It carries counts and no
 * rank, so it takes neither the ramp's ink nor a route's width.
 *
 * An untested link is not on the ramp at all: it is a thin dotted line with a
 * hollow arrowhead, because it carries no quantity to encode.
 */

.rg-root {
  --rg-surface: var(--md-default-bg-color);
  --rg-region: rgba(11, 11, 11, 0.035);
  --rg-hairline: rgba(11, 11, 11, 0.12);
  --rg-ink: var(--md-default-fg-color);
  --rg-ink-2: var(--md-default-fg-color--light);
  --rg-accent: var(--md-accent-fg-color);

  --rg-geo: #eb6834;
  --rg-ncbi: #2a78d6;
  --rg-ebi: #008300;
  --rg-ddbj: #6250d6;
  --rg-arrayexpress: #eda100;
  --rg-shared: #6f6e69;
  --rg-file: #898781;
  --rg-neutral: #6f6e69;

  --rg-resolved: #3d3c39;
  --rg-empty: #c4c3bb;
  --rg-failed: #d03b3b;

  --rg-ramp-0: #aeada5;
  --rg-ramp-1: #8c8b84;
  --rg-ramp-2: #6c6b65;
  --rg-ramp-3: #4b4a46;
  --rg-ramp-4: #262523;
  --rg-untested: #7a7973;
  --rg-surveyed: #5f6b75;

  --rg-row: rgba(11, 11, 11, 0.07);

  margin: 1rem 0 2rem;
}

[data-md-color-scheme="slate"] .rg-root {
  --rg-region: rgba(255, 255, 255, 0.04);
  --rg-hairline: rgba(255, 255, 255, 0.12);

  --rg-geo: #d95926;
  --rg-ncbi: #3987e5;
  --rg-ebi: #008300;
  --rg-ddbj: #9085e9;
  --rg-arrayexpress: #c98500;
  --rg-shared: #a9a89f;
  --rg-neutral: #a9a89f;

  --rg-resolved: #d9d8d2;
  --rg-empty: #46464c;
  --rg-failed: #e66767;

  --rg-ramp-0: #5d5c57;
  --rg-ramp-1: #7d7c76;
  --rg-ramp-2: #9e9d96;
  --rg-ramp-3: #c1c0b9;
  --rg-ramp-4: #e6e5de;
  --rg-untested: #8f8e88;
  --rg-surveyed: #9eaab4;

  --rg-row: rgba(255, 255, 255, 0.07);
}

/* This page is the graph, so it takes the width the navigation would have. */
.md-main__inner:has(.rg-root) {
  max-width: 120rem;
}

/* --------------------------------------------------------------- controls */

.rg-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1.4rem;
  margin-bottom: 0.8rem;
  font-size: 0.7rem;
}

.rg-path-finder {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.rg-path-finder label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
}

.rg-control-label {
  color: var(--rg-ink-2);
  font-weight: 700;
}

.rg-controls > label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
}

.rg-controls select,
.rg-button {
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--rg-hairline);
  border-radius: 0.25rem;
  background: var(--rg-surface);
  color: var(--rg-ink);
  font: inherit;
  cursor: pointer;
}

.rg-button:hover,
.rg-button:focus-visible,
.rg-controls select:hover {
  border-color: var(--rg-accent);
}

/* A plain dropdown. Material styles every <details> in content as a
 * collapsible admonition -- border, icon, chevron -- so all of that is undone. */
.md-typeset details.rg-dropdown {
  position: relative;
  display: inline-block;
  margin: 0;
  padding: 0;
  overflow: visible;
  border: 0;
  background: none;
  box-shadow: none;
  font-size: inherit;
}

.md-typeset details.rg-dropdown > summary {
  min-height: 0;
  margin: 0;
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--rg-hairline);
  border-radius: 0.25rem;
  background: var(--rg-surface);
  color: var(--rg-ink);
  font-weight: 400;
  list-style: none;
  cursor: pointer;
}

.md-typeset details.rg-dropdown > summary::-webkit-details-marker {
  display: none;
}

.md-typeset details.rg-dropdown > summary::before {
  display: none;
}

.md-typeset details.rg-dropdown > summary::after {
  position: static;
  display: inline;
  width: auto;
  height: auto;
  margin: 0;
  background: none;
  content: " \25BE";
  transform: none;
  -webkit-mask-image: none;
  mask-image: none;
}

.rg-dropdown-body {
  position: absolute;
  z-index: 5;
  display: grid;
  gap: 0.3rem;
  margin-top: 0.3rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--rg-hairline);
  border-radius: 0.3rem;
  background: var(--rg-surface);
  box-shadow: var(--md-shadow-z2);
  white-space: nowrap;
}

.rg-dropdown-body label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

/* ------------------------------------------------------------------ stage */

.rg-stage {
  position: relative;
  height: clamp(34rem, 86vh, 64rem);
  min-height: 30rem;
  max-height: 86vh;
  overflow: hidden;
  border: 1px solid var(--rg-hairline);
  border-radius: 0.4rem;
  background: var(--rg-surface);
}

/* Scoped under .md-typeset to outrank Material's `.md-typeset svg { height:
 * auto }`, which otherwise collapses the canvas to the 150px SVG default. */
.md-typeset .rg-svg {
  display: block;
  max-width: none;
  width: 100%;
  height: 100%;
  cursor: grab;
  /* Panning and pinching are the script's (bindViewport), so a drag over the
   * graph moves the graph, not the page. */
  touch-action: none;
  user-select: none;
}

.md-typeset .rg-svg.is-panning {
  cursor: grabbing;
}

.rg-zoom {
  position: absolute;
  right: 0.7rem;
  bottom: 0.7rem;
  display: flex;
  gap: 0.3rem;
  font-size: 0.75rem;
}

.rg-zoom .rg-button {
  min-width: 2rem;
  box-shadow: var(--md-shadow-z1);
}

.rg-hint {
  position: absolute;
  bottom: 0.7rem;
  left: 0.9rem;
  margin: 0;
  color: var(--rg-ink-2);
  font-size: 0.6rem;
  pointer-events: none;
}

/* Layer rows. */
.rg-row-rule {
  stroke: var(--rg-row);
  stroke-width: 1;
}

.rg-row-label {
  fill: var(--rg-ink-2);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

/* -------------------------------------------------------------- the nodes */

.rg-family-geo { --rg-fam: var(--rg-geo); }
.rg-family-ncbi { --rg-fam: var(--rg-ncbi); }
.rg-family-ebi { --rg-fam: var(--rg-ebi); }
.rg-family-ddbj { --rg-fam: var(--rg-ddbj); }
.rg-family-arrayexpress { --rg-fam: var(--rg-arrayexpress); }
.rg-family-shared { --rg-fam: var(--rg-shared); }
.rg-family-file { --rg-fam: var(--rg-file); }
.rg-family-neutral { --rg-fam: var(--rg-neutral); }

.rg-node {
  cursor: pointer;
  transition: opacity 0.15s;
}

.rg-node-body {
  fill: color-mix(in srgb, var(--rg-fam) 16%, var(--rg-surface));
  stroke: var(--rg-fam);
  stroke-width: 2;
  stroke-linejoin: round;
}

/* The sheets behind a dataset: the same colour, quieter. */
.rg-node-back {
  fill: color-mix(in srgb, var(--rg-fam) 8%, var(--rg-surface));
  stroke: color-mix(in srgb, var(--rg-fam) 60%, var(--rg-surface));
  stroke-width: 1.5;
}

.rg-node-fold {
  fill: none;
  stroke: var(--rg-fam);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.rg-node-label {
  fill: var(--rg-ink);
  font-size: 15px;
  font-weight: 600;
  pointer-events: none;
}

/* How an identifier of the node is spelt: SRR, PRJ*, E-XXXX-n. */
.rg-node-prefix {
  fill: var(--rg-ink-2);
  font-family: var(--md-code-font-family, monospace);
  font-size: 11.5px;
  pointer-events: none;
}

/* The archive columns: a name over each, a hairline between them. The name
 * is in ink, with the archive's colour as an underline-weight rule, so the
 * text stays legible whatever the hue. */
.rg-column-label {
  fill: var(--rg-ink);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-decoration: underline;
  text-decoration-color: var(--rg-fam);
  text-decoration-thickness: 3px;
  text-underline-offset: 6px;
}

.rg-column-rule {
  stroke: var(--rg-row);
  stroke-width: 1;
  stroke-dasharray: 2 6;
}

.rg-node:focus-visible {
  outline: none;
}

.rg-node:focus-visible .rg-node-body,
.rg-node.is-focus .rg-node-body {
  stroke-width: 3.5;
}

/* -------------------------------------------------------------- the lines */

.rg-lane,
.rg-lane-label {
  cursor: pointer;
  transition: opacity 0.15s;
}

.rg-line {
  fill: none;
  stroke-linecap: butt;
}

/* A measured route: the ramp step for its resolved share. */
.rg-share-0 { --rg-step: var(--rg-ramp-0); }
.rg-share-1 { --rg-step: var(--rg-ramp-1); }
.rg-share-2 { --rg-step: var(--rg-ramp-2); }
.rg-share-3 { --rg-step: var(--rg-ramp-3); }
.rg-share-4 { --rg-step: var(--rg-ramp-4); }

.rg-line--share { stroke: var(--rg-step); }

/* Resolved or empty, never separated: dark ink, hatched -- the same texture as
 * the bars, so it cannot be read as a step of the ramp. */
.rg-line--unknown { stroke: url(#rg-hatch); }
.rg-hatch-ink { fill: var(--rg-ramp-3); }

/* An untested link: dots, thin, neutral. Round caps on near-zero dashes make
 * them dots at any width. */
.rg-line--untested {
  stroke: var(--rg-untested);
  stroke-dasharray: 0.1 4.6;
  stroke-linecap: round;
}

/* A surveyed link: a solid stroke with a surface-coloured core down it, one
 * width throughout -- solid because a survey counted it, hollow because what
 * it counted is not drawn to the routes' scale. */
.rg-line--surveyed {
  stroke: var(--rg-surveyed);
  stroke-linecap: round;
}

.rg-line-core {
  fill: none;
  stroke: var(--rg-surface);
  stroke-linecap: round;
  pointer-events: none;
}

.rg-arrow { fill: var(--rg-ink-2); }
.rg-arrow.rg-line--share { fill: var(--rg-step); stroke: none; }
.rg-arrow.rg-line--unknown { fill: var(--rg-ramp-3); stroke: none; }

.rg-arrow--hollow {
  fill: var(--rg-surface);
  stroke: var(--rg-untested);
  stroke-width: 1.3;
  stroke-linejoin: round;
}

.rg-arrow--hollow.rg-arrow--surveyed {
  stroke: var(--rg-surveyed);
  stroke-width: 1.6;
}

.rg-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 16;
}

.rg-lane-label {
  fill: var(--rg-ink-2);
  font-family: var(--md-code-font-family);
  font-size: 12px;
  paint-order: stroke;
  stroke: var(--rg-surface);
  stroke-width: 4px;
  stroke-linejoin: round;
}

/* Dots running source to target along a focused route. */
.rg-flow {
  display: none;
  fill: none;
  stroke: var(--rg-surface);
  stroke-dasharray: 1.5 12;
  stroke-linecap: round;
  pointer-events: none;
}

.rg-lane.is-focus .rg-flow {
  display: inline;
  animation: rg-flow 0.9s linear infinite;
}

@keyframes rg-flow {
  from { stroke-dashoffset: 13.5; }
  to { stroke-dashoffset: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .rg-lane.is-focus .rg-flow {
    animation: none;
  }
}

.rg-lane.is-hidden,
.rg-lane-label.is-hidden {
  display: none;
}

/* Hover lifts one route (or a node's routes) out of the rest; a selection or
 * a path does the same, harder, until it is cleared. */
.rg-svg.has-hover .rg-lane:not(.is-hover),
.rg-svg.has-hover .rg-lane-label:not(.is-hover),
.rg-svg.has-hover .rg-node:not(.is-hover) {
  opacity: 0.25;
}

.rg-svg.has-focus .rg-lane:not(.is-focus):not(.is-hover),
.rg-svg.has-focus .rg-lane-label:not(.is-focus):not(.is-hover),
.rg-svg.has-focus .rg-node:not(.is-focus):not(.is-hover) {
  opacity: 0.1;
}

.rg-lane-label.is-focus,
.rg-lane-label.is-hover {
  fill: var(--rg-ink);
  font-weight: 700;
}

/* An untested lane's mechanisms: smaller and quieter than a route's name, and
 * shown only when zoomed in far enough to read, or for the lane in hand. */
.rg-lane-label--untested {
  display: none;
  font-size: 10.5px;
  fill: var(--rg-untested);
}

.rg-svg.is-detailed .rg-lane-label--untested,
.rg-svg .rg-lane-label--untested.is-focus,
.rg-svg .rg-lane-label--untested.is-hover {
  display: inline;
}

.rg-svg .rg-lane-label--untested.is-hidden {
  display: none;
}

/* A surveyed lane's mechanisms: named on the same terms as an untested
 * lane's, in the surveyed grey. */
.rg-lane-label--surveyed {
  display: none;
  font-size: 11px;
  fill: var(--rg-surveyed);
}

.rg-svg.is-detailed .rg-lane-label--surveyed,
.rg-svg .rg-lane-label--surveyed.is-focus,
.rg-svg .rg-lane-label--surveyed.is-hover {
  display: inline;
}

.rg-svg .rg-lane-label--surveyed.is-hidden {
  display: none;
}

.rg-lane--surveyed.is-focus .rg-line--surveyed,
.rg-lane--surveyed.is-hover .rg-line--surveyed,
.rg-lane--surveyed.is-focus .rg-arrow--surveyed,
.rg-lane--surveyed.is-hover .rg-arrow--surveyed {
  stroke: var(--rg-ink);
}

/* Nothing flows along a surveyed lane: its core is already the surface, and
 * it is a link that answers, not a quantity drawn to scale. */
.rg-lane--surveyed .rg-flow {
  display: none !important;
}

/* A focused untested lane is dotted still, and darker. */
.rg-lane--untested.is-focus .rg-line--untested,
.rg-lane--untested.is-hover .rg-line--untested {
  stroke: var(--rg-ink);
}

.rg-lane--untested .rg-flow {
  display: none !important;
}

/* ------------------------------------------------------------------ panel */

.rg-panel {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  z-index: 4;
  width: min(24rem, calc(100% - 1.4rem));
  max-height: calc(100% - 4.2rem);
  overflow-y: auto;
  padding: 0.9rem 1rem;
  border: 1px solid var(--rg-hairline);
  border-radius: 0.4rem;
  background: var(--rg-surface);
  box-shadow: var(--md-shadow-z3);
  font-size: 0.7rem;
}

.rg-panel[hidden] {
  display: none;
}

.rg-panel-close {
  float: right;
  margin: -0.4rem -0.5rem 0 0.5rem;
  padding: 0 0.4rem;
  border: 0;
  background: none;
  color: var(--rg-ink-2);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.rg-panel-close:hover {
  color: var(--rg-ink);
}

.md-typeset .rg-panel-kicker {
  margin: 0 0 0.2rem;
  color: var(--rg-ink-2);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.md-typeset .rg-panel h3 {
  margin: 0 0 0.4rem;
  font-size: 0.9rem;
}

.md-typeset .rg-panel h4 {
  margin: 1rem 0 0.3rem;
  color: var(--rg-ink-2);
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.md-typeset .rg-panel p {
  margin: 0.35rem 0;
}

.rg-panel dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.2rem 0.8rem;
  margin: 0.6rem 0;
}

.rg-panel dt {
  color: var(--rg-ink-2);
}

.rg-panel dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.rg-panel ul {
  margin: 0.2rem 0;
  padding: 0;
  list-style: none;
}

.md-typeset .rg-panel ul li {
  margin: 0.3rem 0 0;
}

.rg-muted {
  color: var(--rg-ink-2);
}

.rg-badge {
  display: inline-block;
  margin: 0.2rem 0.3rem 0 0;
  padding: 0 0.4rem;
  border: 1px solid var(--rg-hairline);
  border-radius: 0.6rem;
  color: var(--rg-ink-2);
  font-size: 0.6rem;
}

/* A route or path offered as something to click, in the panel. */
.rg-item {
  display: block;
  width: 100%;
  margin: 0.2rem 0;
  padding: 0.35rem 0.45rem;
  border: 1px solid transparent;
  border-radius: 0.25rem;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.rg-item:hover,
.rg-item:focus-visible {
  border-color: var(--rg-hairline);
  background: var(--rg-region);
}

.rg-item[aria-pressed="true"] {
  border-color: var(--rg-accent);
}

.rg-item code {
  font-size: 0.65rem;
}

.rg-item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem 0.4rem;
  margin-top: 0.2rem;
  color: var(--rg-ink-2);
}

/* Outcome counts: the value leads, the name follows. */
.rg-counts {
  display: grid;
  grid-template-columns: repeat(3, auto);
  justify-content: start;
  gap: 0.1rem 1.2rem;
  margin: 0.6rem 0 0.3rem;
}

.rg-count strong {
  display: block;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.rg-count span {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--rg-ink-2);
}

/* ------------------------------------------------------------------- bars */

/* Segments are separated by a 2px surface gap rather than a stroke; the data
 * end is rounded and the baseline square. */
.rg-bar {
  display: flex;
  gap: 2px;
  width: 100%;
  height: 0.55rem;
  margin: 0.3rem 0;
}

.rg-bar--mini {
  flex: none;
  width: 6rem;
  height: 0.45rem;
  margin: 0;
}

.rg-seg {
  min-width: 2px;
}

.rg-seg:last-child {
  border-radius: 0 4px 4px 0;
}

.rg-seg--resolved,
.rg-swatch--resolved {
  background: var(--rg-resolved);
}

.rg-seg--empty,
.rg-swatch--empty {
  background: var(--rg-empty);
}

.rg-seg--failed,
.rg-swatch--failed {
  background: var(--rg-failed);
}

.rg-seg--unknown,
.rg-swatch--unknown {
  background: repeating-linear-gradient(45deg, var(--rg-resolved) 0 2px, transparent 2px 5px);
  box-shadow: inset 0 0 0 1px var(--rg-resolved);
}

.rg-swatch {
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 2px;
}

.rg-swatch.rg-family-geo,
.rg-swatch.rg-family-ncbi,
.rg-swatch.rg-family-ebi,
.rg-swatch.rg-family-ddbj,
.rg-swatch.rg-family-arrayexpress,
.rg-swatch.rg-family-shared,
.rg-swatch.rg-family-file {
  width: 0.75rem;
  height: 0.75rem;
  border: 2px solid var(--rg-fam);
  border-radius: 50%;
  background: color-mix(in srgb, var(--rg-fam) 16%, var(--rg-surface));
}

/* ----------------------------------------------------------------- legend */

.rg-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 2rem;
  margin: 0.8rem 0 0;
  color: var(--rg-ink-2);
  font-size: 0.65rem;
}

.rg-legend-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.9rem;
}

.rg-legend-title {
  color: var(--rg-ink);
  font-weight: 700;
}

.rg-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.md-typeset .rg-legend-shape {
  width: 2rem;
  height: 1.4rem;
  overflow: visible;
}

.rg-legend-shape .rg-node {
  cursor: default;
}

.rg-legend-shape .rg-node-body {
  stroke-width: 1.5;
}

.md-typeset .rg-legend-line {
  width: 1.6rem;
  height: 0.5rem;
}

/* ---------------------------------------------------------------- tooltip */

/* One, following the pointer, never the only place a value lives. */
.rg-tooltip {
  position: fixed;
  z-index: 10;
  max-width: 21rem;
  margin: 0;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--rg-hairline);
  border-radius: 0.3rem;
  background: var(--rg-surface);
  box-shadow: var(--md-shadow-z2);
  color: var(--rg-ink);
  font-size: 0.65rem;
  pointer-events: none;
}

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

.rg-tooltip-title {
  color: var(--rg-ink-2);
  font-family: var(--md-code-font-family);
}

.rg-tooltip-values {
  margin: 0.15rem 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ table */

/* The same data, readable without the picture. Material styles only
 * class-less tables, so this one carries its own. */
.rg-table-wrap {
  overflow-x: auto;
  margin-top: 1.6rem;
}

.md-typeset .rg-table {
  display: table;
  width: 100%;
  border-collapse: collapse;
  font-size: 0.65rem;
}

.md-typeset .rg-table th,
.md-typeset .rg-table td {
  padding: 0.45em 0.7em;
  border-bottom: 1px solid var(--rg-hairline);
  vertical-align: middle;
}

.md-typeset .rg-table th {
  color: var(--rg-ink-2);
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
}

.md-typeset .rg-table th button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.md-typeset .rg-table th[aria-sort="ascending"] button::after {
  content: " \2191";
}

.md-typeset .rg-table th[aria-sort="descending"] button::after {
  content: " \2193";
}

.md-typeset .rg-table tbody tr:hover td {
  background: var(--rg-region);
}

.md-typeset .rg-table td.rg-num,
.md-typeset .rg-table th.rg-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.md-typeset .rg-table td.rg-nowrap {
  white-space: nowrap;
}

.md-typeset .rg-table td.rg-corpus {
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.md-typeset .rg-table tr.rg-row--selected td {
  background: var(--rg-region);
}

.md-typeset .rg-table tr.rg-row--selected td:first-child {
  box-shadow: inset 3px 0 0 var(--rg-accent);
}

.rg-route-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--md-typeset-a-color);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.rg-route-button code {
  font-size: inherit;
  white-space: nowrap;
}

.rg-loading,
.rg-error {
  padding: 1rem;
  color: var(--rg-ink-2);
}

@media screen and (max-width: 60em) {
  .rg-stage {
    height: 70vh;
  }

  .rg-hint {
    display: none;
  }
}

/* ------------------------------------------------------------ view toggle */

.rg-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.rg-segmented {
  display: inline-flex;
  margin: 0;
  padding: 0;
  border: 1px solid var(--rg-hairline);
  border-radius: 0.3rem;
  overflow: hidden;
}

.rg-segmented label {
  position: relative;
  cursor: pointer;
}

.rg-segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.rg-segmented span {
  display: inline-block;
  padding: 0.25rem 0.7rem;
  color: var(--rg-ink-2);
}

.rg-segmented label + label span {
  border-left: 1px solid var(--rg-hairline);
}

.rg-segmented input:checked + span {
  background: var(--rg-region);
  color: var(--rg-ink);
  font-weight: 700;
  box-shadow: inset 0 -2px 0 var(--rg-accent);
}

.rg-segmented input:focus-visible + span {
  outline: 2px solid var(--rg-accent);
  outline-offset: -2px;
}

/* Three views do not fit a phone's width on one line: the control takes the
 * row and shares it, and a long name wraps inside its own segment. */
@media screen and (max-width: 30em) {
  .rg-segmented {
    display: flex;
    width: 100%;
  }

  .rg-segmented label {
    display: flex;
    flex: 1 1 0;
  }

  .rg-segmented span {
    flex: 1 1 auto;
    padding: 0.25rem 0.4rem;
    text-align: center;
  }
}

/* ---------------------------------------------------------- panel pieces */

.rg-chip {
  display: inline-block;
  padding: 0 0.35rem;
  border-radius: 0.5rem;
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.rg-chip--measured {
  background: var(--rg-ramp-3);
  color: var(--rg-surface);
}

.rg-chip--untested {
  border: 1px dotted var(--rg-untested);
  color: var(--rg-ink-2);
}

.rg-chip--surveyed {
  border: 1px solid var(--rg-surveyed);
  background: color-mix(in srgb, var(--rg-surveyed) 14%, var(--rg-surface));
  color: var(--rg-ink);
}

/* A surveyed link's splits in a panel: one block per corpus. */
.rg-survey {
  display: grid;
  gap: 0.35rem;
  margin: 0.3rem 0;
  padding-left: 0.5rem;
  border-left: 2px solid var(--rg-surveyed);
}

.md-typeset .rg-survey p {
  margin: 0.1rem 0;
}

.rg-survey .rg-bar {
  margin: 0.15rem 0;
}

/* A surveyed row's outcome bars in the table, one per split, each with its
 * usable count beside it. */
.rg-survey-cell {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.md-typeset dl.rg-node-counts {
  margin: 0.3rem 0;
}

.rg-panel ul.rg-mechanisms {
  display: grid;
  gap: 0.6rem;
}

.md-typeset .rg-panel ul.rg-mechanisms li.rg-mechanism {
  margin: 0;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--rg-hairline);
  border-radius: 0.3rem;
}

.rg-mechanism > div + div {
  margin-top: 0.15rem;
}

.rg-endpoint code {
  font-size: 0.6rem;
  overflow-wrap: anywhere;
}

.md-typeset .rg-panel p.rg-probe {
  margin: 0.3rem 0 0;
}

.rg-probe code {
  font-size: 0.6rem;
}

.rg-tooltip-list {
  margin: 0.3rem 0 0;
  padding-left: 1rem;
}

/* ----------------------------------------------------------------- matrix */

.rg-matrix-section {
  margin-top: 1.8rem;
}

.md-typeset .rg-matrix-title {
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
}

.rg-matrix-legend {
  margin: 0 0 0.6rem;
}

.rg-matrix-wrap {
  overflow-x: auto;
}

.md-typeset .rg-matrix {
  display: table;
  border-collapse: separate;
  border-spacing: 2px;
  font-size: 0.6rem;
}

.md-typeset .rg-matrix th,
.md-typeset .rg-matrix td {
  padding: 0;
  border: 0;
  background: none;
}

.md-typeset .rg-matrix th {
  color: var(--rg-ink-2);
  font-weight: 600;
}

.md-typeset .rg-matrix th.rg-matrix-row {
  padding-right: 0.5rem;
  text-align: right;
  white-space: nowrap;
}

.md-typeset .rg-matrix th.rg-matrix-col {
  height: 9.5rem;
  vertical-align: bottom;
}

.rg-matrix-col span {
  display: inline-block;
  padding-bottom: 0.3rem;
  white-space: nowrap;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

.rg-matrix-corner span {
  color: var(--rg-ink-2);
  font-weight: 400;
}

.md-typeset .rg-matrix td.rg-cell {
  width: 1.15rem;
  height: 1.15rem;
  text-align: center;
  vertical-align: middle;
}

.md-typeset .rg-matrix td.rg-cell--self {
  background: var(--rg-region);
}

.rg-cell-mark {
  display: block;
  width: 1.05rem;
  height: 1.05rem;
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: none;
  cursor: pointer;
}

.rg-cell-key {
  display: inline-block;
  cursor: default;
}

.rg-cell-key--blank {
  width: 1.05rem;
  height: 1.05rem;
  border: 1px solid var(--rg-row);
  border-radius: 3px;
}

.rg-cell--share-0 { background: var(--rg-ramp-0); }
.rg-cell--share-1 { background: var(--rg-ramp-1); }
.rg-cell--share-2 { background: var(--rg-ramp-2); }
.rg-cell--share-3 { background: var(--rg-ramp-3); }
.rg-cell--share-4 { background: var(--rg-ramp-4); }

.rg-cell--unknown {
  background: repeating-linear-gradient(45deg, var(--rg-ramp-3) 0 2px, transparent 2px 5px);
  box-shadow: inset 0 0 0 1px var(--rg-ramp-3);
}

.rg-cell--untested {
  box-shadow: inset 0 0 0 1.5px var(--rg-untested);
}

/* Surveyed, no route: a ring with a tinted centre, the matrix's own form of
 * the hollow solid line. */
.rg-cell--surveyed {
  box-shadow:
    inset 0 0 0 2px var(--rg-surveyed),
    inset 0 0 0 3.5px var(--rg-surface);
  background: color-mix(in srgb, var(--rg-surveyed) 45%, var(--rg-surface));
}

/* A link survey answered and found nothing usable: struck through, like a
 * route's measured absence, in the surveyed grey. */
.rg-cell--none-surveyed {
  border: 1.5px solid var(--rg-surveyed);
  background: linear-gradient(
    to top right,
    transparent calc(50% - 0.75px),
    var(--rg-surveyed) calc(50% - 0.75px),
    var(--rg-surveyed) calc(50% + 0.75px),
    transparent calc(50% + 0.75px)
  );
  opacity: 0.7;
}

.rg-cell--unconfirmed {
  border: 1.5px dashed var(--rg-untested);
  opacity: 0.55;
}

/* Measured, and nothing ever reached the target: a struck-through outline. */
.rg-cell--none-measured {
  border: 1.5px solid var(--rg-untested);
  background: linear-gradient(
    to top right,
    transparent calc(50% - 0.75px),
    var(--rg-untested) calc(50% - 0.75px),
    var(--rg-untested) calc(50% + 0.75px),
    transparent calc(50% + 0.75px)
  );
  opacity: 0.7;
}

/* What a probe checked a found file or document for. Pass, fail and
 * undetermined each carry a glyph as well as a colour. */
.rg-checks {
  margin: 0.2rem 0 0.3rem;
  padding: 0;
  list-style: none;
}

.md-typeset .rg-checks li {
  margin: 0;
}

.rg-check-mark {
  display: inline-block;
  width: 1.1em;
  font-weight: 700;
}

.rg-check--passed .rg-check-mark {
  color: var(--rg-ink);
}

.rg-check--failed .rg-check-mark {
  color: var(--rg-failed);
}

.rg-check--undetermined .rg-check-mark {
  color: var(--rg-ink-2);
}

/* Row and column heads in the matrix carry their archive as a left rule. */
.rg-matrix-row[class*="rg-family-"] {
  box-shadow: inset 3px 0 0 var(--rg-fam);
}

.rg-cell-mark:hover,
.rg-cell-mark:focus-visible {
  outline: 2px solid var(--rg-accent);
  outline-offset: 1px;
}

.rg-cell-mark.is-selected {
  outline: 2px solid var(--rg-accent);
  outline-offset: 1px;
}

.md-typeset .rg-matrix th.rg-matrix-col[class*="rg-family-"] {
  box-shadow: inset 0 -3px 0 var(--rg-fam);
}
