/*
 * The Civic Circle embed kit, v1. Loaded automatically into every embed.
 * Brand tokens in light and dark, readable defaults, and styles for the
 * kit's tooltip, legend, buttons, table and map pieces.
 */
:root {
  --paper: #f6f1e7;
  --ink: #1b1a17;
  --muted: #5f5c56;
  --rule: #d9d3c7;
  --panel: #ece6da;
  --fir: #2f4a3a;
  --river: #3e5c76;
  --brick: #a3402b;
  --signal: #e8b03a;
  /* Validated chart series (same as the site's charts). */
  --series-1: #2a6db0;
  --series-2: #d0552c;
  --series-3: #23875a;
  /* Neutral two-sided pair for contests: never party colors. */
  --side-a: #7b4ea3;
  --side-b: #14907d;
  --neutral: #d9d3c7;
  --focus: #e8b03a;
  --font-sans: "Libre Franklin", "Franklin Gothic Medium", "Helvetica Neue", Arial, sans-serif;
  --font-serif: Newsreader, Georgia, "Times New Roman", serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #161512;
    --ink: #efe9dc;
    --muted: #b3ada2;
    --rule: #3a3731;
    --panel: #211f1b;
    --series-1: #4d8fd0;
    --series-2: #d9673f;
    --series-3: #389f6c;
    --side-a: #9a72c4;
    --side-b: #2fa391;
    --neutral: #4a463e;
    color-scheme: dark;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.45;
}

body {
  padding: 12px;
}

h1,
h2,
h3 {
  margin: 0 0 6px;
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.15;
}

h2 {
  font-size: 1.25rem;
}

p {
  margin: 0 0 8px;
}

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

.civic-muted {
  color: var(--muted);
  font-size: 0.85rem;
}

.civic-num {
  font-variant-numeric: tabular-nums;
}

/* Buttons and toggles: large tap targets, visible focus. */
.civic-button,
button {
  min-height: 40px;
  padding: 8px 12px;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 2px;
  cursor: pointer;
}

button[aria-pressed="true"] {
  color: var(--paper);
  background: var(--ink);
  border-color: var(--ink);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Tooltip / detail panel. */
.civic-tooltip {
  position: fixed;
  z-index: 10;
  max-width: min(280px, calc(100vw - 24px));
  padding: 8px 10px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--ink);
  box-shadow: 0 2px 10px rgb(0 0 0 / 0.18);
  font-size: 0.85rem;
  pointer-events: none;
}

.civic-tooltip[hidden] {
  display: none;
}

.civic-detail {
  min-height: 3.2em;
  padding: 10px 12px;
  border-left: 3px solid var(--ink);
  background: var(--panel);
}

/* Legend. */
.civic-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 6px 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.civic-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.civic-legend i {
  display: inline-block;
  width: 14px;
  height: 10px;
  border-radius: 2px;
}

.civic-ramp {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  height: 10px;
  margin: 4px 0 2px;
}

/* Tables. */
.civic-table-wrap {
  overflow-x: auto;
}

table.civic-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.civic-table th,
.civic-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}

.civic-table td.num,
.civic-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.civic-table th button {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 600;
  color: inherit;
}

.civic-table th[aria-sort="ascending"] button::after {
  content: " ▲";
}

.civic-table th[aria-sort="descending"] button::after {
  content: " ▼";
}

input[type="search"] {
  width: 100%;
  min-height: 40px;
  margin: 0 0 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--muted);
  border-radius: 2px;
}

/* Maps. */
.civic-map {
  position: relative;
  width: 100%;
  height: 420px;
  background: var(--panel);
}

.maplibregl-ctrl-attrib {
  font-family: var(--font-sans);
  font-size: 11px;
}

.civic-source {
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--muted);
}

@media (min-width: 640px) {
  .civic-map {
    height: 520px;
  }
}
