.arcgis-heatmap-2026 {
  --ts-accent: #0090d7;
  --panel-bg: rgba(27, 29, 29, 0.78);
  --panel-solid: #1b1d1d;
  position: relative;
  width: 100%;
  text-align: left;
  font-family: "Open Sans", Helvetica, Arial, sans-serif;
}

.arcgis-heatmap-2026 * { box-sizing: border-box; }

/* ── Map frame. JS wraps .map-viewdiv + .layer-panel in this. ── */
.arcgis-heatmap-2026 .map-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  height: auto;
  max-height: 720px;
}

.arcgis-heatmap-2026 .map-viewdiv { position: absolute; inset: 0; }

/* ── Layer selector panel ── */
.arcgis-heatmap-2026 .layer-panel {
  position: absolute;
  top: 15px;
  left: 15px;
  z-index: 10;
  background: var(--panel-bg);
  color: #fff;
  border-radius: 6px;
  padding: 12px 14px;
  min-width: 220px;
  max-width: 480px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  font-size: 13px;
  backdrop-filter: blur(6px);
}

.arcgis-heatmap-2026 .layer-panel-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #cfcfcf;
  margin: 0 0 10px;
}

.arcgis-heatmap-2026 .layer-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.arcgis-heatmap-2026 .layer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s;
  touch-action: manipulation;
}
.arcgis-heatmap-2026 .layer-item:hover { background: rgba(255, 255, 255, 0.06); }

.arcgis-heatmap-2026 .layer-item input[type="radio"],
.arcgis-heatmap-2026 .layer-item input[type="checkbox"] {
  accent-color: var(--ts-accent);
  width: 15px;
  height: 15px;
  margin: 0;
  cursor: pointer;
  flex-shrink: 0;
}

.arcgis-heatmap-2026 .layer-label {
  flex: 1;
  color: #fff;
  font-size: 13px;
  line-height: 1.4;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.arcgis-heatmap-2026 .layer-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.18);
  margin: 8px 0;
}

.arcgis-heatmap-2026 .esri-ui-bottom-right { bottom: 12px; }

.arcgis-heatmap-2026 arcgis-legend {
  --calcite-color-foreground-1: var(--panel-bg);
  --calcite-color-foreground-2: var(--panel-bg);
  --calcite-color-foreground-3: var(--panel-bg);
  --calcite-color-text-1: #ffffff;
  --calcite-color-text-2: #ffffff;
  --calcite-color-text-3: #ffffff;
  font-family: "Open Sans", Helvetica, Arial, sans-serif;
}

/* ── Below-map stack: layer selector + legend, mobile only ── */
.arcgis-heatmap-2026 .below-map {
  display: block;
  background: var(--panel-solid);
  color: #fff;
  border-top: 2px solid var(--ts-accent);
}

.arcgis-heatmap-2026 .below-map[hidden] { display: none; }

/* The layer panel stops being a floating card once it is in the stack.
   position must be reset — .arcgis-heatmap-2026 is the positioned
   ancestor, so it would keep floating over the map from its new parent. */
.arcgis-heatmap-2026 .below-map .layer-panel {
  position: static;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  border-radius: 0;
  min-width: 0;
  max-width: none;
  width: 100%;
  padding: 14px 16px 6px;
}

.arcgis-heatmap-2026 .legend-summary {
  list-style: none;
  cursor: pointer;
  padding: 13px 16px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 10px;
  touch-action: manipulation;
}

.arcgis-heatmap-2026 .legend-summary::-webkit-details-marker { display: none; }

.arcgis-heatmap-2026 .legend-summary::before {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--ts-accent);
  border-bottom: 2px solid var(--ts-accent);
  transform: rotate(-45deg);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.arcgis-heatmap-2026 .legend-host[open] .legend-summary::before {
  transform: rotate(45deg);
}

.arcgis-heatmap-2026 .legend-body {
  max-height: 40vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 10px 12px;
}

.arcgis-heatmap-2026 .legend-body arcgis-legend {
  --calcite-color-foreground-1: transparent;
  --calcite-color-foreground-2: transparent;
  --calcite-color-foreground-3: transparent;
  display: block;
}

/* ── Mobile: keep this breakpoint equal to MOBILE_QUERY in the JS ── */
@media (max-width: 700px) {
  .arcgis-heatmap-2026 .map-wrap {
    aspect-ratio: auto;
    height: 54vh;
    min-height: 300px;
    max-height: 460px;
  }

  /* Full width available, so long layer names wrap instead of truncating */
  .arcgis-heatmap-2026 .below-map .layer-label {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    font-size: 14px;
  }

  /* Touch targets */
  .arcgis-heatmap-2026 .below-map .layer-item {
    padding: 9px 4px;
    min-height: 40px;
    align-items: flex-start;
  }

  .arcgis-heatmap-2026 .below-map .layer-item input[type="radio"],
  .arcgis-heatmap-2026 .below-map .layer-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-top: 1px;
  }

  .arcgis-heatmap-2026 .below-map .layer-item:hover {
    background: none;   /* no hover state on touch */
  }
}

@media (prefers-reduced-motion: reduce) {
  .arcgis-heatmap-2026 .layer-item,
  .arcgis-heatmap-2026 .legend-summary::before {
    transition: none;
  }
}