/* ---------- Base layout ---------- */
:root {
  --ink: #1d2a33;
  --muted: #5d6b75;
  --water: #1f6fb2;
  --paper: #fbfaf6;
  --rule: #e2ded3;
  --header-h: 56px;
  --sidebar-w: 400px;
  /* One sans-serif font for the whole site: header, map labels, sidebar */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--ink);
}

.site-header {
  height: var(--header-h);
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 14px 20px;
  background: var(--ink);
  color: #fff;
}
.site-header h1 { margin: 0; font-size: 1.15rem; font-weight: 600; letter-spacing: 0.02em; }
.site-header .subtitle { margin: 0; font-size: 0.85rem; color: #b9c6cf; }
.site-header h1 a { color: inherit; text-decoration: none; }

/* Links in the title bar (Map / About), pushed to the right */
.site-nav { margin-left: auto; display: flex; gap: 18px; }
.site-nav a {
  color: #b9c6cf;
  text-decoration: none;
  font-size: 0.9rem;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover { color: #fff; }
.site-nav a[aria-current="page"] { color: #fff; border-bottom-color: #fff; }

/* ---------- Text pages (About, etc.) ---------- */
body.page { height: auto; min-height: 100%; background: var(--paper); }
.page-content {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 64px;
  line-height: 1.6;
}
.page-content h1 { font-size: 1.8rem; line-height: 1.2; margin-top: 0; }
.page-content h2 {
  font-size: 1.15rem;
  margin-top: 2em;
  padding-top: 1em;
  border-top: 1px solid var(--rule);
}
.page-content a { color: var(--water); }

.app {
  position: relative;
  height: calc(100% - var(--header-h));
}
#map { position: absolute; inset: 0; }
/* Leaflet sets its own font on the map (tooltips, layer list, attribution); use ours */
.leaflet-container { font-family: var(--font); }
/* Don't draw the browser's focus box around a feature when it's clicked
   (the feature's own highlight already shows what's selected) */
.leaflet-interactive:focus { outline: none; }

/* ---------- Sidebar (field guide) ---------- */
.sidebar {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: var(--sidebar-w);
  max-width: 100%;
  background: var(--paper);
  border-left: 1px solid var(--rule);
  box-shadow: -4px 0 16px rgba(0,0,0,0.12);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 1000;
}
.sidebar.open { transform: translateX(0); }

.sidebar-content {
  height: 100%;
  overflow-y: auto;
  padding: 24px 26px 40px;
}

.sidebar-close {
  position: absolute;
  top: 10px; right: 12px;
  z-index: 2;
  width: 34px; height: 34px;
  border: none; border-radius: 50%;
  background: rgba(255,255,255,0.9);
  font-size: 1.5rem; line-height: 1;
  cursor: pointer;
  color: var(--muted);
}
.sidebar-close:hover { color: var(--ink); background: #fff; }

.entry-kicker {
  margin: 0 0 4px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--water);
  font-weight: 600;
}
.entry-title {
  margin: 0 40px 4px 0;
  font-family: var(--font);
  font-size: 1.7rem;
  line-height: 1.2;
}
.entry-aka { margin: 0 0 16px; font-style: italic; color: var(--muted); font-size: 0.9rem; }

.entry-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 14px;
  margin: 18px 0;
  padding: 14px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font-size: 0.88rem;
}
.entry-facts dt { color: var(--muted); }
.entry-facts dd { margin: 0; }
.status-swatch {
  display: inline-block;
  margin-right: 6px;
  vertical-align: middle;
}

.entry-body {
  font-family: var(--font);
  font-size: 1.02rem;
  line-height: 1.6;
}
.entry-body h3 { font-family: inherit; font-size: 1.1rem; margin-top: 1.6em; }

figure { margin: 18px 0; }
figure img { width: 100%; height: auto; display: block; border-radius: 3px; background: #eee; }
figcaption { font-size: 0.8rem; color: var(--muted); margin-top: 6px; line-height: 1.4; }
figcaption .credit { display: block; font-style: italic; }
.entry-lead { margin-top: 14px; }

.entry-sources-title { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-top: 28px; }
.entry-sources { font-size: 0.82rem; color: var(--muted); padding-left: 1.2em; }

.loading, .entry-missing { color: var(--muted); }

/* ---------- Map controls ---------- */
.feature-tooltip {
  font-weight: 600;
  font-size: 0.85rem;
}

.legend, .opacity-control {
  background: rgba(255,255,255,0.94);
  padding: 8px 12px;
  border-radius: 6px;
  box-shadow: 0 1px 5px rgba(0,0,0,0.2);
  font-size: 0.78rem;
  line-height: 1.5;
}
.legend-row { display: flex; align-items: center; gap: 6px; }
.opacity-control label { display: block; margin-top: 6px; }
.opacity-control input { display: block; width: 160px; }

/* ---------- Phones: sidebar becomes a bottom sheet ---------- */
@media (max-width: 700px) {
  .site-header .subtitle { display: none; }
  .sidebar {
    top: auto; left: 0; right: 0;
    width: 100%;
    height: 62%;
    border-left: none;
    border-top: 1px solid var(--rule);
    border-radius: 14px 14px 0 0;
    transform: translateY(100%);
  }
  .sidebar.open { transform: translateY(0); }
  .legend { display: none; }
}

/* Keep the layer switcher and legend visible when the sidebar is open */
@media (min-width: 701px) {
  .leaflet-right { transition: right 0.25s ease; }
  .app:has(.sidebar.open) .leaflet-right { right: var(--sidebar-w); }
}
