/* Visual language follows the portfolio site's design (colours, type, spacing).
   Phone first: the three numbers stay side by side, the pills stay on one row, and every
   control is at least 44 px tall. */
:root {
  --bg: #FFFFFF; --card: #F7F9FC; --line: #DCE3EE; --held-line: #C9D6E8; --text: #0E2238; --muted: #4A5A70;
  --link: #1D4ED8; --brand: #1D4ED8; --now: #C2410C; --live: #15803D; --paused: #D97706; --down: #DC2626;
}
:root[data-theme="dark"] {
  --bg: #0B1B2E; --card: #16304D; --line: #2A4766; --held-line: #2A4766; --text: #F7F9FC; --muted: #A9BBD3;
  --link: #8FC1FF; --brand: #8FC1FF; --now: #FB923C; --live: #4ADE80; --paused: #FBBF24; --down: #F87171;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: "DM Sans", system-ui, sans-serif; }
.widget { padding: 16px 14px 18px; display: flex; flex-direction: column; gap: 14px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.card { padding: 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); }

.head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.title { margin: 0; font-family: "Bricolage Grotesque", sans-serif; font-weight: 700; font-size: 19px; }
.filters { display: flex; gap: 6px; align-items: center; width: 100%; }
.pill {
  flex: 1 1 auto; font: inherit; font-size: 13px; padding: 0 8px; min-height: 44px; border-radius: 999px; white-space: nowrap;
  cursor: pointer; border: 1px solid var(--line); background: transparent; color: var(--text);
}
/* On a phone the pills speak for themselves; the group keeps its name for screen readers. */
.filters-label { display: none; }
.pill[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

.metrics { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.metric { padding: 10px; display: flex; flex-direction: column; justify-content: space-between; gap: 4px; min-width: 0; }
.label { font-size: 12px; line-height: 1.3; color: var(--muted); }
.value {
  margin: 0; font-family: "Bricolage Grotesque", sans-serif; font-weight: 800; line-height: 1.1;
  font-size: clamp(20px, 5.6vw, 30px); font-variant-numeric: tabular-nums;
}
/* Paused: the numbers stay, but they're the last ones we had, not now. */
.metrics.held .metric { background: transparent; border-style: dashed; border-color: var(--held-line); }
.metrics.held .value { color: var(--muted); }

.defs-toggle {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; margin: -8px 0;
  padding: 0; border: 0; background: none; color: var(--link); font: inherit; font-size: 14px; cursor: pointer;
}
.defs-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.defs { margin: 0; display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); font-size: 13px; line-height: 1.45; color: var(--muted); }
.defs[hidden] { display: none; }
.defs dt { font-weight: 700; color: var(--text); }
.defs dd { margin: 0; }

.chart-card { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; justify-content: space-between; gap: 8px; }
.axis { font-family: "IBM Plex Mono", monospace; font-size: 12px; }
/* 60 bars must fit a narrow card: 1 px gaps until there's room for 2, and never spill. */
.bars { display: flex; align-items: flex-end; gap: 1px; height: 96px; overflow: hidden; }
.bar { flex: 1; min-width: 2px; border-radius: 2px 2px 0 0; background: var(--brand); }
.bar.partial { background: var(--now); }
.bar.unknown { background: transparent; border-bottom: 2px dotted var(--line); height: 100% !important; }

.list-head { padding-bottom: 6px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-top: 1px solid var(--line); }
.list:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; border-radius: 4px; }
/* The whole row is the link, so it's an easy target on a phone. */
.list a {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px;
  color: var(--link); text-decoration: none; font-size: 15px;
}
.list a:hover .name { text-decoration: underline; }
.article { min-width: 0; display: flex; align-items: baseline; }
.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.count { font-family: "IBM Plex Mono", monospace; font-size: 12px; color: var(--muted); flex: none; }
.lang-tag { font-family: "IBM Plex Mono", monospace; font-size: 12px; color: var(--muted); margin-left: 6px; flex: none; }
.empty { display: flex; align-items: center; min-height: 44px; color: var(--muted); font-size: 14px; }

.foot { display: flex; flex-direction: column; gap: 8px; }
.status { margin: 0; display: flex; gap: 8px; align-items: flex-start; font-size: 14px; font-weight: 500; line-height: 1.45; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; margin-top: 5px; }
.dot.live { background: var(--live); animation: pulse 1.6s ease-in-out infinite; }
.dot.paused { background: var(--paused); }
.dot.down { background: var(--down); }
.note { margin: 0; font-size: 12px; line-height: 1.5; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
button:focus-visible, a:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(21, 128, 61, .5); }
  50% { box-shadow: 0 0 0 6px rgba(21, 128, 61, 0); }
}
@media (prefers-reduced-motion: reduce) { .dot.live { animation: none; } }
/* The smallest phones: tighter pills so all four still fit on one row. */
@media (max-width: 359px) {
  .filters { gap: 4px; }
  .pill { padding: 0 6px; font-size: 12px; }
}
@media (min-width: 560px) {
  .widget { padding: 20px 18px; gap: 16px; }
  .filters { width: auto; flex-wrap: wrap; }
  .filters-label { display: inline; }
  .pill { flex: none; padding: 0 14px; font-size: 14px; }
  .metric { padding: 12px; }
  .bars { height: 110px; gap: 2px; }
}
