/* ---------- tokens ----------
   Brand colours from the Boulder Nordic Club site: logo blue #005daa, navy
   #0c3d54, text #222. The map itself stays light in every theme — it's a
   light basemap by design, and readable in sunlight beats matching the OS. */
:root {
  --brand: #005daa;
  --brand-ink: #0c3d54;
  --panel: #ffffff;
  --ink: #222222;
  --ink-2: #575760;
  --hover: #eef4fa;
  --shadow: 0 1px 2px rgba(16,32,48,.08), 0 8px 24px rgba(16,32,48,.10);
  --radius: 10px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.45 var(--font); color: var(--ink); background: #f7f8f8; overflow: hidden; }
button { font: inherit; color: inherit; }

#map { position: absolute; inset: 0; }

/* ---------- trail list ---------- */
#panel {
  position: absolute; top: 10px; left: 10px; z-index: 2;
  width: 280px; max-width: calc(100vw - 70px); max-height: calc(100dvh - 150px); /* room for the club card */
  display: flex; flex-direction: column;
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  border-top: 4px solid var(--brand);
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 48px; padding: 10px 14px; border: 0; background: none; cursor: pointer; text-align: left;
}
.brand { font-weight: 650; font-size: 15px; color: var(--brand-ink); }
.chev { color: var(--ink-2); transition: transform .15s; }
#panel.is-collapsed .chev { transform: rotate(-90deg); }
#panel.is-collapsed .list { display: none; }

.list { overflow-y: auto; padding: 0 6px 6px; color: var(--ink-2); }
.list:empty::before { content: "Loading…"; display: block; padding: 4px 6px 6px; }
.list-head {
  margin: 8px 8px 2px; font-size: 11px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-2);
}
.item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  min-height: 44px; padding: 8px; border: 0; border-radius: 6px; background: none;
  cursor: pointer; text-align: left; color: var(--ink);
}
.item:hover, .item:focus-visible { background: var(--hover); }
.item:focus-visible, .panel-head:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.swatches { flex: none; display: flex; gap: 2px; width: 30px; }
.swatch { flex: none; display: inline-block; width: 12px; height: 5px; border-radius: 3px; }
.swatches .swatch:only-child { width: 22px; }
.swatches.is-place .swatch {
  width: 20px; height: 20px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.15);
  color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
}
.name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.len { flex: none; color: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ---------- areas in the list ---------- */
.area { border-bottom: 1px solid #eceef1; }
.area > summary {
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px;
  cursor: pointer; list-style: none; color: var(--brand-ink); font-weight: 600;
  border-radius: 6px;
}
.area > summary::-webkit-details-marker { display: none; }
.area > summary::before {
  content: "▸"; flex: none; width: 12px; color: var(--ink-2); transition: transform .15s;
}
.area[open] > summary::before { transform: rotate(90deg); }
.area > summary:hover { background: var(--hover); }
.area > summary:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.area-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.area > summary .len {
  background: #eef1f4; border-radius: 10px; padding: 0 7px; font-weight: 500; line-height: 20px;
}
.area-show {
  display: block; margin: 0 8px 4px 28px; padding: 6px 0; border: 0; background: none;
  color: var(--brand); font-size: 13px; cursor: pointer; text-decoration: underline;
  text-underline-offset: 2px;
}
.area .item { padding-left: 20px; }

/* ---------- popup ---------- */
.maplibregl-popup-content { border-radius: 8px; padding: 12px 14px; font: 14px/1.45 var(--font); color: var(--ink); }
.maplibregl-popup-close-button { width: 32px; height: 32px; font-size: 20px; }
.pop h3 { margin: 0 24px 2px 0; font-size: 15px; color: var(--brand-ink); }
.pop .meta { display: block; color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.pop .profile { display: block; width: 100%; height: auto; margin: 8px 0 2px; }
.pop .profile-slot { display: block; margin: 8px 0; color: var(--ink-2); font-size: 12px; }
.pop p { margin: 6px 0 0; white-space: pre-line; }
.pop p .swatch { width: 14px; margin-right: 6px; vertical-align: middle; }

/* ---------- popup conditions ---------- */
.pop-conditions { margin-top: 10px; padding-top: 8px; border-top: 1px solid #eceef1; }
.pop-conditions h4 {
  margin: 0 0 6px; font-size: 11px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-2);
}
.cond-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.cond-card {
  display: flex; align-items: flex-start; gap: 7px; min-height: 44px; padding: 7px 8px;
  border: 1px solid #e3e7eb; border-radius: 8px; background: #fbfcfd;
  color: var(--brand-ink); text-decoration: none; line-height: 1.25;
}
.cond-card:hover { background: var(--hover); border-color: #c9d6e3; }
.cond-card:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.cond-card svg { flex: none; color: var(--brand); margin-top: 1px; }
.cond-text { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.cond-label { font-size: 12px; font-weight: 600; }
.cond-value { font-size: 12px; color: var(--ink); }
.cond-value:empty { display: none; }
.danger-chip {
  display: inline-block; padding: 1px 7px; border-radius: 9px; font-weight: 600;
  color: #222; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12);
}
.pop-ref { display: block; margin-top: 10px; font-size: 11px; color: #9aa3ab; }

/* ---------- popup actions ---------- */
.pop-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pop-actions button {
  min-height: 36px; padding: 0 12px; border: 1.5px solid var(--brand); border-radius: 18px;
  background: #fff; color: var(--brand); font: 600 13px/1 var(--font); cursor: pointer;
}
.pop-actions button:hover { background: var(--hover); }
.pop-actions button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- filters (js/filters.js) ---------- */
.panel-filters { padding: 0 10px 8px; border-bottom: 1px solid #e6e8eb; }
#panel.is-collapsed .panel-filters { display: none; }
.item[hidden] { display: none; }
.flt-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.flt-chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 0 10px;
  font: 500 13px/1 var(--font); color: var(--ink-2);
  background: #fff; border: 1.5px solid #cfd6dd; border-radius: 20px;
  cursor: pointer; touch-action: manipulation;
}
.flt-chip[aria-pressed="true"] { color: var(--brand-ink); background: var(--hover); border-color: var(--brand); }
.flt-chip[aria-pressed="false"] .flt-swatch { opacity: 0.35; }
.flt-chip:hover { background: var(--hover); }
.flt-chip:focus-visible, .flt-groomed-input:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.flt-swatch, .lgd-swatch { flex: none; display: block; }
.flt-groomed {
  display: flex; align-items: center; gap: 10px; min-height: 40px; margin-top: 4px;
  font: 500 13px/1.2 var(--font); color: var(--ink); cursor: pointer;
}
.flt-groomed-input { width: 20px; height: 20px; margin: 0; accent-color: var(--brand); }

.lgd-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 8px; }
.lgd-row { display: flex; align-items: center; gap: 8px; min-width: 0; font: 400 12px/1.2 var(--font); color: var(--ink); }
.lgd-disc {
  flex: none; width: 18px; height: 18px; margin: 0 2px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--brand-ink); color: #fff; border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.2); font: 700 10px/1 var(--font);
  box-sizing: content-box;
}

/* ---------- map key (floating, bottom-right) ---------- */
.key-ctrl { display: flex; flex-direction: column; align-items: flex-end; }
.key {
  width: 250px; max-width: calc(100vw - 20px); padding: 8px 10px 10px;
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  font: 13px/1.4 var(--font); color: var(--ink);
}
.key[hidden], .key-show[hidden] { display: none; }
.key-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.key-head h2 { margin: 0; font-size: 13px; font-weight: 650; color: var(--brand-ink); }
.key-hide, .key-show {
  min-height: 32px; padding: 0 10px; border: 0; border-radius: 16px; cursor: pointer;
  font: 600 12px/1 var(--font); color: var(--brand); background: transparent;
}
.key-hide:hover { background: var(--hover); }
.key-show { min-height: 40px; padding: 0 14px; background: var(--panel); box-shadow: var(--shadow); }
.key-hide:focus-visible, .key-show:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.key .toggle { margin-top: 6px; padding: 0; border-top: 1px solid #eceef1; padding-top: 4px; }
.key .legend { padding: 2px 0 0; }

/* ---------- club card (floating, bottom-left) ---------- */
.club {
  display: flex; align-items: center; gap: 10px; width: 280px; max-width: calc(100vw - 150px);
  padding: 8px 12px 8px 8px; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  border-left: 4px solid var(--brand); font: 12px/1.35 var(--font); color: var(--ink-2);
}
.club-logo { flex: none; width: 40px; height: 40px; }
.club-text { min-width: 0; }
.club-text p { margin: 0; }
.club-pitch { color: var(--ink); }
.club-join { display: inline-block; padding: 2px 0; font-weight: 650; font-size: 13px; color: var(--brand); }
.club-feedback a { color: var(--brand); overflow-wrap: anywhere; }

/* ---------- map options ---------- */
.toggle { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 6px; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--brand); margin: 0; }
.legend[hidden] { display: none; }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; padding: 2px 6px 4px; font-size: 12px; color: var(--ink-2); }
.legend-row { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.legend .swatch { width: 14px; height: 10px; border-radius: 2px; opacity: .8; }

@media (max-width: 640px) {
  #panel { width: auto; right: 60px; }
  /* Phones: just the logo, the join link and the email. */
  .club { gap: 8px; padding: 6px 10px 6px 6px; }
  .club-logo { width: 32px; height: 32px; }
  .club-pitch { display: none; }
}

/* Bigger map controls on touch screens — usable with cold or gloved hands. */
@media (pointer: coarse) {
  .maplibregl-ctrl-group button { width: 40px; height: 40px; }
  #panel { right: 70px; }
}

/* ---------- offline indicator (shown by the is-offline class on <body>, set in app.js) ---------- */
.offline-note {
  display: none; position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 20;
  padding: 6px 12px; border-radius: 999px; background: var(--brand-ink); color: #fff;
  font: 500 12px/1.3 var(--font); box-shadow: var(--shadow); pointer-events: none; white-space: nowrap;
}
.is-offline .offline-note { display: block; }

/* ---------- partner popup (club supporters) ---------- */
.partner-logo { display: block; width: 230px; max-width: 100%; height: auto; margin: 2px 0 6px; }
.center-logo { width: auto; max-width: 230px; max-height: 56px; }
.partner-tag { margin: 0 0 4px; font-size: 12px; font-weight: 600; color: var(--brand); text-transform: uppercase; letter-spacing: 0.03em; }
.partner-info { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin: 8px 0 0; font-size: 13px; }
.partner-info dt { color: #6b737c; }
.partner-info dd { margin: 0; }
.partner-info a { color: var(--brand); }

/* ---------- coordinates under the mouse ---------- */
.coords {
  margin-top: 6px; padding-top: 4px; border-top: 1px solid #eceef1;
  font-size: 12px; font-variant-numeric: tabular-nums; color: var(--ink);
}
.coords[hidden] { display: none; }
.point-pop .maplibregl-popup-content { padding: 8px 30px 8px 12px; }
.point-ll, .point-elev { display: block; font-variant-numeric: tabular-nums; }
.point-ll { font-size: 13px; }
.point-elev { font-size: 15px; font-weight: 600; }
