/* trail-filters.css — the trail map's Filters button and panel (trail-filters.js, 2026-10-29).
   The button sits in the map's top left corner; the panel is a card under it on wider screens and a sheet from the
   bottom on a phone (760 px or less), over the page's own sheet. The controls inside keep their own classes and
   scripts (trail-map.css's .tm-filter and key, map.css's switches); this only fits them to the panel. */

/* The corner the page gives the button (a fallback only: trail-map.css places it) */
:where(.tm-map-tl) { position: absolute; top: 12px; left: 12px; z-index: 3; display: flex; gap: 8px; }

/* ---------- The button ---------- */
.tmf-pill {
  position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px 0 14px;
  border-radius: 999px; border: 1px solid var(--stroke); background: #fff; color: var(--navy);
  font: inherit; font-size: 15px; font-weight: 600; line-height: 1; box-shadow: var(--shadow); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.tmf-pill svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .tmf-pill:hover { background: #f3f6fa; } }
.tmf-pill[aria-expanded="true"] { border-color: var(--navy); }
.tmf-pill:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
/* How many filters differ from the map's start (its words are in the button's name, for screen readers) */
.tmf-badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-right: -6px; box-sizing: border-box;
  border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 700;
}
.tmf-badge[hidden] { display: none; }

/* ---------- The panel ---------- */
.tmf-panel {
  position: fixed; z-index: 50; width: 340px; max-width: calc(100vw - 16px); box-sizing: border-box;
  display: flex; flex-direction: column; overflow: hidden;
  background: #fff; color: var(--text); border: 1px solid var(--stroke); border-radius: 16px;
  box-shadow: 0 12px 40px rgb(var(--navy-rgb) / .18), 0 1px 3px rgb(var(--navy-rgb) / .1);
  font-size: var(--text-base); animation: tmf-in var(--dur-fast) var(--ease-out);
}
.tmf-panel[hidden] { display: none; }
/* A phone: a sheet from the bottom, over the page's own sheet and its tabs */
.tmf-panel.is-sheet {
  top: auto; left: 0; right: 0; bottom: 0; width: auto; max-width: none;
  max-height: 85vh; max-height: min(85dvh, calc(100dvh - 56px));
  border-radius: 16px 16px 0 0; border-bottom: 0; padding-bottom: env(safe-area-inset-bottom);
  animation: tmf-up var(--dur) var(--ease-sheet);
}
.tmf-veil { position: fixed; inset: 0; z-index: 49; background: rgb(var(--navy-rgb) / .32); animation: tmf-fade var(--dur-fast) var(--ease); }
.tmf-veil[hidden] { display: none; }
/* A message from a switch (friends.js's toast) shows over the panel, not under it */
body.tmf-open .toast { z-index: 51; }

.tmf-head { flex: none; display: flex; align-items: center; gap: 4px; padding: 6px 6px 6px 18px; border-bottom: 1px solid var(--separator); }
.tmf-head h2 { flex: 1; margin: 0; font-size: var(--text-lg); font-weight: 700; letter-spacing: var(--tracking-title); color: var(--navy); }
.tmf-head h2:focus:not(:focus-visible) { outline: none; }
.tmf-reset {
  min-height: 44px; padding: 0 12px; border: 0; border-radius: var(--radius-sm); background: none; cursor: pointer;
  font: inherit; font-size: 15px; font-weight: 600; color: var(--accent);
}
.tmf-reset[aria-disabled="true"] { color: var(--muted); cursor: default; }
.tmf-close {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center; border: 0; border-radius: 50%;
  background: none; color: var(--text); cursor: pointer;
}
.tmf-close svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
@media (hover: hover) { .tmf-reset:not([aria-disabled="true"]):hover, .tmf-close:hover { background: var(--fill-2); } }
.tmf-reset:focus-visible, .tmf-close:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: -1px; }

.tmf-body { overflow-y: auto; overscroll-behavior: contain; padding: 4px 0 10px; }
.tmf-sec { padding: 12px 18px 4px; }
.tmf-sec + .tmf-sec { margin-top: 6px; border-top: 1px solid var(--separator); }
.tmf-sec[hidden] { display: none; }
.tmf-h { margin: 0 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
/* A folding section (trail-filters.js, 2026-11-16): its heading a row the panel's width, its name, what's on and a
   chevron; closed at first, so the panel opens short */
.tmf-sec-fold { padding-top: 4px; padding-bottom: 0; }
.tmf-h-fold { margin: 0 -18px; text-transform: none; letter-spacing: 0; }
.tmf-fold {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 0 18px; margin: 0; box-sizing: border-box;
  border: 0; background: none; color: var(--text); font: inherit; font-size: 15px; font-weight: 600; text-align: left; cursor: pointer;
}
@media (hover: hover) { .tmf-fold:hover { background: var(--fill); } }
.tmf-fold:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: -3px; }
.tmf-fold-title { flex: 1 1 auto; min-width: 0; }
.tmf-fold-sum { flex: none; font-size: 13px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.tmf-sec-fold.is-open .tmf-chev { transform: rotate(180deg); }
.tmf-sec-body { padding-bottom: 6px; }

/* Difficulty: the colour buttons wrap in a grid, never a row that scrolls sideways (trail-map.css's phone rule) */
.tmf-panel .tm-filters.tmf-levels {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 8px;
  margin: 0; padding: 0 0 8px; overflow: visible;
}
.tmf-panel .tm-filter { height: auto; min-height: 44px; justify-content: center; padding: 0 10px; border-radius: var(--radius-sm); }
.tmf-panel .tm-filter .tm-glyph { width: 15px; height: 15px; }

/* Show on map, Friends, Avalanche: map.css's rows with their switches, the panel's full width */
.tmf-panel .layers-menu { margin: 0 -18px; border-top: 0; animation: none; }
.tmf-panel .layers-menu .control { width: 100%; min-width: 0; height: auto; min-height: 46px; padding: 0 18px; border-radius: 0; }
.tmf-panel .layers-menu .control + .control { border-top: 1px solid var(--separator-soft); }
.tmf-panel .layers-menu .control:hover { background: transparent; }   /* map.css's glass hover, on white */
@media (hover: hover) { .tmf-panel .layers-menu .control:hover { background: var(--fill); } }
.tmf-panel .control-label { white-space: normal; padding: 6px 0; line-height: 1.25; }

/* Only what's open: the switch, and under it where the statuses come from (or why there are none) */
.tmf-panel .layers-menu .control[aria-disabled="true"] { cursor: default; }
.tmf-panel .layers-menu .control[aria-disabled="true"] > *, .tmf-panel .layers-menu .control[aria-disabled="true"]::after { opacity: .45; }
.tmf-note { margin: 2px 0 8px; font-size: 13px; line-height: 1.4; color: var(--muted); }
.tmf-retry {
  min-height: 32px; padding: 0 4px; margin: 0 -4px; border: 0; border-radius: var(--radius-sm); background: none; cursor: pointer;
  font: inherit; font-weight: 600; color: var(--accent); text-decoration: underline; text-underline-offset: 2px;
}
.tmf-retry[hidden] { display: none; }
.tmf-retry:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 1px; }

/* Map key: the key's button as a row that opens the legend under it */
.tmf-key-sec { padding-top: 4px; padding-bottom: 0; }
.tmf-panel .tm-key { position: static; display: block; }
.tmf-panel .tm-key-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: calc(100% + 36px); min-height: 46px; height: auto; margin: 0 -18px; padding: 0 18px;
  border: 0; border-radius: 0; background: none; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none;
  font-size: 15px; font-weight: 600; color: var(--text); text-align: left;
}
@media (hover: hover) { .tmf-panel .tm-key-toggle:hover { background: var(--fill); } }
.tmf-panel .tm-key-toggle:focus-visible { outline-offset: -3px; }
.tmf-chev { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform var(--dur-fast) var(--ease); }
.tm-key.is-open .tmf-chev { transform: rotate(180deg); }
.tmf-panel .tm-legend {
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px 14px; padding: 4px 0 10px;
  background: none; border: 0; border-radius: 0; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none;
  font-size: 13.5px;
}
.tmf-panel .tm-legend li { white-space: normal; }

@keyframes tmf-in { from { opacity: 0; transform: translateY(-4px); } }
@keyframes tmf-up { from { transform: translateY(100%); } }
@keyframes tmf-fade { from { opacity: 0; } }
/* On the way out (trail-filters.js leaveAs) */
@keyframes tmf-out { to { opacity: 0; transform: translateY(-4px); } }
@keyframes tmf-down { to { transform: translateY(100%); } }
@keyframes tmf-fade-out { to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .tmf-panel, .tmf-veil { animation: none; }
  .tmf-chev { transition: none; }
}
