/* ============================================================
   MADM — Public Geo-Grid Rank Tracker & Heatmap Tool (/heatmap)
   ============================================================ */

.heatmap-hero {
  padding: calc(var(--nav-h) + 28px) 0 24px;
  background: var(--grad-hero);
  position: relative;
}

.heatmap-hero-head {
  max-width: 880px;
  margin: 0 auto 24px;
  text-align: center;
}

.heatmap-hero-head .eyebrow {
  justify-content: center;
  margin-bottom: 12px;
}
.heatmap-hero-head .eyebrow::before {
  display: none;
}

.heatmap-hero-head h1 {
  font-size: clamp(1.9rem, 1.1rem + 2.8vw, 3.1rem);
  margin-bottom: 12px;
}

.heatmap-hero-head .lede {
  margin: 0 auto;
  max-width: 66ch;
  font-size: 1.02rem;
}

/* ===== Control Bar ===== */
.hm-App {
  width: 100%;
  max-width: 1340px;
  margin: 0 auto;
  padding: 0 20px;
}

.hm-control-card {
  background: var(--surface-strong);
  border: 1px solid color-mix(in srgb, var(--gold) 32%, var(--glass-border));
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-lg);
  margin-bottom: 18px;
  position: relative;
  z-index: 40;
}

.hm-search-grid {
  display: grid;
  grid-template-columns: 1.35fr 1.15fr 0.55fr 0.55fr auto;
  gap: 12px;
  align-items: end;
}

.hm-field {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.hm-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gold);
}

.hm-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.hm-input-wrap svg.hm-input-icon {
  position: absolute;
  left: 13px;
  color: var(--gold);
  pointer-events: none;
}

.hm-input,
.hm-select {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.92rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.hm-input.with-icon {
  padding-left: 38px;
}

.hm-input:focus,
.hm-select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.hm-scan-btn {
  min-height: 46px;
  padding: 10px 24px;
  font-size: 0.94rem;
}

.hm-scan-btn[disabled] {
  opacity: 0.65;
  cursor: wait;
}

/* Autocomplete Dropdown */
.hm-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface-strong);
  border: 1px solid color-mix(in srgb, var(--gold) 45%, var(--glass-border));
  border-radius: var(--radius);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.55);
  max-height: 310px;
  overflow-y: auto;
  z-index: 300;
}

.hm-dropdown[hidden] {
  display: none !important;
}

.hm-drop-item {
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: background 0.15s;
}

.hm-drop-item:last-child {
  border-bottom: none;
}

.hm-drop-item:hover {
  background: var(--gold-soft);
}

.hm-drop-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hm-drop-rating {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--gold);
}

.hm-drop-addr {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Quick Keyword Chips & Selected Business Pill */
.hm-toolbar-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.hm-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.hm-chips-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  margin-right: 4px;
}

.hm-chip {
  font-family: var(--font-mono);
  font-size: 0.73rem;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--glass-border);
  background: var(--surface);
  color: var(--muted);
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.hm-chip:hover,
.hm-chip.active {
  border-color: var(--gold);
  color: var(--gold-bright);
  background: var(--gold-soft);
}

.hm-selected-biz {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ok);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Main Workspace: Map + Sidebar ===== */
.hm-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 18px;
  align-items: start;
  position: relative;
  z-index: 1;
}

.hm-map-panel {
  position: relative;
  isolation: isolate;
  z-index: 1;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--glass-border);
  background: #e5e3df;
  box-shadow: var(--shadow-lg);
  height: 640px;
}

#hmMap {
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Map Style Switcher */
.hm-map-styles {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 500;
  display: inline-flex;
  background: rgba(13, 21, 38, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.hm-style-btn {
  font-family: var(--font-display);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 7px;
  color: #cbd5e1;
  transition: background 0.15s, color 0.15s;
}

.hm-style-btn:hover {
  color: #ffffff;
}

.hm-style-btn.active {
  background: var(--gold);
  color: #14100a;
}

/* Dark tile filter when Dark mode selected */
.hm-tiles-dark {
  filter: invert(90%) hue-rotate(180deg) brightness(95%) contrast(90%);
}

/* Live Scan Progress Pill (Top-Center of Map, MADM OS style) */
.hm-progress-pill {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 550;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(13, 21, 38, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid color-mix(in srgb, var(--gold) 55%, rgba(255, 255, 255, 0.18));
  color: #f8fafc;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
}

.hm-progress-pill[hidden] {
  display: none !important;
}

.hm-mini-spinner {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(201, 160, 106, 0.28);
  border-top-color: var(--gold);
  animation: hm-spin 0.75s linear infinite;
  flex-shrink: 0;
}

/* Map Legend Overlay */
.hm-map-legend {
  position: absolute;
  bottom: 14px;
  left: 14px;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(13, 21, 38, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #f8fafc;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.hm-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hm-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: inline-block;
}
.hm-dot.r-top3 { background: #10b981; }
.hm-dot.r-top10 { background: #f59e0b; }
.hm-dot.r-top20 { background: #f97316; }
.hm-dot.r-out { background: #ef4444; }

@keyframes hm-spin {
  to { transform: rotate(360deg); }
}

@keyframes hm-pin-pulse {
  0%, 100% {
    transform: scale(0.92);
    box-shadow: 0 0 0 0 rgba(201, 160, 106, 0.55), 0 4px 12px rgba(0, 0, 0, 0.35);
  }
  50% {
    transform: scale(1.06);
    box-shadow: 0 0 0 8px rgba(201, 160, 106, 0), 0 4px 14px rgba(0, 0, 0, 0.45);
  }
}

@keyframes hm-pin-pop {
  0% { transform: scale(0.6); }
  65% { transform: scale(1.16); }
  100% { transform: scale(1); }
}

/* Centered Map Unlock Pop-Up Modal (Triggers after scan finishes) */
.hm-unlock-modal {
  position: absolute;
  inset: 0;
  z-index: 650;
  background: rgba(7, 10, 20, 0.52);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: hm-fade-in 0.25s ease-out;
}

.hm-unlock-modal[hidden] {
  display: none !important;
}

@keyframes hm-fade-in {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.hm-unlock-card {
  width: 100%;
  max-width: 430px;
  background: linear-gradient(155deg, rgba(20, 28, 48, 0.98), rgba(10, 15, 28, 0.98));
  border: 1.5px solid color-mix(in srgb, var(--gold) 65%, rgba(255, 255, 255, 0.2));
  border-radius: var(--radius-lg);
  padding: 26px 24px 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65), 0 0 32px rgba(201, 160, 106, 0.22);
  color: #f8fafc;
  text-align: center;
  position: relative;
}

.hm-unlock-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #94a3b8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.hm-unlock-close:hover {
  color: #ffffff;
  border-color: var(--gold);
}

.hm-unlock-card h3 {
  font-family: var(--font-display);
  font-size: 1.32rem;
  color: #ffffff;
  margin: 4px 0 8px;
}

.hm-unlock-card p {
  font-size: 0.88rem;
  color: #cbd5e1;
  margin-bottom: 16px;
  line-height: 1.5;
}

.hm-unlock-form {
  display: grid;
  gap: 10px;
  text-align: left;
}

.hm-unlock-form input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  background: rgba(7, 7, 17, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-sm);
  color: #ffffff;
  font-size: 0.9rem;
}

.hm-unlock-form input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

/* Rank Pin Markers on Map */
.hm-pin-icon {
  background: transparent;
  border: none;
}

.hm-pin {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.8rem;
  color: #ffffff;
  border: 2.2px solid #ffffff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.42);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
}

.hm-pin.size-9 {
  width: 30px;
  height: 30px;
  font-size: 0.72rem;
  border-width: 2px;
}

.hm-pin.size-13 {
  width: 24px;
  height: 24px;
  font-size: 0.64rem;
  border-width: 1.8px;
}

.hm-pin:hover {
  transform: scale(1.18);
}

.hm-pin.tier-scanning {
  background: linear-gradient(135deg, #1e293b, #334155);
  border-color: var(--gold);
  color: var(--gold);
  animation: hm-pin-pulse 1.25s ease-in-out infinite;
}

.hm-pin.pop-in {
  animation: hm-pin-pop 0.34s cubic-bezier(0.16, 1, 0.3, 1);
}

.hm-pin.tier-top3 {
  background: linear-gradient(135deg, #059669, #10b981);
}
.hm-pin.tier-top10 {
  background: linear-gradient(135deg, #d97706, #f59e0b);
}
.hm-pin.tier-top20 {
  background: linear-gradient(135deg, #ea580c, #f97316);
}
.hm-pin.tier-out {
  background: linear-gradient(135deg, #dc2626, #ef4444);
}

/* Blurred Rank Number Inside Pin (Before Lead Unlock) */
.hm-pin-num {
  display: inline-block;
  transition: filter 0.3s ease;
}

.hm-pin-num.blurred {
  filter: blur(4.2px);
  user-select: none;
}

/* ===== Sidebar: KPI Scorecards + Lead Gate + Competitor List ===== */
.hm-sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.hm-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.hm-kpi {
  background: var(--surface-strong);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-width: 0;
  overflow: hidden;
}

.hm-kpi-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hm-kpi-val {
  font-family: var(--font-mono);
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--gold);
  margin-top: 4px;
  line-height: 1.15;
  transition: filter 0.3s ease;
}

.hm-kpi-val.blurred {
  filter: blur(5px);
  user-select: none;
}

.hm-kpi-sub {
  font-size: 0.74rem;
  color: var(--faint);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Lead Gate Card */
.hm-gate-card {
  background: linear-gradient(155deg, rgba(201, 160, 106, 0.16), rgba(13, 21, 38, 0.96) 55%);
  border: 1px solid color-mix(in srgb, var(--gold) 50%, transparent);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--glow-gold);
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.hm-gate-card[hidden] {
  display: none !important;
}

.hm-gate-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #14100a;
  background: var(--grad-gold);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  margin-bottom: 10px;
}

.hm-gate-card h2 {
  font-size: 1.18rem;
  margin-bottom: 6px;
}

.hm-gate-card p {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 14px;
}

.hm-gate-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.hm-gate-form input {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  background: rgba(7, 7, 17, 0.75);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.88rem;
}

.hm-gate-form input:focus {
  outline: none;
  border-color: var(--gold);
}

.hm-gate-note {
  font-size: 0.76rem;
  color: var(--muted);
  text-align: center;
  min-height: 1.2em;
}
.hm-gate-note.ok { color: var(--ok); }
.hm-gate-note.err { color: var(--danger); }

/* Competitor Leaderboard Card */
.hm-comp-card {
  background: var(--surface-strong);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.hm-comp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  min-width: 0;
}

.hm-comp-head h2 {
  font-size: 1.05rem;
  min-width: 0;
}

.hm-comp-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.hm-comp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 0.85rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  box-sizing: border-box;
}

.hm-comp-row.locked {
  filter: blur(4px);
  user-select: none;
  pointer-events: none;
  opacity: 0.65;
}

.hm-comp-rank {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--gold-soft);
  color: var(--gold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.hm-comp-info {
  flex: 1 1 0%;
  min-width: 0;
  overflow: hidden;
}

.hm-comp-name {
  display: block;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hm-comp-meta {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hm-comp-avg {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--gold);
  text-align: right;
  flex-shrink: 0;
  white-space: nowrap;
}

@media (max-width: 1080px) {
  .hm-search-grid {
    grid-template-columns: 1fr 1fr;
  }
  .hm-scan-btn {
    grid-column: 1 / -1;
  }
  .hm-workspace {
    grid-template-columns: 1fr;
  }
  .hm-map-panel {
    height: 520px;
  }
}

@media (max-width: 600px) {
  .hm-search-grid {
    grid-template-columns: 1fr;
  }
  .hm-map-panel {
    height: 440px;
  }
}
