@charset "UTF-8";

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: var(--pk-bg-dark, #131313);
  color: var(--pk-text-dark, #dddddd);
  font-family: Roboto, sans-serif;
}

.page {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 12px var(--pk-gutter-desktop) 8px;
  min-width: 0;
  overflow-x: clip;
}

.hero {
  margin-bottom: 8px;
}

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

.chart-card {
  position: relative;
  flex: 1;
  width: 100%;
  max-width: none;
  margin: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  min-height: 360px;
  display: flex;
  flex-direction: column;
}

.chart-layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(240px, 1fr) auto;
  gap: 8px;
  min-height: 0;
  min-width: 0;
  background: transparent;
}

.chart-layout > * {
  min-width: 0;
  max-inline-size: 100%;
}

#chart-container {
  position: relative;
  display: block;
  width: 100%;
  flex: 1;
  height: auto;
  min-height: 300px;
  background: var(--pk-bg-dark, #131313);
  overflow: hidden;
}

#legend-panel {
  align-self: start;
  min-height: 0;
  min-width: 0;
  height: max-content;
  width: 100%;
  max-width: 100%;
  max-inline-size: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
  background: var(--pk-surface-muted-dark, rgba(30, 30, 30, 0.6));
  border-radius: var(--pk-card-radius, 8px);
  padding: 10px;
}

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

.axis path,
.axis line {
  stroke: #444;
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.axis text {
  fill: #aaa;
  font-size: 0.78rem;
}

.tooltip {
  pointer-events: none;
  position: absolute;
  opacity: 0;
  transform: translate(-50%, -100%);
  background: var(--pk-surface-dark, rgba(30, 30, 30, 0.98));
  border: none;
  border-radius: 4px;
  color: #fff;
  padding: 8px 10px;
  font-size: 0.78rem;
  line-height: 1.35;
  min-width: 170px;
  z-index: 50;
}

.legend {
  position: static;
  width: 100%;
  max-inline-size: 100%;
  top: auto;
  left: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 0;
  padding: 0;
  background: transparent;
  border-radius: 0;
  font-size: 0.8rem;
  max-height: 92px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  min-width: 0;
  box-sizing: border-box;
}

.legend button {
  display: inline-flex;
  flex: 0 1 auto;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  border: none;
  border-radius: 4px;
  padding: 5px 9px;
  background: transparent;
  color: #ddd;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: normal;
  overflow-wrap: anywhere;
  min-width: 0;
  max-width: 100%;
  max-inline-size: 100%;
  text-align: left;
  line-height: 1.2;
}

.legend button span:last-child {
  min-width: 0;
  max-inline-size: 100%;
  overflow-wrap: anywhere;
}

.legend button:hover {
  color: #fff;
}

.legend button.is-hidden {
  opacity: 0.45;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

html[data-theme="light"] body[data-page="hallitus"] #legend-panel .legend {
  background: transparent;
  box-shadow: none;
}

.gov-list {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.gov-list-item {
  list-style: none;
  padding-left: 0;
}

.gov-name {
  display: block;
  font-weight: 700;
  color: #fff;
}

.gov-period {
  display: block;
  color: #bbb;
  margin-top: 2px;
  font-size: 0.82rem;
}

.gov-segments {
  margin-top: 6px;
  color: #ccc;
  font-size: 0.82rem;
  line-height: 1.45;
}

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

  .chart-layout {
    grid-template-rows: minmax(250px, 1fr) auto;
    gap: 8px;
  }

  .legend button {
    font-size: 0.74rem;
    width: auto;
    max-width: 100%;
  }

  #chart-container {
    min-height: 250px;
  }

  #legend-panel {
    order: 0;
    border-radius: var(--pk-card-radius, 8px);
    padding: 8px 10px;
    max-inline-size: 100%;
  }

  .legend {
    max-height: min(22vh, 170px);
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    align-content: flex-start;
    overflow-y: auto;
    padding-right: 4px;
    max-inline-size: 100%;
  }

  .pk-footer {
    padding: 10px 0 calc(env(safe-area-inset-bottom) + 20px);
    font-size: 0.75rem;
  }

  .pk-footer p a,
  .pk-footer p span.pipe {
    margin: 0 3px;
  }
}

@media (min-width: 1080px) and (orientation: landscape) {
  .chart-layout {
    grid-template-columns: minmax(0, 1fr) 250px;
    grid-template-rows: 1fr;
    align-items: stretch;
  }

  #legend-panel {
    align-self: start;
    overflow: visible;
    display: block;
  }

  .legend {
    max-height: min(64vh, 560px);
    align-content: flex-start;
    display: flex;
    flex-wrap: wrap;
    overflow-y: auto;
  }

  .legend button {
    width: 100%;
  }
}
