/* Bundesrat Visualization — editorial dataviz */
@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Serif:wght@400;500;600&display=swap");

:root {
  --color-bg:           #f4f4f4;
  --color-bg-deep:      #ececec;
  --color-fg:           #060b11;
  --color-border:       #e2e2e2;
  --color-border-strong:#cfcfcf;
  --color-accent:       #bb342f;
  --color-accent-dark:  #7e2320;
  --fg2:                rgba(6, 11, 17, 0.62);
  --fg3:                rgba(6, 11, 17, 0.38);
  --fg4:                rgba(6, 11, 17, 0.18);

  --font-sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", SFMono-Regular, Consolas, Menlo, monospace;
  --font-serif:"IBM Plex Serif", Georgia, "Times New Roman", serif;

  /* Party colors — German political conventions */
  --p-cdu:      #111111;
  --p-csu:      #111111;
  --p-spd:      #d72027;
  --p-gruene:   #1c8a3a;
  --p-fdp:      #f0d300;
  --p-linke:    #b73491;
  --p-pds:      #b73491;
  --p-afd:      #009ee0;
  --p-bsw:      #6b2c91;
  --p-fw:       #ff7f00;
  --p-zentrum:  #2b3a67;
  --p-kpd:      #8b0000;
  --p-bp:       #1e6091;
  --p-bhe:      #6a4a2a;
  --p-dp:       #5a4a2a;
  --p-other:    #8a8a8a;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--color-fg);
  background: var(--color-bg);
  font-feature-settings: "ss01", "cv11", "tnum";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 36px 64px;
}

/* ── Header ──────────────────────────────────────────── */
.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 14px;
  margin-bottom: 26px;
}
.masthead .eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg2);
}
.masthead h1 {
  margin: 6px 0 0;
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 34px;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.masthead h1 .accent { color: var(--color-accent); font-weight: 600; }
.masthead .blurb {
  max-width: 360px;
  font-size: 13.5px;
  color: var(--fg2);
  line-height: 1.5;
  text-align: right;
}

/* ── Main grid ───────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 36px;
  align-items: start;
}
@media (max-width: 1060px) {
  .grid { grid-template-columns: 1fr; }
  .masthead { flex-direction: column; gap: 12px; }
  .masthead .blurb { display: none; }
}

/* ── Stage (chart canvas) ────────────────────────────── */
.stage {
  position: relative;
  background: var(--color-bg);
  padding: 8px 0 0;
}

.chart-wrap { position: relative; width: 100%; }
.chart-wrap svg { display: block; width: 100%; height: auto; margin-top: -3%; }

/* center labels in the open semicircle */
.center-stack {
  text-align: center;
  pointer-events: none;
}
@media (min-width: 768px) {
  .center-stack {
    position: relative;
    z-index: 1;
    margin-bottom: clamp(-80px, -9%, -40px);
  }
}
.center-stack .date {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 28px;
  letter-spacing: -0.01em;
  line-height: 1;
}
.center-stack .meta {
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg2);
}

/* tooltip */
.tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 30;
  background: #ffffff;
  border: 1px solid var(--color-border-strong);
  box-shadow: 0 8px 24px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  padding: 10px 12px 11px;
  border-radius: 4px;
  min-width: 180px;
  max-width: 280px;
  font-size: 13px;
  opacity: 0;
  transform: translate(-50%, -100%);
  transition: opacity 0.12s ease;
}
.tooltip.show { opacity: 1; }
.tooltip .tt-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 2px;
}
.tooltip .tt-sub {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--fg2);
  margin-bottom: 8px;
}
.tooltip .tt-parties { display: flex; flex-direction: column; gap: 4px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; }
.tooltip .tt-swatch {
  width: 12px; height: 12px; border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.06);
}
.tooltip .tt-pname { font-size: 12.5px; }
.tooltip .tt-note {
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--color-border);
  font-size: 12px; color: var(--fg2); font-style: italic;
}

/* state segments */
svg { -webkit-tap-highlight-color: transparent; }
.seg { transition: opacity 0.08s ease; cursor: default; }
.seg-group.dim .seg { opacity: 0.35; }
.seg-group .state.hover .seg { opacity: 1; }
.state-divider { stroke: var(--color-bg); stroke-width: 4; fill: none; }
.party-divider { stroke: var(--color-bg); stroke-width: 2.2; fill: none; }
.state-label { font-size: 13px; font-weight: 600; fill: var(--color-fg); font-family: var(--font-sans); transition: opacity 0.08s ease; }
.state-tick { stroke: var(--color-fg); stroke-width: 1.25; transition: opacity 0.08s ease; }
.outer-tick { stroke: var(--color-border-strong); stroke-width: 5; stroke-linecap: butt; }
.seat-tick { transition: opacity 0.08s ease; }

/* When a state is hovered: dim every other state's label, radial tick, and seat ticks */
.seg-group.dim .state .state-label { opacity: 0.25; }
.seg-group.dim .state.hover .state-label { opacity: 1; }
.seg-group.dim .state-tick { opacity: 0.25; }
.seg-group.dim .state-tick.hover { opacity: 1; }
.seg-group.dim .seat-tick { opacity: 0.25; }
.seg-group.dim .seat-tick.hover { opacity: 1; }

/* ── Side panel ──────────────────────────────────────── */
.side {
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.panel {
  background: var(--color-bg);
}
.panel h3 {
  margin: 0 0 10px;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg2);
}

.totals-list { display: flex; flex-direction: column; gap: 7px; }
.total-row {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--color-border);
}
.total-row:last-child { border-bottom: none; }
.total-row .swatch { width: 12px; height: 12px; border-radius: 2px; }
.total-row .name { font-size: 13.5px; font-weight: 500; }
.total-row .value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 500;
}
.total-row .bar {
  grid-column: 1 / -1;
  height: 3px;
  margin-top: 2px;
  background: var(--color-border);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
.total-row .bar > i {
  display: block;
  height: 100%;
  background: currentColor;
  transition: width 0.25s ease;
}

/* ── Selected-state info panel ─────────────────────── */
.state-info-panel { display: flex; flex-direction: column; gap: 10px; }
.state-info-panel[hidden] { display: none; }
.si-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.si-head h3 { margin: 0; }
.si-close {
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--fg2);
  cursor: pointer;
  padding: 0 4px;
  border-radius: 3px;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.si-close:hover { background: var(--color-bg-deep); color: var(--color-fg); }
.si-name {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.01em;
  line-height: 1.15;
}
.si-sub {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg2);
}
.si-parties { display: flex; flex-direction: column; gap: 5px; margin-top: 2px; }
.si-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.si-row .si-swatch {
  width: 12px; height: 12px; border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.06);
}
.si-note {
  margin-top: 4px; padding: 9px 10px;
  background: var(--color-bg-deep);
  border-left: 2px solid var(--color-accent);
  font-size: 12.5px;
  color: var(--fg2);
  line-height: 1.5;
  font-style: italic;
}
.si-source {
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-accent);
  text-decoration: none;
  white-space: nowrap;
  margin-left: 2px;
}
.si-source:hover { text-decoration: underline; color: var(--color-accent-dark); }
.si-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 6px;
}
.si-navbtn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  color: var(--color-fg);
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
.si-navbtn:hover:not(:disabled) { background: var(--color-bg-deep); border-color: var(--color-border-strong); }
.si-navbtn:disabled { opacity: 0.4; cursor: default; }
.si-navbtn .si-arrow {
  font-size: 18px;
  font-weight: 500;
  color: var(--color-accent);
  line-height: 1;
}
.si-navbtn .si-navlabel { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.si-navbtn .si-navlabel.right { text-align: right; align-items: flex-end; }
.si-navhint {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg3);
}
.si-navdate {
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--color-fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Selected-state visualization (sticky, similar to hover) */
.seg-group.selected .seg { opacity: 0.35; }
.seg-group.selected .state.selected .seg { opacity: 1; }
.seg-group.selected .state .state-label { opacity: 0.25; }
.seg-group.selected .state.selected .state-label { opacity: 1; }
.seg-group.selected .state-tick { opacity: 0.25; }
.seg-group.selected .state-tick.selected { opacity: 1; }
.seg-group.selected .seat-tick { opacity: 0.25; }
.seg-group.selected .seat-tick.selected { opacity: 1; }

.summary {
  font-size: 13px;
  color: var(--fg2);
  line-height: 1.55;
}
.summary .big {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 600;
  color: var(--color-fg);
  line-height: 1.1;
  display: block;
  margin-bottom: 2px;
}
.summary .big sup {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--fg2);
  margin-left: 4px;
  vertical-align: super;
}

/* ── Timeline (YouTube-like) ─────────────────────────── */
.timeline {
  margin-top: 28px;
  padding: 14px 16px 16px;
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: 4px;
}
.tl-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 10px;
}
.tl-controls { display: flex; align-items: center; gap: 4px; }
.tl-btn {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; cursor: pointer;
  border-radius: 4px;
  color: var(--color-fg);
  transition: background-color 0.12s ease;
}
.tl-btn:hover { background: var(--color-bg-deep); }
.tl-btn:active { background: var(--color-border); }
.tl-btn svg { width: 18px; height: 18px; }
.tl-btn.play { width: 42px; height: 42px; }
.tl-btn.play svg { width: 22px; height: 22px; }

/* the scrub bar */
.tl-scrub {
  position: relative;
  height: 28px;
  cursor: pointer;
  user-select: none;
  touch-action: none;
}
.tl-track {
  position: absolute;
  left: 0; right: 0; top: 50%;
  transform: translateY(-50%);
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  overflow: hidden;
}
.tl-fill {
  position: absolute;
  inset: 0;
  width: 0%;
  background: var(--color-accent);
  transform-origin: left;
}
.tl-scrub:hover .tl-track { height: 6px; }
.tl-thumb {
  position: absolute;
  top: 50%;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--color-accent);
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.12s ease;
  pointer-events: none;
}
.tl-scrub:hover .tl-thumb,
.tl-scrub.dragging .tl-thumb { transform: translate(-50%, -50%) scale(1); }

/* event ticks (changes) */
.tl-ticks {
  position: absolute;
  left: 0; right: 0; top: 50%;
  transform: translateY(-50%);
  height: 14px;
  pointer-events: none;
}
.tl-tick {
  position: absolute;
  top: 50%;
  width: 1px; height: 8px;
  background: var(--fg4);
  transform: translate(-50%, -50%);
}

/* year axis */
.tl-axis {
  position: relative;
  height: 18px;
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--fg3);
}
.tl-axis .yr {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  white-space: nowrap;
}
.tl-axis .yr.major {
  color: var(--fg2);
  font-weight: 500;
}
.tl-axis .yr.major::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -6px;
  width: 1px;
  height: 4px;
  background: var(--fg4);
}

/* hover tooltip on scrub */
.tl-hover {
  position: absolute;
  bottom: 100%;
  margin-bottom: 8px;
  background: var(--color-fg);
  color: #fff;
  padding: 4px 8px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 11px;
  pointer-events: none;
  transform: translateX(-50%);
  opacity: 0;
  white-space: nowrap;
  transition: opacity 0.1s ease;
}
.tl-hover.show { opacity: 1; }
.tl-hover::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--color-fg);
}

/* footer */
.footer {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
  font-size: 12px;
  color: var(--fg2);
  line-height: 1.6;
  display: flex;
  justify-content: space-between;
  gap: 24px;
}
.footer a { color: var(--color-accent); text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* ── Responsive: mobile ────────────────────────────────── */
@media (max-width: 600px) {
  .app { padding: 20px 16px 48px; }
  .masthead h1 { font-size: 26px; }
}
