/* Alberta Ridings – map page. Mobile first; desktop rules at the end.
   Design A "Survey" (chosen 2026-11-11): navy and amber. method.css uses the same tokens. */
:root {
  --ink: #14263a;
  --ink-2: #1f3650;
  --muted: #5b6672;
  --line: #dfe3e8;
  --paper: #f3f5f7;
  --white: #fff;
  --ucp: #2f6fb5;
  --ucp-l: #b5cdea;
  --ndp: #ee8a2b;
  --ndp-l: #fbd5ad;
  --ptp: #6b7280;
  --vac: #c5c9cf;
  --c89: #d11f2f;
  --hatch: repeating-linear-gradient(135deg, var(--vac) 0 4px, #7d8590 4px 6px);
  --accent: #f2b705;
  --warn-bg: #fff3c4;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(20, 38, 58, .18);
  --body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: var(--body);
  --bar-bg: var(--ink);
  --bar-fg: #fff;
  --logo-line: #fff;
  --logo-cut: var(--accent);
  --logo-fill: transparent;
  --notice-bg: rgba(20, 38, 58, .92);
  --notice-fg: #fff;
  --notice-line: transparent;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex; flex-direction: column;
  height: 100dvh; overflow: hidden;
  font: 16px/1.45 var(--body);
  color: var(--ink); background: var(--white);
  -webkit-text-size-adjust: 100%;
}
a { color: #1d4f91; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---- title bar ---- */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 6px 0 12px; min-height: 52px;
  background: var(--bar-bg); color: var(--bar-fg);
  position: relative; z-index: 5;
}
.brand { display: inline-flex; align-items: center; gap: 9px; color: inherit; text-decoration: none; min-width: 0; }
.logo { width: 24px; height: 32px; flex: none; overflow: visible; }
.logo .ab { fill: var(--logo-fill); stroke: var(--logo-line); stroke-width: 2; stroke-linejoin: round; }
.logo .cut { fill: none; stroke: var(--logo-cut); stroke-width: 1.6; stroke-linecap: round; }
.bname { font-family: var(--display); font-weight: 750; font-size: 1.12rem; line-height: 1.1; letter-spacing: .01em; white-space: nowrap; }
.bname small { display: none; font-family: var(--body); font-weight: 400; font-size: .74rem; letter-spacing: 0; opacity: .78; margin-top: 2px; }
.bar nav { display: flex; align-items: center; }
.bar nav a, .bar nav button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 9px;
  color: inherit; background: none; border: 0; text-decoration: none; cursor: pointer; font-size: .92rem;
}
.bar nav a:hover, .bar nav button:hover { text-decoration: underline; }
#open-help { width: 44px; padding: 0; }
#open-help svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

/* ---- layout ---- */
main { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
#mapwrap { position: relative; flex: 1; min-height: 0; }
#map { position: absolute; inset: 0; background: var(--paper); }
#status {
  position: absolute; left: 50%; bottom: 40px; transform: translateX(-50%);
  margin: 0; padding: 6px 12px; border-radius: 99px; font-size: .85rem;
  background: var(--white); box-shadow: var(--shadow); z-index: 3; max-width: 90%;
}
#status[hidden] { display: none; }
#status.err { background: #fde3e3; }

/* "Unofficial" badge: floats on the map, always shown */
.notice {
  position: absolute; top: 8px; left: 8px; z-index: 2; margin: 0;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px 5px 9px; border-radius: 99px; font-size: .78rem; line-height: 1.2;
  background: var(--notice-bg); color: var(--notice-fg); border: 1.5px solid var(--notice-line);
  box-shadow: 0 1px 6px rgba(0, 0, 0, .2); pointer-events: none;
}
.pulse { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.pulse::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--accent); animation: pulse 2.2s ease-out infinite; }
@keyframes pulse { from { transform: scale(1); opacity: .7; } to { transform: scale(3.2); opacity: 0; } }

/* name of the riding under the mouse (desktop) */
#hover {
  position: absolute; top: 0; left: 0; z-index: 3; pointer-events: none;
  padding: 3px 9px; border-radius: 6px; font-size: .82rem; font-weight: 650; white-space: nowrap;
  background: var(--ink); color: #fff; box-shadow: 0 1px 6px rgba(0, 0, 0, .25);
}
#hover[hidden] { display: none; }

/* ---- controls ---- */
#controls { padding: 6px 12px 8px; background: var(--white); border-bottom: 1px solid var(--line); z-index: 2; }
.ends { display: flex; justify-content: space-between; font-size: .8rem; font-weight: 600; }
#fade {
  -webkit-appearance: none; appearance: none;
  display: block; width: 100%; height: 44px; margin: 0; background: transparent; cursor: pointer;
}
#fade::-webkit-slider-runnable-track { height: 8px; border-radius: 4px; background: linear-gradient(90deg, #c9ced6, var(--ink)); }
#fade::-moz-range-track { height: 8px; border-radius: 4px; background: linear-gradient(90deg, #c9ced6, var(--ink)); }
#fade::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 44px; height: 44px; margin-top: -18px; border-radius: 50%;
  background: var(--white); border: 3px solid var(--ink); box-shadow: 0 1px 5px rgba(0,0,0,.3);
}
#fade::-moz-range-thumb {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--white); border: 3px solid var(--ink); box-shadow: 0 1px 5px rgba(0,0,0,.3);
}

#legend { font-size: .8rem; line-height: 1.7; min-height: 3.4em; }
#legend .lt { font-weight: 600; margin-right: 6px; }
#legend .li { display: inline-block; white-space: nowrap; margin-right: 10px; }
#legend .grp { display: inline-block; white-space: nowrap; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; border: 1px solid rgba(0,0,0,.15); }
.sw.UCP { background: var(--ucp); } .sw.UCP-close { background: var(--ucp-l); }
.sw.NDP { background: var(--ndp); } .sw.NDP-close { background: var(--ndp-l); }
.sw.PTP { background: var(--ptp); } .sw.Vacant { background: var(--hatch); }
#legend b { font-variant-numeric: tabular-nums; }
.lk { width: 26px; height: 10px; vertical-align: 0; margin-right: 4px; overflow: visible; }
.lk .k1 { stroke: #fff; stroke-width: 6; } .lk .k2 { stroke: var(--ink); stroke-width: 2.2; }
.lk path { fill: none; stroke-linejoin: round; stroke-linecap: round; }
.lk .k1 { filter: drop-shadow(0 0 1px rgba(0,0,0,.35)); }

#more { margin-top: 2px; font-size: .85rem; }
#more summary { cursor: pointer; padding: 6px 0; color: var(--muted); min-height: 32px; }
.colourby { border: 0; margin: 0; padding: 0; }
.colourby legend { padding: 0; font-weight: 600; margin-bottom: 4px; }
.colourby label, .t89 { display: flex; align-items: center; gap: 8px; min-height: 36px; cursor: pointer; }
.colourby input, .t89 input { width: 18px; height: 18px; margin: 0; accent-color: var(--ink); }
.t89[hidden] { display: none; }
.t89 { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line); }
.dash { display: inline-block; width: 22px; border-top: 3px dashed var(--c89); }

/* ---- riding panel: bottom sheet on a phone ---- */
#panel {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 4;
  height: 46%; max-height: 100%;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--white); border-radius: 16px 16px 0 0; box-shadow: 0 -3px 16px rgba(20, 38, 58, .25);
  transition: height .18s ease;
}
#panel[hidden] { display: none; }
#panel.full { height: 92%; }
#panel.dragging { transition: none; }
.grab { display: flex; justify-content: center; padding: 8px 0 2px; cursor: grab; touch-action: none; }
.grab span { width: 44px; height: 5px; border-radius: 3px; background: #c3c9d1; }
.phead { display: flex; align-items: center; justify-content: space-between; padding: 0 6px 0 12px; border-bottom: 1px solid var(--line); touch-action: none; }
.tabs { display: flex; gap: 2px; }
.tabs button {
  min-height: 44px; padding: 0 12px; background: none; border: 0; border-bottom: 3px solid transparent;
  font-weight: 600; color: var(--muted); cursor: pointer;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tabs button[hidden] { display: none; }
#close { width: 44px; height: 44px; border: 0; background: none; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); }
.pbody { flex: 1; overflow-y: auto; padding: 0 14px 28px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; background: var(--paper); }
.pbody > p { margin-top: 14px; }

/* coloured name band: the same colour as the riding on the map */
.rh {
  --rh-bg: var(--white); --rh-fg: var(--ink);
  margin: 0 -14px; padding: 14px 14px 13px;
  background: var(--rh-bg); color: var(--rh-fg);
  animation: rise .28s ease both;
}
.rh.UCP { --rh-bg: var(--ucp); --rh-fg: #fff; }
.rh.UCP-close { --rh-bg: var(--ucp-l); }
.rh.NDP { --rh-bg: var(--ndp); }
.rh.NDP-close { --rh-bg: var(--ndp-l); }
.rh.PTP { --rh-bg: var(--ptp); --rh-fg: #fff; }
.rh.Vacant { background: var(--hatch); }
.rh.c89 { --rh-bg: #fbe0e2; }
.rh .rnum { display: block; font-size: .78rem; font-weight: 600; opacity: .85; margin-bottom: 2px; }
.rh h2 { margin: 0; font-family: var(--display); font-size: 1.5rem; line-height: 1.15; letter-spacing: -.005em; }
.rh .st { margin: 7px 0 0; font-size: .82rem; }
.rh .tag { display: inline-block; padding: 1px 9px; margin-right: 4px; border-radius: 99px; background: rgba(255, 255, 255, .9); color: var(--ink); font-weight: 650; }

.blk {
  margin-top: 12px; padding: 12px 14px 12px; background: var(--white);
  border-radius: var(--radius); box-shadow: 0 1px 3px rgba(20, 38, 58, .1);
  animation: rise .32s ease both;
}
.blk:nth-of-type(2) { animation-delay: .05s; } .blk:nth-of-type(3) { animation-delay: .1s; } .blk:nth-of-type(n+4) { animation-delay: .15s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.blk h3 { display: flex; align-items: center; gap: 8px; margin: 0; font-family: var(--display); font-size: 1rem; font-weight: 700; }
.blk h3 svg { width: 22px; height: 22px; flex: none; fill: none; stroke: var(--ink); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.blk .when { display: block; margin: 1px 0 0 30px; font-size: .8rem; color: var(--muted); }
.lead { margin: 10px 0 2px; font-size: 1.15rem; font-weight: 700; line-height: 1.3; }
.lead .dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; }
.dot.UCP { background: var(--ucp); } .dot.NDP { background: var(--ndp); } .dot.PTP { background: var(--ptp); } .dot.Vacant { background: var(--hatch); }
.lead .rng { font-weight: 400; white-space: nowrap; }
.lead .tc { display: inline-block; padding: 0 8px; border-radius: 99px; background: var(--warn-bg); font-size: .85rem; font-weight: 650; vertical-align: 1px; }
.sub { margin: 2px 0; font-size: .9rem; color: var(--muted); }
.how { display: inline-block; margin-top: 6px; font-size: .82rem; }
.note { margin: 6px 0 0; padding: 6px 10px; border-left: 4px solid #e0b100; background: #fff9e0; font-size: .88rem; }

/* range bar: the margin and its range, drawn */
.rb { display: block; width: 100%; max-width: 360px; height: auto; margin: 6px 0 4px; }
.rb .ax { stroke: var(--line); stroke-width: 12; stroke-linecap: round; }
.rb .n { fill: var(--ndp); opacity: .55; } .rb .u { fill: var(--ucp); opacity: .55; }
.rb .n, .rb .u { transform-box: fill-box; transform-origin: center; animation: rbgrow .5s .15s ease both; }
@keyframes rbgrow { from { transform: scaleX(0); } to { transform: none; } }
.rb .zero { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 2 2; }
.rb .m { stroke: #fff; stroke-width: 2.5; }
.rb .m.UCP { fill: var(--ucp); } .rb .m.NDP { fill: var(--ndp); }
.rb text { font-size: 10.5px; fill: var(--muted); }

table.cen { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: .92rem; }
table.cen th, table.cen td { padding: 5px 0; vertical-align: top; text-align: right; font-variant-numeric: tabular-nums; }
table.cen th[scope="row"], table.cen thead th:first-child { text-align: left; font-weight: 400; padding-right: 8px; }
table.cen thead th { font-size: .75rem; color: var(--muted); font-weight: 600; border-bottom: 2px solid var(--ink); }
table.cen thead th.grp { font-size: .92rem; color: var(--ink); font-weight: 700; }
table.cen tbody tr + tr th, table.cen tbody tr + tr td { border-top: 1px solid var(--line); }
table.cen td.v { font-weight: 700; white-space: nowrap; }
table.cen td.ab { color: var(--muted); white-space: nowrap; padding-left: 10px; width: 5.5em; }
table.cen small { display: block; color: var(--muted); font-size: .78rem; }
.foot { margin: 8px 0 0; font-size: .78rem; color: var(--muted); }

dl.now { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 8px 0 0; font-size: .95rem; }
dl.now dt { color: var(--muted); }
dl.now dd { margin: 0; font-weight: 600; }

/* ---- dialog ---- */
dialog { width: min(640px, calc(100vw - 20px)); max-height: calc(100dvh - 20px); border: 0; border-top: 6px solid var(--ink); border-radius: var(--radius); padding: 18px 18px 14px; box-shadow: var(--shadow); color: var(--ink); }
dialog[open] { animation: rise .25s ease both; }
dialog::backdrop { background: rgba(20, 38, 58, .5); }
dialog .x { position: sticky; float: right; top: 0; width: 44px; height: 44px; margin: -10px -10px 0 0; border: 0; background: none; font-size: 1.6rem; cursor: pointer; }
dialog h2 { margin: 0 0 6px; font-family: var(--display); font-size: 1.3rem; }
dialog h3 { margin: 16px 0 4px; font-size: 1rem; }
dialog p { margin: 6px 0; }
dialog ul { margin: 6px 0; padding-left: 20px; }
dialog li { margin: 4px 0; }
.dl span { color: var(--muted); font-size: .88rem; }
.small { font-size: .85rem; color: var(--muted); }
dialog footer { margin-top: 16px; padding-top: 10px; border-top: 1px solid var(--line); font-size: .85rem; }
.noscript { padding: 12px; }

/* ---- summary strip and poll chart ---- */
#summary { margin: 2px 0 4px; font-size: .82rem; line-height: 1.4; }
#summary[hidden] { display: none; }
#summary b { font-variant-numeric: tabular-nums; }
#open-polls {
  padding: 2px 10px; min-height: 28px; border: 1px solid var(--line); border-radius: 99px;
  background: var(--paper); font-size: .8rem; font-weight: 600; cursor: pointer; white-space: nowrap;
}
#open-polls:hover { background: #e9ecf0; }
#chart { margin: 8px 0 2px; }
#chart svg { display: block; width: 100%; height: auto; }
#chart .grid { stroke: var(--line); stroke-width: 1; }
#chart .tick { stroke: #aab1ba; stroke-width: 1; }
#chart .ax { font-size: 12px; fill: var(--muted); }
#chart .ln { fill: none; stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; pointer-events: none; }
#chart .ln.ucp { stroke: var(--ucp); } #chart .ln.ndp { stroke: var(--ndp); }
#chart .pt { opacity: .32; }
#chart .pt.ucp { fill: var(--ucp); } #chart .pt.ndp { fill: var(--ndp); }
#chart .hit { fill: transparent; }
#chart .poll { cursor: pointer; }
#chart .poll.on .pt, #chart .poll:hover .pt { opacity: 1; stroke: var(--ink); stroke-width: 1.5; }
#chart .poll:focus-visible { outline: none; }
#chart .poll:focus-visible .hit { stroke: #f2b705; stroke-width: 2; }
#chart .end { font-size: 13px; font-weight: 700; }
#chart .end.ucp { fill: var(--ucp); } #chart .end.ndp { fill: #b85f0c; }
#chart-info { min-height: 3.2em; padding: 6px 10px; background: var(--paper); border-radius: 8px; font-size: .9rem; }

.maplibregl-ctrl-attrib { font-size: 11px; }

/* ---- help guide: fades in on a first visit, reopened with the ? button ---- */
#help {
  position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; padding: 14px;
  background: rgba(20, 38, 58, .55); animation: fadein .35s ease both;
}
#help[hidden] { display: none; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.hcard {
  width: min(430px, 100%); max-height: 100%; overflow-y: auto; padding: 20px 20px 18px;
  background: var(--white); border-radius: calc(var(--radius) + 4px); border-top: 6px solid var(--accent);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .35); animation: rise .45s .1s ease both;
}
.hcard h2 { margin: 0 0 2px; font-family: var(--display); font-size: 1.35rem; line-height: 1.2; }
.hcard > p { margin: 0 0 6px; color: var(--muted); font-size: .92rem; }
.hcard ul { list-style: none; margin: 10px 0 14px; padding: 0; }
.hcard li { display: flex; gap: 14px; align-items: center; padding: 9px 0; animation: rise .45s ease both; }
.hcard li + li { border-top: 1px solid var(--line); }
.hcard li:nth-child(1) { animation-delay: .35s; } .hcard li:nth-child(2) { animation-delay: .6s; } .hcard li:nth-child(3) { animation-delay: .85s; }
.hcard li svg { width: 56px; height: 56px; flex: none; border-radius: 12px; background: var(--paper); }
.hcard li b { display: block; font-size: 1rem; }
.hcard li span { font-size: .9rem; color: var(--muted); }
#help-ok {
  display: block; width: 100%; min-height: 46px; border: 0; border-radius: 99px; cursor: pointer;
  background: var(--ink); color: #fff; font-weight: 700; font-size: 1rem;
}
#help-ok:hover { background: var(--ink-2); }
.hi { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.hi-f1 { fill: var(--ucp); } .hi-f2 { fill: var(--ndp); } .hi-f3 { fill: var(--ucp-l); }
.hi-edge { fill: none; stroke: #fff; stroke-width: 2.5; stroke-linejoin: round; }
.hi-rip { fill: none; stroke: var(--ink); stroke-width: 2; transform-box: fill-box; transform-origin: center; animation: rip 1.8s ease-out infinite; }
.hi-rip.r2 { animation-delay: .6s; }
@keyframes rip { from { transform: scale(.4); opacity: 1; } to { transform: scale(2.4); opacity: 0; } }
.hi-thumb { fill: #fff; stroke: var(--ink); stroke-width: 2.5; animation: slide 2.6s ease-in-out infinite alternate; }
@keyframes slide { from { transform: translateX(0); } to { transform: translateX(28px); } }
.hi-new { animation: blink 2.6s ease-in-out infinite alternate; }
@keyframes blink { from { opacity: .1; } to { opacity: 1; } }
.hi-draw { stroke-dasharray: 100; animation: draw 2.8s ease-in-out infinite; }
@keyframes draw { 0% { stroke-dashoffset: 100; } 60%, 100% { stroke-dashoffset: 0; } }

/* header logo draws itself once on load */
.logo .ab { stroke-dasharray: 100; animation: logodraw 1.1s .15s ease-out both; }
.logo .cut { stroke-dasharray: 100; animation: logodraw .7s 1.1s ease-out both; }
@keyframes logodraw { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }

/* ---- desktop: controls float over the map, panel at the side ---- */
@media (min-width: 800px) {
  .bar { padding: 0 12px 0 18px; min-height: 58px; }
  .bname small { display: block; }
  .bar nav a, .bar nav button { padding: 0 12px; }
  #controls {
    position: absolute; top: 12px; left: 12px; width: 350px;
    border: 0; border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 14px 10px;
  }
  .notice { top: 12px; left: 374px; font-size: .82rem; }
  #panel {
    top: 0; left: auto; right: 0; bottom: 0; width: 420px; height: auto;
    border-radius: 0; box-shadow: -3px 0 16px rgba(20, 38, 58, .18); transition: none;
  }
  #panel.full { height: auto; }
  .grab { display: none; }
  .phead { touch-action: auto; padding-top: 4px; }
  #status { bottom: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  #panel { transition: none; }
  *, *::before, *::after { animation: none !important; }
}

/* population line in the name band */
.rh .pop { margin: 6px 0 0; font-size: .95rem; }
.rh .pop b { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.rh .pop span { font-size: .8rem; opacity: .9; }

/* Map / Aerial switch, bottom left of the map */
#aerial {
  position: absolute; left: 8px; bottom: 8px; z-index: 3;
  display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 0 14px 0 11px;
  border: 2px solid var(--white); border-radius: 99px; cursor: pointer;
  background: var(--white); color: var(--ink); font-weight: 650; font-size: .9rem; box-shadow: var(--shadow);
}
#aerial svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
#aerial:hover { border-color: var(--accent); }
#aerial[aria-pressed="true"] { background: var(--ink); color: var(--white); border-color: var(--accent); }
@media (min-width: 800px) { #aerial { left: 12px; bottom: 12px; } }
