@font-face {
  font-family: "Barlow Semi Condensed";
  src: url("vendor/barlow-semi-condensed-latin-600-normal.woff2") format("woff2");
  font-weight: 600; font-display: swap;
}
@font-face {
  font-family: "Barlow Semi Condensed";
  src: url("vendor/barlow-semi-condensed-latin-700-normal.woff2") format("woff2");
  font-weight: 700; font-display: swap;
}

:root {
  --ink: #1C2B39;        /* harbour blue, text */
  --ink-soft: #5B6B78;
  --paper: #FFFFFF;
  --mist: #F2F5F7;       /* cool grey surface */
  --line: #DCE3E8;
  --teal: #0E7C86;       /* actions */
  --bus: #B5452E;
  --minibus: #2E8B57;
  --walk: #A9B5BF;
  --signage: "Barlow Semi Condensed", "Arial Narrow", sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", "Noto Sans HK", "PingFang HK", "Microsoft JhengHei", sans-serif;
  --radius-panel: 18px;
  --radius-control: 10px;
  --bar: calc(26px + env(safe-area-inset-bottom));  /* status bar at the bottom of the screen */
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--body); font-size: 16px; line-height: 1.4;
  color: var(--ink); background: var(--mist);
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }

#map { position: fixed; inset: 0 0 var(--bar) 0; }

/* Panel: bottom sheet on phones, side panel on wider screens */
#panel {
  position: fixed; left: 0; right: 0; bottom: var(--bar);
  max-height: 62vh; overflow-y: auto;
  background: var(--paper);
  border-radius: var(--radius-panel) var(--radius-panel) 0 0;
  box-shadow: 0 -6px 24px rgba(28, 43, 57, .16);
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
}
@media (min-width: 768px) {
  #panel {
    top: 16px; left: 16px; bottom: calc(var(--bar) + 16px); right: auto; width: 390px; max-height: none;
    border-radius: var(--radius-panel);
    box-shadow: 0 6px 24px rgba(28, 43, 57, .18);
  }
  #panel.folded { bottom: auto; }
}

/* Handle: folds the panel down to the fields so the map gets the space */
.handle {
  display: block; width: 100%; height: 22px; margin: -8px 0 6px; border: 0; background: transparent;
  touch-action: manipulation;
}
.handle span { display: block; width: 44px; height: 5px; margin: 0 auto; border-radius: 3px; background: var(--line); }
.handle:hover span { background: var(--walk); }

/* Summary bar shown while folded: "found N routes" or the open journey in one line */
.sheet-bar {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  border: 0; border-radius: var(--radius-control); background: var(--mist);
  padding: 12px 14px; margin-top: 2px; font-weight: 600;
}
.sheet-bar[hidden] { display: none; }
.sheet-bar-action { margin-left: auto; color: var(--teal); flex: none; }
#sheet-bar-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Start and destination fields */
.field {
  display: flex; align-items: center; gap: 10px;
  background: var(--mist); border: 2px solid transparent; border-radius: var(--radius-control);
  padding: 4px 4px 4px 10px; margin-bottom: 8px;
}
.field.active { border-color: var(--teal); background: var(--paper); }
.field input {
  flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; color: var(--ink);
  padding: 9px 0;
}
.field input:focus { outline: none; }
.pin {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  font: 700 14px/1 var(--signage); color: #fff; background: var(--ink);
}
.pin-b { background: var(--teal); }
.icon-btn {
  flex: none; width: 40px; height: 40px; border: 0; border-radius: 8px; background: transparent;
  display: grid; place-items: center; color: var(--ink-soft);
}
.icon-btn:hover { background: var(--line); color: var(--ink); }

#suggestions { list-style: none; margin: 0 0 8px; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-control); }
#suggestions li { padding: 10px 12px; border-top: 1px solid var(--line); cursor: pointer; }
#suggestions li:first-child { border-top: 0; }
#suggestions li:hover, #suggestions li[aria-selected="true"] { background: var(--mist); }
#suggestions .zh { display: block; font-size: 14px; color: var(--ink-soft); }

.note { margin: 4px 2px 8px; font-size: 14px; color: var(--ink-soft); }
.status { margin: 8px 2px 0; font-size: 14px; color: var(--ink-soft); min-height: 1em; }
.status.error { color: var(--bus); }
.muted { color: var(--ink-soft); font-size: 14px; }

/* Results */
.results-head { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 10px; }
.sort { display: inline-flex; background: var(--mist); border-radius: var(--radius-control); padding: 3px; }
.sort button { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; font-weight: 600; color: var(--ink-soft); }
.sort button[aria-checked="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px rgba(28, 43, 57, .15); }

#options { list-style: none; margin: 0; padding: 0; }
.option {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 12px 4px 14px; border-top: 1px solid var(--line);
}
.option:hover { background: var(--mist); }
#options li:first-child .option { border-top: 0; }
.option-top { display: flex; align-items: baseline; gap: 12px; }
.mins { font: 700 30px/1 var(--signage); letter-spacing: -.01em; }
.mins small { font-size: 16px; font-weight: 600; margin-left: 2px; }
.fare { font: 600 20px/1 var(--signage); }
.when { margin-left: auto; font-size: 14px; color: var(--ink-soft); }
.option-meta { font-size: 14px; color: var(--ink-soft); margin-top: 8px; }
.next { color: var(--teal); font-weight: 600; }
.option-next { font-size: 14px; margin-top: 2px; min-height: 1.4em; }

/* The leg strip: one segment per leg, width by time, coloured by line or mode */
.strip { display: flex; gap: 3px; height: 26px; margin-top: 10px; }
.seg {
  min-width: 26px; border-radius: 6px; display: flex; align-items: center; justify-content: center;
  font: 700 14px/1 var(--signage); color: #fff; overflow: hidden; white-space: nowrap; padding: 0 6px;
}
.seg.walk {
  min-width: 10px; background: repeating-linear-gradient(90deg, var(--walk) 0 6px, transparent 6px 10px);
  background-size: 10px 4px; background-repeat: repeat-x; background-position: center;
}

/* Detail */
.text-btn { border: 0; background: none; color: var(--teal); font-weight: 600; padding: 6px 0; }
.detail-head { display: flex; align-items: baseline; gap: 12px; margin: 6px 0 4px; }
.legs { list-style: none; margin: 14px 0 0; padding: 0; }
.leg { display: grid; grid-template-columns: 14px 1fr; gap: 12px; padding-bottom: 14px; }
.leg-bar { border-radius: 7px; min-height: 100%; }
.leg-bar.walk { background: repeating-linear-gradient(180deg, var(--walk) 0 5px, transparent 5px 9px); width: 4px; margin: 0 auto; }
.leg-title { font-weight: 600; }
.leg-title .route { font: 700 18px/1 var(--signage); margin-right: 6px; }
.leg-sub { font-size: 14px; color: var(--ink-soft); }
.leg-termini { display: block; font-size: 14px; font-weight: 400; color: var(--ink-soft); }
.arrivals { font-size: 14px; margin-top: 4px; }

@media (prefers-reduced-motion: no-preference) {
  .option, .sort button { transition: background-color .15s; }
}

/* Status bar: version and data date, update notice, disclaimer link */
#statusbar {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--bar); z-index: 2;
  display: flex; align-items: center; gap: 12px;
  padding: 0 12px env(safe-area-inset-bottom);
  background: var(--mist); border-top: 1px solid var(--line);
  font-size: 12px; color: var(--ink-soft); white-space: nowrap;
}
#version { overflow: hidden; text-overflow: ellipsis; }
.bar-link, .bar-update { margin-left: auto; border: 0; background: none; padding: 4px 0; font-size: 12px; color: var(--ink-soft); }
.bar-link { text-decoration: underline; }
.bar-update { color: var(--paper); background: var(--teal); padding: 3px 10px; border-radius: 999px; font-weight: 600; }
.bar-link[hidden], .bar-update[hidden] { display: none; }

/* Disclaimer and copyright page */
.about { position: fixed; inset: 0; z-index: 10; background: rgba(28, 43, 57, .45); display: flex; align-items: flex-end; justify-content: center; }
.about[hidden] { display: none; }
.about-card {
  width: 100%; max-width: 520px; max-height: 85vh; overflow-y: auto;
  background: var(--paper); border-radius: var(--radius-panel) var(--radius-panel) 0 0;
  padding: 18px 20px calc(18px + env(safe-area-inset-bottom)); font-size: 15px;
}
@media (min-width: 768px) { .about { align-items: center; } .about-card { border-radius: var(--radius-panel); } }
.about-card h2 { margin: 0 0 8px; font-size: 18px; }
.about-card h3 { margin: 14px 0 4px; font-size: 15px; }
.about-card p, .about-card ul { margin: 0 0 6px; }
.about-card ul { padding-left: 20px; }
.copyright { font-weight: 600; margin-top: 12px !important; }
