@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400..750&family=Newsreader:ital,opsz,wght@0,6..72,500..600;1,6..72,500..600&display=swap");

/* political-eye: shared tokens and layout for every explorer page and the hub.
   Colours follow the dataviz reference palette: categorical slots in fixed
   order (never cycled), one sequential blue ramp, a blue<->red diverging
   pair with a grey midpoint, and status colours that always come with a
   label. Dark values are their own steps, declared under both scopes. */
:root {
  color-scheme: light;
  --page: #f9f9f7; --surface: #fcfcfb; --ink: #0b0b0b; --ink2: #52514e; --muted: #898781;
  --grid: #e1e0d9; --axis: #c3c2b7; --border: rgba(11, 11, 11, 0.10);
  --wash: rgba(252, 252, 251, 0.74); --is-dark: 0; --edge: 11, 11, 11;
  /* emphasis pair (party A, party B) and everything else */
  --a: #e34948; --b: #2a78d6; --other: #c3c2b7; --line: #2a78d6;
  /* categorical slots, fixed order */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  /* diverging midpoint; status (never themed) */
  --mid: #f0efec;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --up: #006300;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --ink: #f0efec; --ink2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
    --wash: rgba(26, 26, 25, 0.76); --is-dark: 1; --edge: 240, 239, 236;
    --a: #e66767; --b: #3987e5; --other: #5c5b57; --line: #3987e5;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --mid: #383835; --up: #0ca30c;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --ink: #f0efec; --ink2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
  --wash: rgba(26, 26, 25, 0.76); --is-dark: 1; --edge: 240, 239, 236;
  --a: #e66767; --b: #3987e5; --other: #5c5b57; --line: #3987e5;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --mid: #383835; --up: #0ca30c;
}

* { box-sizing: border-box; }
:root { --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif; --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --radius: 14px; --shadow: 0 1px 2px rgba(var(--edge), 0.05), 0 8px 24px -12px rgba(var(--edge), 0.18); }
body { margin: 0; background: var(--page); color: var(--ink); font: 14px/1.5 var(--sans); font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; overflow-x: clip; }
main { max-width: 1240px; margin: 0 auto; padding: 24px 24px 56px; }
a { color: var(--ink2); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--line); outline-offset: 2px; }

/* top bar (lib/page.js and the hub) */
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--page) 84%, transparent); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--border); }
.top .wrap { display: flex; align-items: center; gap: 20px; height: 60px; max-width: 1240px; margin: 0 auto; padding: 0 24px; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 680; font-size: 16px; letter-spacing: -0.01em; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand svg { width: 26px; height: 26px; }
.top .nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.top .nav > a, .pages > summary { color: var(--ink2); text-decoration: none; font-size: 14px; padding: 6px 10px; border-radius: 8px; cursor: pointer; }
.top .nav > a:hover, .pages > summary:hover, .pages[open] > summary { color: var(--ink); background: var(--surface); }
.top .nav a.nav-feature { color: var(--ink); font-weight: 600; border: 1px solid color-mix(in srgb, var(--line) 50%, transparent);
  background: color-mix(in srgb, var(--line) 10%, transparent); border-radius: 999px; padding: 5px 13px; }
.top .nav a.nav-feature:hover, .top .nav a.nav-feature[aria-current="page"] { background: color-mix(in srgb, var(--line) 20%, transparent); }
.pages { position: relative; }
.pages > summary { list-style: none; display: inline-flex; align-items: center; gap: 6px; }
.pages > summary::-webkit-details-marker { display: none; }
.pages > summary::after { content: ""; width: 6px; height: 6px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: translateY(-2px) rotate(45deg); }
.pages .menu { position: absolute; right: 0; top: calc(100% + 8px); display: grid; grid-template-columns: repeat(3, minmax(170px, 1fr)); gap: 4px 18px; padding: 16px 18px; min-width: 600px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 12px 40px -12px rgba(var(--edge), 0.35); }
.pages .group { display: flex; flex-direction: column; gap: 2px; }
.pages .group a { color: var(--ink2); text-decoration: none; font-size: 13.5px; padding: 5px 8px; border-radius: 7px; }
.pages .group a:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--ink); }
.pages .group a.sec { font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.07em; color: var(--accent); }
.pages .group a[aria-current="page"] { color: var(--ink); font-weight: 600; background: color-mix(in srgb, var(--accent) 12%, transparent); }
.lang { display: inline-flex; padding: 3px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); flex: none; }
.lang button { all: unset; cursor: pointer; font-size: 12px; font-weight: 650; letter-spacing: 0.04em; padding: 3px 10px; border-radius: 999px; color: var(--muted); }
.lang button[aria-pressed="true"] { background: var(--ink); color: var(--page); }
.lang button:focus-visible { outline: 2px solid var(--line); outline-offset: 1px; }

/* page header: breadcrumb, title, lede */
main > header { padding: 28px 0 4px; position: relative; }
main > header::before { content: ""; position: absolute; inset: -24px 0 0 0; z-index: -1; pointer-events: none;
  background: radial-gradient(32% 100% at 80% 0%, color-mix(in srgb, var(--accent, var(--line)) 12%, transparent), transparent 70%); }
header h1 { font-family: var(--serif); font-size: clamp(30px, 4vw, 44px); line-height: 1.08; letter-spacing: -0.02em; margin: 0 0 12px; font-weight: 560; text-wrap: balance; }
header p { margin: 0; color: var(--ink2); max-width: 860px; font-size: 15.5px; line-height: 1.6; text-wrap: pretty; }
header .crumb { margin: 0 0 14px; font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
header .crumb a { color: var(--accent, var(--line)); text-decoration: none; }
header .crumb a:hover { text-decoration: underline; }

/* tabs: one scrolling row on narrow screens */
.tabs { display: flex; gap: 2px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 26px 0 20px; border-bottom: 1px solid var(--border); }
.tabs::-webkit-scrollbar { display: none; }
.tabs.more-right { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 44px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 44px), transparent); }
.tabs.more-left { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 44px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 44px), transparent); }
.tabs.more-left.more-right { -webkit-mask-image: linear-gradient(to right, transparent, #000 44px, #000 calc(100% - 44px), transparent); mask-image: linear-gradient(to right, transparent, #000 44px, #000 calc(100% - 44px), transparent); }
.tabs button {
  all: unset; cursor: pointer; padding: 10px 14px; font-size: 14px; font-weight: 500; color: var(--ink2); border-bottom: 2px solid transparent;
  margin-bottom: -1px; white-space: nowrap; border-radius: 8px 8px 0 0; transition: color .15s ease, background .15s ease;
}
.tabs button:hover, .tabs button:focus-visible { color: var(--ink); background: color-mix(in srgb, var(--accent, var(--line)) 7%, transparent); }
.tabs button[aria-selected="true"] { color: var(--ink); font-weight: 650; border-bottom-color: var(--accent, var(--line)); }
section[role="tabpanel"][hidden] { display: none; }

/* filters: one row above the charts */
.controls { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: end; margin: 6px 0 16px; }
.controls label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 550; color: var(--ink2); max-width: 100%; min-width: 0; }
.controls select, .controls input[type="search"], .controls input[type="text"] {
  font: inherit; font-size: 13.5px; color: var(--ink); background: var(--surface); border: 1px solid var(--border);
  border-radius: 9px; padding: 7px 10px; min-height: 36px; max-width: 100%; transition: border-color .15s ease;
}
.controls select:hover, .controls input:hover { border-color: color-mix(in srgb, var(--ink) 25%, transparent); }
.controls input[type="range"] { width: 160px; accent-color: var(--accent, var(--line)); }
.controls label:has(input[type="range"]) > :last-child { display: flex; align-items: center; gap: 8px; min-height: 36px; }

/* cards, tiles, grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; min-width: 0; }
.card h2 { font-size: 16px; line-height: 1.3; margin: 0 0 4px; font-weight: 650; letter-spacing: -0.01em; }
.card .note { font-size: 13px; line-height: 1.5; color: var(--muted); margin: 0 0 14px; max-width: 760px; }
.card .finding { font-size: 13.5px; color: var(--ink2); margin: 10px 0 0; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.tile { position: relative; overflow: hidden; }
.tile::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--accent, var(--line)); opacity: 0.85; }
.tile .label { font-size: 12.5px; font-weight: 550; color: var(--ink2); }
.tile .value { font-size: 30px; line-height: 1.1; font-weight: 700; letter-spacing: -0.03em; margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.tile .sub { font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.wide { margin-bottom: 16px; }
.hint, .empty { color: var(--muted); }
.empty { padding: 32px 8px; text-align: center; }
.error { color: var(--critical); padding: 16px 0; }

/* charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; overflow: visible; }
svg text { font-family: var(--sans); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink2); margin: 10px 0 0; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.legend i.dot { border-radius: 50%; }
.legend i.hollow { background: transparent !important; border: 1.5px solid var(--other); border-radius: 50%; }
.status { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.toggle { all: unset; cursor: pointer; font-size: 12px; font-weight: 550; color: var(--ink2); margin-top: 10px; display: inline-block; padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; }
.toggle:hover { color: var(--ink); border-color: color-mix(in srgb, var(--ink) 25%, transparent); }

/* tables */
.tablewrap { overflow-x: auto;
  background: linear-gradient(to right, var(--surface) 30%, transparent) left center / 28px 100% no-repeat local,
              linear-gradient(to left, var(--surface) 30%, transparent) right center / 28px 100% no-repeat local,
              radial-gradient(farthest-side at 0 50%, rgba(var(--edge), 0.22), transparent) left center / 12px 100% no-repeat scroll,
              radial-gradient(farthest-side at 100% 50%, rgba(var(--edge), 0.22), transparent) right center / 12px 100% no-repeat scroll; }
.tablewrap::-webkit-scrollbar { height: 8px; }
.tablewrap::-webkit-scrollbar-thumb { background: var(--axis); border-radius: 99px; }
table.view { border-collapse: collapse; font-size: 12.5px; margin-top: 10px; font-variant-numeric: tabular-nums; width: 100%; }
table.view th, table.view td { border-bottom: 1px solid var(--grid); padding: 7px 8px; text-align: right; white-space: nowrap; }
table.view th { color: var(--muted); font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em; position: sticky; top: 0; background: var(--surface); border-bottom-color: var(--axis); }
table.view th.text, table.view td.text { text-align: left; }   /* text stays on one line unless its column opts in with wrap */
table.view th button { all: unset; cursor: pointer; }
table.view th button:hover { color: var(--ink); }
table.view tbody tr { transition: background .1s ease; }
table.view tbody tr:hover { background: color-mix(in srgb, var(--accent, var(--line)) 6%, transparent); }
table.view td.wrap { white-space: normal; min-width: 180px; }
.tablebar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.tablebar input { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 6px 10px; flex: 1 1 140px; min-width: 0; max-width: 260px; }
.tablebar button { all: unset; cursor: pointer; color: var(--ink2); font-weight: 550; padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; }
.tablebar button:hover:not([disabled]) { color: var(--ink); border-color: color-mix(in srgb, var(--ink) 25%, transparent); }
.tablebar button[disabled] { opacity: 0.4; cursor: default; }

/* tooltip */
#tip {
  position: fixed; pointer-events: none; z-index: 30; background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px; font-size: 12px;
  box-shadow: 0 8px 28px -8px rgba(var(--edge), 0.3); max-width: 300px; display: none;
}
#tip strong { font-size: 14px; display: block; }
#tip .row { display: flex; align-items: center; gap: 6px; color: var(--ink2); }
#tip .row b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
#tip .key { width: 12px; height: 2px; border-radius: 1px; display: inline-block; }
#tip .key.box { height: 10px; width: 10px; border-radius: 2px; }

.loading .fade { opacity: 0.45; transition: opacity 0.15s; }
main > footer, body > footer { margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--border); font-size: 13px; line-height: 1.65; color: var(--muted); max-width: none; }
footer { margin-top: 20px; font-size: 12px; color: var(--muted); max-width: 980px; }
.about { font-size: 12.5px; color: var(--muted); border-left: 2px solid var(--accent, var(--grid)); padding-left: 12px; margin: 12px 0 0; }

@media (max-width: 900px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pages .menu { grid-template-columns: 1fr 1fr; min-width: 0; width: min(92vw, 460px); }
}
@media (max-width: 640px) {
  main, .top .wrap { padding-left: 16px; padding-right: 16px; }
  .top .wrap { gap: 10px; }
  .hide-sm { display: none; }
  .pages .menu { grid-template-columns: 1fr; position: fixed; left: 16px; right: 16px; top: 64px; width: auto; }
  .tile .value { font-size: 24px; }
  .tablebar { gap: 6px; }
  .tablebar button { padding: 4px 8px; }
}
@media (max-width: 440px) {
  .brand-name { display: none; }   /* the logo alone, so Ranking, the page menu and the language switch fit */
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* find a deputy (lib/search.js) */
.dsearch { position: relative; max-width: 560px; }
.dsearch .icon { position: absolute; left: 13px; top: 50%; width: 15px; height: 15px; transform: translateY(-50%); pointer-events: none;
  border: 2px solid var(--muted); border-radius: 50%; }
.dsearch .icon::after { content: ""; position: absolute; width: 2px; height: 7px; background: var(--muted); right: -4px; bottom: -6px; transform: rotate(-45deg); border-radius: 1px; }
.dsearch input[type="search"], .controls .dsearch input[type="search"] { width: 100%; font: inherit; font-size: 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 12px 9px 38px; min-height: 40px; transition: border-color .15s ease, box-shadow .15s ease; }
.dsearch input:focus { outline: none; border-color: var(--accent, var(--line)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent, var(--line)) 18%, transparent); }
.dsearch.large input[type="search"] { font-size: 16.5px; min-height: 54px; border-radius: 14px; padding-left: 44px; box-shadow: var(--shadow); }
.dsearch.large .icon { left: 16px; width: 17px; height: 17px; }
.dsearch .options { position: absolute; z-index: 25; left: 0; right: 0; top: calc(100% + 6px); margin: 0; padding: 6px; list-style: none; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 16px 44px -14px rgba(var(--edge), 0.4); max-height: 420px; overflow-y: auto; }
.dsearch .option { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 7px 10px; border-radius: 10px; cursor: pointer; }
.dsearch .option[aria-selected="true"] { background: color-mix(in srgb, var(--accent, var(--line)) 12%, transparent); }
.dsearch .option .who { display: flex; flex-direction: column; min-width: 0; }
.dsearch .option .who b { font-weight: 600; font-size: 14px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dsearch .option .who span { font-size: 12px; color: var(--muted); }
.dsearch .option .leg { font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.dsearch .none { padding: 12px; color: var(--muted); font-size: 13px; }
.avatar { position: relative; display: inline-grid; place-items: center; flex: none; border-radius: 50%; overflow: hidden; font-weight: 650; letter-spacing: 0.02em;
  color: var(--ink2); background: color-mix(in srgb, var(--accent, var(--line)) 16%, var(--surface)); }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 20%; }
