/*
 * Vahti site style, after luka.ainias.net: light Helvetica body text,
 * Georgia headings and navigation, one centred column, thin rules, and
 * bordered cards with a soft shadow for agenda items.
 *
 * Night mode is the `night-mode` class on <html> (luka.ainias.net puts it
 * on <body>; <html> lets the head script set it before first paint). It
 * follows the system setting until the reader picks one with the toggle.
 */

:root {
  --bg-color: #ffffff;
  --text-color: #222222;
  --muted-color: #666666;
  --card-border: #dddddd;
  --card-hover: #fcfcfc;
  --shadow-color: rgba(0, 0, 0, 0.08);
  --mark-bg: #fff2a8;
  --column: 600px;
  --wide-column: 800px;
}

html.night-mode {
  --bg-color: #121212;
  --text-color: #eeeeee;
  --muted-color: #a0a0a0;
  --card-border: #333333;
  --card-hover: #1a1a1a;
  --shadow-color: rgba(0, 0, 0, 0.5);
  --mark-bg: #5a4a00;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-weight: 300;
  background-color: var(--bg-color);
  color: var(--text-color);
  margin: 0;
  padding: 0 20px 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: background-color 0.3s, color 0.3s;
  line-height: 1.6;
  min-height: 100vh;
  width: 100%;
}

h1,
h2,
h3,
nav a,
.languages a,
.icon-btn,
summary {
  font-family: Georgia, serif;
  font-weight: normal;
}

strong,
th {
  font-weight: 500;
}

a {
  color: inherit;
  text-decoration: underline;
}

.muted {
  color: var(--muted-color);
}

.skip {
  position: absolute;
  left: -9999px;
}

.skip:focus {
  left: 1rem;
  top: 0.5rem;
  background: var(--bg-color);
}

/* Header ----------------------------------------------------------------- */

#main-header {
  width: 100%;
  max-width: var(--wide-column);
  padding: 60px 0 40px 0;
  margin-bottom: 60px;
  border-bottom: 1px solid var(--card-border);
}

.header-inner {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 36px;
}

nav {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  justify-content: center;
}

nav a {
  text-decoration: none;
  font-size: 1.1rem;
}

nav a:hover {
  text-decoration: underline;
}

.languages {
  display: flex;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.95rem;
}

.languages a {
  text-decoration: none;
}

.languages a:hover,
.languages a[aria-current='page'] {
  text-decoration: underline;
}

.icon-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text-color);
  font-size: 1rem;
  padding: 6px 12px;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
  text-decoration: none;
}

.icon-btn:hover {
  background-color: var(--text-color);
  color: var(--bg-color);
}

.icon-btn[hidden] {
  display: none;
}

.abs-left {
  position: absolute;
  left: 0;
  top: 0;
}

.abs-right {
  position: absolute;
  right: 0;
  top: 0;
}

@media (max-width: 768px) {
  #main-header {
    padding: 32px 0 24px 0;
    margin-bottom: 40px;
  }

  .header-inner {
    flex-direction: column;
    align-items: center;
    gap: 20px;
  }

  .abs-left,
  .abs-right {
    position: static;
  }

  .header-inner nav {
    order: -1;
  }
}

/* Main column ------------------------------------------------------------ */

main {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

main > * {
  width: 100%;
  max-width: var(--column);
}

/* Sections holding a table, and everything under the hero, get the wider column. */
main > section:has(table),
main > .hero ~ section {
  max-width: var(--wide-column);
}

main > section {
  margin-bottom: 60px;
}

h1 {
  margin: 0 0 12px 0;
  font-size: 2rem;
  line-height: 1.25;
}

h2 {
  margin: 0 0 12px 0;
  font-size: 1.5rem;
}

/* Tables ----------------------------------------------------------------- */

.scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th,
td {
  padding: 10px 12px 10px 0;
  border-bottom: 1px solid var(--card-border);
  text-align: left;
  vertical-align: top;
}

th {
  font-size: 0.85rem;
  white-space: nowrap;
}

th button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: inherit;
  cursor: pointer;
}

th[aria-sort='ascending'] button::after {
  content: ' ↑';
}

th[aria-sort='descending'] button::after {
  content: ' ↓';
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Hero: title, intro, region drop-down and key figures ------------------- */

main > .hero {
  max-width: var(--wide-column);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px 40px;
  align-items: end;
  margin-bottom: 60px;
  padding-bottom: 40px;
  border-bottom: 1px solid var(--card-border);
}

.hero-text {
  min-width: 0;
}

/* Level tabs: Eduskunta, Sote-alueet, Kunnat, across the top of the hero. */
.level-tabs {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px 32px;
  border-bottom: 1px solid var(--card-border);
}

.level-tabs a {
  font-size: 1.1rem;
  text-decoration: none;
  padding-bottom: 10px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
}

.level-tabs a:hover {
  border-bottom-color: var(--card-border);
}

.level-tabs a[aria-current='page'] {
  border-bottom-color: var(--text-color);
}

.soon {
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 0.75rem;
  color: var(--muted-color);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hero-text h1 {
  margin: 0 0 8px 0;
}

.hero-text p {
  margin: 0;
  max-width: var(--column);
}

.region-select {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 220px;
}

.region-select label {
  font-size: 0.85rem;
  color: var(--muted-color);
}

.region-select select {
  appearance: none;
  font: inherit;
  font-family: Georgia, serif;
  font-size: 1rem;
  color: var(--text-color);
  background-color: var(--bg-color);
  /* A thin chevron in the text colour, drawn with two gradients. */
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  border: 1px solid var(--card-border);
  border-radius: 0;
  padding: 6px 36px 6px 12px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.region-select select:hover,
.region-select select:focus-visible {
  border-color: var(--text-color);
}

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

.hero-figures {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 16px 48px;
  margin: 0;
}

.hero-figures dt {
  color: var(--muted-color);
  font-size: 0.85rem;
}

.hero-figures dd {
  margin: 0;
  font-family: Georgia, serif;
  font-size: 1.6rem;
  font-variant-numeric: tabular-nums;
}

/* A level with no regions yet has only the hero; the footer draws the rule. */
main > .hero:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

@media (max-width: 768px) {
  main > .hero {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .level-tabs {
    gap: 8px 18px;
  }

  .level-tabs a {
    font-size: 1rem;
  }
}

/* Representative page ------------------------------------------------- */

main > .back,
main > .mock-note {
  max-width: var(--wide-column);
}

.back {
  margin: 0 0 16px 0;
}

.mock-note {
  margin: 0 0 32px 0;
  padding: 12px 16px;
  border: 1px dashed var(--card-border);
  color: var(--muted-color);
  font-size: 0.9rem;
}

.person-hero {
  align-items: start;
}

.person-hero .hero-text p {
  font-family: Georgia, serif;
  font-size: 1.15rem;
}

.contact {
  margin: 0;
  display: grid;
  gap: 6px;
  min-width: 220px;
  font-size: 0.95rem;
}

.contact dt {
  color: var(--muted-color);
  font-size: 0.85rem;
}

.contact dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.vote-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  margin: 0 0 16px 0;
  font-size: 0.95rem;
}

.vote-filters[hidden] {
  display: none;
}

.vote-filters input[type='search'],
.vote-filters select {
  font: inherit;
  color: var(--text-color);
  background-color: var(--bg-color);
  border: 1px solid var(--card-border);
  border-radius: 0;
  padding: 6px 10px;
}

.vote-filters input[type='search'] {
  flex: 1 1 200px;
}

.vote-filters input[type='search']:focus-visible,
.vote-filters select:focus-visible {
  border-color: var(--text-color);
  outline: none;
}

.people {
  padding: 0;
  list-style: none;
}

.people li {
  padding: 10px 0;
  border-bottom: 1px solid var(--card-border);
  font-family: Georgia, serif;
  font-size: 1.15rem;
}

/* Meeting page: agenda items as cards ------------------------------------ */

.filter {
  margin: 0 0 24px 0;
}

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

.items > li {
  position: relative;
  margin-bottom: 40px;
  padding: 24px;
  border: 1px solid var(--card-border);
  background-color: var(--bg-color);
  box-shadow: 0 10px 30px var(--shadow-color);
  transition: transform 0.3s ease-out, background-color 0.3s, box-shadow 0.3s ease-out;
  scroll-margin-top: 24px;
}

.items > li:hover {
  background-color: var(--card-hover);
  transform: translateY(-4px);
  box-shadow: 0 16px 40px var(--shadow-color);
}

.items > li:target {
  border-color: var(--text-color);
}

.items h3 {
  margin: 0 0 12px 0;
  font-size: 1.35rem;
  line-height: 1.35;
}

.flag,
.links {
  margin: 0 0 16px 0;
  font-size: 0.95rem;
}

.flag strong {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 8px;
  border: 1px solid var(--text-color);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.flag em {
  font-style: normal;
  background: var(--mark-bg);
  padding: 0 2px;
}

details {
  font-size: 0.95rem;
  border-top: 1px solid var(--card-border);
  padding-top: 12px;
}

summary {
  cursor: pointer;
}

.item-text {
  margin-top: 12px;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

/* Votes on the meeting page ---------------------------------------------- */

.vote-index {
  margin: 0 0 32px 0;
  padding-left: 1.2em;
}

.vote-index li {
  margin-bottom: 6px;
}

.vote {
  margin: 0 0 20px 0;
  padding: 16px 0 0 0;
  border-top: 1px solid var(--card-border);
}

.vote h4 {
  margin: 0 0 8px 0;
  font-family: Georgia, serif;
  font-size: 1.1rem;
  font-weight: normal;
  line-height: 1.35;
}

.means,
.outcome,
.review,
.provenance {
  margin: 0 0 12px 0;
  font-size: 0.95rem;
}

.vote table.counts {
  width: auto;
  margin: 0 0 12px 0;
}

.vote table.counts th,
.vote table.counts td {
  padding: 4px 24px 4px 0;
}

.vote table.counts td {
  font-family: Georgia, serif;
  font-size: 1.3rem;
}

.badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border: 1px dashed var(--text-color);
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
}

.review code {
  overflow-wrap: anywhere;
}

.vote blockquote {
  margin: 0 0 12px 0;
  padding: 0 0 0 12px;
  border-left: 2px solid var(--card-border);
  font-size: 0.95rem;
}

.ballots {
  margin: 12px 0 0 0;
}

.ballots dt {
  font-weight: 400;
}

.ballots dd {
  margin: 0 0 10px 0;
  color: var(--muted-color);
}

/* Footer ----------------------------------------------------------------- */

footer {
  width: 100%;
  max-width: var(--wide-column);
  border-top: 1px solid var(--card-border);
  padding-top: 24px;
  font-size: 0.85rem;
  color: var(--muted-color);
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }

  .items > li:hover {
    transform: none;
  }
}
