/* CI health page (#20). Colours are tokens, defined once per theme, so
   bynk-lang branding can replace them without touching the layout.
   Conclusions: blue (passed) and red (failed) pass the data-viz palette
   validator in both themes (CVD ΔE 21.6 light, 19.2 dark); grey is
   de-emphasis, not a series. Default-branch state uses the fixed status
   palette, always with an icon and a label. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-muted: #6b6a65;
  --rule: #e1e0d9;
  --ring: rgba(11, 11, 11, 0.10);
  --passed: #2a78d6;
  --failed: #e34948;
  --other: #c3c2b7;
  --good: #0ca30c;
  --good-text: #006300;
  --critical: #d03b3b;
  --link: #1c5cab;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --ink-muted: #a3a29b;
    --rule: #2c2c2a;
    --ring: rgba(255, 255, 255, 0.10);
    --passed: #3987e5;
    --failed: #e66767;
    --other: #4a4a46;
    --good: #0ca30c;
    --good-text: #0ca30c;
    --critical: #e66767;
    --link: #86b6ef;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --ink-muted: #a3a29b;
  --rule: #2c2c2a;
  --ring: rgba(255, 255, 255, 0.10);
  --passed: #3987e5;
  --failed: #e66767;
  --other: #4a4a46;
  --good: #0ca30c;
  --good-text: #0ca30c;
  --critical: #e66767;
  --link: #86b6ef;
}

* { box-sizing: border-box; }
html { background: var(--page); }
body {
  margin: 0 auto;
  max-width: 72rem;
  padding: 24px 16px 48px;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 var(--font);
}
a { color: var(--link); }
h1 { font-size: 1.75rem; margin: 0; }
h2 { font-size: 1.15rem; margin: 0; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.masthead {
  display: flex; flex-wrap: wrap; gap: 16px;
  justify-content: space-between; align-items: flex-end;
  margin-bottom: 16px;
}
.subtitle, .freshness, .coverage { color: var(--ink-2); margin: 4px 0 0; }
.controls { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.window { display: flex; gap: 0; border: 0; padding: 0; margin: 0; }
.window label {
  padding: 4px 12px; border: 1px solid var(--rule); background: var(--surface);
  cursor: pointer; color: var(--ink-2);
}
.window label:first-of-type { border-radius: 6px 0 0 6px; }
.window label:last-of-type { border-radius: 0 6px 6px 0; }
.window label + label { border-left: 0; }
.window input { position: absolute; opacity: 0; }
.window label:has(input:checked) { color: var(--ink); font-weight: 600; box-shadow: inset 0 -2px 0 var(--ink); }
.window label:has(input:focus-visible) { outline: 2px solid var(--link); outline-offset: 2px; }
.freshness.stale { color: var(--critical); }

.legend { display: flex; flex-wrap: wrap; gap: 4px 20px; list-style: none; padding: 0; margin: 12px 0 20px; color: var(--ink-2); font-size: 0.9rem; }
.legend li { display: flex; align-items: center; gap: 8px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.swatch.passed, .seg.passed { background: var(--passed); }
.swatch.failed, .seg.failed { background: var(--failed); }
.swatch.other, .seg.other { background: var(--other); }

.repo {
  background: var(--surface); border: 1px solid var(--ring); border-radius: 10px;
  padding: 16px; margin-bottom: 20px;
}
.repo-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 16px; margin-bottom: 12px; }
/* Maintainers' actions (#53, step 5). */
.rerun h4 { margin: 12px 0 4px; font-size: 0.95rem; }
.rerun-list { margin: 0; padding-left: 1.2em; }
.rerun-list li { margin: 4px 0; }
.rerun-note { color: var(--ink-2); }
/* What is the signed-in maintainer's (#53, step 4). */
.mine h3 { margin: 12px 0 4px; font-size: 1rem; }
.mine-list { margin: 0; padding-left: 1.2em; }
.mine-list li { margin: 4px 0; }
.mine-empty { margin: 4px 0; color: var(--ink-2); }
.mine-ci, .mine-stale { font-weight: 500; }
.mine-ci.failing, .mine-stale { text-decoration: underline; text-decoration-style: dotted; }
.proposal-reason { font-style: italic; }
.proposal-note { color: var(--ink-2); }
.proposal-comment { margin: 4px 0; padding: 0 0 0 8px; border-left: 2px solid var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.settings-problem { overflow-wrap: anywhere; }
.mine-claude { margin: 8px 0 0; font-size: 0.85em; color: var(--ink-2); }
/* Signed in (#53), the page says it covers every repository (signin.js sets `signed-in`). */
.for-maintainers { display: none; }
.signed-in .for-maintainers { display: block; }
.signed-in .for-public { display: none; }
/* A repository only maintainers see (#53): private, or kept off the public pages. Text, not colour alone. */
.repo-mark { margin-left: 8px; padding: 1px 8px; border: 1px solid var(--rule); border-radius: 999px; font-size: 0.75rem; font-weight: 500; color: var(--ink-2); vertical-align: middle; letter-spacing: 0.02em; }
.running { color: var(--ink-2); font-size: 0.9rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { padding: 8px 10px; text-align: left; border-top: 1px solid var(--rule); vertical-align: middle; }
thead th { border-top: 0; color: var(--ink-muted); font-weight: 600; font-size: 0.8rem; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.workflow { font-weight: 600; }
td.workflow small { display: block; font-weight: 400; color: var(--ink-muted); }
td.none { color: var(--ink-muted); }

.state { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.state .icon { width: 16px; height: 16px; border-radius: 50%; color: #fff; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; }
.state.good .icon { background: var(--good); }
.state.good { color: var(--good-text); }
.state.critical .icon { background: var(--critical); }
.state.critical { color: var(--ink); font-weight: 600; }
.state.none { color: var(--ink-muted); }

/* Thin segmented bar: 8px, fully rounded ends, 2px surface gap between parts. */
.bar { display: flex; gap: 2px; width: 100%; min-width: 120px; height: 8px; }
.seg { height: 8px; border-radius: 4px; min-width: 2px; }

/* Recent runs: one 6px mark per attempt, 2px apart, oldest left. Runs the
   pass rate doesn't count are half height, so they differ by shape too. */
.strip { display: inline-flex; align-items: flex-end; gap: 2px; height: 18px; vertical-align: middle; }
.run { display: block; width: 6px; height: 18px; border-radius: 3px; }
.run.passed { background: var(--passed); }
.run.failed { background: var(--failed); }
.run.other { background: var(--other); height: 9px; }
.run:hover { outline: 2px solid var(--ink); outline-offset: 1px; }
.strip-wrap { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 4px; }
/* The strip's keyboard link: out of sight until focused, then shown in full. */
.strip-runs {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; font-size: 0.82rem;
}
.strip-runs:focus-visible {
  position: static; width: auto; height: auto; overflow: visible; clip: auto;
  outline: 2px solid var(--link); outline-offset: 2px;
}

.trend-toggle {
  display: inline-block; margin-top: 4px; padding: 0; border: 0; background: none;
  color: var(--link); font: inherit; font-size: 0.82rem; font-weight: 400; cursor: pointer; text-decoration: underline;
}
.trend-toggle:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
tr.trend-row > td { border-top: 0; padding-top: 0; }
.trend { padding: 4px 0 8px; }
.trend-charts { display: flex; flex-wrap: wrap; gap: 8px 32px; }
.trend-chart { margin: 0; flex: 1 1 280px; max-width: 440px; }
.trend-chart figcaption { color: var(--ink-2); font-size: 0.85rem; margin-bottom: 4px; }
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--rule); stroke-width: 1; }
.chart .axis { stroke: var(--ink-muted); stroke-width: 1; }
.chart .tick { fill: var(--ink-muted); font-size: 10px; font-family: var(--font); }
.chart .mark { fill: var(--passed); }
.chart .line { fill: none; stroke: var(--passed); stroke-width: 2; stroke-linejoin: round; }
.chart .point { fill: var(--passed); stroke: var(--surface); stroke-width: 2; }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: var(--ring); }
details.trend-table { margin-top: 8px; font-size: 0.88rem; color: var(--ink-2); }
details.trend-table table { margin-top: 6px; max-width: 640px; }

/* Between the dashboards. */
.pages .signin { margin-left: auto; color: var(--ink-2); }
.link-button { padding: 0; border: 0; background: none; color: var(--link); font: inherit; cursor: pointer; text-decoration: underline; }
.link-button:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

.pages { display: flex; gap: 20px; margin-bottom: 16px; font-size: 0.92rem; }
.pages a { color: var(--ink-2); text-decoration: none; padding-bottom: 2px; }
.pages a:hover { color: var(--ink); text-decoration: underline; }
.pages a[aria-current="page"] { color: var(--ink); font-weight: 600; box-shadow: inset 0 -2px 0 var(--ink); }

/* PR flow: headline figures as tiles, wrapping on narrow screens. */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 0 0 12px; }
.tile { margin: 0; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 8px; }
.tile dt { color: var(--ink-muted); font-size: 0.8rem; font-weight: 600; }
.tile dd { margin: 0; }
.tile .value { font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }
.tile .value.none { color: var(--ink-muted); font-weight: 400; }
.tile .note { color: var(--ink-muted); font-size: 0.8rem; margin-top: 2px; }
.aside { color: var(--ink-2); font-size: 0.9rem; margin: 4px 0; }
.flow-chart { margin: 12px 0 4px; max-width: 440px; }
.repo h3 { font-size: 0.95rem; margin: 16px 0 4px; }
td.pr { font-weight: 600; }
td.pr a { margin-right: 2px; }
td.pr small { display: block; font-weight: 400; color: var(--ink-muted); }
.stage { display: inline-block; padding: 1px 8px; border-radius: 10px; border: 1px solid var(--rule); font-size: 0.82rem; white-space: nowrap; color: var(--ink-2); }
.stage.queued { border-color: var(--passed); color: var(--ink); }
.stage.draft { border-style: dashed; color: var(--ink-muted); }
.flag { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-weight: 600; }
.flag .icon { width: 16px; height: 16px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--ink); border: 1.5px solid var(--ink); }

details.in-flight { margin-top: 12px; color: var(--ink-2); font-size: 0.9rem; }
details.in-flight ul { margin: 8px 0 0; padding-left: 20px; }

/* Runner wait (#42): its own block in each repository, under the workflows. */
.runners { margin-top: 20px; padding-top: 12px; border-top: 1px solid var(--rule); }
.runners h3 { margin-top: 0; }
.runners .aside { margin: 0 0 8px; }
td.waiting { white-space: nowrap; }
ol.longest { margin: 8px 0 0; padding-left: 24px; }
ol.longest li { margin: 2px 0; }
/* Median to 95th percentile: a 4px range on a shared track, the median an 8px
   point ringed in the surface, so it reads where it overlaps the range. */
.range { position: relative; width: 100%; min-width: 120px; height: 12px; }
.range::before { content: ""; position: absolute; left: 0; right: 0; top: 5.5px; height: 1px; background: var(--rule); }
.range-span { position: absolute; top: 4px; height: 4px; min-width: 2px; border-radius: 2px; background: var(--passed); opacity: 0.55; }
.range-dot { position: absolute; top: 2px; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%; background: var(--passed); box-shadow: 0 0 0 2px var(--surface); }
/* Issues (#48): an issue's labels as chips, and the backlog's ages as small tiles. */
.labels { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.tiles.ages { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); max-width: 640px; }
.tiles.ages .value { font-size: 1.1rem; }
/* A workflow's slowest jobs, in its trend panel. */
.slowest { margin-top: 12px; }
.slowest h4 { font-size: 0.88rem; margin: 0 0 4px; color: var(--ink-2); }
table.compact { max-width: 640px; font-size: 0.88rem; }
table.compact th, table.compact td { padding: 4px 6px; }
table.compact tbody th { font-weight: 600; }

footer { color: var(--ink-muted); font-size: 0.85rem; margin-top: 32px; }

/* Narrow screens: each workflow becomes a card of labelled figures, so nothing
   scrolls sideways or is cut off. */
@media (max-width: 720px) {
  .controls { align-items: flex-start; }
  .masthead { align-items: flex-start; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  tr { border-top: 1px solid var(--rule); padding: 10px 0; }
  tbody tr:first-child { border-top: 0; }
  td { border: 0; padding: 2px 0; }
  td[data-label] { display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  td[data-label]::before { content: attr(data-label); color: var(--ink-muted); text-align: left; }
  td.state-cell .state { white-space: normal; text-align: right; }
  td.bar-cell { padding-top: 6px; }
  td.bar-cell .bar { flex: 0 1 60%; align-self: center; }
  td.strip-cell { align-items: center; }
  tr.trend-row { border-top: 0; padding-top: 0; }
  details.trend-table table, details.trend-table tbody, details.trend-table tr,
  details.trend-table td, details.trend-table th { display: revert; width: auto; }
  details.trend-table thead { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  details.trend-table td, details.trend-table th { border-top: 1px solid var(--rule); padding: 4px 6px; }
  td.waiting { white-space: normal; }
  td.bar-cell .range { flex: 0 1 60%; align-self: center; }
  table.compact tbody th { display: block; border: 0; padding: 2px 0; }
}
.empty { color: var(--ink-2); }

@media (forced-colors: active) {
  .seg, .swatch { forced-color-adjust: none; border: 1px solid CanvasText; }
  /* Passed: outlined. Failed: filled. Not counted: half-height outline. */
  .run { forced-color-adjust: none; border: 1px solid CanvasText; background: Canvas; }
  .run.failed { background: CanvasText; }
  .chart .mark, .chart .point { fill: CanvasText; }
  .chart .line { stroke: CanvasText; }
  .range-span, .range-dot, .range::before { forced-color-adjust: none; background: CanvasText; box-shadow: none; }
}
