/* BC Hunt Map — mobile-first. Category colours (--c-*) are set from app.js so the
   map layers, legend and status chips always share one definition. */
:root {
  --bg: #0e1512;
  --panel: #141d18;
  --panel-2: #1b2620;
  --line: rgba(255, 255, 255, .11);
  --text: #f1f5ef;
  --mute: #a3b5a9;
  --ok: #34d27b;
  --gps: #2f9bff;
  --unknown: #8d9a92;
  --peek: 158px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
body { position: fixed; inset: 0; overflow: hidden; touch-action: manipulation; }

button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--gps); outline-offset: 2px; }
small { color: var(--mute); font-weight: 400; }

/* ---------- map ---------- */
#map { position: absolute; z-index: 0; inset: 0 0 calc(var(--peek) + var(--sab)) 0; background: #1a231e; }

.gps-dot {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--gps); border: 3px solid #fff;
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .5);
}
.gps-dot.stale { background: var(--unknown); }
.tap-pin {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid #fff; background: rgba(0, 0, 0, .25);
  box-shadow: 0 0 0 1.5px #000, inset 0 0 0 1.5px #000;
}
.tap-pin::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 4px; height: 4px;
  margin: -2px 0 0 -2px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px #000;
}

/* ---------- top controls ---------- */
#topbar {
  position: absolute; z-index: 3;
  top: calc(10px + var(--sat)); left: calc(10px + var(--sal));
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  max-width: calc(100% - 84px);
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }

.pill, .round, .notice, #layers, #toast {
  background: rgba(14, 21, 18, .92);
  border: 1px solid var(--line);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .45);
}
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 16px 0 12px; border-radius: 22px;
  font-weight: 650; letter-spacing: .01em;
}
.pill:disabled { opacity: .85; }
.pill svg, .round svg {
  width: 22px; height: 22px; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.notice {
  padding: 6px 11px; border-radius: 9px;
  font-size: 13px; font-weight: 600; color: var(--mute);
}
.notice.warn { color: #111; background: #ffd60a; border-color: transparent; }

#tools {
  position: absolute; z-index: 3;
  top: calc(10px + var(--sat)); right: calc(10px + var(--sar));
  display: flex; flex-direction: column; gap: 10px;
}
.round {
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center; padding: 0;
}
.round[aria-expanded="true"] { background: var(--text); color: #111; }
#btn-follow .dot { fill: currentColor; stroke: none; }
#btn-follow[aria-pressed="true"] { background: var(--gps); color: #fff; border-color: transparent; }

/* ---------- layers / legend panel ---------- */
#layers {
  position: absolute; z-index: 4;
  top: calc(10px + var(--sat)); right: calc(68px + var(--sar));
  width: min(300px, calc(100% - 84px));
  max-height: calc(100% - var(--peek) - var(--sab) - var(--sat) - 20px);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 4px 14px 14px; border-radius: 14px;
}
#layers h2, .sec-title {
  font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--mute);
}
#layers h2 { margin: 14px 0 6px; }
#layers h2 small { text-transform: none; letter-spacing: 0; font-size: 11px; }

.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label + label { border-left: 1px solid var(--line); }
.seg span { display: block; height: 100%; text-align: center; padding: 8px 2px; font-size: 14px; font-weight: 600; line-height: 1.2; color: var(--mute); }
.seg span small { display: block; margin-top: 2px; font-size: 10.5px; font-weight: 500; }
.seg input:checked + span { background: var(--text); color: #111; }
.seg input:checked + span small { color: #4a544d; }
.seg input:focus-visible + span { outline: 2px solid var(--gps); outline-offset: -2px; }

.row { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.row input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--text); }
.sw { width: 18px; height: 18px; flex: none; border-radius: 4px; border: 2px solid var(--c); background: color-mix(in srgb, var(--c) 35%, transparent); }
.legend { list-style: none; margin: 2px 0 0; padding: 0 0 0 30px; font-size: 13px; color: var(--mute); }
.legend li { display: flex; align-items: center; gap: 10px; padding: 3px 0; }
.ln { width: 26px; height: 0; flex: none; border-top: 4px solid var(--c); }
.ln.dashed { border-top-style: dashed; }
.small { font-size: 13px; color: var(--mute); margin: 0 0 10px; }
.ghost {
  width: 100%; min-height: 40px; border-radius: 10px;
  background: transparent; border: 1px solid var(--line); font-weight: 600;
}

/* colour classes (variables injected by app.js) */
.c-private { --c: var(--c-private); }
.c-all { --c: var(--c-all); }
.c-hunt { --c: var(--c-hunt); }
.c-atv { --c: var(--c-atv); }
.c-snow { --c: var(--c-snow); }
.c-open, .c-openSeasonal { --c: var(--c-open); }
.c-closed, .c-closedSeasonal { --c: var(--c-closed); }
.c-limited { --c: var(--c-limited); }
.c-ok { --c: var(--ok); }
.c-unknown { --c: var(--unknown); }

/* ---------- bottom sheet ---------- */
#sheet {
  position: absolute; z-index: 5; left: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column;
  min-height: calc(var(--peek) + var(--sab));
  max-height: min(68dvh, 620px);
  padding-bottom: var(--sab);
  background: var(--panel);
  border-top: 1px solid var(--line);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -6px 24px rgba(0, 0, 0, .5);
  transition: max-height .22s ease;
}
#sheet.collapsed { max-height: calc(var(--peek) + var(--sab)); }

#sheet-handle {
  flex: none; height: 20px; width: 100%;
  background: none; border: 0; padding: 0; cursor: pointer; touch-action: none;
}
#sheet-handle span { display: block; width: 40px; height: 4px; margin: 0 auto; border-radius: 2px; background: rgba(255, 255, 255, .32); }

#sheet-body {
  flex: 1 1 auto; min-height: 0;
  padding: 0 calc(14px + var(--sar)) 6px calc(14px + var(--sal));
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
#sheet.collapsed #sheet-body { overflow: hidden; }

#sheet footer {
  flex: none; padding: 5px 14px 7px;
  border-top: 1px solid var(--line);
  font-size: 10.5px; line-height: 1.25; text-align: center; color: var(--mute);
  background: var(--panel);
}

/* sections */
details.sec + details.sec, #sec-tap details.sec { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
details.sec > summary { list-style: none; cursor: pointer; }
details.sec > summary::-webkit-details-marker { display: none; }

.sec-head { display: flex; align-items: center; gap: 8px; min-height: 22px; }
.sec-sub { font: 12px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.sec-head .x {
  flex: none; width: 32px; height: 32px; margin: -5px -6px -5px 0; border-radius: 50%;
  background: var(--panel-2); border: 1px solid var(--line); font-size: 18px; line-height: 1; padding: 0;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip {
  display: inline-block; padding: 4px 8px; border-radius: 6px;
  font-size: 11.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; line-height: 1.15;
  background: var(--c); color: #10140f; white-space: nowrap; flex: none;
}
.chip.c-unknown { color: #fff; background: #56635b; }
.headline { margin-top: 7px; font-size: 16px; font-weight: 650; line-height: 1.25; text-wrap: pretty; }
#sheet.collapsed .chips { flex-wrap: nowrap; overflow: hidden; }
#sheet.collapsed .card, #sheet.collapsed .note { display: none; }
#sheet.collapsed .headline { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.card {
  margin-top: 10px; padding: 10px 12px;
  background: var(--panel-2); border-radius: 10px; border-left: 5px solid var(--c);
}
.card h3 { margin: 0 0 2px; font-size: 15.5px; font-weight: 700; line-height: 1.25; }
.card .kind { font-size: 12.5px; font-weight: 650; color: var(--c); }
.card dl { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; margin: 8px 0 0; font-size: 13.5px; }
.card dt { color: var(--mute); }
.card dd { margin: 0; overflow-wrap: anywhere; }
.card dd.em { font-weight: 650; }
.card dd .flag { color: #ffd60a; font-weight: 650; }
.note { margin: 10px 0 2px; font-size: 12px; color: var(--mute); line-height: 1.35; }

/* ---------- toast ---------- */
#toast {
  position: absolute; z-index: 6; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--peek) + var(--sab) + 14px);
  width: max-content; max-width: calc(100% - 28px);
  padding: 10px 14px; border-radius: 12px; font-size: 14px; font-weight: 600; text-align: center;
}

/* ---------- MapLibre chrome ---------- */
.maplibregl-ctrl-attrib { font-size: 10.5px; }

/* ---------- larger screens: sheet becomes a floating card ---------- */
@media (min-width: 760px) {
  #map { inset: 0; }
  #sheet {
    left: 12px; right: auto; bottom: 12px; width: 400px;
    border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
  }
  #toast { left: 212px; }
  #layers { max-height: calc(100% - 24px); }
  .maplibregl-ctrl-bottom-left { left: 416px; }
}

@media (prefers-reduced-motion: reduce) {
  #sheet { transition: none; }
}
