/* Map page layout: top bar, filter bar (search + chips), then the map filling the rest of the screen. */
body.map-page {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Project counter: next to the logo in the header (status text, kept apart from the navigation links). */
.count {
  margin: 3px 0 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  max-width: 60vw; /* long search terms are truncated, the full text is in the title attribute */
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Filter bar: search box first (full width on mobile, 140px on desktop), chips scroll sideways. */
.filterbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.search { flex: 1 1 0; min-width: 0; margin: 0; } /* mobile: shares the first row with the Genres button */
.search input {
  width: 100%;
  padding: 8px 8px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--control-border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 16px; /* 16px on touch screens avoids the iOS zoom on focus */
}
.search input::placeholder { color: var(--muted); opacity: 1; font-family: var(--font-mono); }

.chips {
  display: flex;
  gap: 6px;
  flex: 1 1 100%;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}
.chips:empty { display: none; } /* no active filters: no row */
.chip {
  flex: 0 0 auto;
  padding: 6px 12px;
  background: transparent;
  color: var(--chip-text);
  border: 1px solid var(--chip-border);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover { color: var(--text); border-color: var(--muted); }
.chip--active { background: var(--gold); border-color: var(--gold); color: var(--on-gold); font-weight: bold; }
.chip--active:hover { color: var(--on-gold); border-color: var(--gold); }

/* "Genres" button and its dropdown panel */
.genre-filter { flex: 0 0 auto; position: relative; }
.genre-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 0 12px;
  background: transparent; color: var(--text);
  border: 1px solid var(--control-border); border-radius: var(--radius);
  font-family: var(--font-mono); font-size: 0.85rem; white-space: nowrap; cursor: pointer;
}
.genre-toggle::after { /* chevron drawn in CSS */
  content: ""; width: 6px; height: 6px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
}
.genre-toggle[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.genre-toggle[aria-expanded="true"]::after { transform: rotate(-135deg) translateY(-2px); }

.genre-panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 1500; /* above Leaflet (max 1000) */
  width: 300px; max-width: calc(100vw - 24px); padding: 10px;
  background: var(--surface); border: 1px solid var(--control-border);
}
.genre-panel input[type="search"] {
  width: 100%; padding: 8px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--control-border); border-radius: var(--radius);
  font-family: var(--font-mono); font-size: 16px;
}
.genre-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: min(50vh, 340px); overflow-y: auto; }
.genre-option { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 4px; font-size: 0.9rem; cursor: pointer; }
.genre-option:hover { background: var(--surface-2); }
.genre-option input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.genre-count { margin-left: auto; color: var(--muted); font-family: var(--font-mono); font-size: 0.8rem; }
.genre-empty { margin: 8px 4px 0; color: var(--muted); font-size: 0.85rem; }
.genre-clear {
  width: 100%; min-height: 36px; margin-top: 8px;
  background: transparent; color: var(--text);
  border: 1px solid var(--control-border); border-radius: var(--radius);
  font-family: var(--font-mono); cursor: pointer;
}
.genre-clear:disabled { opacity: 0.5; cursor: default; }

.genre-suggest { display: flex; align-items: center; justify-content: center; min-height: 32px; margin-top: 6px; font-family: var(--font-mono); font-size: 0.8rem; color: var(--accent); }

@media (pointer: coarse) {
  .genre-toggle, .genre-clear, .genre-option, .genre-suggest { min-height: 44px; }
}

/* Mobile: the panel drops down under the whole bar, like the navbar menu */
@media (max-width: 719px) {
  .filterbar { position: relative; }
  .genre-filter { position: static; }
  .genre-panel { left: 0; right: 0; top: 100%; width: auto; max-width: none; border-width: 0 0 1px 0; }
  .genre-list { max-height: 45vh; }
}

@media (min-width: 720px) {
  .filterbar { flex-wrap: nowrap; }
  .search { flex: 0 0 140px; }
  .search input { padding: 8px 3px; font-size: 9px; } /* keeps the full placeholder inside 140px */
  .chips { flex: 1 1 0; }
  .genre-toggle { min-height: 30px; padding: 0 10px; font-size: 0.8rem; }
}
main { position: relative; flex: 1 1 auto; min-height: 0; }
#map { position: absolute; inset: 0; background: var(--bg); }

/* Cluster: markercluster assigns small/medium/large by child count. We load only
   MarkerCluster.css (animations), not the Default theme, so no concentric rings exist;
   the outer box is kept fully transparent to guarantee a single flat circle. */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background: transparent;
}
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  width: 34px;
  height: 34px;
  margin: 3px 0 0 3px;
  border: 1px solid var(--gold);
  border-radius: 50%;
  background: var(--chip-fill);
  color: var(--gold);
  font: 600 0.85rem/32px var(--font-ui);
  text-align: center;
}
.marker-cluster-medium div { width: 38px; height: 38px; margin: 1px 0 0 1px; line-height: 36px; }
.marker-cluster-large div { width: 40px; height: 40px; margin: 0; line-height: 38px; }

/* Status messages (the project counter now lives in the header) */
.empty, .load-error {
  position: absolute;
  z-index: 500;
  margin: 0;
  padding: 4px 10px;
  background: var(--overlay);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.8rem;
  pointer-events: none;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
}
.load-error { border-color: var(--danger); }
/* Artist card: bottom sheet on mobile, side panel on wide screens. Compact, archive-like typography. */
.card {
  position: absolute;
  z-index: 1000;
  left: 0; right: 0; bottom: 0;
  max-height: 60%;
  overflow-y: auto;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--accent);
}
.card:focus { outline: none; }
.card h2 {
  margin: 0 64px 0 0;
  font-family: Georgia, serif;
  font-weight: normal;
  font-size: 13px;
  line-height: 1.3;
  color: var(--gold);
  overflow-wrap: anywhere;
}
.card-close {
  position: absolute; top: 8px; right: 8px;
  padding: 4px 8px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--control-border);
  border-radius: var(--radius);
  font-size: 0.8rem;
  cursor: pointer;
}
.card-close:hover { color: var(--text); border-color: var(--muted); }
.card-place {
  margin: 3px 0 0;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--card-meta);
  overflow-wrap: anywhere;
}
.card-rule { margin: 8px 0; border: 0; border-top: 1px solid var(--rule); }
.card-genres { display: flex; flex-wrap: wrap; gap: 4px; }
.genre-chip {
  display: inline-block;
  padding: 2px 7px;
  border: 0.5px solid var(--gold);
  border-radius: 10px;
  background: var(--chip-fill);
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: 7px;
  line-height: 1.4;
}
.card-links { margin: 8px 0 0; font-family: var(--font-mono); font-size: 8px; color: var(--card-link); }
.card-links a { display: inline-block; padding: 4px 1px; color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.card-links a:hover { color: var(--accent); }
.card-curator { margin: 8px 0 0; padding-left: 8px; border-left: 2px solid var(--accent); font-family: var(--font-mono); font-size: 0.72rem; line-height: 1.4; color: var(--accent); }
.card-badge {
  width: fit-content;
  margin: 8px 0 0 auto; /* bottom right of the card */
  padding: 1px 8px;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@media (min-width: 720px) {
  .card {
    top: 12px; left: 12px; right: auto; bottom: auto;
    width: 250px;
    max-height: calc(100% - 24px);
    border: 1px solid var(--border);
    border-top: 2px solid var(--accent);
  }
}