/* Quem ganhou aqui? — newsroom results-desk styling.
   Neutral ink on paper; colour is reserved for parties. Hairline rules, not cards.
   Desktop: split app (scrolling panel + full-height map). Mobile: one column,
   sticky scope tabs, bottom action bar, full-screen map on demand. */
:root {
  --paper: #ffffff;
  --paper-2: #f4f4f2;
  --ink: #111214;
  --ink-2: #4b4f56;
  --ink-3: #80858d;
  --rule: #e3e3e0;
  --rule-strong: #111214;
  --accent: #b3261e;      /* used only for focus/links/"you" pin */
  --pos: #1b7f3b;
  --neg: #b3261e;
  --font: "Libre Franklin", "Helvetica Neue", Arial, sans-serif;
  --panel-w: 480px;
  --bar-h: 48px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #111214; --paper-2: #1b1c1f; --ink: #ececea; --ink-2: #b7bac0; --ink-3: #868b93;
    --rule: #2b2d31; --rule-strong: #ececea; --accent: #ff6b5e; --pos: #4cc27a; --neg: #ff7a6e;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #111214; --paper-2: #1b1c1f; --ink: #ececea; --ink-2: #b7bac0; --ink-3: #868b93;
  --rule: #2b2d31; --rule-strong: #ececea; --accent: #ff6b5e; --pos: #4cc27a; --neg: #ff7a6e;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 15px/1.45 var(--font); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.show-s { display: none; }

/* ── top bar ─────────────────────────────── */
.bar { height: var(--bar-h); display: flex; align-items: center; gap: 14px; padding: 0 20px; border-bottom: 1px solid var(--rule-strong); background: var(--paper); position: relative; z-index: 5; }
.word { font-weight: 800; font-size: 17px; letter-spacing: -.02em; text-decoration: none; white-space: nowrap; }
.bar-meta { color: var(--ink-3); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sep { margin: 0 2px; }

/* ── desktop app frame ───────────────────── */
.app { display: grid; grid-template-columns: var(--panel-w) minmax(0, 1fr); height: calc(100vh - var(--bar-h)); height: calc(100dvh - var(--bar-h)); }
.panel { overflow-y: auto; overflow-x: hidden; border-right: 1px solid var(--rule); padding: 28px 28px 0; scrollbar-width: thin; overscroll-behavior: contain; }
.mapcol { position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: var(--paper-2); z-index: 0; }

/* ── intro + search ──────────────────────── */
h1 { font-size: 30px; line-height: 1.12; letter-spacing: -.025em; font-weight: 800; margin: 0 0 10px; max-width: 18ch; }
.intro p { margin: 0 0 22px; color: var(--ink-2); max-width: 40ch; }
body:not(.landing) .intro, body:not(.landing) .landing-only { display: none; }

.search { display: grid; gap: 10px; }
.field { position: relative; display: flex; align-items: stretch; border: 1.5px solid var(--ink); background: var(--paper); }
.field:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.field input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 12px 12px; font-size: 16px; outline: none; }
.field input::-webkit-search-cancel-button { display: none; }
.kbd { align-self: center; font: 600 11px/1 var(--font); color: var(--ink-3); border: 1px solid var(--rule); padding: 3px 6px; margin-right: 8px; }
.go { background: var(--ink); color: var(--paper); font-weight: 700; padding: 0 18px; letter-spacing: .01em; }
.go:hover { background: var(--ink-2); }
.geo { justify-self: start; display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: 14px; color: var(--ink-2); padding: 4px 0; }
.geo:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.suggest { position: absolute; z-index: 1000; left: -1.5px; right: -1.5px; top: 100%; list-style: none; margin: 0; padding: 0; background: var(--paper); border: 1.5px solid var(--ink); border-top: 0; max-height: 50vh; overflow: auto; }
.suggest li { padding: 10px 12px; cursor: pointer; border-top: 1px solid var(--rule); }
.suggest li b { display: block; font-weight: 600; }
.suggest li span { font-size: 13px; color: var(--ink-3); }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--paper-2); }
.status { min-height: 1.4em; margin: 10px 0 0; font-size: 14px; color: var(--ink-2); }
.status.err { color: var(--neg); }
.status.busy::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 8px; background: var(--ink); animation: pulse 1s ease-in-out infinite; vertical-align: 0; }
@keyframes pulse { 50% { opacity: .2; } }

/* ── landing: national strip ─────────────── */
.nat { margin: 26px 0 0; border-top: 1px solid var(--rule-strong); padding-top: 12px; }
.nat h2, .h-sm { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin: 0 0 10px; color: var(--ink); }
.split { display: flex; height: 10px; margin: 10px 0 8px; }
.split i { display: block; height: 100%; }
.split i + i { border-left: 2px solid var(--paper); }
.nat-row { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.nat-row b { font-size: 22px; font-weight: 800; letter-spacing: -.02em; display: block; line-height: 1.1; }
.nat-row div:last-child { text-align: right; }
.nat-note { font-size: 13px; color: var(--ink-3); margin: 10px 0 0; }
.examples { margin: 22px 0 0; font-size: 14px; color: var(--ink-3); line-height: 1.7; }
.examples a { color: var(--ink-2); }

/* ── place header ────────────────────────── */
.place { padding-bottom: 14px; }
.place .lbl { font-size: 12px; color: var(--ink-3); margin: 0 0 4px; }
.place h2 { font-size: 22px; line-height: 1.2; letter-spacing: -.015em; margin: 0 0 6px; font-weight: 800; }
.place .addr { color: var(--ink-2); font-size: 14px; margin: 0; }
.place .facts { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 10px 0 0; padding: 0; list-style: none; font-size: 13px; color: var(--ink-2); }
.place .facts b { color: var(--ink); font-weight: 600; }
.place .row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.linkbtn { font-size: 13px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; color: var(--ink-2); white-space: nowrap; }
.linkbtn:hover { color: var(--ink); }

/* ── scope tabs ──────────────────────────── */
.scopes { position: sticky; top: 0; z-index: 4; background: var(--paper); display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--rule-strong); border-bottom: 1px solid var(--rule); margin: 0 0 4px; padding-top: 0; }
.scopes button { text-align: left; padding: 9px 10px 9px 0; border-bottom: 3px solid transparent; margin-bottom: -1px; min-width: 0; }
.scopes button span { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.scopes button em { display: block; font-style: normal; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.scopes button[aria-pressed="true"] { border-bottom-color: var(--ink); }
.scopes button[aria-pressed="true"] span, .scopes button[aria-pressed="true"] em { color: var(--ink); }
.scopes button:disabled { opacity: .35; cursor: default; }
.scopes button:not(:disabled):hover em { color: var(--ink); }

/* ── races ───────────────────────────────── */
.race { padding: 18px 0 16px; border-bottom: 1px solid var(--rule); }
.race-h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.race-h h3 { margin: 0; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.turns { display: flex; gap: 14px; font-size: 13px; }
.turns button { color: var(--ink-3); font-weight: 600; padding: 2px 0; border-bottom: 2px solid transparent; }
.turns button[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.turns .only { color: var(--ink-3); }
.lede { font-size: 17px; line-height: 1.35; margin: 8px 0 12px; letter-spacing: -.01em; }
.lede b { font-weight: 800; }
.lede .mark { font-size: 12px; font-weight: 700; color: var(--pos); white-space: nowrap; margin-left: 4px; }

/* fixed layout so long ballot names ellipsize instead of widening the table */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; table-layout: fixed; }
.tbl th.n { width: 70px; }
.tbl th { font-size: 11px; font-weight: 600; color: var(--ink-3); text-align: left; padding: 0 0 6px; border-bottom: 1px solid var(--rule); }
.tbl th.n, .tbl td.n { text-align: right; white-space: nowrap; }
.tbl td { padding: 7px 0 6px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.c { padding-right: 10px; overflow: hidden; }
.tbl td.n { padding-left: 12px; }
.tbl td.n small { display: block; font-size: 11.5px; color: var(--ink-3); }
.tbl .nm { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.tbl .nm strong { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tbl tr.win .nm strong { font-weight: 800; }
.tbl .pty { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; }
.tbl .el { font-size: 11px; font-weight: 700; color: var(--pos); white-space: nowrap; }
.tbl .bar { height: 4px; background: var(--paper-2); margin-top: 6px; }
.tbl .bar i { display: block; height: 100%; width: 0; transition: width .5s cubic-bezier(.2,.7,.2,1); }
.tbl td.here { font-weight: 700; }
.tbl td.base { color: var(--ink-3); }
.tbl .d { font-size: 11.5px; font-weight: 600; }
.tbl .d.up { color: var(--pos); }
.tbl .d.down { color: var(--neg); }
.race-f { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-top: 10px; font-size: 12.5px; color: var(--ink-3); }
.race-f .linkbtn { font-size: 12.5px; }
.race.empty p { color: var(--ink-3); font-size: 14px; margin: 8px 0 0; }

/* ── nearby ──────────────────────────────── */
.nearby { padding: 22px 0 6px; }
.nearby ol { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule-strong); }
.nearby li button { width: 100%; display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 10px; align-items: baseline; text-align: left; padding: 9px 0; border-bottom: 1px solid var(--rule); font-size: 14px; }
.nearby li button:hover strong { text-decoration: underline; text-underline-offset: 3px; }
.nearby li button[aria-current="true"] strong { font-weight: 800; }
.nearby .sw { width: 10px; height: 10px; align-self: center; }
.nearby strong { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nearby small { color: var(--ink-3); font-size: 12.5px; }

.foot { margin-top: 28px; padding: 16px 0 28px; border-top: 1px solid var(--rule); font-size: 12.5px; color: var(--ink-3); }
.foot p { margin: 0 0 8px; }

/* ── map chrome ──────────────────────────── */
.map-tools { position: absolute; z-index: 500; top: 12px; right: 12px; display: flex; gap: 8px; }
.map-tools select { background: var(--paper); border: 1.5px solid var(--ink); padding: 7px 10px; font-size: 13.5px; font-weight: 600; border-radius: 0; }
.map-close { display: none; }
.legend { position: absolute; z-index: 500; left: 12px; bottom: 22px; background: var(--paper); border: 1px solid var(--rule); padding: 8px 10px; font-size: 12.5px; display: grid; gap: 3px; max-width: 70%; }
.legend:empty { display: none; }
.legend b { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; margin-bottom: 2px; }
.legend span { display: flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; display: inline-block; flex: none; }
.legend i.you { border-radius: 50%; background: var(--paper); box-shadow: inset 0 0 0 3px var(--ink); }
.leaflet-container { font: inherit; background: var(--paper-2); }
.leaflet-tile-pane { filter: grayscale(1) contrast(.85) brightness(1.06); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .leaflet-tile-pane { filter: grayscale(1) invert(1) contrast(.75) brightness(.8); } }
:root[data-theme="dark"] .leaflet-tile-pane { filter: grayscale(1) invert(1) contrast(.75) brightness(.8); }
.leaflet-bar a, .leaflet-bar { border-radius: 0 !important; }
.leaflet-tooltip { border-radius: 0; font-size: 12.5px; line-height: 1.35; padding: 6px 8px; }
/* the searched address: an ink ring, deliberately not a party colour */
.you-pin { width: 16px; height: 16px; border-radius: 50%; background: var(--paper); border: 4px solid var(--ink); box-shadow: 0 0 0 2px var(--paper); }

.mobilebar { display: none; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(76px + env(safe-area-inset-bottom)); background: var(--ink); color: var(--paper); padding: 9px 14px; font-size: 14px; z-index: 3000; }

/* ── desktop refinements ─────────────────── */
@media (min-width: 900px) {
  .scopes button { padding-right: 12px; }
  body:not(.landing) .search { margin-bottom: 18px; }
  .tbl tbody tr { cursor: default; }
}
@media (min-width: 1400px) { :root { --panel-w: 540px; } }

/* ── mobile: one column, thumb-zone actions ─ */
@media (max-width: 899px) {
  .hide-s { display: none; }
  .show-s { display: inline; }
  .bar { padding: 0 16px; position: sticky; top: 0; }
  .app { display: block; height: auto; }
  .panel { overflow: visible; border: 0; padding: 20px 16px 0; }
  h1 { font-size: 26px; }
  .geo { justify-self: stretch; justify-content: center; border: 1.5px solid var(--rule); padding: 12px; color: var(--ink); }
  .app > .foot { margin: 24px 16px 0; }
  body.landing .mapcol { height: 56vh; margin: 8px 16px 0; border: 1px solid var(--rule); }
  body:not(.landing) .mapcol { display: none; }
  body.map-open .mapcol { display: block; position: fixed; inset: 0; z-index: 2000; margin: 0; border: 0; background: var(--paper); }
  body.map-open .map-close { display: inline-block; background: var(--ink); color: var(--paper); font-weight: 700; padding: 8px 14px; font-size: 13.5px; }
  body.map-open { overflow: hidden; }
  body:not(.landing) .search { position: sticky; top: var(--bar-h); z-index: 6; background: var(--paper); padding: 10px 0 8px; margin: -20px 0 0; }
  body:not(.landing) .geo { display: none; }
  .scopes { top: calc(var(--bar-h) + 66px); grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(96px, max-content); overflow-x: auto; scrollbar-width: none; margin: 0 -16px 4px; padding: 0 16px; }
  .scopes::-webkit-scrollbar { display: none; }
  .scopes button { padding: 10px 14px 9px 0; max-width: 170px; }
  .lede { font-size: 16px; }
  .tbl td { padding: 9px 0 8px; }
  .nearby li button { padding: 12px 0; }
  .mobilebar:not([hidden]) { display: grid; grid-template-columns: repeat(3, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 1500; background: var(--paper); border-top: 1px solid var(--rule-strong); padding-bottom: env(safe-area-inset-bottom); }
  .mobilebar button { padding: 14px 4px; font-weight: 700; font-size: 14px; }
  .mobilebar button + button { border-left: 1px solid var(--rule); }
  body:not(.landing) .foot { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  .legend { bottom: calc(16px + env(safe-area-inset-bottom)); font-size: 11.5px; padding: 6px 8px; }
  .map-tools { top: 8px; right: 8px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
