/* stats.css — styling for the "What the numbers say" analytics view (js/views/stats.js).
   Everything is prefixed .st- to avoid collisions with the rest of the app. No hardcoded colours:
   every colour reference is one of the CSS variables defined in css/app.css, so this view inherits
   both the dark and light theme automatically. No chart library, no canvas — bars are plain divs. */

.st-page { max-width: 100%; }

.st-title { margin-bottom: var(--space-3); }

.st-panel {
  margin-top: var(--space-10);
  padding-top: var(--space-8);
  border-top: 1px solid var(--border-soft);
}
.st-panel:first-of-type { margin-top: var(--space-8); }

.st-callout {
  color: var(--muted);
  font-size: var(--text-sm);
  max-width: 68ch;
  margin: 0 0 var(--space-5);
}

.st-subhead {
  font-family: var(--serif);
  font-weight: 400;
  font-size: var(--text-base);
  color: var(--text);
  margin: 0 0 var(--space-3);
}

.st-fineprint { font-size: var(--text-xs); margin-top: var(--space-3); }

/* ---------- headline stat cards ---------- */
.st-stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-4);
}
.st-stat {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: var(--space-4);
}
.st-stat-value {
  font-family: var(--serif);
  font-size: var(--text-2xl);
  font-weight: 400;
  color: var(--brass);
  line-height: 1;
}
.st-stat-label {
  font-size: var(--text-sm);
  color: var(--text);
  margin-top: var(--space-2);
}
.st-stat-note {
  font-size: var(--text-xs);
  color: var(--faint);
  margin-top: var(--space-2);
  line-height: 1.4;
}

/* ---------- tenure ---------- */
.st-median {
  font-size: var(--text-base);
  color: var(--text);
  margin: 0 0 var(--space-4);
}
.st-median strong { color: var(--brass); font-family: var(--serif); }

/* ---------- horizontal bar histograms (shared by tenure, degree, venues) ---------- */
.st-hist {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.st-hbar-row {
  display: grid;
  grid-template-columns: minmax(70px, 15ch) minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
}
.st-hbar-label {
  font-size: var(--text-sm);
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.st-hbar-label a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}
.st-hbar-label a:hover { border-bottom-color: var(--brass); }
.st-hbar-track {
  position: relative;
  height: 14px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-soft);
}
.st-hbar-fill {
  height: 100%;
  background: var(--brass);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  min-width: 2px;
}
.st-hbar-value {
  font-family: var(--mono);
  font-size: var(--text-xs);
  color: var(--faint);
  min-width: 2.5ch;
  text-align: right;
}

/* ---------- top-N ranked list (people by degree) ---------- */
.st-ranked {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.st-ranked-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-soft);
  font-size: var(--text-sm);
}
.st-ranked-row:last-child { border-bottom: 0; }
.st-rank-n {
  font-family: var(--mono);
  font-size: var(--text-xs);
  color: var(--faint);
  min-width: 2ch;
  text-align: right;
}
.st-rank-name {
  font-family: var(--serif);
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  flex: 1;
}
.st-rank-name:hover { border-bottom-color: var(--brass); }
.st-rank-count {
  font-family: var(--mono);
  font-size: var(--text-xs);
  color: var(--brass);
  white-space: nowrap;
}

/* ---------- venue meta list under the bar chart ---------- */
.st-venue-meta {
  list-style: none;
  margin: var(--space-4) 0 0;
  padding: 0;
  font-size: var(--text-xs);
  columns: 1;
}
.st-venue-meta li { padding: var(--space-1) 0; }
.st-venue-meta-name {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}
.st-venue-meta-name:hover { border-bottom-color: var(--brass); }
@media (min-width: 640px) { .st-venue-meta { columns: 2; column-gap: var(--space-6); } }

/* ---------- per-year coverage bar chart (vertical bars) ---------- */
.st-yearchart-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: var(--space-4) var(--space-3) var(--space-2);
}
.st-yearchart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 180px;
  min-width: max-content;
}
.st-vbar {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 10px;
  height: 100%;
  flex: none;
}
.st-vbar-fill {
  width: 100%;
  background: var(--cool);
  border-radius: 2px 2px 0 0;
  min-height: 1px;
}
.st-vbar-year {
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%) rotate(0deg);
  font-family: var(--mono);
  font-size: 8px;
  color: var(--faint);
  white-space: nowrap;
  display: none;
}
/* Only every 5th year label would fit; showing all of them via title/aria is enough for a11y,
   so visible labels are trimmed with nth-child on wider screens only, to avoid a smear of text. */
.st-vbar:nth-child(5n+1) .st-vbar-year { display: block; }
.st-yearchart-wrap { padding-bottom: var(--space-6); }

/* ---------- gap meters ---------- */
.st-gap-list { display: flex; flex-direction: column; gap: var(--space-4); }
.st-gap-row { font-size: var(--text-sm); }
.st-gap-top {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-1);
  color: var(--text);
}
.st-gap-num { font-family: var(--mono); color: var(--brass); }
.st-gap-track {
  height: 8px;
  border-radius: 4px;
  background: var(--surface-3);
  overflow: hidden;
}
.st-gap-fill { display: block; height: 100%; background: var(--cool-dim); }

/* ---------- cities table ---------- */
.st-city-table td:not(:first-child), .st-city-table th:not(:first-child) {
  font-family: var(--mono);
  font-size: var(--text-xs);
}

/* ---------- responsive down to 360px ---------- */
@media (max-width: 480px) {
  .st-hbar-row { grid-template-columns: minmax(56px, 9ch) minmax(0, 1fr) auto; gap: var(--space-2); }
  .st-hbar-label { font-size: var(--text-xs); }
  .st-stat-row { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
  .st-stat-value { font-size: var(--text-xl); }
  .st-yearchart { height: 140px; }
}

@media (prefers-reduced-motion: reduce) {
  .st-hbar-fill, .st-vbar-fill, .st-gap-fill { transition: none; }
}
