/* Shared styles for the dataset explorers at /data/tgov/ and /data/tcs/.
   Committed to a single light look, matching the parent site (#faf8f8). */

.viz-root {
  color-scheme: light;
  --surface-1: #faf8f8;
  --surface-card: #ffffff;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #03396c;

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--surface-1);
  color: var(--text-primary);
}

body {
  font-family: 'Fira Sans', 'Trebuchet MS', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

.viz-wrap {
  width: 94%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 0 4rem;
}

.viz-breadcrumb {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}
.viz-breadcrumb a { color: var(--accent); text-decoration: none; }
.viz-breadcrumb a:hover { text-decoration: underline; }

h1.viz-title {
  font-family: Merriweather, Georgia, 'Times New Roman', Times, serif;
  font-size: 1.85rem;
  line-height: 1.25;
  margin: 0 0 0.35rem;
}

.viz-sub {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin: 0 0 1.5rem;
  max-width: 62ch;
}

/* ---- filter row: one row above everything it scopes ---- */

.viz-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  align-items: flex-start;
  padding: 1rem 1.15rem;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 1.25rem;
}

.viz-field { display: flex; flex-direction: column; gap: 0.4rem; }
.viz-field--grow { flex: 1 1 260px; min-width: 240px; }

.viz-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}

.viz-search {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.42rem 0.6rem;
  border: 1px solid var(--baseline);
  border-radius: 4px;
  background: var(--surface-card);
  color: var(--text-primary);
  width: 100%;
}
.viz-search:focus { outline: 2px solid var(--series-1); outline-offset: 1px; }

.viz-results {
  max-height: 168px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-top: 0.35rem;
}
.viz-results button {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 0.88rem;
  padding: 0.32rem 0.6rem;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
}
.viz-results button:hover:not(:disabled) { background: #eef4fb; }
.viz-results button:disabled { color: var(--text-muted); cursor: default; }
.viz-results .viz-empty {
  padding: 0.5rem 0.6rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.viz-years { display: flex; align-items: center; gap: 0.5rem; }
.viz-years input {
  font: inherit;
  font-size: 0.9rem;
  width: 5.2rem;
  padding: 0.42rem 0.5rem;
  border: 1px solid var(--baseline);
  border-radius: 4px;
  background: var(--surface-card);
  color: var(--text-primary);
}
.viz-years span { color: var(--text-muted); font-size: 0.85rem; }

.viz-toggles { display: flex; flex-direction: column; gap: 0.35rem; }
.viz-toggle {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
  cursor: pointer;
}

/* ---- selected chips (legend is always present for >= 2 series) ---- */

.viz-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1rem;
  min-height: 1.9rem;
}
.viz-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  padding: 0.25rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-card);
  color: var(--text-primary);
}
.viz-swatch {
  width: 11px; height: 11px;
  border-radius: 3px;
  flex: none;
}
.viz-chip button {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0 0 0.1rem;
  cursor: pointer;
}
.viz-chip button:hover { color: var(--text-primary); }

.viz-hint { font-size: 0.85rem; color: var(--text-muted); }

/* ---- chart ---- */

.viz-card {
  position: relative;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.85rem 0.6rem 0.4rem;
  margin-bottom: 1rem;
}

.viz-chart { display: block; width: 100%; height: auto; overflow: visible; }

.viz-grid line { stroke: var(--gridline); stroke-width: 1; }
.viz-axis line, .viz-axis path { stroke: var(--baseline); stroke-width: 1; }
.viz-axis text {
  fill: var(--text-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.viz-axis-title { fill: var(--text-secondary); font-size: 11.5px; }

.viz-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz-band { stroke: none; opacity: 0.12; }
.viz-endlabel { font-size: 11.5px; font-weight: 600; }

.viz-crosshair { stroke: var(--baseline); stroke-width: 1; pointer-events: none; }
.viz-dot { stroke: var(--surface-card); stroke-width: 2; pointer-events: none; }

.viz-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: 5px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.10);
  padding: 0.5rem 0.65rem;
  font-size: 0.83rem;
  min-width: 170px;
  opacity: 0;
  transition: opacity 0.1s;
  z-index: 5;
}
.viz-tooltip.is-on { opacity: 1; }
.viz-tooltip-year {
  font-weight: 700;
  margin-bottom: 0.3rem;
  font-variant-numeric: tabular-nums;
}
.viz-tooltip-row {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  white-space: nowrap;
}
.viz-tooltip-row .viz-val {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}
.viz-tooltip-row .viz-ci {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.viz-empty-state {
  padding: 3.5rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ---- table view (the WCAG-clean twin) ---- */

.viz-tablewrap { overflow-x: auto; margin-bottom: 1.5rem; }
table.viz-table {
  border-collapse: collapse;
  font-size: 0.85rem;
  width: 100%;
  background: var(--surface-card);
}
table.viz-table th, table.viz-table td {
  border-bottom: 1px solid var(--gridline);
  padding: 0.35rem 0.6rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
table.viz-table th { color: var(--text-secondary); font-weight: 600; }
table.viz-table th:first-child, table.viz-table td:first-child {
  text-align: left;
  font-variant-numeric: normal;
}
table.viz-table caption {
  caption-side: top;
  text-align: left;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding-bottom: 0.4rem;
}

/* ---- actions + notes ---- */

.viz-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 2rem; }
.viz-btn {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--baseline);
  border-radius: 4px;
  background: var(--surface-card);
  color: var(--text-primary);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.viz-btn:hover { background: #eef4fb; border-color: var(--series-1); }

.viz-notes {
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  max-width: 68ch;
}
.viz-notes h2 {
  font-family: Merriweather, Georgia, serif;
  font-size: 1.1rem;
  margin: 1.5rem 0 0.5rem;
  color: var(--text-primary);
}
.viz-notes h2:first-child { margin-top: 0; }
.viz-notes a { color: var(--accent); }
.viz-notes code {
  font-family: Hack, 'Source Code Pro', monospace;
  font-size: 0.85em;
  background: #f0eeee;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}
.viz-cite {
  background: var(--surface-card);
  border-left: 3px solid var(--series-1);
  padding: 0.7rem 0.9rem;
  font-size: 0.87rem;
  margin: 0.5rem 0;
}

@media (max-width: 620px) {
  .viz-filters { flex-direction: column; gap: 0.9rem; }
  h1.viz-title { font-size: 1.45rem; }
}

@media print, (forced-colors: active) {
  .viz-filters, .viz-actions { display: none; }
}
