/* =============================================================================
   Wayfinder — dark-glass panel UI, drive-time color ramp, route overlay
   Designed to sit on top of the Island Falls GIS viewer without disturbing it.
   All selectors are scoped to .wf-* or #wf-* to avoid collisions.
   ============================================================================= */

/* ── Design tokens (self-contained, mirrors the viewer's dark palette) ──────── */
:root {
  --wf-bg:            rgba(13, 20, 33, 0.96);
  --wf-bg-2:          rgba(22, 32, 45, 0.98);
  --wf-bg-3:          rgba(15, 23, 38, 0.92);
  --wf-border:        rgba(255, 255, 255, 0.10);
  --wf-border-hi:     rgba(56, 189, 248, 0.35);
  --wf-brand:         #38bdf8;        /* sky-400 — matches viewer --color-primary */
  --wf-brand-dim:     rgba(56, 189, 248, 0.15);
  --wf-brand-glow:    rgba(56, 189, 248, 0.08);
  --wf-text:          #f1f5f9;
  --wf-text-2:        #94a3b8;
  --wf-text-3:        #475569;
  --wf-good:          #34d399;
  --wf-warn:          #fbbf24;
  --wf-bad:           #f87171;
  --wf-radius:        12px;
  --wf-radius-sm:     8px;
  --wf-panel-w:       340px;
  --wf-panel-top:     52px;          /* below the 48px toolbar */
  --wf-z:             600;           /* above most viewer layers, below toast */
  --wf-trans:         0.22s cubic-bezier(0.4, 0, 0.2, 1);
  --wf-shadow:        0 8px 32px rgba(0,0,0,0.55), 0 2px 8px rgba(0,0,0,0.35);
  --wf-blur:          12px;

  /* Drive-time color ramp stops (0 → 30+ minutes) */
  --wf-ramp-0:   #34d399;   /* 0 min  — emerald */
  --wf-ramp-5:   #6ee7b7;   /* 5 min  — light emerald */
  --wf-ramp-10:  #fde68a;   /* 10 min — amber */
  --wf-ramp-15:  #fbbf24;   /* 15 min — yellow */
  --wf-ramp-20:  #f97316;   /* 20 min — orange */
  --wf-ramp-30:  #ef4444;   /* 30 min — red */

  /* Animated route line palette (amber/gold — distinct from the blue parcel-selection overlay).
     The route animation is JS-driven via OL postrender; these tokens are here for reference
     and for any future CSS-side route UI (e.g. the route card accent colour). */
  --wf-route-glow:   rgba(245, 158, 11, 0.28);  /* wide amber halo, opacity is animated */
  --wf-route-core:   #f59e0b;                    /* amber-400 solid core */
  --wf-route-dash:   #fffbeb;                    /* near-white flowing dashes */
  --wf-route-dot:    #fbbf24;                    /* amber-300 destination dot */
}

/* ── Toolbar button ────────────────────────────────────────────────────────── */
#btn-wayfinder {
  /* inherits .btn-toggle from viewer styles — no override needed */
}
#btn-wayfinder.active {
  color: var(--wf-brand);
}

/* ── Panel container ────────────────────────────────────────────────────────── */
#wf-panel {
  position: fixed;
  top:      var(--wf-panel-top);
  right:    0;
  width:    var(--wf-panel-w);
  max-width: calc(100vw - 8px);
  max-height: calc(100vh - var(--wf-panel-top) - 8px);
  background: var(--wf-bg);
  backdrop-filter: blur(var(--wf-blur));
  -webkit-backdrop-filter: blur(var(--wf-blur));
  border: 1px solid var(--wf-border);
  border-right: none;
  border-top: none;
  border-radius: var(--wf-radius) 0 0 var(--wf-radius);
  box-shadow: var(--wf-shadow);
  z-index: var(--wf-z);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* Entry animation */
  transform: translateX(100%);
  opacity: 0;
  transition:
    transform var(--wf-trans),
    opacity var(--wf-trans);
  pointer-events: none;
}

#wf-panel.wf-open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

/* ── Panel header ───────────────────────────────────────────────────────────── */
.wf-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--wf-border);
  flex-shrink: 0;
}

.wf-header-icon {
  color: var(--wf-brand);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.wf-header-title {
  flex: 1;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--wf-text);
}

.wf-header-town {
  font-size: 11px;
  font-weight: 500;
  color: var(--wf-brand);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.85;
}

.wf-close-btn {
  background: none;
  border: none;
  color: var(--wf-text-2);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color var(--wf-trans), background var(--wf-trans);
  flex-shrink: 0;
}
.wf-close-btn:hover {
  color: var(--wf-text);
  background: rgba(255,255,255,0.08);
}

/* ── Scrollable body ────────────────────────────────────────────────────────── */
.wf-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--wf-text-3) transparent;
}
.wf-body::-webkit-scrollbar { width: 4px; }
.wf-body::-webkit-scrollbar-thumb { background: var(--wf-text-3); border-radius: 2px; }

/* ── Section ────────────────────────────────────────────────────────────────── */
.wf-section {
  padding: 10px 16px;
  border-bottom: 1px solid var(--wf-border);
}
.wf-section:last-child {
  border-bottom: none;
}

.wf-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--wf-text-3);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.wf-section-label svg {
  color: var(--wf-brand);
  opacity: 0.7;
}

/* ── Town center row ─────────────────────────────────────────────────────────── */
.wf-center-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--wf-bg-3);
  border: 1px solid var(--wf-border);
  border-radius: var(--wf-radius-sm);
  padding: 8px 10px;
  min-height: 44px;
}

.wf-center-coords {
  flex: 1;
  font-size: 11px;
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  color: var(--wf-brand);
  line-height: 1.4;
}
.wf-center-coords .wf-center-label {
  font-family: inherit;
  font-size: 10px;
  color: var(--wf-text-2);
  margin-bottom: 1px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.wf-center-unset {
  color: var(--wf-text-3);
  font-style: italic;
  font-size: 12px;
}

.wf-set-btn {
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  background: var(--wf-brand-dim);
  color: var(--wf-brand);
  border: 1px solid var(--wf-border-hi);
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--wf-trans), color var(--wf-trans);
  flex-shrink: 0;
}
.wf-set-btn:hover {
  background: var(--wf-brand);
  color: #0d1421;
}
.wf-set-btn.wf-set-active {
  background: var(--wf-warn);
  color: #0d1421;
  border-color: var(--wf-warn);
  animation: wf-pulse 1.2s ease-in-out infinite;
}

@keyframes wf-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.7; }
}

.wf-click-hint {
  font-size: 11px;
  color: var(--wf-warn);
  margin-top: 6px;
  padding: 6px 8px;
  background: rgba(251, 191, 36, 0.08);
  border-radius: 6px;
  border-left: 2px solid var(--wf-warn);
  display: none;
}
.wf-click-hint.wf-visible {
  display: block;
}

/* ── Primary action button ───────────────────────────────────────────────────── */
.wf-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  padding: 9px 16px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: none;
  border-radius: var(--wf-radius-sm);
  cursor: pointer;
  transition: background var(--wf-trans), transform 0.1s ease, opacity var(--wf-trans);
  position: relative;
  overflow: hidden;
}
.wf-action-btn:active { transform: scale(0.98); }
.wf-action-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.wf-action-btn-primary {
  background: linear-gradient(135deg, var(--wf-brand) 0%, #0ea5e9 100%);
  color: #0d1421;
}
.wf-action-btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #7dd3fc 0%, var(--wf-brand) 100%);
}

.wf-action-btn-secondary {
  background: var(--wf-bg-3);
  color: var(--wf-text-2);
  border: 1px solid var(--wf-border);
}
.wf-action-btn-secondary:hover:not(:disabled) {
  background: rgba(255,255,255,0.06);
  color: var(--wf-text);
  border-color: var(--wf-border-hi);
}

.wf-action-btn-toggle {
  background: var(--wf-bg-3);
  color: var(--wf-text-2);
  border: 1px solid var(--wf-border);
}
.wf-action-btn-toggle.wf-toggle-on {
  background: var(--wf-brand-dim);
  color: var(--wf-brand);
  border-color: var(--wf-border-hi);
}

/* Spinner shimmer overlay */
.wf-action-btn.wf-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.18) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: wf-shimmer 1s linear infinite;
}
@keyframes wf-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

/* ── Status / info strip ─────────────────────────────────────────────────────── */
.wf-status {
  font-size: 11px;
  color: var(--wf-text-3);
  margin-top: 7px;
  min-height: 16px;
  transition: color var(--wf-trans);
}
.wf-status.wf-ok    { color: var(--wf-good); }
.wf-status.wf-err   { color: var(--wf-bad);  }
.wf-status.wf-warn  { color: var(--wf-warn); }

/* ── Drive-time legend ───────────────────────────────────────────────────────── */
.wf-legend {
  display: none;
  margin-top: 10px;
}
.wf-legend.wf-visible {
  display: block;
}

.wf-ramp-bar {
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(to right,
    var(--wf-ramp-0)  0%,
    var(--wf-ramp-5)  20%,
    var(--wf-ramp-10) 40%,
    var(--wf-ramp-15) 60%,
    var(--wf-ramp-20) 80%,
    var(--wf-ramp-30) 100%
  );
  margin-bottom: 4px;
}

.wf-ramp-labels {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--wf-text-3);
  letter-spacing: 0.03em;
}

/* ── Histogram ───────────────────────────────────────────────────────────────── */
.wf-histogram {
  display: none;
  margin-top: 10px;
  align-items: flex-end;
  gap: 2px;
  height: 36px;
}
.wf-histogram.wf-visible {
  display: flex;
}

.wf-hist-bar {
  flex: 1;
  border-radius: 2px 2px 0 0;
  min-width: 3px;
  transition: height 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), background var(--wf-trans);
  cursor: default;
}
.wf-hist-bar:hover {
  filter: brightness(1.3);
}

/* ── Filter slider ───────────────────────────────────────────────────────────── */
.wf-slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.wf-slider-label {
  font-size: 11px;
  color: var(--wf-text-2);
  white-space: nowrap;
  min-width: 32px;
}

.wf-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--wf-bg-3);
  border-radius: 2px;
  outline: none;
  border: 1px solid var(--wf-border);
  cursor: pointer;
}
.wf-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--wf-brand);
  box-shadow: 0 0 6px rgba(56, 189, 248, 0.5);
  cursor: pointer;
  transition: background var(--wf-trans), transform 0.1s;
}
.wf-slider::-webkit-slider-thumb:hover {
  background: #7dd3fc;
  transform: scale(1.15);
}
.wf-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--wf-brand);
  border: none;
  cursor: pointer;
}

.wf-slider-val {
  font-size: 11px;
  font-weight: 700;
  color: var(--wf-brand);
  min-width: 36px;
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
}

/* ── Route info card ─────────────────────────────────────────────────────────── */
.wf-route-card {
  display: none;
  flex-direction: column;
  gap: 6px;
  background: var(--wf-bg-3);
  border: 1px solid var(--wf-border);
  border-radius: var(--wf-radius-sm);
  padding: 10px 12px;
  margin-top: 8px;
}
.wf-route-card.wf-visible {
  display: flex;
}

.wf-route-parcel {
  font-size: 12px;
  font-weight: 700;
  color: var(--wf-brand);
  font-family: 'JetBrains Mono', monospace;
}

.wf-route-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
}

.wf-route-stat {
  display: flex;
  flex-direction: column;
}
.wf-route-stat-val {
  font-size: 18px;
  font-weight: 800;
  color: var(--wf-text);
  line-height: 1;
}
.wf-route-stat-unit {
  font-size: 10px;
  color: var(--wf-text-3);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-top: 2px;
}

.wf-route-clear {
  background: none;
  border: none;
  font-size: 11px;
  color: var(--wf-text-3);
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  text-align: left;
  transition: color var(--wf-trans);
}
.wf-route-clear:hover { color: var(--wf-bad); }

/* ── Road usage section ──────────────────────────────────────────────────────── */
.wf-usage-note {
  font-size: 11px;
  color: var(--wf-text-3);
  margin-top: 6px;
  font-style: italic;
}
.wf-usage-note.wf-hidden { display: none; }

/* ── Loading spinner (inline) ────────────────────────────────────────────────── */
.wf-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.15);
  border-top-color: var(--wf-brand);
  border-radius: 50%;
  animation: wf-spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 5px;
}
@keyframes wf-spin {
  to { transform: rotate(360deg); }
}

/* ── Score summary pill ──────────────────────────────────────────────────────── */
.wf-score-summary {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--wf-brand-glow);
  border: 1px solid var(--wf-border-hi);
  border-radius: 20px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--wf-brand);
  font-weight: 600;
}
.wf-score-summary.wf-visible {
  display: flex;
}
.wf-score-summary svg {
  flex-shrink: 0;
}

/* ── Coexist with the viewer's panels/overlays — reserve the panel's strip ──
   When the (desktop) panel is open, reserve its right-hand strip at the layout
   container so the MAP, the parcel DOCK, the data TABLE, and the in-#map controls
   (the .map-layer-controls rail + fullscreen button, which ride inside #map) all
   reflow to the LEFT of the panel instead of being covered by it. Island Falls +
   Richmond share #content-area. Eliot uses a right-side .e-drawer, shifted left to
   clear the panel. Mobile is a bottom sheet, so no reserve is needed. wayfinder.js
   calls _map.updateSize() on toggle so the OL canvas tracks the reflow. */
@media (min-width: 601px) {
  body.wf-panel-active #content-area {
    padding-right: calc(var(--wf-panel-w) + 16px);
    transition: padding-right var(--wf-trans);
  }
  body.wf-panel-active .e-drawer.is-open {
    right: calc(var(--wf-panel-w) + 16px) !important;
    transition: right var(--wf-trans);
  }
  /* Alpha Attribute: shift its top-right map control cluster clear of the panel. */
  body.wf-panel-active .mctrl {
    right: calc(var(--wf-panel-w) + 16px) !important;
    transition: right var(--wf-trans);
  }
}

/* ── Mobile overrides ────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  :root {
    --wf-panel-w: 100vw;
  }
  #wf-panel {
    border-radius: 0;
    border-left: none;
    top: auto;
    bottom: 0;
    right: 0;
    max-height: 70vh;
    border-radius: var(--wf-radius) var(--wf-radius) 0 0;
    border-right: 1px solid var(--wf-border);
    border-top: 1px solid var(--wf-border);
    transform: translateY(100%);
  }
  #wf-panel.wf-open {
    transform: translateY(0);
  }
}
