/* ---------------------------------------------------------------------------
   The load map and the dispatch board's map (V0640).

   Leaflet draws; this colours. Every line and dot has a class osm-map-<kind>
   (wwwroot/js/load-map.js), and each takes its colour from the theme's
   tokens, so the map follows the theme and light or dark like the rest of the
   page. A stroke set here wins over the one Leaflet writes on the path.
   --------------------------------------------------------------------------- */

.osm-map {
    width: 100%;
    height: 420px;
    min-height: 260px;
    border: var(--osm-border-width, 1px) solid var(--osm-rule);
    border-radius: var(--osm-radius);
    background: var(--osm-sunk);
    z-index: 0;
}

/* Our own basemap (osm-map-vector, load-map.js) is drawn in its own light or
   dark style. Where it is not set up (osm-map-nostreets) the lines and pins
   sit on the plain background, and a note on the map says so. */
/* Leaflet paints its container #ddd; without streets the theme's own sunk tone shows instead. */
.osm-map.leaflet-container { background: var(--osm-sunk); }
.osm-map-note {
    position: absolute;
    top: 0.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 450;
    max-width: calc(100% - 6rem);
    padding: 0.2rem 0.6rem;
    border: var(--osm-border-width, 1px) solid var(--osm-rule);
    border-radius: var(--osm-radius);
    background: var(--osm-surface);
    color: var(--osm-ink-soft);
    font-size: 0.8125rem;
    text-align: center;
    pointer-events: none;
}
.osm-map .leaflet-container,
.osm-map.leaflet-container { font: inherit; }
.osm-map .leaflet-control-attribution,
.osm-map.leaflet-container .leaflet-control-attribution {
    background: var(--osm-surface);
    color: var(--osm-ink-soft);
}
.osm-map .leaflet-control-attribution a { color: var(--osm-accent); }
.osm-map .leaflet-bar a {
    background: var(--osm-surface);
    color: var(--osm-ink);
    border-bottom-color: var(--osm-rule);
}
.osm-map .leaflet-tooltip {
    background: var(--osm-surface);
    color: var(--osm-ink);
    border: 1px solid var(--osm-rule-strong);
    box-shadow: var(--osm-shadow-sm);
}
.osm-map .leaflet-tooltip-top::before { border-top-color: var(--osm-rule-strong); }
/* Wide enough to read a truck's driver, load, step and time on a line each. */
.osm-map-tip { white-space: pre-line; min-width: 20rem; max-width: min(30rem, 80vw); font-size: 0.875rem; line-height: 1.45; }
.osm-map .leaflet-tooltip { padding: 8px 12px; }

/* Lines */
.osm-map .osm-map-line { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.osm-map .osm-map-actual { stroke: var(--osm-accent); stroke-width: 4; stroke-opacity: 0.95; }
.osm-map .osm-map-gap { stroke: var(--osm-warn); stroke-width: 3; stroke-dasharray: 6 8; stroke-opacity: 0.95; }
.osm-map .osm-map-estimated,
.osm-map .osm-map-straight { stroke: var(--osm-info); stroke-width: 4; stroke-dasharray: 10 8; stroke-opacity: 0.85; }
.osm-map .osm-map-estimated-faint,
.osm-map .osm-map-straight-faint { stroke: var(--osm-ink-mute); stroke-width: 3; stroke-dasharray: 10 8; stroke-opacity: 0.45; }
/* Lease roads (V0831): short dashes, unlike the estimated route's long ones;
   a retired one (CYOPS's map, V0928) in the alarm colour, fainter. */
.osm-map .osm-map-leaseroad { stroke: var(--osm-signal); stroke-width: 5; stroke-dasharray: 2 8; stroke-opacity: 0.95; }
.osm-map .osm-map-leaseroad-retired { stroke: var(--osm-alarm); stroke-width: 4; stroke-dasharray: 2 8; stroke-opacity: 0.6; }

/* Breadcrumbs and steps */
.osm-map .osm-map-dot { stroke: var(--osm-surface); stroke-width: 1.5; fill-opacity: 1; }
.osm-map .osm-map-crumb { fill: var(--osm-accent); }
.osm-map .osm-map-last { fill: var(--osm-signal); stroke-width: 3; }
.osm-map .osm-map-step { fill: var(--osm-surface); stroke: var(--osm-ink); stroke-width: 3; }
/* An entrance a driver proposed (V0830). */
.osm-map .osm-map-proposal { fill: var(--osm-warn); stroke: var(--osm-surface); stroke-width: 2; }
/* A map the entrance is set on: pressing it places the entrance. */
.osm-map.osm-map-pickable .leaflet-container,
.osm-map.osm-map-pickable { cursor: crosshair; }

/* Pins: the pickup, the drop-off and the board's trucks */
.osm-map-pin-host { background: transparent; border: 0; }
.osm-map-pin {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.75rem;
    height: 1.75rem;
    padding: 0 0.4rem;
    transform: translate(-50%, -50%);
    border-radius: 999px;
    border: 2px solid var(--osm-surface);
    box-shadow: var(--osm-shadow-md);
    font-weight: 700;
    font-size: 0.8rem;
    white-space: nowrap;
    cursor: pointer;
}
.osm-map-pin.osm-map-origin { background: var(--osm-signal); color: var(--osm-surface); }
.osm-map-pin.osm-map-destination { background: var(--osm-alarm); color: var(--osm-surface); }
.osm-map-pin.osm-map-entrance { background: var(--osm-info); color: var(--osm-surface); }
.osm-map-pin.osm-map-site { background: var(--osm-ink); color: var(--osm-surface); }
.osm-map-pin.osm-map-truck { background: var(--osm-accent); color: var(--osm-on-accent); font-family: var(--osm-font-mono); }
/* The energy company's map (task 01, V1479): its own trucks blue, a carrier's
   green; on either board a truck with a current safety incident red. Blue and
   green are the themes' own hauler colours (Tools/Theme/build.py), the same in
   every theme, lighter in dark mode. */
.osm-map-pin.osm-map-truck-own { background: var(--osm-haul-own); color: var(--osm-surface); font-family: var(--osm-font-mono); }
.osm-map-pin.osm-map-truck-carrier { background: var(--osm-haul-carrier); color: var(--osm-surface); font-family: var(--osm-font-mono); }
.osm-map-pin.osm-map-truck-incident { background: var(--osm-alarm); color: var(--osm-surface); font-family: var(--osm-font-mono); }
.osm-map-pin.osm-map-truck-stale,
.osm-map-pin.osm-map-truck-stale-own,
.osm-map-pin.osm-map-truck-stale-carrier,
.osm-map-pin.osm-map-truck-stale-incident {
    background: var(--osm-sunk);
    color: var(--osm-ink-mute);
    border-color: var(--osm-rule-strong);
    font-family: var(--osm-font-mono);
    opacity: 0.85;
}
/* Not heard from in 15 minutes: greyed, its border keeping its colour (V1479). */
.osm-map-pin.osm-map-truck-stale-own { border: 3px solid var(--osm-haul-own); }
.osm-map-pin.osm-map-truck-stale-carrier { border: 3px solid var(--osm-haul-carrier); }
.osm-map-pin.osm-map-truck-stale-incident { border: 3px solid var(--osm-alarm); color: var(--osm-alarm); opacity: 1; }

/* The legend under a load's map */
.osm-map-legend { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; margin-top: 0.4rem; color: var(--osm-ink-soft); }
.osm-map-legend > span { display: inline-flex; align-items: center; gap: 0.35rem; }
.osm-map-key { display: inline-block; width: 1.5rem; height: 0; border-top: 3px solid var(--osm-accent); }
.osm-map-key-gap { border-top: 3px dashed var(--osm-warn); }
.osm-map-key-planned { border-top: 3px dashed var(--osm-info); }
.osm-map-swatch { display: inline-block; width: 0.8rem; height: 0.8rem; border-radius: 50%; }
.osm-map-swatch-own { background: var(--osm-haul-own); }
.osm-map-swatch-carrier { background: var(--osm-haul-carrier); }
.osm-map-swatch-incident { background: var(--osm-alarm); }
.osm-map-key-step { width: 0.7rem; height: 0.7rem; border: 3px solid var(--osm-ink); border-radius: 50%; }
.osm-map-key-leaseroad { border-top: 4px dotted var(--osm-signal); }
.osm-map-key-leaseroad-retired { border-top: 4px dotted var(--osm-alarm); opacity: 0.7; }

/* CYOPS's lease roads (V0928): the road chosen in the list. */
.plr-row-chosen { border-color: var(--osm-accent) !important; box-shadow: inset 3px 0 0 var(--osm-accent); }

/* A load's Map tab: the map and the timeline side by side on a desk or a
   tablet held sideways, one above the other on a phone. */
.osm-load-map-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(14rem, 1fr); gap: 1rem; align-items: start; }
.osm-load-map-timeline { max-height: 480px; overflow-y: auto; }
.osm-map-timeline { list-style: none; margin: 0; padding: 0; border-inline-start: 2px solid var(--osm-rule); }
.osm-map-timeline-item { margin: 0; padding: 0; }
.osm-map-timeline-button {
    display: grid;
    grid-template-columns: 3.25rem minmax(0, 1fr);
    gap: 0 0.5rem;
    width: 100%;
    min-height: 44px;
    padding: 0.35rem 0.5rem;
    border: 0;
    background: transparent;
    color: var(--osm-ink);
    font: inherit;
    text-align: start;
    cursor: pointer;
}
.osm-map-timeline-button:hover { background: var(--osm-sunk); }
.osm-map-timeline-button:focus-visible { outline: 2px solid var(--osm-accent); outline-offset: -2px; }
.osm-map-timeline-button.is-off-map { cursor: default; }
.osm-map-timeline-button.is-off-map:hover { background: transparent; }
.osm-map-timeline-time { grid-row: span 2; color: var(--osm-ink-soft); }
.osm-map-timeline-title { font-weight: 600; }
.osm-map-timeline-detail { grid-column: 2; font-size: 0.85em; }
.osm-map-timeline-item.is-gap .osm-map-timeline-title { color: var(--osm-warn); }

/* The dispatch board's map */
.osm-board-map .osm-map { height: calc(100vh - var(--osm-dispatch-top, 240px) - 6rem); min-height: 320px; }
.osm-board-map-none { margin-top: 0.5rem; }

@media (max-width: 767.98px) {
    .osm-load-map-layout { grid-template-columns: minmax(0, 1fr); }
    .osm-map { height: 320px; }
    .osm-load-map-timeline { max-height: none; }
    .osm-board-map .osm-map { height: 60vh; }
}

/* CYOPS's live map (V0851): the map and the counts side by side on a desk,
   one above the other on a phone. */
.osm-live-layout { display: grid; grid-template-columns: minmax(0, 3fr) minmax(16rem, 1fr); gap: 1rem; align-items: start; }
.osm-live-canvas .osm-map { height: calc(100vh - 22rem); min-height: 360px; }
.osm-live-side { max-height: calc(100vh - 20rem); overflow-y: auto; }
.osm-live-counts { list-style: none; margin: 0; padding: 0; }
.osm-live-counts li { padding: 0.35rem 0; border-bottom: 1px solid var(--osm-rule); }
.osm-live-facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.15rem 0.75rem; margin: 0.5rem 0; }
.osm-live-facts dt { color: var(--osm-ink-soft); }
.osm-live-facts dd { margin: 0; }
.osm-truck-heard { margin-inline-start: 0.25rem; white-space: nowrap; }

@media (max-width: 767.98px) {
    .osm-live-layout { grid-template-columns: minmax(0, 1fr); }
    .osm-live-canvas .osm-map { height: 60vh; }
    .osm-live-side { max-height: none; }
}
