/* Leaflet and its plugins on the clearGRID tokens.

   Loaded after every Leaflet and plugin stylesheet (base.html), so the same
   selectors win. Only colours change: in the light scheme each value is the
   plugin default or its --cg-* equivalent, so pages look as before; in the
   dark scheme the map chrome follows the tokens. Shadows stay black, which
   reads in both schemes. leaflet-draw's toolbar sprite and leaflet-measure's
   icons are dark PNG/SVG artwork and keep a light button behind them. */

/* ---- Leaflet core ---- */

.leaflet-container {
  background: var(--cg-map-bg);
}

.leaflet-container a {
  color: var(--row-map-link);
}

.leaflet-zoom-box {
  background: color-mix(in srgb, var(--cg-card) 50%, transparent);
}

.leaflet-bar a,
.leaflet-bar a:hover {
  background-color: var(--cg-map-control);
  border-bottom-color: var(--cg-border);
  color: var(--cg-on-map-control);
}

.leaflet-bar a:hover {
  background-color: var(--cg-surface);
}

.leaflet-bar a.leaflet-disabled {
  background-color: var(--cg-surface);
  color: var(--row-map-faint);
}

.leaflet-control-layers,
.leaflet-control-layers-expanded {
  background: var(--cg-map-control);
  color: var(--cg-on-map-control);
}

.leaflet-control-layers-separator {
  border-top-color: var(--cg-border);
}

.leaflet-container .leaflet-control-attribution {
  background: color-mix(in srgb, var(--cg-card) 70%, transparent);
}

.leaflet-control-attribution,
.leaflet-control-scale-line {
  color: var(--cg-text);
}

.leaflet-control-scale-line,
.leaflet-control-scale-line:not(:first-child),
.leaflet-control-scale-line:not(:first-child):not(:last-child) {
  border-color: var(--cg-control-border);
  background: color-mix(in srgb, var(--cg-card) 50%, transparent);
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--cg-card);
  color: var(--cg-text);
}

.leaflet-container a.leaflet-popup-close-button {
  color: var(--row-map-faint);
}

.leaflet-container a.leaflet-popup-close-button:hover {
  color: var(--row-map-subtle);
}

.leaflet-popup-scrolled {
  border-color: var(--cg-border);
}

.leaflet-div-icon {
  background: var(--cg-card);
  border-color: var(--cg-control-border);
}

.leaflet-tooltip {
  background-color: var(--cg-card);
  border-color: var(--cg-card);
  color: var(--cg-text);
}

.leaflet-tooltip-top:before {
  border-top-color: var(--cg-card);
}

.leaflet-tooltip-bottom:before {
  border-bottom-color: var(--cg-card);
}

.leaflet-tooltip-left:before {
  border-left-color: var(--cg-card);
}

.leaflet-tooltip-right:before {
  border-right-color: var(--cg-card);
}

/* ---- Basemaps ----
   The OSM street tiles take the theme's street filter (dark in the dark
   scheme). Satellite and ROW inspection imagery are photographs: never
   inverted, only dimmed in dark by the imagery filters. Vector overlays sit
   in other panes and are not filtered. */

.row-tiles-street {
  filter: var(--cg-tiles-street-filter);
}

.row-tiles-satellite {
  filter: var(--cg-tiles-satellite-filter);
}

.row-tiles-imagery {
  filter: var(--cg-tiles-row-imagery-filter);
}

/* ---- leaflet-panel-layers 1.3.1 ---- */

.leaflet-panel-layers {
  background: color-mix(in srgb, var(--cg-card) 50%, transparent);
  color: var(--cg-text);
}

.leaflet-panel-layers-separator {
  border-top-color: color-mix(in srgb, var(--cg-text) 30%, transparent);
}

.leaflet-panel-layers-icon {
  background: var(--cg-card);
}

.leaflet-panel-layers-group {
  border-color: color-mix(in srgb, var(--cg-text) 30%, transparent);
  background: color-mix(in srgb, var(--cg-card) 60%, transparent);
}

.leaflet-panel-layers-overlays .leaflet-panel-layers-item {
  background: var(--cg-card);
  border-color: color-mix(in srgb, var(--cg-text) 30%, transparent);
}

.leaflet-panel-layers-overlays .leaflet-panel-layers-item:hover {
  border-color: var(--cg-control-border);
}

/* ---- leaflet-contextmenu 1.4.0 ---- */

.leaflet-contextmenu {
  background-color: var(--cg-card);
}

.leaflet-contextmenu a.leaflet-contextmenu-item {
  color: var(--cg-text);
}

.leaflet-contextmenu a.leaflet-contextmenu-item.over {
  background-color: var(--cg-hover);
  border-top-color: transparent;
  border-bottom-color: transparent;
}

.leaflet-contextmenu-separator {
  border-bottom-color: var(--cg-border);
}

/* ---- leaflet-measure (vendored) ---- */

.leaflet-control-measure,
.leaflet-measure-resultpopup {
  color: var(--cg-text);
}

.leaflet-control-measure {
  background: var(--cg-map-control);
}

.leaflet-control-measure h3,
.leaflet-measure-resultpopup h3 {
  border-bottom-color: var(--cg-border);
}

.leaflet-control-measure .tasks,
.leaflet-measure-resultpopup .tasks {
  border-top-color: var(--cg-border);
}

.leaflet-control-measure .results .group {
  border-top-color: var(--cg-border);
}

.leaflet-control-measure .coorddivider,
.leaflet-measure-resultpopup .coorddivider,
.leaflet-control-measure .results .heading {
  color: var(--row-map-subtle);
}

.leaflet-control-measure a.start,
.leaflet-control-measure a.cancel,
.leaflet-control-measure a.finish,
.leaflet-control-measure a.link,
.leaflet-measure-resultpopup a.zoomto,
.leaflet-measure-resultpopup a.deletemarkup,
.leaflet-measure-resultpopup a.link {
  color: var(--row-measure-link);
}

/* The measure toggle and the draw toolbar draw dark icons from PNG/SVG
   sprites: their buttons keep a light face (dimmed in dark). */
.leaflet-control-measure .leaflet-control-measure-toggle,
.leaflet-control-measure .leaflet-control-measure-toggle:hover,
.leaflet-draw-toolbar a,
.leaflet-draw-toolbar a:hover {
  background-color: var(--row-map-sprite-face);
}

/* ---- leaflet-draw 1.0.4 ---- */

.leaflet-mouse-marker {
  background-color: var(--cg-card);
}

/* ---- maplibre-gl (status pages) ---- */

.maplibregl-ctrl-attrib {
  background-color: color-mix(in srgb, var(--cg-card) 50%, transparent);
  color: var(--cg-text);
}
