/* Landscape dashboard board — tuned for e-ink: pure black/white, no gradients/
   shadows, thick borders, huge tabular numerals, no animations (avoids ghosting
   on e-ink refresh). Modeled on the wall-mounted Bus Aunty display: a wide grid
   of stop panels with giant arrival-time digits, not a stacked phone list. */

* { box-sizing: border-box; }

:root {
  --ink: #000000;
  --paper: #ffffff;
  --grey: #666666;
  --line: #000000;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: none;
  font-smooth: never;
  height: 100%;
  overflow: hidden;
}

body {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  border-bottom: 3px solid var(--line);
  flex: none;
}

.topbar h1 {
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  margin: 0;
  letter-spacing: -0.02em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.updated-label {
  font-size: 0.8rem;
  color: var(--grey);
  font-variant-numeric: tabular-nums;
}

.icon-btn {
  background: var(--paper);
  border: 2px solid var(--line);
  color: var(--ink);
  font-size: 1.2rem;
  line-height: 1;
  padding: 5px 14px;
  border-radius: 6px;
}

.icon-btn:active { background: var(--ink); color: var(--paper); }

.banner {
  margin: 10px 18px 0;
  padding: 10px 14px;
  border: 3px solid var(--line);
  font-size: 0.9rem;
  line-height: 1.4;
  flex: none;
}

.banner a { color: var(--ink); }

.hidden { display: none !important; }

.stop-list {
  flex: 1;
  min-height: 0;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  grid-auto-rows: 1fr;
  gap: 14px;
  overflow: hidden;
}

.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: var(--grey);
  text-align: center;
  font-size: 1.1rem;
  line-height: 1.5;
}

.empty-add-btn {
  padding: 14px 28px;
  font-size: 1.1rem;
  font-weight: 700;
  background: var(--ink);
  color: var(--paper);
  border: none;
  border-radius: 10px;
}

.stop-card {
  border: 3px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.stop-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 16px;
  border-bottom: 2px solid var(--line);
  flex: none;
}

.stop-card-title {
  font-size: clamp(1rem, 1.6vw, 1.3rem);
  font-weight: 700;
}

.stop-card-code {
  font-size: 0.8rem;
  color: var(--grey);
  font-variant-numeric: tabular-nums;
}

.stop-remove-btn {
  background: none;
  border: 2px solid var(--line);
  border-radius: 6px;
  font-size: 0.9rem;
  padding: 2px 10px;
  color: var(--ink);
}

.stop-card-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.service-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: clamp(6px, 1.4vh, 16px) 18px;
  border-bottom: 1px solid #ccc;
  flex: 1;
  min-height: 0;
}

.service-row:last-child { border-bottom: none; }

.service-no {
  font-size: clamp(1.5rem, 3.4vw, 2.6rem);
  font-weight: 800;
  min-width: 3.4ch;
  line-height: 1;
}

.service-meta {
  font-size: 0.75rem;
  color: var(--grey);
  min-width: 3.5ch;
}

.service-arrivals {
  margin-left: auto;
  display: flex;
  gap: clamp(10px, 2vw, 26px);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.arrival-mins {
  font-size: clamp(1.8rem, 4.2vw, 3.4rem);
  font-weight: 800;
  min-width: 2.4ch;
  line-height: 1;
}

.arrival-mins.due { text-decoration: underline; }

.arrival-sub {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--grey);
  display: block;
  text-align: center;
  margin-top: 2px;
}

.stop-error {
  padding: 14px 16px;
  color: var(--grey);
  font-size: 1rem;
  margin: auto;
}

.overlay {
  position: fixed;
  inset: 0;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.overlay-header {
  display: flex;
  gap: 10px;
  padding: 16px;
  border-bottom: 3px solid var(--line);
}

#search-input {
  flex: 1;
  font-size: 1.05rem;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
}

.text-btn {
  background: none;
  border: none;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 700;
  padding: 0 6px;
}

.search-results {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  columns: 2;
  column-gap: 0;
}

.search-results li {
  padding: 14px 16px;
  border-bottom: 1px solid #ccc;
  break-inside: avoid;
}

.search-results li .sr-code {
  font-weight: 800;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.search-results li .sr-desc {
  font-size: 0.9rem;
}

.search-results li .sr-road {
  font-size: 0.8rem;
  color: var(--grey);
}

.search-empty {
  padding: 30px 16px;
  color: var(--grey);
  text-align: center;
  columns: 1;
}

/* Narrow/portrait fallback (e.g. rotating the device, or a phone browser tab
   that isn't running the locked-landscape installed PWA): stack single column
   and allow the page to scroll instead of clipping content. */
@media (orientation: portrait), (max-width: 640px) {
  html, body { overflow-y: auto; height: auto; min-height: 100dvh; }
  .stop-list {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
    overflow: visible;
  }
  .stop-card { min-height: 200px; }
  .stop-card-body { overflow-y: visible; }
  .search-results { columns: 1; }
}
