/* ============================================
   NCA Overlay Analysis Site — Shared Styles
   ============================================ */

:root {
  --navy: #1a1a2e;
  --red: #dc2626;
  --green: #16a34a;
  --orange: #f97316;
  --gray: #6b7280;
  --purple: #8b5cf6;
  --blue: #2563eb;
  --light-bg: #f8f9fa;
  --border: #e5e7eb;
  --text: #333;
  --text-light: #666;
  --nav-height: 56px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  line-height: 1.6;
}

/* ---- NAV BAR ---- */
.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5em;
  z-index: 9999;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.nav-brand {
  color: white;
  font-weight: 700;
  font-size: 1.1em;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.nav-links {
  display: flex;
  gap: 0.2em;
}

.nav-links a {
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 0.85em;
  font-weight: 500;
  padding: 0.4em 0.8em;
  border-radius: 6px;
  transition: all 0.15s;
}

.nav-links a:hover {
  color: white;
  background: rgba(255,255,255,0.1);
}

.nav-links a.active {
  color: white;
  background: rgba(255,255,255,0.15);
}

.nav-links a.external::after {
  content: " \2197";
  font-size: 0.8em;
}

/* ---- MAP PAGE LAYOUT ---- */
.map-container {
  margin-top: var(--nav-height);
  display: flex;
  height: calc(100vh - var(--nav-height));
}

.map-sidebar {
  width: 340px;
  min-width: 340px;
  padding: 1.2em;
  overflow-y: auto;
  background: white;
  border-right: 1px solid var(--border);
}

.map-sidebar h2 {
  font-size: 1.15em;
  color: var(--navy);
  margin-bottom: 0.2em;
}

.sidebar-subtitle {
  font-size: 0.78em;
  color: var(--text-light);
  margin-bottom: 1em;
  line-height: 1.4;
}

#map {
  flex: 1;
  min-width: 0;
}

/* ---- FILTER CONTROLS ---- */
.filter-group {
  margin-bottom: 1em;
}

.filter-group > label {
  display: block;
  font-size: 0.75em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
  margin-bottom: 0.3em;
}

.filter-group select {
  width: 100%;
  padding: 0.5em 0.6em;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85em;
  background: white;
  color: var(--text);
  cursor: pointer;
}

.filter-group select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 0.3em;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 0.4em;
  font-size: 0.82em;
  cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* ---- SUMMARY STATS ---- */
.summary-stats {
  background: var(--light-bg);
  border-radius: 8px;
  padding: 0.8em;
  margin: 1em 0;
}

.summary-stats .stat {
  font-size: 0.82em;
  color: var(--text-light);
  display: flex;
  justify-content: space-between;
  padding: 0.15em 0;
}

.summary-stats .stat span {
  font-weight: 600;
  color: var(--text);
}

/* ---- LEGEND ---- */
.legend {
  margin-top: 1em;
  padding-top: 1em;
  border-top: 1px solid var(--border);
}

.legend h3 {
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
  margin-bottom: 0.5em;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5em;
  font-size: 0.8em;
  padding: 0.2em 0;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,0.3);
  flex-shrink: 0;
}

.dot.red { background: var(--red); }
.dot.green { background: var(--green); }
.dot.orange { background: var(--orange); }
.dot.gray { background: var(--gray); }
.dot.purple { background: var(--purple); }

.polygon-swatch {
  width: 16px;
  height: 12px;
  border: 2px dashed var(--red);
  background: rgba(220,38,38,0.08);
  border-radius: 2px;
  flex-shrink: 0;
}

/* ---- MAP POPUPS ---- */
.map-popup h3 {
  font-size: 1em;
  color: var(--navy);
  margin-bottom: 0.15em;
}

.map-popup .popup-address {
  font-size: 0.82em;
  color: var(--text-light);
  margin-bottom: 0.5em;
}

.map-popup p {
  font-size: 0.85em;
  margin: 0.25em 0;
}

.map-popup .popup-alert {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--red);
  padding: 0.3em 0.5em;
  border-radius: 4px;
  font-weight: 600;
  margin-top: 0.5em;
  font-size: 0.82em;
}

.map-popup .popup-alert.purple {
  background: #f5f3ff;
  border-color: #ddd6fe;
  color: var(--purple);
}

.popup-path-badge {
  display: inline-block;
  padding: 0.15em 0.5em;
  border-radius: 999px;
  font-size: 0.75em;
  font-weight: 600;
  color: white;
}
.popup-path-badge.zba { background: var(--red); }
.popup-path-badge.by-right { background: var(--green); }
.popup-path-badge.unmatched { background: var(--orange); }

/* ---- CONTENT PAGES (analysis, data) ---- */
.page-content {
  margin-top: var(--nav-height);
  max-width: 860px;
  margin-left: auto;
  margin-right: auto;
  padding: 2em 1.5em 4em;
}

.page-content h1 {
  font-size: 1.8em;
  color: var(--navy);
  margin-bottom: 0.3em;
  line-height: 1.2;
}

.page-content h2 {
  font-size: 1.35em;
  color: var(--navy);
  margin-top: 2em;
  margin-bottom: 0.5em;
  padding-bottom: 0.3em;
  border-bottom: 2px solid var(--border);
}

.page-content h3 {
  font-size: 1.1em;
  color: var(--navy);
  margin-top: 1.5em;
  margin-bottom: 0.4em;
}

.page-content p {
  margin-bottom: 1em;
}

.page-content ul, .page-content ol {
  margin-bottom: 1em;
  padding-left: 1.5em;
}

.page-content li {
  margin-bottom: 0.3em;
}

.page-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
  font-size: 0.9em;
}

.page-content th {
  background: var(--navy);
  color: white;
  padding: 0.6em 0.8em;
  text-align: left;
  font-weight: 600;
}

.page-content td {
  padding: 0.5em 0.8em;
  border-bottom: 1px solid var(--border);
}

.page-content tr:nth-child(even) {
  background: var(--light-bg);
}

.page-content strong {
  color: var(--navy);
}

.page-content em {
  color: var(--text-light);
}

.page-content hr {
  border: none;
  border-top: 2px solid var(--border);
  margin: 2em 0;
}

.page-content img {
  max-width: 100%;
  border-radius: 8px;
  margin: 1em 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.page-content blockquote {
  border-left: 4px solid var(--blue);
  padding: 0.8em 1.2em;
  margin: 1em 0;
  background: #eff6ff;
  border-radius: 0 8px 8px 0;
}

/* ---- DATA PAGE ---- */
.download-card {
  background: white;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 2em;
  margin: 1.5em 0;
  text-align: center;
}

.download-card h3 {
  margin-top: 0;
  margin-bottom: 0.5em;
}

.download-btn {
  display: inline-block;
  background: var(--blue);
  color: white;
  text-decoration: none;
  padding: 0.8em 2em;
  border-radius: 8px;
  font-weight: 600;
  font-size: 1em;
  margin-top: 0.8em;
  transition: background 0.15s;
}

.download-btn:hover {
  background: #1d4ed8;
}

.meta-info {
  font-size: 0.82em;
  color: var(--text-light);
  margin-top: 0.5em;
}

/* ---- PRESENTATION PAGE ---- */
.presentation-frame {
  margin-top: var(--nav-height);
  width: 100%;
  height: calc(100vh - var(--nav-height));
  border: none;
}

/* ---- RESPONSIVE ---- */

/* Tablet */
@media (max-width: 900px) {
  .nav-brand {
    font-size: 0.9em;
  }

  .nav-links a {
    padding: 0.4em 0.5em;
    font-size: 0.78em;
  }

  .map-sidebar {
    width: 280px;
    min-width: 280px;
  }
}

/* Mobile */
@media (max-width: 640px) {
  /* Nav: stack brand above links */
  .site-nav {
    height: auto;
    flex-direction: column;
    padding: 0.5em 1em;
    gap: 0.3em;
  }

  .nav-brand {
    font-size: 0.85em;
    text-align: center;
  }

  .nav-links {
    gap: 0;
    flex-wrap: wrap;
    justify-content: center;
  }

  .nav-links a {
    padding: 0.3em 0.5em;
    font-size: 0.72em;
  }

  /* Map: sidebar becomes collapsible top panel */
  .map-container {
    flex-direction: column;
    margin-top: 80px; /* taller stacked nav */
  }

  .map-sidebar {
    width: 100%;
    min-width: 100%;
    max-height: 35vh;
    border-right: none;
    border-bottom: 2px solid var(--border);
    padding: 0.8em;
  }

  .map-sidebar h2 {
    font-size: 1em;
  }

  .sidebar-subtitle {
    font-size: 0.72em;
    margin-bottom: 0.6em;
  }

  /* Compact filters on mobile */
  .filter-group {
    margin-bottom: 0.6em;
  }

  .checkbox-group {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.2em 0.8em;
  }

  .checkbox-group label {
    font-size: 0.75em;
  }

  .legend {
    display: none; /* hide on mobile to save space; info is in popups */
  }

  #map {
    height: calc(100vh - 80px - 35vh);
    min-height: 300px;
  }

  /* Content pages */
  .page-content {
    padding: 1.2em 0.8em 3em;
    margin-top: 80px;
  }

  .page-content h1 {
    font-size: 1.4em;
  }

  .page-content h2 {
    font-size: 1.15em;
  }

  .page-content table {
    font-size: 0.78em;
  }

  .page-content img {
    margin: 0.5em 0;
  }

  .download-card {
    padding: 1.2em;
  }

  .download-btn {
    padding: 0.6em 1.5em;
    font-size: 0.9em;
  }

  /* Presentation iframe */
  .presentation-frame {
    margin-top: 80px;
    height: calc(100vh - 80px);
  }
}
