/* ========================================
   BASE STYLES - Body & Global Settings
   ======================================== */
html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
  font-size: 16px;
  background: #111;
  color: #fff;
  overflow: hidden;
}

body {
  display: flex;
}

/* ========================================
   LINKS - Brand Colors
   ======================================== */
a {
  color: #ade4fa;
  text-decoration: none;
  transition: color 0.2s, text-decoration 0.2s;
  font-weight: 500;
}

a:hover,
a:focus {
  color: #9de0fc;
  text-decoration: underline;
  outline: none;
}

a:visited {
  color: #ade4fa;
}

/* ========================================
   SIDEBAR - Left Control Panel
   ======================================== */
#sidebar {
  width: 300px;
  background-color: #000;
  color: #fff;
  padding: 15px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #444 transparent;
  box-shadow: 2px 0 5px rgba(0, 0, 0, 0.25);
  z-index: 2;
}

#sidebar::-webkit-scrollbar {
  width: 5px;
}

#sidebar::-webkit-scrollbar-track {
  background: transparent;
}

#sidebar::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 3px;
}

#sidebar::-webkit-scrollbar-thumb:hover {
  background: #666;
}

.sidebar-title {
  font-size: 1.125em;
  margin: 0 0 12px 0;
  font-weight: 700;
  color: #f7c320;
  letter-spacing: 0.01em;
  line-height: 1.3;
}

/* ========================================
   STEP HEADERS & HELPER TEXT
   ======================================== */
h3 {
  font-weight: 600;
  font-size: 1em;
  color: #f7c320;
  margin: 20px 0 8px 0;
}

.helper-text {
  font-size: 0.86em;
  color: #e6e6e6;
  margin: 4px 0 10px 0;
  line-height: 1.4;
}

.helper-text strong {
  color: #fff;
  font-weight: 600;
}

/* Methodology Link */
#methodology-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.86em;
  color: #ade4fa;
  cursor: pointer;
}

#methodology-link:hover {
  text-decoration: underline;
}



/* ========================================
   RISK GROUP BUTTONS
   ======================================== */
.risk-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 15px;
}

.risk-buttons button {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.86em;
  font-weight: 600;
  color: #000;
  border: 3px solid transparent;
  cursor: pointer;
  background: #1a1a1a;
  transition: all 0.15s ease;
  font-family: inherit;
  text-align: left;
}

.risk-buttons button:hover {
  transform: translateX(2px);
  filter: brightness(1.1);
}

.tooltip-wrap {
  position: relative;
}

.tooltip-wrap .tooltip {
  display: none;
}

#floating-tooltip {
  position: fixed;
  z-index: 1000;
  width: 240px;
  background: rgba(15, 15, 15, 0.95);
  color: #e5e7eb;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
  padding: 10px 14px;
  border: 1px solid #555;
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

#floating-tooltip.visible {
  opacity: 1;
}

#floating-tooltip::before {
  content: '';
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 7px solid transparent;
  border-right-color: #555;
}

#floating-tooltip::after {
  content: '';
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-right-color: rgba(15, 15, 15, 0.95);
}

.tooltip-trigger {
  cursor: help;
}

.risk-buttons button.active {
  border-color: #fff;
}

/* County dropdown - matches city project control style */
#county-select {
  width: 100%;
  padding: 10px;
  margin-bottom: 8px;
  background-color: #363636;
  color: #fff;
  border: 2px solid #4a4a4a;
  font-size: 0.875em;
  cursor: pointer;
  font-family: inherit;
}

#county-select:focus {
  outline: none;
  border-color: #f7c320;
}

/* Show All Toggle Button */
.toggle-all {
  background: #1a1a1a !important;
  color: #fff !important;
  border: 2px solid #333 !important;
  text-align: center;
  font-weight: 700;
}

.toggle-all:hover {
  background: #262626 !important;
  border-color: #555 !important;
}

.toggle-all.active {
  background: #fff !important;
  color: #000 !important;
  border-color: #fff !important;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .risk-buttons button {
    padding: 9px 10px;
    font-size: 0.7em;
  }

  #floating-tooltip {
    display: none;
  }
}




/* ========================================
   COUNTY DATA DISPLAY
   ======================================== */
.county-display {
  background: #1a1a1a;
  padding: 12px;
  margin: 10px 0;
  border-left: 3px solid #f7c320;
  min-height: 60px;
}

.county-prompt {
  color: #888;
  font-size: 1em;
  font-style: italic;
  margin: 0;
}

.county-display h4 {
  margin: 0 0 10px 0;
  color: #f7c320;
  font-size: 1.125em;
  font-weight: 600;
}

.county-display p {
  font-size: 0.9em;
  line-height: 1.5;
  margin: 6px 0;
  color: #e6e6e6;
}

.county-display strong {
  color: #fff;
}


/* ========================================
   STEP 4 - Blue Acres Buyouts
   ======================================== */
#blue-acres-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #333;
}

/* Blue Acres button uses .risk-buttons button styles */

#toggle-blue-acres {
  display: none;
}

/* Blue Acres stats box */
.blue-acres-stats {
  font-size: 0.85em;
  color: #d1d5db;
  line-height: 1.5;
  padding: 8px 10px;
  background: rgba(13, 148, 136, 0.08);
  border-left: 3px solid #0d9488;
  border-radius: 0 4px 4px 0;
  margin-top: 6px;
}

.blue-acres-stats .stat-highlight {
  color: #2dd4bf;
  font-weight: 600;
}

.blue-acres-stats .stat-county {
  color: #fbbf24;
  font-weight: 600;
}

.hidden {
  display: none !important;
}

/* ========================================
   MAP CONTAINER
   ======================================== */
#map {
  flex-grow: 1;
  position: relative;
  background: #f5f5f5;
}


  /* Logo overlay on map */
  .map-logo {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 5;
  }

  .map-logo img {
    max-width: 80px;
    display: block;
  }

#loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  background: rgba(0, 0, 0, 0.9);
  color: #fff;
  padding: 20px 40px;
  font-size: 1.375em;
  font-weight: 600;
}

/* ========================================
   HOW TO USE BANNER & MODAL
   ======================================== */
.howto-banner {
  position: absolute;
  bottom: 30px;
  right: 10px;
  z-index: 10;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  border: 1.5px solid rgba(255, 255, 255, 0.5);
  font-size: 0.875em;
  font-weight: 600;
  font-style: italic;
  font-family: Georgia, 'Times New Roman', serif;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  padding: 0;
  line-height: 1;
}

.howto-banner:hover,
.howto-banner:focus {
  background: rgba(0, 0, 0, 0.9);
  border-color: #fff;
  transform: scale(1.1);
  outline: none;
}

.howto-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 1;
  transition: opacity 0.3s;
}

.howto-modal.hidden {
  opacity: 0;
  pointer-events: none;
}

.howto-content {
  background: #111;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 22px 24px 18px 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  position: relative;
  color: #fff;
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
  font-size: 0.92em;
  line-height: 1.55;
  border: 1px solid #333;
}

.howto-content a {
  color: #ade4fa;
  text-decoration: none;
}

.howto-content a:hover {
  text-decoration: underline;
}

.howto-content h2 {
  margin-top: 0;
  font-size: 1em;
  line-height: 1.3;
  font-weight: 700;
  color: #f7c320;
  font-family: inherit;
}

.howto-content ul {
  margin: 12px 0 8px 0;
  padding-left: 20px;
  font-size: 1em;
  line-height: 1.5;
  font-family: inherit;
}

.howto-content li {
  margin-bottom: 10px;
  color: #e6e6e6;
}

.howto-content li strong {
  color: #fff;
}

.howto-content p {
  color: #888;
}

.howto-content a {
  color: #ade4fa;
  font-weight: 600;
}

#howto-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.5em;
  color: #888;
  cursor: pointer;
  transition: color 0.2s;
  padding: 5px 10px;
  line-height: 1;
}

#howto-close:hover {
  color: #ade4fa;
}

.howto-content h3 {
  margin: 16px 0 6px 0;
  font-size: 0.88em;
  font-weight: 700;
  color: #f7c320;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.howto-content p {
  margin: 0 0 8px 0;
}

.howto-content ul {
  margin: 6px 0 10px 0;
  padding-left: 18px;
}

.howto-content li {
  margin-bottom: 5px;
  color: #e6e6e6;
}

table.method-sources {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 12px 0;
  font-size: 0.92em;
}

table.method-sources td {
  padding: 4px 8px 4px 0;
  border-bottom: 1px solid #222;
  color: #ccc;
  vertical-align: top;
}

table.method-sources td:first-child {
  color: #e6e6e6;
  white-space: nowrap;
}

table.method-sources td:last-child {
  color: #999;
  text-align: right;
}

.method-credits {
  font-size: 0.9em;
  color: #888 !important;
  margin-top: 12px !important;
  border-top: 1px solid #222;
  padding-top: 10px;
}

/* ========================================
   FINDING CARD OVERLAY
   ======================================== */
#finding-card {
  position: absolute;
  right: 60px;
  top: 140px;
  width: 310px;
  max-width: calc(100% - 72px);
  background: rgba(0, 0, 0, 0.82);
  border-left: none;
  padding: 24px 22px 24px 30px;
  z-index: 5;
  pointer-events: auto;
}

#finding-close {
  position: absolute;
  top: 4px;
  right: 6px;
  background: none;
  border: none;
  color: #888;
  font-size: 1.2em;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  transition: color 0.2s;
}

#finding-close:hover {
  color: #fff;
}

/* Two vertical bars: Crisis (#dd4000) + Emigrating (#f27407) */
#finding-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 12px; /* 6px Crisis + 6px Emigrating */
  background: linear-gradient(to right, #dd4000 50%, #f27407 50%);
}

.finding-label {
  font-size: 0.8em;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #dd4000;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.finding-text {
  font-size: 1.16em;
  line-height: 1.65;
  color: #f0f0f0;
  margin: 0;
}

.finding-text strong {
  color: #ffffff;
}

.finding-crisis {
  color: #dd4000;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 600;
}

/* ========================================
   CITY CALLOUT - "Closer Look" box below key finding
   ======================================== */
.city-callout {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.city-callout-label {
  font-size: 0.9em;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #dd4000;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.city-callout-text {
  font-size: 1.16em;
  line-height: 1.65;
  color: #fff;
  margin: 0 0 8px 0;
}

.city-callout-text strong {
  color: #ffffff;
}

.city-callout-link {
  display: inline-block;
  font-size: 0.9em;
  font-weight: 600;
  color: #e0e0e0;
  text-decoration: none;
  padding: 6px 12px;
  border: 1px solid rgba(224, 224, 224, 0.4);
  border-radius: 3px;
  transition: all 0.2s ease;
}

.city-callout-link:hover {
  color: #fff;
  border-color: #e0e0e0;
  background: rgba(224, 224, 224, 0.1);
}

/* Hide finding card on mobile and tablet */
@media (max-width: 1024px) {
  #finding-card {
    display: none;
  }
}

/* ========================================
   COUNTY CLICK POPUP (dark mode)
   ======================================== */
.mapboxgl-popup {
  max-width: none !important;
  /* Keep popup within viewport edges */
  max-height: 85vh;
}

.mapboxgl-popup-content {
  background: #1f1f1f !important;
  padding: 0 !important;
  border-radius: 0px !important;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5) !important;
  overflow: hidden;
  /* Constrain to viewport */
  max-height: 80vh;
  max-width: calc(100vw - 340px); /* account for sidebar width + some margin */
}

.mapboxgl-popup-tip {
  border-top-color: #1f1f1f !important;
}

.mapboxgl-popup-close-button {
  color: #b0b0b0 !important;
  font-size: 28px !important;
  right: 8px !important;
  top: 6px !important;
  width: 32px !important;
  height: 32px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 10;
}

.mapboxgl-popup-close-button:hover {
  color: #e0e0e0 !important;
  background: rgba(255, 255, 255, 0.12) !important;
  border-radius: 0px;
}

/* ========================================
   COUNTY HOVER TOOLTIP (dark mode)
   ======================================== */
.county-hover-tooltip .mapboxgl-popup-content {
  background: rgba(42, 42, 42, 0.95) !important;
  padding: 6px 12px !important;
  border-radius: 4px !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
  pointer-events: none;
}

.county-hover-tooltip .mapboxgl-popup-tip {
  border-top-color: rgba(42, 42, 42, 0.95) !important;
}

/* ========================================
   GEOCODER COUNTY POPUP - anchored left of pin (appears to right)
   Popup tip points left toward the pin
   ======================================== */

/* ========================================
   GEOCODER CUSTOMIZATION
   ======================================== */
.mapboxgl-ctrl-geocoder {
  background-color: #fff !important;
  border: 2px solid #fff !important;
  border-radius: 0 !important;
}

/* Force black text on all geocoder text elements */
.mapboxgl-ctrl-geocoder input,
.mapboxgl-ctrl-geocoder--input {
  color: #000 !important;
  border-radius: 0 !important;
}

.mapboxgl-ctrl-geocoder input::placeholder,
.mapboxgl-ctrl-geocoder--input::placeholder {
  color: #000 !important;
  opacity: 0.55;
}

/* Black search icon */
.mapboxgl-ctrl-geocoder .mapboxgl-ctrl-geocoder--icon {
  fill: #000 !important;
}

/* ========================================
   GEOCODER IN SIDEBAR — override map-control positioning
   ======================================== */
#geocoder-container {
  margin-top: 8px;
}

#geocoder-container .mapboxgl-ctrl-geocoder {
  position: relative !important;
  width: 100% !important;
  max-width: 100% !important;
  top: auto !important;
  right: auto !important;
  left: auto !important;
}


/* ========================================
   SIDEBAR TOGGLE HANDLE (mobile/tablet only)
   ======================================== */
.sidebar-toggle {
  display: none; /* hidden on desktop */
}

/* ========================================
   MOBILE COUNTY BOTTOM SHEET
   ======================================== */
.mobile-county-sheet {
  display: none; /* only shown on mobile/tablet via JS */
}

/* ========================================
   TABLET (769px - 1024px)
   ======================================== */
@media screen and (min-width: 769px) and (max-width: 1024px) {
  #sidebar {
    width: 280px;
  }

  .sidebar-title {
    font-size: 1em;
  }
}

/* ========================================
   MOBILE + TABLET RESPONSIVE (≤ 1024px)
   ======================================== */
@media screen and (max-width: 1024px) {
  html {
    font-size: 14px;
  }

  body {
    flex-direction: column;
  }

  /* ---- SIDEBAR: collapsible bottom drawer ---- */
  #sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 55vh;
    padding: 0 20px 18px 20px;
    box-sizing: border-box;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.6);
    border-top: 2px solid #f7c320;
    z-index: 20;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #444 transparent;
  }

  /* Collapsed state: slide down, only toggle bar visible */
  #sidebar.collapsed {
    transform: translateY(calc(100% - 48px));
  }

  /* Expanded state */
  #sidebar.expanded {
    transform: translateY(0);
  }

  /* ---- Toggle handle ---- */
  .sidebar-toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 0 6px 0;
    cursor: pointer;
    position: sticky;
    top: 0;
    background: #000;
    z-index: 5;
    -webkit-tap-highlight-color: transparent;
  }

  .sidebar-toggle-arrow {
    font-size: 1em;
    color: #999;
    transition: color 0.2s, transform 0.3s ease;
    line-height: 1;
  }

  .sidebar-toggle:hover .sidebar-toggle-arrow,
  .sidebar-toggle:active .sidebar-toggle-arrow {
    color: #f7c320;
  }

  /* Arrow points up when collapsed (inviting user to pull up) */
  #sidebar.collapsed .sidebar-toggle-arrow {
    transform: rotate(0deg);
  }

  /* Arrow points down when expanded (inviting user to close) */
  #sidebar.expanded .sidebar-toggle-arrow {
    transform: rotate(180deg);
  }

  .sidebar-toggle-label {
    font-size: 0.78em;
    color: #999;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    transition: color 0.2s;
  }

  .sidebar-toggle:hover .sidebar-toggle-label {
    color: #f7c320;
  }

  /* Map takes full viewport */
  #map {
    width: 100%;
    height: 100vh;
  }

  /* Compact header */
  .sidebar-title {
    font-size: 1em;
    line-height: 1.2;
    margin-bottom: 8px;
  }

  .helper-text {
    font-size: 0.8em;
    margin: 2px 0 8px 0;
  }

  /* Step headers */
  h3 {
    font-size: 0.9em;
    margin: 12px 0 6px 0;
  }

  /* Risk buttons */
  .risk-buttons {
    gap: 4px;
    margin-bottom: 10px;
  }

  .risk-buttons button,
  .toggle-all {
    font-size: 0.86em;
    padding: 8px 6px;
  }

  /* Blue Acres section */
  #blue-acres-section {
    margin-top: 10px;
    padding-top: 10px;
  }

  .blue-acres-stats {
    font-size: 0.8em;
    padding: 6px 8px;
  }

  /* ---- Methodology banner: keep above collapsed sidebar ---- */
  .howto-banner {
    width: 24px;
    height: 24px;
    font-size: 0.75em;
    bottom: 60px;
    right: 8px;
  }

  /* Help modal */
  .howto-content {
    max-width: 90vw;
    max-height: 80vh;
    padding: 15px;
    font-size: 1em;
  }

  /* ---- County popup max-width for mobile (popup is hidden via JS branching,
         but this ensures any accidental popups don't break layout) ---- */
  .mapboxgl-popup-content {
    max-width: 90vw !important;
  }

  /* ---- MOBILE COUNTY BOTTOM SHEET ---- */
  .mobile-county-sheet {
    display: flex;
    flex-direction: column;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 70vh;
    background: #1f1f1f;
    z-index: 30;
    border-top: 3px solid #f7c320;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.7);
    transform: translateY(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .mobile-county-sheet.hidden {
    transform: translateY(100%);
    pointer-events: none;
  }

  .mobile-county-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px 6px 14px;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
  }

  .mobile-county-title {
    font-weight: 700;
    font-size: 1.1em;
    color: #e0e0e0;
  }

  .mobile-county-close {
    background: none;
    border: none;
    color: #888;
    font-size: 1.6em;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
  }

  .mobile-county-close:hover {
    color: #fff;
  }

  /* Tabs */
  .mobile-county-tabs {
    display: flex;
    flex-shrink: 0;
    border-bottom: 1px solid #333;
  }

  .mobile-tab {
    flex: 1;
    background: #1a1a1a;
    border: none;
    color: #888;
    font-size: 0.85em;
    font-weight: 600;
    padding: 10px 8px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    transition: color 0.2s, border-color 0.2s;
    border-bottom: 2px solid transparent;
  }

  .mobile-tab.active {
    color: #f7c320;
    border-bottom-color: #f7c320;
    background: #252525;
  }

  .mobile-tab:hover {
    color: #ccc;
  }

  /* Scrollable body */
  .mobile-county-body {
    overflow-y: auto;
    padding: 12px 14px;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: #555 transparent;
    -webkit-overflow-scrolling: touch;
  }
}
