/* Layout and pieces (docs/DESIGN.md). Uses the tokens of tokens.css only. */
html, body { margin: 0; height: 100%; font-family: system-ui, sans-serif; color: var(--ink); }
#map { position: absolute; inset: 0; }
button { font: inherit; color: inherit; }

/* ---- round map buttons: rare things top, frequent things near the thumb ---- */
.fab {
  position: absolute; z-index: 1000; width: var(--touch); height: var(--touch); border-radius: 50%;
  background: var(--surface); box-shadow: 0 2px 6px rgba(0,0,0,.25); border: 0; cursor: pointer;
  font-size: 20px; display: flex; align-items: center; justify-content: center;
}
.fab:focus-visible { outline: 3px solid var(--selected); }
#settingsBtn { top: var(--s3); right: var(--s3); }
#locateBtn { right: var(--s3); bottom: calc(var(--sheet-h, 150px) + var(--s3)); color: var(--ink-2); }
#locateBtn.following { color: var(--you); }
#savedBtn { right: var(--s3); bottom: calc(var(--sheet-h, 150px) + var(--s3) + var(--touch) + var(--s2)); color: var(--selected); }
#locateBtn.waiting { opacity: .5; }
.leaflet-top.leaflet-right { top: 64px; }             /* zoom buttons below the settings button */
@media (pointer: coarse) { .leaflet-control-zoom { display: none; } }   /* phones pinch */
@media (max-width: 799px) { body[data-sheet="full"] #locateBtn, body[data-sheet="full"] #savedBtn { display: none; } }   /* no map left to centre */

/* ---- banner (feed problems): only when something is wrong ---- */
#banner {
  position: absolute; z-index: 1002; top: var(--s3); left: var(--s3); right: 70px; display: none;
  background: var(--alert-tint); color: var(--alert-ink); border-radius: var(--r-label); padding: var(--s2) var(--s3);
  font-size: var(--t-s); box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
#banner.show { display: block; }

/* ---- the panel: bottom sheet on phones, side panel on computers ---- */
#sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1001; background: var(--surface);
  border-radius: var(--r-panel) var(--r-panel) 0 0; box-shadow: 0 -2px 12px rgba(0,0,0,.18);
  height: var(--sheet-h, 150px); display: flex; flex-direction: column; box-sizing: border-box;
  transition: height var(--motion) ease;
}
#sheet.dragging { transition: none; }
#handle {
  flex: 0 0 auto; height: 28px; cursor: grab; touch-action: none; border: 0; background: none;
  display: flex; align-items: center; justify-content: center; width: 100%;
}
#handle::before { content: ""; width: 36px; height: 4px; border-radius: 2px; background: #c4c4c4; }
#sheetBody { flex: 1; overflow-y: auto; padding: 0 var(--s4) var(--s4); overscroll-behavior: contain; }
@media (min-width: 800px) {
  #sheet {
    left: var(--s3); top: var(--s3); bottom: var(--s3); right: auto; width: 400px; height: auto;
    border-radius: var(--r-panel); box-shadow: 0 2px 12px rgba(0,0,0,.2);
  }
  #handle { display: none; }
  #sheetBody { padding-top: var(--s4); }
  #locateBtn { bottom: var(--s5); }
  #savedBtn { bottom: calc(var(--s5) + var(--touch) + var(--s2)); }
  #banner { left: 430px; }
}

/* ---- panel content ---- */
.head { display: flex; align-items: center; gap: var(--s2); min-height: var(--touch); }
.head h2 { flex: 1; min-width: 0; font-size: var(--t-m); font-weight: 600; margin: 0; padding: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }   /* padding: room for the selection ring */
.back { border: 0; background: none; font-size: var(--t-l); width: var(--touch); height: var(--touch);
  margin-left: calc(-1 * var(--s3)); cursor: pointer; }
/* ✕: straight back to "Near you" (shown when ← would take more than one tap) */
.close { border: 0; background: none; font-size: var(--t-m); color: var(--ink-2); width: var(--touch); height: var(--touch);
  margin-right: calc(-1 * var(--s3)); cursor: pointer; flex: none; }
.back:focus-visible, .close:focus-visible { outline: 3px solid var(--selected); }
.sub { color: var(--ink-2); font-size: var(--t-s); margin-top: 2px; }
.big { font-size: var(--t-xl); font-weight: 700; line-height: 1.15; margin: var(--s1) 0 2px; }
.big small { font-size: var(--t-m); font-weight: 500; color: var(--ink-2); }
.section { font-size: var(--t-xs); font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--ink-2); margin: var(--s4) 0 var(--s1); }
.empty { color: var(--ink-2); font-size: var(--t-s); padding: var(--s4) 0; }

/* line label (list and panel) */
.line { display: inline-block; min-width: 28px; text-align: center; padding: 3px 6px; border-radius: var(--r-label);
  background: var(--live); color: #fff; font-weight: 700; font-size: var(--t-s); box-sizing: border-box; }
.line.timetable { background: var(--timetable); color: var(--ink); border: 1px dashed #333; }
.line.selected { box-shadow: 0 0 0 3px var(--selected); }
.lines { display: inline-flex; align-items: center; gap: 2px; }
.lines .then { color: var(--ink-2); font-size: var(--t-s); }

/* badges: always a word, never colour alone */
.badge { display: inline-block; font-size: var(--t-xs); font-weight: 600; padding: 1px 7px; border-radius: 10px;
  vertical-align: middle; white-space: nowrap; }
.badge.live { background: var(--live-tint); color: #00468c; }
.badge.live::before { content: "● "; color: var(--live); }
.badge.predicted { background: #eee; color: #444; }
.badge.timetable { background: var(--timetable-tint); color: #6b4e00; border: 1px dashed #b38600; }
.late { color: var(--late); font-weight: 600; }

/* list rows */
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: var(--s3); min-height: 56px; border-top: 1px solid var(--line);
  cursor: pointer; padding: var(--s1) 0; }
.row:focus-visible { outline: 3px solid var(--selected); outline-offset: -3px; }
.row .main { flex: 1; min-width: 0; }
.row .t1 { font-size: var(--t-m); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .t2 { font-size: 13px; color: var(--ink-2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .t2.leg { white-space: normal; }   /* a bus of a journey: where, when, where off; never cut */
.row .when { text-align: right; font-size: 18px; font-weight: 700; white-space: nowrap; }
.row .when .t2 { font-weight: 400; text-align: right; }

/* next stops of a bus: a magenta line through the stops */
.stopline { position: relative; padding-left: 22px; }
.stopline::before { content: ""; position: absolute; left: 6px; top: 0; bottom: 0; border-left: 3px solid var(--selected); }
.stopline .dot { position: absolute; left: 1px; top: 50%; margin-top: -6px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--selected); }

/* saving: stars, buttons, the line search */
.star { border: 0; background: none; cursor: pointer; min-width: var(--touch); height: var(--touch); font-size: var(--t-l);
  color: var(--ink-2); white-space: nowrap; padding: 0 var(--s1); }
.head .star { font-size: var(--t-s); font-weight: 600; }
.star.on { color: var(--selected); }
.remove { border: 0; background: none; cursor: pointer; width: var(--touch); height: var(--touch); color: var(--late); font-size: var(--t-m); }
.actions { display: flex; gap: var(--s2); margin-top: var(--s4); flex-wrap: wrap; align-items: center; }
.actions.small { margin-top: var(--s2); }
.pill { flex: 1; min-height: var(--touch); border-radius: 22px; border: 1px solid var(--line); background: var(--surface);
  font-weight: 600; cursor: pointer; }
.textbtn { border: 0; background: none; color: var(--live); cursor: pointer; font-size: var(--t-s); min-height: var(--touch);
  padding: 0 var(--s2); display: inline-flex; align-items: center; }
.textbtn[disabled] { color: var(--ink-2); cursor: default; }
.search { width: 100%; box-sizing: border-box; min-height: var(--touch); font-size: var(--t-m); padding: 0 var(--s3);
  border: 1px solid var(--line); border-radius: var(--r-label); margin: var(--s2) 0; }
.search:focus-visible, .pill:focus-visible, .textbtn:focus-visible, .star:focus-visible { outline: 3px solid var(--selected); }
.saved-mark { color: var(--selected); }

.warn-box { margin-top: var(--s3); padding: var(--s2) var(--s3); border-radius: var(--r-label);
  background: var(--alert-tint); color: var(--alert-ink); font-size: var(--t-s); }

/* settings */
.toggle { display: flex; align-items: center; gap: var(--s3); min-height: var(--touch); font-size: var(--t-m); cursor: pointer; }
.toggle input { width: 20px; height: 20px; accent-color: var(--selected); }
.hint { color: var(--ink-2); font-size: var(--t-xs); margin: 0 0 var(--s2) 32px; }
.warn { color: var(--late); font-size: var(--t-xs); margin: 0 0 var(--s2) 32px; white-space: pre-wrap; }
.legend { list-style: none; margin: 0; padding: 0; }
.legend li { display: flex; align-items: center; gap: var(--s3); margin: var(--s2) 0; font-size: var(--t-s); }
.legend .sw { flex: 0 0 46px; display: flex; justify-content: center; }
.sw-ring { width: 8px; height: 8px; border-radius: 50%; border: 2px solid #37474f; background: #fff; }
.sw-you { width: 12px; height: 12px; border-radius: 50%; background: var(--you); border: 2px solid #fff;
  box-shadow: 0 0 0 6px rgba(46,125,50,.2); }
.status { font-size: var(--t-xs); color: var(--ink-2); line-height: 1.5; }

/* ---- map markers ---- */
.bus-wrap { position: relative; width: 40px; height: 40px; }
.bus-icon {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: var(--bus-color, var(--live)); color: #fff; font-size: 11px; font-weight: 600;
  border-radius: 4px; padding: 2px 4px; border: 1px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.4); white-space: nowrap;
}
.bus-icon.tt { background: var(--timetable); color: var(--ink); border: 1px dashed #333; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.bus-wrap.sel .bus-icon { box-shadow: 0 0 0 3px var(--selected), 0 1px 3px rgba(0,0,0,.4); }
.arrow { position: absolute; inset: 0; }
.arrow::before {
  content: ""; position: absolute; top: 0; left: 50%; margin-left: -6px;
  border-left: 6px solid transparent; border-right: 6px solid transparent;
  border-bottom: 10px solid var(--bus-color, var(--live)); filter: drop-shadow(0 0 1px #fff);
}
.stop-mark { width: 12px; height: 12px; border-radius: 3px; background: #fff; border: 2px solid var(--ink-2); box-sizing: border-box; }

/* rendezvous: the big action, the pin */
.cta { display: block; width: 100%; min-height: 52px; margin-top: var(--s4); border: 0; border-radius: 26px;
  background: var(--selected); color: #fff; font-size: var(--t-m); font-weight: 700; cursor: pointer; }
.cta:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.meet-pin { position: relative; width: 24px; height: 32px; }
.meet-pin .pin { position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg); background: var(--selected); border: 2px solid #fff; box-sizing: border-box;
  box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.meet-pin .meet-time { position: absolute; left: 28px; top: 0; background: var(--selected); color: #fff; font-weight: 700;
  font-size: var(--t-s); padding: 2px 6px; border-radius: var(--r-label); white-space: nowrap; }
/* Meet: the next bus of the line, when this one cannot be met safely */
.next-bus { margin-top: var(--s4); padding-top: var(--s3); border-top: 1px solid var(--line); }
.next-bus .t1 { font-size: var(--t-m); font-weight: 600; }
.next-bus .sub { margin-top: var(--s1); }
/* TEC's alerts about a line (bus and line panels); the strike banner's link */
.alerts { margin-top: var(--s3); display: flex; flex-direction: column; gap: var(--s1); }
.alert { background: var(--timetable-tint); border-radius: var(--r-label); padding: var(--s2) var(--s3); font-size: var(--t-s); }
.alert.strike { background: var(--alert-tint); color: var(--alert-ink); }
.alert summary { cursor: pointer; min-height: 24px; }
.alert .t2 { margin-top: var(--s1); }
.alert a, #banner a { color: inherit; font-weight: 600; }
#banner { cursor: pointer; }
/* a stop named in one of TEC's alerts (works, moved stop): "may be affected" */
.works { color: var(--works-ink); font-weight: 600; }
.deviated { color: var(--works-ink); font-weight: 600; margin-top: 4px; }
/* all stops of a trip: passed ones greyed, the bus's place between them */
.stopline.passed { color: var(--ink-2); }
.stopline.passed::before { border-left-color: var(--line); }
.stopline.passed .dot { border-color: var(--line); }
.stopline.skipped .t1 { text-decoration: line-through; }
.here { position: relative; padding: var(--s2) 0 var(--s2) 22px; color: var(--selected); font-weight: 600; font-size: var(--t-s); }
.here::before { content: ""; position: absolute; left: 6px; top: 0; bottom: 0; border-left: 3px solid var(--selected); }
.here .dot { position: absolute; left: -1px; top: 50%; margin-top: -7px; width: 13px; height: 13px; border-radius: 50%; background: var(--selected); }
/* Meet: how you get to the stop (walk / bike / car), one tap, remembered */
.modes { display: flex; gap: var(--s2); margin: var(--s2) 0 var(--s3); }
.mode { flex: 1; min-height: var(--touch); border: 1px solid var(--line); border-radius: var(--r-label);
  background: var(--surface); color: var(--ink); font-size: var(--t-s); cursor: pointer; }
.mode.on { border: 2px solid var(--selected); font-weight: 600; }
.modes.sure { align-items: center; margin-top: 0; }
.sure-label { font-size: var(--t-s); color: var(--ink-2); }

/* places (roadmap 11): the cross in the middle of the visible map, a saved place on the map */
.crosshair { position: fixed; width: 36px; height: 36px; margin: -18px 0 0 -18px; pointer-events: none; z-index: 900;
  background: linear-gradient(var(--selected), var(--selected)) center / 2px 100% no-repeat,
              linear-gradient(var(--selected), var(--selected)) center / 100% 2px no-repeat; }
.place-pin { width: 32px; height: 32px; border-radius: 50%; background: var(--surface); border: 2px solid var(--selected);
  display: flex; align-items: center; justify-content: center; font-size: 18px; box-sizing: border-box; }
.cta[disabled] { opacity: 0.5; cursor: default; }
.place-icon { width: 36px; text-align: center; font-size: 22px; }
