/* PDCC geocoded timeline map. Flat-file deployment:
   index.html, style.css, map.js, pdcc_data.json. */

/* Leaflet layout fallback for slow or blocked Leaflet CSS. */
.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}
.leaflet-container { overflow: hidden; touch-action: pan-x pan-y; }
.leaflet-container img, .leaflet-container .leaflet-tile { max-width: none !important; max-height: none !important; }
.leaflet-tile { border: 0; visibility: hidden; }
.leaflet-tile-loaded { visibility: inherit; }
.leaflet-zoom-animated { transform-origin: 0 0; }
.leaflet-interactive { cursor: pointer; }
.leaflet-grab { cursor: grab; }
.leaflet-dragging .leaflet-grab { cursor: move; }
.leaflet-control { position: relative; z-index: 800; pointer-events: auto; }
.leaflet-top, .leaflet-bottom { position: absolute; z-index: 1000; pointer-events: none; }
.leaflet-top { top: 0; }
.leaflet-right { right: 0; }
.leaflet-bottom { bottom: 0; }
.leaflet-left { left: 0; }
.leaflet-left .leaflet-control { margin-left: 10px; }
.leaflet-top .leaflet-control { margin-top: 10px; }
.leaflet-right .leaflet-control { margin-right: 10px; }
.leaflet-bottom .leaflet-control { margin-bottom: 10px; }
.leaflet-control-zoom a {
  background: #fff;
  border-bottom: 1px solid #ccc;
  color: #000;
  display: block;
  height: 26px;
  line-height: 26px;
  text-align: center;
  text-decoration: none;
  width: 26px;
}
.leaflet-control-zoom a:last-child { border-bottom: 0; }
.leaflet-popup { position: absolute; text-align: center; margin-bottom: 20px; }
.leaflet-popup-content-wrapper { background: #fff; border-radius: 8px; box-shadow: 0 3px 14px rgba(0,0,0,0.4); padding: 1px; text-align: left; }
.leaflet-popup-content { margin: 12px 14px; line-height: 1.35; }
.leaflet-popup-tip-container { height: 20px; left: 50%; margin-left: -20px; overflow: hidden; pointer-events: none; position: absolute; width: 40px; }
.leaflet-popup-tip { background: #fff; box-shadow: 0 3px 14px rgba(0,0,0,0.4); height: 17px; margin: -10px auto 0; padding: 1px; transform: rotate(45deg); width: 17px; }
.leaflet-popup-close-button { color: #757575; font: 16px/24px Tahoma, Verdana, sans-serif; height: 24px; position: absolute; right: 0; text-align: center; text-decoration: none; top: 0; width: 24px; }
.leaflet-container a { color: #0078a8; }
.leaflet-control-attribution { background: rgba(255,255,255,0.8); font-size: 11px; padding: 0 5px; }

:root {
  --paper: #f7f7f7;
  --panel: #ffffff;
  --ink: #222222;
  --muted: #58606a;
  --line: #dbe2ea;
  --blue: #1a4d8f;
  --shadow: 0 2px 12px rgba(0,0,0,0.12);
}

html, body { height: 100%; margin: 0; }

body.pdcc-page {
  background: var(--paper);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.45;
  overflow: hidden;
}

button, input, select { font: inherit; }

button {
  border: 1px solid #b8c4d1;
  background: #f7faff;
  color: #173f75;
  border-radius: 5px;
  padding: 0.38rem 0.55rem;
  cursor: pointer;
}
button:hover, button:focus { background: #e9f2ff; outline: none; }

.app-shell {
  display: grid;
  grid-template-columns: minmax(315px, 405px) 1fr;
  height: 100vh;
  width: 100vw;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow-y: auto;
  padding: 0.95rem 1rem 1.2rem;
  z-index: 500;
}

.sidebar-header h1 {
  font-size: 1.22rem;
  line-height: 1.2;
  margin: 0 0 0.35rem 0;
}
.sidebar-header p, .note-text, .load-status {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0.25rem 0 0.6rem;
}

.compact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.75rem 0;
}

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin: 0.7rem 0;
}
.status-grid div {
  background: #f9fbff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.45rem 0.5rem;
}
.status-grid strong { display: block; font-size: 1.02rem; line-height: 1.1; }
.status-grid span { color: var(--muted); display: block; font-size: 0.75rem; margin-top: 0.12rem; }

details {
  border-top: 1px solid #e5eaf0;
  padding: 0.45rem 0;
}
summary { cursor: pointer; font-weight: bold; color: #111; }

.filter-block { margin-top: 0.45rem; }

.mode-list, .checkbox-list, .legend-list {
  display: grid;
  gap: 0.22rem;
}
.checkbox-list label, .mode-list label, .check-line, .select-line {
  display: block;
  margin: 0.25rem 0;
}
.select-line input, .select-line select {
  box-sizing: border-box;
  display: block;
  width: 100%;
  margin-top: 0.2rem;
  padding: 0.36rem 0.42rem;
  border: 1px solid #b8c4d1;
  border-radius: 4px;
  background: #fff;
}
.slider-label { display: block; margin: 0.55rem 0 0.2rem; }
input[type="range"] { width: 100%; }

.range-pair {
  display: none;
  gap: 0.55rem;
  margin-top: 0.45rem;
}
.range-pair.active { display: grid; }

.map-stage { position: relative; min-width: 0; }
#map { height: 100%; width: 100%; background: #d9e6ef; }

.sidebar-toggle {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 800;
  box-shadow: var(--shadow);
  background: rgba(255,255,255,0.92);
}

body.sidebar-collapsed .app-shell { grid-template-columns: 0 1fr; }
body.sidebar-collapsed .sidebar { display: none; }
body.sidebar-collapsed .sidebar-toggle { left: 0.75rem; }

.legend-item {
  align-items: center;
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 0.45rem;
  font-size: 0.88rem;
}
.swatch {
  border: 1px solid rgba(0,0,0,0.25);
  border-radius: 50%;
  display: inline-block;
  height: 12px;
  width: 12px;
}
.top-places {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
  font-size: 0.88rem;
}
.top-places li { margin-bottom: 0.18rem; }

.popup h3 { margin: 0 0 0.35rem; font-size: 1rem; }
.popup table {
  border-collapse: collapse;
  font-size: 0.78rem;
  margin-top: 0.35rem;
  width: 100%;
}
.popup th, .popup td {
  border-top: 1px solid #e2e6ec;
  padding: 0.15rem 0.25rem;
  text-align: left;
  vertical-align: top;
}

.conf-note { color: #775b00; font-size: 0.78rem; }

@media (max-width: 840px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    bottom: 0;
    display: block;
    height: 47vh;
    left: 0;
    position: absolute;
    right: 0;
    top: auto;
    z-index: 900;
  }
  .map-stage { height: 100vh; }
  body.sidebar-collapsed .sidebar { display: none; }
}

.load-status[hidden] { display: none !important; }
