/*
  style.css — white background, black text, square corners everywhere
  (no border-radius).

  Colour only ever marks data, never text. All comparisons draw from one
  categorical palette (below). For each bar, the order of its colours was
  checked for colour-blind separation; where a colour is lighter than 3:1
  against white, the legend, the values above the bar and the tooltip carry
  the information as well.

  Font: Inter, served from site/fonts/ (SIL Open Font License, see
  site/fonts/OFL.txt), so every device shows the same font and no request
  goes to Google.
*/

/* Font ------------------------------------------------------------------------------ */
/* One variable font file covers all weights (100–900). Split by character
   range like on Google Fonts: "latin" covers German, French and Italian;
   "latin-ext" is only downloaded if a page shows rarer letters. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308,
    U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* The true italics of Inter (not slanted upright letters), for *italic* in
   the Markdown texts. Only downloaded when a page shows italic text. */
@font-face {
  font-family: "Inter";
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter-italic-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308,
    U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Inter";
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter-italic-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Design tokens ------------------------------------------------------------------ */
:root {
  color-scheme: light;

  --bg: #ffffff;           /* boxes with content */
  --canvas: #f2f2ef;       /* page background around the boxes */
  --ink: #0b0b0b;          /* primary text */
  --ink-2: #52514e;        /* secondary text */
  --ink-3: #6f6e69;        /* muted labels */
  --line: #e6e5e0;         /* hairlines */
  --wash: #f3f3f1;         /* hover background */
  --leaving: #fde9e8;      /* a member who has announced their resignation */
  --chart-muted: #d6d5d0;  /* history chart: the lines not emphasized */

  /* Categorical palette for all comparisons */
  --blue: #2a78d6;
  --orange: #eb6834;
  --aqua: #1baf7a;
  --amber: #eda100;
  --green: #008300;
  --violet: #6250d6;
  --magenta: #e87ba4;
  --red: #e34948;
  --other: #c3c2b7;        /* grouped rest: "Übrige Parteien", "Andere Sprachen" */

  /* Ordered categories (age): one hue, light to dark */
  --blue-light: #86b6ef;
  --blue-mid: #3987e5;
  --blue-dark: #184f95;

  --female: var(--orange);
  --male: var(--blue);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --max: 56rem;            /* content width */
  --gutter: clamp(1.25rem, 5vw, 2.5rem);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Base --------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

/* Browsers round some form controls by default (e.g. Safari buttons) */
button,
input {
  border-radius: 0;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

h1,
h2,
p {
  margin: 0;
}

/* Text only for screen readers */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.page {
  max-width: var(--max);
  margin: 0 auto;
  padding-inline: var(--gutter);
  padding-bottom: 3rem;
  padding-top: max(clamp(2.5rem, 8vw, 5rem), env(safe-area-inset-top));
}

/* Header --------------------------------------------------------------------------- */
.eyebrow {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 1rem;
}

h1 {
  font-size: clamp(2rem, 6vw, 3.25rem);
  line-height: 1.08;
  letter-spacing: -0.025em;
  font-weight: 700;
  max-width: 18ch;
  text-wrap: balance;
}

/* Longer texts from site/content/ (Markdown, js/content.js) */
.prose {
  max-width: 65ch;
}

.prose > * + *,
.more-text > * + * {
  margin-top: 0.875rem;
}

/* The page title, when it comes from the text (intro.md) */
.prose h1 {
  color: var(--ink);
}

.prose .eyebrow + h1 {
  margin-top: 0;
}

.prose h1 + * {
  margin-top: 1.5rem;
}

.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.875em;
}

.prose pre {
  margin-bottom: 0;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  background: var(--bg);
  line-height: 1.5;
}

.prose hr {
  margin-block: 1.75rem 0;
  border: 0;
  border-top: 1px solid var(--line);
}

/* "Mehr lesen" / "Weniger" (+++ in the Markdown): looks like a link */
.more-link {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit; /* the colour of the text around it, like the other links */
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.prose h2,
.prose h3,
.prose h4 {
  margin-top: 1.75rem;
  font-size: 1.25rem;
  line-height: 1.3;
}

.prose h3,
.prose h4 {
  font-size: 1.0625rem;
}

.prose ul,
.prose ol {
  margin-bottom: 0;
  padding-left: 1.25rem;
}

/* The page title and the intro below it */
.intro-text {
  font-size: 1.125rem;
  color: var(--ink-2);
}

/* Sections ------------------------------------------------------------------------- */
h2 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.subtitle {
  margin-top: 0.35rem;
  color: var(--ink-3);
  font-size: 0.9375rem;
}

.warning,
.load-error {
  margin-top: 1.25rem;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--ink);
  background: var(--wash);
}

/* Colour keys & legend --------------------------------------------------------------- */
.key {
  display: inline-block;
  flex: none;
  width: 0.75rem;
  height: 0.75rem;
  margin-right: 0.45rem;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  list-style: none;
  padding: 0;
  margin: 2rem 0 0;
  font-size: 0.9375rem;
  color: var(--ink-2);
}

.legend li {
  display: flex;
  align-items: center;
}

/* Boxes: everything with content sits in a white box with a black
   hairline on the gray page (panel, editor, score, each comparison, the
   history chart, the text pages). */
.box,
.council-panel,
.editor,
.score,
.comparison,
.history {
  background: var(--bg);
  border: 1px solid var(--ink);
}

.score,
.comparison,
.history {
  padding: clamp(1rem, 3vw, 1.5rem);
}

/* Federal Council: the 7 seats ------------------------------------------------------ */
.council-panel {
  margin-top: 1rem;
  overflow: hidden;
}

.council {
  list-style: none;
  padding: 0;
  /* Hairline grid: each card draws its right/bottom edge; the negative
     margins push the outermost edges under the panel border. */
  margin: 0 -1px -1px 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
}

.member {
  display: flex;
  gap: 0.875rem;
  align-items: flex-start;
  padding: 1.125rem 1rem;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  color: #fff;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.avatar-female { background: var(--female); }
.avatar-male { background: var(--male); }

/* Portrait photo, shown as it is. The box is portrait-shaped (3:4) so
   photos need little cropping; faces are usually in the upper part. */
.portrait {
  flex: none;
  display: block;
  width: 3rem;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  object-position: center 20%;
  background: var(--wash); /* while loading */
}

.member-body {
  min-width: 0;
}

/* Next to a portrait, the body is at least as tall as the photo and the
   buttons sit at its bottom, level with the photo's lower edge (unless a
   long name needs two lines). */
.portrait + .member-body {
  display: flex;
  flex-direction: column;
  min-height: 4rem; /* portrait: 3rem wide, 3:4 */
}

.portrait + .member-body .member-actions {
  margin-top: auto;
  padding-top: 0.25rem;
}

.member-name {
  font-weight: 600;
  line-height: 1.3;
}

.member-meta {
  font-size: 0.875rem;
  color: var(--ink-2);
  line-height: 1.45;
}

.member-name + .member-meta {
  margin-top: 0.2rem;
}

/* Canton flag instead of the canton code ("[flag] SVP"): square, about
   as tall as the letters next to it. The faint ring keeps white flags
   (e.g. Basel-Stadt, Solothurn) visible on the white card. Hovering it
   shows the canton's name (setupFlagLabels in app.js). */
.flag {
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  margin-right: 0.4em;
  vertical-align: -0.1em;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
}

/* On a candidate's card the flag lies above the invisible radio button,
   so it can be hovered (a click still chooses the person) */
.person .flag {
  position: relative;
}

/* Panel head: period, dates, buttons, slider. Sticks to the top of the
   screen while scrolling through the whole page. */
.panel-head {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 5;
  margin-top: clamp(2.5rem, 7vw, 3.5rem); /* below the page title */
  padding: 1rem 1rem 0.5rem;
  background: var(--bg);
  border: 1px solid var(--ink);
}

/* One row: ‹ dates (and the score, once it is out of view) › */
.panel-top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
}

.panel-middle {
  display: flex;
  flex-wrap: wrap; /* narrow screens: the score goes below the dates */
  justify-content: center;
  align-items: center;
  gap: 0.25rem 1.5rem;
  text-align: center;
}

/* The dates. On phones the font is smaller and the title always takes two
   lines, so the navigator keeps its height while stepping through the
   versions. */
.panel-period {
  text-wrap: balance;
  font-weight: 700;
  font-size: clamp(1.25rem, 3.5vw, 1.5rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 36rem) {
  .panel-period {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(2 * 1.2em);
    font-size: 1.125rem;
  }
}

.nav-btn {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--ink);
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.nav-btn svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.nav-btn:hover:not(:disabled) {
  background: var(--ink);
  color: #fff;
}

.nav-btn:disabled {
  border-color: var(--line);
  color: var(--line);
  cursor: default;
}

/* Sliders (timeline, age in the editor): thin black track, square black
   thumb (1rem wide) */
.range {
  display: block;
  width: 100%;
  height: 1.5rem;
  margin: 0;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.range::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--ink);
}

.range::-moz-range-track {
  height: 2px;
  background: var(--ink);
}

.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 1rem;
  height: 1rem;
  margin-top: calc(-0.5rem + 1px);
  border: 2px solid var(--bg);
  background: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}

.range::-moz-range-thumb {
  border-radius: 0; /* Firefox rounds the thumb by default */
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--bg);
  background: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}

.range:focus-visible {
  outline-offset: 2px;
}

.nav-range {
  margin-top: 0.75rem;
}

/* Year labels under the slider. --at (0..1) is set in app.js; the thumb's
   centre travels from 0.5rem to (100% - 0.5rem), so the labels do too. */
.nav-ticks {
  position: relative;
  height: 1.25rem;
  font-size: 0.75rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.tick {
  position: absolute;
  top: 0;
  left: calc(0.5rem + (100% - 1rem) * var(--at));
  transform: translateX(-50%);
  white-space: nowrap;
}

.tick-start {
  left: 0;
  transform: none;
}

/* "73 % Übereinstimmung" next to the dates, like them in size and weight:
   only shown while the big score is off screen */
.nav-score {
  display: none;
  font-weight: 700;
  font-size: clamp(1.25rem, 3.5vw, 1.5rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.panel-head.show-score .nav-score {
  display: block;
}

/* Where dates and score don't always fit side by side (the longest
   dates, "16. Aug. 1895 – 11. März 1897", need about 900 px), the score
   always gets its own line, so the navigator doesn't change height
   between versions. */
@media (max-width: 57rem) {
  .nav-score {
    flex-basis: 100%;
  }
}

@media (max-width: 36rem) {
  .nav-score {
    font-size: 1.125rem;
  }
}

/* Replacing a member --------------------------------------------------------------------- */

/* Small text buttons on the cards ("Ersetzen", "Bearbeiten", "Rückgängig") */
.link-button {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 0.8125rem;
  color: var(--ink-2);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.member-actions {
  display: flex;
  gap: 0.875rem;
  margin-top: 0.4rem;
  line-height: 1.2;
}

/* A person created by the user */
.member.is-new {
  background: var(--wash);
}

/* A member who has announced their resignation (can be replaced) */
.member.is-leaving {
  background: var(--leaving);
}

.avatar-new {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* The editor */
.editor {
  margin-top: 1rem;
  padding: 1.25rem;
  scroll-margin-top: 11rem; /* keep it clear of the sticky panel head */
}

.editor-title {
  margin: 0 0 1.25rem;
  font-size: clamp(1.25rem, 3vw, 1.5rem);
  line-height: 1.2;
}

.editor-fields {
  display: grid;
  gap: 1.25rem;
}

.editor-field {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.editor-field legend,
.editor-label {
  padding: 0;
  font-weight: 600;
}

.editor-note {
  margin-top: 0.35rem;
  font-size: 0.9375rem;
  color: var(--ink-3);
}

/* The three ways to replace a member */
.modes {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  border: 1px solid var(--ink);
}

.mode-button {
  flex: 1 1 auto;
  padding: 0.6rem 0.9rem;
  border: 0;
  border-right: 1px solid var(--ink);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.mode-button:last-child {
  border-right: 0;
}

.mode-button:hover {
  background: var(--wash);
}

.mode-button[aria-pressed="true"] {
  background: var(--ink);
  color: #fff;
}

/* Narrow screens: the three modes stacked */
@media (max-width: 36rem) {
  .modes {
    flex-direction: column;
  }

  .modes .mode-button {
    border-right: 0;
    border-bottom: 1px solid var(--ink);
  }

  .modes .mode-button:last-child {
    border-bottom: 0;
  }
}

/* History view ------------------------------------------------------------------------ */
.history {
  margin-top: 1rem;
}

.history .legend {
  margin-top: 1.25rem;
  gap: 0.5rem;
}

/* Legend of the history chart: one button per line. Mouse over: preview
   the line; click: keep it emphasized (pressed). */
.legend-button {
  display: flex;
  align-items: center;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--line);
  background: var(--bg);
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.legend-button[aria-pressed="true"] {
  border-color: var(--ink);
  color: var(--ink);
}

.legend-button.is-muted {
  color: var(--ink-3);
}

.legend-button.is-muted .key-line {
  background: var(--chart-muted);
}

/* Legend key for a line: a short stroke in the colour of its series */
.key-line {
  display: inline-block;
  flex: none;
  width: 1rem;
  height: 2px;
  margin-right: 0.45rem;
  background: var(--series-color, currentColor);
}

.key-line-strong {
  height: 3px;
}

.chart {
  position: relative;
  margin-top: 1rem;
}

.chart-svg {
  display: block;
  max-width: 100%;
  overflow: visible;
}

.chart-grid {
  stroke: var(--line);
  stroke-width: 1;
}

.chart-axis {
  stroke: var(--ink-3);
  stroke-width: 1;
}

.chart-label {
  fill: var(--ink-3);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.chart-band {
  fill: var(--wash);
}

.chart-band-hover {
  fill: rgba(11, 11, 11, 0.05);
}

/* Lines: the primary one (overall) strong; the others thinner and lighter
   ("average first, details on request") */
.chart-line {
  fill: none;
  stroke: var(--series-color);
  stroke-width: 3px;
  stroke-linejoin: round;
  stroke-linecap: round;
  transition: stroke 0.15s, stroke-width 0.15s, opacity 0.15s;
}

.chart-line.is-secondary {
  stroke-width: 1.5px;
  opacity: 0.75;
}

/* One line emphasized (legend or pointer): it keeps its colour and gets
   strong, all others turn light gray */
.chart.has-focus .chart-line {
  stroke: var(--chart-muted);
  stroke-width: 1.5px;
  opacity: 1;
}

.chart.has-focus .chart-line.is-focus {
  stroke: var(--series-color);
  stroke-width: 3px;
}

.chart-dot {
  fill: var(--series-color);
  stroke: var(--bg);
  stroke-width: 2;
}

.chart.has-focus .chart-dot:not(.is-focus) {
  display: none;
}

/* Catches the pointer over the plot area; clicking selects a Council */
.chart-hit {
  fill: transparent;
  cursor: pointer;
}

.chart-tooltip {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  min-width: 12rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--line);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  font-size: 0.875rem;
  color: var(--ink-2);
}

.chart-tooltip-title {
  font-weight: 600;
  color: var(--ink);
}

.chart-tooltip-rows {
  display: grid;
  gap: 0.15rem;
  margin: 0.4rem 0 0;
  padding: 0;
  list-style: none;
  font-variant-numeric: tabular-nums;
}

.chart-tooltip-rows li {
  display: grid;
  grid-template-columns: auto 7ch 1fr; /* line key, value ("100.0 %"), label */
  align-items: center;
  gap: 0.5rem;
}

.chart-tooltip-rows strong {
  color: var(--ink);
  text-align: right;
}

.chart-tooltip-rows .key-line {
  margin-right: 0;
}

/* The emphasized line in the tooltip: the others recede */
.chart.has-focus .chart-tooltip-rows li:not(.is-focus) {
  opacity: 0.5;
}

.chart-tooltip-rows li.is-focus {
  font-weight: 600;
  color: var(--ink);
}

.editor-fields > .link-button {
  justify-self: start;
}

/* "Offizielle Kandidierende": one card per person, in a grid like the
   Council's (hairlines between the cards, no scrolling inside the box) */
.person-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.person {
  position: relative;
  display: block;
  cursor: pointer;
}

/* The radio button covers the whole card (invisible) */
.person input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.person-card {
  display: flex;
  gap: 0.875rem;
  align-items: flex-start;
  height: 100%;
  padding: 0.875rem 1rem;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.person-text {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
}

.person:hover .person-card {
  background: var(--wash);
}

/* The person chosen: grey, with a black bar on the left */
.person input:checked + .person-card {
  background: var(--wash);
  box-shadow: inset 3px 0 0 var(--ink);
}

.person input:focus-visible + .person-card {
  outline: 2px solid var(--ink);
  outline-offset: -2px;
}

.person-name {
  font-weight: 600;
  line-height: 1.3;
}

.person-meta {
  font-size: 0.875rem;
  color: var(--ink-2);
  line-height: 1.45;
}

/* Options as "chips": radio buttons styled as small toggles */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.5rem;
}

.chip {
  position: relative;
  cursor: pointer;
}

/* The real radio sits invisibly on top of its label: clickable and
   keyboard-accessible (arrow keys move between options). */
.chip input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.chip > span {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--line);
  font-size: 0.9375rem;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.chip:hover > span {
  border-color: var(--ink);
}

.chip input:checked + span {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.chip input:focus-visible + span {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.editor-age-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.5rem;
}

.editor-age-value {
  font-variant-numeric: tabular-nums;
}

/* Live result inside the editor */
.editor-result {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.editor-result-label {
  font-weight: 600;
}

.editor-score {
  margin-top: 0.25rem;
  font-size: clamp(2.25rem, 8vw, 3rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.editor-delta {
  margin-top: 0.5rem;
  font-weight: 600;
}

.editor-scores {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.9375rem;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.editor-actions {
  margin-top: 1.25rem;
}

/* Main button: black, white text */
.button {
  padding: 0.6rem 1.25rem;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.button:hover {
  background: var(--ink-2);
}

/* Smaller version, on a card ("Ersetzen") */
.button-small {
  padding: 0.3rem 0.75rem;
  font-size: 0.8125rem;
  line-height: 1.2;
}

/* Score -------------------------------------------------------------------------------- */
.score {
  margin-top: 1rem;
}

.score-label {
  font-weight: 600;
}

.score-value {
  font-size: clamp(4rem, 17vw, 8rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
  margin-top: 0.5rem;
  font-variant-numeric: tabular-nums; /* no jitter while the number counts */
}

.score-caption {
  font-size: 0.9375rem;
  color: var(--ink-3);
}

/* Comparison sections (gender, party, language, age) ------------------------------- */
.comparison {
  margin-top: 1rem;
}

.comparison-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.comparison h3,
.history-title,
.box-title {
  margin: 0;
  font-size: clamp(1.25rem, 3vw, 1.5rem);
  line-height: 1.2;
}

.comparison-score {
  font-size: clamp(1.75rem, 6vw, 2.5rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.comparison-note {
  font-size: 0.9375rem;
  color: var(--ink-3);
}

.comparison-note:empty {
  display: none;
}

/* No data for this time: only the note is shown */
.comparison.is-unavailable .legend,
.comparison.is-unavailable .bars {
  display: none;
}

.comparison .legend {
  margin-top: 0.75rem;
}

/* Comparison bars --------------------------------------------------------------------- */
.bars {
  margin-top: 1.25rem;
  display: grid;
  gap: 1.75rem;
}

.bar-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin-bottom: 0.5rem;
}

.bar-name {
  font-weight: 600;
}

.bar-values {
  color: var(--ink-2);
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
}

.bar {
  display: flex;
  gap: 2px;                 /* white gap between segments */
  height: 1.5rem;           /* 24px */
}

.seg {
  flex-basis: 0;            /* width comes from flex-grow = share */
  min-width: 2px;
  cursor: default;
  transition: flex-grow 0.6s var(--ease), opacity 0.15s;
}


.bar:hover .seg:not(:hover) {
  opacity: 0.55;            /* the hovered segment stands out */
}

/* Tooltip ------------------------------------------------------------------------------ */
.tooltip {
  position: fixed;
  z-index: 10;
  pointer-events: none;
  display: grid;
  gap: 0.1rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--line);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  font-size: 0.875rem;
  color: var(--ink-2);
  max-width: 20rem;
}

.tooltip strong {
  font-size: 1.125rem;
  color: var(--ink);
}

.tooltip-detail {
  color: var(--ink-3);
}

/* The canton's name above a flag: a small label */
.tooltip.is-compact {
  padding: 0.25rem 0.5rem;
  font-size: 0.8125rem;
}

.tooltip-label {
  color: var(--ink);
  font-weight: 600;
}

.tooltip-detail:empty {
  display: none;
}

/* Names of the Council members in a segment, in one line */
.tooltip-names {
  margin-top: 0.3rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--line);
  color: var(--ink);
}

/* What a grouped segment contains ("Übrige Parteien", "Andere Sprachen") */
.tooltip-breakdown {
  list-style: none;
  margin: 0.4rem 0 0.2rem;
  padding: 0.4rem 0 0;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 0.1rem;
  font-variant-numeric: tabular-nums;
}

.tooltip-breakdown li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

/* Footer ------------------------------------------------------------------------------- */
.footer {
  margin-top: clamp(4rem, 12vw, 6rem);
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  font-size: 0.875rem;
  color: var(--ink-3);
  padding-bottom: env(safe-area-inset-bottom);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  align-items: baseline;
}

.footer-links .link-button {
  font-size: inherit;
  color: inherit;
}

/* Consent banner for Google Analytics (analytics.js) ------------------------------------- */
.consent {
  position: fixed;
  inset: auto 0 0;
  z-index: 50;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  padding-block: 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
  /* Lined up with the page content (.page) on wide screens */
  padding-inline: max(var(--gutter), calc((100% - var(--max)) / 2 + var(--gutter)));
  background: var(--bg);
  border-top: 1px solid var(--ink);
  font-size: 0.875rem;
}

.consent-text {
  flex: 1 1 28rem;
  max-width: 65ch;
  margin: 0;
}

.consent-buttons {
  display: flex;
  gap: 0.5rem;
}

@media (max-width: 30rem) {
  .consent-buttons {
    width: 100%;
  }

  .consent-buttons .button {
    flex: 1;
  }
}

/* Pages with running text: Quellen, Datenschutzerklärung ------------------------------- */
.text-page h2 {
  margin-top: 2.25rem;
  margin-bottom: 0.5rem;
  font-size: 1.25rem;
}

/* The content of a text page sits in white boxes, like the main page */
.text-box {
  margin-top: 1.5rem;
  padding: clamp(1rem, 3vw, 1.5rem);
}

.text-box + .text-box {
  margin-top: 1rem;
}

.text-page .text-box > :first-child {
  margin-top: 0;
}

.text-page p,
.text-page ul {
  max-width: 65ch;
}

.text-page p + p {
  margin-top: 0.75rem;
}

.text-page ul {
  margin: 0;
  padding-left: 1.25rem;
}

.text-lead {
  margin-top: 1.5rem;
  color: var(--ink-2);
}

.text-note {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: var(--ink-3);
}

/* Sources and picture credits: plain lists, one entry per line */
.text-page .source-list {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.375rem;
  overflow-wrap: anywhere; /* some credits contain long web addresses */
}

.text-page .credits-list {
  margin-top: 0.5rem;
  font-size: 0.875rem;
}

/* Picture credits: one group each for councillors, candidates and flags */
.text-page h3 {
  margin: 1.5rem 0 0;
  font-size: 1rem;
}

/* "Zurück zur Übersicht": a plain link, below the boxes and above the title */
.back-link {
  margin-top: 2.25rem;
}

.back-link-top {
  margin: 0 0 1.5rem;
}

/* A page title inside its box (Kontakt), like "Geschlecht" on the main page */
.text-page .box-title {
  margin-bottom: 0.75rem;
}

/* Small screens --------------------------------------------------------------------------- */
@media (max-width: 30rem) {
  .member {
    padding: 0.875rem;
  }
}

/* Motion ---------------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .seg,
  .nav-btn,
  .chip > span,
  .mode-button,
  .legend-button,
  .chart-line {
    transition: none;
  }
}
