/* US Federal Districts — Educational Map */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, Tahoma, sans-serif;
  color: #2c3e50;
}

#map {
  position: absolute;
  inset: 0;
}

/* Mute the full-colour OpenStreetMap tiles into a light, neutral basemap.
   Set on the tiles, not the pane: Leaflet's .leaflet-tile { filter: inherit }
   would otherwise apply it twice. */
.leaflet-tile-pane .leaflet-tile {
  filter: grayscale(1) brightness(1.08) contrast(0.85);
}

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

#sidebar {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 360px;
  max-width: 100%;
  background: #fff;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
  overflow-y: auto;
  z-index: 1100;
  padding: 18px 20px 30px;
  transition: transform 0.25s ease;
}

#sidebar h1 {
  margin: 0 0 4px;
  font-size: 21px;
  border-bottom: 3px solid #3498db;
  padding-bottom: 8px;
}

.tagline {
  margin: 8px 0 16px;
  font-size: 13px;
  color: #555;
  line-height: 1.5;
}

#sidebar-toggle {
  display: none;
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1200;
  background: #fff;
  border: none;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  font-size: 20px;
  padding: 8px 12px;
  cursor: pointer;
}

/* ---------- Search ---------- */

#search-section {
  background: #f0f7fc;
  border: 2px solid #3498db;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
}

#search-section h2 {
  margin: 0 0 8px;
  font-size: 15px;
  color: #2980b9;
}

#address-input {
  width: 100%;
  padding: 8px 10px;
  border: 2px solid #cfd8dc;
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 8px;
}

#address-input:focus {
  outline: none;
  border-color: #3498db;
}

.search-buttons {
  display: flex;
  gap: 8px;
}

#search-btn, #locate-btn {
  flex: 1;
  padding: 9px 6px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
}

#search-btn { background: linear-gradient(135deg, #3498db, #2980b9); }
#locate-btn { background: #607d8b; }
#search-btn:disabled { opacity: 0.6; cursor: wait; }
#search-btn:hover:not(:disabled), #locate-btn:hover { filter: brightness(1.08); }

#search-status {
  margin-top: 8px;
  font-size: 12px;
  color: #555;
}
#search-status.error { color: #c0392b; }

#share-btn {
  width: 100%;
  margin-top: 8px;
  padding: 6px;
  background: none;
  border: 1px solid #b0bec5;
  border-radius: 6px;
  font-size: 12px;
  color: #546e7a;
  cursor: pointer;
}
#share-btn:hover { background: #eceff1; }

/* ---------- Results ---------- */

#results-panel {
  background: #fffaf0;
  border-left: 4px solid #f0a500;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
}

#results-panel h2 { margin: 0 0 8px; font-size: 15px; color: #8a6d3b; }
.results-location { font-size: 12px; color: #555; margin-bottom: 6px; }
.results-count { font-size: 13px; margin: 6px 0 10px; }
.results-branch { margin: 12px 0 6px; font-size: 13px; }
.no-results { font-size: 13px; color: #8a6d3b; margin: 0; }

.result-card {
  background: #fff;
  border-left: 3px solid #3498db;
  border-radius: 4px;
  padding: 8px 10px;
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.result-layer { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: #78909c; }
.result-name { font-size: 14px; font-weight: 600; margin: 2px 0 4px; }
.result-purpose { font-size: 12px; color: #607d8b; font-style: italic; }
.result-sub { font-size: 12px; margin: 2px 0; color: #546e7a; }
.result-link { display: inline-block; margin-top: 4px; font-size: 12px; color: #2980b9; text-decoration: none; }
.result-link:hover { text-decoration: underline; }

#print-btn {
  width: 100%;
  margin-top: 4px;
  padding: 7px;
  background: #fff;
  border: 1px solid #f0a500;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: #8a6d3b;
  cursor: pointer;
}
#print-btn:hover { background: #fff3d6; }

/* ---------- Layer panel ---------- */

#layer-panel h2 { font-size: 15px; margin: 0 0 8px; }

.branch-group { margin-bottom: 14px; }
.branch-group h3 { font-size: 13px; margin: 10px 0 6px; text-transform: uppercase; letter-spacing: 0.03em; }

.layer-row { margin-bottom: 4px; }
.layer-row-top { display: flex; align-items: center; gap: 6px; }

.layer-label {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 5px;
}
.layer-label:hover { background: #f5f7fa; }

.swatch {
  width: 16px;
  height: 12px;
  border: 1.5px solid;
  border-radius: 2px;
  flex-shrink: 0;
}

.spinner {
  width: 12px;
  height: 12px;
  border: 2px solid #cfd8dc;
  border-top-color: #3498db;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.info-btn {
  background: none;
  border: 1px solid #cfd8dc;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 12px;
  color: #78909c;
  cursor: pointer;
  flex-shrink: 0;
}
.info-btn:hover { background: #eceff1; color: #37474f; }

.layer-blurb {
  font-size: 12px;
  color: #546e7a;
  background: #f8f9fa;
  border-radius: 6px;
  padding: 8px 10px;
  margin: 4px 0 6px 30px;
  line-height: 1.5;
}

/* ---------- About ---------- */

#about-section {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid #e0e0e0;
  font-size: 11.5px;
  color: #78909c;
  line-height: 1.5;
}
#about-section a { color: #2980b9; }

/* ---------- Popups ---------- */

.popup { font-size: 13px; line-height: 1.45; }
.popup-layer { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: #78909c; }
.popup-title { margin: 2px 0 6px; font-size: 16px; color: #2c3e50; }
.popup-sub { font-size: 12px; margin: 2px 0; color: #546e7a; }
.edu-desc { margin: 8px 0 6px; font-size: 12.5px; }
.edu-item { margin: 4px 0; font-size: 12px; color: #546e7a; }
.edu-matters {
  margin-top: 8px;
  padding: 8px;
  background: #eaf4fd;
  border-radius: 5px;
  font-size: 12px;
}
.popup-link { margin-top: 8px; font-size: 12.5px; }
.popup-link a { color: #2980b9; text-decoration: none; font-weight: 600; }
.popup-link a:hover { text-decoration: underline; }

/* ---------- Search pin ---------- */

.search-pin .pin {
  width: 22px;
  height: 22px;
  background: #e74c3c;
  border: 3px solid #fff;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* ---------- Mobile ---------- */

@media (max-width: 720px) {
  #sidebar {
    width: min(340px, 88vw);
    transform: translateX(-105%);
  }
  #sidebar.open { transform: translateX(0); }
  #sidebar-toggle { display: block; }
}

/* ---------- Printable report ---------- */

#print-report { display: none; }

@media print {
  @page { margin: 16mm 14mm; }

  html, body { height: auto; }
  #map, #sidebar, #sidebar-toggle, noscript { display: none !important; }

  #print-report {
    display: block;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 10.5pt;
    line-height: 1.4;
    color: #000;
  }

  .report-header { border-bottom: 2px solid #000; padding-bottom: 8px; margin-bottom: 12px; }
  .report-kicker { font-family: system-ui, sans-serif; font-size: 8.5pt; text-transform: uppercase; letter-spacing: 0.08em; color: #555; }
  .report-header h1 { margin: 2px 0 6px; font-size: 22pt; }
  .report-address { margin: 0; font-size: 11.5pt; font-weight: 600; }
  .report-meta { margin: 2px 0 0; font-size: 9pt; color: #555; }

  .report-branch { margin-top: 14px; }
  .report-branch h2 {
    margin: 0 0 2px;
    font-size: 13pt;
    color: var(--branch-color);
    border-bottom: 1px solid var(--branch-color);
    padding-bottom: 2px;
    break-after: avoid;
  }
  .report-branch-blurb { margin: 2px 0 8px; font-size: 9.5pt; font-style: italic; color: #444; }

  .report-item {
    border-left: 3pt solid #999;
    padding: 2px 0 2px 10px;
    margin: 0 0 10px;
    break-inside: avoid;
  }
  .report-item h3 { margin: 0 0 3px; font-size: 12pt; }
  .report-item p { margin: 3px 0; }
  .report-layer { font-family: system-ui, sans-serif; font-size: 8pt; text-transform: uppercase; letter-spacing: 0.05em; color: #555; }
  .report-sub { font-size: 9.5pt; }
  .report-link { font-family: ui-monospace, Menlo, monospace; font-size: 8.5pt; color: #333; overflow-wrap: anywhere; }

  .report-footer { margin-top: 16px; padding-top: 6px; border-top: 1px solid #999; font-size: 8.5pt; color: #555; }
  .report-footer p { margin: 2px 0; overflow-wrap: anywhere; }

  /* Keep branch colours on paper; browsers drop them by default */
  #print-report * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
