/* Locality pages /locality/ (scripts/locality/README.md) */
:root {
    --ink: #222;
    --muted: #666;
    --line: #ddd;
    --bg: #fafaf7;
    --card: #fff;
    --accent: #F28C28;
    --accent-dark: #B35900;
    --nat: #888;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.5 Arial, "Helvetica Neue", sans-serif;
}
a { color: var(--accent-dark); }
main { max-width: 860px; margin: 0 auto; padding: 0 16px 32px; }
.top-bar {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    max-width: 860px; margin: 0 auto; padding: 10px 16px; font-size: 14px;
}
.langs button {
    font: inherit; font-size: 14px; background: none; border: 1px solid var(--line); border-radius: 14px;
    padding: 2px 10px; cursor: pointer; color: var(--ink);
}
.langs button:hover { border-color: var(--accent); }
.langs button::before { content: "\1F310\FE0E  "; font-size: 12px; color: var(--muted); }

.head { display: flex; gap: 20px; align-items: stretch; margin: 8px 0 20px; }
.head-text { flex: 1 1 auto; min-width: 0; }
h1 { font-size: 32px; line-height: 1.2; margin: 0 0 4px; }
.code { color: var(--muted); margin: 0 0 10px; font-size: 14px; }
.note {
    background: #fff6ea; border-inline-start: 4px solid var(--accent); padding: 8px 12px; margin: 0;
    font-size: 15px;
}
.locmap { flex: 0 0 260px; height: 200px; border-radius: 6px; overflow: hidden; background: #e6e9ea; }

h3 { font-size: 16px; margin: 24px 0 8px; }
/* newest first, from the right in every language, like the turnout chart: 2 rows of 4 past elections on a
   desktop, with the 26th beside them over both rows; 3 rows of 3 on a phone */
.strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; direction: rtl; }
.strip:has(.live) { grid-template-columns: repeat(5, 1fr); }
.strip .live { grid-row: span 2; justify-content: center; }
[dir="ltr"] .strip .cell { direction: ltr; }
[dir="rtl"] .strip .cell { direction: rtl; }
.strip .cell {
    display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--ink);
    background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 6px; font-size: 12px;
}
.strip .k { color: var(--muted); }
.strip .w {
    unicode-bidi: plaintext;
    color: #fff; border-radius: 4px; padding: 2px 6px; font-weight: bold; font-size: 13px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.strip .live .w:not([style]) { color: var(--muted); background: none; font-weight: normal; }
.strip .gap .w { color: var(--muted); background: none; font-weight: normal; }

.turnout { width: 100%; height: auto; display: block; direction: ltr; }   /* text-anchor start/end flip under rtl */
.turnout .grid { stroke: var(--line); stroke-width: 1; }
.turnout .ax { fill: var(--muted); font-size: 12px; }
.turnout polyline { fill: none; stroke-width: 2.5; }
.turnout polyline.loc { stroke: var(--accent); }
.turnout polyline.nat { stroke: var(--nat); stroke-dasharray: 5 4; stroke-width: 2; }
.turnout circle.loc { fill: var(--accent); }
.turnout circle.nat { fill: var(--nat); }
.turnout .val { fill: var(--accent-dark); font-size: 12px; font-weight: bold; }
.legend { font-size: 13px; color: var(--muted); margin: 4px 0 0; }
.key { display: inline-block; width: 18px; height: 3px; vertical-align: middle; margin-inline: 8px 4px; }
.key.loc { background: var(--accent); }
.key.nat { background: repeating-linear-gradient(90deg, var(--nat) 0 5px, transparent 5px 9px); }

.election { background: var(--card); border: 1px solid var(--line); border-radius: 8px; margin: 12px 0; padding: 0 14px; }
.election summary {
    display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 10px 0; list-style: none;
}
.election summary::-webkit-details-marker { display: none; }
.election summary::before { content: "\25B8"; color: var(--muted); }
.election[open] summary::before { content: "\25BE"; }
[dir="rtl"] .election summary::before { content: "\25C2"; }
[dir="rtl"] .election[open] summary::before { content: "\25BE"; }
.election h2 { font-size: 18px; margin: 0; flex: 1 1 auto; }
.election .top {
    color: #fff; border-radius: 4px; padding: 2px 8px; font-size: 13px; font-weight: bold;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; unicode-bidi: plaintext;
}
.election.empty h2 { color: var(--muted); }
.none { color: var(--muted); margin: 0 0 12px; }
.counting { color: var(--muted); font-size: 14px; margin: 0 0 8px; }

.stats { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 0 0 12px; }
.stats div { min-width: 0; }
.stats dt { color: var(--muted); font-size: 12px; }
.stats dd { margin: 0; font-weight: bold; }
.stats small { font-weight: normal; color: var(--muted); }

.bars { display: grid; grid-template-columns: minmax(120px, 34%) 1fr 56px 56px; gap: 4px 10px; align-items: center; font-size: 14px; }
.bars-head, .bar-row { display: contents; }
.bars-head span { color: var(--muted); font-size: 12px; }
.bars-head span:first-child { grid-column: 1 / 3; }
.threshold {
    grid-column: 1 / -1; border-top: 1px dashed #bbb; margin-top: 4px; padding-top: 2px;
    font-size: 11px; color: var(--muted);
}
.bar-row.below .lbl { color: var(--muted); }
.bar-row.below .track i { opacity: 0.6; }
.lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lbl b { display: inline-block; min-width: 2.6em; color: var(--muted); font-weight: normal; }
.track { position: relative; height: 14px; background: #f0f0ee; border-radius: 2px; }
.track i { position: absolute; inset-block: 0; inset-inline-start: 0; border-radius: 2px; }
.n { text-align: end; font-variant-numeric: tabular-nums; }
.n.nat { color: var(--muted); }
.maplink { font-size: 13px; margin: 10px 0 12px; }

footer { color: var(--muted); font-size: 13px; margin-top: 28px; }
footer p { margin: 4px 0; }
/* the site's logo and credit */
.top-bar nav { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.logo img { display: block; }
footer .brand { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }

/* index */
.index input[type=search] {
    width: 100%; font: inherit; font-size: 18px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
    margin: 8px 0 12px;
}
.localities { list-style: none; padding: 0; margin: 0; columns: 3 180px; column-gap: 24px; }
.localities li { break-inside: avoid; padding: 2px 0; }
.localities small { color: var(--muted); font-size: 12px; }
.no-match { color: var(--muted); }

@media (max-width: 600px) {
    .head { flex-direction: column; }
    .locmap { flex-basis: auto; height: 180px; }
    h1 { font-size: 26px; }
    .turnout .ax { font-size: 20px; }
    .turnout .val { font-size: 17px; }
    .strip, .strip:has(.live) { grid-template-columns: repeat(3, 1fr); }
    .strip .live { grid-row: auto; }
    .bars { grid-template-columns: minmax(110px, 46%) 1fr 48px; }
    .election h2 { font-size: 16px; }
    .bars .nat, .bars-head span:last-child { display: none; }
}
