:root {
  --paper: #f4efe6;
  --paper-2: #ece5d8;
  --ink: #2b2622;
  --ink-soft: #6b5f54;
  --ink-faint: #9a8d80;
  --clay: #b5532f;   /* police / incidents */
  --ochre: #c98a2b;  /* traffic */
  --sage: #5c7a52;   /* community */
  --indigo: #4a5b8c; /* flights overhead */
  --line: rgba(43, 38, 34, 0.14);
  --line-strong: rgba(43, 38, 34, 0.28);
  --shadow: 0 1px 2px rgba(43, 38, 34, 0.08), 0 8px 24px rgba(43, 38, 34, 0.10);

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Archivo", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: grid;
  grid-template-columns: 380px 1fr;
  height: 100vh;
  width: 100vw;
}

/* ---------- Sidebar ---------- */

aside {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(181, 83, 47, 0.06), transparent 60%),
    var(--paper);
  overflow: hidden;
}

.brand {
  padding: 26px 24px 18px;
  border-bottom: 1px solid var(--line);
}

.brand .eyebrow {
  font-family: var(--font-body);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 6px;
}

.brand h1 {
  font-family: var(--font-display);
  font-weight: 360;
  font-style: italic;
  font-size: 30px;
  line-height: 1.05;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--ink);
}

.brand h1 .amp {
  font-style: italic;
  color: var(--clay);
}

.brand .lede {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--ink-soft);
  max-width: 38ch;
}

/* filters */
.filters {
  display: flex;
  gap: 8px;
  padding: 14px 24px 16px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

/* time filter row */
.time-filters {
  display: flex;
  gap: 8px;
  padding: 12px 24px 14px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  align-items: center;
}

.tchip {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s ease;
}
.tchip.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.tchip:hover:not(.active) { color: var(--ink); border-color: var(--ink-soft); }
.tchip.apply { background: var(--clay); color: var(--paper); border-color: var(--clay); }

.range-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-soft);
}
.range-inputs input[type="date"] {
  font-family: var(--font-body);
  font-size: 12px;
  padding: 3px 6px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--ink);
  background: var(--paper);
}

.chip {
  --c: var(--ink-soft);
  appearance: none;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 5px 11px 5px 22px;
  border-radius: 999px;
  cursor: pointer;
  position: relative;
  transition: all 0.18s ease;
}
.chip::before {
  content: "";
  position: absolute;
  left: 9px; top: 50%;
  transform: translateY(-50%);
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--c);
  opacity: 0.45;
  transition: opacity 0.18s ease;
}
.chip[data-type="police"]    { --c: var(--clay); }
.chip[data-type="traffic"]   { --c: var(--ochre); }
.chip[data-type="community"] { --c: var(--sage); }
.chip[data-type="flight"]    { --c: var(--indigo); }
.chip.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.chip.active::before { opacity: 1; }
.chip:hover:not(.active) { color: var(--ink); border-color: var(--ink-soft); }
.chip:hover:not(.active)::before { opacity: 0.85; }

/* feed */
.feed-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 16px 24px 8px;
}
.feed-head h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 15px;
  letter-spacing: 0.02em;
  margin: 0;
  color: var(--ink);
}
.feed-head .count {
  font-size: 12px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

.feed {
  list-style: none;
  margin: 0;
  padding: 4px 0 24px;
  overflow-y: auto;
  flex: 1;
}

.feed li {
  padding: 12px 24px;
  border-top: 1px solid var(--line);
  cursor: pointer;
  position: relative;
  transition: background 0.15s ease;
}
.feed li:hover { background: var(--paper-2); }
.feed li.active { background: var(--paper-2); }
.feed li.active::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--ink);
}

.feed .row1 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 3px;
}
.feed .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex: none;
}
.feed .dot.police    { background: var(--clay); }
.feed .dot.traffic   { background: var(--ochre); }
.feed .dot.community { background: var(--sage); }
.feed .dot.flight    { background: var(--indigo); }
.feed .kind {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 600;
}
.feed .title {
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.25;
  letter-spacing: -0.005em;
  margin: 0 0 4px;
  color: var(--ink);
}
.feed .meta {
  font-size: 12px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.feed .meta .sep { color: var(--ink-faint); margin: 0 6px; }
.feed .desc {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 5px 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.feed .empty {
  padding: 40px 24px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 13px;
}

/* ---------- Map ---------- */

main { position: relative; overflow: hidden; }
#map { position: absolute; inset: 0; background: var(--paper-2); }

.map-overlay {
  position: absolute;
  left: 18px; bottom: 18px;
  z-index: 500;
  background: rgba(244, 239, 230, 0.9);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--ink-soft);
  box-shadow: var(--shadow);
  max-width: 280px;
  line-height: 1.45;
}
.map-overlay strong {
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 13px;
}

/* legend */
.legend {
  position: absolute;
  right: 14px; top: 14px;
  z-index: 500;
  background: rgba(244, 239, 230, 0.9);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 12px;
  box-shadow: var(--shadow);
}
.legend h3 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 8px;
  color: var(--ink);
}
.legend ul { list-style: none; margin: 0; padding: 0; }
.legend li {
  display: flex; align-items: center; gap: 8px;
  margin: 4px 0;
  color: var(--ink-soft);
}
.legend li .dot {
  width: 10px; height: 10px; border-radius: 50%;
}
.legend li .dot.police    { background: var(--clay); }
.legend li .dot.traffic   { background: var(--ochre); }
.legend li .dot.community { background: var(--sage); }
.legend li .dot.flight    { background: var(--indigo); }
.legend .sizes {
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--line);
  display: flex; align-items: flex-end; gap: 10px;
  color: var(--ink-faint);
}
.legend .sizes .b {
  width: 10px; background: var(--ink-soft); border-radius: 50%; opacity: 0.5;
}

/* ---------- Leaflet pin overrides ---------- */
.pin {
  border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,0.95);
  box-shadow: 0 1px 2px rgba(0,0,0,0.5), 0 2px 7px rgba(0,0,0,0.45);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.pin.police    { background: var(--clay); }
.pin.traffic   { background: var(--ochre); }
.pin.community { background: var(--sage); }
.pin.flight    { background: var(--indigo); color: #fff; }
.pin:hover, .pin.active {
  transform: scale(1.25);
  box-shadow: 0 3px 10px rgba(0,0,0,0.55);
}

/* ---------- Cluster badges ---------- */
.cluster {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 13px;
  color: var(--paper);
  border: 2.5px solid rgba(255,255,255,0.9);
  box-shadow: 0 1px 3px rgba(0,0,0,0.5), 0 3px 10px rgba(0,0,0,0.4);
  background-clip: padding-box;
}
.cluster.police    { background: var(--clay); }
.cluster.traffic   { background: var(--ochre); }
.cluster.community { background: var(--sage); }
.cluster.flight    { background: var(--indigo); }
.cluster span { pointer-events: none; }

/* Flight pins are airplane glyphs, not dots — let the SVG fill the pin and
   rotate to heading. Keep a subtle white halo so it reads on dark aerial tiles. */
.pin.flight {
  width: 22px; height: 22px;
  border: none;
  background: transparent;
  box-shadow: 0 1px 2px rgba(0,0,0,0.45), 0 0 0 1.5px rgba(255,255,255,0.7);
  border-radius: 0;
  transform: rotate(var(--hdg, 0deg));
}
.pin.flight svg { display: block; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.6)); }
.pin.flight:hover, .pin.flight.active {
  transform: scale(1.3) rotate(var(--hdg, 0deg));
}

.leaflet-popup-content-wrapper {
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-family: var(--font-body);
}
.leaflet-popup-content {
  margin: 12px 14px;
  font-size: 13px;
  line-height: 1.45;
}
.leaflet-popup-content .pop-kind {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 700;
  margin-bottom: 4px;
}
.leaflet-popup-content .pop-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  margin: 0 0 5px;
  color: var(--ink);
}
.leaflet-popup-content .pop-meta {
  color: var(--ink-soft);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  margin-bottom: 6px;
}
.leaflet-popup-content a {
  color: var(--clay);
  text-decoration: none;
  font-weight: 600;
}
.leaflet-popup-content a:hover { text-decoration: underline; }

/* provenance list inside a popup */
.pop-sources {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.pop-src {
  font-size: 12px;
  color: var(--ink-soft);
  margin: 3px 0;
  line-height: 1.4;
}
.pop-src a { color: var(--indigo); font-weight: 600; }
.pop-src-when {
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.leaflet-popup-content a:hover { text-decoration: underline; }

.leaflet-container { font-family: var(--font-body); }
.leaflet-control-attribution {
  background: rgba(244,239,230,0.8) !important;
  font-size: 10px !important;
  color: var(--ink-faint) !important;
}

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; }
  aside {
    position: absolute;
    z-index: 1000;
    width: 86%;
    max-width: 360px;
    height: 100%;
    transform: translateX(-100%);
    transition: transform 0.28s ease;
    box-shadow: var(--shadow);
  }
  aside.open { transform: translateX(0); }
  .menu-btn {
    position: absolute; left: 14px; top: 14px; z-index: 600;
    background: rgba(244,239,230,0.9); border: 1px solid var(--line-strong);
    border-radius: 10px; width: 40px; height: 40px; cursor: pointer;
    font-size: 18px; color: var(--ink); box-shadow: var(--shadow);
  }
}

/* staggered load reveal */
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.feed li {
  animation: rise 0.4s ease both;
}
