/* =========================================================================
   CBWAI directory — stylesheet
   Tokens live in :root. Zone colors are the single source of truth; the
   map fills, panel dots, legend pills, and avatar tints all reference them.
   ========================================================================= */

:root {
  /* Surfaces & text */
  --bg:              #F7F8FB;
  --surface:         #FFFFFF;
  --surface-hover:   #F1F5F9;
  --border:          #E2E8F0;
  --border-light:    #EFF1F5;
  --text:            #0F172A;
  --text-secondary:  #475569;
  --text-muted:      #94A3B8;

  /* Brand accent (slate-royal blue — civic/institutional feel) */
  --accent:          #1E40AF;
  --accent-hover:    #1E3A8A;
  --accent-light:    #EEF2FF;
  --accent-soft:     #DBEAFE;

  /* Zone palette — unified HSL: s ~ 45%, l ~ 72% */
  --z-north1:        #E9A8A8;  /* rose */
  --z-north2:        #9CC596;  /* sage */
  --z-east1:         #84C3D4;  /* teal */
  --z-east2:         #EBB17A;  /* peach */
  --z-central:       #9EC1E0;  /* periwinkle */
  --z-west:          #BDA6D6;  /* lilac */
  --z-south1:        #8BC8B4;  /* mint */
  --z-south2:        #E8AFCC;  /* blush */
  --z-andaman:       #D8B892;  /* sand */

  /* Scale */
  --radius:          14px;
  --radius-sm:       10px;
  --radius-xs:       8px;
  --shadow:          0 1px 2px rgba(15,23,42,0.04), 0 4px 12px rgba(15,23,42,0.04);
  --shadow-lg:       0 2px 8px rgba(15,23,42,0.05), 0 12px 40px rgba(15,23,42,0.08);
  --shadow-hero:     0 1px 0 var(--border);
}

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

html, body { overflow-x: hidden; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}
img, svg { max-width: 100%; }

.tabular { font-variant-numeric: tabular-nums; }

/* =========================================================================
   Hero header — sticky, translucent
   ========================================================================= */
header.hero {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255,255,255,0.92);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.hero-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 14px 24px 12px;
}
.hero-wordmark {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
  line-height: 1.35;
}
.hero-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.hero-title-text { flex: 1; min-width: 0; }
.hero-logo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(15,23,42,0.1), 0 0 0 2px var(--surface), 0 0 0 3px var(--border);
  display: block;
}
.hero-logo-link {
  line-height: 0;
  border-radius: 50%;
  transition: transform 0.15s, box-shadow 0.15s;
}
.hero-logo-link:hover .hero-logo {
  box-shadow: 0 2px 6px rgba(15,23,42,0.14), 0 0 0 2px var(--surface), 0 0 0 3px var(--accent);
}
@media (max-width: 600px) {
  .hero-logo { width: 48px; height: 48px; }
}
.hero-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.15;
}
.hero-sub {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Search bar */
.search-bar {
  position: relative;
  margin: 12px 0 10px;
  max-width: 520px;
}
.search-bar input {
  width: 100%;
  font: inherit;
  font-size: 0.88rem;
  padding: 10px 38px 10px 38px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.search-bar input::placeholder { color: var(--text-muted); }
.search-bar input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--surface-hover);
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
}
.search-clear:hover { background: var(--border); color: var(--text); }
.search-bar.has-query .search-clear { display: flex; }

/* Zone legend pills */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}
.legend-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px 4px 8px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.legend-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* =========================================================================
   Main layout
   ========================================================================= */
.main {
  display: flex;
  gap: 24px;
  max-width: 1320px;
  margin: 20px auto;
  padding: 0 24px;
  align-items: stretch;
}
.map-col { flex: 1; min-width: 0; }
.panel-col {
  width: 500px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.panel-col > .panel-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.panel-col > .panel-card > #gbGrid {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.panel-col > .panel-card > #gbGrid::-webkit-scrollbar { width: 6px; }
.panel-col > .panel-card > #gbGrid::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* Search modal — command-palette style */
.search-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 499;
  animation: searchBackdropIn 0.15s ease;
}
.search-backdrop.visible { display: block; }
@keyframes searchBackdropIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.search-section {
  position: fixed;
  top: 90px;
  left: 50%;
  transform: translateX(-50%);
  width: min(780px, calc(100vw - 32px));
  max-height: calc(100vh - 120px);
  z-index: 500;
  display: none;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: searchModalIn 0.18s ease;
}
.search-section:not([hidden]) { display: flex; }
@keyframes searchModalIn {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.search-modal-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  position: relative;
  flex-shrink: 0;
}
.search-modal-input-row .search-icon {
  position: static;
  transform: none;
  color: var(--text-muted);
  flex-shrink: 0;
}
.search-modal-input-row input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 0.95rem;
  padding: 4px 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
}
.search-modal-input-row input::placeholder { color: var(--text-muted); }
.search-modal-input-row .panel-card-count { flex-shrink: 0; }
.search-section #searchResultsBody {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.search-section #searchResultsBody::-webkit-scrollbar { width: 6px; }
.search-section #searchResultsBody::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
.search-section .member-grid {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.search-modal-close {
  background: var(--surface-hover);
  border: 1px solid var(--border);
  width: 26px; height: 26px;
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.search-modal-close:hover {
  background: var(--border);
  color: var(--text);
}

/* Mobile: turn the search modal into a bottom sheet */
@media (max-width: 900px) {
  .search-section {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    max-height: 80vh;
    transform: none;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
    box-shadow: 0 -4px 40px rgba(0, 0, 0, 0.18);
    animation: searchSheetUp 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .search-section::before {
    content: "";
    display: block;
    width: 36px;
    height: 4px;
    background: #D4D4D4;
    border-radius: 2px;
    margin: 10px auto 2px;
  }
  .search-section .member-grid {
    grid-template-columns: 1fr;
  }
  .search-section #searchResultsBody {
    padding-bottom: env(safe-area-inset-bottom, 12px);
  }
  @keyframes searchSheetUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
}

.map-wrapper {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow);
  position: relative;
}
.map-wrapper svg { width: 100%; height: auto; display: block; }

/* =========================================================================
   Info panel (desktop overlay) — unchanged behavior, refreshed look
   ========================================================================= */
.info-panel {
  display: none;
  position: absolute;
  top: 16px;
  right: 16px;
  width: 440px;
  max-height: 80%;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  z-index: 10;
  animation: fadeSlideIn 0.2s ease;
}
.info-panel.visible { display: block; }
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.panel-header {
  padding: 14px 18px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel-header .zone-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px rgba(0,0,0,0.06);
}
.panel-body {
  max-height: 72vh;
  overflow-y: auto;
}
.panel-body::-webkit-scrollbar { width: 6px; }
.panel-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
.panel-hint {
  padding: 48px 24px;
  color: var(--text-muted);
  text-align: center;
  font-size: 0.85rem;
}
.panel-hint svg { display: block; margin: 0 auto 12px; opacity: 0.3; }

/* VP bar above member cards */
.vp-bar {
  background: var(--accent-light);
  padding: 10px 18px;
  font-size: 0.76rem;
  color: var(--accent);
  font-weight: 500;
  border-bottom: 1px solid var(--border-light);
  line-height: 1.45;
}

.no-data {
  padding: 40px 24px;
  text-align: center;
  color: var(--text-muted);
  line-height: 1.7;
  font-size: 0.85rem;
}
.no-data strong { color: var(--text-secondary); }

/* =========================================================================
   SVG map — zone fills use the palette tokens
   ========================================================================= */
svg#indiaMap path {
  stroke: #94A3B8;
  stroke-width: 0.4;
}
svg#indiaMap path:not([data-zone]) { fill: #E5E7EB; }
svg#indiaMap path[data-zone] {
  cursor: pointer;
  transition: opacity 0.25s, stroke-width 0.2s, filter 0.25s;
}
svg#indiaMap path[data-zone="north1"]  { fill: var(--z-north1); }
svg#indiaMap path[data-zone="north2"]  { fill: var(--z-north2); }
svg#indiaMap path[data-zone="east1"]   { fill: var(--z-east1); }
svg#indiaMap path[data-zone="east2"]   { fill: var(--z-east2); }
svg#indiaMap path[data-zone="central"] { fill: var(--z-central); }
svg#indiaMap path[data-zone="west"]    { fill: var(--z-west); }
svg#indiaMap path[data-zone="south1"]  { fill: var(--z-south1); }
svg#indiaMap path[data-zone="south2"]  { fill: var(--z-south2); }
svg#indiaMap path[data-zone="andaman"] { fill: var(--z-andaman); }

svg#indiaMap path[data-zone]:hover,
svg#indiaMap path.zone-active {
  filter: brightness(1.06) saturate(1.1);
  stroke-width: 1.5;
  stroke: var(--text);
}
svg#indiaMap.has-active path[data-zone]:not(.zone-active) {
  opacity: 0.22;
  filter: grayscale(0.6) brightness(1.1);
}

/* =========================================================================
   GB / search-results card
   ========================================================================= */
.panel-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-card + .panel-card { margin-top: 16px; }
.panel-card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.panel-card-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.panel-card-count {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  background: var(--surface-hover);
  padding: 2px 8px;
  border-radius: 999px;
}

/* =========================================================================
   Member cards
   ========================================================================= */
.member-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
}
.member-card {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  align-items: start;
}
.member-card:hover {
  border-color: var(--accent-soft);
  box-shadow: 0 1px 3px rgba(15,23,42,0.05);
}
.member-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.78rem;
  color: rgba(15,23,42,0.85);
  background: var(--accent-soft);
  flex-shrink: 0;
  letter-spacing: 0.01em;
}
.member-meta { min-width: 0; }
.member-name {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.member-role {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.member-contact-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.phone-link {
  font-size: 0.76rem;
  color: var(--accent);
  font-weight: 500;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.phone-link:hover { text-decoration: underline; }
.city-chip {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  color: var(--text-secondary);
  background: var(--surface-hover);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-light);
  white-space: nowrap;
}
.zone-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.66rem;
  color: var(--text-secondary);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-light);
  background: var(--surface);
  white-space: nowrap;
}
.zone-tag::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--zdot, var(--accent));
}
.zone-tag-gold {
  background: #FEF3C7;
  border-color: #FCD34D;
  color: #92400E;
  font-weight: 600;
}
.zone-tag-gold::before {
  background: #D97706;
}

/* Empty-state inside a grid */
.search-no-match {
  padding: 36px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.search-no-match strong { color: var(--text-secondary); display: block; margin-bottom: 4px; }

/* =========================================================================
   Footer
   ========================================================================= */
.site-footer {
  max-width: 1320px;
  margin: 24px auto 0;
  padding: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  color: var(--text-muted);
  font-size: 0.74rem;
}
.site-footer .footer-left strong {
  color: var(--text-secondary);
  font-weight: 600;
}
.site-footer .footer-right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.site-footer a {
  color: var(--accent);
  text-decoration: none;
}
.site-footer a:hover { text-decoration: underline; }

/* =========================================================================
   Mobile bottom sheet (zone info on tap)
   ========================================================================= */
.mobile-sheet {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -4px 40px rgba(0,0,0,0.15);
  max-height: 72vh;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}
.mobile-sheet.open { transform: translateY(0); }
.mobile-sheet .sheet-handle {
  width: 36px;
  height: 4px;
  background: #D4D4D4;
  border-radius: 2px;
  margin: 10px auto 4px;
}
.mobile-sheet .sheet-header {
  padding: 8px 20px 12px;
  font-weight: 600;
  color: var(--text);
  font-size: 0.88rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
}
.mobile-sheet .sheet-close {
  background: var(--surface-hover);
  border: 1px solid var(--border);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 1rem;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.mobile-sheet .sheet-body {
  overflow-y: auto;
  max-height: calc(72vh - 70px);
  padding-bottom: env(safe-area-inset-bottom, 20px);
}
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.25);
  backdrop-filter: blur(2px);
  z-index: 999;
  transition: opacity 0.3s;
}
.overlay.open { display: block; }

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 900px) {
  .main { flex-direction: column; gap: 16px; padding: 0 12px; margin: 16px auto; }
  .panel-col { width: 100%; min-width: 0; }
  .panel-col > .panel-card { flex: none; display: block; }
  .panel-col > .panel-card > #gbGrid,
  .panel-col > .panel-card > #searchResultsBody {
    flex: none;
    overflow-y: visible;
    min-height: auto;
  }
  .map-col { padding: 0; min-width: 0; }
  .map-wrapper { max-width: 100%; position: static; padding: 12px; }
  .mobile-sheet { display: block; }

  .hero-inner { padding: 12px 16px 10px; }
  .hero-title { font-size: 1.18rem; }
  .hero-sub { font-size: 0.76rem; }
  .hero-wordmark { margin-bottom: 6px; letter-spacing: 0.1em; }
  .search-bar { margin: 10px 0 8px; max-width: 100%; }
  .legend { gap: 4px; }
  .legend-pill { font-size: 0.65rem; padding: 3px 9px 3px 6px; }
}
@media (max-width: 600px) {
  .hero-inner { padding: 10px 14px 8px; }
  .hero-wordmark {
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    word-spacing: 0.02em;
  }
  .hero-title { font-size: 1.02rem; }
  .hero-sub { font-size: 0.72rem; }

  .search-bar { max-width: 100%; margin: 8px 0 6px; }
  .search-bar input { font-size: 0.84rem; padding: 9px 34px 9px 34px; }
  .search-icon { left: 10px; }

  .member-grid { grid-template-columns: 1fr; gap: 6px; padding: 10px; }
  .panel-card-title { font-size: 0.82rem; }
  .panel-card-header { padding: 12px 14px; }

  .site-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 20px 14px;
    margin-top: 16px;
  }
  .site-footer .footer-right { text-align: left; }
}
@media (max-width: 380px) {
  .hero-title { font-size: 0.95rem; }
  .hero-wordmark { font-size: 0.58rem; }
  .legend-pill { font-size: 0.6rem; padding: 3px 8px 3px 5px; }
}
@media (min-width: 901px) {
  .mobile-sheet, .overlay { display: none !important; }
}
