/* =========================================================================
   The map page (map-page.js, map.js, map-list.js, map-search.js,
   map-controls.js): the map with its controls beside a 360 px panel —
   search, Layers, Filters, Base maps — collapsible to a rail; Map / List /
   Split; the hover preview; OpenLayers' chrome in the console's colours.
   Tokens only.
   ========================================================================= */
.arc-map-page-root { display: block; height: 100%; }
#page-content:has(.arc-map-page-root) { padding: 0; max-width: none; height: 100%; }
#main:has(.arc-map-page-root) { overflow: hidden; }

/* ---- The grid: map (+ list) beside the panel ------------------------------ */
.map-page {
  --panel-w: 360px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--panel-w);
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "map panel";
  height: 100%; min-height: 0;
}
.map-page.panel-collapsed { --panel-w: 64px; }
.map-page.panel-hidden { --panel-w: 0px; }              /* a lot's drawer is up: no panel, no rail */
.map-page.panel-hidden .map-panel { display: none; }
.map-page[data-view="list"] { grid-template-areas: "list panel"; }
.map-page[data-view="list"] .map-page-map { display: none; }
.map-page[data-view="split"] { grid-template-rows: minmax(0, 1fr) minmax(0, 320px); grid-template-areas: "map panel" "list panel"; }
.map-page:not([data-view="list"]):not([data-view="split"]) .map-list-pane { display: none; }
.map-page-map { grid-area: map; position: relative; min-width: 0; min-height: 0; background: var(--bg-2); }
.map-list-pane { grid-area: list; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--bg-0); border-top: 1px solid var(--line); }
.map-page[data-view="list"] .map-list-pane { border-top: 0; }
arc-map, .arc-map-canvas { display: block; position: absolute; inset: 0; }
arc-map .arc-map-canvas { cursor: default; }
arc-map.is-over-feature .arc-map-canvas { cursor: pointer; }
arc-map.is-box-select .arc-map-canvas { cursor: crosshair; }   /* Shift held: a drag draws a box */
.map-hint {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  padding: 6px 12px; background: var(--bg-2); border: 1px solid var(--amber-line); border-radius: var(--r-sm);
  color: var(--amber); font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.06em; z-index: 5; white-space: nowrap;
}

/* Fullscreen: the chrome folds away, the map takes the window. Esc returns. */
#app.map-full { grid-template-columns: 0 1fr; grid-template-rows: 0 1fr; }
#app.map-full #toolbar, #app.map-full #sidebar, #app.map-full .toolbar-brand { display: none; }

/* ---- Controls over the map ------------------------------------------------- */
.map-controls { position: absolute; top: 12px; left: 12px; z-index: 6; display: flex; flex-direction: column; gap: 8px; }
.map-controls-group { display: flex; flex-direction: column; border: 1px solid var(--line-bold); border-radius: var(--r-sm); overflow: hidden; box-shadow: var(--shadow-md); }
.map-ctl {
  width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-2); color: var(--fg); border: 0; border-bottom: 1px solid var(--line); cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.map-ctl:last-child { border-bottom: 0; }
.map-ctl:hover { background: var(--bg-3); color: var(--amber); }
.map-ctl:disabled { color: var(--fg-faint); cursor: not-allowed; background: var(--bg-2); }
.map-ctl:focus-visible { outline: 2px solid var(--amber-line); outline-offset: -2px; }
/* The legend in the panel's Layers section: rules, then the label key (ARB) and the notes. */
.legend-key { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 12px; color: var(--fg-mute); line-height: 1.4; }
.legend-row + .legend-key, .layer-legend .legend-key { margin-top: 10px; }
.legend-key-row { display: contents; }
.legend-key dt { font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.04em; color: var(--fg); white-space: nowrap; align-self: baseline; }
.legend-key dd { margin: 0; }
.legend-key + .legend-notes { margin-top: 10px; }

/* OpenLayers' own: scale line and attribution, small and in the palette. */
.ol-scale-line { display: flex; align-items: flex-end; gap: 10px; background: var(--bg-2); border-radius: var(--r-xs); bottom: 10px; left: 12px; padding: 2px 6px 2px 4px; }
.ol-scale-line-inner { border: 1px solid var(--fg-mute); border-top: none; color: var(--fg-mute); font-family: var(--f-mono); font-size: 10px; }
.map-scale-ratio { color: var(--fg-mute); font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.04em; white-space: nowrap; padding-bottom: 1px; }   /* "1 : 4,500", halves each zoom step */
.ol-attribution { background: var(--bg-2); font-size: 10px; bottom: 0; right: 0; border-radius: var(--r-xs) 0 0 0; }
.ol-attribution ul { color: var(--fg-dim); text-shadow: none; font-family: var(--f-mono); font-size: 9px; padding: 1px 6px; }
.ol-attribution a { color: var(--fg-mute); }
.ol-attribution button { display: none; }

/* ---- The panel -------------------------------------------------------------- */
.map-panel {
  grid-area: panel; display: flex; flex-direction: column; min-height: 0; min-width: 0; position: relative;   /* the seam tab hangs off its edge */
  background: var(--bg-1); border-left: 1px solid var(--line);
}
.map-panel-head { display: flex; align-items: center; gap: 8px; padding: 12px 10px 10px 16px; border-bottom: 1px solid var(--line); }
.map-panel-title { flex: 1 1 auto; min-width: 0; }
.map-panel-head h1 { font-size: 17px; font-weight: 800; letter-spacing: -0.015em; white-space: nowrap; }
.map-panel-head h1::first-letter { color: var(--amber); }
.map-panel-site { font-size: 12px; color: var(--fg-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-panel-body { overflow-y: auto; min-height: 0; flex: 1 1 auto; }
.map-panel-rail { display: none; }
.panel-collapsed .map-panel-head, .panel-collapsed arc-map-search, .panel-collapsed .map-panel-body { display: none; }
/* Collapsed: a column of labelled tabs, not a sliver of icons — the panel is where the layers, Colour by and
   filters live, and a person who collapsed it must see the way back. */
.panel-collapsed .map-panel-rail { display: flex; flex-direction: column; align-items: stretch; gap: 2px; padding: 6px 4px; background: var(--bg-2); border-left: 1px solid var(--line-bold); }
.rail-tab {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 9px 2px 8px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--fg-mute); cursor: pointer; font-family: var(--f-mono); font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase; line-height: 1;
  transition: background var(--t-fast), color var(--t-fast);
}
.rail-tab:hover { background: var(--bg-3); color: var(--amber); }
.rail-tab:focus-visible { outline: 2px solid var(--amber-line); outline-offset: -2px; }
.rail-tab.is-on { color: var(--amber); }
.panel-collapsed [data-panel-toggle] { display: none; }   /* only while the panel is open; a rail tab brings it back */

/* The search at the top of the panel, results inline under it. */
arc-map-search { display: block; position: relative; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.map-search-field { position: relative; display: flex; align-items: center; }
.map-search-field .icon { position: absolute; left: 10px; color: var(--fg-dim); pointer-events: none; }
.map-search-field input[type="search"] { width: 100%; min-width: 0; padding-left: 30px; background: var(--bg-0); }
.map-search-results {
  position: absolute; left: 12px; right: 12px; top: calc(100% - 6px); z-index: 20; max-height: 320px; overflow-y: auto;
  background: var(--bg-2); border: 1px solid var(--line-bold); border-radius: var(--r-md); box-shadow: var(--shadow-md); padding: 4px;
}
.map-search-hit { display: flex; flex-direction: column; gap: 1px; padding: 7px 10px; border-radius: var(--r-xs); cursor: pointer; }
.map-search-hit.is-active { background: var(--bg-hover); }
.map-search-title { font-weight: 600; font-size: 13px; }
.map-search-sub { font-size: 12px; color: var(--fg-mute); font-family: var(--f-mono); }
.map-search-layer { font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--fg-dim); }
.map-search-empty { padding: 10px; color: var(--fg-mute); font-size: 13px; text-align: center; }

/* Sections: Layers, Filters, Base maps. */
.panel-section { border-bottom: 1px solid var(--line-soft); }
.panel-section-head {
  width: 100%; display: flex; align-items: center; gap: 8px; padding: 11px 14px 11px 16px;
  background: none; border: 0; color: var(--fg); text-align: left; cursor: pointer;
  font: 700 12.5px/1.2 var(--f-sans); letter-spacing: 0.01em;
}
.panel-section-head .icon { color: var(--fg-dim); }
.panel-section-head:hover { background: var(--bg-2); }
.panel-section-head:hover .icon { color: var(--amber); }
.panel-section-note { margin-left: auto; font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--amber); }
.panel-section-caret { transition: transform var(--t-fast); }
.panel-section.is-open .panel-section-caret { transform: rotate(180deg); }
.panel-section-body { display: none; padding: 2px 16px 14px; }
.panel-section.is-open .panel-section-body { display: block; }
.panel-section.has-active .panel-section-head .icon:first-child { color: var(--amber); }

/* A layer: switch · name · count; "Colour by"; the legend with counts. */
.layer-block { padding: 8px 0 10px; border-bottom: 1px dashed var(--line); }
.layer-block:last-child { border-bottom: 0; padding-bottom: 4px; }
.layer-head { display: flex; align-items: center; gap: 10px; }
.layer-head .switch { flex: none; }
.layer-name { font-weight: 700; letter-spacing: 0.01em; }
.layer-count { margin-left: auto; font-family: var(--f-mono); font-size: 11px; color: var(--fg-mute); white-space: nowrap; }
.layer-theme { display: flex; align-items: center; gap: 10px; margin: 10px 0 0; }
.layer-theme .section-label { margin: 0; white-space: nowrap; }
.layer-theme select { flex: 1 1 auto; min-width: 0; }
.layer-theme-one { font-size: 12.5px; color: var(--fg-mute); }
.layer-legend { margin-top: 8px; display: flex; flex-direction: column; gap: 3px; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--fg-mute); }
.legend-row.is-empty { opacity: 0.5; }
.legend-swatch { width: 14px; height: 14px; border: 1px solid var(--line-bold); border-radius: var(--r-xs); background: var(--swatch, transparent); flex: none; }
.legend-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-count { font-size: 11px; color: var(--fg-dim); }
.legend-notes { margin: 10px 0 0; padding: 0 0 0 14px; font-size: 12px; color: var(--fg-dim); line-height: 1.45; }
.legend-notes li { margin: 2px 0; }

/* Filters: chips first, then the controls, then Clear. */
.filter-block { padding-top: 8px; }
.filter-block .section-label { margin: 6px 0 4px; }
arc-chips[data-filter-chips] { margin: 8px 0 4px; }
.map-filter { margin: 0 0 12px; border: none; padding: 0; min-width: 0; }
.map-filter legend, .map-filter > span:first-child {
  font-family: var(--label-font); font-size: var(--label-size); text-transform: var(--label-case); letter-spacing: var(--label-tracking); color: var(--fg-mute); margin-bottom: 6px; padding: 0;
}
.map-filter-options { display: flex; flex-direction: column; gap: 3px; max-height: 150px; overflow-y: auto; padding: 2px 0; }
.map-filter-options .form-check-label { font-size: 12.5px; }
.map-filter-range { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filter-foot { display: flex; justify-content: flex-end; }

/* Base maps: switches; a slider for the site-plan tiles. */
.tile-block { padding: 6px 0; }
.tile-row { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.tile-name { font-size: 13px; }
.tile-opacity { display: flex; align-items: center; gap: 10px; margin: 6px 0 0 48px; }
.tile-opacity .section-label { margin: 0; }
.tile-opacity input[type="range"] { flex: 1 1 auto; accent-color: var(--amber); }

/* ---- The list (map-list.js) ------------------------------------------------- */
arc-map-list { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.map-list-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--bg-1); }
.map-list-title { font-weight: 700; }
arc-map-list arc-data-table { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
arc-map-list .dt-scroll { flex: 1 1 auto; min-height: 0; border: 0; border-radius: 0; background: var(--bg-0); }
arc-map-list .dt-foot { padding: 6px 12px; border-top: 1px solid var(--line); background: var(--bg-1); }
arc-map-list .skeleton-table { margin: 12px; }
arc-map-list .empty-state { margin: 16px; }

/* ---- The hover preview ------------------------------------------------------ */
.arc-map-preview {
  width: max-content; max-width: 380px; padding: 10px 12px;   /* room for the 136 px thumbnail beside three lines of text */
  background: var(--bg-2); color: var(--fg); border: 1px solid var(--line-bold); border-radius: var(--r-md);
  box-shadow: var(--shadow-md); font-size: 12.5px; pointer-events: none;
}
.preview-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }   /* room under the badge before the picture (Eric, 2026-11-02) */
.preview-title { font-weight: 700; font-size: 13px; }
.preview-body { display: flex; gap: 10px; align-items: flex-start; }
.preview-lines { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.preview-lines > div { display: flex; gap: 8px; }
.preview-k { font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-dim); min-width: 56px; padding-top: 2px; }
.preview-v { color: var(--fg); }
.preview-thumb { width: 136px; height: 102px; object-fit: cover; border-radius: var(--r-xs); border: 1px solid var(--line); flex: none; }   /* a touch larger than the 96 × 72 first cut (Eric, 2026-11-02); the thumbnails are 300 px boxes */
/* The colour scheme under the card (ARB): materials as picture tiles, the house colours as one block with named bands. */
.preview-scheme { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line-soft); }
.preview-scheme-name { display: flex; gap: 8px; margin-bottom: 6px; }
.preview-scheme-body { display: flex; flex-wrap: nowrap; gap: 6px; align-items: stretch; }   /* one row always: the tiles shrink to share it */
.preview-material { margin: 0; position: relative; flex: 1 1 0; min-width: 0; max-width: 150px; height: 96px; border-radius: var(--r-xs); overflow: hidden; border: 1px solid var(--line-bold); }
.preview-material img { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview-material figcaption { position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 4px; font-size: 11px; font-weight: 600; text-align: center; color: #fff; background: rgba(0, 0, 0, 0.45); }
.preview-house { flex: 1 1 0; min-width: 0; max-width: 150px; height: 96px;   /* the tiles share the row equally, never wrapping (Eric, 2026-11-02) */ border-radius: var(--r-xs); border: 1px solid var(--line-bold); padding: 6px 8px; display: flex; flex-direction: column; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; }
.preview-band { padding: 2px 6px; border-radius: 2px; text-align: center; line-height: 1.3; }

/* ---- Narrow: the panel under the map; a bottom sheet of a list ------------- */
@media (max-width: 900px) {
  .map-page, .map-page[data-view="split"], .map-page[data-view="list"] {
    grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 300px);
    grid-template-areas: "map" "panel";
  }
  .map-page[data-view="list"] { grid-template-areas: "list" "panel"; }
  .map-page[data-view="split"] { grid-template-rows: minmax(0, 1fr) minmax(0, 240px) minmax(0, 200px); grid-template-areas: "map" "list" "panel"; }
  .map-page.panel-collapsed { grid-template-rows: minmax(0, 1fr) 60px; }
  .map-page.panel-hidden, .map-page.panel-hidden[data-view="list"] { grid-template-rows: minmax(0, 1fr) 0; }
  .map-page.panel-hidden[data-view="split"] { grid-template-rows: minmax(0, 1fr) minmax(0, 240px) 0; }
  .map-panel { border-left: none; border-top: 1px solid var(--line); }
  .panel-collapsed .map-panel-rail { flex-direction: row; justify-content: center; }
  .map-panel-head h1 { font-size: 15px; }
}
