/* ══════════════════════════════════════════════════════════════════════
   DATA LAYERS — atlas overlays (atlas_layers.js + atlas_panel.js)

   Sidebar picker, bottom-left legend, map place labels, and the
   "Active layers" mirror inside .map-control-panel.

   Design tokens only (--bg-*, --text-*, --border-*, --accent-*, --radius-*,
   --shadow-*, all defined in root.css) so this follows the theme like the
   rest of the shell instead of hard-coding chrome.
   ══════════════════════════════════════════════════════════════════════ */

/* ---- "Data Layers" button in #results-count-wrapper ---- */
.atlas-layers-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .15s, color .15s, border-color .15s;
}
.atlas-layers-btn:hover { background: var(--accent-glow); color: var(--text-primary); }
.atlas-layers-btn.active {
  background: var(--accent-glow);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}
.atlas-layers-btn svg { width: 15px; height: 15px; flex: 0 0 auto; }
.atlas-btn-count {
  min-width: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--accent-primary);
  color: #fff;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
}
.atlas-btn-count[hidden] { display: none; }

/* ---- sidebar panel (swaps with #listing-view) ---- */
.atlas-layers-view {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 12px 18px;
  overflow-y: auto;
  color: var(--text-primary);
}
.atlas-layers-view.hidden,
#listing-view.hidden { display: none !important; }

.atlas-panel-title { font-size: 15px; font-weight: 700; }
.atlas-panel-sub,
.atlas-panel-foot {
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-tertiary);
}
.atlas-panel-foot { border-top: 1px solid var(--border-subtle); padding-top: 10px; }

.atlas-group {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.atlas-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--bg-tertiary, var(--bg-secondary));
  border-left: 3px solid var(--atlas-group-color, var(--accent-primary));
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .3px;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.atlas-group-icon svg {
  display: block;
  width: 15px;
  height: 15px;
  color: var(--atlas-group-color, var(--accent-primary));
}
.atlas-group-body { display: flex; flex-direction: column; }

.atlas-row { padding: 7px 10px; border-top: 1px solid var(--border-subtle); }
.atlas-group-body .atlas-row:first-child { border-top: none; }
.atlas-row-main {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 0;
  padding: 0;          /* root.css puts 5px 10px on every bare `label` */
  cursor: pointer;
}

/* root.css draws the site's own checkbox with `label span:before/:after` —
   a 20px accent-bordered box on EVERY span inside ANY label. These rows use
   real <input type=checkbox> plus three or four spans each, so that rule
   sprays phantom squares through the panel. Neutralize it for this subtree
   instead of restructuring the markup (the spans carry the layout). */
.atlas-row-main span:before,
.atlas-row-main span:after { content: none !important; }
.atlas-row-main span {
  position: static;
  padding-left: 0;
  line-height: inherit;
}
.atlas-row-toggle { flex: 0 0 auto; margin-top: 2px; accent-color: var(--accent-primary); cursor: pointer; }
.atlas-row-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.atlas-row-title { font-size: 13px; font-weight: 600; }
.atlas-row-note { font-size: 11px; line-height: 1.35; color: var(--text-tertiary); }

.atlas-row-disabled { opacity: .5; }
.atlas-row-disabled .atlas-row-main { cursor: not-allowed; }
.atlas-row-error .atlas-row-note { color: var(--error, #e5534b); }

/* Spinner while a layer file is in flight. */
.atlas-row-spinner { display: none; flex: 0 0 auto; width: 13px; height: 13px; margin-left: auto; }
.atlas-row-busy .atlas-row-spinner {
  display: block;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: atlas-spin .7s linear infinite;
}
@keyframes atlas-spin { to { transform: rotate(360deg); } }

/* Attribute dropdown + scenario pills (demographics, SVI, CMRA periods,
   heat-traverse time of day). */
.atlas-row-select {
  width: 100%;
  margin-top: 6px;
  padding: 4px 6px;
  background: var(--bg-input, var(--bg-secondary));
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.atlas-row-scenarios { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.atlas-scen-btn {
  padding: 3px 9px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  color: var(--text-tertiary);
  font-size: 11px;
  cursor: pointer;
}
.atlas-scen-btn.active {
  background: var(--accent-glow);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  font-weight: 600;
}

/* ---- legend widget, bottom-left of the map ---- */
.atlas-legend {
  max-width: 260px;
  max-height: 46vh;
  overflow-y: auto;
  padding: 9px 11px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  color: var(--text-primary);
  font-size: 11.5px;
  line-height: 1.35;
}
.atlas-legend.hidden { display: none; }
.atlas-legend-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.atlas-legend-clear {
  padding: 0;
  background: none;
  border: none;
  color: var(--accent-primary);
  font-size: 10.5px;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
}
.atlas-legend-clear:hover { text-decoration: underline; }

.atlas-legend-block { padding-top: 7px; border-top: 1px solid var(--border-subtle); }
.atlas-legend-block:first-of-type { padding-top: 0; border-top: none; }
.atlas-legend-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
  font-weight: 700;
}
.atlas-legend-off,
.mcp-atlas-off {
  padding: 0 2px;
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.atlas-legend-off:hover,
.mcp-atlas-off:hover { color: var(--error, #e5534b); }

.atlas-legend-rows { display: flex; flex-direction: column; gap: 3px; }
.atlas-legend-row { display: flex; align-items: center; gap: 7px; }
.atlas-legend-row i {
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, .25);
}
.atlas-legend-credit { margin-top: 5px; font-size: 10px; color: var(--text-tertiary); }

/* ---- "Active layers" mirror inside the map control panel ---- */
.map-control-section-atlas { display: flex; flex-direction: column; gap: 5px; }
.mcp-atlas-rows { display: flex; flex-direction: column; gap: 3px; }
.mcp-atlas-row { display: flex; align-items: center; gap: 7px; font-size: 11.5px; }
.mcp-atlas-dot { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 2px; }
.mcp-atlas-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; }
.map-control-panel.collapsed .map-control-section-atlas { display: none; }

/* ---- map place-name labels ---- */
.atlas-map-label {
  background: none !important;
  border: none !important;
  white-space: nowrap;
  pointer-events: none;
  font-weight: 700;
  /* A halo rather than a box, so labels stay legible over any basemap. */
  text-shadow:
     0    0   3px var(--bg-secondary),
     1px  1px 2px var(--bg-secondary),
    -1px -1px 2px var(--bg-secondary);
}
.atlas-map-label span { display: block; transform: translate(-50%, -50%); }
.atlas-map-label-county {
  font-size: 13px;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.atlas-map-label-city { font-size: 12px; color: var(--text-primary); }
.atlas-map-label-town { font-size: 10.5px; font-weight: 600; color: var(--text-tertiary); }

/* ---- feature popups ---- */
.atlas-popup .leaflet-popup-content { margin: 10px 12px; font-size: 12px; }
.atlas-popup-body table { width: 100%; border-collapse: collapse; }
.atlas-popup-body td { padding: 2px 0; vertical-align: top; }
.atlas-popup-body td:first-child {
  padding-right: 10px;
  white-space: nowrap;
  color: var(--text-tertiary);
}
.atlas-popup-credit {
  margin-top: 7px;
  padding-top: 5px;
  border-top: 1px solid var(--border-subtle);
  font-size: 10px;
  color: var(--text-tertiary);
}

/* County-tiled layer status ("Zoom in to load flood zones…"). */
.atlas-legend-note {
  margin-top: 5px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  background: var(--accent-glow);
  color: var(--text-secondary);
  font-size: 10.5px;
  line-height: 1.35;
}

/* ---- first-run nudge: one-time coach mark on the Data Layers button ---- */
.atlas-nudge {
  position: fixed;
  z-index: 100000;          /* above the map panes and the Leaflet controls */
  width: min(280px, calc(100vw - 16px));
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 11px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--accent-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  color: var(--text-primary);
  /* Starts hidden and slightly high; .visible drops it into place. */
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .22s ease, transform .22s ease;
  pointer-events: none;
}
.atlas-nudge.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }

/* Arrow pointing up at the button. Two stacked squares — the outer one is the
   border colour, the inner covers it in the panel colour a pixel lower. */
.atlas-nudge-arrow {
  position: absolute;
  top: -7px;
  width: 13px;
  height: 13px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--accent-primary);
  border-top: 1px solid var(--accent-primary);
  transform: rotate(45deg);
  border-radius: 2px 0 0 0;
}

.atlas-nudge-body { flex: 1 1 auto; cursor: pointer; min-width: 0; }
.atlas-nudge-title {
  margin-bottom: 2px;
  color: var(--accent-primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .3px;
  text-transform: uppercase;
}
.atlas-nudge-text { font-size: 12px; line-height: 1.4; color: var(--text-secondary); }
.atlas-nudge-close {
  flex: 0 0 auto;
  padding: 0 2px;
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.atlas-nudge-close:hover { color: var(--text-primary); }

/* Matching pulse on the button so the eye connects bubble to target. */
.atlas-layers-btn.atlas-btn-pulse {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  animation: atlas-btn-pulse 1.9s ease-out 3;
}
@keyframes atlas-btn-pulse {
  0%   { box-shadow: 0 0 0 0 var(--accent-glow); }
  70%  { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* Respect the OS setting: keep the nudge, drop the motion. */
@media (prefers-reduced-motion: reduce) {
  .atlas-nudge { transition: none; transform: none; }
  .atlas-nudge.visible { transform: none; }
  .atlas-layers-btn.atlas-btn-pulse { animation: none; }
}

/* Link from the panel footer out to /about-layers. */
.atlas-panel-about {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent-primary);
  text-decoration: none;
}
.atlas-panel-about:hover { text-decoration: underline; }
.atlas-panel-about svg { width: 12px; height: 12px; flex: 0 0 auto; }

/* ---- Pay-as-you-go CTA on the property paywall ---- */
.reapi-payg { margin-top: 14px; }
.reapi-payg-or {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  color: var(--text-tertiary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .6px;
}
.reapi-payg-or::before,
.reapi-payg-or::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--border-subtle);
}
.reapi-payg-btn {
  width: 100%;
  padding: 10px 16px;
  background: transparent;
  border: 1px solid var(--accent-primary);
  border-radius: var(--radius-sm);
  color: var(--accent-primary);
  font-size: .92rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color .15s, color .15s;
}
.reapi-payg-btn:hover:not(:disabled) { background: var(--accent-primary); color: #fff; }
.reapi-payg-btn:disabled { opacity: .6; cursor: default; }
.reapi-payg-note {
  margin-top: 7px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-tertiary);
  text-align: center;
}
.reapi-payg-err {
  margin-top: 7px;
  font-size: 11.5px;
  color: var(--error, #e5534b);
  text-align: center;
}

/* Inline $2 unlock inside the map-click pin popup (tighter than the paywall). */
.reapi-payg-btn--inline {
  margin-top: 8px;
  padding: 8px 12px;
  font-size: .82rem;
}
.reapi-mock-pin-iw .reapi-payg-note { margin-top: 5px; font-size: 10.5px; }

/* ── Map-click pin: promote the primary CTA to a real button ──────────
   It was rendering as a bare underlined link, which read as an
   afterthought next to the dashes above it. The subscription is the
   primary action, so it gets the solid treatment; the one-time unlock
   sits underneath as quieter underlined text. */
.reapi-mock-pin-iw__btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 9px 14px;
  box-sizing: border-box;
  background: var(--accent-primary);
  border: 1px solid var(--accent-primary);
  border-radius: var(--radius-sm, 6px);
  color: #fff !important;
  font-size: .85rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none !important;
  cursor: pointer;
}
.reapi-mock-pin-iw__btn:hover { filter: brightness(1.08); }

/* Secondary one-time-payment line, under whichever primary button is shown. */
.reapi-payg-alt {
  margin-top: 9px;
  font-size: 12px;
  line-height: 1.45;
  text-align: center;
  color: var(--text-tertiary);
}
.reapi-payg-link {
  color: var(--accent-primary);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}
.reapi-payg-link:hover { filter: brightness(1.15); }
.reapi-payg-link[aria-busy="true"] { opacity: .6; pointer-events: none; }
