/* TruckAhead Phase 1 — glanceable-first design (PLAN.md):
   big icons, minimal text, body >= 16px, huge tap targets.
   Cards always size to content (flex:0 0 auto) — never let a flex
   column shrink a card and spill its contents. */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.35;
  color: #14202b;
  background: #eef1f4;
  -webkit-text-size-adjust: 100%;
}
:root {
  --open: #cf2418;
  --closed: #1c8a45;
  --unknown: #868d96;
  --navy: #0b2a4a;
  --card: #ffffff;
  --hair: #d8dee4;
}

.app-header {
  background: var(--navy);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { min-width: 0; }
.brand-name { font-size: 26px; font-weight: 800; letter-spacing: .2px; }
.brand-sub { font-size: 16px; opacity: .85; overflow-wrap: anywhere; }
.lang-switch { display: flex; gap: 6px; flex: 0 0 auto; }
.lang-switch button {
  min-width: 48px; min-height: 48px;
  border: 1px solid rgba(255,255,255,.45); border-radius: 10px;
  background: transparent; color: #fff; font-size: 16px; font-weight: 600;
  padding: 6px 8px; cursor: pointer;
}
.lang-switch button.on { background: #fff; color: var(--navy); }

main { max-width: 860px; margin: 0 auto; padding: 12px; display: flex; flex-direction: column; gap: 12px; }

/* ---------- status badges: color + shape, tier by ring style ---------- */
.badge {
  flex: 0 0 auto;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.badge svg { display: block; }
.badge-56 { width: 56px; height: 56px; }
.badge-72 { width: 72px; height: 72px; }
.badge-76 { width: 76px; height: 76px; }
.badge.open    { background: var(--open); }
.badge.closed  { background: var(--closed); }
.badge.unknown { background: var(--unknown); }
/* single unconfirmed report: dashed ring, same color/shape language */
.badge.reported { background: #fff; border: 4px dashed currentColor; }
.badge.reported.open   { color: var(--open); }
.badge.reported.closed { color: var(--closed); }
.badge.reported svg * { stroke: currentColor; }

/* ---------- Layer-0 glance card ---------- */
.glance-card {
  flex: 0 0 auto;
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  display: flex; gap: 14px; align-items: center;
  box-shadow: 0 1px 4px rgba(11,42,74,.14);
  cursor: pointer; width: 100%; border: 0; text-align: left;
  font: inherit; color: inherit;
}
.glance-main { flex: 1 1 auto; min-width: 0; }
.glance-label { font-size: 16px; font-weight: 700; color: #5a6672; text-transform: uppercase; letter-spacing: .6px; }
.glance-name { font-size: 27px; font-weight: 800; line-height: 1.15; overflow-wrap: anywhere; }
.glance-meta { font-size: 17px; color: #3c4753; overflow-wrap: anywhere; }
.glance-side { flex: 0 0 auto; text-align: right; }
.glance-dist { font-size: 34px; font-weight: 800; line-height: 1; }
.glance-dist small { font-size: 18px; font-weight: 700; }
.glance-status { font-size: 21px; font-weight: 800; margin-top: 4px; }
.glance-status.open { color: var(--open); }
.glance-status.closed { color: var(--closed); }
.glance-status.unknown { color: var(--unknown); }
.glance-updated { font-size: 16px; color: #5a6672; margin-top: 2px; }

/* ---------- map ---------- */
.map-wrap { flex: 0 0 auto; border-radius: 16px; overflow: hidden; box-shadow: 0 1px 4px rgba(11,42,74,.14); }
#map { height: 46vh; min-height: 300px; width: 100%; background: #dfe7ec; }
.pin {
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 3px solid #fff;
  box-shadow: 0 1px 5px rgba(0,0,0,.45);
}
.pin.open { background: var(--open); }
.pin.closed { background: var(--closed); }
.pin.unknown { background: var(--unknown); }
.pin.reported { background: #fff; border-style: dashed; }
.pin.reported.open { border-color: var(--open); }
.pin.reported.closed { border-color: var(--closed); }
.pin.reported svg * { stroke: currentColor; }
.pin.reported.open { color: var(--open); }
.pin.reported.closed { color: var(--closed); }

/* ---------- station list ---------- */
.list-wrap { flex: 0 0 auto; background: var(--card); border-radius: 16px; box-shadow: 0 1px 4px rgba(11,42,74,.14); overflow: hidden; }
.list-wrap h2 { font-size: 20px; margin: 0; padding: 14px 16px 6px; }
.list-hint { font-size: 16px; color: #5a6672; padding: 0 16px 8px; }
.station-row {
  display: flex; gap: 12px; align-items: center;
  width: 100%; min-height: 78px;
  padding: 10px 16px; background: none; border: 0; border-top: 1px solid var(--hair);
  font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.station-row:active { background: #f0f4f8; }
.row-main { flex: 1 1 auto; min-width: 0; }
.row-name { font-size: 20px; font-weight: 700; overflow-wrap: anywhere; }
.row-meta { font-size: 16px; color: #5a6672; overflow-wrap: anywhere; }
.row-dist { flex: 0 0 auto; font-size: 18px; font-weight: 700; color: #3c4753; }

.foot { font-size: 16px; color: #5a6672; padding: 4px 4px 20px; }

/* ---------- detail sheet ---------- */
/* Leaflet controls sit at z-index 1000 — the sheet must paint above them. */
#sheet-backdrop {
  position: fixed; inset: 0; background: rgba(8,20,32,.5); z-index: 1100;
}
#sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1101;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  max-height: 90vh; overflow-y: auto;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 24px rgba(0,0,0,.3);
}
.sheet-head { display: flex; gap: 14px; align-items: center; }
.sheet-title { flex: 1 1 auto; min-width: 0; }
.sheet-name { font-size: 27px; font-weight: 800; line-height: 1.15; overflow-wrap: anywhere; }
.sheet-route { font-size: 18px; color: #3c4753; overflow-wrap: anywhere; }
.sheet-status { font-size: 32px; font-weight: 800; line-height: 1.1; margin-top: 10px; }
.sheet-status.open { color: var(--open); }
.sheet-status.closed { color: var(--closed); }
.sheet-status.unknown { color: var(--unknown); }
.sheet-close {
  flex: 0 0 auto; width: 52px; height: 52px; border-radius: 50%;
  border: 1px solid var(--hair); background: #f2f5f8; font-size: 22px; cursor: pointer;
}
.sheet-lines { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; font-size: 17px; }
.sheet-lines .k { color: #5a6672; font-weight: 600; }
.tier-line { font-weight: 700; }
.collecting {
  margin-top: 12px; background: #f2f5f8; border: 1px dashed var(--hair);
  border-radius: 12px; padding: 12px; font-size: 16px;
}
.collecting .t { font-weight: 700; display: block; margin-bottom: 2px; }
.report-prompt { margin: 16px 0 10px; font-size: 18px; font-weight: 700; }
.report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.report-btn {
  min-height: 108px; border: 0; border-radius: 16px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  color: #fff; font-size: 25px; font-weight: 800; padding: 10px 6px;
}
.report-btn.open { background: var(--open); }
.report-btn.closed { background: var(--closed); }
.report-btn:active { filter: brightness(1.15); }
.report-btn[disabled] { opacity: .55; }
.report-msg { margin-top: 12px; font-size: 17px; font-weight: 700; min-height: 24px; }
.report-msg.ok { color: var(--closed); }
.report-msg.err { color: var(--open); }

@media (max-width: 400px) {
  .brand-name { font-size: 23px; }
  .glance-name { font-size: 24px; }
  .glance-dist { font-size: 29px; }
  .report-btn { font-size: 22px; }
}
