/* The charts in "CI now" (views/infrastructure-charts.js, infrastructure-charts.logic.js).
 *
 * PALETTE. Runner hosts take the fixed categorical slots 1 to 7 (HOST_SLOT in the logic), a host the
 * page does not know, a paused or an offline runner slot 0 (grey). Light and dark are each their own
 * steps of the same seven hues, checked with the colour-blind and contrast validator against this
 * page's surfaces (#ffffff light, #241f33 dark) on 2026-10-27: every adjacent pair passes in both.
 * The heavy and light job tags are one hue in two steps (an ordered pair, checked the same way), so
 * they never look like a runner. Status colours (normal, long, very long, past its usual length,
 * stuck) are fixed and always come with an icon and a word. Text is never drawn in a series colour.
 * Data-viz colours are outside the cross-project theme sync (firebase-changelog-service/CLAUDE.md). */

.infra-root {
  --ic-1: #3987e5; --ic-2: #d95926; --ic-3: #199e70; --ic-4: #c98500; --ic-5: #d55181; --ic-6: #008300; --ic-7: #9085e9;
  --ic-0: #6b7280;
  --ic-heavy: #a5b4fc; --ic-heavy-ink: #0b0b0b;
  --ic-light: #6366c9; --ic-light-ink: #ffffff;
  --ic-untagged: #6b7280; --ic-untagged-ink: #ffffff;
  --ic-other: #4b5563; --ic-other-ink: #ffffff;
  --ic-ink: #c3c2b7;
  --ic-ghost: #898781;
  --ic-free-mix: 22%;
  --ic-good: #0ca30c; --ic-warn: #fab219; --ic-bad: #d03b3b;
}
html[data-theme="light"] .infra-root {
  --ic-1: #2a78d6; --ic-2: #eb6834; --ic-3: #1baf7a; --ic-4: #eda100; --ic-5: #e87ba4; --ic-6: #008300; --ic-7: #6250d6;
  --ic-0: #9ca3af;
  --ic-heavy: #4338ca; --ic-heavy-ink: #ffffff;
  --ic-light: #8b93f0; --ic-light-ink: #0b0b0b;
  --ic-untagged: #9ca3af; --ic-untagged-ink: #0b0b0b;
  --ic-other: #d1d5db; --ic-other-ink: #0b0b0b;
  --ic-ink: #52514e;
  --ic-ghost: #898781;
  --ic-free-mix: 18%;
}
.is-slot-0 { --ic-c: var(--ic-0); }
.is-slot-1 { --ic-c: var(--ic-1); }
.is-slot-2 { --ic-c: var(--ic-2); }
.is-slot-3 { --ic-c: var(--ic-3); }
.is-slot-4 { --ic-c: var(--ic-4); }
.is-slot-5 { --ic-c: var(--ic-5); }
.is-slot-6 { --ic-c: var(--ic-6); }
.is-slot-7 { --ic-c: var(--ic-7); }

/* ── Layout: cards in one column on a phone, two side by side when there is room ── */

.ic-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin: 4px 0 12px; }
@media (min-width: 900px) { .ic-grid { grid-template-columns: 1fr 1fr; align-items: start; } }
.ic-col { display: grid; gap: 12px; min-width: 0; }
.ic-card { min-width: 0; padding: 12px; background: var(--lf-panel); border: 1px solid var(--lf-border); border-radius: var(--radius-sm, 8px); }
.ic-title { margin: 0 0 6px; font-size: 15px; font-weight: 700; }
.ic-title-sub { margin-left: 6px; color: var(--lf-text-muted); font-size: 12px; font-weight: 600; }
.ic-subtitle { margin: 12px 0 2px; color: var(--lf-text-muted); font-size: 12px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; }
.ic-note { margin: 4px 0 6px; color: var(--lf-text-muted); font-size: 12px; overflow-wrap: anywhere; }
.ic-hero { margin: 0 0 6px; }
.ic-hero-num { font-size: 22px; font-weight: 700; }
.ic-hero-sub { color: var(--lf-text-muted); font-size: 13px; }

/* ── A tappable row: name and value on top, the bar under them ── */

.ic-rows { display: grid; }
.ic-row { min-width: 0; border-radius: 6px; }
.ic-row-sum { display: grid; gap: 3px; min-height: 44px; padding: 5px 4px; align-content: center; cursor: pointer; list-style: none; border-radius: 6px; }
.ic-row-sum::-webkit-details-marker { display: none; }
.ic-row-sum:hover { background: var(--lf-panel-hover); }
.ic-row-sum:focus-visible { outline: 2px solid var(--lf-accent); outline-offset: 1px; }
.ic-row[open] > .ic-row-sum { background: var(--lf-panel-hover); }
.ic-row-detail { padding: 4px 6px 8px; font-size: 12px; }
.ic-detail-line { margin: 0 0 2px; color: var(--lf-text-muted); overflow-wrap: anywhere; }
.ic-detail-title { color: var(--lf-text); }
.ic-row-detail a { color: var(--lf-text); }
.ic-row-top { display: flex; align-items: baseline; gap: 6px; min-width: 0; font-size: 13px; }
.ic-name { min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.ic-value { margin-left: auto; flex: none; font-weight: 700; font-variant-numeric: tabular-nums; }
.ic-value-big { font-size: 16px; }
.ic-compare { color: var(--lf-text-muted); font-size: 12px; }
.ic-compare.is-fastest { color: var(--lf-text); font-weight: 600; }
.ic-waiting { color: var(--lf-text-muted); font-size: 12px; }
.ic-track { position: relative; display: block; height: 12px; min-width: 0; }

/* Legends and keys: swatches beside words, under or over the chart they name. */
.ic-legend, .ic-key { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 2px 0 4px; color: var(--lf-text-muted); font-size: 12px; }
.ic-key { gap: 4px 6px; margin-top: 6px; }
.ic-legend-item { display: inline-flex; align-items: center; gap: 4px; }
.ic-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.ic-key-cell { display: inline-block; width: 10px; height: 10px; margin-left: 4px; border-radius: 3px; background: var(--lf-text-muted); }
.ic-key-cell.is-free { background: transparent; border: 1px solid var(--lf-text-muted); }
.ic-key-cell.is-over { background: var(--ic-warn); }
.ic-key-bar { display: inline-block; width: 16px; height: 8px; margin-left: 4px; border-radius: 3px; }

/* ── Runner slots: a cell per slot, busy filled, free tinted, over its record amber ── */

.ic-cells { display: flex; gap: 2px; height: 12px; }
.ic-cell { flex: 1 1 0; min-width: 4px; border-radius: 3px; background: var(--ic-c); }
.ic-cell.is-free { background: color-mix(in oklab, var(--ic-c) var(--ic-free-mix), transparent); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--ic-c) 55%, transparent); }
.ic-cell.is-over { background: repeating-linear-gradient(135deg, var(--ic-warn) 0 3px, color-mix(in oklab, var(--ic-warn) 40%, transparent) 3px 6px); }
.ic-slot-row.is-off .ic-name { color: var(--lf-text-muted); }
.ic-slot-row .ic-name::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--ic-c); vertical-align: 1px; }
.ic-share { display: flex; gap: 2px; height: 8px; margin: 0 0 6px; }
.ic-share-seg { min-width: 2px; border-radius: 2px; background: var(--ic-c); }
.ic-share-seg.is-free { background: color-mix(in oklab, var(--lf-text-muted) 22%, transparent); }
.ic-hero.is-full .ic-hero-sub { color: var(--lf-text); font-weight: 600; }

/* ── Jobs: two stacked bars on one scale, numbers on the segments that have room ── */

.ic-jobs-row .ic-track { height: 18px; }
.ic-stack { display: flex; gap: 2px; height: 18px; min-width: 2px; }
.ic-seg { display: flex; align-items: center; justify-content: center; min-width: 2px; border-radius: 4px; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; overflow: hidden; }
.ic-seg.is-heavy, .ic-swatch.is-heavy { background: var(--ic-heavy); color: var(--ic-heavy-ink); }
.ic-seg.is-light, .ic-swatch.is-light { background: var(--ic-light); color: var(--ic-light-ink); }
.ic-seg.is-untagged, .ic-swatch.is-untagged { background: var(--ic-untagged); color: var(--ic-untagged-ink); }
.ic-seg.is-other, .ic-swatch.is-other { background: var(--ic-other); color: var(--ic-other-ink); }

/* ── Status words with an icon, so colour never carries the meaning alone ── */

.ic-status { display: inline-flex; align-items: center; gap: 4px; color: var(--lf-text); font-size: 12px; font-weight: 600; }
.ic-status-icon { display: inline-block; width: 9px; height: 9px; background: var(--ic-good); border-radius: 50%; }
.ic-status.is-warn .ic-status-icon { background: var(--ic-warn); border-radius: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); width: 10px; height: 10px; }
.ic-status.is-bad .ic-status-icon { background: var(--ic-bad); border-radius: 1px; }

/* ── The longest wait: a bar on a 30-minute scale with the 15-minute flag line ── */

.ic-wait { display: grid; gap: 3px; margin: 8px 0 0; padding: 6px 4px 0; border-top: 1px solid var(--lf-border); font-size: 13px; }
.ic-wait.is-none { display: block; padding-bottom: 4px; }
.ic-gauge { height: 10px; border-radius: 4px; background: color-mix(in oklab, var(--lf-text-muted) 18%, transparent); }
.ic-gauge-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--ic-good); }
.ic-wait.is-warn .ic-gauge-fill { background: var(--ic-warn); }
.ic-wait.is-bad .ic-gauge-fill { background: var(--ic-bad); }
.ic-mark { position: absolute; top: -3px; bottom: -3px; width: 0; border-left: 1px solid var(--lf-text-muted); }
.ic-marks { position: relative; display: block; height: 14px; }
.ic-mark-label { position: absolute; top: 0; transform: translateX(-50%); color: var(--lf-text-muted); font-size: 11px; white-space: nowrap; }
.ic-mark-label.is-end { right: 0; transform: none; }
.ic-mark-label.is-last { transform: translateX(-100%); }
.ic-wait-job { font-size: 12px; overflow-wrap: anywhere; }
.ic-wait-job a { color: var(--lf-text); }

/* ── The day's sparkline ── */

.ic-spark { margin: 10px 0 0; padding-top: 8px; border-top: 1px solid var(--lf-border); }
.ic-spark-cap { font-size: 12px; font-weight: 400; color: var(--lf-text-muted); margin-bottom: 4px; }
.ic-spark-cap strong { color: var(--lf-text); }
.ic-spark-plot { position: relative; }
.ic-spark-svg { display: block; width: 100%; height: 56px; }
.ic-spark-base { stroke: var(--lf-border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.ic-spark-line { fill: none; stroke: var(--ic-heavy); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.ic-spark-area { fill: color-mix(in oklab, var(--ic-heavy) 16%, transparent); stroke: none; }
.ic-spark-hit { fill: transparent; }
.ic-spark-hit:hover { fill: color-mix(in oklab, var(--ic-heavy) 20%, transparent); }
.ic-spark-dot { position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: var(--ic-heavy); box-shadow: 0 0 0 2px var(--lf-panel); }
.ic-spark-empty { font-size: 12px; margin: 8px 0 0; }

/* Axes under the sparkline and over the timeline: clock labels in HTML so they keep their shape. */
.ic-axis { position: relative; height: 16px; }
.ic-tick { position: absolute; top: 2px; transform: translateX(-50%); color: var(--lf-text-muted); font-size: 11px; white-space: nowrap; }
.ic-tick.is-first { transform: none; }
.ic-tick.is-last { transform: translateX(-100%); }

/* ── Pipelines: a timeline row each ── */

.ic-tl-axis { height: 30px; margin: 0 4px; }
.ic-tl-axis .ic-tick { top: 14px; }
.ic-tl-axis .ic-tl-now { top: 0; color: var(--lf-text); font-weight: 700; }
.ic-tl-rows { display: grid; }
.ic-tl-row .ic-row-sum { padding-left: 4px; padding-right: 4px; }
.ic-tl-track { height: 12px; background: linear-gradient(var(--lf-border), var(--lf-border)) 0 50% / 100% 1px no-repeat; }
.ic-tl-bar { position: absolute; top: 2px; height: 8px; border-radius: 0 4px 4px 0; }
.ic-tl-bar.is-ghost { top: 0; height: 12px; border: 1.5px dashed var(--ic-ghost); border-radius: 4px; box-sizing: border-box; background: transparent; }
.ic-tl-bar.is-elapsed, .ic-key-bar.is-elapsed { background: var(--ic-ink); }
.ic-tl-bar.is-queued { background: repeating-linear-gradient(135deg, color-mix(in oklab, var(--ic-ink) 45%, transparent) 0 3px, transparent 3px 6px); }
.ic-tl-bar.is-over, .ic-key-bar.is-over { background: var(--ic-warn); }
.ic-tl-row.is-bad .ic-tl-bar.is-over { background: var(--ic-bad); }
.ic-tl-bar.is-remain, .ic-key-bar.is-remain { background: color-mix(in oklab, var(--ic-ink) 30%, transparent); }
.ic-key-bar.is-ghost { border: 1.5px dashed var(--ic-ghost); box-sizing: border-box; }
.ic-tl-nowtick { position: absolute; top: -3px; bottom: -3px; width: 0; border-left: 2px solid var(--lf-text); }
.ic-tl-clip { position: absolute; left: -2px; top: -4px; color: var(--lf-text-muted); font-size: 14px; line-height: 1; }
.ic-ref { color: var(--lf-text-muted); font-weight: 400; font-variant-numeric: tabular-nums; }

/* ── Job speed by machine and the usual pipeline lengths: one bar each ── */

.ic-family + .ic-family { margin-top: 4px; }
.ic-bar { position: absolute; left: 0; top: 1px; height: 10px; border-radius: 0 4px 4px 0; background: var(--ic-c); }
.ic-bar.is-thin { background: color-mix(in oklab, var(--ic-c) 45%, transparent); }
.ic-bar.is-neutral { background: var(--ic-ink); }
.ic-speed-row .ic-name::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--ic-c); vertical-align: 1px; }
.ic-typical { display: grid; gap: 6px; padding: 4px 0; }
.ic-typical-row { display: grid; gap: 3px; }

@media (forced-colors: active) {
  .ic-cell, .ic-seg, .ic-bar, .ic-tl-bar, .ic-gauge-fill, .ic-swatch { forced-color-adjust: none; border: 1px solid CanvasText; }
}
