/* Hikes hub (/randonnees, /en/hikes), on top of randonnees.css: the filter bar, the cards
   and the map beside the list. Loaded only by the hub, not by the fiches. */

/* Author `display` beats the UA [hidden] rule. Only the hub components that set one,
   or that the list and the map toggle with the hidden attribute. */
.flt[hidden],
.hk[hidden],
.hk-h[hidden],
.rk[hidden],
.hk-empty[hidden],
.ls-pop[hidden],
.mk-wrap[hidden] {
  display: none;
}

/* --- Hub: filter bar and hike cards --------------------------------------------------------- */
/* After the « Liste des randonnées » board. The bar is hidden until randonnees-liste.js takes
   it over; a reader without JS keeps the list grouped by region. */

.flt {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  gap: 10px;
  margin: 24px 0 0;
  padding: 14px 0 12px;
  background: var(--canvas);
  border-bottom: 1px solid var(--border);
}

.flt-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.flt-grp {
  display: inline-flex;
  gap: 8px;
  flex: none;
}

.flt-sep {
  flex: none;
  width: 1px;
  height: 22px;
  margin: 0 4px;
  background: var(--border);
}

.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  font: 600 14px/1.2 Manrope, system-ui, sans-serif;
  white-space: nowrap;
  cursor: pointer;
}

.chip:hover {
  border-color: var(--ink-2);
  color: var(--ink);
}

.chip[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--canvas);
}

.chip i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.chip .n {
  font-size: 12px;
  font-weight: 700;
  opacity: 0.6;
}

.flt-meta {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--muted);
}

.flt-n b {
  color: var(--ink);
  font-weight: 800;
}

.flt-reset {
  margin-left: 8px;
  padding: 0;
  border: 0;
  background: none;
  font: 700 14px Manrope, system-ui, sans-serif;
  color: var(--action);
  cursor: pointer;
}

.flt-reset::before {
  content: "·";
  margin-right: 8px;
  color: var(--muted);
  font-weight: 400;
}

.flt-sort {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.flt-sort select {
  appearance: none;
  -webkit-appearance: none;
  font: 600 14px Manrope, system-ui, sans-serif;
  color: var(--ink);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%236b7a93' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 34px 7px 12px;
  cursor: pointer;
}

.flt-sort select:hover {
  border-color: var(--ink-2);
}

.hk-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
}

.hk-h h2 {
  margin: 28px 0 6px;
  font-size: 22px;
}

.hk-h:first-child h2 {
  margin-top: 20px;
}

.hk {
  position: relative;
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 18px;
  padding: 16px 10px;
  margin: 0 -10px;
  border-radius: 16px;
  border-bottom: 1px solid var(--border);
}

.hk:hover {
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--border), 0 6px 20px rgba(11, 23, 48, 0.07);
  border-bottom-color: transparent;
}

.hk-img {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  overflow: hidden;
  background: var(--map);
  border: 1px solid var(--border);
}

.hk-img img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hk-img .rk {
  position: absolute;
  left: 8px;
  top: 8px;
  padding: 2px 8px;
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 1px 4px rgba(11, 23, 48, 0.15);
}

.hk-trace {
  background-image: linear-gradient(var(--map-grid) 1px, transparent 1px), linear-gradient(90deg, var(--map-grid) 1px, transparent 1px);
  background-size: 20px 20px;
}

.trace-thumb {
  display: block;
  width: 100%;
  height: 100%;
}

.trace-thumb .line {
  fill: none;
  stroke: var(--trail);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.trace-thumb .line-halo {
  fill: none;
  stroke: var(--trail-halo);
  stroke-width: 6;
  stroke-linejoin: round;
}

.trace-thumb .start {
  fill: var(--depart);
  stroke: var(--surface);
  stroke-width: 2;
}

.hk-b {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hk-k {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--depart);
}

.hk-t {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
  font-weight: 800;
}

.hk-t a {
  color: var(--ink);
  text-decoration: none;
}

/* The whole card is the link. Only inside .hk: a popup reuses .hk-t and must not cover itself. */
.hk .hk-t a::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 16px;
}

.hk:hover .hk-t a {
  color: var(--action);
}

.hk-f {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 0;
  font-size: 15px;
  color: var(--ink-2);
}

.hk-f > span:not(:last-child)::after {
  content: "·";
  margin: 0 8px;
  color: var(--muted);
}

.hk-f b {
  color: var(--ink);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.hk-d {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}

.hk-d i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.hk-p {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hk-x {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding-top: 2px;
}

.hk-x .spark {
  flex: none;
}

.hk-x span {
  min-width: 0;
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spark-a {
  fill: var(--area);
}

.spark-l {
  fill: none;
  stroke: var(--trail);
  stroke-width: 1.6;
  stroke-linejoin: round;
}

.hk-empty {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 32px 0;
  color: var(--ink-2);
}

@media (max-width: 640px) {
  .flt {
    margin-top: 16px;
    padding: 10px 0;
  }

  .flt-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    margin: 0 -20px;
    padding: 0 20px;
  }

  .flt-row::-webkit-scrollbar {
    display: none;
  }

  .flt-sep {
    display: none;
  }

  .hk {
    grid-template-columns: 108px minmax(0, 1fr);
    gap: 14px;
    padding: 14px 8px;
    margin: 0 -8px;
  }

  .hk-img {
    aspect-ratio: 1;
  }

  .hk-t {
    font-size: 16px;
  }

  .hk-f {
    font-size: 14px;
  }

  .hk-p,
  .hk-x span {
    display: none;
  }
}

/* --- Hub: the map beside the list ----------------------------------------------------------- */
/* On a wide screen the list keeps the reading column on the left and the map, sticky, takes
   the right; on a phone the map is a full-screen layer behind the « Carte » button. The
   markers and the popup card are randonnees-liste-carte.js's; the traces are MapLibre layers,
   drawn only for the hovered or selected hike. */

main.hub-main {
  max-width: none;
  padding: 0;
}

.ls-col {
  min-width: 0;
  padding: 0 20px 48px;
}

.ls-col > .crumbs,
.ls-col > .hub {
  max-width: 780px;
  margin-left: auto;
  margin-right: auto;
}

.hk.on {
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--border), 0 6px 20px rgba(11, 23, 48, 0.07);
  border-bottom-color: transparent;
}

.hk.on .hk-t a {
  color: var(--action);
}

.ls-map {
  position: relative;
  background: var(--map);
}

/* MapLibre's own CSS makes its container `position: relative`: size it, do not inset it. */
.ls-map-gl {
  width: 100%;
  height: 100%;
}

.ls-map .maplibregl-ctrl-top-right {
  top: 56px;
}

.mk-wrap {
  position: relative;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.mk {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(11, 23, 48, 0.35);
  box-sizing: border-box;
  transition: transform 0.15s;
}

.mk-wrap.on .mk {
  transform: scale(1.3);
}

.mk-easy {
  background: var(--easy);
}

.mk-medium {
  background: var(--medium);
}

.mk-hard {
  background: var(--hard);
}

.mk-veryHard {
  background: var(--very-hard);
}

.mk-km {
  display: none;
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  white-space: nowrap;
  background: #0b1730;
  color: #fff;
  font: 700 12px Manrope, system-ui, sans-serif;
  padding: 3px 8px;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(11, 23, 48, 0.3);
  pointer-events: none;
}

.mk-wrap.on .mk-km {
  display: block;
}

.ls-zone {
  position: absolute;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  font: 700 14px Manrope, system-ui, sans-serif;
  box-shadow: 0 2px 10px rgba(11, 23, 48, 0.12);
  cursor: pointer;
  white-space: nowrap;
}

.ls-zone input {
  margin: 0;
  accent-color: var(--action);
}

.ls-pop {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 4;
  max-width: 460px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 14px;
  padding: 12px 36px 12px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 28px rgba(11, 23, 48, 0.18);
}

.ls-pop .hk-img {
  aspect-ratio: auto;
  min-height: 96px;
}

.ls-pop .hk-t {
  font-size: 16px;
}

.ls-pop .hk-f {
  font-size: 14px;
}

.ls-pop .go {
  margin-top: 2px;
  font-size: 14px;
  font-weight: 800;
}

.ls-pop .close {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 0;
  background: var(--soft);
  color: var(--ink-2);
  font: 700 16px/1 Manrope, system-ui, sans-serif;
  cursor: pointer;
}

.ls-toggle {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 60;
  height: 48px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  font: 800 15px Manrope, system-ui, sans-serif;
  box-shadow: 0 6px 20px rgba(11, 23, 48, 0.35);
  cursor: pointer;
}

@media (min-width: 981px) {
  .ls.has-map {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 44%);
    align-items: start;
  }

  .ls.has-map .ls-col {
    padding: 0 32px 48px max(20px, calc(50vw - 720px));
  }

  .ls.has-map .ls-col > .crumbs,
  .ls.has-map .ls-col > .hub {
    margin-left: 0;
  }

  .ls-map {
    position: sticky;
    top: 0;
    height: 100vh;
    min-height: 520px;
  }
}

@media (max-width: 980px) {
  .ls-map {
    position: fixed;
    inset: 0;
    z-index: 50;
  }

  .ls-locked {
    overflow: hidden;
  }

  .ls-pop {
    bottom: 84px;
    grid-template-columns: 96px minmax(0, 1fr);
  }
}
