/* Map page — loading shell + canvas (kept separate for cache bust). */

/* Shared map height: home preview + /driver/map. Small screens reserve chrome for content below. */
.driver-hub {
  --ch-map-reserve: calc(var(--dh-dock-h, 72px) + 200px + env(safe-area-inset-top, 0px));
  --ch-map-height: min(58dvh, 58vh, 460px);
}

.driver-hub .ch-home--map {
  --ch-map-reserve: calc(var(--dh-dock-h, 72px) + 280px + env(safe-area-inset-top, 0px));
}

.driver-hub .ch-page.ch-map {
  --ch-map-reserve: calc(var(--dh-dock-h, 72px) + 240px + env(safe-area-inset-top, 0px));
}

@media (max-width: 430px), (max-height: 896px) {
  .driver-hub {
    --ch-map-height: clamp(
      200px,
      min(38dvh, calc(100dvh - var(--ch-map-reserve) - env(safe-area-inset-bottom, 0px))),
      min(46dvh, 360px)
    );
  }

  .driver-hub .ch-home--map {
    --ch-map-reserve: calc(var(--dh-dock-h, 72px) + 320px + env(safe-area-inset-top, 0px));
  }

  .driver-hub .ch-page.ch-map {
    --ch-map-reserve: calc(var(--dh-dock-h, 72px) + 260px + env(safe-area-inset-top, 0px));
  }
}

.ch-map-canvas-wrap {
  position: relative;
  padding: 0;
  overflow: hidden;
}

.driver-hub .ch-map-canvas {
  height: var(--ch-map-height);
  min-height: 200px;
  width: 100%;
  border-radius: var(--dh-radius-sm, 12px);
  background: #f3ebe8;
  z-index: 0;
}

.ch-home--map .ch-home-map__frame {
  position: relative;
  min-height: 0;
  height: var(--ch-map-height);
  border-radius: 16px;
  overflow: hidden;
}

.ch-page.ch-home.ch-home--map .ch-home-map .ch-map-canvas {
  position: absolute;
  inset: 0;
  height: 100%;
  min-height: 0;
  border-radius: 16px;
}

.ch-map-canvas.is-loading {
  display: grid;
  place-items: center;
}

.ch-map-loading {
  margin: 0;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #7a1010;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(167, 20, 20, 0.22);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  pointer-events: none;
  z-index: 2;
}

.ch-map-heat-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 8px 0;
  font-size: 0.75rem;
  color: var(--dh-muted, #6b6b6b);
}

.ch-map-heat-legend__bar {
  flex: 1 1 120px;
  height: 10px;
  min-width: 100px;
  border-radius: 999px;
  border: 1px solid rgba(120, 20, 20, 0.25);
  background: linear-gradient(
    90deg,
    #fee8e2 0%,
    #fc8a6a 45%,
    #a50f15 100%
  );
}

.ch-map-heat-legend__stops {
  display: flex;
  gap: 12px;
}

.ch-map-heat-legend__stops span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ch-map-heat-legend i {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1px solid rgba(120, 20, 20, 0.35);
}

.ch-map-basemap-hint,
.ch-map-source {
  display: none;
}

.ch-map-canvas .leaflet-control-attribution {
  margin: 0 0 8px 8px;
  padding: 2px 7px;
  max-width: none;
  background: rgba(255, 255, 255, 0.72);
  border-radius: 6px;
  box-shadow: none;
  font-size: 10px;
  line-height: 1.2;
  color: #8a8178;
}

.leaflet-tooltip.ch-map-name-label {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(167, 20, 20, 0.35);
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  color: #7a1010;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  padding: 2px 6px;
  white-space: nowrap;
  pointer-events: none;
}

.leaflet-tooltip.ch-map-name-label--district {
  color: #5c1010;
  font-size: 12px;
  background: rgba(255, 248, 246, 0.88);
}

.leaflet-tooltip.ch-map-name-label--poi {
  color: #a8071a;
}

.leaflet-tooltip.ch-map-name-label::before {
  border-top-color: rgba(167, 20, 20, 0.35);
}

.ch-route-marker {
  display: flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 0;
}

.ch-route-marker__idx {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #c45c26;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.ch-route-marker.is-current .ch-route-marker__idx {
  background: #ff9f0a;
  color: #3d2200;
}

.ch-route-marker.is-past .ch-route-marker__idx {
  background: #8a7a70;
}

.ch-route-marker__name {
  display: none;
}

.ch-route-arrow {
  background: transparent !important;
  border: 0 !important;
  font-size: 16px;
  line-height: 1;
  color: #c45c26;
  text-shadow: 0 0 4px #fff, 0 1px 2px rgba(0, 0, 0, 0.25);
}

.ch-route-arrow span {
  display: block;
  transform-origin: 50% 50%;
}

.ch-map-head {
  padding-bottom: 10px;
}

.ch-map-lead {
  margin: 4px 0 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--dh-muted, #6b6b6b);
}

.ch-map .ch-map-city,
.ch-map .ch-map-slices {
  margin-top: 8px;
  margin-bottom: 8px;
  padding: 10px 12px;
}

/* Gaode-style map tools: stacked white controls, bottom-right. */
.ch-map-tools {
  position: absolute;
  right: max(10px, env(safe-area-inset-right, 0px));
  bottom: max(10px, env(safe-area-inset-bottom, 0px));
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}

.ch-map-tools > * {
  pointer-events: auto;
}

.ch-map-fs-btn,
.ch-map-loc-btn,
.ch-map-home-btn {
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: #1c140e;
  box-shadow: 0 2px 8px rgba(28, 20, 14, 0.18);
  display: grid;
  place-items: center;
  cursor: pointer;
  outline: none;
  box-sizing: border-box;
  line-height: 0;
  font-size: 0;
  appearance: none;
  -webkit-appearance: none;
  touch-action: manipulation;
}

.ch-map-fs-btn:active,
.ch-map-loc-btn:active,
.ch-map-home-btn:active {
  transform: scale(0.96);
}

.ch-map-fs-btn svg,
.ch-map-loc-btn svg,
.ch-map-home-btn svg {
  display: block;
  width: 20px;
  height: 20px;
}

.ch-map-loc-btn.is-busy {
  color: #1a73e8;
  animation: ch-map-loc-pulse 0.9s ease-in-out infinite;
}

@keyframes ch-map-loc-pulse {
  50% { opacity: 0.45; }
}

.ch-map-me {
  background: transparent;
  border: 0;
}

.ch-map-me__dot {
  display: block;
  width: 14px;
  height: 14px;
  margin: 4px;
  border-radius: 50%;
  background: #1a73e8;
  border: 2px solid #fff;
  box-shadow: 0 0 0 6px rgba(26, 115, 232, 0.22);
}

.ch-map-toast {
  position: absolute;
  left: 50%;
  top: 10px;
  z-index: 9;
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(28, 20, 14, 0.86);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.3;
  pointer-events: none;
}

.ch-map-near {
  position: absolute;
  left: max(10px, env(safe-area-inset-left, 0px));
  right: 58px;
  bottom: max(10px, env(safe-area-inset-bottom, 0px));
  z-index: 8;
}

.ch-map-near__go {
  width: 100%;
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 10px 12px;
  border: 0;
  border-radius: 14px;
  background: #fff;
  color: #1c140e;
  text-align: left;
  box-shadow: 0 4px 16px rgba(28, 20, 14, 0.16);
  cursor: pointer;
  touch-action: manipulation;
}

.ch-map-near__kicker {
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  color: #8a8178;
}

.ch-map-near__name {
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.2;
}

.ch-map-near__meta {
  font-size: 0.75rem;
  font-style: normal;
  color: #6b6b6b;
}

.ch-map-near__orders {
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.25;
  color: #c45c26;
}

.ch-map-fs-btn .ch-map-fs-btn__exit {
  display: none;
}

.ch-map-fs-btn.is-fs .ch-map-fs-btn__enter {
  display: none;
}

.ch-map-fs-btn.is-fs .ch-map-fs-btn__exit {
  display: block;
}

html.dh-map-fs,
body.dh-map-fs {
  overflow: hidden;
  width: 100%;
  height: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  background: #c5d4c8;
}

html.dh-android-app.dh-map-fs .dh-shell:not(.dh-shell--ai-chat),
body.dh-android-app.dh-map-fs .dh-shell:not(.dh-shell--ai-chat),
body.dh-map-fs .dh-shell {
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  max-width: none !important;
  min-height: 100% !important;
  min-height: 100dvh !important;
}

body.dh-map-fs .dh-top,
body.dh-map-fs .dh-dock,
body.dh-map-fs .ch-home-hud,
body.dh-map-fs .ch-home-lead,
body.dh-map-fs .ch-home-below,
body.dh-map-fs .ch-map-head,
body.dh-map-fs .ch-wide-pane--side,
body.dh-map-fs .ch-map-heat-legend,
body.dh-map-fs .tdm__hud,
body.dh-map-fs .tdm__legend {
  display: none !important;
}

body.dh-map-fs .dh-shell,
body.dh-map-fs .dh-main,
body.dh-map-fs .ch-page,
body.dh-map-fs .ch-wide-split,
body.dh-map-fs .ch-wide-pane--main,
body.dh-map-fs .ch-home-map,
body.dh-map-fs .tdm,
body.dh-map-fs .tdm--widget {
  margin: 0 !important;
  padding: 0 !important;
  max-width: none !important;
  width: 100% !important;
}

body.dh-map-fs .ch-home-map__frame,
body.dh-map-fs .ch-map-canvas-wrap,
body.dh-map-fs .tdm__frame,
body.dh-map-fs .tdm__frame.is-map-fs {
  position: fixed !important;
  inset: 0 !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  z-index: 80;
  width: 100% !important;
  width: 100vw !important;
  height: 100% !important;
  height: 100dvh !important;
  height: 100lvh !important;
  min-height: 100vh !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background: #f3ebe8;
  overflow: hidden !important;
  animation: none !important;
  transform: none !important;
  filter: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

body.dh-map-fs .ch-map-canvas,
body.dh-map-fs .tdm__canvas {
  position: absolute !important;
  inset: 0 !important;
  height: 100% !important;
  min-height: 0 !important;
  width: 100% !important;
  border-radius: 0 !important;
}

body.dh-map-fs .ch-map-tools {
  right: max(12px, env(safe-area-inset-right, 0px));
  bottom: max(16px, calc(env(safe-area-inset-bottom, 0px) + 12px));
  z-index: 90;
}

.ch-map-ai-btn {
  display: none;
  width: 40px;
  min-height: 40px;
  margin: 0;
  padding: 5px 3px;
  border: 0;
  border-radius: 12px;
  background: #fff;
  color: #1c140e;
  box-shadow: 0 2px 8px rgba(28, 20, 14, 0.18);
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  text-align: center;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  touch-action: manipulation;
}

.ch-map-ai-btn span {
  display: block;
  white-space: pre-line;
}

body.dh-map-fs .ch-map-ai-btn,
.tdm__frame.is-map-fs .ch-map-ai-btn,
.ch-home-map__frame.is-map-fs .ch-map-ai-btn,
.ch-map-canvas-wrap.is-map-fs .ch-map-ai-btn {
  display: grid;
  place-items: center;
}

/* Gaode-style floating back — top-left over map */
.ch-map-fs-back {
  display: none;
  position: absolute;
  top: max(12px, calc(env(safe-area-inset-top, 0px) + 10px));
  left: max(12px, calc(env(safe-area-inset-left, 0px) + 10px));
  z-index: 95;
  width: 42px;
  height: 42px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.96);
  color: #1d1d1f;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.ch-map-fs-back svg {
  display: block;
  margin-left: -1px;
}

.ch-map-fs-back:active {
  transform: scale(0.96);
  background: #fff;
}

body.dh-map-fs .ch-map-fs-back,
.tdm__frame.is-map-fs .ch-map-fs-back,
.ch-home-map__frame.is-map-fs .ch-map-fs-back,
.ch-map-canvas-wrap.is-map-fs .ch-map-fs-back {
  display: inline-flex;
}

body.dh-map-fs .ch-map-near {
  left: max(12px, env(safe-area-inset-left, 0px));
  right: 64px;
  bottom: max(16px, calc(env(safe-area-inset-bottom, 0px) + 12px));
}
