/* /election-map — results by election district. Loaded after /style.css. */
.election-map { max-width: 1080px; margin: 0 auto; padding: 36px 20px 70px; font-family: 'PT Sans', sans-serif; }
.election-map h1 { font-family: 'Playfair Display', serif; font-weight: 900; font-size: clamp(32px, 6vw, 52px); line-height: 1.08; letter-spacing: -.02em; margin: 8px 0 14px; }
.election-map h2 { font-family: 'Playfair Display', serif; font-weight: 700; font-size: clamp(24px, 4vw, 32px); line-height: 1.15; margin: 0; }
.election-map h3 { font-family: 'Playfair Display', serif; font-weight: 700; font-size: 24px; line-height: 1.2; margin: 4px 0 14px; }
.em-eyebrow, .em-overline, .election-map label { font-weight: 700; letter-spacing: .12em; font-size: 11px; text-transform: uppercase; color: #a30f27; }
.em-overline { margin-bottom: 6px; }
.em-deck { font-family: 'Lora', Georgia, serif; font-size: 18px; line-height: 1.55; color: #444; max-width: 640px; margin: 0 0 14px; }
.em-deck a, .election-map a { color: #c41230; }
.em-notice { display: flex; align-items: center; gap: 9px; font-size: 14px; margin: 0 0 26px; color: #444; flex-wrap: wrap; }
.em-subtle { font-size: 13.5px; line-height: 1.5; color: #666; margin: 8px 0; }
.em-status { font-size: 14px; color: #555; margin: 12px 0; min-height: 1.2em; }
.em-status[hidden] { display: none; }
.em-error { color: #a30f27; font-weight: 700; }

/* controls */
.em-controls { display: flex; flex-wrap: wrap; gap: 18px 24px; align-items: flex-end; background: #fff; border: 2px solid #1c1c1c; padding: 18px 22px; }
.em-field[hidden] { display: none; }
.em-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1 1 220px; max-width: 340px; }
.election-map select { font: 600 16px 'PT Sans', sans-serif; color: #1a1a1a; background: #fff; border: 1px solid #aaa; border-radius: 4px; padding: 11px 12px; width: 100%; }
.election-map select:disabled { opacity: .6; }
.election-map button { font-family: 'PT Sans', sans-serif; }
.election-map :focus-visible { outline: 3px solid #1a1a1a; outline-offset: 2px; }

/* sections */
.em-town, .em-explore, .em-compare { padding: 40px 0; border-bottom: 1px solid #d9d4c8; }
.em-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.em-scope { display: inline-flex; border: 2px solid #1c1c1c; border-radius: 4px; overflow: hidden; }
.em-scope[hidden] { display: none; }
.em-scope button { background: #fff; border: 0; padding: 9px 14px; font-weight: 700; font-size: 14px; cursor: pointer; color: #1a1a1a; }
.em-scope button + button { border-left: 2px solid #1c1c1c; }
.em-scope button[aria-pressed="true"] { background: #1c1c1c; color: #fff; }
.em-scope button:disabled { color: #999; background: #f0ede6; cursor: not-allowed; }

/* result rows */
.em-result { display: grid; grid-template-columns: minmax(140px, 1fr) 2fr 84px; align-items: center; gap: 16px; padding: 11px 0; border-bottom: 1px solid #e4dfd3; font-size: 15px; }
.em-name { line-height: 1.3; }
.em-party { color: #666; font-size: 13px; white-space: nowrap; }
.em-party::before { content: '· '; }
.em-bar { height: 10px; background: #e7e3da; border-radius: 10px; overflow: hidden; }
.em-fill { height: 100%; border-radius: 10px; }
.em-value { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.em-value small { display: block; font-size: 12px; color: #666; font-weight: 400; }

.em-seats { font-weight: 700; font-size: 15px; color: #1a1a1a; margin: 8px 0 4px; }
.em-seats[hidden] { display: none; }
.em-intro { font-size: 15px; line-height: 1.5; color: #333; margin: 12px 0 0; }
.em-rhead { display: flex; justify-content: space-between; gap: 12px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #666; padding: 10px 0 4px; border-bottom: 2px solid #1c1c1c; }
.em-swipe { display: none; font-size: 12.5px; font-weight: 700; color: #a30f27; margin: 6px 0 0; text-align: right; }
.em-card .em-buttons { margin: 0 0 14px; }

.em-scope-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.em-scope-note { font-size: 12px; color: #666; }
.em-scope-note[hidden] { display: none; }
.em-jump { margin: 0 0 14px; font-weight: 700; font-size: 15px; }
.em-jump[hidden] { display: none; }
.em-selected { margin: 10px 0 0; padding: 9px 12px; background: #fbe9ec; border-left: 4px solid #c41230; font-size: 14px; font-weight: 700; }
.em-selected[hidden] { display: none; }
.em-find { margin: 14px 0 12px; }

/* map area */
.em-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 28px; margin-top: 18px; align-items: start; }
.em-map { position: relative; background: #fff; border: 1px solid #d3cec1; overflow: hidden; }
#em-map { position: relative; }
#em-map svg { display: block; width: 100%; height: auto; max-height: 560px; }
.em-district { stroke: #6b6b65; stroke-width: 1.2; vector-effect: non-scaling-stroke; cursor: pointer; fill: #e7e3dc; }
.em-district.plain { fill: #e7e3dc; }
.em-district.no-data { fill: url(#em-hatch); }
.em-district:hover, .em-district:focus-visible { stroke: #111; stroke-width: 3; outline: none; }
.em-district.in-town { stroke: #8a0f24; stroke-width: 2.4; }
.em-district.is-selected { stroke: #111; stroke-width: 3.5; }
.em-roads path { fill: none; stroke: #fff; stroke-width: 2; opacity: .85; vector-effect: non-scaling-stroke; }
.em-roads { pointer-events: none; }
.em-road-label { position: absolute; transform: translate(-50%, -50%); font: 700 10.5px 'PT Sans', sans-serif; color: #252525; text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff; pointer-events: none; white-space: nowrap; }
.em-town-chip { position: absolute; left: 8px; bottom: 8px; background: #fff; border: 2px solid #8a0f24; border-radius: 3px; padding: 3px 8px; font: 700 12px 'PT Sans', sans-serif; color: #8a0f24; pointer-events: none; }
.em-town-chip:empty { display: none; }
.em-north { position: absolute; top: 8px; right: 10px; display: flex; flex-direction: column; align-items: center; font: 700 13px/1 'PT Sans', sans-serif; color: #1a1a1a; pointer-events: none; text-shadow: 0 0 3px #fff, 0 0 3px #fff; }
.em-north span + span { font-size: 18px; }
.em-zoom { position: absolute; top: 10px; left: 10px; display: flex; gap: 4px; z-index: 1; }
.em-zoom[hidden] { display: none; }
.em-zoom button { background: #fff; border: 1px solid #777; border-radius: 3px; padding: 6px 11px; cursor: pointer; font-weight: 700; font-size: 16px; min-width: 38px; min-height: 38px; }
.em-zoom button:last-child { font-size: 13px; }
#em-map[data-type] svg { cursor: grab; max-height: 680px; }

/* legend */
.em-legend { font-size: 13px; color: #404040; line-height: 1.45; margin-top: 14px; }
.em-legend p { margin: 6px 0 10px; }
.em-bands { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.em-bands span { display: block; height: 14px; border: 1px solid rgba(0, 0, 0, .15); }
.em-bands.em-bands5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.em-bands small { display: block; font-size: 11px; white-space: nowrap; margin-top: 2px; }
.em-ends { display: flex; justify-content: space-between; font-weight: 700; margin-top: 6px; }
.em-leaders { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.em-sw { display: inline-block; width: 14px; height: 14px; margin-right: 8px; vertical-align: -2px; border: 1px solid rgba(0, 0, 0, .2); }
.em-leaders small { color: #666; margin-left: 4px; }

/* district buttons, finder */
.em-buttons { display: flex; flex-wrap: wrap; gap: 7px; margin: 14px 0; }
.em-buttons[hidden] { display: none; }
.em-buttons button { min-width: 42px; height: 42px; padding: 0 8px; background: #fff; border: 1px solid #aaa; border-radius: 4px; font-weight: 700; font-size: 15px; cursor: pointer; color: #1a1a1a; }
.em-buttons button.is-active { background: #c41230; border-color: #c41230; color: #fff; }
.em-buttons button.no-shape { border-style: dashed; }
.em-find { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 14px 0; }
.em-find[hidden] { display: none; }
.em-find-label { font-weight: 700; font-size: 13px; width: 100%; }
.em-find select { flex: 1 1 150px; width: auto; max-width: 260px; }

/* selection card */
.em-card { background: #fff; border: 2px solid #1c1c1c; padding: 22px 24px; position: sticky; top: 14px; }
.em-card .em-result { grid-template-columns: 1fr 84px; }
.em-card .em-bar { display: none; }

#em-card { scroll-margin-top: 12px; }
#em-card:focus { outline: none; }
.em-flash { animation: em-flash 1.4s ease-out; }
@keyframes em-flash { 0%, 35% { box-shadow: 0 0 0 5px #c41230; } 100% { box-shadow: 0 0 0 5px rgba(196,18,48,0); } }
@media (prefers-reduced-motion: reduce) { .em-flash { animation: none; } }

/* compare table */
.em-table-wrap { overflow-x: auto; margin-top: 12px; border: 1px solid #d3cec1; background: #fff; }
.em-table { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
.em-table th, .em-table td { padding: 9px 12px; border-bottom: 1px solid #e4dfd3; text-align: right; white-space: nowrap; }
.em-table thead th { background: #1c1c1c; color: #fff; font-weight: 700; font-size: 12px; position: sticky; top: 0; }
.em-table th[scope="row"], .em-table thead th:first-child { text-align: left; position: sticky; left: 0; background: #fff; z-index: 1; white-space: normal; min-width: 108px; }
.em-table thead th:first-child { background: #1c1c1c; }
.em-table td small { display: block; font-size: 11px; color: #666; }
.em-table td.is-lead { font-weight: 700; background: #f6f1e4; }
.em-table tr.is-selected th, .em-table tr.is-selected td { background: #fbe9ec; }
.em-table tr.em-total th, .em-table tr.em-total td { font-weight: 700; border-top: 2px solid #1c1c1c; background: #f4f1eb; }
.em-table tr.em-unassigned th, .em-table tr.em-unassigned td { color: #555; font-style: italic; }
.em-table button { background: none; border: 0; padding: 0; color: #c41230; font-weight: 700; font-size: 14px; cursor: pointer; text-align: left; text-decoration: underline; text-underline-offset: 2px; }

.em-about { margin-top: 36px; max-width: 760px; font-family: 'Lora', Georgia, serif; font-size: 14px; line-height: 1.65; color: #555; }
.em-about strong { font-family: 'PT Sans', sans-serif; color: #222; }

.er-map-link { margin-top: 10px; }

@media (max-width: 760px) {
  .election-map { padding: 26px 16px 56px; }
  .em-grid { grid-template-columns: 1fr; gap: 20px; }
  .em-card { position: static; padding: 18px; }
  .em-swipe { display: block; }
  /* Selected district's results first: card, then townwide totals, then the map. */
  .election-map { display: flex; flex-direction: column; }
  .em-card { order: 1; }
  .em-town { order: 2; padding: 26px 0; }
  .em-explore, .em-grid, .em-left { display: contents; }
  .em-head { order: 3; padding-top: 26px; border-top: 1px solid #d9d4c8; }
  .em-intro { order: 3; }
  .em-left > * { order: 4; }
  .em-compare { order: 5; }
  .em-wy-summary { order: 6; }
  .em-about { order: 7; }
  .em-controls { padding: 16px; }
  .em-controls { gap: 12px; }
  .em-field { flex: 1 1 100%; max-width: none; }
  .em-field select { font-size: 15px; padding: 9px 8px; }
  .em-notice { margin-bottom: 16px; }
  .em-deck { font-size: 16px; }
  .em-result { grid-template-columns: 1fr 1fr 74px; gap: 8px; font-size: 14px; }
  .em-bands small { font-size: 9.5px; }
  .em-scope { width: 100%; }
  .em-scope-wrap { width: 100%; align-items: flex-start; }
  .em-scope button { flex: 1; }
  .em-table th, .em-table td { padding: 8px 9px; font-size: 13px; }
  .em-table th[scope="row"], .em-table thead th:first-child { min-width: 92px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
