@charset "UTF-8";

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100%;
}

body[data-page="hallituspohjat"] {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--pk-bg-dark, #131313);
  color: var(--pk-text-dark, #dddddd);
  font-family: Roboto, sans-serif;
}

.coalition-page {
  flex: 1 0 auto;
  width: 100%;
  padding: 12px var(--pk-gutter-desktop) 8px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-x: clip;
}

.coalition-hero {
  display: grid;
  gap: 4px;
}

.coalition-hero h1 {
  margin: 4px 0 0;
  color: #fff;
  font-size: var(--pk-page-title-size, clamp(1.35rem, 2.45vw, 2.05rem));
  line-height: 1.15;
}

.coalition-subtitle {
  margin: 0;
  color: var(--pk-text-muted-dark, #b7b7b7);
  font-size: var(--pk-page-subtitle-size, clamp(0.84rem, 1.05vw, 0.92rem));
}

.coalition-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 382px);
  gap: 10px;
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: none;
}

.visual-card,
.side-panel,
.summary-card,
.seat-selector-card {
  min-width: 0;
  box-sizing: border-box;
}

.visual-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--pk-bg-dark, #131313);
  border-radius: 0;
  overflow: visible;
  gap: 10px;
}

.party-seat-groups {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  gap: 8px;
  align-content: start;
}

.party-seat-group {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 6px;
  width: 100%;
  min-height: 96px;
  height: 100%;
  padding: 7px;
  border: 1px solid rgba(255, 255, 255, 0.085);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: #e7e9ee;
  text-align: left;
  font: inherit;
  cursor: pointer;
  box-sizing: border-box;
  transition: border-color 90ms ease, background-color 90ms ease, transform 90ms ease, opacity 90ms ease;
}

.party-seat-group:hover,
.party-seat-group:focus-visible {
  border-color: color-mix(in srgb, var(--party-color, #888) 64%, #ffffff);
  background: rgba(255, 255, 255, 0.065);
  outline: none;
}

.party-seat-group:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--party-color, #888) 42%, transparent);
}

.party-seat-group.is-selected {
  border-color: color-mix(in srgb, var(--party-color, #888) 74%, #ffffff);
  background: color-mix(in srgb, var(--party-color, #888) 18%, rgba(255, 255, 255, 0.035));
}

.party-seat-group.is-dragging {
  opacity: 0.55;
  transform: scale(0.985);
}

.party-seat-group-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.party-seat-group-abbr {
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.01em;
}

.party-seat-group-count {
  color: #c5c9d1;
  font-size: 0.75rem;
  font-weight: 900;
}

.party-seat-mini-grid {
  display: grid;
  grid-template-columns: repeat(20, minmax(0, 1fr));
  gap: 3px;
  align-content: flex-start;
}

.party-seat-mini-square {
  width: 100%;
  aspect-ratio: 1 / 1;
  min-width: 5px;
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.coalition-grid-card {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 10px;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.026);
}

.coalition-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--grid-columns, 40), minmax(0, 1fr));
  gap: 4px;
  padding: 8px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px dashed rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.coalition-grid::after {
  content: "";
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: var(--majority-line-left, 50%);
  border-left: 1px dashed rgba(255, 255, 255, 0.2);
  pointer-events: none;
  transform: translateX(-50%);
}

.coalition-grid.is-drop-target {
  border-color: rgba(235, 238, 244, 0.55);
  background: rgba(255, 255, 255, 0.055);
}

.coalition-grid-seat {
  aspect-ratio: 1 / 1;
  min-width: 0;
  border-radius: clamp(2px, 0.32vw, 5px);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.055);
}

.coalition-grid-seat.is-filled {
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14), 0 1px 4px rgba(0, 0, 0, 0.18);
}

.coalition-grid-seat.is-filled:hover {
  filter: brightness(1.16);
}

.coalition-grid-count,
.visual-description {
  margin: 0;
  color: var(--pk-text-muted-dark, #aeb3bd);
  font-size: 0.78rem;
  line-height: 1.35;
}

.coalition-grid-count {
  font-weight: 900;
}

.side-panel {
  display: grid;
  grid-template-rows: auto auto;
  gap: 8px;
  align-self: start;
  min-height: 0;
}

.summary-card,
.seat-selector-card {
  background: var(--pk-surface-muted-dark, rgba(30, 30, 30, 0.66));
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: var(--pk-card-radius, 10px);
  padding: 10px;
}

.summary-card {
  display: grid;
  gap: 8px;
}

.summary-topline,
.section-heading-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.section-heading-row {
  flex-wrap: wrap;
}

.section-heading-row > div {
  flex: 1 1 0;
  min-width: 0;
}

.section-heading-row .text-button {
  flex: 0 0 auto;
  align-self: flex-start;
}

.summary-card h2,
.seat-selector-card h2 {
  margin: 0;
  color: #f3f3f3;
  font-size: 1rem;
  line-height: 1.15;
}

.seat-selector-card p {
  margin: 4px 0 0;
  color: #aeb4bf;
  font-size: 0.76rem;
  line-height: 1.32;
}

.seat-selector-card .table-note {
  margin-top: 8px;
  color: #aeb4bf;
  font-size: 0.72rem;
}

.selected-parties {
  margin: 0;
  color: #c3c8d1;
  font-size: 0.85rem;
  line-height: 1.3;
}

.majority-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 9px;
  background: rgba(160, 166, 176, 0.16);
  color: #dadde3;
  font-weight: 900;
  font-size: 0.76rem;
  white-space: nowrap;
}

.majority-badge.is-majority {
  background: rgba(92, 172, 67, 0.18);
  color: #c9f2be;
}

.majority-badge.is-minority {
  background: rgba(226, 89, 83, 0.16);
  color: #ffc8c5;
}

.summary-metrics {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(150px, 0.88fr);
  gap: 7px;
  align-items: stretch;
}

.metric {
  display: grid;
  align-content: start;
  gap: 3px;
  min-height: 58px;
  padding: 9px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.metric-label {
  color: #aab0bb;
  font-size: 0.66rem;
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: 0.045em;
  font-weight: 900;
}

.metric strong {
  color: #fff;
  font-size: clamp(1rem, 1.45vw, 1.38rem);
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.metric-primary strong {
  font-size: clamp(1.8rem, 3.8vw, 3.2rem);
}

.metric-secondary {
  align-content: stretch;
  gap: 0;
}

.metric-compact {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 3px;
  min-width: 0;
}

.metric-compact:first-child {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 4px 8px;
}

.metric-compact + .metric-compact {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.metric-compact .metric-label {
  font-size: 0.57rem;
  letter-spacing: 0.04em;
}

.metric-compact strong {
  justify-self: start;
  max-width: 100%;
  font-size: clamp(0.9rem, 1.05vw, 1.04rem);
  letter-spacing: -0.025em;
  text-align: left;
}

.metric-compact:first-child strong {
  justify-self: end;
  font-size: clamp(0.98rem, 1.2vw, 1.18rem);
  text-align: right;
}

.metric-compact + .metric-compact strong {
  font-size: clamp(0.98rem, 1.15vw, 1.12rem);
  line-height: 1.08;
}

.metric span:last-child {
  color: #b9bec8;
  font-size: 0.75rem;
}

.text-button {
  border: 1px solid rgba(190, 196, 208, 0.32);
  border-radius: 999px;
  background: transparent;
  color: #d6d8dc;
  padding: 5px 9px;
  font: inherit;
  font-size: 0.76rem;
  cursor: pointer;
  white-space: nowrap;
}

.text-button:hover,
.text-button:focus-visible {
  color: #fff;
  border-color: rgba(240, 244, 250, 0.72);
  outline: none;
}

.table-scroll {
  overflow: auto;
  margin-top: 9px;
  max-height: min(48vh, 500px);
}

.seat-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 0;
  font-size: 0.77rem;
}

.seat-table th,
.seat-table td {
  padding: 6px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-align: right;
  white-space: nowrap;
}

.seat-table th:first-child,
.seat-table td:first-child {
  text-align: left;
}

.seat-table th {
  color: #aeb4bf;
  text-transform: uppercase;
  letter-spacing: 0.035em;
  font-size: 0.63rem;
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--pk-surface-muted-dark, rgba(30, 30, 30, 0.96));
}

.seat-table-help {
  position: relative;
  display: inline-block;
  cursor: help;
  outline: none;
}

.seat-table-help::after {
  content: attr(data-help);
  position: absolute;
  left: 50%;
  top: calc(100% + 7px);
  width: 220px;
  max-width: min(220px, 78vw);
  padding: 8px 10px;
  border: none;
  border-radius: 4px;
  background: var(--pk-surface-dark, rgba(30, 30, 30, 0.98));
  color: #f4f4f4;
  font-size: 0.73rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -3px);
  transition: opacity 120ms ease, transform 120ms ease;
  z-index: 12;
}

.seat-table-help:hover::after,
.seat-table-help:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.seat-table th:first-child .seat-table-help::after {
  left: 0;
  transform: translateY(-3px);
}

.seat-table th:first-child .seat-table-help:hover::after,
.seat-table th:first-child .seat-table-help:focus-visible::after {
  transform: translateY(0);
}

.seat-table th:last-child .seat-table-help::after {
  left: auto;
  right: 0;
  transform: translateY(-3px);
}

.seat-table th:last-child .seat-table-help:hover::after,
.seat-table th:last-child .seat-table-help:focus-visible::after {
  transform: translateY(0);
}

.seat-table-help:focus-visible {
  outline: 2px solid rgba(235, 238, 244, 0.72);
  outline-offset: 2px;
  border-radius: 3px;
}

.seat-row {
  cursor: pointer;
  color: #e8eaf0;
}

.seat-row:hover,
.seat-row:focus-within {
  background: rgba(255, 255, 255, 0.045);
}

.seat-row:focus-visible {
  outline: 2px solid rgba(235, 238, 244, 0.72);
  outline-offset: -2px;
}

.seat-row.is-selected {
  background: color-mix(in srgb, var(--party-color, #888) 18%, transparent);
}

.seat-row button {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  width: 100%;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 900;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.table-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--party-color, #777);
  flex: 0 0 auto;
}

.table-party-abbr {
  display: block;
  min-width: 0;
  text-align: left;
}

.seat-tooltip {
  pointer-events: none;
  position: fixed;
  display: none;
  z-index: 60;
  max-width: 240px;
  padding: 8px 10px;
  border-radius: 4px;
  background: var(--pk-surface-dark, rgba(30, 30, 30, 0.98));
  color: #f4f4f4;
  border: none;
  font-size: 0.8rem;
  line-height: 1.35;
}

.seat-tooltip strong {
  display: block;
  font-size: 0.88rem;
}

html[data-theme="light"] body[data-page="hallituspohjat"] {
  background: var(--pk-bg-light, #f4f4f4);
  color: var(--pk-text-light, #202124);
}

html[data-theme="light"] body[data-page="hallituspohjat"] .visual-card {
  background: var(--pk-bg-light, #f4f4f4);
}

html[data-theme="light"] body[data-page="hallituspohjat"] .coalition-hero h1,
html[data-theme="light"] body[data-page="hallituspohjat"] h2,
html[data-theme="light"] body[data-page="hallituspohjat"] .metric strong,
html[data-theme="light"] body[data-page="hallituspohjat"] .seat-row button,
html[data-theme="light"] body[data-page="hallituspohjat"] .party-seat-group {
  color: #202124;
}

html[data-theme="light"] body[data-page="hallituspohjat"] .summary-card,
html[data-theme="light"] body[data-page="hallituspohjat"] .seat-selector-card,
html[data-theme="light"] body[data-page="hallituspohjat"] .coalition-grid-card,
html[data-theme="light"] body[data-page="hallituspohjat"] .party-seat-group {
  background: rgba(255, 255, 255, 0.82);
  border-color: rgba(32, 33, 36, 0.1);
}

html[data-theme="light"] body[data-page="hallituspohjat"] .party-seat-group:hover,
html[data-theme="light"] body[data-page="hallituspohjat"] .party-seat-group:focus-visible {
  background: rgba(255, 255, 255, 0.98);
}

html[data-theme="light"] body[data-page="hallituspohjat"] .party-seat-group.is-selected {
  background: color-mix(in srgb, var(--party-color, #888) 22%, #ffffff);
}

html[data-theme="light"] body[data-page="hallituspohjat"] .metric {
  background: rgba(32, 33, 36, 0.035);
  border-color: rgba(32, 33, 36, 0.1);
}

html[data-theme="light"] body[data-page="hallituspohjat"] .metric-compact + .metric-compact {
  border-top-color: rgba(32, 33, 36, 0.1);
}

html[data-theme="light"] body[data-page="hallituspohjat"] .coalition-grid {
  background: rgba(32, 33, 36, 0.035);
  border-color: rgba(32, 33, 36, 0.16);
}

html[data-theme="light"] body[data-page="hallituspohjat"] .coalition-grid::after {
  border-left-color: rgba(32, 33, 36, 0.22);
}

html[data-theme="light"] body[data-page="hallituspohjat"] .coalition-grid-seat {
  background: rgba(32, 33, 36, 0.12);
  box-shadow: inset 0 0 0 1px rgba(32, 33, 36, 0.06);
}

html[data-theme="light"] body[data-page="hallituspohjat"] .coalition-subtitle,
html[data-theme="light"] body[data-page="hallituspohjat"] .selected-parties,
html[data-theme="light"] body[data-page="hallituspohjat"] .seat-selector-card p,
html[data-theme="light"] body[data-page="hallituspohjat"] .seat-selector-card .table-note,
html[data-theme="light"] body[data-page="hallituspohjat"] .metric span:last-child,
html[data-theme="light"] body[data-page="hallituspohjat"] .visual-description,
html[data-theme="light"] body[data-page="hallituspohjat"] .coalition-grid-count,
html[data-theme="light"] body[data-page="hallituspohjat"] .party-seat-group-count {
  color: #4f5661;
}

html[data-theme="light"] body[data-page="hallituspohjat"] .seat-table th,
html[data-theme="light"] body[data-page="hallituspohjat"] .metric-label {
  color: #4f5661;
}

html[data-theme="light"] body[data-page="hallituspohjat"] .seat-table th {
  background: rgba(255, 255, 255, 0.96);
}

html[data-theme="light"] body[data-page="hallituspohjat"] .seat-table-help::after,
html[data-theme="light"] body[data-page="hallituspohjat"] .seat-tooltip {
  background: rgba(255, 255, 255, 0.98);
  color: #202124;
  box-shadow: 0 10px 24px rgba(32, 33, 36, 0.14);
}

html[data-theme="light"] body[data-page="hallituspohjat"] .seat-row {
  color: #202124;
}

html[data-theme="light"] body[data-page="hallituspohjat"] .seat-row:hover,
html[data-theme="light"] body[data-page="hallituspohjat"] .seat-row:focus-within {
  background: rgba(32, 33, 36, 0.055);
}

html[data-theme="light"] body[data-page="hallituspohjat"] .seat-row.is-selected {
  color: #17191c;
  background: color-mix(in srgb, var(--party-color, #888) 22%, #ffffff);
}

html[data-theme="light"] body[data-page="hallituspohjat"] .text-button {
  color: #24272b;
  border-color: rgba(32, 33, 36, 0.38);
}

html[data-theme="light"] body[data-page="hallituspohjat"] .text-button:hover,
html[data-theme="light"] body[data-page="hallituspohjat"] .text-button:focus-visible {
  color: #000;
  border-color: rgba(32, 33, 36, 0.72);
}

html[data-theme="light"] body[data-page="hallituspohjat"] .majority-badge {
  background: rgba(32, 33, 36, 0.08);
  color: #24272b;
}

html[data-theme="light"] body[data-page="hallituspohjat"] .majority-badge.is-majority {
  background: rgba(68, 135, 48, 0.18);
  color: #215015;
}

html[data-theme="light"] body[data-page="hallituspohjat"] .majority-badge.is-minority {
  background: rgba(190, 45, 40, 0.13);
  color: #8a211e;
}

html[data-theme="light"] body[data-page="hallituspohjat"] .seat-table th,
html[data-theme="light"] body[data-page="hallituspohjat"] .seat-table td {
  border-bottom-color: rgba(32, 33, 36, 0.1);
}

@media (max-width: 980px) {
  .coalition-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .table-scroll {
    max-height: none;
  }
}

@media (max-width: 720px) {
  .coalition-page {
    padding: 10px var(--pk-gutter-mobile) 8px;
  }

  .party-seat-groups {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .coalition-grid-card {
    padding: 8px;
  }

  .summary-topline {
    flex-direction: column;
    align-items: stretch;
  }

  .summary-metrics {
    grid-template-columns: minmax(0, 1fr);
  }

  .metric-compact,
  .metric-compact:first-child {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .metric-compact strong,
  .metric-compact:first-child strong {
    justify-self: start;
    text-align: left;
  }

  .seat-table {
    font-size: 0.72rem;
  }

  .seat-table th,
  .seat-table td {
    padding: 6px 4px;
  }
}

@media (max-width: 520px) {
  .party-seat-groups {
    grid-template-columns: minmax(0, 1fr);
  }

  .party-seat-mini-square {
    min-width: 5px;
  }

  .coalition-grid {
    gap: 4px;
    padding: 8px;
  }

  .table-scroll {
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-gutter: stable;
  }

  .seat-table {
    min-width: 560px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
