/* intel.css — Neighborhood Intelligence Map page */

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

:root {
  --bg-dark:     #0d0d0f;
  --bg-panel:    #1a1a1e;
  --bg-card:     #222228;
  --border:      rgba(255,255,255,0.08);
  --border-hi:   rgba(255,255,255,0.18);
  --text-light:  #ffffff;
  --text-dim:    rgba(255,255,255,0.45);
  --neon-yellow: #f0ff20;
  --neon-green:  #00ff66;
  --neon-blue:   #00c8ff;
  --neon-purple: #c644fc;
  --neon-orange: #ff9900;
  --font:        'Inter', system-ui, -apple-system, sans-serif;
  --glow-yellow: 0 0 20px rgba(240,255,32,0.25);
  --glow-green:  0 0 20px rgba(0,255,102,0.25);
}

body {
  background: var(--bg-dark);
  color: var(--text-light);
  font-family: var(--font);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
.intel-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  height: 54px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 100;
}
.intel-back {
  font-size: 13px;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.15s;
}
.intel-back:hover { color: var(--neon-yellow); }
.intel-logo { height: 28px; }
.intel-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--neon-yellow);
}
.intel-sub {
  font-size: 12px;
  color: var(--text-dim);
}
.intel-header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Main layout ─────────────────────────────────────────────────────────────── */
.intel-main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Left panel ─────────────────────────────────────────────────────────────── */
.intel-panel {
  width: 300px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 10;
}

.panel-section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.panel-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

/* County selector */
.intel-select {
  width: 100%;
  padding: 10px 12px;
  background: #111;
  border: 1px solid var(--border-hi);
  border-radius: 8px;
  color: var(--text-light);
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  margin-bottom: 10px;
  cursor: pointer;
}
.intel-select:focus {
  border-color: var(--neon-yellow);
  box-shadow: var(--glow-yellow);
}

/* Score button */
.btn-score {
  display: block;
  width: 100%;
  padding: 12px;
  background: #000;
  color: var(--neon-yellow);
  border: 2px solid var(--neon-yellow);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.15s, color 0.15s;
  box-shadow: var(--glow-yellow);
}
.btn-score:hover  { background: var(--neon-yellow); color: #000; }
.btn-score:disabled { opacity: 0.4; cursor: not-allowed; }

/* Grade filter pills */
.grade-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.grade-pill {
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-hi);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  background: none;
  color: var(--text-dim);
  font-family: var(--font);
}
.grade-pill.active-A { border-color: #00ff66; color: #00ff66; background: rgba(0,255,102,0.1); }
.grade-pill.active-B { border-color: #f0ff20; color: #f0ff20; background: rgba(240,255,32,0.1); }
.grade-pill.active-C { border-color: #ff9900; color: #ff9900; background: rgba(255,153,0,0.1); }
.grade-pill.active-D { border-color: #ff5533; color: #ff5533; background: rgba(255,85,51,0.1); }
.grade-pill.active-F { border-color: #880000; color: #cc2200; background: rgba(136,0,0,0.1); }

/* Legend */
.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 5px;
}
.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Tract info panel ────────────────────────────────────────────────────────── */
#tract-info {
  padding: 16px;
  flex: 1;
}
.tract-placeholder {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.6;
}
.tract-placeholder .tract-icon { font-size: 40px; margin-bottom: 12px; }

.tract-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-light);
  margin-bottom: 12px;
  line-height: 1.3;
}

/* Score circle */
.score-circle-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.score-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.score-circle .score-num {
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}
.score-circle .score-grade {
  font-size: 11px;
  font-weight: 700;
  opacity: 0.8;
}
.score-details {
  flex: 1;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.8;
}
.score-details strong { color: var(--text-light); }

/* Score bars */
.score-bars { margin-bottom: 14px; }
.score-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.score-bar-label { font-size: 11px; color: var(--text-dim); width: 80px; flex-shrink: 0; }
.score-bar-track {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
}
.score-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}
.score-bar-pts { font-size: 11px; color: var(--text-dim); width: 40px; text-align: right; }

/* Data rows */
.data-rows { margin-bottom: 14px; }
.data-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.data-row:last-child { border-bottom: none; }
.data-row .lbl { color: var(--text-dim); }
.data-row .val { font-weight: 700; color: var(--text-light); }
.data-row .val.green { color: var(--neon-green); }
.data-row .val.yellow { color: var(--neon-yellow); }

/* Action buttons */
.tract-actions { display: flex; flex-direction: column; gap: 8px; }
.btn-tract {
  display: block;
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s;
  text-align: center;
  text-decoration: none;
}
.btn-tract-primary {
  background: var(--neon-green);
  color: #000;
  border-color: var(--neon-green);
}
.btn-tract-primary:hover { opacity: 0.85; }
.btn-tract-secondary {
  background: none;
  color: var(--neon-blue);
  border-color: var(--neon-blue);
}
.btn-tract-secondary:hover { background: rgba(0,200,255,0.1); }

/* ── Map container ────────────────────────────────────────────────────────────── */
.intel-map-wrap {
  flex: 1;
  position: relative;
}
#intel-map {
  width: 100%;
  height: 100%;
  background: #111;
}

/* Loading overlay */
.map-loading {
  position: absolute;
  inset: 0;
  background: rgba(13,13,15,0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  gap: 16px;
  backdrop-filter: blur(4px);
}
.map-loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(240,255,32,0.2);
  border-top-color: var(--neon-yellow);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.map-loading-text { font-size: 14px; color: var(--text-dim); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Map top info bar */
.map-info-bar {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(26,26,30,0.92);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-hi);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 12px;
  color: var(--text-dim);
  z-index: 500;
  display: none;
  gap: 16px;
  white-space: nowrap;
}
.map-info-bar span { color: var(--text-light); font-weight: 700; }

/* Tooltip */
.tract-tooltip {
  background: rgba(13,13,15,0.95);
  border: 1px solid var(--border-hi);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-light);
  pointer-events: none;
  line-height: 1.6;
}
.tract-tooltip .tt-score { font-size: 18px; font-weight: 900; }

/* ── Top tracts list ─────────────────────────────────────────────────────────── */
.top-tracts { padding: 0 16px 16px; }
.top-tract-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
.top-tract-row:last-child { border-bottom: none; }
.top-tract-row:hover { opacity: 0.8; }
.tt-grade-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 900;
  flex-shrink: 0;
}
.tt-name { font-size: 12px; color: var(--text-light); line-height: 1.3; flex: 1; }
.tt-score-val { font-size: 13px; font-weight: 700; }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 680px) {
  .intel-panel { width: 260px; }
  .intel-sub { display: none; }
}
@media (max-width: 520px) {
  .intel-main { flex-direction: column; }
  .intel-panel { width: 100%; height: 280px; overflow-y: auto; border-right: none; border-bottom: 1px solid var(--border); }
  body { overflow: auto; }
}
