/* JoyClub Germany — dark theme shared by the Map and Charts pages. */

:root {
  --bg: #0f1419;
  --panel: #161d27;
  --panel2: #1d2733;
  --text: #e7edf3;
  --muted: #9aa7b5;
  --accent: #f46d43;
  --line: #28323f;

  --seg-women: #e7567f;
  --seg-men: #3fa7d6;
  --seg-couples: #b57ce0;
  --seg-nonbinary: #5ec97a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden; /* lock the viewport; the panel and content scroll internally */
}

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

/* ---------- Top nav ---------- */
.topnav {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  height: 52px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.topnav .brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
}

.topnav nav {
  display: flex;
  gap: 6px;
}

.topnav nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 600;
}

.topnav nav a:hover {
  color: var(--text);
  background: var(--panel2);
}

.topnav nav a.active {
  color: var(--accent);
  background: rgba(244, 109, 67, 0.12);
}

/* ---------- Layout ---------- */
.layout {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

.panel {
  width: 340px;
  flex: 0 0 340px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 18px 16px 28px;
  overflow-y: auto;
}

.content {
  flex: 1;
  position: relative;
  min-width: 0;
}

/* ---------- Panel content ---------- */
.title {
  font-size: 18px;
  margin: 0 0 4px;
  font-weight: 700;
}

.subtitle {
  margin: 0 0 18px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.group {
  margin-bottom: 20px;
}

.group > h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 10px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 0;
  cursor: pointer;
  user-select: none;
}

.check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.seg-women input {
  accent-color: var(--seg-women);
}
.seg-men input {
  accent-color: var(--seg-men);
}
.seg-couples input {
  accent-color: var(--seg-couples);
}
.seg-nonbinary input {
  accent-color: var(--seg-nonbinary);
}

.seg-swatch {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-left: auto;
}
.seg-women .seg-swatch {
  background: var(--seg-women);
}
.seg-men .seg-swatch {
  background: var(--seg-men);
}
.seg-couples .seg-swatch {
  background: var(--seg-couples);
}
.seg-nonbinary .seg-swatch {
  background: var(--seg-nonbinary);
}

.age-readout {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.age-slider {
  margin: 22px 8px 6px;
}

/* ---------- noUiSlider dark theme ---------- */
.age-slider.noUi-target {
  height: 6px;
  background: var(--line);
  border: none;
  box-shadow: none;
  border-radius: 4px;
}

.age-slider .noUi-connect {
  background: var(--accent);
}

.age-slider .noUi-handle {
  width: 16px;
  height: 16px;
  right: -8px;
  top: -6px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  cursor: grab;
}

.age-slider .noUi-handle:active {
  cursor: grabbing;
}

.age-slider .noUi-handle::before,
.age-slider .noUi-handle::after {
  display: none;
}

.age-slider .noUi-tooltip {
  display: none;
}

/* ---------- Stat cards ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.stat {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
}

.stat-num {
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat-lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-top: 2px;
}

/* ---------- Legend ---------- */
.legend-bar {
  display: block;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(
    to right,
    #2c7bb6 0%,
    #00a6ca 30%,
    #7fd13b 45%,
    #fdae61 62%,
    #f46d43 80%,
    #d7191c 100%
  );
}

.legend-lbls {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
  margin-top: 4px;
}

/* ---------- Members by state bars ---------- */
.state-bars {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bar-row {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.bar-label {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-track {
  height: 8px;
  background: var(--panel2);
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
}

.bar-val {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  min-width: 48px;
  text-align: right;
}

/* ---------- Top locations ---------- */
.top-locations {
  display: flex;
  flex-direction: column;
}

.top-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font: inherit;
  text-align: left;
  padding: 7px 2px;
  cursor: pointer;
}

.top-row:hover {
  background: var(--panel2);
}

.top-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 1 auto;
}

.top-dots {
  flex: 1;
  border-bottom: 1px dotted var(--line);
  transform: translateY(-3px);
  min-width: 12px;
}

.top-val {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

/* ---------- Map ---------- */
#map {
  position: absolute;
  inset: 0;
  background: var(--bg);
}

.leaflet-container {
  background: var(--bg);
  font-family: inherit;
}

.leaflet-tooltip {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.leaflet-tooltip-top::before,
.leaflet-tooltip-bottom::before,
.leaflet-tooltip-left::before,
.leaflet-tooltip-right::before {
  border-top-color: var(--line);
}

.leaflet-bar a {
  background: var(--panel2);
  color: var(--text);
  border-bottom-color: var(--line);
}

.leaflet-bar a:hover {
  background: var(--panel);
}

.map-empty {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 600;
  place-items: center;
  align-content: center;
  text-align: center;
  background: rgba(15, 20, 25, 0.72);
  color: var(--muted);
  font-size: 16px;
  font-weight: 600;
}

.map-empty.show {
  display: grid;
}

/* ---------- Charts ---------- */
.charts-content {
  overflow-y: auto;
  padding: 18px;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px 16px;
  min-width: 0;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
}

.card-wide {
  grid-column: 1 / -1;
}

.canvas-wrap {
  position: relative;
  height: 260px;
}

.canvas-wrap.tall {
  height: 340px;
}

.couples-grids {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.couples-sub {
  min-width: 0;
}

.caption {
  color: var(--muted);
  font-size: 12px;
  margin: 8px 2px 0;
}

.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 180px;
  color: var(--muted);
  font-weight: 600;
  background: var(--panel2);
  border: 1px dashed var(--line);
  border-radius: 10px;
}

.charts-empty {
  display: none;
  position: sticky;
  bottom: 0;
  margin-top: 16px;
  padding: 14px;
  text-align: center;
  color: var(--muted);
  font-weight: 600;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.charts-empty.show {
  display: block;
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .layout {
    flex-direction: column;
  }

  .panel {
    width: 100%;
    flex: none;
    max-height: 48vh;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .content {
    flex: 1;
    min-height: 0; /* fill the space left after the (capped 48vh) panel; avoids clipping the map */
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }

  .couples-grids {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .topnav {
    gap: 10px;
    padding: 0 12px;
  }

  .panel {
    padding: 14px 12px 22px;
  }

  .stats {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .stat-num {
    font-size: 15px;
  }
}
