:root { color-scheme: light; }
* { box-sizing: border-box; }
body { margin: 0; padding: 16px; background: #f9f9f7; color: #0b0b0b;
       font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
main { max-width: 1100px; margin: 0 auto; }
h1 { font-size: 22px; font-weight: 400; margin: 8px 0; }
h2 { font-size: 17px; margin: 24px 0 4px; }
p { margin: 4px 0; color: #52514e; }
a { color: #2a78d6; }

/* Legend of a drive page */
/* always one line: on a narrow screen it scrolls sideways */
.legend { list-style: none; padding: 0; margin: 12px 0; display: flex; flex-wrap: nowrap; gap: 18px;
          overflow-x: auto; font-size: 13px; color: #52514e; }
.legend li { flex: none; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.swatch { flex: none; }

/* Map and charts of a drive page */
.figure { background: #ebe9e3; border: 1px solid rgba(11, 11, 11, 0.10); border-radius: 6px; overflow: hidden; }
#map svg { display: block; width: 100%; height: 100%; }
#map svg path { vector-effect: non-scaling-stroke; }  /* lines keep their width on screen while zooming */
/* only car boxes take clicks: lines and labels on top of a box let the click through */
#map svg g[id^="line2d"], #map svg g[id^="text_"] { pointer-events: none; }
#map svg g[id^="car_"] { cursor: pointer; }
#map svg g.selected path { stroke-width: 3px !important; }  /* the box whose info is shown; matplotlib sets the width inline */

/* Top of a drive page: fills the window (minus the body padding), the map takes the height left */
.map-page { min-height: calc(100vh - 32px); display: flex; flex-direction: column; }
/* heading with the mode selector on the left, "All drives" on the right */
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0 16px; }
/* Drive page title: drive name, vehicle count, "Prediction method:", or the text of a drive without samples */
.page-head h1 { font-size: 16px; font-weight: 600; }

/* Map modes: data-mode on .map-page is "drive" or "frame". The map SVG has the group axes_drive, */
/* and per frame axes_frame_<frame> and one group per predictor (axes_predictions_<frame>_<predictor>), */
/* shown only in frame mode; the rules in the page head of drive.html pick the frame and the predictor */
.map-page[data-mode="drive"] .frame-only, .map-page[data-mode="drive"] [id^="axes_frame_"],
.map-page[data-mode="drive"] [id^="axes_predictions_"] { display: none; }
.map-page[data-mode="frame"] .drive-only, .map-page[data-mode="frame"] #axes_drive { display: none; }
/* Mode selector: the drive name and the vehicle count above the selector; the selector keeps its own width */
.mode-select { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px; margin-right: 6px; }
/* Prediction method: after the vehicle count, the label above the selector */
.predictor-select { display: inline-flex; flex-direction: column; gap: 2px; margin: 0 6px; }
/* both selectors dark, their lists light */
.mode-select select, .predictor-select select { font: inherit; font-size: 16px; font-weight: 400; padding: 2px 6px;
    cursor: pointer; border: 1px solid #52514e; border-radius: 4px; background: #52514e; color: #fcfcfb; }
.mode-select option, .predictor-select option { background: #fcfcfb; color: #0b0b0b; }

/* Map with axes and grid: map_zoom.js draws them on every pan and zoom */
/* The map takes 2/3 of the width; "x East (m)" is right of the x axis */
/* flex-basis 0: the height comes from the free space, not from the SVG's own height. 322px = the rows' smallest sizes */
.map-layout { flex: 1 1 0; min-height: 322px; display: grid;
              grid-template-columns: 18px 48px minmax(0, 2fr) minmax(0, 1fr);
              grid-template-rows: minmax(300px, 1fr) 22px; }
.map-area { grid-row: 1; grid-column: 3; position: relative; }
#map { position: relative; height: 100%; }  /* above the grid */
#map-grid { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
#y-axis { grid-row: 1; grid-column: 2; width: 100%; height: 100%; }
#x-axis { grid-row: 2; grid-column: 3; width: 100%; height: 100%; }
.axis-label { font-size: 12px; color: #52514e; text-align: center; line-height: 18px; }
.y-label { grid-row: 1; grid-column: 1; writing-mode: vertical-rl; transform: rotate(180deg); }
.x-label { grid-row: 2; grid-column: 4; text-align: left; padding-left: 8px; line-height: 26px; }  /* level with the tick numbers */
/* Narrow screens: the map takes the whole width, "x East (m)" below the x axis */
@media (max-width: 700px) {
  .map-layout { min-height: 340px; grid-template-columns: 18px 48px minmax(0, 1fr);
                grid-template-rows: minmax(300px, 1fr) 22px 18px; }
  .x-label { grid-row: 3; grid-column: 3; text-align: center; padding-left: 0; line-height: 18px; }
}
.axis text { fill: #898781; font-size: 11px; }
.tick-line { stroke: #c3c2b7; stroke-width: 1; }
.grid-line { stroke: #d5d3cc; stroke-width: 1; }
.hint { font-size: 13px; color: #898781; }

/* Info panel: right of the map, in the column of "x East (m)"; scrolls if it is taller than the map */
.car-panel { grid-row: 1; grid-column: 4; min-height: 0; overflow-y: auto; padding: 0 4px 0 16px; font-size: 13px; }
.car-panel.open .car-panel-empty { display: none; }
.car-panel p { margin: 4px 0; }
.nowrap { white-space: nowrap; }  /* a group of words that goes to the next line as a whole */
.car-panel h3 { font-size: 13px; margin: 12px 0 2px; }
.car-head { display: flex; align-items: center; gap: 8px; }
.car-head h2 { flex: 1; font-size: 16px; margin: 0; }
.car-close { font: inherit; font-size: 18px; line-height: 1; padding: 2px 8px; cursor: pointer;
             border: 1px solid #c3c2b7; border-radius: 4px; background: #fcfcfb; color: #52514e; }
.car-panel .legend { margin: 4px 0; font-size: 12px; }
/* the selected predictor's scores: border and background from the rules in the page head */
.predictor-scores { border-left: 3px solid transparent; padding: 2px 0 2px 8px; margin: 4px 0; }
.predictor-name { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.jitter-panel { width: 200px; }
.jitter-panel svg, .error-chart svg { display: block; width: 100%; height: auto; }
/* Narrow screens: no column right of the map, the panel lies over the bottom of the window while a car is shown */
@media (max-width: 700px) {
  .car-panel { position: fixed; left: 0; right: 0; bottom: 0; max-height: 50vh; z-index: 10; padding: 8px 16px;
               background: #f9f9f7; border-top: 1px solid #c3c2b7; box-shadow: 0 -2px 8px rgba(11, 11, 11, 0.15); }
  .car-panel:not(.open) { display: none; }
}
.below-map { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 16px; margin: 4px 0;
             font-size: 13px; }

/* Thumbnails of the index page */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-top: 16px; }
.card { display: block; background: #fcfcfb; border: 1px solid rgba(11, 11, 11, 0.10); border-radius: 6px;
        overflow: hidden; text-decoration: none; color: #0b0b0b; }
.card:hover { border-color: #2a78d6; }
.card img { display: block; width: 100%; height: auto; }
.card .name { display: block; padding: 8px 10px 0; font-weight: 600; }
.card .meta { display: block; padding: 0 10px 8px; font-size: 13px; color: #898781; }
