/* Green Party palette (greens.org.nz):
     white #ffffff · beige #f9f9f1 · mārama #ecf5e9 · rēmana #cde9c8
     māuri #007041 · pounamu #006633 · puha #00491e · pōuri #023015
   --muted is not in the palette: pōuri mixed 70% with white. */
:root {
  --green: #007041;          /* māuri: buttons, links, radios */
  --green-strong: #00491e;   /* puha: headings, candidate names */
  --green-tint: #ecf5e9;     /* mārama: hover, image placeholder */
  --on-green: #ffffff;       /* text/icons on --green */
  --ink: #023015;            /* pōuri */
  --muted: #4e6e5b;
  --line: #cde9c8;           /* rēmana */
  --bg: #ffffff;
  --panel: #ffffff;
  --card: #ffffff;
  --group-bg: #ecf5e9;       /* mārama */
  --section-title: #00491e;  /* puha; beige in dark mode (beige on white is ~1:1) */
  --list-border: #8fb08a;    /* rēmana darkened ~30%; muted grey-green in dark mode */
  --group-link: #007041;     /* māuri on mārama (5.5:1); beige on puha in dark mode (10.1:1) */
  --focus: #f5b700;
  --shadow: 0 1px 2px rgb(2 48 21 / .06), 0 4px 16px rgb(2 48 21 / .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --green: #cde9c8; --green-strong: #cde9c8; --green-tint: #00491e; --on-green: #023015;
    --ink: #f9f9f1; --muted: #a9c2ae; --line: #006633;
    --bg: #023015; --panel: #023015; --card: #00491e;
    --group-bg: #00491e; --section-title: #f9f9f1; --list-border: #557060; --group-link: #f9f9f1;
    --shadow: 0 1px 2px rgb(0 0 0 / .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --green: #cde9c8; --green-strong: #cde9c8; --green-tint: #00491e; --on-green: #023015;
  --ink: #f9f9f1; --muted: #a9c2ae; --line: #006633;
  --bg: #023015; --panel: #023015; --card: #00491e;
  --group-bg: #00491e; --section-title: #f9f9f1; --list-border: #557060; --group-link: #f9f9f1;
  --shadow: 0 1px 2px rgb(0 0 0 / .4);
  color-scheme: dark;
}

@font-face {
  font-family: "Untitled Sans Round";
  src: url("fonts/woff2/UntitledSansRound-Regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Untitled Sans Round";
  src: url("fonts/woff2/UntitledSansRound-Medium.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Untitled Sans Round";
  src: url("fonts/woff2/UntitledSansRound-Bold.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Untitled Sans Round";
  src: url("fonts/woff2/UntitledSansRound-RegularItalic.woff2") format("woff2");
  font-weight: 400; font-style: italic; font-display: swap;
}

/* Fraunces (SIL OFL, see fonts/fraunces/OFL.txt): static instances at optical
   size 72, SOFT 100, Latin subset. 400 for the header "Maps", 600 for section titles. */
@font-face {
  font-family: "Fraunces";
  src: url("fonts/fraunces/Fraunces-Regular-Soft-latin.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("fonts/fraunces/Fraunces-SemiBold-Soft-latin.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}

* { box-sizing: border-box; }
/* Sharp corners: form controls are rounded by default in some browsers (Safari's search box). */
button, input { border-radius: 0; }
html, body { height: 100%; margin: 0; }
[hidden] { display: none !important; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 "Untitled Sans Round", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.map-layout {
  display: grid;
  grid-template-columns: minmax(320px, 400px) 1fr;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100dvh;
}
.page { min-height: 100dvh; display: flex; flex-direction: column; }

/* Brand bar: pōuri in both themes, since the logo is white. The pounamu edge
   keeps it distinct from the dark-mode panel, which is also pōuri. */
/* Baseline alignment: the logo's lettering sits on the bottom edge of the image
   (rows 93–94 of 96), and a block image's baseline is its bottom edge, so "Maps"
   lands on the same baseline as "Green". The negative margin lets the "p"
   descender hang into the padding without making the bar taller. */
.site-header {
  --logo-h: 34px;
  grid-column: 1 / -1;
  display: flex;
  padding: 10px 20px 17px;
  background: #023015; color: #ffffff;
  border-bottom: 1px solid #006633;
}
.site-brand {
  position: relative; display: flex; align-items: baseline; gap: 12px;
  color: inherit; text-decoration: none;
}
/* One underline below the logo, divider and "Maps" together. The title's outline in
   the header colour breaks it around the "p", like a normal text underline. */
.site-brand::before {
  content: ""; position: absolute; left: 0; right: 0; bottom: -5px; height: 1px;
  background: currentColor; opacity: 0; transition: opacity .15s;
}
.site-brand:hover::before { opacity: 1; }
.site-brand:hover .site-title {
  text-shadow: 2px 0 #023015, -2px 0 #023015, 0 2px #023015, 0 -2px #023015;
}
.site-logo { display: block; height: var(--logo-h); width: auto; }
.site-divider {
  align-self: flex-end; width: 1px; height: calc(var(--logo-h) * .8);
  background: rgb(255 255 255 / .45);
}
.site-title {
  font-family: "Fraunces", Georgia, "Times New Roman", serif;
  font-weight: 400; font-size: 2.25rem; line-height: 1;
  margin-bottom: -.25em;
  /* The logo's lettering stops 2.5px above its bottom edge (of 96px); match it. */
  transform: translateY(calc(var(--logo-h) * -2.5 / 96));
}
a { color: var(--green); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
/* Links out to other sites: a small box-and-arrow after the text, in the link's colour. */
a.external::after {
  content: ""; display: inline-block; width: 1em; height: 1em; margin-left: .3em; vertical-align: -.15em;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 4h6v6M20 4l-9 9M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5'/%3E%3C/svg%3E") center / contain no-repeat;
}
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 20px 20px 12px;
  display: flex; flex-direction: column; gap: 16px;
}
.panel-head h1, .content h1 {
  font-family: "Fraunces", Georgia, serif; font-weight: 600; font-size: 1.5rem; line-height: 1.15;
  margin: 0 0 6px; color: var(--section-title);
}
.all-head h1 { margin-bottom: 14px; }
/* Layers stack: stands for "all jurisdictions" (in the breadcrumbs and that page's title). */
.layers-icon {
  width: 1.15em; height: 1.15em; vertical-align: -.2em;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.all-head h1 .layers-icon { margin-right: .3em; vertical-align: -.15em; }
.lede { margin: 0; color: var(--muted); }
.panel-head .blurb { margin: 12px 0 14px; color: var(--muted); line-height: 1.45; }
.panel-head .cta {
  margin: 0; padding: 10px 12px;
  background: var(--group-bg); color: var(--green-strong); font-style: italic;
}

.search { display: flex; gap: 8px; }
.search input {
  flex: 1; min-width: 0;
  font: inherit; padding: 10px 12px;
  border: 0;
  background: var(--group-bg); color: var(--ink);   /* mārama / puha: visible without a border */
}
.search input::placeholder { color: var(--muted); opacity: 1; }
.search button {
  flex: none; width: 44px;
  border: 1px solid var(--green); background: var(--green); color: var(--on-green); cursor: pointer;
  display: grid; place-items: center;
}
.search button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.status { margin: -8px 0 0; min-height: 1.2em; color: var(--muted); font-size: .9rem; }

.back { display: inline-block; margin-bottom: 6px; font-size: .88rem; text-decoration: none; }
.back:hover { text-decoration: underline; }
.crumbs ol { display: flex; flex-wrap: wrap; margin: 0 0 6px; padding: 0; list-style: none; font-size: .88rem; }
.crumbs li::after { content: "/"; margin: 0 .45em; color: var(--muted); }   /* trailing one too: the title follows */
.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
/* The icon has no text to underline, so draw the line under it. */
.crumbs a:has(.layers-icon):hover {
  background: linear-gradient(currentColor, currentColor) 0 100% / 100% 1px no-repeat;
}
.panel h1:focus { outline: none; }   /* focused by script when the panel changes */
.block h2 {
  font-family: "Fraunces", Georgia, serif; font-weight: 600; font-size: 1.15rem; line-height: 1.2;
  color: var(--section-title); margin: 0 0 8px;
}
.sub-units ul { list-style: none; margin: 0; padding: 0; }
.sub-units li { padding: 3px 0; }
.sub-units a { color: var(--green); text-underline-offset: 2px; }
.links { margin: 0; padding: 0; list-style: none; }
/* Rules between the representatives, the jurisdictions inside this one, and the links.
   Several sub-unit lists (e.g. wards, then community boards) count as one section. */
.block:is(.sub-units, .links-block) { border-top: 1px solid var(--line); padding-top: 16px; }
.sub-units + .sub-units { border-top: 0; padding-top: 0; }
.type-label { margin: 0; font-size: .78rem; font-style: italic; color: var(--muted); }
.note { font-size: .78rem; font-style: italic; color: var(--muted); }
.sep { margin: 0 .28em; color: var(--muted); }

/* Other parties' names, in their colours. Unlisted parties get the plain style. */
.party {
  padding: 5px 7px 3px; font-size: .85em; font-weight: 700; white-space: nowrap;
  background: var(--group-bg); color: var(--ink);
}
.party-national { background: #00529f; color: #ffffff; }
.party-labour { background: #d82a20; color: #ffffff; }
.party-act { background: #fde401; color: #000000; }
.party-te-pati-maori { background: #b2001a; color: #ffffff; }
.party-nz-first { background: #000000; color: #ffffff; }
.party-opportunity { background: #32dac3; color: #000000; }

/* Representatives. Greens and Green-endorsed get the filled card. */
.card {
  display: flex; gap: 12px; align-items: flex-start;
  border: 1px solid var(--line);
  padding: 10px 12px; margin-bottom: 8px; text-decoration: none; color: var(--ink);
}
.card p { margin: 0; }
.card img { width: 64px; height: 64px; object-fit: cover; border-radius: 50%; flex: none; background: var(--group-bg); }
.rep-name { font-weight: 700; }
a.card:hover .rep-name { text-decoration: underline; text-underline-offset: 2px; }
.rep-role { font-size: .92rem; }
.card .rep-blurb { margin-top: 6px; font-size: .88rem; }
.card.green {
  --muted: #cde9c8;
  background: #006633; border-color: #006633; color: #ffffff;   /* 7:1 in both themes */
}
.card.green .rep-name { font-size: 1.1rem; }
.card .badge {
  display: inline-block; margin-top: 4px; padding: 1px 8px;
  background: #f9f9f1; color: #00491e; font-size: .78rem; font-weight: 700;
}

.jurisdiction-list ul { list-style: none; margin: 0; padding: 0; }
.jurisdiction-list ul + h2 { margin-top: 18px; }
.jurisdiction-list h2 {   /* the council, region etc. a group belongs to */
  margin: 0 0 2px; padding: 0 8px;
  font-weight: 400; font-size: .82rem;
}
.jurisdiction-list h2 a { color: var(--muted); text-decoration: none; }
.jurisdiction-list h2 a:hover { text-decoration: underline; }
.jurisdiction-list li { padding: 6px 8px; }
.jurisdiction-list li.selected { background: var(--group-bg); font-weight: 700; }
.jurisdiction-list a { color: var(--green); text-underline-offset: 2px; }   /* rēmana in dark mode, like other links */
.jurisdiction-list li.selected a { color: var(--group-link); }   /* beige in dark mode, to stand out */

.group { background: var(--group-bg); padding: 14px 16px; }
.group a { color: var(--group-link); }
.group-label {   /* as on the home page's cards; puha in light mode, beige in dark */
  margin: 0 0 6px; color: var(--section-title);
  font-family: "Fraunces", Georgia, serif; font-weight: 600; font-size: 1.15rem; line-height: 1.2;
}

/* Your representatives */
.content { width: 100%; max-width: 720px; margin: 0 auto; padding: 28px 20px; flex: 1; }
.content h1 { font-size: 2rem; }
.content .group { margin-top: 16px; }
.membership + .membership { margin-top: 12px; }
.membership p { margin: 0; }
.membership.has-green { border-left: 4px solid var(--green); padding-left: 12px; }

.list-mps { margin-top: 8px; padding: 10px 12px; background: #006633; color: #ffffff; }
.list-mps .list-mps-title { font-size: .8rem; font-weight: 700; }
.list-mps a { color: #ffffff; }
.list-mps .note { color: #cde9c8; }
.list-intro { margin-bottom: 8px; font-size: .88rem; }

/* Home: always pōuri, like the brand bar, since the logo is white. */
.home {
  background: #023015; color: #ffffff; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center;
}
.topo { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
/* 404: the home page's background, in both themes. */
.not-found { background: #023015; color: #ffffff; }
.not-found > :not(.topo) { position: relative; z-index: 1; }   /* above the contour lines */
.not-found .content { display: flex; flex-direction: column; justify-content: center; text-align: center; }
.not-found h1, .not-found .content a { color: #f9f9f1; }
.hero {
  position: relative; flex: 1; width: 100%; max-width: 680px; padding: clamp(40px, 14vh, 150px) 20px 32px;
}
.hero-brand { --logo-h: clamp(44px, 11vw, 76px);
  display: flex; justify-content: center; align-items: baseline; gap: calc(var(--logo-h) * .3);
  margin: 0 0 40px; font-weight: 400;
}
.hero-brand .site-title { font-size: calc(var(--logo-h) * 1.06); }
.switcher {
  position: relative;
  display: grid; grid-template-columns: 1fr 1fr; padding: 4px; gap: 4px;
  background: #00491e;
}
.switcher::before {   /* the sliding highlight */
  content: ""; position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 6px);
  background: #f9f9f1;
}
.switcher.second::before { transform: translateX(calc(100% + 4px)); }
.switcher.animate::before { transition: transform .25s cubic-bezier(.3, 0, .2, 1); }
.switcher.animate button { transition: color .25s; }
@media (prefers-reduced-motion: reduce) {
  .switcher.animate::before, .switcher.animate button { transition: none; }
}
.switcher button {
  position: relative;
  border: 0; padding: 11px 8px; cursor: pointer;
  font: inherit; font-weight: 700; background: transparent; color: #cde9c8;
}
.switcher button:hover { color: #ffffff; }
.switcher button[aria-selected="true"] { color: #00491e; }
.hero-panel { margin-top: 20px; }
#find { margin-top: 44px; }
.hero .search input { background: #ffffff; color: #023015; font-size: 1.05rem; padding: 13px 14px; }
.hero .search :is(input, button):focus-visible { outline-color: #f9f9f1; }
.hero .search input::placeholder { color: #4e6e5b; }
.hero .search button { width: 50px; background: #007041; border-color: #007041; color: #ffffff; }
.hero .hint { font-family: "Fraunces", Georgia, serif; font-size: 1.1rem; margin: 10px 0 0; color: #cde9c8; text-align: center; }
.hero .status { margin: 10px 0 0; color: #ffffff; text-align: center; }
.hero .status.error { padding: 10px 14px; background: #c2410c; white-space: pre-line; }   /* white on orange: 5.2:1 */
.hero .status.error a { color: inherit; text-underline-offset: 3px; }
/* "Use my location": pin, hourglass while the browser asks permission, then a spinner. */
#locate:not([data-state="waiting"]) .icon-waiting,
#locate:not([data-state="loading"]) .icon-loading,
#locate[data-state] .icon-idle { display: none; }
#locate[data-state] { cursor: progress; }
#locate .icon-loading { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  #locate .icon-loading { animation-duration: 2.4s; }
}
/* "Random area": a whimsical link, centred in the space below the search. */
.hero .random { margin: clamp(40px, 14vh, 140px) 0 0; text-align: center; font-size: .88rem; }
.hero .random a { color: #cde9c8; opacity: .55; text-underline-offset: 3px; transition: opacity .2s; }
.hero .random a:is(:hover, :focus-visible) { opacity: 1; }
.type-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.type-column { display: grid; gap: 16px; }
.type-group { background: #00491e; padding: 12px 14px; }
.type-group h2 {
  margin: 0 0 6px; color: #f9f9f1;
  font-family: "Fraunces", Georgia, serif; font-weight: 600; font-size: 1.15rem; line-height: 1.2;
}
.type-group.gp { background: #007041; }
@media (min-width: 761px) {   /* two columns: on its own row, centred, one column wide */
  .type-column:has(.gp) { grid-column: 1 / -1; }
  .type-group.gp { width: calc(50% - 8px); margin-inline: auto; }
}
/* All jurisdictions page: the same cards, stacked to fit the panel. */
.panel .type-groups, .panel .type-column { grid-template-columns: 1fr; gap: 12px; }
.panel .type-column:has(.gp) { grid-column: auto; }
.panel .type-group.gp { width: auto; margin-inline: 0; }
.type-group ul { list-style: none; margin: 0; padding: 0; }
.type-group li { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.type-group a { color: #f9f9f1; text-underline-offset: 2px; }
/* Types that sit inside the one above (wards in councils, subdivisions in community boards). */
.type-group li.sub { padding-left: calc((var(--depth) - 1) * 1.1em); }
.type-group .sub-arrow { display: inline-block; width: 1.1em; color: #a9c2ae; }
.type-group.gp .sub-arrow { color: #ecf5e9; }
.type-group .count { color: #a9c2ae; font-size: .8rem; font-variant-numeric: tabular-nums; }
.type-group.gp .count { color: #ecf5e9; }

.source { margin-top: auto; font-size: .65rem; line-height: 1.4; color: var(--muted); }
.source .built-by { margin: 8px 0 0; font-size: .72rem; text-align: center; }
.page > .source, .home > .source { padding: 12px 20px; text-align: center; }
.home > .source { position: relative; color: #a9c2ae; }
.home > .source a { color: inherit; }

.pin-map { height: 240px; margin-top: 16px; overflow: hidden; }

/* The basemap's sea, shown until tiles load (OpenStreetMap / OpenFreeMap fiord) */
#map, .pin-map { background: #aad3df; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) :is(#map, .pin-map) { background: #38435c; }
}
:root[data-theme="dark"] :is(#map, .pin-map) { background: #38435c; }
#map { min-height: 0; }
.map-marker { display: block; width: 25px; height: 41px; }
/* Basemap credit: required by the OpenStreetMap licence, so keep it visible but quiet. */
.maplibregl-ctrl.maplibregl-ctrl-attrib {
  font: 10px/1.6 "Untitled Sans Round", system-ui, sans-serif;
  background: rgb(255 255 255 / .55); padding: 0 6px;
  color: rgb(2 48 21 / .7);   /* fixed, not var(--ink): the strip is light in both themes */
}
.maplibregl-ctrl-attrib a { color: rgb(2 48 21 / .7); }
.maplibregl-popup-content { background: var(--card); color: var(--ink); font: inherit; padding: 8px 12px; }
/* MapLibre rounds its zoom buttons, popups and the collapsed credit, some with more specific
   selectors (e.g. a focused first button); keep them all square. */
.maplibregl-ctrl-group, .maplibregl-ctrl-group button, .maplibregl-popup-content,
.maplibregl-popup-close-button, .maplibregl-ctrl-attrib, .maplibregl-ctrl-attrib-button { border-radius: 0 !important; }

/* Addy's suggestions: a jQuery UI menu, only on the home page, so its colours are
   fixed. !important beats Addy's inline font size and the theme's focus style. */
.ui-autocomplete.ui-menu {
  z-index: 10 !important; max-width: 90vw; max-height: 50vh; overflow-y: auto;
  padding: 4px;
  /* The transparent border is a gap for the focus ring; jQuery UI cancels out margins. */
  border: 0 solid transparent; border-top-width: 6px;
  background: #ffffff; background-clip: padding-box; color: #023015;
  font-family: inherit; filter: drop-shadow(0 6px 12px rgb(0 0 0 / .35));
}
.ui-autocomplete, .ui-autocomplete * { border-radius: 0 !important; }   /* jQuery UI's ui-corner-* */
.ui-autocomplete .ui-menu-item {
  margin: 0 !important; padding: 9px 10px !important;
  border: 0 !important; background: none;
  color: #023015 !important; font-size: .95rem !important; font-weight: 400 !important; line-height: 1.35;
  list-style: none; cursor: pointer;
}
.ui-autocomplete .ui-menu-item a { color: inherit; text-decoration: none; padding: 0; }
.ui-autocomplete .ui-menu-item b { font-weight: 700; color: #007041; }
.ui-autocomplete .ui-menu-item.ui-state-focus { background: #cde9c8 !important; color: #00491e !important; }
.ui-autocomplete .ui-menu-item.ui-state-focus b { color: #00491e; }

@media (max-width: 760px) {
  .map-layout { grid-template-columns: 1fr; grid-template-rows: auto 45dvh minmax(0, 1fr); }
  .site-header { padding: 8px 16px 14px; }
  .site-header { --logo-h: 28px; }
  .site-header .site-title { font-size: 1.85rem; }
  .type-groups { grid-template-columns: 1fr; }
  #map { grid-row: 2; }
  .panel { grid-row: 3; border-right: 0; border-top: 1px solid var(--line); padding: 16px; }
}
