/* Mobile-first: this is used one-handed, outdoors, in bright sunlight.
   Layout is a fixed header + flexible map + bottom control bar, so every
   interactive control sits within thumb reach at the bottom of the screen. */

:root {
  --orange: #FF7F00;
  --ink: #14261c;
  --bar: #1b3a2b;
  --bar-line: #2c5742;
  --paper: #ffffff;
  --muted: #5d6b63;
  --focus: #ffb454;
  --topbar-h: auto;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;           /* no pull-to-refresh while panning */
}

body {
  /* 100dvh tracks the mobile browser chrome as it collapses, so the control
     bar is never pushed under the URL bar. */
  height: 100dvh;
  display: flex;
  flex-direction: column;
  font: 16px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bar);
  -webkit-text-size-adjust: 100%;
}

/* ---------- header ---------- */

.topbar {
  flex: 0 0 auto;
  background: var(--bar);
  color: #fff;
  padding: max(0.55rem, env(safe-area-inset-top)) 0.85rem 0.55rem;
  border-bottom: 1px solid var(--bar-line);
}

.topbar h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.1px;
  line-height: 1.25;
}

.t-main { color: #fff; }
.t-dash { color: #7fa392; }
.t-org  { color: #bcd6c9; font-weight: 500; }

/* On narrow screens the two halves stack instead of the title shrinking. */
@media (max-width: 30rem) {
  .t-dash { display: none; }
  .t-main, .t-org { display: block; }
  .t-main { font-size: 1rem; }
  .t-org  { font-size: 0.82rem; }
}

/* ---------- map ---------- */

#map {
  flex: 1 1 auto;
  min-height: 0;                        /* let the flex child actually shrink */
  background: #e8e5de;
}

/* Keep MapLibre's own controls clear of the bottom bar and readable outdoors. */
.maplibregl-ctrl-bottom-right { margin-bottom: 0.25rem; }

.maplibregl-ctrl-group button {
  width: 44px;                          /* >= 44px touch target */
  height: 44px;
}

.maplibregl-ctrl-attrib {
  font-size: 11px;
  background: rgba(255, 255, 255, 0.85);
}

/* Keep the attribution clear of the zoom/locate column on the right, which is
   ~54px wide plus margins. Without this the expanded text runs underneath it. */
.maplibregl-ctrl-bottom-left { max-width: calc(100% - 4.25rem); }
.maplibregl-ctrl-bottom-left .maplibregl-ctrl-attrib { max-width: 100%; }

/* ---------- status toast ---------- */

.status {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 5.5rem;
  z-index: 5;
  max-width: min(92vw, 30rem);
  padding: 0.6rem 0.9rem;
  border-radius: 0.5rem;
  background: rgba(20, 38, 28, 0.92);
  color: #fff;
  font-size: 0.87rem;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.28);
}

/* ---------- bottom controls ---------- */

.controls {
  flex: 0 0 auto;
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  padding: 0.5rem 0.6rem calc(0.5rem + env(safe-area-inset-bottom));
  background: var(--bar);
  border-top: 1px solid var(--bar-line);
}

.seg {
  display: flex;
  flex: 0 0 auto;
  background: #12291e;
  border: 1px solid var(--bar-line);
  border-radius: 0.55rem;
  overflow: hidden;
}

.seg-btn,
.toggle {
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: #cfe3d8;
  background: transparent;
  border: 0;
  min-height: 44px;                     /* touch target */
  padding: 0 0.9rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.seg-btn + .seg-btn { border-left: 1px solid var(--bar-line); }

.seg-btn.is-active {
  background: #eef4f0;
  color: var(--bar);
}

.toggle {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 1px solid var(--bar-line);
  border-radius: 0.55rem;
  background: #12291e;
  min-width: 0;
}

.toggle > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toggle.is-active {
  background: #eef4f0;
  color: var(--bar);
  border-color: #eef4f0;
}

/* The swatch is the legend: it always shows the colour of the line layer. */
.swatch {
  flex: 0 0 auto;
  width: 1.15rem;
  height: 0.3rem;
  border-radius: 0.15rem;
  background: var(--orange);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
  opacity: 0.35;
}

.toggle.is-active .swatch { opacity: 1; }

.seg-btn:focus-visible,
.toggle:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: -3px;
}

/* Wider screens: the bar does not need to span the full width. */
@media (min-width: 40rem) {
  .topbar h1 { font-size: 1.15rem; }
  .controls { justify-content: flex-start; }
  .toggle { flex: 0 0 auto; }
}
