/* ---------------------------------------------------------------------------
   The parent-facing pages: the live map, signing in, and accepting an invite.
   Parents open these on a phone in a driveway, often in sunlight and often
   one-handed, so the map gets the whole screen and the controls stay large.

   The admin console has its own stylesheet, admin.css. It is a desk tool built
   around a map and a panel, and the two want different furniture; keeping them
   apart means neither is restyled by accident when the other changes.
   --------------------------------------------------------------------------- */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #d9dde3;
  --text: #1b1f24;
  --muted: #5c6672;
  --accent: #1d4ed8;
  --accent-text: #ffffff;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --ok: #067647;
  --warn: #b54708;
  --warn-bg: #fffaeb;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.1), 0 1px 2px rgba(16, 24, 40, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --surface: #1c2027;
    --border: #333a44;
    --text: #e8eaed;
    --muted: #98a2b3;
    --accent: #5b8def;
    --danger: #f97066;
    --danger-bg: #2d1b1a;
    --ok: #47cd89;
    --warn: #fdb022;
    --warn-bg: #2b2213;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

a { color: var(--accent); }

/* --- Layout --------------------------------------------------------------- */

.page {
  max-width: 60rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.centered {
  max-width: 26rem;
  margin: 3rem auto;
  padding: 0 1rem;
}

.row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.stack > * + * { margin-top: 0.75rem; }

h1 { font-size: 1.5rem; margin: 0 0 0.25rem; }
h2 { font-size: 1.15rem; margin: 0 0 0.75rem; }

.muted { color: var(--muted); font-size: 0.9rem; }

/* --- Forms ---------------------------------------------------------------- */

label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.25rem; }

input, select, textarea {
  width: 100%;
  padding: 0.6rem 0.7rem;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

input:focus-visible, select:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button, a.button {
  font: inherit;
  font-weight: 600;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-block;
  text-decoration: none;
}

button.primary, a.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.small { padding: 0.35rem 0.6rem; font-size: 0.85rem; }
button:disabled { opacity: 0.55; cursor: not-allowed; }

/* --- Messages ------------------------------------------------------------- */

.error {
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  font-size: 0.92rem;
  margin: 0.75rem 0;
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid currentColor;
}
.error p { margin: 0; }
.error ul { margin: 0.4rem 0 0; padding-left: 1.1rem; }

/* --- Map page ------------------------------------------------------------- */

.map-page { display: flex; flex-direction: column; height: 100%; }

/* Installed to the home screen there is no browser chrome, so the app itself
   has to keep clear of the notch and the home indicator. These insets are 0
   in a normal tab, so the same rules serve both. */
.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  padding-top: calc(0.6rem + env(safe-area-inset-top));
  padding-left: calc(1rem + env(safe-area-inset-left));
  padding-right: calc(1rem + env(safe-area-inset-right));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

/* On a phone the route name is long and the buttons matter more, so the title
   takes the leftover space and truncates rather than wrapping the controls
   onto a second row. */
.topbar h1 {
  font-size: 1.05rem;
  margin: 0;
  flex: 1 1 6rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar .spacer { flex: 0 1 auto; }
.topbar select { width: auto; min-width: 12rem; }

#map { flex: 1; min-height: 0; background: var(--bg); }

.status {
  padding: 0.55rem 1rem;
  padding-bottom: calc(0.55rem + env(safe-area-inset-bottom));
  padding-left: calc(1rem + env(safe-area-inset-left));
  padding-right: calc(1rem + env(safe-area-inset-right));
  font-size: 0.9rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Google's logo and terms links must stay visible in standalone mode -- their
   terms require the attribution not be obscured or moved off-screen. */
#map .gm-style-cc, #map a[href*="maps.google.com"] { margin-right: env(safe-area-inset-right); }

.install-hint {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0.5rem 1rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--muted); flex: none; }
.dot.live { background: var(--ok); }
.dot.stale { background: var(--warn); }
.dot.off { background: var(--muted); }

/* The bus marker is a rotating arrow so heading is readable at a glance. The
   transition is on the arrow itself rather than the wrapper, because Google
   positions the wrapper and animating that would fight the map. */
.bus-marker svg { display: block; overflow: visible; }
.bus-marker .bus-arrow { transform-origin: 16px 16px; transition: transform 0.4s linear; }

/* Shown in place of the map when no API key is configured or Maps fails to
   load, so the page explains itself instead of showing an empty rectangle. */
.map-unavailable {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.25rem;
  padding: 2rem 1.5rem;
  background: var(--bg);
  color: var(--muted);
}
.map-unavailable p { margin: 0; }
