/* Valley Project Map — Livable Telluride */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green-dark: #1B4332;
  --green-mid: #2D6A4F;
  --green-light: #95D5B2;
  --bg: #f4f1eb;
  --panel-bg: #1a2e24;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --border: #e5e7eb;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg);
  color: var(--text);
}

/* HEADER */
#header {
  background: var(--green-dark);
  color: white;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  z-index: 100;
}
#header-left h1 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}
#header-left p {
  font-size: 0.72rem;
  opacity: 0.7;
  margin-top: 1px;
}
#submit-missing {
  background: rgba(255,255,255,0.15);
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 5px;
  padding: 6px 11px;
  font-size: 0.73rem;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s;
}
#submit-missing:hover { background: rgba(255,255,255,0.25); }

/* MAIN LAYOUT */
#main {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* LEFT PANEL */
#left-panel {
  width: 300px;
  flex-shrink: 0;
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border);
  z-index: 10;
}

#search-box {
  padding: 10px 10px 8px;
  border-bottom: 1px solid var(--border);
}
#search-input {
  width: 100%;
  padding: 7px 11px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.83rem;
  outline: none;
  background: #fafafa;
}
#search-input:focus { border-color: var(--green-mid); background: #fff; }

/* COUNTER */
#counter {
  background: var(--green-dark);
  color: white;
  padding: 8px 10px;
  border-bottom: 2px solid #0f2318;
  flex-shrink: 0;
}
#counter-title {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.65;
  margin-bottom: 6px;
}
.counter-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.counter-stat { text-align: center; }
.counter-stat .val {
  font-size: 0.88rem;
  font-weight: 700;
  display: block;
}
.counter-stat .lbl {
  font-size: 0.52rem;
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.2;
}

/* FILTERS */
#filters {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
  max-height: 180px;
}
.filter-section { margin-bottom: 6px; }
.filter-section:last-child { margin-bottom: 0; }
.filter-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 3px;
  font-weight: 600;
}
.filter-chips { display: flex; flex-wrap: wrap; gap: 3px; }
.filter-chip {
  padding: 2px 7px;
  border: 1px solid #d1d5db;
  border-radius: 99px;
  background: white;
  font-size: 0.68rem;
  cursor: pointer;
  color: #374151;
  transition: all 0.12s;
  white-space: nowrap;
}
.filter-chip:hover { border-color: var(--green-mid); color: var(--green-mid); }
.filter-chip.active { background: var(--green-dark); color: white; border-color: var(--green-dark); }

/* PROJECT LIST */
#project-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}
.project-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 10px;
  cursor: pointer;
  border-bottom: 1px solid #f3f4f6;
  transition: background 0.1s;
}
.project-item:hover { background: #f9fafb; }
.project-item.active { background: #ecfdf5; border-left: 3px solid var(--green-mid); }
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 3px;
  flex-shrink: 0;
  border: 1.5px solid rgba(255,255,255,0.6);
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.project-item-text strong { font-size: 0.78rem; display: block; line-height: 1.3; }
.project-item-text span { font-size: 0.67rem; color: var(--text-muted); }
.no-results { padding: 20px 10px; color: var(--text-muted); font-size: 0.8rem; text-align: center; }

/* MAP */
#map-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
}
#map { width: 100%; height: 100%; }

/* PRESET VIEW BUTTONS */
#preset-buttons {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: center;
  z-index: 10;
  max-width: 620px;
  padding: 0 10px;
}
.preset-btn {
  background: rgba(255,255,255,0.95);
  border: 1px solid #d1d5db;
  border-radius: 5px;
  padding: 4px 9px;
  font-size: 0.69rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  transition: all 0.15s;
  white-space: nowrap;
}
.preset-btn:hover { border-color: var(--green-mid); color: var(--green-mid); }
.preset-btn.active { background: var(--green-dark); color: white; border-color: var(--green-dark); }

/* MAP MARKERS */
.map-marker {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.9);
  box-shadow: 0 1px 5px rgba(0,0,0,0.35);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.map-marker:hover { transform: scale(1.45); z-index: 100; }
.map-marker.active-marker {
  transform: scale(1.8);
  z-index: 200;
  border: 3px solid #fff;
  box-shadow: 0 0 0 3px #1a1a1a, 0 0 0 5px rgba(255,255,255,0.7), 0 3px 12px rgba(0,0,0,0.55);
  animation: markerPulse 1.8s ease-in-out infinite;
}
@keyframes markerPulse {
  0%, 100% { box-shadow: 0 0 0 3px #1a1a1a, 0 0 0 5px rgba(255,255,255,0.7), 0 3px 12px rgba(0,0,0,0.55); }
  50%       { box-shadow: 0 0 0 3px #1a1a1a, 0 0 0 8px rgba(255,255,255,0.35), 0 3px 16px rgba(0,0,0,0.4); }
}

/* LEGEND */
#legend {
  position: absolute;
  bottom: 36px;
  left: 10px;
  background: rgba(255,255,255,0.96);
  border-radius: 7px;
  padding: 8px 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  z-index: 10;
  font-size: 0.68rem;
}
#legend h4 {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.7);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  flex-shrink: 0;
}

/* RIGHT DRAWER */
#drawer {
  position: absolute;
  top: 0;
  right: -380px;
  width: 360px;
  height: 100%;
  background: white;
  box-shadow: -3px 0 16px rgba(0,0,0,0.12);
  z-index: 20;
  display: flex;
  flex-direction: column;
  transition: right 0.22s ease;
  overflow: hidden;
}
#drawer.open { right: 0; }

.drawer-header {
  background: var(--green-dark);
  color: white;
  padding: 12px 14px;
  flex-shrink: 0;
  position: relative;
}
.drawer-close {
  position: absolute;
  top: 9px;
  right: 11px;
  background: none;
  border: none;
  color: white;
  font-size: 0.95rem;
  cursor: pointer;
  opacity: 0.65;
  padding: 3px 5px;
  line-height: 1;
  border-radius: 3px;
}
.drawer-close:hover { opacity: 1; background: rgba(255,255,255,0.15); }
.drawer-status-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 99px;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 5px;
  color: white;
  background: rgba(255,255,255,0.2);
}
.drawer-title {
  font-size: 0.97rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 3px;
  padding-right: 22px;
}
.drawer-meta { font-size: 0.7rem; opacity: 0.7; }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
}
.drawer-section {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f3f4f6;
}
.drawer-section:last-of-type { border-bottom: none; }
.drawer-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 3px;
  font-weight: 700;
}
.drawer-key-question {
  font-style: italic;
  font-size: 0.83rem;
  line-height: 1.5;
  color: #374151;
}
.drawer-section p { font-size: 0.8rem; line-height: 1.5; color: #374151; }
.drawer-date { font-weight: 600; color: #dc2626; font-size: 0.8rem; }

.drawer-stats-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.stat {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 5px 9px;
  text-align: center;
  font-size: 0.67rem;
  color: var(--text-muted);
  min-width: 60px;
}
.stat span { display: block; font-size: 0.95rem; font-weight: 700; color: var(--text); }

.confidence-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-top: 2px;
}
.confidence-confirmed  { background: #dcfce7; color: #166534; }
.confidence-estimated  { background: #fef9c3; color: #854d0e; }
.confidence-disputed   { background: #fee2e2; color: #991b1b; }
.confidence-unknown    { background: #f3f4f6; color: #6b7280; }
.confidence-needs-source { background: #f3f4f6; color: #6b7280; }

.drawer-links { display: flex; flex-direction: column; gap: 5px; margin-top: 10px; }
.drawer-btn {
  display: block;
  text-align: center;
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: opacity 0.12s;
  background: #f3f4f6;
  color: #374151;
}
.drawer-btn:hover { opacity: 0.8; }
.drawer-btn-primary { background: var(--green-dark) !important; color: white !important; }
.drawer-btn-subtle {
  background: transparent !important;
  color: var(--text-muted) !important;
  border: 1px solid #e5e7eb;
  font-weight: 400;
  font-size: 0.73rem;
}
.drawer-footer { margin-top: 10px; font-size: 0.67rem; color: var(--text-muted); text-align: right; }

/* 3D MASSING TOGGLE */
#massing-toggle-bar {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  background: rgba(255,255,255,0.97);
  border-radius: 8px;
  padding: 7px 13px 7px 11px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.14);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 240px;
}
.massing-toggle-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #1a2e24;
  cursor: pointer;
  user-select: none;
}
.massing-toggle-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #2D6A4F;
}
.massing-toggle-icon {
  font-size: 0.9rem;
}
#massing-disclaimer {
  display: none;
  font-size: 0.62rem;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 4px;
  padding: 3px 7px;
  text-align: center;
  line-height: 1.4;
  max-width: 280px;
}

/* Massing legend block (square, not circle) */
.legend-block {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  opacity: 0.8;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.5);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* UPCOMING HEARINGS */
.hearing-alert-label {
  color: #b91c1c !important;
}
.hearing-card {
  background: #fff8f0;
  border: 1px solid #fed7aa;
  border-left: 3px solid #ea580c;
  border-radius: 5px;
  padding: 8px 10px;
  margin-top: 5px;
}
.hearing-type {
  font-size: 0.68rem;
  font-weight: 700;
  color: #c2410c;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}
.hearing-date {
  font-size: 0.83rem;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 5px;
}
.hearing-desc {
  font-size: 0.72rem;
  color: #555;
  line-height: 1.45;
  margin-bottom: 7px;
}
.hearing-links { display: flex; flex-wrap: wrap; gap: 4px; }
.hearing-link {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--green-dark);
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 4px;
  padding: 3px 7px;
  text-decoration: none;
  white-space: nowrap;
}
.hearing-link:hover { background: #d1fae5; }

/* DOCUMENT DOWNLOAD BUTTON */
.drawer-btn-download {
  background: #eff6ff !important;
  color: #1d4ed8 !important;
  border: 1px solid #bfdbfe !important;
  font-weight: 600;
}
.drawer-btn-download:hover { background: #dbeafe !important; opacity: 1; }

/* Mapbox overrides */
.mapboxgl-ctrl-bottom-right { z-index: 5; }

/* ── Mobile-only floating toggle + close + backdrop (hidden on desktop) ── */
#mobile-filter-toggle,
#mobile-panel-close,
#mobile-panel-backdrop { display: none; }

/* ── MOBILE: left panel becomes a slide-out drawer ── */
@media (max-width: 860px) {
  /* Map takes full width by default */
  #left-panel {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(340px, 86vw);
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.24s ease;
    z-index: 200;
    box-shadow: 3px 0 16px rgba(0,0,0,0.18);
    border-right: none;
  }
  #left-panel.open { transform: translateX(0); }

  /* Backdrop fades in when panel is open */
  #mobile-panel-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 35, 24, 0);
    z-index: 150;
    pointer-events: none;
    transition: background 0.24s ease;
  }
  #mobile-panel-backdrop.open {
    background: rgba(15, 35, 24, 0.45);
    pointer-events: auto;
  }

  /* Close button inside the panel — top-right */
  #mobile-panel-close {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 8px;
    right: 8px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(15, 35, 24, 0.08);
    border: none;
    color: #15291f;
    font-size: 1.05rem;
    cursor: pointer;
    z-index: 5;
  }
  #mobile-panel-close:hover { background: rgba(15, 35, 24, 0.16); }

  /* Push search box content right so it doesn't overlap the close button */
  #left-panel #search-box { padding-right: 50px; }

  /* Floating pill button on the map — top-left, above the preset buttons */
  #mobile-filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 30;
    background: #fff;
    color: var(--green-dark);
    border: 1px solid rgba(15, 35, 24, 0.12);
    border-radius: 999px;
    padding: 9px 16px;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.12);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  }
  #mobile-filter-toggle:hover { background: #f5f9f6; }

  /* When panel is open, also dim/hide the floating button so it doesn't
     poke out from behind the panel */
  body.left-panel-open #mobile-filter-toggle { display: none; }

  /* Preset region-zoom buttons: hidden on mobile — they wrap to 3 rows of
     chips on a narrow viewport and blanket the map. The Community Area
     filter inside the slide-out drawer still gives the same filtering. */
  #preset-buttons { display: none !important; }

  /* Right drawer (project details) becomes a BOTTOM SHEET on mobile so the
     user can see the map AND the project info at the same time. Three
     heights: collapsed (small peek), default (~55% screen), expanded
     (full screen). User toggles via the drag-handle bar at the top. */
  #drawer {
    top: auto !important;
    bottom: 0 !important;
    right: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 55vh !important;
    max-height: 55vh;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.18) !important;
    transform: translateY(100%);
    transition: transform 0.24s ease, height 0.24s ease, max-height 0.24s ease;
  }
  #drawer.open {
    right: 0 !important;
    transform: translateY(0);
  }
  #drawer.expanded {
    height: 92vh !important;
    max-height: 92vh;
  }
  #drawer.collapsed {
    height: 64px !important;
    max-height: 64px;
  }
  /* Drag handle bar at the top of the drawer — tap to cycle through
     collapsed → default → expanded → default → collapsed. */
  .drawer-toggle-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 24px;
    flex-shrink: 0;
    cursor: pointer;
    background: #fff;
    position: relative;
    z-index: 1;
  }
  .drawer-toggle-bar::before {
    content: '';
    width: 44px;
    height: 5px;
    border-radius: 999px;
    background: #c4c8c2;
  }
  .drawer-toggle-bar:hover::before { background: #9aa2a0; }
  /* In collapsed mode, swap the drawer header background to white so the
     project-name peek looks clean above the map */
  #drawer.collapsed .drawer-body { display: none; }
  #drawer.collapsed .drawer-header {
    background: #fff;
    color: var(--green-dark);
    border-bottom: 1px solid rgba(0,0,0,0.08);
  }
  #drawer.collapsed .drawer-close,
  #drawer.collapsed .drawer-title,
  #drawer.collapsed .drawer-status-badge,
  #drawer.collapsed .drawer-meta { color: var(--green-dark); }
}
/* Desktop default: toggle bar is hidden (drawer slides in from the right). */
.drawer-toggle-bar { display: none; }
@media (max-width: 860px) {
  .drawer-toggle-bar { display: flex; }

  /* Allow filters to scroll when the panel itself is the scroll container */
  #filters { max-height: none; overflow: visible; }
}
