/* Map vehicles (gps-map.js VEHICLE_SVG), shared by index.html and live.html after legacy.css.
   Each vehicle is drawn from above, alone on the road like Google Maps, and turned to its heading (.gps-vehicle-turn);
   the name label above stays upright. The GPS fix is the middle of the vehicle. */
/* The box grows with the zoom (data-zoom-band on the map, GpsMap.watchZoomBand) so the vehicle stays in proportion:
   small over the whole area, larger at street level; the wall screen (rem) is a little larger and grows in TV mode.
   The drawn vehicle is about 85% of the box long. */
.gps-marker-wrap {
  --vehicle-box: 26px;
  transform: translate(-50%, calc(-100% + var(--vehicle-box) / 2));
}
[data-zoom-band="far"] .gps-marker-wrap { --vehicle-box: 21px; }
[data-zoom-band="near"] .gps-marker-wrap { --vehicle-box: 30px; }
.live-page .gps-marker-wrap { --vehicle-box: 1.75rem; }
.live-page [data-zoom-band="far"] .gps-marker-wrap { --vehicle-box: 1.4rem; }
.live-page [data-zoom-band="near"] .gps-marker-wrap { --vehicle-box: 2rem; }
.gps-marker-wrap .gps-vehicle-icon {
  width: var(--vehicle-box);
  height: var(--vehicle-box);
  overflow: visible;
  /* on the upright box, so the shadow falls the same way whichever way the vehicle faces */
  filter: drop-shadow(1px 2px 1.6px rgba(0, 0, 0, .45));
}
.gps-vehicle-turn { width: 100%; height: 100%; }
.gps-vehicle-icon svg { overflow: visible; }
.gps-legend .gps-vehicle-icon { width: 24px; height: 24px; filter: none; }

/* Light bar on refer/EMS vehicles: red and blue take turns. A lit lamp glows white-hot, lights the roof around it and
   throws its colour in a glow around the body. Each colour flashes 1⅔ times a second, under the 3-a-second flash limit,
   over a small area. In the legend and with reduced motion both lamps stay lit with a soft glow and no aura. */
.gps-siren-halo { opacity: .45; }
.gps-siren-aura { opacity: 0; }
.gps-marker-wrap .gps-siren-red { animation: gps-lamp-red .6s steps(1) infinite; }
.gps-marker-wrap .gps-siren-blue { animation: gps-lamp-blue .6s steps(1) infinite -.3s; }
.gps-marker-wrap :is(.gps-siren-halo, .gps-siren-aura) { animation: gps-halo .6s steps(1) infinite; }
.gps-marker-wrap :is(.gps-siren-halo, .gps-siren-aura).is-blue { animation-delay: -.3s; }
@keyframes gps-lamp-red { 0% { fill: #fff0f0; } 50% { fill: #7f1d1d; } }
@keyframes gps-lamp-blue { 0% { fill: #eef6ff; } 50% { fill: #1e3a8a; } }
@keyframes gps-halo { 0% { opacity: 1; } 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .gps-marker-wrap :is(.gps-siren-red, .gps-siren-blue, .gps-siren-halo, .gps-siren-aura) { animation: none; }
}

/* Name label at 93% of its old size (user's steps 2026-10-29: half, after a warning that the text is only ~4px, then +20%, +30%, +20%):
   legacy style.css had .45rem text, .05rem .4rem padding, 7px corners and a 2px route-colour outline on a mission;
   the wall screen sizes it in live.css */
.gps-marker-wrap .gps-marker { font-size: .42rem; padding: .048rem .37rem; border-radius: 7px; }
.gps-marker-wrap .gps-marker.gps-on-mission { border-width: 1px; }

/* Label colour on the way out (ไปส่ง, GpsMap.icon): the case colour picked at dispatch; on the way back (กลับ) the label keeps
   its GPS state colour. A thin white ring inside keeps the route-colour outline visible on a label of the same colour.
   Over the limit the label blinks red/white once a second, so a red case is never read as speeding; with reduced motion
   it stays white with red text and a red ring. All text is at least 6:1 on its ground. */
.gps-marker-wrap .gps-marker.gps-on-mission:is(.gps-case-red, .gps-case-pink, .gps-case-yellow, .gps-case-green) {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .75), 0 1px 4px rgba(0, 0, 0, .35);
}
.gps-marker-wrap .gps-marker.gps-on-mission.gps-case-red { background: #b91c1c; color: #fff; }
.gps-marker-wrap .gps-marker.gps-on-mission.gps-case-pink { background: #be185d; color: #fff; }
.gps-marker-wrap .gps-marker.gps-on-mission.gps-case-yellow { background: #facc15; color: #422006; }
.gps-marker-wrap .gps-marker.gps-on-mission.gps-case-green { background: #4ade80; color: #052e16; }
.gps-marker-wrap .gps-marker.gps-overspeed { animation: gps-overspeed-blink 1s steps(1) infinite, gps-pulse 1s ease-in-out infinite alternate; }
@keyframes gps-overspeed-blink { 0% { background-color: #dc2626; color: #fff; } 50% { background-color: #fff; color: #b91c1c; } }
@media (prefers-reduced-motion: reduce) {
  .gps-marker-wrap .gps-marker.gps-overspeed { animation: none; background: #fff; color: #b91c1c; box-shadow: 0 0 0 2px #dc2626; }
}

/* Group labels (GpsMap.renderGroups): vehicles whose labels would overlap share one label above them, its tail pointing at
   them (or at the hospital they stand at); their own labels hide, their drawings stay. Colours: console.css (app), live.css */
.gps-marker-wrap.is-grouped .gps-marker { display: none; }
.gps-group-anchor { transform: translate(-50%, calc(-100% - .7rem)); }
.gps-group-anchor.at-hospital { transform: translate(-50%, calc(-100% - 2.9rem)); }
.gps-group {
  position: relative; display: block; width: max-content; max-width: 16rem; margin: 0; padding: .45rem .6rem .5rem;
  border-radius: .6rem; font: inherit; font-size: .78rem; line-height: 1.4; text-align: left; cursor: pointer;
}
.gps-group::after {
  content: ''; position: absolute; left: 50%; bottom: -.38rem; width: .7rem; height: .7rem; margin-left: -.35rem;
  transform: rotate(45deg); background: inherit; border-right: inherit; border-bottom: inherit;
}
/* Closed it is one line: the count and a state dot per vehicle. Pointing at it (or keyboard focus) opens the list above */
.gps-group { padding: .3rem .6rem; border-radius: 999px; }
.gps-group-pill { display: flex; align-items: center; gap: .45rem; }
.gps-group-dots { display: inline-flex; align-items: center; gap: .2rem; }
.gps-group-dots small { font-size: inherit; font-weight: 600; }
.gps-group-list { display: none; margin-bottom: .3rem; padding-bottom: .3rem; border-bottom: 1px solid currentColor; border-bottom-color: rgba(127, 127, 127, .3); }
@media (hover: hover) {
  .gps-group:hover { border-radius: .6rem; }
  .gps-group:hover .gps-group-list { display: block; }
}
.gps-group:focus-visible { border-radius: .6rem; }
.gps-group:focus-visible .gps-group-list { display: block; }
.gps-group-head { display: block; min-width: 0; overflow: hidden; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.gps-group-head small { font-size: inherit; font-weight: 600; }
.gps-group-row { display: flex; align-items: center; gap: .4rem; min-width: 0; white-space: nowrap; }
.gps-group-row b { flex-shrink: 0; font-family: 'IBM Plex Mono', 'Kanit', ui-monospace, monospace; font-weight: 600; }
.gps-group-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.gps-group-row .gps-state-dot { flex-shrink: 0; }
.gps-group-more { display: block; font-weight: 600; white-space: nowrap; }

/* A car in for repair (admin "แจ้งซ่อมบำรุง", 2026-11-11): orange label at full strength with a second line saying so;
   dark brown on orange is 7:1. Wins over the GPS state colour on both maps and the wall screen. */
.gps-marker-wrap .gps-marker.gps-repair,
.live-page .gps-marker-wrap .gps-marker.gps-repair { background: #FDBA74; color: #431407; border-color: #fff; opacity: 1; animation: none; }
.gps-marker-wrap .gps-marker-repair { display: block; font-size: inherit; font-weight: 600; }
