:root {
  --paper: #FAFAF7;
  --ink: #1A1A1A;
  --maroon: #7A2E26;
  --teal: #1A7A6E;
  --muted: #6E6E6E;
  --line: rgba(26, 26, 26, 0.10);
  --panel-w: 380px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

#app {
  display: grid;
  grid-template-columns: var(--panel-w) 1fr;
  height: 100vh;
  height: 100dvh;
}

/* ── Map ───────────────────────────────────────────── */
#map { position: relative; height: 100%; width: 100%; }
.maplibregl-ctrl-group {
  border-radius: 0 !important;
  box-shadow: 0 2px 12px rgba(0,0,0,0.18) !important;
  border: 1px solid var(--line) !important;
}

/* ── Panel ─────────────────────────────────────────── */
#panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  border-right: 1px solid var(--line);
  background: var(--paper);
  overflow: hidden;
}

.panel-head { padding: 22px 22px 14px; border-bottom: 1px solid var(--line); }
.mark { display: inline-flex; align-items: center; gap: 7px; text-decoration: none; }
.mark-word {
  font-family: "DM Sans", sans-serif;
  font-weight: 700;
  letter-spacing: 0.14em;
  font-size: 20px;
  color: var(--ink);
}
.mark-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--maroon);
  box-shadow: 0 0 0 4px rgba(122,46,38,0.16);
}
.kicker {
  margin: 10px 0 0;
  font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--teal);
}
.blurb {
  margin: 10px 0 0;
  font-family: "Playfair Display", Georgia, serif;
  font-size: 14.5px; line-height: 1.45; color: var(--muted);
}

.controls { padding: 14px 22px 4px; }
.search-wrap { position: relative; }
#search {
  width: 100%;
  font-family: inherit; font-size: 14px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 0;
  outline: none;
}
#search:focus { border-color: var(--maroon); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip {
  font-family: inherit;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.03em;
  padding: 6px 10px;
  border: 1px solid var(--line);
  background: #fff; color: var(--muted);
  cursor: pointer; border-radius: 999px;
  transition: all 140ms ease;
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
.chip .swatch { width: 8px; height: 8px; border-radius: 50%; }
.chip[aria-pressed="true"] { color: #fff; border-color: transparent; }
.chip:hover { border-color: var(--ink); }

.list-head {
  display: flex; align-items: baseline; gap: 8px;
  padding: 16px 22px 8px;
}
.count { font-family: "Playfair Display", serif; font-size: 26px; color: var(--ink); }
.list-hint { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }

.list { list-style: none; margin: 0; padding: 0 10px 10px; overflow-y: auto; flex: 1; }
.row {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 120ms ease;
}
.row:hover, .row.active { background: rgba(122,46,38,0.06); }
.row-name { font-weight: 600; font-size: 14px; color: var(--ink); display: flex; align-items: center; gap: 7px; }
.row-name .swatch { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.row-name-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-site {
  flex: none; text-decoration: none; color: var(--muted);
  font-size: 13px; font-weight: 700; line-height: 1;
  padding: 2px 5px; border: 1px solid var(--line); border-radius: 4px;
  transition: all 130ms ease;
}
.row-site:hover { color: #fff; background: var(--maroon); border-color: var(--maroon); }
.row-meta { font-size: 12px; color: var(--muted); margin-top: 3px; padding-left: 15px; }
.row-empty { padding: 24px 12px; color: var(--muted); font-style: italic; font-family: "Playfair Display", serif; }

.panel-foot { padding: 12px 22px 16px; border-top: 1px solid var(--line); }
.suggest {
  width: 100%;
  font-family: inherit; font-size: 12px; font-weight: 600;
  letter-spacing: 0.04em;
  padding: 10px; cursor: pointer;
  background: var(--ink); color: var(--paper);
  border: none; border-radius: 0;
}
.suggest:hover { background: var(--maroon); }
.src { margin: 10px 0 0; font-size: 10px; color: var(--muted); letter-spacing: 0.02em; }

/* ── Popup ─────────────────────────────────────────── */
.maplibregl-popup-content {
  border-radius: 0 !important;
  padding: 14px 16px !important;
  box-shadow: 0 16px 44px rgba(0,0,0,0.28) !important;
  font-family: "DM Sans", sans-serif;
}
.pop-cat {
  font-size: 10px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 6px;
}
.pop-cat .swatch { width: 8px; height: 8px; border-radius: 50%; }
.pop-name { font-family: "Playfair Display", serif; font-size: 19px; margin: 6px 0 4px; line-height: 1.15; display: block; }
.pop-name-link { color: var(--ink); text-decoration: none; }
.pop-name-link:hover { color: var(--maroon); text-decoration: underline; }
.pop-meta { font-size: 12.5px; color: var(--muted); margin: 2px 0 0; }
.pop-link { display: inline-block; margin-top: 8px; font-size: 12px; font-weight: 600; color: var(--maroon); text-decoration: none; }
.pop-badge {
  margin-top: 9px; font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--teal); text-transform: uppercase;
}

/* ── Metro switcher + stats ────────────────────────── */
.metro-label {
  display: block; margin: 14px 0 5px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted);
}
.metro-wrap { position: relative; }
.metro-wrap::after {
  content: "▾"; position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  pointer-events: none; color: var(--maroon); font-size: 12px;
}
#metro {
  width: 100%; appearance: none; -webkit-appearance: none;
  font-family: "Playfair Display", serif; font-size: 17px; font-weight: 500;
  padding: 10px 30px 10px 12px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 0; cursor: pointer; outline: none;
}
#metro:focus { border-color: var(--maroon); }
.stats {
  margin: 9px 0 0; font-size: 11px; font-weight: 600;
  letter-spacing: 0.04em; color: var(--teal);
}
.stats span { color: var(--ink); }

.control-row { margin-top: 10px; }
.ev-toggle {
  width: 100%; font-family: inherit; font-size: 12px; font-weight: 600;
  letter-spacing: 0.04em; padding: 9px; cursor: pointer; border-radius: 0;
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  transition: all 140ms ease;
}
.ev-toggle[aria-pressed="true"] {
  background: linear-gradient(135deg, #f6b73c22, #7bbf5a22);
  border-color: #7bbf5a; color: var(--ink);
}

/* ── Event markers — editorial line-icon on a paper disc (no emoji) ── */
.ev-bubble {
  --sz: 42px; --ink: #6f8f4f;
  position: relative; width: var(--sz); height: var(--sz);
  padding: 0; cursor: pointer; border-radius: 50%;
  background: var(--paper);
  border: 1.5px solid color-mix(in srgb, var(--ink) 55%, transparent);
  box-shadow: 0 3px 12px rgba(26,26,26,0.16);
  display: flex; align-items: center; justify-content: center;
  transition: transform 200ms ease, box-shadow 200ms ease;
}
/* a single fine concentric ring — quiet, cartographic, no pulsing */
.ev-bubble::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--ink) 30%, transparent);
  pointer-events: none;
}
.ev-ico { width: calc(var(--sz) * 0.5); height: calc(var(--sz) * 0.5); color: var(--ink); }
.ev-label {
  position: absolute; top: calc(100% + 7px); left: 50%; transform: translateX(-50%);
  white-space: nowrap; font-family: "Playfair Display", Georgia, serif; font-style: italic;
  font-size: 13px; color: var(--ink); background: rgba(250,250,247,0.96); padding: 2px 9px;
  border: 1px solid var(--line); opacity: 0; transition: opacity 160ms ease; pointer-events: none;
  box-shadow: 0 4px 14px rgba(0,0,0,0.14);
}
.ev-bubble:hover { transform: scale(1.1); z-index: 5; box-shadow: 0 6px 18px rgba(26,26,26,0.24); }
.ev-bubble:hover .ev-label { opacity: 1; }
.ev-hidden { display: none !important; }

/* ── Mobile toggle ─────────────────────────────────── */
.toggle { display: none; }

@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; }
  #map { position: absolute; inset: 0; }
  #panel {
    position: absolute; inset: auto 0 0 0;
    height: 62dvh; z-index: 5;
    border-right: none; border-top: 1px solid var(--line);
    box-shadow: 0 -10px 40px rgba(0,0,0,0.18);
    transform: translateY(calc(100% - 132px));
    transition: transform 260ms ease;
  }
  #panel.open { transform: translateY(0); }
  .toggle {
    display: flex; position: absolute; top: 14px; right: 14px; z-index: 6;
    border: 1px solid var(--line); background: var(--paper);
    font-family: inherit; font-size: 12px; font-weight: 700; letter-spacing: 0.08em;
    overflow: hidden; cursor: pointer;
  }
  .toggle span { padding: 9px 14px; }
  .toggle .toggle-list { background: var(--ink); color: var(--paper); }
  #panel.open ~ .toggle .toggle-list { background: var(--paper); color: var(--ink); }
  #panel.open ~ .toggle .toggle-map { background: var(--ink); color: var(--paper); }
}
