/* Weimar HSC learning page — mobile-first, accessible */

:root {
  --bg: #f4f1ec;
  --surface: #ffffff;
  --text: #1a1a1a;
  --muted: #5c5c5c;
  --border: #d4cfc4;
  --accent: #2c5282;
  --focus: #2563eb;
  --majority: #7c3aed;
  --cause-bg: #fef3c7;
  --cause-border: #d97706;
  --effect-bg: #dbeafe;
  --effect-border: #2563eb;
  --event-bg: #f3f4f6;
  --radius: 10px;
  --touch: 44px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --surface: #1e1e1e;
    --text: #ececec;
    --muted: #a3a3a3;
    --border: #3a3a3a;
    --accent: #90cdf4;
    --cause-bg: #422006;
    --cause-border: #f59e0b;
    --effect-bg: #1e3a5f;
    --effect-border: #60a5fa;
    --event-bg: #2a2a2a;
  }
}

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

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

img,
svg,
canvas {
  max-width: 100%;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: #fff;
  z-index: 100;
}

.skip-link:focus {
  left: 0;
}

header {
  padding: 1rem 1rem 0.5rem;
  max-width: 1200px;
  margin: 0 auto;
}

header h1 {
  font-size: clamp(1.25rem, 4vw, 1.75rem);
  margin: 0 0 0.35rem;
  line-height: 1.25;
}

.how-to {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
}

.layout {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

@media (min-width: 960px) {
  .layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  .col-left,
  .col-right {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.panel h2 {
  font-size: 1.1rem;
  margin: 0 0 0.75rem;
}

.timeline-sticky {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  padding: 0.5rem 0;
  border-top: 1px solid var(--border);
  margin: 0 -1rem;
  padding-left: 1rem;
  padding-right: 1rem;
}

@media (min-width: 960px) {
  .timeline-sticky {
    position: static;
    border-top: none;
    margin: 0;
    padding: 0;
  }
}

.timeline-wrap {
  position: relative;
  padding: 0.5rem 0 2rem;
}

.timeline-phases {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.timeline-phases span {
  flex: 1;
}

#timeline-slider {
  width: 100%;
  min-height: var(--touch);
  accent-color: var(--accent);
}

.timeline-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--muted);
}

.timeline-dots {
  position: relative;
  height: 24px;
  margin-top: 0.25rem;
}

.timeline-dot {
  position: absolute;
  transform: translateX(-50%);
  width: var(--touch);
  height: var(--touch);
  margin-top: -10px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timeline-dot::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border);
}

.timeline-dot[aria-current="true"]::after {
  width: 14px;
  height: 14px;
  background: var(--focus);
}

.timeline-nav {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.timeline-nav button {
  flex: 1;
  min-height: var(--touch);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
}

.timeline-nav button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

#chart-container {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 220px;
  border-radius: var(--radius);
  overflow: hidden;
  background: #1a1a2e;
}

#chart-container canvas,
#chart-container svg {
  display: block;
  width: 100%;
  height: 100%;
}

#chart-container .chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 1rem;
}

#chart-container .chart-empty[hidden] {
  display: none;
}

.chart-meta {
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

.chart-meta .election-title {
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.chart-notes {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.legend {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.35rem 0.75rem;
  margin-top: 0.75rem;
  font-size: 0.8rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}

.majority-row {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-left: 4px solid var(--majority);
  background: var(--event-bg);
  font-size: 0.85rem;
}

.coalition-grid {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.coalition-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  padding: 0.25rem 0;
}

.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.badge-yes {
  background: #dcfce7;
  color: #166534;
}

.badge-no {
  background: #fee2e2;
  color: #991b1b;
}

@media (prefers-color-scheme: dark) {
  .badge-yes {
    background: #14532d;
    color: #bbf7d0;
  }
  .badge-no {
    background: #450a0a;
    color: #fecaca;
  }
}

#map-svg {
  width: 100%;
  height: auto;
  max-height: 280px;
}

.map-region {
  fill: var(--event-bg);
  stroke: var(--border);
  stroke-width: 1.5;
}

.map-region.highlight {
  fill: #fcd34d;
  stroke: #d97706;
}

@media (prefers-color-scheme: dark) {
  .map-region.highlight {
    fill: #854d0e;
    stroke: #fbbf24;
  }
}

.map-city {
  fill: var(--text);
  font-size: 11px;
  font-family: var(--font);
}

.event-card .date-line {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.event-card .phase-tag {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  background: var(--event-bg);
  margin-bottom: 0.5rem;
}

.event-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}

.power-line {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
  font-style: italic;
}

.flow {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

@media (min-width: 600px) {
  .flow {
    flex-direction: row;
    align-items: stretch;
  }
}

.flow-box {
  flex: 1;
  padding: 0.75rem;
  border-radius: var(--radius);
  position: relative;
}

.flow-box h4 {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.flow-cause {
  background: var(--cause-bg);
  border: 1px solid var(--cause-border);
}

.flow-event {
  background: var(--event-bg);
  border: 1px solid var(--border);
}

.flow-effect {
  background: var(--effect-bg);
  border: 1px solid var(--effect-border);
}

.flow-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 1.25rem;
  min-width: 1.5rem;
}

.party-bar-wrap {
  margin-bottom: 1rem;
}

.party-bar {
  display: flex;
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.party-bar span {
  flex: 1;
}

.party-list details {
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0;
}

.party-list summary {
  cursor: pointer;
  min-height: var(--touch);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  list-style: none;
}

.party-list summary::-webkit-details-marker {
  display: none;
}

.party-list summary::before {
  content: "▸";
  color: var(--muted);
}

.party-list details[open] summary::before {
  content: "▾";
}

.party-detail {
  padding: 0.5rem 0 0.75rem 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.party-detail p {
  margin: 0.35rem 0;
}

.quiz-phase {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 2px solid var(--border);
}

.quiz-q {
  margin: 0.75rem 0;
}

.quiz-options label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  min-height: var(--touch);
  padding: 0.35rem 0;
  cursor: pointer;
}

.quiz-feedback {
  font-size: 0.9rem;
  margin-top: 0.35rem;
  min-height: 1.25rem;
}

.quiz-score {
  font-weight: 600;
  margin-top: 0.5rem;
}

footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem 2rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
}

footer h2 {
  font-size: 1rem;
  color: var(--text);
}

footer ul {
  padding-left: 1.2rem;
}

footer a {
  color: var(--accent);
}

#source-links a {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.no-assembly {
  padding: 2rem 1rem;
  text-align: center;
  color: #ccc;
  font-size: 0.95rem;
}

.order-note {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.35rem;
}
