body[data-page="aikajana"] {
  --timeline-bg: var(--pk-bg-dark);
  --timeline-ink: var(--pk-text-dark);
  --timeline-muted: var(--pk-text-muted-dark);
  --timeline-line: var(--pk-border-dark);
  --timeline-surface: var(--pk-surface-dark, #1e1e1e);
  --timeline-hover: rgba(255, 255, 255, 0.08);
  --timeline-motion: 0.24s;
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--timeline-bg);
  color: var(--timeline-ink);
  font-family: Roboto, sans-serif;
}

html[data-theme="light"] body[data-page="aikajana"] {
  --timeline-bg: var(--pk-bg-light);
  --timeline-ink: var(--pk-text-light);
  --timeline-muted: var(--pk-text-muted-light);
  --timeline-line: var(--pk-border-light);
  --timeline-surface: var(--pk-surface-light, #fff);
  --timeline-hover: rgba(0, 0, 0, 0.06);
}

.timeline-page {
  --timeline-pad-top: clamp(26px, 5vw, 66px);
  --timeline-pad-x: clamp(16px, 4vw, 46px);
  flex: 1;
  max-width: 1080px;
  padding: var(--timeline-pad-top) var(--timeline-pad-x) 40px;
}

.timeline-header {
  padding-bottom: 20px;
  margin-bottom: clamp(20px, 3vw, 32px);
  border-bottom: 1px solid var(--timeline-line);
}

.timeline-header h1 {
  margin: 0;
  font-size: clamp(2rem, 5.2vw, 4.25rem);
  line-height: 1.06;
  letter-spacing: -0.035em;
}

.timeline-status {
  color: var(--timeline-muted);
  font-size: 0.88rem;
}

.timeline-status:empty { display: none; }

/* ---- The finder: the search, and a highlight's navigation ----
   #timeline-tools holds the finder's place on the page: beside today's line
   on wide screens, over the heading row on narrow ones. .timeline-finder fills
   that place, or pins to the top of the window once it scrolls away (js sets
   --finder-top, --finder-left and --finder-width). */

.timeline-tools {
  --finder-height: 42px;
  position: absolute;
  z-index: 25;
  height: var(--finder-height);
}

.timeline-tools[hidden] { display: none; }

.timeline-finder {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.timeline-finder > * { pointer-events: auto; }

/* Pinning and clearance are calculated from the finder's current bounds. */
.timeline-finder,
.timeline-finder-bar { transition-property: none; }

.timeline-tools.is-pinned .timeline-finder {
  position: fixed;
  inset: auto;
  top: var(--finder-top, 12px);
  left: var(--finder-left, auto);
  width: var(--finder-width, 22rem);
  height: var(--finder-height);
}

/* The finder at rest: a magnifier. */
.timeline-finder-open {
  position: absolute;
  top: 0;
  right: 0;
  display: none;
  width: 42px;
  height: 42px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--timeline-line);
  border-radius: 999px;
  background: var(--timeline-bg);
  color: var(--timeline-ink);
  cursor: pointer;
}

.timeline-finder-open:hover { border-color: var(--timeline-muted); }

.timeline-finder-bar {
  border-radius: var(--pk-card-radius, 8px);
}

/* Layer the card fill over the page colour to make the finder opaque. */
.timeline-finder-bar,
.is-pinned .timeline-finder-open {
  background: linear-gradient(var(--timeline-surface), var(--timeline-surface)), var(--timeline-bg);
}

.timeline-finder-controls {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1px;
  height: var(--finder-height);
  padding-right: 4px;
}

.is-focus .timeline-finder-controls { height: auto; }

/* The pinned magnifier floats over the timeline. */
.is-pinned .timeline-finder-open {
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.32);
}

html[data-theme="light"] .is-pinned .timeline-finder-open {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
}

/* Bar or magnifier. At the top of a wide page the bar is always there. */
.timeline-tools:not(.is-open) .timeline-finder-bar { display: none; }
.timeline-tools:not(.is-open) .timeline-finder-open { display: grid; }

@media (min-width: 900px) {
  .timeline-tools:not(.is-pinned) .timeline-finder-bar { display: block; }
  .timeline-tools:not(.is-pinned) .timeline-finder-open { display: none; }
}

/* The site paints every svg the page colour (style.css; with !important in
   the light theme), which would put a square behind each icon here. */
.timeline-finder svg,
html[data-theme="light"] .timeline-finder svg { background-color: transparent !important; }

.timeline-finder svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.timeline-finder-open svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.7;
}

/* The search face. */
.timeline-search {
  flex: 1 1 auto;
  align-self: stretch;
  min-width: 0;
}

.timeline-search[hidden] { display: none; }

.timeline-search .timeline-search-icon {
  position: absolute;
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
  stroke: var(--timeline-muted);
  stroke-width: 1.7;
  pointer-events: none;
}

.timeline-search:focus-within .timeline-search-icon {
  stroke: var(--timeline-ink);
  stroke-width: 2;
}

.timeline-search-input {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  padding: 0 6px 0 36px;
  border: 0;
  border-radius: 8px;
  outline: none;
  background: transparent;
  color: var(--timeline-ink);
  font: inherit;
  font-size: 1rem;
  appearance: none;
}

/* The finder's own × does this job. */
.timeline-search-input::-webkit-search-cancel-button { display: none; }

.timeline-search-input::placeholder { color: var(--timeline-muted); }

/* The suggestions and person card sit below the controls in the same box. */
.timeline-suggestions {
  max-height: min(62dvh, 28rem);
  overflow-y: auto;
  margin: 0;
  padding: 0 0 6px;
  list-style: none;
}

.timeline-suggestions[hidden] { display: none; }

.timeline-suggestion-group {
  padding: 9px 12px 3px;
  color: var(--timeline-muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.timeline-suggestion {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 6px 12px;
  font-size: 0.92rem;
  cursor: pointer;
}

.timeline-suggestion:hover,
.timeline-suggestion[aria-selected="true"] { background: var(--timeline-hover); }

.timeline-suggestion[aria-selected="true"] { box-shadow: inset 2px 0 var(--timeline-ink); }

.timeline-suggestion-name {
  min-width: 0;
  overflow-wrap: anywhere;
}

.timeline-suggestion-meta,
.timeline-suggestion-empty {
  color: var(--timeline-muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.timeline-suggestion-empty { padding: 8px 12px; }

/* The name and count get the full first row. The event and its controls fit
   below it, with the shared close button in the last column. */
.timeline-focus {
  display: grid;
  flex: 1 1 0;
  grid-template-columns: minmax(0, 1fr) repeat(3, auto) 34px;
  grid-template-areas: "heading heading heading heading heading"
                       "event person previous next .";
  grid-template-rows: auto 34px;
  align-items: center;
  column-gap: 1px;
  min-width: 0;
  padding-block: 4px;
}

.timeline-focus[hidden] { display: none; }

.timeline-focus-text {
  grid-area: heading;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  min-width: 0;
  min-height: 28px;
  margin: 0;
  padding: 3px 8px 3px 13px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--timeline-ink);
  font: inherit;
  font-size: 0.88rem;
  text-align: left;
  cursor: text;
}

.timeline-focus-text:hover { background: var(--timeline-hover); }

.timeline-focus-text:focus-visible { outline: none; }

.timeline-focus-text:focus-visible .timeline-focus-name {
  text-decoration: underline 2px;
  text-underline-offset: 0.2em;
}

.timeline-focus-name {
  min-width: 0;
  overflow-wrap: anywhere;
}

.timeline-focus-count {
  flex: none;
  color: var(--timeline-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.timeline-focus-current {
  grid-area: event;
  display: -webkit-box;
  overflow: hidden;
  padding-left: 13px;
  color: var(--timeline-muted);
  font-size: 0.78rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.timeline-focus-step[data-step="-1"] { grid-area: previous; }
.timeline-focus-step[data-step="1"] { grid-area: next; }

.timeline-focus-step,
.timeline-finder-close {
  display: grid;
  flex: none;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--timeline-ink);
  cursor: pointer;
}

.timeline-focus-step:hover:not(:disabled),
.timeline-finder-close:hover { background: var(--timeline-hover); }

.timeline-focus-step:disabled {
  opacity: 0.35;
  cursor: default;
}

/* × always ends the highlight's face. On the search face it closes the box,
   so it shows where there is a magnifier to go back to, or text to clear. */
.timeline-finder-close { display: none; }

.is-focus .timeline-finder-close,
.is-editing .timeline-finder-close,
.is-pinned .timeline-finder-close,
.has-text .timeline-finder-close { display: grid; }

.is-focus .timeline-finder-close {
  position: absolute;
  right: 4px;
  bottom: 4px;
}

/* ---- Person card ----
   A highlighted person's card is the lower half of the finder itself: it
   unfolds from the bar under the person button (aikajana.js: renderPerson),
   with the bar's fill and a divider between the two. Party
   colours appear only as the dots beside group names. */

.timeline-focus-person {
  grid-area: person;
  display: grid;
  flex: none;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--timeline-muted);
  cursor: pointer;
}

.timeline-focus-person[hidden] { display: none; }

.timeline-focus-person:hover,
.timeline-focus-person[aria-expanded="true"] {
  background: var(--timeline-hover);
  color: var(--timeline-ink);
}

.timeline-focus-person svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
}

.person-card {
  max-height: min(70dvh, 34rem);
  overflow-y: auto;
  box-sizing: border-box;
  padding: 11px 13px 13px;
  border-radius: 0 0 8px 8px;
  background: linear-gradient(var(--timeline-line), var(--timeline-line)) center top / calc(100% - 26px) 1px no-repeat;
  color: var(--timeline-ink);
  font-size: 0.84rem;
  line-height: 1.5;
  cursor: auto;
}

.person-card[hidden] { display: none; }

.person-card-text { margin: 0; }

.person-card-facts {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 5px 14px;
  margin: 12px 0 0;
}

.person-card-facts dt {
  color: var(--timeline-muted);
  font-size: 0.74rem;
  line-height: 1.75;
}

.person-card-facts dd {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.person-card-group {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  white-space: nowrap;
}

.person-card-group-name { font-weight: 700; }

.person-card-group[data-party]::before {
  content: "";
  align-self: center;
  width: 8px;
  height: 8px;
  margin-right: 2px;
  border-radius: 50%;
  background: var(--party-color);
}

.person-card-sources {
  display: none;
  margin: 12px 0 0;
  color: var(--timeline-muted);
  font-size: 0.74rem;
}

.timeline-content.is-showing-sources .person-card-sources { display: block; }

.person-card-sources a { color: inherit; text-underline-offset: 3px; }

/* ---- The axis ---- */

.timeline-content {
  --timeline-years: 4.25rem;
  --timeline-governments: 10rem;
  --timeline-rail: calc(var(--timeline-years) + var(--timeline-governments) - 2px);
  --timeline-marker-step: 1.125rem;
  --timeline-label-gap: 0.55rem;
  --timeline-event-inset: calc(var(--timeline-rail) + var(--timeline-marker-step) + var(--timeline-label-gap));
}

.timeline-axis {
  position: relative;
  cursor: grab;
}

.timeline-axis.is-dragging {
  cursor: grabbing;
  user-select: none;
}

.timeline-axis.is-dragging * { cursor: grabbing; }

.timeline-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  overflow: visible;
  pointer-events: none;
}

.timeline-line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.timeline-tick-marks {
  fill: none;
  stroke: var(--timeline-muted);
  stroke-width: 1.25;
  stroke-linecap: round;
}

.timeline-year-rules {
  fill: none;
  stroke: var(--timeline-line);
  stroke-width: 1;
}

/* Cabinet boundaries (js/aikajana.js paint), under the line like the rules. */
.timeline-boundaries {
  fill: none;
  stroke: var(--timeline-line);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.timeline-years {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--timeline-years);
}

.timeline-year {
  position: absolute;
  left: 0;
}

.timeline-year span {
  position: absolute;
  top: 5px;
  color: var(--timeline-muted);
  font-size: 1.16rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.timeline-governments {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--timeline-years);
  width: var(--timeline-governments);
}

.timeline-government {
  position: absolute;
  left: 0;
  right: 0;
}


.timeline-government-label {
  position: sticky;
  z-index: 1;
  top: 12px;
  padding: 8px 14px 8px 3px;
  font-size: 0.92rem;
  /* js/aikajana.js puts soft hyphens in long words, so a word that has to
     break does so at a syllable, with a hyphen. */
  overflow-wrap: break-word;
  hyphens: manual;
}

.timeline-government-label strong,
.timeline-government-label span { background: var(--timeline-bg); }

.timeline-government-label span {
  display: block;
  width: fit-content;
  margin-top: 3px;
  color: var(--government-color);
  font-size: 0.78rem;
  font-weight: 700;
}

/* ---- Events ---- */

.timeline-events,
.timeline-day-events {
  list-style: none;
  padding: 0;
  margin: 0;
}

.timeline-day {
  position: absolute;
  left: var(--timeline-rail);
  right: 0;
  padding-left: calc(var(--timeline-marker-step) + var(--timeline-label-gap));
  /* Days a few pixels apart overlap: a later row's box reaches over the labels
     of the one above it. Only the labels themselves take the pointer. */
  pointer-events: none;
}

.timeline-day-labels {
  display: flow-root;
  max-width: 44rem;
  margin-top: calc(var(--timeline-label-offset, 0px) - 0.5rem);
  pointer-events: auto;
  cursor: auto;
}

.timeline-day-labels > .timeline-date {
  display: table;
  background: var(--timeline-bg);
  line-height: 1rem;
}

.timeline-date {
  color: var(--timeline-muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.timeline-event-title {
  color: inherit;
  font-size: 0.98rem;
  font-weight: 500;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.timeline-marker {
  position: absolute;
  z-index: 1;
  top: 0;
  left: 0;
  width: var(--timeline-marker-step);
  height: 1.4rem;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
}

.timeline-marker::before {
  content: "";
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--timeline-ink);
  box-shadow: 0 0 0 2px var(--timeline-bg);
}

.timeline-day--election > .timeline-marker::before {
  border-radius: 0;
  transform: rotate(45deg);
}

.timeline-now .timeline-marker::before {
  background: var(--timeline-bg);
  border: 2px solid var(--timeline-ink);
}

.timeline-election .timeline-event-title { font-weight: 750; }

/* "Näytä lähteet" in the footer (js/aikajana.js). */
.timeline-sources {
  display: none;
  margin: 3px 0 0;
  color: var(--timeline-muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.timeline-content.is-showing-sources .timeline-sources { display: block; }

.timeline-sources a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

.timeline-sources a:hover { color: var(--timeline-ink); }

.timeline-label { background: var(--timeline-bg); }

button.timeline-event-title {
  display: block;
  font-family: inherit;
  text-align: left;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

/* The last word and the arrow wrap together. */
.timeline-label-end { white-space: nowrap; }

button.timeline-event-title .timeline-label-end::after {
  content: "›";
  display: inline-block;
  margin-left: 0.3em;
  color: var(--timeline-muted);
  transition: transform var(--timeline-motion) ease;
}

.timeline-event.is-open .timeline-label-end::after { transform: rotate(90deg); }

.timeline-event-title:hover .timeline-label,
.timeline-event-title:focus-visible .timeline-label {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.timeline-day:has(.timeline-event-title:hover) > .timeline-marker::before,
.timeline-day:has(.timeline-event-title:focus-visible) > .timeline-marker::before {
  outline: 1px solid var(--timeline-ink);
  outline-offset: 2px;
}

/* Details open in place: the line below makes room, nothing covers the page. */
.timeline-event-detail {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--timeline-motion) ease;
}

.timeline-event-detail-inner {
  min-height: 0;
  overflow: hidden;
  visibility: hidden;
  transition: visibility 0s linear var(--timeline-motion);
  cursor: text;
}

.timeline-event.is-open .timeline-event-detail { grid-template-rows: 1fr; }

/* Closed at once when a highlight moves on, so the page does not shift under the scroll. */
.timeline-event.is-instant .timeline-event-detail,
.timeline-event.is-instant .timeline-event-detail-inner { transition: none; }

.timeline-event.is-open .timeline-event-detail-inner {
  visibility: visible;
  transition-delay: 0s;
}

.timeline-event-text {
  margin: 5px 0 0;
  padding-left: 10px;
  border-left: 2px solid var(--timeline-line);
  font-size: 0.9rem;
  line-height: 1.45;
}

.timeline-event-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  margin: 6px 0 2px;
  padding-left: 12px;
  color: var(--timeline-ink);
  font-size: 0.8rem;
  font-weight: 500;
}

/* People and parties are buttons: they highlight their other events. */
.timeline-person,
.timeline-party {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  text-decoration: underline dotted;
  text-decoration-color: var(--timeline-muted);
  text-underline-offset: 0.22em;
}

.timeline-event-tags .timeline-party {
  color: var(--timeline-muted);
  font-weight: 700;
}

.timeline-person:hover,
.timeline-party:hover,
.timeline-person:focus-visible,
.timeline-party:focus-visible,
.timeline-event-tags .timeline-party:is(:hover, :focus-visible) {
  color: var(--timeline-ink);
  text-decoration-style: solid;
  text-decoration-color: currentColor;
}

.timeline-party::before,
.timeline-results-swatch::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--party-color);
}

.timeline-event:last-child .timeline-event-detail-inner { padding-bottom: 2px; }

/* ---- Election results ---- */

.timeline-result-strips {
  display: grid;
  gap: 7px;
  max-width: 24rem;
  margin: 5px 0 2px;
  cursor: pointer;
}

.timeline-result {
  display: grid;
  gap: 4px;
}

.timeline-result-kind {
  color: var(--timeline-muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.timeline-result-bar {
  display: flex;
  gap: 1px;
  height: 7px;
  overflow: hidden;
  border-radius: 2px;
}

.timeline-result-segment {
  flex: 1 1 0;
  min-width: 0;
  background: var(--party-color);
}

.timeline-result-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 11px;
  color: var(--timeline-muted);
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}

.timeline-result-item::before,
.timeline-suggestion-name[data-party]::before,
.timeline-focus-name[data-party]::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--party-color);
  vertical-align: 0.06em;
}

.timeline-result-name {
  color: var(--timeline-ink);
  font-weight: 600;
}

.timeline-results {
  width: min(100% - 12px, 27rem);
  margin: 8px 0 4px 12px;
  border-collapse: collapse;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}

.timeline-results caption {
  padding-bottom: 4px;
  color: var(--timeline-muted);
  font-size: 0.74rem;
  text-align: left;
}

.timeline-results th,
.timeline-results td {
  padding: 2px 0;
  font-weight: 400;
  text-align: left;
  vertical-align: baseline;
}

.timeline-results thead th {
  padding-bottom: 3px;
  border-bottom: 1px solid var(--timeline-line);
  color: var(--timeline-muted);
  font-size: 0.7rem;
  font-weight: 600;
}

.timeline-results tbody tr:first-child > * { padding-top: 5px; }

.timeline-results .is-number {
  padding-left: 10px;
  text-align: right;
  white-space: nowrap;
}

/* th.: ".timeline-results th" above would otherwise zero it. */
.timeline-results th.timeline-results-name { padding-right: 8px; }

/* A line may break after an inline-block, so in a narrow column the dot used
   to sit alone above the name. As a flex pair the dot stays with the name:
   only the name's own words wrap, and the column is at least dot plus the
   longest word. */
.timeline-results-name > :is(.timeline-party, .timeline-results-swatch) {
  display: inline-flex;
  align-items: baseline;
}

.timeline-results-name .timeline-party,
.timeline-results-party {
  font-weight: 700;
}

.timeline-results-note,
.timeline-results-change { color: var(--timeline-muted); }

.timeline-results-note { font-size: 0.72rem; }

.timeline-results td.timeline-results-bar {
  width: 38%;
  vertical-align: middle;
}

.timeline-results td.timeline-results-bar span {
  display: block;
  min-width: 1px;
  height: 8px;
  border-radius: 1px;
  background: var(--party-color);
}

/* ---- Highlighting ---- */

.timeline-event,
.timeline-date { transition: opacity 0.2s ease; }

.timeline-content.is-filtering .timeline-event:not(.is-match),
.timeline-content.is-filtering .timeline-day:not(.has-match) > .timeline-day-labels > .timeline-date {
  opacity: 0.28;
}

.timeline-content.is-filtering .timeline-day:not(.has-match) > .timeline-marker {
  opacity: 0.28;
}

.timeline-content.is-filtering .timeline-day.has-match > .timeline-marker::before {
  box-shadow: 0 0 0 2px var(--timeline-bg), 0 0 0 3.5px var(--timeline-ink);
}

.timeline-day:has(.timeline-event.is-current) > .timeline-marker::before {
  background: var(--timeline-bg);
  border: 3px solid var(--timeline-ink);
}

.timeline-event.is-current > .timeline-event-title .timeline-label {
  text-decoration: underline 2px;
  text-underline-offset: 0.22em;
}

/* ---- Year scrubber ---- */

.timeline-scrubber:not([hidden]) {
  position: fixed;
  z-index: 20;
  top: 76px;
  bottom: 24px;
  right: 0;
  width: 26px;
  transition: opacity var(--timeline-motion) ease;
}

.timeline-scrubber[inert] {
  opacity: 0;
  pointer-events: none;
}

/* The page padding plus this keeps text clear of the narrow scrubber. */
.timeline-content { padding-right: 12px; }

@media (min-width: 760px) {
  .timeline-scrubber:not([hidden]) {
    right: 10px;
    width: 64px;
  }

  .timeline-content { padding-right: 72px; }
}

.timeline-scrubber-track {
  position: absolute;
  inset: 0;
  cursor: pointer;
  touch-action: none;
  user-select: none;
}

.timeline-scrubber-cabinets {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 14px;
  width: 4px;
  border-radius: 2px;
  overflow: hidden;
  background: var(--timeline-line);
}

.timeline-scrubber-cabinet {
  position: absolute;
  left: 0;
  right: 0;
}

.timeline-scrubber-years {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline-scrubber-year {
  position: absolute;
  right: 20px;
  width: 4px;
  border-top: 1px solid var(--timeline-line);
}

.timeline-scrubber-year.is-labelled {
  width: 8px;
  border-color: var(--timeline-muted);
}

.timeline-scrubber-year button {
  display: none;
  position: absolute;
  right: 10px;
  top: 0;
  transform: translateY(-50%);
  padding: 2px 3px;
  border: 0;
  background: transparent;
  color: var(--timeline-muted);
  font: inherit;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.timeline-scrubber-year button:hover { color: var(--timeline-ink); }

@media (min-width: 760px) {
  .timeline-scrubber-year button { display: block; }
}

.timeline-scrubber-matches {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.timeline-scrubber-match {
  position: absolute;
  right: 11px;
  width: 10px;
  height: 2px;
  margin-top: -1px;
  border-radius: 1px;
  background: var(--timeline-ink);
}

.timeline-scrubber-thumb {
  position: absolute;
  right: 8px;
  width: 16px;
  min-height: 10px;
  border: 1.5px solid var(--timeline-ink);
  border-radius: 5px;
  pointer-events: none;
}

.timeline-scrubber-bubble {
  position: absolute;
  right: 74px;
  transform: translateY(-50%);
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--timeline-ink);
  color: var(--timeline-bg);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.timeline-scrubber.is-active .timeline-scrubber-bubble,
.timeline-scrubber.is-pulling .timeline-scrubber-bubble,
.timeline-scrubber-track:hover .timeline-scrubber-bubble { opacity: 1; }

@media (max-width: 759px) {
  .timeline-scrubber-cabinets { right: 9px; width: 3px; }
  .timeline-scrubber-year { display: none; }
  .timeline-scrubber-thumb { right: 4px; width: 13px; }
  .timeline-scrubber-match { right: 6px; width: 9px; }
  .timeline-scrubber-bubble { right: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  body[data-page="aikajana"] { --timeline-motion: 0s; }
}

/* ---- Wide screens: the heading turns on its side ---- */

@media (min-width: 900px) {
  .timeline-page {
    --timeline-heading-size: clamp(2.5rem, 4vw, 3.75rem);
    --timeline-desktop-padding: clamp(16px, 4vw, 46px);
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    max-width: none;
    padding: clamp(24px, 3vw, 40px) 0 40px;
  }

  .timeline-header,
  .timeline-content {
    grid-area: 1 / 1;
  }

  .timeline-header {
    justify-self: start;
    align-self: start;
    margin: 0 0 0 var(--pk-gutter-desktop);
    padding: 0;
    border: 0;
  }

  .timeline-header h1 {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: var(--timeline-heading-size);
  }

  .timeline-content {
    --timeline-content-right: max(var(--timeline-desktop-padding), 76px);
    position: relative;
    width: 100%;
    max-width: var(--pk-content-max);
    margin-inline: auto;
    /* Reserve the heading width and gap within the centred timeline. */
    padding-inline: calc(var(--timeline-desktop-padding) + 1.06 * var(--timeline-heading-size) + clamp(24px, 3vw, 44px))
      var(--timeline-content-right);
  }

  /* The search waits in the empty corner beside today's line, so the timeline
     itself starts at the top. layout() keeps the event labels below it. */
  .timeline-tools {
    top: -7px;
    right: var(--timeline-content-right);
    width: min(22rem, 40%);
  }
}

/* ---- Narrow screens: the finder over the heading row ----
   At rest it is a magnifier at the end of the row; open, the bar covers the
   heading, so nothing below moves. */

@media (max-width: 899.98px) {
  .timeline-page { position: relative; }

  /* The heading row is the finder's 44px; content-box, so the padding below
     is extra. */
  .timeline-header {
    display: flex;
    align-items: center;
    box-sizing: content-box;
    min-height: 44px;
    padding-right: 56px;
    padding-bottom: 14px;
    margin-bottom: 18px;
  }

  .timeline-header h1 { font-size: clamp(1.75rem, 7.4vw, 2.6rem); }

  /* The finder follows the content edge, with room for the year scrubber. */
  .timeline-tools {
    --finder-height: 44px;
    top: var(--timeline-pad-top);
    left: var(--timeline-pad-x);
    right: max(30px, calc(var(--timeline-pad-x) + 12px));
  }

  .timeline-finder-open {
    width: 44px;
    height: 44px;
  }

  .timeline-finder-close { display: grid; }

  @media (min-width: 760px) {
    .timeline-tools { right: calc(var(--timeline-pad-x) + 72px); }
  }

  /* An open pinned bar spans the width: the sticky government name waits
     below it. */
  .timeline-page.has-pinned-finder .timeline-government-label { top: var(--pinned-finder-clearance, 60px); }
}

@media (max-width: 600px) {
  /* The events need the width more than the cabinet names do. */
  .timeline-content {
    --timeline-years: 1.75rem;
    --timeline-governments: 4.75rem;
    --timeline-marker-step: 0.875rem;
    --timeline-label-gap: 0.4rem;
  }

  .timeline-year span { font-size: 0.74rem; }

  /* The right padding keeps a sticky label clear of the markers on the axis. */
  .timeline-government-label {
    padding-right: 10px;
    padding-left: 2px;
    font-size: 0.68rem;
    line-height: 1.2;
  }

  .timeline-government-label span { font-size: 0.64rem; }
  .timeline-event-title { font-size: 0.9rem; }
}

.timeline-result-measures {
  margin: 6px 0 3px 12px;
  color: var(--timeline-muted);
  font-size: 0.75rem;
}

.timeline-results-toggle {
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.timeline-results-toggle::after {
  content: "›";
  display: inline-block;
  margin-left: 0.35em;
  color: var(--timeline-muted);
}

.timeline-results-toggle[aria-expanded="true"]::after { transform: rotate(90deg); }
.timeline-results-toggle:hover { text-decoration: underline; text-underline-offset: 0.2em; }
.timeline-results tbody.timeline-results-extra[hidden] { display: none; }
.timeline-results-extra th.timeline-results-name { padding-left: 0.75em; }

.timeline-results-archive { table-layout: fixed; }
.timeline-results-archive th.timeline-results-name { padding-right: 5px; }
.timeline-results-archive .timeline-results-name > :is(.timeline-party, .timeline-results-party) {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.timeline-results-votes { width: 5rem; }
.timeline-results-share { width: 3.25rem; }
.timeline-results-seats { width: 3.15rem; }

@media (max-width: 600px) {
  .timeline-results-archive .is-number { box-sizing: border-box; padding-left: 4px; }
  .timeline-results-votes { width: 4rem; }
  .timeline-results-share { width: 2.45rem; }
  .timeline-results-seats { width: 2.2rem; }
}

.timeline-prelude {
  max-width: calc(var(--timeline-event-inset) + 44rem);
  padding-top: 16px;
  border-top: 1px solid var(--timeline-line);
  scroll-margin-top: 76px;
}

.timeline-prelude h2 { margin: 0 0 16px; font-size: 1.25rem; }
.timeline-prelude-day { position: static; padding: 0 0 12px; pointer-events: auto; }
.timeline-prelude-day .timeline-day-labels {
  display: grid;
  grid-template-columns: var(--timeline-event-inset) minmax(0, 1fr);
  align-items: baseline;
  max-width: none;
  margin: 0;
}
.timeline-prelude-day .timeline-date { padding-inline-end: var(--timeline-label-gap); }
.timeline-prelude-day .timeline-event + .timeline-event { margin-top: 6px; }

/* The earlier entries are in document flow. Open their details at full height. */
.timeline-prelude-day .timeline-event-detail { display: none; }
.timeline-prelude-day .timeline-event.is-open .timeline-event-detail { display: block; }
.timeline-prelude-day .timeline-event-detail-inner { overflow: visible; }

@media (max-width: 360px) {
  .timeline-content {
    --timeline-years: 1.75rem;
    --timeline-governments: 3.25rem;
  }
  .timeline-results-archive { width: 100%; margin-left: 0; }
  .timeline-results-archive .timeline-results-votes { width: 3.65rem; }
  .timeline-results-archive .timeline-results-seats { width: 2rem; }
}

/* ---- Ajankuvat ----
   A card on the years in view (js/aikajana.js, js/ajankuvat.json). Wide
   screens give it the column under the search: each card sticks there while
   its years pass, beside a hairline bracket that spans them, and the event
   labels stop short of the column. Narrower screens get a bar at the bottom
   that opens the same card. No party colour anywhere: the card is about the
   times, not a side. */

.timeline-eras { display: none; }

/* No outline beside the line: the card's own tone sets it apart, and the
   year bracket is the only hairline. Floating over the timeline in the bar's
   sheet it takes one (below). */
.timeline-era-card {
  position: relative;
  z-index: 2;
  padding: 16px 18px 14px;
  border-radius: var(--pk-card-radius, 8px);
  background: var(--timeline-surface);
  color: var(--timeline-ink);
  cursor: auto;
}

.timeline-era-kicker,
.timeline-era-subhead {
  margin: 0;
  color: var(--timeline-muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.timeline-era-title {
  margin: 6px 0 10px;
  color: inherit;
  font-size: 1.1rem;
  line-height: 1.25;
}

.timeline-era-text {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.55;
  /* "pretty" (accessibility-theme.css) leaves a ragged run of short lines
     at the end of a paragraph this narrow. */
  text-wrap: wrap;
}

.timeline-era-subhead {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--timeline-line);
}

.timeline-era-events {
  display: grid;
  gap: 1px;
  margin: 6px -8px 0;
  padding: 0;
  list-style: none;
}

.timeline-era-events a {
  display: grid;
  grid-template-columns: 6.4rem minmax(0, 1fr);
  column-gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  color: inherit;
  font-size: 0.84rem;
  line-height: 1.3;
  text-decoration: none;
}

.timeline-era-events a:hover { background: var(--timeline-hover); }

.timeline-era-date {
  color: var(--timeline-muted);
  font-variant-numeric: tabular-nums;
}

.timeline-era-event::after {
  content: "\00a0›";
  color: var(--timeline-muted);
}

.timeline-era-sources { margin-top: 12px; }

@media (min-width: 1200px) {
  .timeline-eras {
    display: block;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 22rem;
    pointer-events: none;
  }

  /* No bracket: the cards' years overlap the events they cover, so a line
     claiming an exact stretch would mislead. */
  .timeline-era {
    position: absolute;
    left: 0;
    right: 0;
  }

  /* The finder can extend downwards when it opens a panel. */
  .timeline-era .timeline-era-card.is-leaving { pointer-events: none; }

  .timeline-era .timeline-era-card {
    position: sticky;
    top: var(--era-top, 68px);
    max-height: max(0px, calc(100dvh - var(--era-top, 68px) - 16px));
    margin-left: 18px;
    overflow-y: auto;
    pointer-events: auto;
    transition-property: none;
  }

  .timeline-axis.has-eras .timeline-day-labels { max-width: min(44rem, calc(100% - 22rem - 2.5rem)); }

  .timeline-era-dock { display: none !important; }
}

/* Before independence the cards are part of the dated list. */
.timeline-prelude-era {
  max-width: 34rem;
  margin: 4px 0 24px var(--timeline-event-inset);
}

@media (max-width: 600px) {
  .timeline-prelude-era { margin-left: 0; }
}

/* Folded: the years and the title are the button that opens the card. */
.timeline-era-card.is-folded { padding: 0; }

.timeline-era-card.is-folded .timeline-era-title { margin: 0; }

.timeline-era-toggle {
  display: block;
  width: 100%;
  padding: 13px 18px 14px;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.timeline-era-toggle .timeline-era-kicker { display: block; margin-bottom: 5px; }

/* Event labels wear the page colour to cut the axis line; on a card that
   shows as a dark box. */
.timeline-era-toggle .timeline-label { background: none; }

.timeline-era-toggle .timeline-label-end::after {
  content: "›";
  display: inline-block;
  margin-left: 0.3em;
  color: var(--timeline-muted);
  transition: transform var(--timeline-motion) ease;
}

.timeline-era-card.is-open .timeline-era-toggle .timeline-label-end::after { transform: rotate(90deg); }

.timeline-era-toggle:hover .timeline-label,
.timeline-era-toggle:focus-visible .timeline-label {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.timeline-era-body { padding: 0 18px 14px; }

/* The bar beside the corner button; open, the card above it. */
.timeline-era-dock {
  position: fixed;
  z-index: 24;
  left: calc(70px + env(safe-area-inset-left));
  right: calc(40px + env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom) + var(--dock-lift, 0px));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
}

.timeline-era-dock[hidden],
.timeline-era-dock-sheet[hidden] { display: none; }

.timeline-era-dock.is-covered { visibility: hidden; }

.timeline-era-dock > * { pointer-events: auto; }

/* Two short lines, so the title has the bar's whole width. */
.timeline-era-dock-toggle {
  display: grid;
  grid-template-columns: minmax(0, auto) auto;
  align-items: center;
  column-gap: 12px;
  max-width: 100%;
  min-height: 44px;
  padding: 5px 16px 5px 18px;
  border: 1px solid var(--timeline-line);
  border-radius: 22px;
  text-align: left;
  background: var(--timeline-surface);
  color: var(--timeline-ink);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  font: inherit;
  cursor: pointer;
}

html[data-theme="light"] .timeline-era-dock-toggle,
html[data-theme="light"] .timeline-era-dock-sheet .timeline-era-card { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12); }

.timeline-era-dock-toggle:hover { border-color: var(--timeline-muted); }

.timeline-era-dock-kicker {
  grid-area: 1 / 1;
  color: var(--timeline-muted);
  font-size: 0.6rem;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.timeline-era-dock-label {
  grid-area: 2 / 1;
  min-width: 0;
  line-height: 1.25;
  overflow: hidden;
  font-size: 0.88rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-era-dock-toggle::after {
  content: "";
  grid-area: 1 / 2 / 3;
  width: 7px;
  height: 7px;
  margin-left: 2px;
  border-top: 1.6px solid var(--timeline-muted);
  border-right: 1.6px solid var(--timeline-muted);
  transform: translateY(2px) rotate(-45deg);
  transition: transform var(--timeline-motion) ease;
}

.timeline-era-dock.is-open .timeline-era-dock-toggle::after { transform: translateY(-2px) rotate(135deg); }

/* The open card lines up with the corner button's left edge. */
.timeline-era-dock-sheet {
  width: min(calc(100% + 54px), 26rem);
  margin-left: -54px;
}

.timeline-era-dock-sheet .timeline-era-card {
  border: 1px solid var(--timeline-line);
  max-height: min(65dvh, 32rem, var(--dock-sheet-space, 100dvh));
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

/* ---- The corner: back to the top, or the menu ----
   Bottom left, in the margin beside the timeline. aikajana.js shows it once
   the top of the page has scrolled away, and lifts it clear of the footer
   (--corner-lift). Below 1120px the header collapses to the menu button, so
   the corner opens the menu instead (site-ui.js runs it). */

.timeline-corner {
  position: fixed;
  z-index: 30;
  left: calc(16px + env(safe-area-inset-left));
  bottom: calc(16px + env(safe-area-inset-bottom) + var(--corner-lift, 0px));
  transition: opacity var(--timeline-motion) ease, visibility var(--timeline-motion);
}

.timeline-corner:not(.is-shown) {
  opacity: 0;
  visibility: hidden;
}

.timeline-corner-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--timeline-line);
  border-radius: 999px;
  background: var(--timeline-surface);
  color: var(--timeline-muted);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  cursor: pointer;
}

html[data-theme="light"] .timeline-corner-button { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12); }

.timeline-corner-button:hover {
  border-color: var(--timeline-muted);
  color: var(--timeline-ink);
}

/* As in the finder: no page-coloured square behind the icon. */
.timeline-corner svg,
html[data-theme="light"] .timeline-corner svg { background-color: transparent !important; }

.timeline-corner svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.timeline-corner-menu { display: none; }

@media (max-width: 1120px) {
  .timeline-corner-top { display: none; }

  /* The size and colour of the pinned magnifier at the top. */
  .timeline-corner-menu {
    display: grid;
    width: 44px;
    height: 44px;
    color: var(--timeline-ink);
  }

  .timeline-corner-menu svg { width: 18px; height: 18px; }

  /* The footer moves into the menu here, so the page ends clear of the
     button instead. */
  .timeline-page { padding-bottom: 84px; }
}
