/* KRNX network stats page. Plain CSS, no build step, no external fonts.
   Colours are custom properties so the dark scheme only swaps values. */

:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --text: #1b1f27;
  --muted: #5d6675;
  --border: #d7dbe3;
  --accent: #1d5fd1;
  --ok: #1f8a4c;
  --warn: #b3700f;
  --bad: #c0392b;
  --verified: #1f8a4c;
  --discovered: #1d5fd1;
  --banner-stale-bg: #fff4de;
  --banner-stale-fg: #6b4400;
  --banner-bad-bg: #fde8e6;
  --banner-bad-fg: #7a1f17;
  --skeleton: #e3e6ec;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --surface: #1b1f27;
    --surface-2: #232834;
    --text: #e6e9ef;
    --muted: #9aa4b4;
    --border: #323948;
    --accent: #6ea0ff;
    --ok: #4cc27c;
    --warn: #e0a03a;
    --bad: #ff6b5b;
    --verified: #4cc27c;
    --discovered: #6ea0ff;
    --banner-stale-bg: #3a2d10;
    --banner-stale-fg: #ffd98a;
    --banner-bad-bg: #3d1c19;
    --banner-bad-fg: #ffb3aa;
    --skeleton: #2c3240;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px 32px;
  overflow-x: hidden;
}

h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 8px; font-weight: 600; }
code { font-family: var(--mono); font-size: 0.92em; }
a { color: var(--accent); }
button, select { font: inherit; color: inherit; }

.site-header { padding: 20px 0 8px; }
.title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.subtitle { margin: 6px 0 0; color: var(--muted); font-size: 0.9rem; overflow-wrap: anywhere; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface-2);
  text-transform: lowercase;
}
.badge-network { background: var(--accent); color: #fff; border-color: transparent; }
.badge-ok { color: var(--ok); }
.badge-stale { color: var(--warn); }
.badge-unavailable, .badge-bad { color: var(--bad); }

.banner {
  margin: 12px 0;
  padding: 10px 14px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border: 1px solid transparent;
}
.banner-stale { background: var(--banner-stale-bg); color: var(--banner-stale-fg); }
.banner-unavailable, .banner-error { background: var(--banner-bad-bg); color: var(--banner-bad-fg); }

.btn {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
}
.btn:disabled { opacity: 0.5; cursor: default; }

.summary { margin-top: 12px; }
.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  min-width: 0;
}
.card h2 { font-size: 0.95rem; color: var(--muted); font-weight: 600; }
.big {
  font-size: 2.4rem;
  font-weight: 700;
  margin: 2px 0 8px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.big .skeleton { display: inline-block; width: 3ch; }
.secondary { margin: 0; display: grid; gap: 2px; font-size: 0.85rem; }
.secondary div { display: flex; justify-content: space-between; gap: 8px; }
.secondary dt { color: var(--muted); font-family: var(--mono); font-size: 0.8rem; }
.secondary dd { margin: 0; font-variant-numeric: tabular-nums; text-align: right; }

.skeleton {
  background: var(--skeleton);
  border-radius: 4px;
  color: transparent;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.5; } }

.updated { margin: 12px 0 4px; color: var(--muted); font-size: 0.9rem; }
.caveat { margin: 4px 0; color: var(--muted); font-size: 0.85rem; }
.note { margin: 8px 0; color: var(--muted); font-size: 0.9rem; }
.hint { margin: 0 0 8px; color: var(--muted); font-size: 0.85rem; }

.toolbar { display: flex; align-items: center; gap: 10px; margin: 10px 0 4px; flex-wrap: wrap; }
.toolbar .label { color: var(--muted); font-size: 0.9rem; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.segmented button {
  padding: 5px 12px;
  border: 0;
  background: var(--surface);
  cursor: pointer;
}
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button[aria-pressed="true"] { background: var(--accent); color: #fff; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-top: 16px;
  min-width: 0;
}
.panel[aria-busy="true"] .table-wrap, .panel[aria-busy="true"] .bars, .panel[aria-busy="true"] .chart-wrap { opacity: 0.55; }

.filters { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.filters label { display: flex; flex-direction: column; font-size: 0.8rem; color: var(--muted); gap: 2px; }
.filters select {
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  min-width: 9ch;
}

/* Between the phone layout and the full width the table scrolls inside
   its panel instead of crushing its columns; the page itself never
   scrolls sideways. */
.table-wrap { width: 100%; overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.data th, table.data td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; white-space: nowrap; }
table.data th { color: var(--muted); font-weight: 600; font-size: 0.8rem; }
table.data td.wrap, table.data td .caps { white-space: normal; overflow-wrap: anywhere; }
td.num { font-variant-numeric: tabular-nums; }
.node-id { font-family: var(--mono); white-space: nowrap; }
.copy {
  margin-left: 6px;
  padding: 0 6px;
  font-size: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-2);
  cursor: pointer;
}
.state { font-family: var(--mono); font-size: 0.82rem; }
.state-krnx_verified { color: var(--ok); }
.state-stale { color: var(--warn); }
.state-rlpx_ok, .state-enr_krnx, .state-enr_only { color: var(--muted); }
.caps { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); }
time { white-space: nowrap; }

.pager { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.pager span { color: var(--muted); font-size: 0.85rem; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.two-col > div { min-width: 0; }
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.bars li { display: grid; grid-template-columns: minmax(8ch, 22ch) 1fr 4ch; align-items: center; gap: 8px; font-size: 0.88rem; }
.bar-label { font-family: var(--mono); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); width: 0; }
.bar-count { text-align: right; font-variant-numeric: tabular-nums; }

.legend { display: flex; gap: 16px; font-size: 0.82rem; color: var(--muted); margin-bottom: 6px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 3px; display: inline-block; border-radius: 2px; }
.swatch-verified { background: var(--verified); }
.swatch-discovered { background: var(--discovered); }
.chart-wrap { position: relative; }
#chart { width: 100%; height: auto; display: block; }
.grid-line { stroke: var(--border); stroke-width: 1; }
.axis-label { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.series-verified { stroke: var(--verified); }
.series-discovered { stroke: var(--discovered); }
.point { stroke-width: 0; vector-effect: non-scaling-stroke; }
.point-verified { fill: var(--verified); }
.point-discovered { fill: var(--discovered); }

.site-footer { margin-top: 24px; color: var(--muted); font-size: 0.82rem; }
.site-footer p { margin: 4px 0; overflow-wrap: anywhere; }

.yes { color: var(--ok); }
.no { color: var(--muted); }

@media (max-width: 700px) {
  body { font-size: 14px; }
  .cards { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .big { font-size: 2rem; }

  /* Tables become stacked cards: each cell shows its header as a label. */
  table.data thead { display: none; }
  table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data tr { border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; margin-bottom: 8px; }
  table.data td { border: 0; padding: 3px 0; display: grid; grid-template-columns: 9ch 1fr; gap: 8px; white-space: normal; overflow-wrap: anywhere; }
  table.data td::before { content: attr(data-label); color: var(--muted); font-size: 0.78rem; }
  .node-id { white-space: normal; overflow-wrap: anywhere; }
  .bars li { grid-template-columns: minmax(8ch, 14ch) 1fr 4ch; }
  .filters label { flex: 1 1 40%; }
  .filters select { width: 100%; }
}
