/* ── Base ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --page: #f9f9f7;
  --surface: #ffffff;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --hairline: #e1e0d9;
  --border: rgba(11, 11, 11, 0.10);
  /* GoServ brand — used for chrome only, never for pin/category colors */
  --brand-green: #bdd62e;
  --brand-teal: #25525b;
  --link: #25525b;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--page);
}

a { color: var(--link); }

code {
  background: #f0efec;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.9em;
}

.site-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 3px solid var(--brand-green);
}
.site-header .logo { height: 44px; width: auto; display: block; }
.site-header h1 { margin: 0; font-size: 18px; color: var(--brand-teal); }
.site-header p { margin: 2px 0 0; font-size: 13px; color: var(--ink-2); }

.notice {
  max-width: 480px;
  margin: 48px auto;
  padding: 20px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--ink-2);
  line-height: 1.5;
}

/* ── Map page ─────────────────────────────────────────────────────────────── */
.map-page {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

#map-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
}

#map {
  height: 100%;
  background: #e8e8e4;
}

/* ── Pins ─────────────────────────────────────────────────────────────────── */
.goserv-pin-anchor { background: none; border: none; }

.goserv-pin {
  width: 26px;
  height: 26px;
  margin: 4px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid rgba(15, 15, 15, 0.45);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  position: relative;
}

/* "featured": true in locations.json — a bigger pin for a site that would
   otherwise be lost under its neighbours. */
.goserv-pin.featured {
  width: 34px;
  height: 34px;
  border-width: 2.5px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
.goserv-pin.featured .goserv-pin-glyph { font-size: 15px; }
.goserv-pin.featured .goserv-pin-glyph svg { width: 19px; height: 19px; }

.goserv-pin-glyph {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(45deg);
  color: #ffffff;
  font-weight: 700;
  font-size: 12px;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
}
.goserv-pin-glyph.dark {
  color: #14140f;
  text-shadow: none;
}
.goserv-pin-glyph svg {
  width: 15px;
  height: 15px;
  display: block;
}

/* ── Legend ───────────────────────────────────────────────────────────────── */
/* The legend is now a button that opens the filter panel; both live in this box. */
#legend {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 800; /* above tiles, below popups */
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

#filter-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.14);
  cursor: pointer;
}
#filter-toggle svg { width: 15px; height: 15px; display: block; color: var(--brand-teal); }
#filter-toggle:hover { background: #fff; border-color: #b9b9b2; }
#filter-toggle.open { background: #fff; border-color: var(--brand-teal); }
#filter-toggle:focus-visible { outline: 2px solid var(--brand-teal); outline-offset: 2px; }

.filter-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--brand-teal);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}
.filter-badge[hidden] { display: none; }

#filter-panel {
  width: 210px;
  max-height: min(70vh, 560px);
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
  padding: 10px 12px 8px;
}
#filter-panel[hidden] { display: none; }

#legend h2 {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--brand-teal);
}
#filter-panel h2 + .filter-list { margin-bottom: 10px; }

/* The panel scrolls as one — nested scroll areas are fiddly to use — so the year
   list just runs on and the footer below stays pinned. */

.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 4px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink);
}
.filter-row:hover { background: rgba(189, 214, 46, 0.25); }
.filter-row input { flex: none; margin: 0; cursor: pointer; accent-color: var(--brand-teal); }
.filter-row.empty .legend-label,
.filter-row.empty .legend-count { opacity: 0.45; }
.filter-row.empty .legend-swatch { opacity: 0.35; }

.filter-footer {
  position: sticky;
  bottom: -8px; /* cancels the panel's bottom padding so nothing shows underneath */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  background: #fff;
}
.filter-summary { font-size: 11px; color: var(--muted); }

.filter-reset {
  padding: 4px 10px;
  font: inherit;
  font-size: 12px;
  color: var(--brand-teal);
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}
.filter-reset:hover:not(:disabled) { background: rgba(189, 214, 46, 0.25); }
.filter-reset:disabled { opacity: 0.4; cursor: default; }

.legend-swatch {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid rgba(15, 15, 15, 0.45);
  color: #ffffff;
  font-weight: 700;
  font-size: 10px;
}
.legend-swatch.dark { color: #14140f; }
.legend-swatch svg {
  width: 12px;
  height: 12px;
  display: block;
}

.legend-label { flex: 1; }

.legend-count {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

/* Nothing of this type in the chosen year — dimmed, but still clickable. */
.legend-row.empty .legend-label,
.legend-row.empty .legend-count { opacity: 0.45; }
.legend-row.empty .legend-swatch { opacity: 0.35; }

.legend-hint {
  margin: 8px 0 0;
  font-size: 11px;
  color: var(--muted);
}

/* Year filter */
#legend h2 + .year-select { margin-top: 2px; }

.year-select {
  width: 100%;
  padding: 5px 7px;
  font: inherit;
  font-size: 13px;
  color: inherit;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
}
.year-select:focus-visible {
  outline: 2px solid var(--brand-teal);
  outline-offset: 1px;
}

@media (max-width: 640px) {
  /* Button bottom-right, panel opening upward so it never runs off the screen. */
  #legend {
    top: auto;
    right: 8px;
    bottom: 8px;
    flex-direction: column-reverse;
  }
  #filter-panel { width: min(78vw, 230px); max-height: 60vh; }
}

/* ── Popups ───────────────────────────────────────────────────────────────── */
.popup h3 { margin: 0 0 6px; font-size: 15px; }

.popup-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.popup-date { font-size: 12px; color: var(--ink-2); }

.popup p { margin: 0 0 6px; font-size: 13px; line-height: 1.45; }

.popup-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  display: block;
  margin: 4px 0 6px;
  background: var(--hairline);
}

.details-link { font-weight: 600; font-size: 13px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  background: #f0efec;
  color: var(--ink-2);
  font-size: 12px;
  white-space: nowrap;
}

.chip-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid rgba(15, 15, 15, 0.35);
}

/* ── Detail page ──────────────────────────────────────────────────────────── */
.detail-page main {
  max-width: 780px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

.back-link {
  display: inline-block;
  margin-bottom: 14px;
  font-size: 14px;
  text-decoration: none;
}
.back-link:hover { text-decoration: underline; }

.detail-page h1 { margin: 0 0 8px; font-size: 28px; }

.meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.meta-date { color: var(--ink-2); font-size: 14px; }

#minimap {
  height: 260px;
  margin: 18px 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  z-index: 0;
}

.description p { line-height: 1.6; margin: 0 0 14px; font-size: 16px; }

.detail-page h2 { font-size: 18px; margin: 26px 0 12px; color: var(--brand-teal); }

.video-embed {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}

/* A location carrying several videos stacks them. */
.video-embed + .video-embed { margin-top: 14px; }

.video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.photo-grid figure { margin: 0; }

/* Each thumbnail is a button so it is keyboard-reachable; strip the button chrome. */
.photo-open {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
  border-radius: 10px;
  overflow: hidden;
}
.photo-open img { display: block; transition: transform 0.18s ease; }
.photo-open:hover img,
.photo-open:focus-visible img { transform: scale(1.03); }
.photo-open:focus-visible {
  outline: 3px solid var(--brand-teal);
  outline-offset: 2px;
}

/* ── Full-screen photo viewer ──────────────────────────────────────────────── */
body.viewer-open { overflow: hidden; }

.viewer {
  position: fixed;
  inset: 0;
  z-index: 2000; /* above the legend (800) and Leaflet's panes */
  background: rgba(12, 12, 12, 0.93);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 72px;
  cursor: zoom-out;
}
.viewer[hidden] { display: none; }

.viewer-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.5);
  cursor: default;
}

.viewer-caption {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  margin: 0;
  max-width: min(90%, 700px);
  text-align: center;
  color: #f2f2f0;
  font-size: 14px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}
.viewer-caption[hidden] { display: none; }

.viewer-count {
  position: absolute;
  top: 18px;
  left: 20px;
  color: #d8d8d4;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.viewer-count[hidden] { display: none; }

.viewer-close,
.viewer-nav {
  position: absolute;
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  border-radius: 50%;
  line-height: 1;
  transition: background 0.15s ease;
}
.viewer-close:hover,
.viewer-nav:hover,
.viewer-close:focus-visible,
.viewer-nav:focus-visible { background: rgba(255, 255, 255, 0.28); }

.viewer-close {
  top: 12px;
  right: 16px;
  width: 40px;
  height: 40px;
  font-size: 19px;
}

.viewer-nav {
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  font-size: 32px;
  padding-bottom: 4px;
}
.viewer-nav[hidden] { display: none; }
.viewer-nav.prev { left: 14px; }
.viewer-nav.next { right: 14px; }

@media (max-width: 600px) {
  .viewer { padding: 52px 12px; }
  .viewer-nav { width: 42px; height: 42px; font-size: 27px; }
  .viewer-nav.prev { left: 6px; }
  .viewer-nav.next { right: 6px; }
}

.photo-grid img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 10px;
  display: block;
  background: var(--hairline);
}

.photo-grid figcaption {
  margin-top: 5px;
  font-size: 13px;
  color: var(--ink-2);
}
