/* ─── Reset & Base ──────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #F4EFE3;   /* warm paper */
  --paper:        #FBF7EE;   /* lighter card paper */
  --ink:          #1A1A1A;
  --ink-soft:     #3A3A3A;
  --muted:        #6B6557;
  --line:         #1A1A1A;
  --line-soft:    #C9C2B0;
  --accent:       #F4D58D;   /* warm yellow highlight */
  --accent-soft:  #FBE8B6;
  --header-bg:    #1A1A1A;

  /* Party colours */
  --c-A:   #E8003D;
  --c-H:   #003B8E;
  --c-FrP: #00447C;
  --c-SV:  #C8102E;
  --c-Sp:  #00773B;
  --c-MDG: #27A24A;
  --c-KrF: #C49600;
  --c-V:   #006B4A;
  --c-R:   #8B0000;

  --radius:    14px;
  --radius-sm: 10px;
  --sidebar:   240px;

  --font-hand:    'Patrick Hand', 'Caveat', cursive;
  --font-script:  'Caveat', cursive;
  --font-body:    'Patrick Hand', 'Inter', sans-serif;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 16px;
}

/* faint paper noise */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(0,0,0,.02) 1px, transparent 1px);
  background-size: 4px 4px;
  z-index: 0;
}

/* ─── Header ────────────────────────────────────────── */
.site-header {
  background: var(--header-bg);
  color: #fff;
  padding: 12px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 2;
}

.logo-text-link {
  color: #fff;
  text-decoration: none;
  font-family: var(--font-script);
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: .3px;
}
.logo-text-link span {
  opacity: .78;
  font-weight: 500;
}

.header-nav {
  display: flex;
  gap: 28px;
}
.header-nav a {
  color: #fff;
  text-decoration: none;
  font-family: var(--font-script);
  font-size: 22px;
  font-weight: 500;
  opacity: .92;
}
.header-nav a:hover { opacity: 1; text-decoration: underline; }

/* ─── Info modal ────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26,26,26,.35);
  z-index: 10;
}

.info-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 28px;
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 30px rgba(26,26,26,.22);
  z-index: 11;
}
.info-modal h2 {
  font-family: var(--font-script);
  font-size: 34px;
  line-height: 1;
  margin-bottom: 10px;
}
.modal-lead {
  font-size: 18px;
  line-height: 1.45;
  color: var(--ink);
  margin-bottom: 16px;
}
.info-block {
  padding: 14px 16px;
  margin-top: 12px;
  background: rgba(244,213,141,.2);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
}
.info-block h3 {
  font-family: var(--font-script);
  font-size: 24px;
  line-height: 1.1;
  color: var(--ink);
  margin-bottom: 8px;
}
.info-modal p {
  color: var(--ink-soft);
  font-size: 17px;
  line-height: 1.45;
}
.info-block p + p,
.info-modal p + p {
  margin-top: 10px;
}
.modal-note {
  margin-top: 16px;
  font-size: 15px;
  color: var(--muted);
}
.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 30px;
  height: 30px;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 22px;
  line-height: 1;
}
.modal-close:hover {
  background: var(--accent-soft);
}

/* ─── Layout ────────────────────────────────────────── */
.app-layout {
  flex: 1;
  max-width: 1300px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 24px 40px;
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  gap: 28px;
  align-items: start;
  position: relative;
  z-index: 1;
}

/* ─── Sidebar ───────────────────────────────────────── */
.sidebar {
  position: sticky;
  top: 16px;
  padding-right: 24px;
  border-right: 1.5px dashed var(--line-soft);
  min-height: 600px;
}

.sidebar-heading {
  font-family: var(--font-script);
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 18px;
  color: var(--ink);
  letter-spacing: .5px;
}

.filter-section {
  margin-bottom: 22px;
}

.filter-label {
  font-family: var(--font-script);
  font-size: 20px;
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: 8px;
  letter-spacing: .3px;
}

/* Filter dropdowns */
.filter-dropdown {
  position: relative;
}
.filter-dropdown-toggle {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1.5px solid var(--line);
  border-radius: 99px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.15;
  text-align: left;
}
.filter-dropdown-toggle:hover {
  background: var(--accent-soft);
}
.filter-dropdown-toggle:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(244,213,141,.6);
}
.filter-caret {
  flex-shrink: 0;
  font-size: 13px;
  transform: translateY(-1px);
}
.filter-dropdown-panel {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow: auto;
  padding: 6px;
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 0 3px 8px rgba(26,26,26,.18);
  z-index: 5;
}
.filter-dropdown.open .filter-dropdown-panel {
  display: grid;
  gap: 4px;
}
#party-options {
  max-height: none;
  overflow: visible;
}
.filter-option {
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.15;
  text-align: left;
}
.filter-option:hover {
  background: var(--accent-soft);
}
.filter-option.selected {
  background: var(--accent);
  font-weight: 500;
}
.filter-check {
  width: 15px;
  flex-shrink: 0;
  opacity: 0;
  font-weight: 700;
}
.filter-option.selected .filter-check {
  opacity: 1;
}
.filter-option-label {
  min-width: 0;
}
.party-dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  flex-shrink: 0;
}

/* Clear all filters link */
.clear-link {
  display: block;
  background: none;
  border: none;
  border-bottom: 1.5px solid var(--ink);
  padding: 0 0 1px;
  margin-top: 24px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.clear-link:hover { color: #B91C1C; border-color: #B91C1C; }

/* ─── Main content ──────────────────────────────────── */
.main-content { min-width: 0; }

.intro-section,
.seo-section {
  background: rgba(251,247,238,.75);
  border: 1.5px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
}

.intro-kicker {
  font-family: var(--font-script);
  font-size: 22px;
  color: var(--muted);
  margin-bottom: 4px;
}

.intro-title {
  font-family: var(--font-script);
  font-size: 38px;
  line-height: 1;
  margin-bottom: 10px;
  color: var(--ink);
}

.intro-copy {
  font-size: 17px;
  color: var(--ink-soft);
  max-width: 70ch;
}

.intro-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.intro-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border: 1.5px solid var(--line);
  border-radius: 99px;
  background: var(--paper);
  font-size: 13px;
  color: var(--ink-soft);
}

/* Search bar */
.search-bar {
  position: relative;
  margin-bottom: 16px;
}
.search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 14px 18px 14px 46px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  font-family: var(--font-body);
  font-size: 17px;
  background: var(--paper);
  color: var(--ink);
  outline: none;
  transition: box-shadow .12s, background .12s;
}
.search-input::placeholder {
  color: var(--muted);
  opacity: .7;
  font-style: italic;
}
.search-input:focus {
  background: #fff;
  box-shadow: 0 0 0 3px rgba(244,213,141,.7);
}

/* Meta row */
.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 8px;
}
.result-count {
  font-family: var(--font-script);
  font-size: 18px;
  color: var(--muted);
  letter-spacing: .3px;
}
.sort-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.sort-label {
  font-family: var(--font-script);
  font-size: 18px;
  color: var(--muted);
}
.sort-select {
  padding: 4px 26px 4px 8px;
  border: none;
  border-bottom: 1.5px solid var(--line);
  background: transparent;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink);
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%231A1A1A' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 4px center;
}

/* ─── States ────────────────────────────────────────── */
.state-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  text-align: center;
  color: var(--muted);
  gap: 10px;
  font-family: var(--font-body);
  font-size: 17px;
}
.state-icon {
  font-size: 40px;
  margin-bottom: 6px;
}
.spinner {
  width: 40px; height: 40px;
  border: 2.5px solid var(--line-soft);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-bottom: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-primary {
  margin-top: 8px;
  padding: 9px 20px;
  background: var(--ink);
  color: #fff;
  border: 1.5px solid var(--ink);
  border-radius: 99px;
  font-family: var(--font-body);
  font-size: 15px;
  cursor: pointer;
}
.btn-primary:hover { background: #000; }

/* ─── Rep grid ──────────────────────────────────────── */
.rep-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
}

.seo-section h2 {
  font-family: var(--font-script);
  font-size: 30px;
  line-height: 1;
  margin-bottom: 14px;
}

.seo-grid,
.faq-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.seo-card,
.faq-item {
  padding: 14px 16px;
  background: var(--paper);
  border: 1.5px solid var(--line-soft);
  border-radius: 12px;
}

.seo-card h3,
.faq-item h3 {
  font-family: var(--font-script);
  font-size: 23px;
  line-height: 1.05;
  margin-bottom: 8px;
  color: var(--ink);
}

.seo-card p,
.faq-item p {
  color: var(--ink-soft);
  font-size: 16px;
}

/* ─── Rep card ──────────────────────────────────────── */
.rep-card {
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  min-height: 0;
  transition: transform .15s, box-shadow .15s;
  animation: fadeUp .25s ease both;
}
.rep-card:hover {
  transform: translateY(-2px);
  box-shadow: 3px 4px 0 rgba(26,26,26,.85);
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.rep-top {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Avatar */
.rep-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}
.rep-avatar-img,
.rep-avatar-fallback {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  display: block;
}
.rep-avatar-img {
  object-fit: cover;
  object-position: center -10%;
  background: #f0eada;
}
.rep-avatar-img.hidden { display: none; }
.rep-avatar-fallback {
  display: none;
  align-items: center;
  justify-content: center;
  font-family: var(--font-script);
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  /* background tinted with party color via JS inline */
}
/* Crossed avatar placeholder for missing photos */
.rep-avatar-fallback::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 47%, rgba(0,0,0,.18) 47% 53%, transparent 53%),
              linear-gradient(45deg, transparent 47%, rgba(0,0,0,.18) 47% 53%, transparent 53%);
  border-radius: 50%;
  pointer-events: none;
}

.rep-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 2px;
}

.rep-name {
  font-family: var(--font-body);
  font-size: 19px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
  word-break: break-word;
}

/* Party indicator pill (next to avatar/name) */
.party-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border: 1.5px solid var(--line);
  border-radius: 99px;
  background: var(--paper);
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--ink);
  margin-top: 2px;
  align-self: flex-start;
  line-height: 1.2;
}
.party-indicator-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  border: 1px solid var(--line);
  flex-shrink: 0;
}

/* Location */
.rep-county {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--muted);
  margin-top: 2px;
}
.rep-county-icon {
  width: 13px; height: 13px;
  flex-shrink: 0;
}

/* Committees */
.rep-committees {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}
.committee-tag {
  display: inline-block;
  padding: 3px 10px;
  border: 1.5px solid var(--line);
  border-radius: 99px;
  background: var(--paper);
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  transition: background .12s;
  line-height: 1.3;
}
.committee-tag:hover {
  background: var(--accent-soft);
}
.committee-tag.highlight {
  background: var(--accent);
  font-weight: 500;
}

/* Card footer */
.rep-footer {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1.5px dashed var(--line-soft);
}

.kontakt-email {
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.2;
  overflow-wrap: anywhere;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}
.kontakt-email:hover {
  color: #000;
}

.copy-email-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 9px;
  background: var(--paper);
  color: var(--ink);
  border: 1.5px solid var(--ink);
  border-radius: 99px;
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  transition: background .12s, transform .1s;
}
.copy-email-btn:hover { background: var(--accent-soft); }
.copy-email-btn:disabled {
  background: var(--accent);
  cursor: default;
}

/* Vara pill */
.vara-tag {
  position: absolute;
  top: 10px; right: 12px;
  padding: 1px 8px;
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: 99px;
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: .04em;
}

/* ─── Footer ────────────────────────────────────────── */
.site-footer {
  flex-shrink: 0;
  text-align: center;
  padding: 22px 20px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--muted);
  border-top: 1.5px dashed var(--line-soft);
  margin-top: 12px;
  position: relative;
  z-index: 1;
}
.site-footer a { color: var(--ink); text-decoration: underline; }

/* ─── Responsive ────────────────────────────────────── */
@media (max-width: 920px) {
  .app-layout {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 20px;
  }
  .sidebar {
    position: static;
    border-right: none;
    border-bottom: 1.5px dashed var(--line-soft);
    padding-right: 0;
    padding-bottom: 16px;
    min-height: 0;
  }
}

@media (max-width: 560px) {
  .site-header { padding: 10px 16px; }
  .logo-text-link { font-size: 22px; }
  .header-nav { gap: 18px; }
  .header-nav a { font-size: 18px; }
  .intro-section,
  .seo-section { padding: 16px; }
  .intro-title { font-size: 32px; }
  .rep-grid { grid-template-columns: 1fr; }
  .meta-row { flex-direction: column; align-items: flex-start; }
}
