/* Simple, plain CSS — no framework. */

body {
  font-family: sans-serif;
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
  background-color: #ffffff;
  color: #1a1a1a;
}

h1 {
  font-size: 28px;
  margin-bottom: 4px;
}

#page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#page-header-row h1 {
  margin-bottom: 0;
}

#home-button {
  border: 1px solid #ccc;
  background: #f0f0f0;
  color: #444;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

#home-button:hover {
  background: #e4e4e4;
  transform: scale(1.05);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

#intro {
  color: #555;
  margin-bottom: 24px;
}

#party-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.party-card {
  border: 1px solid #ddd;
  border-left-width: 8px;
  border-radius: 6px;
  padding: 12px 14px;
  cursor: pointer;
  background: #fafafa;
}

.party-card:hover {
  background: #f0f0f0;
}

#voting-info-section {
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 24px;
  background: #fafafa;
}

.voting-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.voting-info-item h3 {
  font-size: 14px;
  margin: 0 0 4px;
}

.voting-info-item p {
  margin: 0;
  font-size: 14px;
  color: #333;
}

#overview-chart-section {
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 24px;
}

#overview-chart svg {
  width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

.overview-legend-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #666;
  padding: 2px 6px;
  border-radius: 4px;
}

.legend-item-selected {
  background: #f0f0f0;
  color: #1a1a1a;
  font-weight: bold;
}

/* "stoppa in samma funktionalitet i opinionsläge grafen som kartan" —
   same hover-to-highlight/click-to-lock pattern as the map's legend. */
.legend-item-interactive {
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.legend-item-interactive:hover {
  background: #f0f0f0;
}

/* Plain <span>s made tab-focusable via tabindex don't get a sane default
   outline from the browser the way a real <button> would — without this
   a keyboard user tabbing here would have no visible sign of it. */
.legend-item-interactive:focus-visible {
  outline: 2px solid #2b6cb0;
  outline-offset: 2px;
  background: #f0f0f0;
}

.legend-item-locked {
  background: #f0f0f0;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35);
}

#overview-chart svg polyline,
#overview-chart svg circle,
.enlarge-poll-svg polyline,
.enlarge-poll-svg circle {
  transition: opacity 0.15s ease;
}

.legend-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.party-card .abbreviation {
  font-size: 22px;
  font-weight: bold;
}

.party-card .name {
  font-size: 14px;
  color: #444;
}

.party-card .seats {
  font-size: 12px;
  color: #777;
  margin-top: 6px;
}

#party-detail {
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 16px 20px;
  margin-bottom: 24px;
}

#party-detail.hidden {
  display: none;
}

#party-detail .accent-bar {
  height: 6px;
  border-radius: 3px;
  margin-bottom: 12px;
}

#party-detail h2 {
  margin-top: 0;
  margin-bottom: 4px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.tag {
  background: #eee;
  border-radius: 12px;
  padding: 3px 10px;
  font-size: 13px;
}

.tag.historical {
  background: #f5f5f5;
  color: #888;
  font-style: italic;
}

.section-heading {
  font-size: 16px;
  font-weight: bold;
  margin-top: 18px;
  margin-bottom: 8px;
}

.own-channels a {
  display: inline-block;
  margin-right: 14px;
}

.sakfragor-intro {
  font-size: 13px;
  color: #888;
  margin: 0 0 8px;
}

.sakfragor-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sakfragor-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid #eee;
}

.sakfragor-list li:last-child {
  border-bottom: none;
}

.sakfragor-issue {
  font-weight: bold;
}

.sakfragor-fallback {
  color: #888;
  font-style: italic;
}

.vallofte-intro {
  font-size: 13px;
  color: #888;
  margin: 0 0 8px;
}

.poll-section svg {
  width: 100%;
  height: auto;
  display: block;
  margin: 4px auto 0;
}

.poll-source-note {
  font-size: 12px;
  color: #888;
  margin-top: 6px;
}

/* Poll chart + map side by side instead of stacked, to cut down on
   vertical scrolling — wraps to stacked columns on narrow viewports
   rather than squeezing both below a usable width. */
.poll-and-map-row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-start;
}

.poll-and-map-column {
  flex: 1 1 320px;
  min-width: 0;
}

.kommun-map-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.kommun-map-render-area {
  flex: 1 1 auto;
  min-width: 0;
}

.kommun-map-granularity-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 0 0 auto;
  padding-top: 4px;
}

.kommun-map-top-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.kommun-map-scale-controls,
.kommun-map-source-controls {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 4px;
}

.kommun-map-source-note {
  font-size: 12px;
  color: #888;
  margin: 6px 0 0;
  text-align: center;
}

.kommun-map-scale-option {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: #444;
  cursor: pointer;
}

.kommun-map-wrapper svg {
  width: 100%;
  max-width: 420px;
  height: auto;
  display: block;
  margin: 4px auto 0;
}

.kommun-map-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}

.kommun-map-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #666;
}

/* "för muspekaren över färgerna ... klickar man så låser man färgen" —
   swatches double as filters: hover previews, click locks (ring stays
   after the mouse leaves). */
.kommun-map-legend-item-interactive {
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.kommun-map-legend-item-interactive:hover {
  background: #f0f0f0;
}

.kommun-map-legend-item-interactive:focus-visible {
  outline: 2px solid #2b6cb0;
  outline-offset: 2px;
  background: #f0f0f0;
}

.kommun-map-legend-item-locked {
  background: #f0f0f0;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35);
}

.kommun-map-wrapper svg path {
  transition: opacity 0.15s ease;
}

.kommun-map-legend-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1px solid #ccc;
  border-radius: 2px;
}

/* "en zoom funktion på kartan skulle vara bra" / "det skulle vara fint
   med förstoring/zoom på graferna" — clicking the map or the chart
   itself (not a separate button) opens a bigger modal (see
   openEnlargeModal() in app.js). The cursor + subtle hover dimming are
   the only affordance that they're clickable, since there's no button. */
.enlargeable-svg {
  cursor: zoom-in;
  border-radius: 4px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

/* Slight scale-up + a ring, rather than just a cursor change — makes
   "this is clickable" obvious on hover, not just discoverable by
   accident. transform-origin centered so it grows evenly instead of
   shifting toward one edge. */
.enlargeable-svg:hover {
  transform: scale(1.015);
  transform-origin: center;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.15);
}

.enlargeable-svg:focus-visible {
  outline: 3px solid #2b6cb0;
  outline-offset: 2px;
}

.enlarge-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.enlarge-modal {
  background: #ffffff;
  border-radius: 8px;
  padding: 14px 20px 20px;
  max-width: 95vw;
  max-height: 95vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.enlarge-modal-close {
  align-self: flex-end;
  border: 1px solid #ccc;
  background: #f5f5f5;
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
}

.enlarge-modal-close:hover {
  background: #eee;
}

.enlarge-modal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.enlarge-modal-hint {
  font-size: 12px;
  color: #666;
  margin: 0;
}

.enlarge-modal-reset {
  border: 1px solid #ccc;
  background: #f5f5f5;
  border-radius: 4px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}

.enlarge-modal-reset:hover {
  background: #eee;
}

.enlarge-map-svg-area {
  width: min(88vw, 900px);
  max-width: 100%;
  height: min(78vh, 900px);
  touch-action: none;
  position: relative;
}

.enlarge-map-svg-area svg {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  background: #f7f7f7;
}

.enlarge-map-svg-area svg.dragging {
  cursor: grabbing;
}

/* Tapping an area on a touchscreen shows this — the SVG <title> hover
   tooltip every path already has doesn't fire on touch at all, so
   without this a mobile user has no way to find out which kommun/län
   they're looking at. Positioned in JS, above the tapped finger. */
.map-tap-label {
  position: absolute;
  transform: translate(-50%, -100%);
  background: #222;
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 1;
}

.map-tap-label.visible {
  opacity: 1;
}

.enlarge-poll-svg {
  width: min(88vw, 1300px);
  max-width: 100%;
  height: auto;
  display: block;
}

.youtube-embed iframe {
  width: 100%;
  max-width: 480px;
  aspect-ratio: 16 / 9;
  height: auto;
  border: none;
  display: block;
  margin-top: 8px;
}

.news-search {
  display: block;
  width: 100%;
  max-width: 320px;
  box-sizing: border-box;
  padding: 6px 10px;
  margin-bottom: 8px;
  font-size: 13px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.news-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 4px;
}

.news-list li {
  padding: 8px 12px;
  border-bottom: 1px solid #eee;
}

.news-list li:last-child {
  border-bottom: none;
}

.news-list .news-source {
  font-size: 12px;
  color: #888;
}

.news-list a {
  color: #1a4fba;
  text-decoration: none;
}

.news-list a:hover {
  text-decoration: underline;
}

.no-news {
  color: #888;
  font-style: italic;
}

#error-message {
  display: none;
  background-color: #fdeaea;
  border: 1px solid #e3a3a3;
  border-radius: 6px;
  padding: 12px 16px;
  color: #a12424;
  margin-bottom: 20px;
}

#error-message.visible {
  display: block;
}

footer#about {
  border-top: 1px solid #ddd;
  padding-top: 16px;
  color: #555;
  font-size: 13px;
}

/* Mobilanpassning — the granularity sidebar (Kommun/Län) sits beside the
   map in a row on desktop (see kommun-map-row's own comment above), but
   on a phone-width viewport that steals ~1/3 of the already-narrow map's
   width. Stack it below the map instead, as its own row, matching how
   Partiet/Landet and Valet 2022/Senaste already lay out above the map. */
@media (max-width: 480px) {
  .kommun-map-row {
    flex-direction: column;
  }

  .kommun-map-granularity-controls {
    flex-direction: row;
    justify-content: center;
    gap: 16px;
    padding-top: 8px;
  }

  .kommun-map-scale-controls,
  .kommun-map-source-controls {
    flex-wrap: wrap;
    row-gap: 4px;
  }
}
