/* ============================================================
   Find Advocates — Map Search Page
   Mobile-first, uber-clean layout
   ============================================================ */

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

:root {
  --teal: #008080;
  --teal-light: #e6f2f2;
  --teal-dark: #006666;
  --gold: #f59e0b;
  --gold-light: #fffbeb;
  --text: #111827;
  --text-2: #4b5563;
  --text-3: #9ca3af;
  --border: #e5e7eb;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,.10), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.12), 0 4px 12px rgba(0,0,0,.08);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --topbar-h: 56px;
  --filter-h: 48px;
  --panel-peek: 140px; /* how much panel shows by default on mobile */
  --panel-w: 360px;    /* desktop sidebar width */
  --ease: cubic-bezier(.4,0,.2,1);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface-2);
  -webkit-font-smoothing: antialiased;
}

/* ── Topbar ──────────────────────────────────────────── */

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  flex-shrink: 0;
}

.topbar-logo-img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.topbar-logo-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  display: none;
}

@media (min-width: 640px) {
  .topbar-logo-text { display: block; }
}

.topbar-search-wrap {
  flex: 1;
  position: relative;
  max-width: 480px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 100px;
  padding: 0 14px;
  height: 38px;
  transition: border-color .2s, box-shadow .2s;
}

.search-box:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0,128,128,.12);
  background: var(--surface);
}

.search-icon {
  width: 15px;
  height: 15px;
  color: var(--text-3);
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  color: var(--text);
  outline: none;
  min-width: 0;
}

.search-input::placeholder { color: var(--text-3); }

.search-clear {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-3);
  padding: 2px;
  display: flex;
  align-items: center;
}

.search-clear > svg { width: 14px; height: 14px; }
.search-clear:hover { color: var(--text); }

.search-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 300;
  display: none;
}

.search-suggestions.open { display: block; }

.suggestion-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  transition: background .15s;
}

.suggestion-item:hover { background: var(--surface-2); }

.suggestion-icon {
  width: 14px;
  height: 14px;
  color: var(--text-3);
  flex-shrink: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-ghost {
  background: none;
  border: none;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  transition: background .15s;
}

.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost > svg { width: 18px; height: 18px; }

.btn-primary-sm {
  background: var(--teal);
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 100px;
  white-space: nowrap;
  transition: background .15s, transform .1s;
  display: none;
}

@media (min-width: 480px) {
  .btn-primary-sm { display: inline-flex; }
}

.btn-primary-sm:hover {
  background: var(--teal-dark);
  transform: translateY(-1px);
}

/* ── Filter bar ──────────────────────────────────────── */

.filter-bar {
  position: fixed;
  top: var(--topbar-h);
  left: 0; right: 0;
  z-index: 190;
  height: var(--filter-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

.filter-chips {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.filter-chips::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 100px;
  padding: 4px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}

.chip:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.chip.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

/* ── Layout ──────────────────────────────────────────── */

.layout {
  position: fixed;
  top: calc(var(--topbar-h) + var(--filter-h));
  left: 0; right: 0;
  bottom: 0;
  display: flex;
}

/* ── Map ─────────────────────────────────────────────── */

.map-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
}

/* Mapbox override */
.mapboxgl-canvas { outline: none; }
.mapboxgl-ctrl-logo { display: none !important; }
.mapboxgl-ctrl-attrib { font-size: 10px; }

.map-controls {
  position: absolute;
  right: 12px;
  bottom: calc(var(--panel-peek) + 16px);
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
}

.map-btn {
  width: 36px;
  height: 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  box-shadow: var(--shadow-sm);
  transition: background .15s, color .15s;
}

.map-btn:hover { background: var(--surface-2); color: var(--text); }
.map-btn > svg { width: 16px; height: 16px; }

.no-results {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 20;
}

.no-results > svg {
  width: 40px;
  height: 40px;
  color: var(--text-3);
}

.no-results p {
  font-size: 16px;
  color: var(--text-2);
  font-weight: 500;
}

.btn-ghost-sm {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 100px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: all .15s;
}

.btn-ghost-sm:hover {
  border-color: var(--teal);
  color: var(--teal);
}

/* ── Panel ───────────────────────────────────────────── */

.panel {
  position: absolute;
  left: 0; right: 0;
  bottom: 0;
  height: calc(100% - 0px);
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,.10);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transform: translateY(calc(100% - var(--panel-peek)));
  transition: transform .35s var(--ease);
  will-change: transform;
  overflow: hidden;
}

.panel.expanded {
  transform: translateY(0);
}

.panel.mid {
  transform: translateY(calc(100% - 55%));
}

.panel-handle {
  padding: 10px 0 4px;
  display: flex;
  justify-content: center;
  cursor: grab;
  flex-shrink: 0;
}

.panel-handle:active { cursor: grabbing; }

.handle-bar {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 100px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 16px 10px;
  flex-shrink: 0;
}

.panel-count {
  font-size: 13px;
  color: var(--text-2);
  font-weight: 500;
}

.sort-select {
  border: none;
  font-size: 13px;
  color: var(--teal);
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  outline: none;
}

.results-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 24px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

/* ── Desktop override ────────────────────────────────── */

@media (min-width: 768px) {
  .map-controls {
    bottom: 24px;
    right: 16px;
  }

  .panel {
    position: static;
    width: var(--panel-w);
    height: 100%;
    border-radius: 0;
    box-shadow: none;
    border-right: 1px solid var(--border);
    transform: none !important;
    flex-shrink: 0;
  }

  .panel-handle { display: none; }
}

/* ── Advocate Cards ──────────────────────────────────── */

.advocate-card {
  display: flex;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all .18s;
  margin-bottom: 8px;
  background: var(--surface);
}

.advocate-card:hover {
background-color: var(--surface-2);
}

.advocate-card.active {
  border-color: var(--teal);
  background: var(--teal-light);
}

.advocate-card.sponsored {
  background: var(--gold-light);
  border-color: var(--gold);
}

.advocate-card.sponsored.active {
  border-color: var(--teal);
  background: var(--teal-light);
}

.card-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--teal-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  color: var(--teal);
  position: relative;
}

.card-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sponsored-badge {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 16px;
  height: 16px;
  background: var(--gold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--surface);
}

.sponsored-badge > svg {
  width: 8px;
  height: 8px;
  color: #fff;
}

.card-body {
  flex: 1;
  min-width: 0;
}

.card-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
  min-width: 0;
}

.card-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.card-meta {
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-meta > svg { width: 11px; height: 11px; color: var(--text-3); }

.card-distance {
  font-size: 11px;
  color: var(--teal);
  font-weight: 600;
  margin-left: auto;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.card-tag {
  font-size: 11px;
  background: var(--surface-2);
  color: var(--text-2);
  padding: 2px 8px;
  border-radius: 100px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.card-tag.teal {
  background: var(--teal-light);
  color: var(--teal);
  border-color: transparent;
}

.card-pro-tag {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: black;
  color: white;
  padding: 1px 6px;
  border-radius: 4px !important;
  margin-left: 6px;
  vertical-align: middle;
  line-height: 1.5;
}

.advocate-card.sponsored .card-pro-tag {
  background: var(--gold-light);
  color: #92400e;
}

.card-rate {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  flex-shrink: 0;
  margin-left: auto;
}

/* ── Skeleton Loader ─────────────────────────────────── */

.skeleton-card {
  height: 82px;
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  margin-bottom: 8px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Map Markers ─────────────────────────────────────── */

.advocate-marker {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2.5px solid var(--surface);
  box-shadow: 0 2px 8px rgba(0,0,0,.20);
  cursor: pointer;
  background: var(--teal-light);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--teal);
  overflow: hidden;
}

.advocate-marker:hover {
  border-color: var(--teal);
}

.advocate-marker.active {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0,128,128,.25), 0 2px 8px rgba(0,0,0,.20);
}

.advocate-marker.sponsored {
  border-color: var(--gold);
  width: 42px;
  height: 42px;
  font-size: 15px;
}

.marker-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.marker-inner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── Detail Sheet ────────────────────────────────────── */

.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 400;
  opacity: 0;
  transition: opacity .3s;
}

.detail-overlay.visible { opacity: 1; }

.detail-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  z-index: 500;
  max-height: 72vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform .35s var(--ease);
  -webkit-overflow-scrolling: touch;
}

.detail-sheet.open {
  transform: translateY(0);
}

@media (min-width: 768px) {
  .detail-sheet {
    left: auto;
    right: 0;
    top: calc(var(--topbar-h) + var(--filter-h));
    bottom: 0;
    width: 420px;
    border-radius: var(--radius-lg) 0 0 0;
    max-height: none;
    height: auto;
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
  }
}

.detail-close {
  position: sticky;
  top: 16px;
  float: right;
  margin: 16px 16px 0 0;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--surface-2);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  z-index: 10;
  transition: background .15s;
}

.detail-close:hover { background: var(--border); }
.detail-close > svg { width: 16px; height: 16px; }

.detail-content {
  padding: 16px 20px 32px;
  clear: both;
}

.detail-hero {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 20px;
}

.detail-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--teal-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 700;
  color: var(--teal);
  flex-shrink: 0;
}

.detail-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-info { flex: 1; min-width: 0; }

.detail-name {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 2px;
  line-height: 1.2;
}

.detail-org {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 6px;
}

.detail-loc {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-2);
}

.detail-loc > svg { width: 13px; height: 13px; color: var(--teal); }

.detail-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
}

.badge-teal {
  background: var(--teal-light);
  color: var(--teal);
}

.badge-gold {
  background: var(--gold-light);
  color: #92400e;
}

.badge > svg { width: 11px; height: 11px; }

.detail-section {
  margin-bottom: 20px;
}

.detail-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-3);
  margin-bottom: 10px;
}

.detail-bio {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-2);
}

.detail-bio.clamped {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.detail-bio-toggle {
  background: none;
  border: none;
  color: var(--teal);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0 0;
  display: none;
}

.detail-bio-toggle:hover {
  text-decoration: underline;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.detail-tag {
  font-size: 12px;
  background: var(--surface-2);
  color: var(--text-2);
  padding: 4px 12px;
  border-radius: 100px;
  border: 1px solid var(--border);
}

.detail-rate-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.detail-rate {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
}

.detail-rate-label {
  font-size: 13px;
  color: var(--text-3);
}

.detail-services-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-service-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color .15s;
}

.detail-service-item:hover {
  border-color: var(--teal);
}

.detail-service-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--teal-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.detail-service-icon > svg {
  width: 18px;
  height: 18px;
  color: var(--teal);
}

.detail-service-text {
  flex: 1;
  min-width: 0;
}

.detail-service-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}

.detail-service-desc {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.4;
}

.detail-cta {
  margin-top: 24px;
}

.btn-teal {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: var(--teal);
  color: #fff;
  text-decoration: none;
  font-size: 15px;
  font-weight: 700;
  padding: 14px;
  border-radius: var(--radius-md);
  transition: background .15s, transform .1s;
  border: none;
  cursor: pointer;
}

.btn-teal:hover {
  background: var(--teal-dark);
  transform: translateY(-1px);
}

.btn-teal > svg { width: 18px; height: 18px; }

/* ── Beta Pill ───────────────────────────────────────── */

.beta-pill {
  position: fixed;
  top: calc(var(--topbar-h) + var(--filter-h) + 10px);
  left: 10px;
  background: var(--teal);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  padding: 3px 8px;
  border-radius: 100px;
  z-index: 150;
  pointer-events: none;
}

@media (min-width: 768px) {
  .beta-pill {
    left: calc(var(--panel-w) + 10px);
  }
}

/* ── Search radius ring ──────────────────────────────── */

.mapboxgl-popup {
  max-width: 200px;
}

.mapboxgl-popup-content {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  font-family: var(--font);
  color: var(--text);
}

.mapboxgl-popup-close-button {
  font-size: 16px;
  right: 8px;
  top: 6px;
  color: var(--text-3);
}

/* ── Utility ─────────────────────────────────────────── */

.hidden { display: none !important; }

/* Thin scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 100px;
}

/* Pulse animation for user location dot */
@keyframes pulse-ring {
  0% { transform: scale(1); opacity: .6; }
  100% { transform: scale(2.2); opacity: 0; }
}

.user-dot {
  width: 14px;
  height: 14px;
  background: var(--teal);
  border: 2.5px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,128,128,.4);
  position: relative;
}

.user-dot::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: rgba(0,128,128,.25);
  animation: pulse-ring 2s ease-out infinite;
}
