/* ============================================================
   Cart Path Router — redesigned styles
   Palette: Villages green #00492b / #0a6b41, warm paper neutrals,
   start green #1a9850, finish brick #c0442c, car slate #4a5a68.
   Type: Roboto (UI) + Zilla Slab (title, route times).
   ============================================================ */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: 'Roboto', system-ui, sans-serif; font-size: 15px; color: #252a22; background: #f6f3ec; }
a { color: #0a6b41; } a:hover { color: #00492b; }
input::placeholder { color: #9aa091; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid #0a6b41; outline-offset: 2px; }
.leaflet-container { font-family: inherit; }

/* ---- layout: sidebar + map ---- */
#wrap { display: flex; height: 100dvh; width: 100%; overflow: hidden; }
#side { width: 402px; min-width: 402px; background: #fbf9f3; border-right: 1px solid #e3ddcd; display: flex; flex-direction: column; height: 100%; }
#map { flex: 1; height: 100%; background: #e8e4d8; }

/* ---- header ---- */
header { padding: 18px 20px 12px; display: flex; align-items: center; gap: 12px; }
header h1 { margin: 0; font-family: 'Zilla Slab', serif; font-size: 27px; font-weight: 700; color: #00492b; line-height: 1.15; }
header p { margin: 2px 0 0; font-size: 13.5px; color: #6b7263; }
.routeglyph { display: inline-flex; align-items: center; gap: 4px; flex: none; }
.routeglyph .g-start { width: 10px; height: 10px; border-radius: 50%; background: #1a9850; }
.routeglyph .g-line { width: 16px; height: 0; border-top: 2px dotted #b4ac95; }
.routeglyph .g-end { width: 9px; height: 9px; background: #c0442c; border-radius: 2px; }

.scroll { overflow-y: auto; flex: 1; padding: 4px 20px 20px; }
.row { margin-bottom: 14px; }

/* ---- vehicle toggle ---- */
.seg { display: flex; gap: 4px; background: #efeadd; border: 1px solid #ddd6c2; border-radius: 999px; padding: 4px; }
.seg button { flex: 1; border: 0; border-radius: 999px; padding: 11px 8px; font-family: inherit; font-size: 15px; font-weight: 600; color: #565e50; background: transparent; cursor: pointer; min-height: 44px; }
.seg button.on { background: #00492b; color: #fff; }
.seg button:not(.on):hover { background: #fff; }

/* ---- start / finish ---- */
.routebox { position: relative; margin-bottom: 6px; }
.fields { display: flex; flex-direction: column; gap: 9px; }
.field { position: relative; display: flex; align-items: center; }
.field input { width: 100%; padding: 13px 58px 13px 38px; border: 1.5px solid #ddd6c2; border-radius: 11px; font-family: inherit; font-size: 16px; background: #fff; color: #252a22; }
.field input:focus { border-color: #0a6b41; box-shadow: 0 0 0 3px rgba(10,107,65,.14); outline: none; }
.dot { position: absolute; left: 15px; box-shadow: 0 0 0 2px #fff; }
.dot.start { width: 11px; height: 11px; border-radius: 50%; background: #1a9850; }
.dot.end { width: 11px; height: 11px; background: #c0442c; border-radius: 2px; }
#swapBtn { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid #ddd6c2; background: #fbf9f3; color: #565e50; font-size: 17px; cursor: pointer; line-height: 1; }
#swapBtn:hover { background: #efeadd; color: #252a22; }
.matched { font-size: 13px; color: #6b7263; min-height: 17px; margin-bottom: 10px; }

/* ---- buttons & options ---- */
.btns { display: flex; gap: 8px; margin-bottom: 12px; }
.btn { border: 0; border-radius: 11px; font-family: inherit; font-weight: 700; cursor: pointer; min-height: 48px; }
.btn.primary { flex: 1; padding: 14px 12px; font-size: 16.5px; background: #00492b; color: #fff; }
.btn.primary:hover { background: #0a6b41; }
.btn.ghost { border: 1.5px solid #ddd6c2; padding: 14px 16px; font-size: 15px; font-weight: 600; background: transparent; color: #565e50; }
.btn.ghost:hover { background: #efeadd; }
.opts, .adv { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.adv { padding: 10px 0 4px; margin-bottom: 0; }
.chk { display: flex; align-items: center; gap: 10px; font-size: 15px; cursor: pointer; }
.chk input { width: 20px; height: 20px; margin: 0; accent-color: #00492b; cursor: pointer; }
.status { font-size: 14px; color: #6b7263; min-height: 18px; margin-bottom: 8px; }
details { margin-top: 8px; }
summary { cursor: pointer; font-size: 14px; font-weight: 600; color: #6b7263; padding: 6px 0; }
.foot { padding: 11px 20px; border-top: 1px solid #e3ddcd; font-size: 12px; color: #6b7263; line-height: 1.5; }

/* ---- autocomplete (rendered by app.js) ---- */
.ac-menu { position: absolute; top: calc(100% + 5px); left: 0; right: 0; background: #fff; border: 1px solid #ddd6c2; border-radius: 10px; box-shadow: 0 10px 28px rgba(40,35,20,.16); z-index: 1200; max-height: 260px; overflow-y: auto; display: none; }
.ac-menu.show { display: block; }
.ac-item { display: flex; align-items: center; gap: 10px; padding: 11px 13px; font-size: 15px; cursor: pointer; border-bottom: 1px solid #f1ede1; }
.ac-item:last-child { border-bottom: 0; }
.ac-item.active { background: #eef2e6; }
.ac-item .ic { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.ac-item .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-item .meta { color: #6b7263; font-size: 12px; margin-left: auto; flex: none; padding-left: 8px; }

/* ---- result cards (rendered by app.js) ---- */
.result { background: #fff; border: 1px solid #e3ddcd; border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; }
.result .top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.result .veh { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.result .metrics { display: flex; gap: 14px; align-items: baseline; }
.result .big { font-family: 'Zilla Slab', serif; font-size: 29px; font-weight: 700; line-height: 1.1; }
.result .sub { font-size: 14.5px; color: #6b7263; }
.result .speed { font-size: 13.5px; color: #6b7263; margin-top: 4px; }
.result .speed b { color: #252a22; font-weight: 700; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex: none; }

/* ---- banners (rendered by app.js) ---- */
.banner { border-radius: 10px; padding: 12px 14px; font-size: 14px; line-height: 1.45; margin: 0 0 12px; display: none; }
.banner.err { background: #f9e9e4; border: 1px solid #e6c3b7; color: #6e2412; display: block; }
.banner.warn { background: #f7efd9; border: 1px solid #e4d5a8; color: #5c470e; display: block; }
.banner code { background: rgba(0,0,0,.06); padding: 1px 4px; border-radius: 4px; font-size: 12px; }
.banner b { display: block; margin-bottom: 2px; }

/* ---- turn-by-turn (rendered by app.js) ---- */
.dirs { margin-top: 4px; border-top: 1px solid #e3ddcd; padding-top: 12px; }
.dirs h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: #6b7263; }
.dir { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid #eee9db; font-size: 15px; line-height: 1.4; }
.dir:last-child { border-bottom: 0; }
.dir .n { color: #a3a891; font-size: 12.5px; min-width: 18px; text-align: right; padding-top: 2px; font-variant-numeric: tabular-nums; }
.dir .d { color: #6b7263; font-size: 12.5px; margin-left: auto; white-space: nowrap; font-variant-numeric: tabular-nums; padding-top: 2px; }

/* ---- mobile: map on top, draggable panel beneath ---- */
#panelToggle { display: none; width: 100%; border: 0; border-bottom: 1px solid #e3ddcd; background: #f1ecdf; color: #565e50; font-family: inherit; font-size: 13.5px; font-weight: 600; padding: 9px 12px; cursor: ns-resize; align-items: center; justify-content: center; gap: 8px; min-height: 44px; }
#panelToggle .grip { width: 36px; height: 4px; border-radius: 2px; background: #c9c2ab; }
@media (max-width: 760px) {
  #wrap { flex-direction: column-reverse; }

  /* The panel's height is the only thing the drag handle changes; the map simply takes
     whatever is left over. --panel-h is written in px onto #wrap by initPanelDrag()
     while the handle is being dragged; 58dvh is what the page opens at (map on top,
     panel below). The var is only read inside this query, so the desktop layout can
     never pick up a stale height left behind by a drag. */
  #map { flex: 1 1 auto; height: auto; min-height: 0; }
  #side { width: 100%; min-width: 0; flex: none; height: var(--panel-h, 58dvh); border-right: 0; border-top: 1px solid #e3ddcd; overflow: hidden; transition: height .22s ease; }

  /* The panel is clipped, not re-laid-out, as it shrinks: the handle always keeps its
     full height, the scrolling middle absorbs the change, and the footer slides out of
     view under overflow:hidden. That is what makes the drag look continuous instead of
     popping between states. */
  #panelToggle { display: flex; flex: none; touch-action: none; }
  #side header, #side .foot { flex: none; }
  #side .scroll { min-height: 0; }

  /* No easing while a finger is down — the height already tracks the pointer, and a
     transition on top of that just makes the panel lag behind the drag. */
  #wrap.dragging #side { transition: none; }
}
