/* =============================================================
   map.css
   The map and everything that floats on top of it: search bar,
   map layers legend, zoom / location buttons and Ask AI.
   ============================================================= */

/* MapLibre draws inside #map, which fills the whole map card.
   The light grey shows while basemap tiles are loading. */
.map {
  position: absolute;
  inset: 0;
  background: var(--grey-100);
}

/* Shared look for every panel that floats on the map. */
.map-overlay {
  position: absolute;
  z-index: 2; /* above the map canvas */
  background: var(--surface-base);
}

/* ---------- Search bar (top left) ---------- */
.map-search {
  top: 8px;
  left: 9px;
  display: flex;
  align-items: center;
  gap: 8px;
  /* Wide enough for the whole placeholder ("Search a neighbourhood
     or street in Olomouc"), but never wider than the map. */
  width: 340px;
  max-width: calc(100% - 18px);
  height: 34px;
  padding: 6px 8px;
  border-radius: var(--radius-pill);
}

.map-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: var(--caption-2-size);
  line-height: 16px;
}

.map-search input::placeholder {
  color: var(--grey-600);
}

.map-search:focus-within {
  outline: 2px solid var(--green-500);
}

/* Suggestion list, just under the search bar. */
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 300px;
  overflow-y: auto;
  padding: 4px;
  border-radius: var(--radius-tile);
  background: var(--surface-base);
  box-shadow: 0 4px 12px rgba(40, 42, 46, 0.12);
}

.search-results[hidden] {
  display: none;
}

/* One suggestion: place name, then type + town in grey. */
.search-result {
  display: flex;
  flex-direction: column;
  padding: 6px 8px;
  border-radius: var(--radius-row);
  cursor: pointer;
}

.search-result:hover,
.search-result[aria-selected="true"] {
  background: var(--green-25);
}

.search-result__name {
  font-weight: var(--weight-medium);
  color: var(--grey-900);
}

.search-result__meta {
  font-size: var(--caption-3-size);
  line-height: var(--caption-3-line);
  color: var(--grey-700);
}

/* "No places found" and error messages. */
.search-message {
  padding: 6px 8px;
  color: var(--grey-700);
}

/* ---------- Map layers legend (bottom left) ---------- */
.map-layers {
  bottom: 16px;
  left: 9px;
  width: 233px;
  border-radius: var(--radius-row);
  overflow: hidden;
}

/* Header row: "Map layers" + arrow to collapse the panel. */
.map-layers__toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 6px;
  border-bottom: 1px solid var(--grey-50);
  font-weight: var(--weight-medium);
  line-height: 16px;
}

.map-layers__title {
  display: flex;
  align-items: center;
  gap: 3px;
}

/* Arrow points up when the panel is collapsed. */
.map-layers__toggle[aria-expanded="false"] .map-layers__arrow {
  transform: rotate(180deg);
}

.map-layers__body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px 7.5px;
}

.map-layers__body[hidden] {
  display: none;
}

/* One layer row: (icon) name … eye button. */
.layer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
  font-weight: var(--weight-medium);
  color: var(--display-subtle-01);
}

.layer-row__name {
  flex: 1;
}

/* Round grey icon in front of "Building". */
.layer-row__icon {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--grey-100);
}

/* Eye button that shows / hides a layer: open eye when shown,
   crossed-out eye when hidden. */
.eye-btn {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 6px;
}

/* Hexagon views: the chosen view (with legend and opacity) on top,
   then a divider, then the other views. */
.layer-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.layer-current {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* The visible view is darker than the others. */
.layer-current .layer-row:has(.eye-btn[aria-pressed="true"]) {
  color: var(--grey-900);
}

.layer-choice {
  display: flex;
  flex-direction: column;
  padding-top: 8px;
  border-top: 1px solid var(--grey-50);
}

/* Brownfields, microzone boundaries, buildings: under a divider. */
.layer-overlays {
  display: flex;
  flex-direction: column;
  padding-top: 8px;
  border-top: 1px solid var(--grey-50);
}

.layer-row[hidden],
.legend[hidden],
.legend__note[hidden] {
  display: none;
}

/* Thick dark square in front of "Brownfields and vacant land". */
.layer-row__icon--outline {
  background: none;
  border: 2.5px solid #1F1F1F;
  border-radius: 3px;
  width: 12px;
  height: 12px;
  margin: 0 2px;
}

/* Blue square in front of "Public buildings" (same blue as the
   outline on the map, PUBLIC_COLOR in js/map/layers.js). */
.layer-row__icon--public {
  background: none;
  border: 2px solid #2F6FB3;
  border-radius: 3px;
  width: 12px;
  height: 12px;
  margin: 0 2px;
}

/* Dashed square in front of "Microzone boundaries". */
.layer-row__icon--dashed {
  background: none;
  border: 1.5px dashed var(--grey-900);
  border-radius: 3px;
  width: 12px;
  height: 12px;
  margin: 0 2px;
}

/* Legend: colour ramp, Low / High. */
.legend {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Grey box + "too few reports": hexes without a value. */
.legend__note {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--caption-3-size);
  line-height: var(--caption-3-line);
  font-weight: var(--weight-medium);
  color: var(--display-subtle-02);
}

.legend__swatch {
  width: 12px;
  height: 12px;
  background: #e6e6e6; /* the no-value grey in js/map/layers.js */
  opacity: var(--hex-opacity, 0.7);
}

/* Classified legend: one box per class (added by layer-panel.js).
   Drawn like the hexagons on the map: white outlines between the
   classes and the same 0.7 opacity as the hexagon fill. */
.legend__scale {
  display: flex;
  gap: 2px; /* white gap = the white hexagon outline */
  margin-top: 2px;
  background: var(--surface-base);
}

.legend__scale span {
  flex: 1;
  height: 12px;
  /* Same as the hexagon fill; updated by the Opacity slider. */
  opacity: var(--hex-opacity, 0.7);
}

/* Numbers at the class breaks, centred under the box edges (the
   first and last are aligned to the ends so they stay inside). */
.legend__ticks {
  position: relative;
  height: 14px;
  margin-top: 2px;
  font-size: var(--caption-3-size);
  line-height: var(--caption-3-line);
  font-variant-numeric: tabular-nums;
  color: var(--display-subtle-01);
}

.legend__ticks span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  white-space: nowrap;
}

.legend__ticks span:first-child {
  transform: none;
}

.legend__ticks span:last-child {
  transform: translateX(-100%);
}

/* Opacity slider for the hexagon colours: label · slider · value. */
.opacity-control {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--caption-3-size);
  line-height: var(--caption-3-line);
  font-weight: var(--weight-medium);
  color: var(--display-subtle-01);
}

.opacity-control .range {
  flex: 1;
  min-width: 0;
}

.opacity-control output {
  min-width: 3.5ch;
  text-align: right;
}

.opacity-control[hidden] {
  display: none;
}

.legend__numbers {
  /* Low (left) · Medium (centred under the middle box) · High (right) */
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  font-size: var(--caption-3-size);
  line-height: var(--caption-3-line);
  font-weight: var(--weight-medium);
  color: var(--display-subtle-02);
}

.legend__numbers span:last-child {
  text-align: right;
}

/* ---------- Right-hand tools (bottom right) ----------
   Ask AI on top, then location, basemap and zoom buttons. */
.map-tools {
  position: absolute;
  z-index: 2;
  right: 13px;
  bottom: 12.6px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

/* The column is as wide as the "Ask AI" button, so its empty area
   reaches over MapLibre's attribution (i) button. Let clicks pass
   through the empty area; the buttons themselves stay clickable. */
.map-tools {
  pointer-events: none;
}

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

.map-tools__buttons {
  display: flex;
  flex-direction: column;
  gap: 7.2px;
}

/* Ask AI pill. */
.ask-ai {
  position: static;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: var(--radius-tile);
  font-weight: var(--weight-medium);
}

.ask-ai[hidden] {
  display: none;
}

/* Small square white map button (24 × 24). */
.map-btn {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-btn);
  background: var(--surface-base);
}

.map-btn:hover,
.ask-ai:hover {
  background: var(--grey-50);
}

/* Basemap button while the orthophoto is shown. */
.map-btn[aria-pressed="true"] {
  background: var(--green-100);
}

/* Zoom in / out joined into one block with a thin divider. */
.zoom-group {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-btn);
  overflow: hidden;
}

.zoom-group .map-btn {
  border-radius: 0;
}

.zoom-group .map-btn + .map-btn {
  border-top: 0.667px solid var(--highlight-grey-10);
}

/* ---------- MapLibre's own controls ----------
   Only the scale bar and attribution are used. They sit at the
   bottom right, moved left so they don't cover our buttons. */
.maplibregl-ctrl-bottom-right {
  right: 44px;
  z-index: 3; /* the opened attribution is drawn above the map buttons */
}

.maplibregl-ctrl-scale {
  font-family: var(--font-family);
  font-size: var(--caption-3-size);
  color: var(--grey-800);
  border-color: var(--grey-800);
  background: rgba(255, 255, 255, 0.8);
}

.maplibregl-ctrl-attrib {
  font-family: var(--font-family);
  font-size: var(--caption-3-size);
}
