/* ============================================================
   Sidewalk Search — dark-glass design system
   ============================================================ */

:root {
  --coral: #FF6A4D;
  --coral-hi: #FF9C86;
  --coral-lo: #E64A2E;

  --bg: #0B0E13;
  --bg-2: #10141C;

  --panel: rgba(20, 24, 31, 0.72);
  --panel-solid: rgba(16, 20, 27, 0.94);
  --panel-border: rgba(255, 255, 255, 0.08);
  --panel-border-hi: rgba(255, 255, 255, 0.14);

  --text: #F2F4F8;
  --text-dim: #9AA3B2;
  --text-faint: #6B7280;

  --good: #4ADE80;
  --warn: #FBBF24;
  --bad: #FB7185;

  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.35);
  --inner-hi: inset 0 1px 0 rgba(255, 255, 255, 0.06);

  --radius: 20px;
  --radius-sm: 12px;

  --font: system-ui, -apple-system, "SF Pro Display", "SF Pro Text",
          "Segoe UI", Roboto, "Helvetica Neue", sans-serif;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  overscroll-behavior: none;
}

button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* ---------- glass primitive ---------- */
.glass {
  background: var(--panel);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow), var(--inner-hi);
}

/* ============================================================
   MAP
   ============================================================ */
#map {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--bg);
}

/* Vignette so glass chrome reads against bright tile clusters */
#map::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 400;
  background:
    radial-gradient(120% 90% at 50% 40%, transparent 55%, rgba(0,0,0,0.35) 100%);
}

.leaflet-container { background: var(--bg); font-family: var(--font); }
.leaflet-control-attribution {
  background: rgba(11, 14, 19, 0.6) !important;
  color: var(--text-faint) !important;
  backdrop-filter: blur(8px);
  border-radius: 8px 0 0 0;
  font-size: 10px !important;
  padding: 2px 8px !important;
}
.leaflet-control-attribution a { color: var(--text-dim) !important; }

/* ============================================================
   CENTER PIN  (screen-fixed, sits above the map)
   ============================================================ */
#center-pin {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 600;
  pointer-events: none;
  transform: translate(-50%, -100%);
  will-change: transform;
}
#center-pin .pin-body {
  width: 34px;
  height: 44px;
  animation: pin-bob 2.6s var(--ease) infinite;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.45));
}
#center-pin.moving .pin-body { animation-play-state: paused; }

/* ground shadow ellipse anchored at the exact center point */
#center-pin .pin-shadow {
  position: absolute;
  left: 50%;
  top: 0;
  width: 22px;
  height: 7px;
  transform: translate(-50%, -50%);
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.55), transparent 70%);
  filter: blur(1.5px);
  animation: shadow-pulse 2.6s var(--ease) infinite;
}

@keyframes pin-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-5px); }
}
@keyframes shadow-pulse {
  0%, 100% { opacity: 0.55; transform: translate(-50%, -50%) scale(1); }
  50%      { opacity: 0.30; transform: translate(-50%, -50%) scale(0.82); }
}

/* ============================================================
   ZOOM CONTROL (custom, glass)
   ============================================================ */
#zoom {
  position: fixed;
  right: 16px;
  bottom: 28px;
  z-index: 620;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#zoom button {
  width: 44px;
  height: 44px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 22px;
  font-weight: 500;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background 0.15s;
}
#zoom button:first-child { border-bottom: 1px solid var(--panel-border); }
#zoom button:hover { background: rgba(255, 255, 255, 0.06); }
#zoom button:active { background: rgba(255, 106, 77, 0.18); }

/* ============================================================
   SEARCH BAR
   ============================================================ */
#searchbar {
  position: fixed;
  z-index: 640;
  top: 16px;
  left: 16px;
  width: 400px;
  max-width: calc(100vw - 32px);
  padding: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.search-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: var(--coral);
}
#search-input {
  flex: 1 1 auto;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.01em;
  padding: 8px 4px;
}
#search-input::placeholder { color: var(--text-faint); }
#search-clear {
  width: 28px; height: 28px;
  flex: 0 0 auto;
  border: none; background: transparent;
  color: var(--text-faint);
  border-radius: 8px;
  display: none;
  place-items: center;
  font-size: 15px;
}
#search-clear.show { display: grid; }
#search-clear:hover { background: rgba(255,255,255,0.07); color: var(--text); }

/* search results dropdown */
#search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 2px;
  max-height: 340px;
  overflow-y: auto;
}
#search-results.show { display: flex; }
.search-opt {
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.35;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  transition: background 0.12s;
}
.search-opt:hover, .search-opt.active { background: rgba(255, 106, 77, 0.14); }
.search-opt .opt-pin { color: var(--coral); flex: 0 0 auto; margin-top: 1px; }
.search-opt .opt-text { color: var(--text-dim); }
.search-opt .opt-text b { color: var(--text); font-weight: 600; }
.search-empty {
  padding: 12px;
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
}

/* ============================================================
   RESULTS PANEL
   ============================================================ */
#panel {
  position: fixed;
  z-index: 630;
  top: 84px;
  right: 16px;
  width: 400px;
  max-height: calc(100vh - 100px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.35s var(--ease), opacity 0.35s var(--ease);
}

.sheet-handle { display: none; }

.panel-head {
  flex: 0 0 auto;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.panel-head .addr-wrap { flex: 1 1 auto; min-width: 0; }
.panel-eyebrow {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--coral);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.panel-eyebrow .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 3px rgba(255,106,77,0.22);
}
#panelAddress {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.2;
  color: var(--text);
  word-break: break-word;
}
.panel-collapse { display: none; }

.panel-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 4px 20px 22px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.16) transparent;
}
.panel-body::-webkit-scrollbar { width: 8px; }
.panel-body::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.14);
  border-radius: 8px;
}

/* section scaffolding */
.section { padding-top: 18px; }
.section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-label .spark {
  color: var(--coral);
  display: inline-flex;
}

/* ---------- badges row ---------- */
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 2px; }
.badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--panel-border-hi);
  color: var(--text-dim);
  background: rgba(255,255,255,0.03);
  display: inline-flex; align-items: center; gap: 5px;
}
.badge .bdot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.good  { color: var(--good); border-color: rgba(74,222,128,0.3); background: rgba(74,222,128,0.08); }
.badge.warn  { color: var(--warn); border-color: rgba(251,191,36,0.3); background: rgba(251,191,36,0.08); }
.badge.coral { color: var(--coral); border-color: rgba(255,106,77,0.32); background: rgba(255,106,77,0.10); }

/* ---------- primary facts grid ---------- */
.facts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--panel-border);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  overflow: hidden;
}
.fact {
  background: rgba(255,255,255,0.02);
  padding: 12px 12px 11px;
  min-height: 64px;
  display: flex; flex-direction: column; justify-content: center;
}
.fact .v {
  font-size: 17px; font-weight: 700; letter-spacing: -0.01em;
  color: var(--text); line-height: 1.15;
}
.fact .v small { font-size: 11px; font-weight: 600; color: var(--text-dim); margin-left: 1px; }
.fact .l {
  font-size: 11px; font-weight: 500; color: var(--text-dim);
  margin-top: 3px; letter-spacing: 0.01em;
}
.fact.empty .v { color: var(--text-faint); font-weight: 500; }

/* ---------- detail rows ---------- */
.detail-list { display: flex; flex-direction: column; }
.detail-row {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 14px;
}
.detail-row:last-child { border-bottom: none; }
.detail-row .k { color: var(--text-dim); font-weight: 500; flex: 0 0 auto; }
.detail-row .val { color: var(--text); font-weight: 600; text-align: right; }
.detail-row .val.pos { color: var(--good); }

/* ---------- AI overview ---------- */
.ai-block { margin-bottom: 16px; }
.ai-block:last-child { margin-bottom: 0; }
.ai-heading {
  font-size: 12px; font-weight: 600; color: var(--coral);
  letter-spacing: 0.02em; margin-bottom: 6px;
  display: flex; align-items: center; gap: 6px;
}
.ai-text {
  font-size: 15px; font-weight: 400; line-height: 1.55;
  color: var(--text); opacity: 0.94;
}
.ai-card {
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 15px 16px;
  background: linear-gradient(180deg, rgba(255,106,77,0.05), rgba(255,255,255,0.015));
}

/* ---------- link chips ---------- */
.chips { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chip {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  font-size: 13.5px; font-weight: 600;
  transition: transform 0.14s var(--ease), border-color 0.14s, background 0.14s;
}
.chip:hover {
  transform: translateY(-1px);
  border-color: rgba(255,106,77,0.4);
  background: rgba(255,106,77,0.07);
}
.chip .glyph {
  width: 26px; height: 26px; flex: 0 0 auto;
  border-radius: 8px; display: grid; place-items: center;
  font-size: 12px; font-weight: 800; letter-spacing: -0.02em;
  background: rgba(255,255,255,0.06);
  color: var(--text);
}
.chip .glyph svg { width: 15px; height: 15px; }
.chip.zillow  .glyph { background: rgba(0,106,255,0.16);  color: #4d94ff; }
.chip.realtor .glyph { background: rgba(214,54,41,0.18);  color: #ff6f60; }
.chip.redfin  .glyph { background: rgba(166,0,153,0.18);  color: #ff5ae0; }
.chip.google  .glyph { background: rgba(255,255,255,0.09); color: #e8eaed; }
.chip.county  .glyph { background: rgba(74,222,128,0.14); color: var(--good); }
.chip.street  .glyph { background: rgba(255,106,77,0.16); color: var(--coral); }
.chip .chevron { margin-left: auto; color: var(--text-faint); flex: 0 0 auto; }
.chip.disabled {
  opacity: 0.4; pointer-events: none;
}
.chip.disabled .chevron { opacity: 0; }
.chip.span-2 { grid-column: 1 / -1; }

/* ---------- states ---------- */
.state {
  padding: 40px 24px;
  text-align: center;
  color: var(--text-dim);
}
.state .state-icon {
  width: 46px; height: 46px; margin: 0 auto 14px;
  color: var(--coral); opacity: 0.9;
}
.state h3 {
  margin: 0 0 6px; font-size: 16px; font-weight: 600; color: var(--text);
  letter-spacing: -0.01em;
}
.state p { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--text-dim); }

.norecord {
  font-size: 13.5px; color: var(--text-faint);
  padding: 14px 0 4px; line-height: 1.5;
}
.inline-error {
  font-size: 13px; color: var(--warn);
  padding: 12px 14px; border-radius: 12px;
  background: rgba(251,191,36,0.08); border: 1px solid rgba(251,191,36,0.2);
}

/* ---------- shimmer ---------- */
.shimmer {
  position: relative; overflow: hidden;
  background: rgba(255,255,255,0.045);
  border-radius: 10px;
}
.shimmer::after {
  content: ""; position: absolute; inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg,
    rgba(255,255,255,0) 0%,
    rgba(255,255,255,0.09) 50%,
    rgba(255,255,255,0) 100%);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }

.sk { height: 14px; }
.sk-line { height: 13px; margin: 8px 0; }
.sk-fact { height: 64px; border-radius: 12px; }
.sk-chip { height: 44px; border-radius: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* fade-in for landed content */
.fade-in { animation: fade-in 0.35s var(--ease) both; }
@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   MOBILE — bottom sheet
   ============================================================ */
@media (max-width: 899px) {
  #searchbar {
    top: 12px; left: 12px; right: 12px; width: auto;
    max-width: none;
  }

  #zoom { bottom: calc(env(safe-area-inset-bottom, 0px) + 96px); right: 12px; }

  #panel {
    top: auto; right: 0; left: 0; bottom: 0;
    width: auto;
    max-width: none;
    max-height: 78vh;
    border-radius: var(--radius) var(--radius) 0 0;
    border-bottom: none;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transition: transform 0.4s var(--ease);
  }
  #panel.collapsed {
    transform: translateY(calc(100% - var(--peek, 96px)));
  }
  .sheet-handle {
    display: block;
    width: 40px; height: 5px; border-radius: 3px;
    background: rgba(255,255,255,0.22);
    margin: 9px auto 2px;
    flex: 0 0 auto;
  }
  .panel-head {
    padding: 6px 20px 14px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .panel-collapse {
    display: grid; place-items: center;
    width: 30px; height: 30px; flex: 0 0 auto;
    border: none; background: rgba(255,255,255,0.05);
    color: var(--text-dim); border-radius: 50%;
    transition: transform 0.35s var(--ease);
  }
  #panel.collapsed .panel-collapse { transform: rotate(180deg); }
  #panelAddress { font-size: 20px; }
  .chips { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 380px) {
  .facts-grid { grid-template-columns: repeat(2, 1fr); }
  .chips { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  #center-pin .pin-body, #center-pin .pin-shadow { animation: none; }
  .shimmer::after { animation: none; }
  * { transition-duration: 0.01ms !important; }
}

/* ============================================================
   LOGIN PAGE  (rendered by functions/login.js, styled here)
   ============================================================ */
.login-body {
  overflow: auto;
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(90% 60% at 20% 10%, rgba(255,106,77,0.16), transparent 60%),
    radial-gradient(80% 60% at 90% 90%, rgba(255,106,77,0.10), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 360px;
  padding: 36px 30px 30px;
  text-align: center;
}
.login-pin {
  width: 40px; height: 52px; margin: 0 auto 18px;
  background-image: url("/assets/img/favicon.svg");
  background-size: contain; background-repeat: no-repeat; background-position: center;
  filter: drop-shadow(0 8px 16px rgba(255,106,77,0.35));
  animation: pin-bob 2.6s var(--ease) infinite;
}
.login-card h1 {
  margin: 0 0 6px; font-size: 26px; font-weight: 700;
  letter-spacing: -0.02em; color: var(--text);
}
.login-sub {
  margin: 0 0 22px; font-size: 14px; color: var(--text-dim);
}
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-input {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--panel-border-hi);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 17px; font-weight: 600;
  letter-spacing: 0.14em; text-align: center;
  padding: 14px 16px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.login-input::placeholder { color: var(--text-faint); letter-spacing: normal; font-weight: 500; }
.login-input:focus {
  border-color: var(--coral);
  box-shadow: 0 0 0 3px rgba(255,106,77,0.22);
}
.btn-primary {
  width: 100%;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 16px; font-weight: 700; letter-spacing: -0.01em;
  color: #fff;
  background: linear-gradient(180deg, var(--coral-hi), var(--coral) 55%, var(--coral-lo));
  box-shadow: 0 8px 20px rgba(255,106,77,0.3), var(--inner-hi);
  transition: transform 0.14s var(--ease), box-shadow 0.14s, filter 0.14s;
}
.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.04); }
.btn-primary:active { transform: translateY(0); }
.login-error {
  margin: 0; font-size: 13.5px; font-weight: 600;
  color: var(--bad);
  padding: 10px 12px; border-radius: 10px;
  background: rgba(251,113,133,0.1); border: 1px solid rgba(251,113,133,0.25);
}
