/* Primary map guarantee + honest fallback + route planner.
   The map is the product's ground plane: it must always own a
   measurable, full-viewport box below every overlay. When no real
   map can be drawn, #map-fallback says so instead of leaving gray. */

#map {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  min-width: 100vw;
  min-height: 100vh;
  min-height: 100dvh;
  z-index: 1;
}
#map .mapboxgl-canvas-container,
#map .mapboxgl-canvas {
  display: block;
  width: 100%;
  height: 100%;
}
#map.assist-map-active .mapboxgl-canvas { cursor: crosshair; }
body.drev-assist-app-open #map { z-index: 1; }

/* ── Fallback state (provider / WebGL / token / network failure) ───── */
#map-fallback {
  position: fixed;
  z-index: 8900;
  top: 84px;
  left: 18px;
  display: grid;
  gap: 10px;
  width: min(386px, calc(100vw - 36px));
  max-height: calc(100vh - 110px);
  max-height: calc(100dvh - 110px);
  overflow: auto;
  padding: 18px;
  border: 1px solid rgba(137, 218, 255, .38);
  border-radius: 18px;
  color: #eefaff;
  background: linear-gradient(150deg, rgba(4, 18, 38, .97), rgba(9, 31, 62, .94));
  box-shadow: 0 24px 70px rgba(0, 0, 0, .55), inset 0 1px rgba(255, 255, 255, .08);
  /* The kit's measured frost. 20px was four times the value and, because this
     sheet was never linked until now, nobody saw what it did to the page. */
  backdrop-filter: var(--glass-blur, blur(6px) saturate(1.8));
  -webkit-backdrop-filter: var(--glass-blur, blur(6px) saturate(1.8));
  font-family: var(--font-ui, Rajdhani, system-ui, sans-serif);
}
#map-fallback[hidden] { display: none !important; }

/* Short landscape screens: the fallback card shares the left edge with the
   orbital entry panel and was covering the "Enter the network" button.
   Park it on the right, clear of the panel (z-index stays below nothing —
   the orbital UI (600) must never lose the tap to this card (8900)). */
@media (max-height: 620px) and (orientation: landscape) {
  #map-fallback {
    left: auto;
    right: 12px;
    top: 56px;
    max-height: calc(100dvh - 70px);
  }
}
.map-fallback-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(172, 228, 247, .25);
  border-radius: 9px;
  color: #c7ebf7;
  background: rgba(255, 255, 255, .06);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.map-fallback-eyebrow {
  color: #8fddf3;
  font: 800 8px/1 'Orbitron', system-ui, sans-serif;
  letter-spacing: 1.1px;
}
#map-fallback h2 {
  margin: 0;
  color: #fff;
  font: 800 19px/1.15 'Orbitron', system-ui, sans-serif;
  letter-spacing: -.2px;
}
#map-fallback p { margin: 0; color: #c4d8e4; font-size: 13.5px; line-height: 1.45; }
.map-fallback-boundary { color: #ffe0ae !important; }
.map-fallback-field { display: grid; gap: 5px; color: #d7edf6; font-size: 12.5px; font-weight: 700; }
.map-fallback-field span { color: #9dc2d4; font-weight: 600; }
.map-fallback-field input {
  box-sizing: border-box;
  width: 100%;
  min-height: 38px;
  padding: 9px 10px;
  border: 1px solid rgba(168, 225, 245, .25);
  border-radius: 9px;
  color: #effaff;
  background: rgba(0, 0, 0, .22);
  font: 14px/1.3 system-ui, sans-serif;
}
.map-fallback-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.map-fallback-actions button,
.map-fallback-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(120, 218, 250, .4);
  border-radius: 9px;
  color: #03141f;
  background: linear-gradient(135deg, #a5f3ff, #5e97ef);
  font: 800 8px/1 'Orbitron', system-ui, sans-serif;
  letter-spacing: .3px;
  text-decoration: none;
  cursor: pointer;
}
.map-fallback-actions a { color: #bdefff; background: rgba(64, 174, 221, .14); }
.map-fallback-actions a.is-disabled { opacity: .45; pointer-events: none; }
#map-fallback-status:empty { display: none; }
body.primary-map-fallback #map { background: radial-gradient(ellipse at 50% 35%, #0b1c30 0%, #040a14 60%, #01030a 100%); }

/* ── Route planner (inside the DREV ENERGY drawer) ─────────────────── */
.route-intro, .route-note, .route-limitations, .route-source {
  color: var(--muted, rgba(220, 232, 248, .62));
  font-size: 13.5px;
  line-height: 1.5;
}
.route-fields { display: grid; gap: 12px; margin-top: 12px; }
.route-field { display: grid; gap: 6px; color: var(--text, #e8f2fb); font-size: 13px; font-weight: 700; }
.route-field .dw-input {
  box-sizing: border-box;
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 10px;
  color: #fff;
  background: rgba(255, 255, 255, .05);
  font-family: var(--font-ui, system-ui, sans-serif);
  font-size: 15px;
}
.route-field .dw-input[aria-invalid="true"] { border-color: rgba(255, 120, 120, .75); }
.route-field-error { color: #ff9d9d; font-size: 12.5px; font-weight: 600; }
.route-status { min-height: 20px; margin: 12px 0 0; color: var(--muted, rgba(220, 232, 248, .62)); font-size: 13.5px; line-height: 1.45; }
.route-status[data-tone="success"] { color: #8ff0bd; }
.route-status[data-tone="warning"] { color: #ffd28a; }
.route-result {
  display: grid;
  gap: 9px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(120, 218, 250, .28);
  border-radius: 12px;
  background: rgba(24, 90, 140, .12);
}
.route-result[hidden] { display: none; }
.route-summary span {
  color: #8fddf3;
  font: 800 8px/1 'Orbitron', system-ui, sans-serif;
  letter-spacing: .9px;
}
.route-summary p { margin: 6px 0 0; color: #eaf7ff; font-size: 14.5px; line-height: 1.5; overflow-wrap: anywhere; }
.route-provider-facts { display: flex; flex-wrap: wrap; gap: 8px 18px; color: #d9eefb; font-size: 14px; }
.route-provider-facts b { color: #fff; }
.route-unavailable { margin: 0; color: #ffe0ae; font-size: 14px; line-height: 1.5; }
.route-source, .route-limitations { margin: 0; font-size: 12.5px; }
.route-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.route-external, .route-view-map {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 15px;
  border: 1px solid rgba(120, 218, 250, .45);
  border-radius: 10px;
  color: #dff6ff;
  background: rgba(64, 174, 221, .14);
  font: 800 9px/1 'Orbitron', system-ui, sans-serif;
  letter-spacing: .35px;
  text-decoration: none;
  cursor: pointer;
}
.route-external:hover, .route-view-map:hover { border-color: rgba(160, 235, 255, .8); background: rgba(64, 174, 221, .24); }
.route-external.is-disabled { opacity: .45; }
.route-note { margin-top: 10px; }
#btn-plan-route:disabled { opacity: .55; cursor: wait; }

@media (max-width: 720px) {
  #map-fallback {
    top: 66px;
    left: 10px;
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 150px);
    padding: 15px;
  }
  .route-actions > * { flex: 1 1 46%; }
}
