/* ──────────────────────────────────────────────────────────────────────
   Regional map — the drill-down choropleth that replaces the flat
   Figma export on the insight-detail route.

   Mounts into the page's existing <aside class="_map_*">, so it inherits
   that element's size. Everything here is scoped under .rm-* to keep it
   clear of the app's hashed CSS-module class names.
   ────────────────────────────────────────────────────────────────────── */

.rm-root { position: absolute; inset: 0; overflow: hidden; background: #142019; }
.rm-map  { position: absolute; inset: 0; }
.rm-root .maplibregl-ctrl-attrib { font-size: 10px; }

/* ── Breadcrumb / filter chips, pinned over the map ── */
.rm-chips {
  position: absolute; top: 14px; left: 14px; right: 62px; z-index: 3;
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center; pointer-events: none;
}
/* The chip is the app's own SmartSearch filter chip, so it carries no
   styling here beyond sitting in the right place inside the field. */
.rm-chips--inline {
  position: static; inset: auto; flex: 0 0 auto; margin: 0 8px 0 0;
  pointer-events: auto; max-width: 55%; display: inline-flex;
}
/* SmartSearch sizes the chip at 2rem; the field is 44px, so it sits
   centred without changing the field's own height. */
.rm-chips--inline .rm-chip { display: inline-flex; align-items: center; }

.rm-chip-sep { pointer-events: none; color: rgba(255,255,255,0.75); font-size: 12px; text-shadow: 0 1px 3px rgba(0,0,0,0.5); }

/* ── Legend ── */
.rm-legend {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 16px; z-index: 3;
  background: rgba(255,255,255,0.95); border-radius: 8px; padding: 9px 14px 11px;
  box-shadow: 0 2px 10px rgba(10,10,10,0.2); min-width: 210px;
  font-family: 'Oracle Sans', system-ui, sans-serif;
}
.rm-legend-title { font-size: 11.5px; font-weight: 600; color: #1a1a1a; text-align: center; }
.rm-legend-bar { height: 7px; border-radius: 4px; margin: 7px 0 4px;
  background: linear-gradient(90deg, #fdeae3, #f6b39a, #e8735000, #e05a2b, #a5301070); }
.rm-legend-scale { display: flex; justify-content: space-between; font-size: 10.5px; color: rgba(10,10,10,0.6); }

/* ── Hover readout ──
   Redwood surfaces are light: white content background, a hairline border,
   the theme's own shadow and text colours. Values are read straight from
   the vendored oj-redwood theme with fallbacks, so this sits in the design
   system rather than beside it. */
.rm-tip {
  position: absolute; z-index: 4; pointer-events: none; display: none;
  background: var(--oj-core-bg-color-content, #fff);
  color: var(--oj-core-text-color-primary, #161513);
  border: 1px solid var(--oj-core-border-color-enabled, rgba(22,21,19,0.16));
  border-radius: var(--oj-core-border-radius-lg, 0.375rem);
  box-shadow: var(--oj-core-box-shadow-md, 0 6px 12px 0 rgba(0,0,0,0.2));
  padding: 8px 11px; max-width: 224px;
  font: 400 11.5px/1.5 'Oracle Sans', system-ui, sans-serif;
}
.rm-tip b {
  display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 2px;
  color: var(--oj-core-text-color-primary, #161513);
}
.rm-tip span { color: var(--oj-core-text-color-secondary, rgba(22,21,19,0.7)); }
.rm-tip em { font-style: normal; font-weight: 600; }

/* ── Map controls ──
   Rebuilt to match Visual Explorer's: white rounded groups holding Nitro
   icon buttons, zoom as a pair and each other control on its own. The
   button states are Nitro's neutral scale, 0.08 at rest, 0.12 on hover,
   0.16 when pressed or toggled, rather than a colour of my choosing. */
.rm-controls {
  display: grid !important; gap: 12px !important;
  flex-direction: unset !important;
}
.rm-control-group {
  background: #fff; border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  display: grid; gap: 4px; padding: 4px; pointer-events: auto;
}
.rm-controls button {
  width: 28px !important; height: 28px !important; min-width: 28px !important;
  border-radius: 4px !important; border: 1px solid transparent !important;
  background: rgba(22,21,19,0.08) !important;
  color: var(--oj-core-text-color-primary, #161513) !important;
  box-shadow: none !important; font-size: 16px !important;
  display: grid !important; place-items: center !important;
  transition: background-color 0.15s ease;
}
.rm-controls button:hover { background: rgba(22,21,19,0.12) !important; }
.rm-controls button:active { background: rgba(22,21,19,0.16) !important; }
.rm-controls button:focus-visible { outline: 2px solid #00688c; outline-offset: 1px; }
.rm-tool-on { background: rgba(22,21,19,0.16) !important; }

/* ── Leaf notice ── */
.rm-note {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 74px; z-index: 3;
  background: rgba(20,20,20,0.9); color: #fff; border-radius: 100px; padding: 7px 15px;
  font: 400 11.5px/1.3 'Oracle Sans', system-ui, sans-serif; opacity: 0;
  transition: opacity 0.25s ease; pointer-events: none; white-space: nowrap;
}
.rm-note.is-on { opacity: 1; }

.rm-err {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 32px; text-align: center; color: #fff; background: #142019;
  font: 400 13px/1.6 'Oracle Sans', system-ui, sans-serif;
}

/* ── Region name labels ──
   HTML markers rather than a symbol layer, so no glyph server is needed
   and the type is styleable. Small, quiet, readable over satellite. */
.rm-label {
  font: 400 8.5px/1.1 'Oracle Sans', system-ui, sans-serif;
  letter-spacing: 0.015em; color: rgba(255,255,255,0.92); white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8), 0 0 4px rgba(0,0,0,0.5);
  pointer-events: none; user-select: none; text-align: center;
}
/* Over the pale basemaps white type disappears, so flip it. */
.rm-light .rm-label { color: rgba(28,28,28,0.78); text-shadow: 0 1px 2px rgba(255,255,255,0.95), 0 0 4px rgba(255,255,255,0.8); }

/* ── Layer panel ──
   A Redwood popup: white surface, 6px radius, the theme's own shadow and
   text colours, 12px labels on 'Oracle Sans' like the rest of the app. */
.rm-layers {
  position: absolute; top: 20px; right: 64px; z-index: 6; width: 216px;
  background: var(--oj-core-bg-color-content, #fff);
  border-radius: var(--oj-core-border-radius-lg, 6px);
  box-shadow: var(--oj-core-box-shadow-md, 0 6px 12px 0 rgba(0,0,0,0.2));
  padding: 0 0 6px; overflow: hidden;
  font-family: 'Oracle Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--oj-core-text-color-primary, #161513);
}
.rm-layers[hidden] { display: none; }
.rm-layers-head {
  padding: 12px 14px 8px; font-size: 14px; font-weight: 600; line-height: 20px;
  color: var(--oj-core-text-color-primary, #161513);
}
.rm-layers-h {
  margin: 8px 14px 4px; font-size: 11px; font-weight: 600; line-height: 16px;
  color: var(--oj-core-text-color-secondary, rgba(22,21,19,0.7));
}
.rm-layer-list { padding: 0 6px; }
.rm-layer {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  cursor: pointer; padding: 7px 8px; border: 0; border-radius: 4px;
  background: transparent; color: inherit; font-family: inherit;
}
.rm-layer:hover { background: var(--oj-core-bg-color-hover, rgba(22,21,19,0.08)); }
.rm-layer.is-on { background: rgba(0,104,140,0.08); }
.rm-layer-swatch {
  flex: 0 0 auto; width: 22px; height: 22px; border-radius: 3px;
  border: 1px solid rgba(22,21,19,0.14); background-size: cover;
}
.rm-sw-satellite { background: linear-gradient(135deg, #3d5a3a, #24402c 55%, #1d3350); }
.rm-sw-terrain   { background: linear-gradient(135deg, #cdbb99, #9fae87 60%, #7e9a8c); }
.rm-sw-streets   { background: linear-gradient(135deg, #f6f3ee, #e3ddd2 55%, #cfd8e0); }
.rm-sw-light     { background: linear-gradient(135deg, #f4f4f4, #e6e6e6 60%, #d8dde0); }
.rm-layer-copy { flex: 1 1 auto; min-width: 0; }
.rm-layer-copy strong { display: block; font-size: 12px; font-weight: 400; line-height: 16px; }
.rm-layer-copy small {
  display: block; font-size: 11px; line-height: 15px;
  color: var(--oj-core-text-color-secondary, rgba(22,21,19,0.7));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rm-layer.is-on .rm-layer-copy strong { font-weight: 600; color: #00688c; }
/* Selection is shown by a check, not the word "Off" repeated down the
   list. Oracle's own icon font is already loaded by the app. */
.rm-layer-check { flex: 0 0 auto; font-size: 15px; color: #00688c; opacity: 0; }
.rm-layer.is-on .rm-layer-check { opacity: 1; }

.rm-layer-item { padding: 2px 14px 6px; }
.rm-range-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12px; line-height: 16px; margin-bottom: 6px;
  color: var(--oj-core-text-color-secondary, rgba(22,21,19,0.7));
}
.rm-range-head output { font-size: 12px; color: var(--oj-core-text-color-primary, #161513); }
.rm-range { width: 100%; accent-color: #00688c; margin: 0; }

.rm-toggle { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; padding: 6px 14px; }
.rm-toggle:hover { background: var(--oj-core-bg-color-hover, rgba(22,21,19,0.08)); }
.rm-toggle input { margin: 1px 0 0; accent-color: #00688c; flex: 0 0 auto; }
.rm-toggle strong { display: block; font-size: 12px; font-weight: 400; line-height: 16px; }
.rm-toggle small {
  display: block; font-size: 11px; line-height: 15px;
  color: var(--oj-core-text-color-secondary, rgba(22,21,19,0.7));
}

/* ── The page's legend keeps its layout, at a smaller size ── */
[class*="_mapLegend_"] { width: 316px !important; padding: 7px 14px !important; }
[class*="_mapLegend_"] strong { font-size: 12.5px !important; line-height: 17px !important; }
[class*="_mapLegend_"] > div { font-size: 10.5px !important; gap: 7px !important; margin-top: 4px !important; }
[class*="_mapLegend_"] i { width: 196px !important; height: 9px !important; }

/* ── Cards ──
   The card's own selected state is the design's and is left alone. The only
   thing this module changes is the chart line colour, set per card in JS,
   so a card and the map read as the same measure. */
[data-rm-metric] { cursor: pointer; }

/* The page's legend keeps its own styling. This module only rewrites its
   text and gradient; the shape, size and position are the design's. */

/* ── Repair the app's percentage axis ──
   `._barChart_ > div > span` sets `flex: 0 0 70px` for the region labels,
   and the axis row is also a `> div`, so its six scale labels inherit a
   70px basis. Six 70px labels plus gaps overflow the 391px chart, which is
   why 100% sat outside the card and none of the labels lined up with the
   20% gridlines. The axis rule resets `width` but not `flex-basis`.
   This is the app's own bug, present without this module. */
[class*="_barAxis_"] > span {
  flex: 0 1 auto !important;
  width: auto !important;
  margin-left: 0 !important;
}

/* ── Centre the legend on the map ──
   The build pins the legend with a hard-coded `left: 458px` inside an 880px
   map, which puts it 176px right of centre: 458px of space on its left and
   106px on its right. Anchored to the middle instead, so it stays centred
   whatever width the map is given. */
[class*="_mapLegend_"] {
  left: 50% !important;
  right: auto !important;
  transform: translateX(-50%) !important;
}
