/* IRC Precinct Results Map — all rules are scoped to .ircmap */
.ircmap {
  --ircmap-ink: #1d2a2f;
  --ircmap-muted: #5c6a6e;
  --ircmap-line: #d8d0bf;
  --ircmap-panel: #fffdf8;
  --ircmap-sea: #eef3f2;
  --ircmap-stroke: #0d1518;
  color: var(--ircmap-ink);
  margin: 1.5em 0;
  max-width: var(--ircmap-max-w, 100%);
  font-size: 16px;
  line-height: 1.4;
}
.ircmap *, .ircmap *::before, .ircmap *::after { box-sizing: border-box; }

.ircmap-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.ircmap-title { margin: 0; line-height: 1.15; flex: 1 1 auto; min-width: 0; max-width: 100%; font-size: var(--ircmap-header-fs, 28px); overflow-wrap: anywhere; }
.ircmap-title[hidden] { display: none; }
.ircmap-align-center { flex-direction: column; align-items: center; }
.ircmap-align-right { flex-direction: row-reverse; }
.ircmap-race { max-width: 100%; padding: 6px 10px; border: 1px solid var(--ircmap-line); border-radius: 8px; background: var(--ircmap-panel); color: var(--ircmap-ink); font: inherit; font-size: .9em; }

.ircmap-body { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 820px) { .ircmap-body { grid-template-columns: minmax(0, 1fr) var(--ircmap-legend-w, 280px); } }

.ircmap-mapwrap { position: relative; background: var(--ircmap-sea); border: 1px solid var(--ircmap-line); border-radius: 12px; overflow: hidden; }
.ircmap-svg { display: block; width: 100%; height: auto; max-height: var(--ircmap-map-h, 720px); }
.ircmap-p { stroke: var(--ircmap-stroke); stroke-width: var(--ircmap-stroke-w, 1.2px); vector-effect: non-scaling-stroke; stroke-linejoin: round; cursor: pointer; transition: fill .4s ease, filter .12s; outline: none; }
.ircmap-p:hover, .ircmap-p:focus { filter: brightness(.9); }
.ircmap-svg text { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-weight: 700; fill: #1d2a2f; paint-order: stroke; stroke: #ffffffd9; stroke-width: 3px; stroke-linejoin: round; text-anchor: middle; dominant-baseline: middle; pointer-events: none; }

.ircmap-tip { position: absolute; z-index: 5; min-width: min(12em, calc(100vw - 40px)); max-width: min(18em, calc(100vw - 40px)); background: var(--ircmap-panel); color: var(--ircmap-ink); border: 1px solid var(--ircmap-line); border-radius: 10px; padding: 8px 10px; font-size: var(--ircmap-tip-fs, 85%); box-shadow: 0 6px 20px rgba(0,0,0,.15); pointer-events: none; }
.ircmap-tip[hidden] { display: none; }
.ircmap-tip > strong { display: block; margin-bottom: 4px; }
.ircmap-tr { display: flex; align-items: center; gap: 6px; padding: 1px 0; }
.ircmap-tn { flex: 1; }
.ircmap-tv { font-variant-numeric: tabular-nums; white-space: nowrap; }

.ircmap-legend { font-size: var(--ircmap-legend-fs, 100%); display: flex; flex-direction: column; gap: 8px; align-content: start; }
.ircmap-li { display: flex; align-items: flex-start; gap: 8px; }
.ircmap-lt { display: flex; flex-direction: column; }
.ircmap-ln { color: var(--ircmap-muted); font-size: .85em; }
.ircmap-sw { flex: none; width: 1em; height: 1em; margin-top: .15em; border: 1px solid var(--ircmap-stroke); border-radius: 3px; }

.ircmap-status { margin: 8px 0 0; color: var(--ircmap-muted); font-size: var(--ircmap-status-fs, 80%); }

/* ---------- sub-heading under a fixed header ---------- */
.ircmap-sub { flex-basis: 100%; color: var(--ircmap-muted); font-weight: 600; font-size: .95em; margin-top: -4px; }
.ircmap-sub[hidden] { display: none; }

/* ---------- pagination ---------- */
.ircmap-pager { font-size: var(--ircmap-nav-fs, 100%); display: flex; align-items: center; gap: 6px; margin: 0 0 10px; flex-wrap: nowrap; }
.ircmap-pager[hidden] { display: none; }
.ircmap-pages { display: flex; gap: 6px; flex: 1 1 auto; overflow-x: auto; scrollbar-width: thin; padding: 2px; }
.ircmap .ircmap-pg { flex: none; min-width: 2.2em; height: 2.2em; padding: 0 .7em; border: 1px solid var(--ircmap-line); border-radius: 999px; background: var(--ircmap-panel); color: var(--ircmap-ink); font: inherit; font-size: .9em; font-weight: 600; line-height: 1; cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.ircmap .ircmap-pg:hover { border-color: var(--ircmap-ink); }
.ircmap .ircmap-pg:focus-visible { outline: 2px solid #2f6fb5; outline-offset: 2px; }
.ircmap .ircmap-pg.is-current { background: var(--ircmap-ink); border-color: var(--ircmap-ink); color: #fff; }
.ircmap .ircmap-prev, .ircmap .ircmap-next { font-size: 1.25em; padding: 0; width: 1.9em; min-width: 1.9em; height: 1.9em; }
.ircmap-pager-names .ircmap-page { white-space: nowrap; border-radius: 8px; max-width: min(18em, 70vw); overflow: hidden; text-overflow: ellipsis; }
.ircmap-pager-dots .ircmap-page { min-width: 0; width: .8em; height: .8em; padding: 0; align-self: center; }
.ircmap-pager-dots .ircmap-pages { justify-content: center; align-items: center; }
.ircmap-count { flex: none; color: var(--ircmap-muted); font-size: .8em; font-variant-numeric: tabular-nums; min-width: 3.5em; text-align: right; }

/* ---------- slide between races ---------- */
.ircmap-viewport { overflow: hidden; }
.ircmap-body { --ircmap-dir: 1; }
.ircmap-body.ircmap-out { transition: transform .22s ease-in, opacity .22s ease-in; transform: translateX(calc(var(--ircmap-dir) * -40px)); opacity: 0; }
.ircmap-body.ircmap-in-start { transition: none; transform: translateX(calc(var(--ircmap-dir) * 40px)); opacity: 0; }
.ircmap-body.ircmap-in { transition: transform .28s ease-out, opacity .28s ease-out; transform: none; opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .ircmap-body.ircmap-out, .ircmap-body.ircmap-in, .ircmap-body.ircmap-in-start { transition: none; transform: none; }
}

/* ---------- dropdown navigation ---------- */
.ircmap-pager .ircmap-race { flex: 1 1 auto; min-width: 0; max-width: 520px; height: 2.4em; font-weight: 600; text-overflow: ellipsis; }
.ircmap-nav-both { flex-wrap: wrap; }
.ircmap-nav-both .ircmap-pages { order: 5; flex-basis: 100%; }
.ircmap-nav-both .ircmap-count { margin-left: auto; }

/* ---------- never wider than the screen ---------- */
.ircmap, .ircmap-body, .ircmap-mapwrap, .ircmap-legend, .ircmap-pager { min-width: 0; }
.ircmap-body > * { min-width: 0; }
.ircmap-lt, .ircmap-tn { overflow-wrap: anywhere; }

/* ---------- phones (600px wide or less) ----------
   Each size uses its phone value if one was set (…-m), otherwise the normal value.
   Headers with no phone size shrink automatically so fixed sizes never spill over. */
@media (max-width: 600px) {
  .ircmap { max-width: var(--ircmap-max-w-m, var(--ircmap-max-w, 100%)); margin: 1em 0; }
  .ircmap-title { font-size: var(--ircmap-header-fs-m, min(var(--ircmap-header-fs, 28px), 8vw)); }
  .ircmap-svg { max-height: var(--ircmap-map-h-m, var(--ircmap-map-h, 720px)); }
  .ircmap-legend { font-size: var(--ircmap-legend-fs-m, var(--ircmap-legend-fs, 100%)); }
  .ircmap-pager { font-size: var(--ircmap-nav-fs-m, var(--ircmap-nav-fs, 100%)); }
  .ircmap-tip { font-size: var(--ircmap-tip-fs-m, var(--ircmap-tip-fs, 85%)); }
  .ircmap-status { font-size: var(--ircmap-status-fs-m, var(--ircmap-status-fs, 80%)); }
  .ircmap-p { stroke-width: var(--ircmap-stroke-w-m, var(--ircmap-stroke-w, 1.2px)); }
  .ircmap-pager { flex-wrap: wrap; }
  .ircmap-pager .ircmap-race { flex: 1 1 60%; max-width: none; }
  .ircmap-count { min-width: 0; }
  .ircmap .ircmap-pg { min-width: 2.6em; height: 2.6em; }            /* finger-sized buttons */
  .ircmap .ircmap-prev, .ircmap .ircmap-next { width: 2.4em; min-width: 2.4em; height: 2.4em; }
}

/* Vote totals by precinct */
.ircmap-totals { margin: 10px 0 0; border: 1px solid var(--ircmap-line); border-radius: 10px; background: var(--ircmap-panel); color: var(--ircmap-ink); }
.ircmap-totals > summary { cursor: pointer; padding: 10px 12px; font-weight: 700; }
.ircmap-tw { overflow-x: auto; padding: 0 8px 10px; max-height: 70vh; overflow-y: auto; }
.ircmap-tt { border-collapse: collapse; width: 100%; font-size: 90%; font-variant-numeric: tabular-nums; }
.ircmap-tt th, .ircmap-tt td { padding: 5px 8px; border-bottom: 1px solid var(--ircmap-line); text-align: right; white-space: nowrap; }
.ircmap-tt th:first-child { text-align: left; }
.ircmap-tt thead th { position: sticky; top: 0; background: var(--ircmap-panel); z-index: 1; vertical-align: bottom; }
.ircmap-tt thead .ircmap-sw { display: inline-block; vertical-align: -1px; }
.ircmap-tt tbody tr { cursor: pointer; }
.ircmap-tt tbody tr:hover, .ircmap-tt tbody tr:focus { background: rgba(0,0,0,.05); outline: none; }
.ircmap-tt td.ircmap-lead { font-weight: 700; }
.ircmap-tt .ircmap-ttotc { font-weight: 700; }
.ircmap-tt tfoot th, .ircmap-tt tfoot td { font-weight: 700; border-top: 2px solid var(--ircmap-line); border-bottom: 0; }
.ircmap-ttot { border-top: 1px solid var(--ircmap-line); margin-top: 4px; padding-top: 4px; font-weight: 700; }
