@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Playfair+Display:wght@500;700&display=swap");

:root {
  --obsidian: #0a0a0a;
  --obsidian-2: #141414;
  --obsidian-3: #1f1f1f;
  --champagne: #d4af37;
  --champagne-soft: #b8962e;
  --ink: #ffffff;
  --ink-mute: rgba(255, 255, 255, 0.62);
  --ink-faint: rgba(255, 255, 255, 0.38);
  --hairline: rgba(255, 255, 255, 0.08);
  --avail-green: #6dd49e;
  --avail-amber: #e0a96d;
  --avail-red: #c46b6b;
  --safe-top: env(safe-area-inset-top, 0);
  --safe-bottom: env(safe-area-inset-bottom, 0);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--obsidian);
  color: var(--ink);
  font-family: "Inter", system-ui, sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

h1, h2, h3 {
  font-family: "Playfair Display", Georgia, serif;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
}

button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease;
}
button:active { transform: scale(0.97); }

/* ─── Glass utility ─────────────────────────────────────────────── */
.glass {
  background: rgba(20, 20, 20, 0.55);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--hairline);
}

/* ─── Top nav ──────────────────────────────────────────────────── */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  padding: calc(var(--safe-top) + 12px) 18px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.nav-brand {
  font-family: "Playfair Display", serif;
  font-size: 22px;
  letter-spacing: 0.02em;
}
.nav-brand .accent { color: var(--champagne); }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.toggle[aria-pressed="true"] {
  color: var(--obsidian);
  background: var(--champagne);
  border-color: var(--champagne);
}
.toggle .dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.6;
}

/* ─── Map ──────────────────────────────────────────────────────── */
#map {
  position: absolute;
  inset: 0;
  background: var(--obsidian);
}
.maplibregl-ctrl-attrib,
.maplibregl-ctrl-bottom-right { display: none !important; }

/* ─── Tier markers ─────────────────────────────────────────────── */
.marker {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.2s ease;
}
.marker:hover { transform: scale(1.08); }
.marker svg { width: 22px; height: 22px; }

.marker-platinum {
  background: radial-gradient(circle at 30% 30%, #f3d77a 0%, var(--champagne) 50%, var(--champagne-soft) 100%);
  color: var(--obsidian);
  box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.18), 0 6px 20px rgba(212, 175, 55, 0.35);
  animation: pulse-gold 2.4s ease-in-out infinite;
}
.marker-gold {
  background: rgba(212, 175, 55, 0.18);
  color: var(--champagne);
  border: 1.5px solid var(--champagne);
}
.marker-silver {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink-mute);
  border: 1.5px solid var(--ink-mute);
}

@keyframes pulse-gold {
  0%, 100% { box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.18), 0 6px 20px rgba(212, 175, 55, 0.35); }
  50%      { box-shadow: 0 0 0 12px rgba(212, 175, 55, 0.0),  0 6px 24px rgba(212, 175, 55, 0.55); }
}

/* User location dot */
.me-marker {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #5fa9ff;
  box-shadow: 0 0 0 4px rgba(95, 169, 255, 0.25), 0 0 16px rgba(95, 169, 255, 0.6);
  border: 2px solid #ffffff;
}

/* ─── Bottom search bar ────────────────────────────────────────── */
.search {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(var(--safe-bottom) + 22px);
  z-index: 25;
  border-radius: 999px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  color: var(--ink-mute);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.search:active { transform: scale(0.99); }
.search .ico {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--champagne);
  box-shadow: 0 0 8px var(--champagne);
}
.search .label { flex: 1; color: var(--ink); }
.search .meta { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); }

body.sheet-open .search {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}

/* ─── Zip / address search ─────────────────────────────────────── */
.zip-search {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(var(--safe-bottom) + 88px);
  z-index: 26;
  border-radius: 999px;
  padding: 10px 14px 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.45);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.zip-search .zip-icon {
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--ink-mute);
}
.zip-search input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  padding: 4px 0;
}
.zip-search input::placeholder { color: var(--ink-faint); }
.zip-search input::-webkit-search-cancel-button { display: none; }
.zip-clear {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 18px;
  line-height: 1;
  color: var(--ink-mute);
  background: rgba(255,255,255,0.06);
}
.zip-clear:hover { color: var(--ink); background: rgba(255,255,255,0.12); }

body.sheet-open .zip-search {
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
}

/* Geocode error shake */
.zip-search.shake { animation: shake 0.32s ease-in-out; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* Search-result pin */
.search-pin {
  width: 22px;
  height: 22px;
  border-radius: 50% 50% 50% 0;
  background: var(--champagne);
  border: 2px solid var(--obsidian);
  transform: rotate(-45deg);
  box-shadow: 0 0 0 4px rgba(212,175,55,0.22), 0 4px 12px rgba(0,0,0,0.5);
}

/* ─── Bottom sheet ─────────────────────────────────────────────── */
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  height: 38vh;
  max-height: 38vh;
  border-radius: 28px 28px 0 0;
  padding: 12px 16px calc(var(--safe-bottom) + 24px);
  transform: translateY(100%);
  transition: transform 0.42s cubic-bezier(0.22, 1, 0.36, 1),
              height 0.36s cubic-bezier(0.22, 1, 0.36, 1),
              max-height 0.36s cubic-bezier(0.22, 1, 0.36, 1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.sheet[data-open="true"] { transform: translateY(0); }
.sheet[data-expanded="full"] { height: 78vh; max-height: 78vh; }
.sheet[data-mode="detail"]   { height: 92vh; max-height: 92vh; }
.sheet-view {
  animation: sheetFade 0.28s ease-out both;
}
@keyframes sheetFade {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.sheet .grip {
  width: 40px;
  height: 5px;
  border-radius: 999px;
  background: var(--ink-faint);
  margin: 4px auto 14px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}
.sheet .grip:hover { background: var(--ink-mute); transform: scaleX(1.1); }

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.sheet-head-title { flex: 1; min-width: 0; cursor: pointer; }
.sheet-head h2 { margin-bottom: 2px; }

.refresh-btn {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--champagne);
}
.refresh-btn svg { width: 18px; height: 18px; }
.refresh-btn:hover { color: #f3d77a; }
.sheet h2 {
  font-size: 22px;
  margin-bottom: 4px;
}
.sheet .subhead {
  font-size: 13px;
  color: var(--ink-mute);
  letter-spacing: 0.02em;
}

/* ─── Tier filter chips ────────────────────────────────────────── */
.chip-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-mute);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--hairline);
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.chip:hover { color: var(--ink); background: rgba(255, 255, 255, 0.08); }
.chip[aria-selected="true"] {
  color: var(--obsidian);
  background: var(--champagne);
  border-color: var(--champagne);
  font-weight: 500;
}

/* ─── Search this area button ──────────────────────────────────── */
.search-area {
  position: fixed;
  left: 50%;
  top: calc(var(--safe-top) + 80px);
  transform: translateX(-50%) translateY(-12px);
  z-index: 35;
  padding: 10px 18px 10px 14px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--obsidian);
  background: var(--champagne);
  border: none;
  box-shadow: 0 8px 28px rgba(212, 175, 55, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.search-area svg { width: 16px; height: 16px; }
.search-area[data-show="true"] {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* ─── Cluster marker ───────────────────────────────────────────── */
.cluster-marker {
  display: grid;
  place-items: center;
  border-radius: 50%;
  cursor: pointer;
  font-family: "Playfair Display", serif;
  color: var(--obsidian);
  font-weight: 500;
  background: radial-gradient(circle at 30% 30%, #f3d77a 0%, var(--champagne) 60%, var(--champagne-soft) 100%);
  box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.2), 0 6px 20px rgba(212, 175, 55, 0.4);
  transition: transform 0.2s ease;
}
.cluster-marker:hover { transform: scale(1.06); }
.cluster-small  { width: 38px; height: 38px; font-size: 14px; }
.cluster-medium { width: 48px; height: 48px; font-size: 16px; }
.cluster-large  { width: 60px; height: 60px; font-size: 19px; }

/* ─── Result card (in sheet) ───────────────────────────────────── */
.result {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 12px;
  border-bottom: 1px solid var(--hairline);
  text-align: left;
  width: 100%;
}
.result:last-child { border-bottom: none; }
.result-tier {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
}
.result-tier svg { width: 18px; height: 18px; }
.result-tier.platinum { background: var(--champagne); color: var(--obsidian); }
.result-tier.gold     { background: rgba(212,175,55,0.18); color: var(--champagne); border: 1px solid var(--champagne); }
.result-tier.silver   { background: rgba(255,255,255,0.08); color: var(--ink-mute); border: 1px solid var(--ink-faint); }

.result-body { flex: 1; min-width: 0; }
.result-title { font-size: 15px; font-weight: 500; }
.result-meta { font-size: 12px; color: var(--ink-mute); margin-top: 2px; display: flex; align-items: center; gap: 6px; }
.result-meta .pulse {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  display: inline-block;
}
.pulse.green { background: var(--avail-green); box-shadow: 0 0 6px var(--avail-green); }
.pulse.amber { background: var(--avail-amber); box-shadow: 0 0 6px var(--avail-amber); }
.pulse.red   { background: var(--avail-red); }

.result-score {
  font-family: "Playfair Display", serif;
  font-size: 24px;
  color: var(--champagne);
  letter-spacing: -0.02em;
}

/* ─── Throne Card (detail view) ────────────────────────────────── */
.detail-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: -4px 0 14px;
}
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px 10px 10px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--hairline);
  letter-spacing: 0.02em;
}
.back-btn svg { width: 18px; height: 18px; }
.back-btn:hover { color: var(--champagne); background: rgba(255,255,255,0.10); }
.close-btn {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink-mute);
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--hairline);
}
.close-btn svg { width: 18px; height: 18px; }
.close-btn:hover { color: var(--ink); background: rgba(255,255,255,0.12); }

.detail-hero {
  position: relative;
  height: 220px;
  border-radius: 18px;
  overflow: hidden;
  background: var(--obsidian-2) center/cover no-repeat;
  margin-bottom: 18px;
}
.detail-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 50%, rgba(10,10,10,0.85) 100%);
}
.detail-hero .tier-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  padding: 7px 13px 7px 9px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  z-index: 2;
}
.tier-badge.platinum {
  background: linear-gradient(135deg, #f3d77a 0%, var(--champagne) 100%);
  color: var(--obsidian);
}
.tier-badge.gold {
  background: rgba(10, 10, 10, 0.65);
  color: var(--champagne);
  border: 1px solid rgba(212, 175, 55, 0.7);
}
.tier-badge.silver {
  background: rgba(10, 10, 10, 0.65);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.4);
}
.tier-badge svg { width: 14px; height: 14px; }

.detail-body h1 {
  font-size: 30px;
  line-height: 1.1;
  margin-bottom: 6px;
}
.detail-body .address {
  font-size: 13px;
  color: var(--ink-mute);
  margin-bottom: 20px;
}

.detail-score-row {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 16px;
  background: rgba(255,255,255,0.04);
  margin-bottom: 18px;
}
.detail-score {
  font-family: "Playfair Display", serif;
  font-size: 56px;
  line-height: 1;
  color: var(--champagne);
  letter-spacing: -0.03em;
}
.detail-score-pct { font-size: 22px; color: var(--ink-mute); padding-bottom: 6px; }
.detail-score-label {
  margin-left: auto;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute);
  text-align: right;
}
.detail-score-availability {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  color: var(--ink);
  letter-spacing: 0.04em;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}
.tag {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(212,175,55,0.10);
  color: var(--champagne);
  border: 1px solid rgba(212,175,55,0.30);
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}
.feature {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--hairline);
  font-size: 13px;
  color: var(--ink-mute);
}
.feature[data-on="true"] {
  background: rgba(212,175,55,0.06);
  border-color: rgba(212,175,55,0.28);
  color: var(--ink);
}
.feature .check {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  background: var(--obsidian-3);
  color: var(--ink-faint);
}
.feature[data-on="true"] .check {
  background: var(--champagne);
  color: var(--obsidian);
}

.cta {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  border-radius: 16px;
  background: linear-gradient(180deg, #efcf60 0%, var(--champagne) 100%);
  color: var(--obsidian);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(212,175,55,0.30);
}
.cta:active { transform: scale(0.98); }
.cta svg { width: 18px; height: 18px; }

/* ─── Skeleton shimmer ─────────────────────────────────────────── */
.skeleton {
  display: block;
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.10) 50%, rgba(255,255,255,0.04) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
.skeleton-row { height: 56px; margin: 8px 0; }
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── Toast ────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  top: calc(var(--safe-top) + 80px);
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 50;
}
.toast[data-show="true"] { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
