/* Leaflet basemap treatment. Shared by the vehicle map and vehicle detail pages. */

/*
 * Dark themes reuse the OpenStreetMap street tiles rather than loading a second tile set.
 * A dedicated dark basemap (CARTO Dark Matter) was tried and dropped: it draws no
 * buildings, no green space and almost no water, so the dark themes lost most of the map
 * instead of recolouring it.
 *
 * The tiles are dimmed rather than inverted. Inverting gives a true night map - dark ground,
 * light roads - but it was too dark and lost the map's own colour language. Dimming keeps
 * OSM's cartography intact: parks stay green, water stays blue, roads stay pale, everything
 * just sits at a lower level so it does not glare inside a dark UI. The trade-off is that
 * place labels stay dark-on-grey rather than flipping to light-on-dark.
 *
 * To retune, edit --basemap-filter in the theme files and adjust these three:
 *   brightness()  overall level      lower = darker
 *   saturate()    colour strength    lower = greyer
 *   contrast()    road/ground separation
 *
 * Scoped to the street layer's own class, so satellite and hybrid imagery, vector overlays
 * and the vehicle markers are untouched - a filter on the tile pane would dim the aerial
 * imagery too.
 *
 * Which themes dim, and by how much, is carried by --basemap-filter rather than by
 * listing theme names here. Naming them meant a new dark theme silently got a glaring
 * bright map until someone noticed - which is exactly what happened when the two
 * dark-brand variants were added. A theme now opts in by declaring the token.
 */
.fh-basemap-street {
    filter: var(--basemap-filter, none);
}

/*
 * Map marker palette.
 *
 * These are deliberately NOT theme tokens. A marker sits on map tiles, not on an app
 * surface, and the cartography is the same in every theme - only its brightness changes.
 * Driving the tones from --success / --warning / --text-secondary made them swing wildly:
 * idle resolved to #7a7a7a in light and #b0b0b0 in dark, both of which vanish against pale
 * OSM tiles, and info went to #00567a in dark, nearly black. These five are picked once,
 * for legibility over cartography, and stay put.
 */
:root {
    --map-tone-ok: #1e8e3e;
    --map-tone-warn: #e8710a;
    --map-tone-error: #d93025;
    --map-tone-info: #1a73e8;
    /* Idle still has to be seen. A mid slate reads clearly on pale tiles and on the
       dimmed dark map, without competing with the states that need attention. */
    --map-tone-idle: #546e7a;
}

.is-tone-ok { --map-tone: var(--map-tone-ok); }
.is-tone-warn { --map-tone: var(--map-tone-warn); }
.is-tone-error { --map-tone: var(--map-tone-error); }
.is-tone-info { --map-tone: var(--map-tone-info); }
.is-tone-idle { --map-tone: var(--map-tone-idle); }

/*
 * Vehicle marker. Shared by the vehicle map and the vehicle detail page, which had
 * near-identical copies that had already drifted apart. The white ring and drop shadow
 * are what make it readable over any cartography; --map-tone carries the state.
 */
.vehicle-marker-badge {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-circle);
    border: 3px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: var(--text-xs);
    line-height: 1;
    background-color: var(--map-tone, var(--map-tone-info));
}
