/* The bus and route on the map, shared by the web page and the mobile app's map view. Shape changes with state as well as colour. */
.bus-marker { background: transparent; border: 0; }
.bus-marker-body { position: relative; width: 36px; height: 36px; }
.bus-marker-heading { position: absolute; inset: 0; width: 36px; height: 36px; transform-origin: 50% 50%; fill: #071B35; }
.bus-marker-heading-hidden { display: none; }
.bus-marker-dot { position: absolute; left: 7px; top: 7px; width: 22px; height: 22px; border-radius: 50%; background: #0866F5; border: 2px solid #FFFFFF; box-shadow: 0 0 0 2px #071B35; box-sizing: border-box; display: flex; align-items: center; justify-content: center; }
/* The bus inside the circle. A stale position greys it out with the circle. */
.bus-marker-bus { width: 12px; height: 12px; fill: #FFFFFF; }
.bus-marker-stale .bus-marker-bus { fill: #4F5F78; }
.bus-marker-delayed .bus-marker-dot { background: #FF8A00; }
.bus-marker-stale .bus-marker-dot { background: #FFFFFF; border: 3px dashed #4F5F78; box-shadow: none; }
.bus-marker-stale .bus-marker-heading { fill: #4F5F78; opacity: 0.6; }
.bus-map-stop { stroke: #071B35; stroke-width: 2; fill: #FFFFFF; fill-opacity: 1; }
.bus-map-route { stroke: #0866F5; stroke-width: 3; stroke-dasharray: 6 8; fill: none; opacity: 0.7; }

/* One renderer shows at a time. A 3D map that is still loading sits hidden behind the 2D one, so the page never goes blank. */
.bus-map { position: relative; overflow: hidden; }
/* Two classes, so MapLibre's own .maplibregl-map { position: relative }, loaded later, can't collapse the layer to no height. */
.bus-map > .bus-map-layer { position: absolute; inset: 0; z-index: 0; }
.bus-map > .bus-map-layer-loading { visibility: hidden; }

/* The same controls in 2D and 3D, on the web and in the app. 44px targets suit fingers. */
.bus-map-controls { position: absolute; top: 8px; right: 8px; z-index: 2; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; max-height: calc(100% - 16px); overflow-y: auto; }
.bus-map-group { display: flex; flex-direction: column; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 4px rgba(7, 27, 53, 0.35); }
.bus-map-group[hidden] { display: none; }
.bus-map-modes { flex-direction: row; }
.bus-map-button { min-width: 44px; min-height: 44px; padding: 0 8px; border: 0; border-bottom: 1px solid #D5DDEA; background: #FFFFFF; color: #071B35; font: 600 15px/1 system-ui, sans-serif; cursor: pointer; }
.bus-map-modes .bus-map-button { border-bottom: 0; border-right: 1px solid #D5DDEA; }
.bus-map-group .bus-map-button:last-child { border-bottom: 0; border-right: 0; }
.bus-map-button:hover { background: #EEF3FB; }
.bus-map-button:focus-visible { outline: 3px solid #0866F5; outline-offset: -3px; }
.bus-map-button[aria-pressed="true"] { background: #071B35; color: #FFFFFF; }
.bus-map-button:disabled { color: #8592A6; background: #F4F7FC; cursor: not-allowed; }
/* The 3D camera buttons sit in a row along the bottom, so that all the controls fit on a phone. */
/* Above the map provider's credit, which must stay readable. bus-map.js measures the credit, since its height varies with the provider and width. */
.bus-map > .bus-map-camera { position: absolute; left: 8px; bottom: calc(var(--bus-map-credit-height, 34px) + 6px); z-index: 2; flex-direction: row; max-width: calc(100% - 16px); overflow-x: auto; }
.bus-map-camera .bus-map-button { border-bottom: 0; border-right: 1px solid #D5DDEA; }
.bus-map-caption { position: absolute; left: 8px; top: 8px; z-index: 2; max-width: min(60%, 360px); margin: 0; padding: 6px 10px; border-radius: 8px; background: rgba(255, 255, 255, 0.92); color: #071B35; font: 13px/1.35 system-ui, sans-serif; box-shadow: 0 1px 4px rgba(7, 27, 53, 0.25); }
.bus-map-caption[hidden] { display: none; }

/* In 3D the marker lies on the map, so it needs no shadow box from MapLibre. */
.maplibregl-marker.bus-marker { width: 36px; height: 36px; }

@media (prefers-reduced-motion: reduce) {
    .bus-map-button { transition: none; }
}

/* Google's map. Its markers are page elements. Google puts a marker's bottom centre on its spot: the bus box is moved down by half so it is
   centred there, and a stop's locator pin needs no move, because its tip is at the bottom. */
.bus-map-google .bus-marker-google { position: relative; width: 56px; height: 56px; transform: translateY(50%); }
/* The round marker, where the 3D bus can't be drawn: half as big again as on the other maps, with a ring pulsing out from it. */
.bus-marker-google .bus-marker-body { position: absolute; left: 10px; top: 10px; transform: scale(1.5); }
.bus-marker-google .bus-marker-body::before {
    content: ""; position: absolute; left: 7px; top: 7px; width: 22px; height: 22px; border-radius: 50%; background: rgba(8, 102, 245, 0.35);
    animation: bus-map-pulse 1.8s ease-out infinite;
}
.bus-marker-google.bus-marker-delayed .bus-marker-body::before { background: rgba(255, 138, 0, 0.4); }
.bus-marker-google.bus-marker-stale .bus-marker-body::before { animation: none; background: none; }
@keyframes bus-map-pulse { from { transform: scale(1); opacity: 1; } to { transform: scale(2.6); opacity: 0; } }
/* The 3D bus is drawn instead: the round marker goes, the tag stays. */
.bus-marker-google.bus-marker-model .bus-marker-body { display: none; }

/* The tag above the bus: its registration in a navy bubble pointing down at it, coloured by how fresh the position is. */
.bus-map-bustag {
    position: absolute; left: 50%; bottom: calc(50% + 36px); transform: translateX(-50%); display: flex; align-items: center; gap: 6px;
    padding: 4px 12px 4px 4px; border: 2px solid #FFFFFF; border-radius: 999px; background: #071B35; color: #FFFFFF; white-space: nowrap;
    font: 800 14px/1 system-ui, sans-serif; letter-spacing: 0.02em; box-shadow: 0 4px 12px rgba(7, 27, 53, 0.4);
}
.bus-map-bustag::after {
    content: ""; position: absolute; left: 50%; top: 100%; transform: translateX(-50%); border: 8px solid transparent; border-top-color: #071B35;
}
.bus-marker-model .bus-map-bustag { bottom: calc(50% + 100px); }
.bus-map-bustag-icon { width: 26px; height: 26px; padding: 5px; box-sizing: border-box; border-radius: 50%; background: #0866F5; fill: #FFFFFF; flex: none; }
.bus-marker-delayed .bus-map-bustag-icon { background: #FF8A00; fill: #071B35; }
.bus-marker-stale .bus-map-bustag { background: #4F5F78; }
.bus-marker-stale .bus-map-bustag::after { border-top-color: #4F5F78; }
.bus-marker-stale .bus-map-bustag-icon { background: #FFFFFF; fill: #4F5F78; }

/* Stops: a locator pin with the stop's number in its head, and the stop's name on a card beside it. The start is navy, the destination
   orange, the stops between royal blue. */
.bus-map-gstop { position: relative; width: 32px; height: 42px; }
.bus-map-locator { display: block; width: 32px; height: 42px; filter: drop-shadow(0 2px 3px rgba(7, 27, 53, 0.45)); }
.bus-map-locator path { fill: #0866F5; stroke: #FFFFFF; stroke-width: 2.5; }
.bus-map-gstop-start .bus-map-locator path { fill: #071B35; }
.bus-map-gstop-end .bus-map-locator path { fill: #FF8A00; }
.bus-map-stop-pin {
    position: absolute; left: 50%; top: 16px; transform: translate(-50%, -50%); display: flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; border-radius: 50%; background: #FFFFFF; color: #071B35; font: 800 11px/1 system-ui, sans-serif;
}
.bus-map-stop-name {
    position: absolute; left: calc(100% + 2px); top: 16px; transform: translateY(-50%); display: flex; flex-direction: column; max-width: 180px;
    padding: 4px 10px 4px 8px; border-left: 4px solid #0866F5; border-radius: 8px; background: #FFFFFF; color: #071B35; white-space: nowrap;
    box-shadow: 0 2px 8px rgba(7, 27, 53, 0.28);
}
.bus-map-stop-label { overflow: hidden; text-overflow: ellipsis; font: 600 12px/1.25 system-ui, sans-serif; }
.bus-map-gstop-start .bus-map-stop-label, .bus-map-gstop-end .bus-map-stop-label { font-weight: 800; font-size: 13px; }
.bus-map-stop-kind { font: 800 10px/1.3 system-ui, sans-serif; letter-spacing: 0.06em; text-transform: uppercase; }
.bus-map-gstop-start .bus-map-stop-name { border-left-color: #071B35; }
.bus-map-gstop-start .bus-map-stop-kind { color: #071B35; }
.bus-map-gstop-end .bus-map-stop-name { border-left-color: #FF8A00; }
.bus-map-gstop-end .bus-map-stop-kind { color: #A85400; }
/* Zoomed out, only the start and destination keep their names. */
.bus-map-names-few .bus-map-gstop:not(.bus-map-gstop-start):not(.bus-map-gstop-end) .bus-map-stop-name { display: none; }

/* Where the passenger is: a navy dot with a soft halo, unlike the bus. It stays on their device. */
.bus-map-viewer { width: 16px; height: 16px; border-radius: 50%; background: #071B35; border: 3px solid #FFFFFF; box-sizing: border-box; transform: translateY(50%); box-shadow: 0 0 0 7px rgba(7, 27, 53, 0.18); }

/* The icons on Follow, Show full route and My location. */
.bus-map-icon { width: 22px; height: 22px; display: block; margin: 0 auto; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bus-map-icon .bus-map-icon-filled { fill: currentColor; stroke: none; }
.bus-map-button[aria-busy="true"] { opacity: 0.6; }

/* While Google's map loads, and when there's no position to show. */
.bus-map-loading {
    position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    background: #F4F7FC; color: #071B35; font: 600 14px/1.3 system-ui, sans-serif;
}
.bus-map-spinner { width: 32px; height: 32px; border-radius: 50%; border: 4px solid #D5DDEA; border-top-color: #0866F5; animation: bus-map-spin 0.9s linear infinite; }
@keyframes bus-map-spin { to { transform: rotate(360deg); } }
.bus-map-chip {
    position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 2; max-width: calc(100% - 140px); margin: 0; padding: 6px 12px;
    border-radius: 16px; background: rgba(7, 27, 53, 0.88); color: #FFFFFF; font: 600 13px/1.3 system-ui, sans-serif; text-align: center;
}
.bus-map-chip[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
    .bus-map-spinner { animation-duration: 3s; }
    .bus-marker-google .bus-marker-body::before { animation: none; }
}
