/* lib/drive.css — the drive surface's shared styles (roadmap #39, docs/drive-modules.md).
 *
 * EVERY RULE IS NAMESPACED UNDER .dd-drive-*, and that is the point of the file (plan #39, gate
 * resolution 5): both pages already carry their own .sheet / .me / .recenter / .toast / .maphint /
 * .leaflet-popup-* rules, and a shared sheet that styled any of those bare would restyle a page that
 * never asked. The one rule that also names an id (#map.dd-drive-map.mrot) does so only to outrank a
 * page's own `#map{inset:0}`; it still cannot match an element that lacks the namespace class.
 *
 * e85.html is the only page that loads this today. route.html keeps its inline .turn / #map.mrot
 * rules until the gear slice (A10) moves them here — until then the card's look exists twice, and
 * the turn card's CLASS NAMES are the module's (lib/turncard.js writes `<base> <cls> near|imminent`),
 * so the two cannot disagree about which state is which, only about pixels.
 */

/* ---- orient-forward: the map container rotates (lib/orient.js corrects taps and popups) ---- */
#map.dd-drive-map.mrot{inset:auto;left:50%;top:50%;width:125vmax;height:125vmax;transform-origin:50% 50%;
  transform:translate(-50%,-50%) rotate(var(--dd-rot,0deg))}
.dd-drive-map.mrot .leaflet-control-zoom{display:none}
.dd-drive-map.mrot .leaflet-marker-icon>.dd-drive-upright{transform:rotate(var(--dd-inv,0deg));transform-origin:50% 50%}

/* ---- the live-position arrow inside a page's own .me dot ---- */
.dd-drive-me-arrow{width:0;height:0;border-left:5px solid transparent;border-right:5px solid transparent;
  border-bottom:11px solid #FF8A1E;transform-origin:50% 70%;position:absolute;left:50%;top:50%;margin:-8px 0 0 -5px}

/* ---- the drive bar: the turn card, the route state and the two ways out ----
   AT THE BOTTOM, in the place and the shape of route.html's .sheet, which is where that page carries
   its turn card (issue #221): a driver who moves between the two pages finds the card where they left
   it. The page hides its own bottom sheet while this is up; the bar takes its place, it does not
   stack on it. */
.dd-drive-bar{position:absolute;left:0;right:0;bottom:0;z-index:640;
  background:linear-gradient(180deg,rgba(23,26,32,.94),rgba(18,20,25,.96));border-top:1px solid #2A2E36;border-radius:20px 20px 0 0;
  padding:10px 16px calc(12px + env(safe-area-inset-bottom));box-shadow:0 -10px 40px rgba(0,0,0,.5);color:#ECEEF1}
.dd-drive-bar[hidden]{display:none}
.dd-drive-dest{font-family:"Saira Condensed",sans-serif;font-weight:700;font-size:12px;letter-spacing:.06em;text-transform:uppercase;
  color:#969CA6;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.dd-drive-state{margin-top:6px;font-size:12.5px;line-height:1.35;color:#ECEEF1}
.dd-drive-state[hidden]{display:none}
.dd-drive-state.warn{color:#FF3B30}
.dd-drive-state button{margin-left:6px;background:#FF8A1E;border:0;color:#2a1400;border-radius:999px;padding:4px 11px;cursor:pointer;
  font-family:"Saira Condensed",sans-serif;font-weight:700;font-size:12px;letter-spacing:.03em;text-transform:uppercase}
.dd-drive-actions{display:flex;gap:8px;margin-top:8px}
.dd-drive-actions button,.dd-drive-actions a{flex:1;display:inline-flex;align-items:center;justify-content:center;gap:6px;border-radius:9px;
  padding:8px 10px;cursor:pointer;text-decoration:none;font-family:"Saira Condensed",sans-serif;font-weight:700;font-size:13px;
  letter-spacing:.03em;text-transform:uppercase;border:1px solid #2A2E36;background:#1F2228;color:#ECEEF1}
.dd-drive-actions .dd-drive-end{border-color:#FF3B30;color:#FF3B30}
.dd-drive-attr{margin-top:7px;font-size:9.5px;line-height:1.35;color:#969CA6}
.dd-drive-attr a{color:#FF8A1E;text-decoration:none}

/* ---- the turn card (lib/turncard.js with base "dd-drive-turn") ---- */
.dd-drive-turn{display:grid;grid-template-columns:auto 1fr auto;align-items:center;gap:12px;margin:7px 0 0;
  background:#1F2228;border:1px solid #2A2E36;border-radius:12px;padding:8px 12px;transition:padding .25s ease}
.dd-drive-turn .arr{width:34px;height:34px;border-radius:9px;display:grid;place-items:center;background:rgba(255,138,30,.14);color:#FF8A1E;
  transition:width .25s ease,height .25s ease,background .25s ease}
.dd-drive-turn .arr svg{width:20px;height:20px;transition:transform .3s ease}
.dd-drive-turn .tdir{font-family:"Saira Condensed",sans-serif;font-weight:700;font-size:14px;letter-spacing:.04em;text-transform:uppercase;
  color:#969CA6;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;transition:font-size .25s ease,color .25s ease}
.dd-drive-turn .tdist{font-family:"JetBrains Mono",monospace;font-weight:700;font-size:21px;white-space:nowrap;color:#FF8A1E;
  transition:font-size .25s ease,color .25s ease}
.dd-drive-turn.fuel{border-color:#FFC400}
.dd-drive-turn.fuel .arr{background:rgba(255,196,0,.16);color:#FFC400}
.dd-drive-turn.fuel .tdir,.dd-drive-turn.fuel .tdist{color:#FFC400}
.dd-drive-turn.near{padding:11px 12px}
.dd-drive-turn.near .arr{width:46px;height:46px;border-radius:11px}
.dd-drive-turn.near .arr svg{width:28px;height:28px}
.dd-drive-turn.near .tdir{font-size:17px}
.dd-drive-turn.near .tdir,.dd-drive-turn.imminent .tdir{white-space:normal;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.dd-drive-turn.near .tdist{font-size:25px}
.dd-drive-turn.imminent{padding:14px 12px}
.dd-drive-turn.imminent .arr{width:62px;height:62px;border-radius:14px;background:#FFC400;color:#2a2000}
.dd-drive-turn.imminent .arr svg{width:40px;height:40px;stroke-width:2.6}
.dd-drive-turn.imminent .tdir{font-size:21px}
.dd-drive-turn.imminent .tdist{font-size:30px}

/* ---- the ⚙ settings menu's shared row kinds (lib/gear.js; moved from route.html by roadmap #39 A10) ----
   .dd-drive-gear is the menu's scrolling list; route.html puts it beside its own .setlist, whose
   button rows, route picker and version line stay in route.html because only that page has them.
   .dd-drive-seg is the segmented control OUTSIDE a menu (route.html's sim speed picker). */
/* scrolls inside .modal-card's 86vh cap — without this the rows past the cap (Sign in, "I need help")
   were clipped with no way to reach them. 4px side padding so the :focus-visible ring isn't clipped;
   min-height:0 is belt-and-braces (overflow!=visible already zeroes a flex item's auto min size). */
.dd-drive-gear{display:flex;flex-direction:column;gap:8px;padding:4px 4px;
  overflow-y:auto;min-height:0;overscroll-behavior:contain}
.dd-drive-gear .seg,.dd-drive-seg{display:flex;background:var(--asphalt-2);border:1px solid var(--line);border-radius:9px;overflow:hidden}
.dd-drive-gear .seg button,.dd-drive-seg button{appearance:none;border:none;background:transparent;color:var(--ink-dim);cursor:pointer;font-family:"JetBrains Mono",monospace;font-weight:700;font-size:12px;padding:7px 9px}
.dd-drive-gear .seg .seglbl,.dd-drive-seg .seglbl{display:flex;align-items:center;padding:0 8px;font-family:"Saira Condensed",sans-serif;font-weight:700;font-size:10px;letter-spacing:.1em;color:var(--ink-dim);background:var(--asphalt);border-right:1px solid var(--line)}
.dd-drive-gear .seg button.on,.dd-drive-seg button.on{background:var(--amber);color:#2a1400}
/* Driver-set turn-card growth distance (⚙ → Map & drive options). A sticky/discrete slider rather
   than another cycle button: the scale has six stops and "how far out" is a feel, not a toggle. It is
   deliberately NOT a <button>/<a>, so the settings-modal click handler leaves the menu open on drag
   without needing data-keepopen. .on marks any non-default choice, matching the toggle rows. */
.dd-drive-gear .setrange{display:flex;flex-direction:column;gap:6px;box-sizing:border-box;width:100%;
  background:var(--asphalt-2);border:1px solid var(--line);border-radius:11px;padding:9px 13px 7px}
.dd-drive-gear .setrange.on{border-color:var(--amber);background:rgba(255,138,30,.12)}
.dd-drive-gear .setrange .rlab{display:flex;align-items:center;justify-content:space-between;gap:10px;
  font-family:"Saira Condensed",sans-serif;font-weight:600;font-size:14px;letter-spacing:.3px;color:var(--ink)}
.dd-drive-gear .setrange .v{flex:0 0 auto;font-family:"JetBrains Mono",monospace;font-weight:500;font-size:12px;color:var(--amber)}
.dd-drive-gear .setrange.off .v{color:var(--ink-dim)}
.dd-drive-gear .setrange input[type=range]{width:100%;margin:0;height:24px;background:transparent;cursor:pointer;accent-color:var(--amber)}
.dd-drive-gear .setrange .rticks{display:flex;justify-content:space-between;
  font-family:"JetBrains Mono",monospace;font-size:10px;letter-spacing:0;color:var(--ink-dim)}
/* Map theme (roadmap #35) is three ABSOLUTE choices, so it is a radio group and not a toggle — it
   reuses the .seg segmented control the sim speed picker already uses. Like .setrange the WRAPPER is
   deliberately not a <button>/<a>; the three radios inside it are, so they carry data-keepopen. */
.dd-drive-gear .setseg{display:flex;flex-direction:column;gap:7px;box-sizing:border-box;width:100%;
  background:var(--asphalt-2);border:1px solid var(--line);border-radius:11px;padding:9px 13px}
.dd-drive-gear .setseg.on{border-color:var(--amber);background:rgba(255,138,30,.12)}
.dd-drive-gear .setseg .rlab{display:flex;align-items:center;justify-content:space-between;gap:10px;
  font-family:"Saira Condensed",sans-serif;font-weight:600;font-size:14px;letter-spacing:.3px;color:var(--ink)}
.dd-drive-gear .setseg .v{flex:0 0 auto;font-family:"JetBrains Mono",monospace;font-weight:500;font-size:12px;color:var(--ink-dim)}
.dd-drive-gear .setseg.on .v{color:var(--amber)}
.dd-drive-gear .setseg .seg{width:100%}
.dd-drive-gear .setseg .seg button{flex:1 1 0;text-align:center}
/* one-line explainer under a setlist row (offline map "route changed"). No `display` rule — the plain
   `hidden` attribute must keep working, and the button rules above only cover button/a. */
.dd-drive-gear .setnote{padding:0 4px;margin-top:-4px;font-family:Saira,sans-serif;font-size:12px;line-height:1.35;color:var(--ink-dim)}
.dd-drive-gear .setnote[hidden]{display:none}
/* A radio inside a .seg that cannot be chosen (roadmap #51: Sharper on a device with no WebGL2). It
   is rendered rather than hidden, deliberately -- see the note beside #detailRow -- so it needs to
   READ as unavailable and not merely be inert. route.html's `.setlist>button:disabled` does not reach it:
   these are grandchildren, inside .setseg .seg. */
.dd-drive-gear .setseg .seg button:disabled{opacity:.45;cursor:default}
.dd-drive-gear .setseg .seg button:disabled.on{background:transparent;color:var(--ink-dim)}

/* ---- a page that runs the shared theme and Map detail on its own map (e85.html: <body class="dd-drive-page">) ----
   route.html carries the SAME four rules inline, pinned there by test/mapdetail.test.js and
   test/maptheme.test.js; test/drive-lib.test.js pins these values identical to route.html's. Dark
   inverts ONLY the tile pane (the GL canvas lives in it), so pins and the route line keep their real
   colours; the fade arms only once the stored theme has painted, so a saved Dark never fades in. */
.dd-drive-page .leaflet-tile-pane{transition:filter .6s ease}
.dd-drive-page:not(.theme-ready) .leaflet-tile-pane{transition:none}
.dd-drive-page.map-dark .leaflet-tile-pane{filter:invert(1) hue-rotate(180deg) brightness(.95) contrast(.9)}
/* the vector canvas's counter-rotation out of #map.mrot (lib/basemap.js sets the pivot) */
.dd-drive-page .dd-vecrot{position:absolute;left:0;top:0;transform:rotate(var(--dd-inv,0deg))}
@media (prefers-reduced-motion:reduce){.dd-drive-page .leaflet-tile-pane{transition:none}}

/* ---- the ⚙ dialog on a page with no modal system of its own (e85.html); route.html's is its .modal ---- */
.dd-drive-dialog{position:fixed;inset:0;z-index:1200;display:grid;place-items:center;padding:18px;
  background:rgba(8,9,12,.72);-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px)}
.dd-drive-dialog[hidden]{display:none}
.dd-drive-panel{width:min(440px,94vw);max-height:86vh;display:flex;flex-direction:column;color:#ECEEF1;
  background:linear-gradient(180deg,#171A20,#121419);border:1px solid #2A2E36;border-radius:18px;
  box-shadow:0 24px 70px rgba(0,0,0,.6);padding:16px 16px 14px}
.dd-drive-head{display:flex;align-items:flex-start;justify-content:space-between;gap:10px;margin-bottom:12px}
.dd-drive-title{font-family:"Saira Condensed",sans-serif;font-weight:700;font-size:22px;letter-spacing:.02em;text-transform:uppercase}
.dd-drive-sub{font-family:"JetBrains Mono",monospace;font-size:10px;letter-spacing:.18em;text-transform:uppercase;color:#FF8A1E;margin-top:2px}
.dd-drive-x{background:none;border:none;color:#969CA6;font-size:26px;line-height:1;cursor:pointer;padding:0 4px}
.dd-drive-x:focus-visible,.dd-drive-gear .seg button:focus-visible{outline:2px solid #FF8A1E;outline-offset:2px}
.dd-drive-gear>[hidden]{display:none}
/* .setseg sets display:flex above, which beats the UA [hidden] rule for a row that is not a direct child (#241) */
.dd-drive-gear .setseg[hidden]{display:none}
/* a plain on/off row (Voice directions) on a page without route.html's .setlist: route.html's own
   row look, value for value (test/drive-lib.test.js pins the pair) */
.dd-drive-gear>.dd-drive-toggle{display:flex;align-items:center;gap:10px;width:100%;text-align:left;box-sizing:border-box;
  background:var(--asphalt-2);border:1px solid var(--line);border-radius:11px;color:var(--ink);
  font-family:"Saira Condensed",sans-serif;font-weight:600;font-size:15px;letter-spacing:.3px;padding:12px 14px;cursor:pointer;text-decoration:none;justify-content:flex-start}
.dd-drive-gear>.dd-drive-toggle.on{border-color:var(--amber);background:rgba(255,138,30,.12)}
.dd-drive-gear>.dd-drive-toggle:focus-visible{outline:2px solid #FF8A1E;outline-offset:2px}

/* ---- the one-time safety notice ---- */
.dd-drive-modal{position:fixed;inset:0;z-index:1300;background:rgba(8,9,12,.72);display:grid;place-items:center;padding:16px}
.dd-drive-modal[hidden]{display:none}
.dd-drive-modal .dd-drive-card{max-width:440px;width:100%;background:#1F2228;border:1px solid #2A2E36;border-radius:16px;padding:18px 18px 16px;color:#ECEEF1}
.dd-drive-modal h2{margin:0 0 10px;font-family:"Saira Condensed",sans-serif;font-weight:700;font-size:22px;letter-spacing:.02em;text-transform:uppercase}
.dd-drive-modal ul{margin:0 0 12px;padding-left:18px;line-height:1.5;font-size:14px}
.dd-drive-modal li{margin-bottom:7px}
.dd-drive-modal p{font-size:12.5px;color:#969CA6;margin:0 0 12px;line-height:1.5}
.dd-drive-modal a{color:#FF8A1E;text-decoration:none}
.dd-drive-modal .dd-drive-row{display:flex;gap:8px}
.dd-drive-modal button{flex:1;border-radius:10px;padding:10px 12px;cursor:pointer;font-family:"Saira Condensed",sans-serif;font-weight:700;
  font-size:14px;letter-spacing:.03em;text-transform:uppercase;border:1px solid #2A2E36;background:#15171C;color:#ECEEF1}
.dd-drive-modal button.dd-drive-agree{background:#FF8A1E;border-color:#FF8A1E;color:#2a1400}

@media (prefers-reduced-motion: reduce){.dd-drive-turn,.dd-drive-turn *{transition:none !important}}
