/* Map + report card (Task C4). Loaded on every page; map rules are scoped to body.geo-map-page. */

/* ---------- Grade circle (map card + property page) ---------- */
.geo-grade {
  --pin: #8a96a3;
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--pin); color: #fff; font-weight: 800; font-size: 1.6rem; line-height: 1;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.28), 0 2px 6px rgba(16, 24, 40, 0.18);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.18);
}
.geo-grade[data-grade="C"] { color: #2b2100; text-shadow: none; }
.geo-grade-lg { width: 60px; height: 60px; font-size: 1.9rem; }
.geo-grade-none { background: #eef1f5; color: var(--muted); box-shadow: inset 0 0 0 2px var(--border); text-shadow: none; }

/* ---------- Property page report card ---------- */
.geo-rc {
  display: flex; align-items: center; gap: 14px; color: var(--text); text-decoration: none; margin-bottom: 8px;
}
a.geo-rc:active { background: #f3f5f8; }
.geo-rc-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.geo-rc-top { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.geo-rc-title { font-weight: 700; }
.geo-rc-life { font-weight: 700; font-size: 0.95rem; }
.geo-rc-sub { color: var(--muted); font-size: 0.875rem; }
.geo-rc-counts { display: flex; flex-wrap: wrap; gap: 6px; }
.geo-rc-go { color: var(--muted); font-size: 1.5rem; }
.geo-rc-map {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-weight: 600; text-decoration: none;
}
.geo-rc-map svg, .geo-pill svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.geo-rc-pin {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border: 1px dashed var(--border); border-radius: var(--radius); background: var(--surface);
}
.geo-rc-pin-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.geo-rc-pin .btn { flex: none; }
.geo-rc-pin.is-done { border-style: solid; border-color: #b9e0c9; background: #effaf3; }

/* ---------- Map page layout: full height between the top bar and the tab bar ---------- */
body.geo-map-page {
  height: 100vh; height: 100dvh; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column; overscroll-behavior: none;
}
body.geo-map-page .page {
  position: relative; flex: 1 1 auto; min-height: 0; width: 100%; max-width: none; margin: 0; padding: 0;
}
body.geo-map-page .messages { position: absolute; z-index: 1200; top: 60px; left: 12px; right: 12px; }
.geo-shell { position: absolute; inset: 0; overflow: hidden; isolation: isolate; }
body.geo-map-page .toast { bottom: auto; top: calc(120px + env(safe-area-inset-top)); }
.geo-map { position: absolute; inset: 0; background: #e8ecef; }
.geo-map.leaflet-container { font-family: var(--font); -webkit-tap-highlight-color: transparent; }
.geo-map .leaflet-top { top: 56px; }
.geo-map .leaflet-control-attribution { font-size: 10px; background: rgba(255, 255, 255, 0.75); border-top-left-radius: 6px; }
.geo-map .leaflet-control-zoom { border: 0; box-shadow: 0 2px 8px rgba(16, 24, 40, 0.2); border-radius: 10px; overflow: hidden; }
.geo-map .leaflet-control-zoom a { width: 36px; height: 36px; line-height: 36px; }

/* ---------- Filter chips ---------- */
.geo-filters {
  position: absolute; z-index: 1000; top: 0; left: 0; right: 0;
  display: flex; gap: 8px; padding: 10px 12px; overflow-x: auto; scrollbar-width: none;
  -webkit-overflow-scrolling: touch; pointer-events: none;
}
.geo-filters::-webkit-scrollbar { display: none; }
.geo-chip {
  pointer-events: auto; flex: none; display: inline-flex; align-items: center; gap: 6px;
  min-height: 38px; padding: 6px 12px; border: 0; border-radius: 999px;
  background: rgba(255, 255, 255, 0.96); color: var(--text); font: inherit; font-size: 0.86rem; font-weight: 600;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.12), 0 3px 10px rgba(16, 24, 40, 0.14); cursor: pointer;
  -webkit-tap-highlight-color: transparent; transition: background 0.15s, color 0.15s;
}
.geo-chip.is-on { background: var(--brand); color: var(--brand-contrast); }
.geo-chip:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.geo-chip-n { font-size: 0.76rem; font-weight: 700; opacity: 0.7; min-width: 1ch; }
.geo-chip-n:empty { display: none; }

/* ---------- Floating buttons ---------- */
.geo-fabs {
  position: absolute; z-index: 1000; left: 12px; right: 12px; bottom: 26px;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; pointer-events: none;
  transition: opacity 0.2s, transform 0.25s;
}
.geo-fabs > * { pointer-events: auto; }
.geo-fabs.is-hidden { opacity: 0; transform: translateY(12px); }
.geo-fabs.is-hidden > * { pointer-events: none; }
.geo-fab {
  margin-left: auto; width: 48px; height: 48px; border-radius: 50%; border: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: #fff; color: var(--brand); box-shadow: 0 2px 10px rgba(16, 24, 40, 0.25);
  -webkit-tap-highlight-color: transparent;
}
.geo-fab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.geo-fab.is-busy svg { animation: geo-spin 1s linear infinite; }
.geo-fab.is-on { background: var(--brand); color: #fff; }
.geo-pill {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 14px;
  border: 0; border-radius: 999px; background: #fff; color: var(--text); font: inherit; font-size: 0.9rem; font-weight: 600;
  box-shadow: 0 2px 10px rgba(16, 24, 40, 0.22); cursor: pointer;
}
.geo-pill svg { color: var(--warn); }

/* ---------- Loading + empty ---------- */
.geo-loading {
  position: absolute; z-index: 1000; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 999px;
  background: rgba(27, 36, 48, 0.88); color: #fff; font-weight: 600; font-size: 0.9rem;
}
.geo-loading.is-done { opacity: 0; pointer-events: none; transition: opacity 0.25s; }
.geo-spinner {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.35); border-top-color: #fff;
  animation: geo-spin 0.8s linear infinite;
}
@keyframes geo-spin { to { transform: rotate(360deg); } }
.geo-empty { position: absolute; z-index: 1000; left: 16px; right: 16px; top: 72px; display: flex; justify-content: center; pointer-events: none; }
.geo-empty-card {
  pointer-events: auto; max-width: 360px; padding: 16px; border-radius: var(--radius); background: #fff; text-align: center;
  box-shadow: 0 4px 18px rgba(16, 24, 40, 0.18);
}
.geo-empty-card p { margin: 6px 0 12px; }

/* ---------- Pins (Leaflet divIcons) ---------- */
.geo-marker { background: none; border: 0; }
.geo-pin-wrap {
  position: relative; width: 36px; height: 46px; transform-origin: 18px 45px;
  transition: transform 0.18s cubic-bezier(0.3, 1.5, 0.6, 1);
}
.geo-marker.is-active .geo-pin-wrap { transform: scale(1.25); }
.geo-pin-shadow {
  position: absolute; left: 9px; top: 40px; width: 18px; height: 8px; border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.35) 0%, rgba(0, 0, 0, 0) 70%);
}
.geo-map .geo-marker svg { z-index: auto; } /* Leaflet lifts every svg in the map pane to z-index 200 */
.geo-map .geo-marker .geo-pin-svg { position: absolute; inset: 0; z-index: 0; width: 36px; height: 46px; overflow: visible; }
.geo-pin-svg path { fill: var(--pin); stroke: #fff; stroke-width: 2.5; }
.geo-pin-label {
  position: absolute; z-index: 1; left: 0; top: 4px; width: 36px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font: 800 16px/1 var(--font); text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}
.geo-pin-label[data-grade="C"] { color: #2b2100; text-shadow: none; }
.geo-pin-label svg { width: 17px; height: 17px; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.geo-pin-dot { width: 9px; height: 9px; border-radius: 50%; background: #fff; }
.geo-pin-badge {
  position: absolute; z-index: 2; right: -5px; top: -4px; width: 19px; height: 19px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand); border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.geo-pin-badge svg { width: 10px; height: 10px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; }

/* "You are here" */
.geo-me { background: none; border: 0; }
.geo-me-dot {
  position: relative; width: 18px; height: 18px; border-radius: 50%; background: #2f7cf6; border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}
.geo-me-dot::after {
  content: ""; position: absolute; inset: -9px; border-radius: 50%; background: rgba(47, 124, 246, 0.35);
  animation: geo-pulse 2s ease-out infinite;
}
@keyframes geo-pulse { from { transform: scale(0.4); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }
.geo-me-acc { fill: #2f7cf6; fill-opacity: 0.12; stroke: #2f7cf6; stroke-opacity: 0.4; stroke-width: 1; }

/* ---------- Bottom sheets ---------- */
.geo-sheet {
  position: absolute; z-index: 1100; left: 0; right: 0; bottom: 0;
  max-height: calc(100% - 64px); overflow-y: auto; overscroll-behavior: contain;
  padding: 6px 16px 16px; background: var(--surface);
  border-radius: 20px 20px 0 0; box-shadow: 0 -6px 28px rgba(16, 24, 40, 0.2);
  transform: translateY(calc(100% + 24px)); visibility: hidden;
  transition: transform 0.32s cubic-bezier(0.22, 0.9, 0.3, 1), visibility 0s linear 0.32s;
  will-change: transform; outline: none;
}
.geo-sheet.is-open { transform: translateY(0); visibility: visible; transition: transform 0.32s cubic-bezier(0.22, 0.9, 0.3, 1), visibility 0s; }
.geo-sheet.is-dragging { transition: none; }
.geo-sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: #cfd6de; margin: 4px auto 10px; }
.geo-sheet-close {
  position: absolute; top: 8px; right: 8px; width: 40px; height: 40px; border: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; background: transparent; color: var(--muted); cursor: pointer;
}
.geo-sheet-close svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.geo-sheet-close:active { background: #eef1f5; }

.geo-card-head { display: flex; align-items: center; gap: 14px; padding-right: 36px; }
.geo-card-title { min-width: 0; }
.geo-card-addr { font-weight: 700; font-size: 1.1rem; line-height: 1.25; }
.geo-card-place { color: var(--muted); font-size: 0.9rem; }
.geo-card-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 4px; }
.geo-card-chips:empty { display: none; }
.geo-card-chips .chip { font-size: 0.82rem; padding: 3px 10px; }
.geo-card-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin: 12px 0 14px; }
.geo-card-facts > div { min-width: 0; }
.geo-card-facts dt { color: var(--muted); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.geo-card-facts dd { margin: 2px 0 0; font-weight: 600; font-size: 0.95rem; }
.geo-card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.geo-card-actions .btn { width: 100%; }
.geo-card-actions .btn.hidden + .btn { grid-column: span 2; }

.geo-unpinned-title { font-size: 1.1rem; margin: 0 0 4px; padding-right: 40px; }
.geo-unpinned-help { margin-bottom: 8px; }
.geo-unpinned-list { list-style: none; margin: 0; padding: 0; }
.geo-unpinned-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0;
  border-top: 1px solid var(--border);
}
.geo-unpinned-main { display: flex; flex-direction: column; min-width: 0; color: var(--text); text-decoration: none; }
.geo-unpinned-addr { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.geo-unpinned-place { color: var(--muted); font-size: 0.85rem; }
.geo-unpinned-row .btn { flex: none; }
.geo-unpinned-row.is-gone { opacity: 0; transform: translateX(24px); transition: opacity 0.25s, transform 0.25s; }

@media (min-width: 700px) {
  .geo-sheet { left: 16px; right: auto; bottom: 16px; width: 380px; border-radius: 16px; max-height: calc(100% - 88px); }
  .geo-filters { padding: 14px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .geo-sheet, .geo-pin-wrap, .geo-fabs, .geo-unpinned-row.is-gone { transition: none !important; }
  .geo-me-dot::after, .geo-fab.is-busy svg { animation: none; }
}
