/* WaveHouse design system (subset) — tokens lifted verbatim from
   Wave-RF/WaveHouse docs/src/styles/global.css. Dark mode is the brand;
   electric Wave RF blue (#06B0BF) on a dense, cool background. */
:root {
  --wh-bg: #0a0b0e;
  --wh-bg-grid: #0e1014;
  --wh-surface: #14171c;
  --wh-surface-elevated: #1b1f26;
  --wh-border: #23272f;
  --wh-border-strong: #2f343f;

  --wh-ink: #f1f3f7;
  --wh-ink-muted: #9ca3af;
  --wh-ink-subtle: #6b7280;

  --wh-accent: #06b0bf;
  --wh-accent-hi: #1dc9d8;
  --wh-accent-lo: #054249;
  --wh-accent-glow: rgba(6, 176, 191, 0.18);

  --wh-emerald: #10b981;
  --wh-amber: #f59e0b;
  --wh-rose: #f43f5e;

  --wh-code-bg: #0f1116;
  --wh-code-border: #1b1e26;

  --radius-card: 0.75rem;
  --radius-pill: 999px;

  --font-sans: "Inter Variable", "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono Variable", "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden; /* belt-and-suspenders: no horizontal scroll on mobile */
  color: var(--wh-ink);
  background-color: var(--wh-bg);
  /* Accent glow at the top + the WaveHouse grid texture. */
  background-image:
    radial-gradient(1100px 520px at 50% -8%, var(--wh-accent-glow) 0%, transparent 60%),
    linear-gradient(var(--wh-bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--wh-bg-grid) 1px, transparent 1px);
  background-size: 100% 100%, 48px 48px, 48px 48px;
  font: 15px/1.6 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  display: flex;
  justify-content: center;
}

main { width: 100%; max-width: 41rem; padding: 4.5rem 1.25rem 2rem; }

header { text-align: center; margin-bottom: 2rem; }
.logo { color: var(--wh-accent); filter: drop-shadow(0 0 18px var(--wh-accent-glow)); }
.logo svg { display: inline-block; }
h1 {
  margin: 0.75rem 0 0.35rem;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.tag { margin: 0; color: var(--wh-ink-muted); }
.tag a { color: var(--wh-accent-hi); text-decoration: none; }
.tag a:hover { text-decoration: underline; }

/* Star CTA (issue #21) — mirrors the docs hero's ask. */
.cta-row { margin: 1.1rem 0 0; display: flex; align-items: center; justify-content: center; gap: 0.55rem; flex-wrap: wrap; }
.cta {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.48rem 0.95rem;
  border: 1px solid var(--wh-border-strong);
  border-radius: var(--radius-pill);
  background: var(--wh-surface);
  color: var(--wh-ink);
  font-weight: 600;
  font-size: 0.86rem;
  text-decoration: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}
.cta:hover { border-color: var(--wh-accent); color: var(--wh-accent-hi); box-shadow: 0 0 0 4px var(--wh-accent-glow); }
.cta .star { color: var(--wh-amber); flex: none; }
.cta-hint { color: var(--wh-ink-subtle); font-size: 0.82rem; }
@media (max-width: 420px) { .cta-hint { display: none; } }

/* Real-time latency proof (#33) — the "wow" line */
.latency {
  margin: 1.1rem auto 0;
  font-size: 0.95rem;
  color: var(--wh-ink-muted);
  font-family: var(--font-mono);
}
.latency strong { color: var(--wh-accent-hi); font-weight: 600; }
.latency #lat-ms { font-variant-numeric: tabular-nums; }

code { font-family: var(--font-mono); font-size: 0.85em; color: var(--wh-accent-hi); }
.muted { color: var(--wh-ink-subtle); font-size: 0.8rem; font-family: var(--font-mono); }

/* Headline counts */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.stat {
  background: var(--wh-surface);
  border: 1px solid var(--wh-border);
  border-radius: var(--radius-card);
  padding: 1.4rem 1.25rem;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
}
.stat .num {
  font-size: 2.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--wh-ink);
  font-variant-numeric: tabular-nums;
}
.stat .lbl {
  margin-top: 0.35rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--wh-ink-subtle);
  font-weight: 600;
}

/* Card header (title + meta/status on one row; wraps on narrow screens) */
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.4rem 0.75rem; margin-bottom: 0.9rem; }
.card-head h2 {
  margin: 0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--wh-ink-subtle);
  font-weight: 600;
}

/* Sparkline */
.chart #spark, .chart #epm-spark { display: block; width: 100%; height: 90px; }
.epm-rate { text-align: center; margin-top: 0.5rem; }
.empty { color: var(--wh-ink-subtle); font-size: 0.88rem; text-align: center; padding: 0.75rem 0 0.25rem; }

/* Stream status pill */
.stream { display: inline-flex; align-items: center; gap: 0.45rem; font-family: var(--font-mono); font-size: 0.74rem; color: var(--wh-ink-muted); }
.stream[data-state="live"] .stream-label { color: var(--wh-emerald); }

/* Activity feed */
.events { list-style: none; margin: 0; padding: 0; }
.event { display: flex; align-items: baseline; gap: 0.7rem; padding: 0.6rem 0; border-top: 1px solid var(--wh-border); animation: fadein 0.4s ease; }
.event:first-child { border-top: none; }
/* Load-more (cursor pagination) — full-width, subdued, matches the range pills */
.load-more {
  appearance: none; display: block; width: 100%; margin: 0.6rem 0 0.1rem; padding: 0.5rem 0.8rem;
  background: var(--wh-surface); color: var(--wh-ink-muted); font: 600 0.78rem var(--font-mono);
  border: 1px solid var(--wh-border-strong); border-radius: var(--radius-pill);
  cursor: pointer; transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.load-more:hover:not(:disabled) { color: var(--wh-ink); border-color: var(--wh-accent); }
.load-more:disabled { opacity: 0.55; cursor: default; }
.load-more[hidden] { display: none; } /* our display:block would otherwise defeat the hidden attribute */
.ev-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; align-self: center; background: var(--wh-ink-subtle); }
.ev-body { flex: 1; min-width: 0; }
.ev-actor { color: var(--wh-ink); font-weight: 600; text-decoration: none; }
.ev-actor:hover { color: var(--wh-accent-hi); }
.ev-verb { color: var(--wh-ink-muted); }
a.ev-verb { text-decoration: none; }
a.ev-verb:hover { color: var(--wh-accent-hi); text-decoration: underline; }
.ev-detail { color: var(--wh-ink-subtle); }
a.ev-detail { text-decoration: none; }
a.ev-detail:hover { color: var(--wh-accent-hi); text-decoration: underline; }
.ev-time { flex: none; color: var(--wh-ink-subtle); font-family: var(--font-mono); font-size: 0.74rem; white-space: nowrap; }

/* Actor avatar — replaces the bare tone dot; tone shows as a colored ring (below). */
.ev-avatar { flex: none; align-self: center; display: block; width: 24px; height: 24px; border-radius: 50%; line-height: 0; background: var(--wh-surface-elevated); }
.ev-avatar img { width: 24px; height: 24px; border-radius: 50%; display: block; object-fit: cover; }

.tone-accent { background: var(--wh-accent); box-shadow: 0 0 0 3px var(--wh-accent-glow); }
.tone-emerald { background: var(--wh-emerald); }
.tone-amber { background: var(--wh-amber); }
.tone-rose { background: var(--wh-rose); }
.tone-muted { background: var(--wh-ink-subtle); }

/* Tone as a ring around the avatar (when an avatar replaces the dot). */
.tone-ring-accent { box-shadow: 0 0 0 2px var(--wh-accent); }
.tone-ring-emerald { box-shadow: 0 0 0 2px var(--wh-emerald); }
.tone-ring-amber { box-shadow: 0 0 0 2px var(--wh-amber); }
.tone-ring-rose { box-shadow: 0 0 0 2px var(--wh-rose); }
.tone-ring-muted { box-shadow: 0 0 0 2px var(--wh-border-strong); }

@keyframes fadein { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
@media (max-width: 420px) { .stat .num { font-size: 2.1rem; } .ev-detail { display: none; } }

.card {
  background: var(--wh-surface);
  border: 1px solid var(--wh-border);
  border-radius: var(--radius-card);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
}
.card > p:first-child { margin-top: 0; }
.card p { color: var(--wh-ink-muted); }

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--wh-ink-subtle); flex: none; box-shadow: 0 0 0 4px transparent; }
.dot.pending { animation: pulse 1.2s ease-in-out infinite; }
.dot.up { background: var(--wh-emerald); box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.15); }
.dot.warn { background: var(--wh-amber); box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.15); }
.dot.down { background: var(--wh-rose); box-shadow: 0 0 0 4px rgba(244, 63, 94, 0.15); }
@keyframes pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

footer { text-align: center; color: var(--wh-ink-subtle); font-size: 0.8rem; margin-top: 1.75rem; line-height: 1.7; }
footer a { color: var(--wh-ink-muted); text-decoration: none; }
footer a:hover { color: var(--wh-accent-hi); }
footer .sep { color: var(--wh-border-strong); margin: 0 0.4rem; }

/* ==========================================================================
   Stats-page analytics (charts, hero grid, contributor cards, heatmap, etc.) —
   reuses the design tokens above. Rendered by worker/app/analytics.js.
   ========================================================================== */
main.wide { max-width: 60rem; }

/* Nav + time-range selector */
.nav-row { margin: 1.1rem 0 0; display: flex; align-items: center; justify-content: center; gap: 0.6rem; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; padding: 0.36rem 0.8rem; border: 1px solid var(--wh-border-strong);
  border-radius: var(--radius-pill); background: var(--wh-surface); color: var(--wh-ink-muted);
  font-size: 0.8rem; font-weight: 600; text-decoration: none; transition: color 0.15s, border-color 0.15s;
}
.chip:hover { color: var(--wh-accent-hi); border-color: var(--wh-accent); }
.range { display: inline-flex; border: 1px solid var(--wh-border-strong); border-radius: var(--radius-pill); overflow: hidden; background: var(--wh-surface); }
.range button {
  appearance: none; border: 0; background: transparent; color: var(--wh-ink-muted); font: 600 0.8rem var(--font-sans);
  padding: 0.36rem 0.8rem; cursor: pointer; transition: background 0.15s, color 0.15s;
}
.range button:hover { color: var(--wh-ink); }
.range button.on { background: var(--wh-accent); color: #06222a; }

/* Hero summary grid */
.hero-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; margin-bottom: 1rem; }
.hero-grid .stat { padding: 1rem 0.9rem; }
.hero-grid .stat .num { font-size: 1.9rem; }
@media (max-width: 720px) { .hero-grid { grid-template-columns: repeat(2, 1fr); } }

/* Card head extras */
.card-head h2 { display: flex; align-items: center; gap: 0.5rem; }
.badge {
  font-size: 0.6rem; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 700;
  color: var(--wh-accent-hi); background: var(--wh-accent-glow); border: 1px solid var(--wh-accent-lo);
  padding: 0.1rem 0.4rem; border-radius: var(--radius-pill);
}
.legend { display: inline-flex; align-items: center; gap: 0.55rem; font-family: var(--font-mono); font-size: 0.68rem; color: var(--wh-ink-muted); flex-wrap: wrap; }
.legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-right: 0.25rem; vertical-align: -1px; }
.sub-head { margin: 1.1rem 0 0.5rem; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; }

/* Charts (hand-rolled SVG) */
.chart-mount { width: 100%; }
.vchart { display: block; width: 100%; height: auto; }
.vaxis { fill: var(--wh-ink-subtle); font: 10px var(--font-mono); }
.vbar { transition: opacity 0.12s; }
.vhit { cursor: crosshair; }
.vhit:hover ~ .vbar { opacity: 1; }
.vunit { text-align: right; margin-top: 0.2rem; }

/* Horizon small-multiples — 3-col grid so the name and its total never collide */
.horizons { display: flex; flex-direction: column; gap: 3px; }
.hz-row { display: grid; grid-template-columns: 8.5rem 1fr 2.6rem; align-items: center; gap: 0.6rem; }
.hz-label { font-size: 0.78rem; color: var(--wh-ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hz-label.strong { color: var(--wh-ink); font-weight: 600; }
.hz-sum { font-family: var(--font-mono); font-size: 0.72rem; color: var(--wh-ink-subtle); text-align: right; font-variant-numeric: tabular-nums; }
.hz-plot { position: relative; height: 34px; border-radius: 4px; overflow: hidden; background: rgba(255,255,255,0.015); }
.hz { display: block; width: 100%; height: 34px; }
@media (max-width: 560px) { .hz-row { grid-template-columns: 7rem 1fr 2.2rem; } .hz-label { font-size: 0.74rem; } }

/* Contributor leaderboard */
.cboard { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0.7rem; }
@media (max-width: 640px) { .cboard { grid-template-columns: minmax(0, 1fr); } }
.ccard { display: flex; min-width: 0; gap: 0.7rem; align-items: center; padding: 0.7rem 0.8rem; background: var(--wh-surface-elevated); border: 1px solid var(--wh-border); border-radius: 0.6rem; }
.cav { flex: none; width: 34px; height: 34px; border-radius: 50%; overflow: hidden; background: var(--wh-surface); display: block; line-height: 0; box-shadow: 0 0 0 2px var(--wh-border-strong); }
.cav img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }
.cbody { flex: 1; min-width: 0; }
.crow { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.cname { color: var(--wh-ink); font-weight: 600; text-decoration: none; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cname:hover { color: var(--wh-accent-hi); }
.cscore { font-family: var(--font-mono); font-size: 0.82rem; color: var(--wh-accent-hi); font-weight: 600; }
.cbar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; margin: 0.4rem 0 0.35rem; background: var(--wh-code-bg); gap: 2px; }
.cbar > div { min-width: 2px; }
.cmeta { font-size: 0.68rem; line-height: 1.45; overflow-wrap: anywhere; }

/* Stat tiles inside cards */
.tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.6rem; margin-bottom: 1rem; }
.tile { text-align: center; padding: 0.7rem 0.3rem; background: var(--wh-surface-elevated); border: 1px solid var(--wh-border); border-radius: 0.55rem; }
.tnum { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; color: var(--wh-ink); }
.tlbl { margin-top: 0.15rem; font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--wh-ink-subtle); font-weight: 600; }
@media (max-width: 640px) { .tiles { grid-template-columns: repeat(2, 1fr); } }

/* Histogram */
.hist { display: flex; align-items: flex-end; gap: 0.5rem; height: 130px; padding-top: 0.5rem; }
.hist-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.hist-n { font-size: 0.65rem; margin-bottom: 0.2rem; }
.hist-bar { width: 100%; max-width: 46px; background: linear-gradient(var(--wh-accent-hi), var(--wh-accent-lo)); border-radius: 4px 4px 0 0; min-height: 0; transition: filter 0.12s; }
.hist-bar:hover { filter: brightness(1.25); }
.hist-x { font-size: 0.62rem; color: var(--wh-ink-subtle); margin-top: 0.35rem; font-family: var(--font-mono); }

/* Punch-card heatmap */
.hm { display: flex; flex-direction: column; gap: 3px; }
.hm-row { display: grid; grid-template-columns: 2.4rem repeat(24, 1fr); gap: 3px; align-items: center; }
.hm-day { font-size: 0.68rem; color: var(--wh-ink-subtle); font-family: var(--font-mono); }
.hm-cell { aspect-ratio: 1 / 1; border-radius: 2px; }
.hm-head .hm-cell { aspect-ratio: auto; }
.hm-hh { font-size: 0.6rem; color: var(--wh-ink-subtle); font-family: var(--font-mono); text-align: left; }
.hm-row:not(.hm-head) .hm-cell { cursor: crosshair; }

/* Workflow success meters */
.wf-list { display: flex; flex-direction: column; gap: 0.4rem; }
.wf-row { display: grid; grid-template-columns: 11rem 1fr 3rem 4.5rem; align-items: center; gap: 0.6rem; }
.wf-name { font-size: 0.8rem; color: var(--wh-ink); line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.wf-meter { height: 8px; border-radius: 4px; background: var(--wh-code-bg); overflow: hidden; }
.wf-fill { height: 100%; border-radius: 4px; }
.wf-pct { font-family: var(--font-mono); font-size: 0.78rem; text-align: right; color: var(--wh-ink-muted); }
.wf-runs { font-size: 0.68rem; text-align: right; }
@media (max-width: 560px) { .wf-row { grid-template-columns: 7rem 1fr 2.6rem; } .wf-runs { display: none; } }

/* Review meters */
.rv-list { display: flex; flex-direction: column; gap: 0.45rem; }
.rv-row { display: grid; grid-template-columns: 1fr 8rem 2.2rem; align-items: center; gap: 0.6rem; }
.rv-pair { font-size: 0.82rem; color: var(--wh-ink-muted); }
.rv-pair b { color: var(--wh-ink); }
.rv-meter { height: 8px; border-radius: 4px; background: var(--wh-code-bg); overflow: hidden; }
.rv-fill { height: 100%; background: linear-gradient(90deg, var(--wh-accent-lo), var(--wh-accent-hi)); border-radius: 4px; }
.rv-n { font-family: var(--font-mono); font-size: 0.78rem; text-align: right; color: var(--wh-ink-muted); }
@media (max-width: 560px) { .rv-row { grid-template-columns: 1fr 4rem 2rem; } }

/* Shared hover tooltip */
.vtip {
  position: fixed; z-index: 50; pointer-events: none; max-width: 16rem;
  background: rgba(20,23,28,0.97); border: 1px solid var(--wh-border-strong); border-radius: 0.5rem;
  padding: 0.5rem 0.65rem; font-size: 0.78rem; color: var(--wh-ink); line-height: 1.5;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5); backdrop-filter: blur(4px);
}
.vtip[hidden] { display: none; }
.vtip .tt-h { font-family: var(--font-mono); font-size: 0.68rem; color: var(--wh-ink-subtle); margin-bottom: 0.15rem; }
.vtip .tk { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 0.35rem; vertical-align: 0; }
.vtip b { font-variant-numeric: tabular-nums; }

/* ---- Mobile hardening (no horizontal scroll) ---- */
/* Nothing may exceed the viewport width. */
svg, img { max-width: 100%; }
.card { overflow: hidden; } /* clip any chart that rounds a hair over the card */
/* Legend chips travel as whole units and wrap. */
.legend > span { display: inline-flex; align-items: center; white-space: nowrap; }
/* The 24-column punch-card gets its own scroll area on tiny screens instead of
   widening the page; min-width keeps cells legible, overflow contains it. */
.heatmap-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.hm { min-width: 340px; }
/* Legends drop below the title on narrow screens rather than squeezing it. */
@media (max-width: 560px) {
  main.wide { padding-left: 0.9rem; padding-right: 0.9rem; }
  .card { padding: 1.1rem 1rem; }
  .card-head { justify-content: flex-start; }
  .legend { font-size: 0.64rem; gap: 0.4rem; }
  h1 { font-size: 1.7rem; }
}
