.map {
  aspect-ratio: 1 / 0.98; /* format de la France : pas de bande vide sous la Corse */
  margin: 0 calc(var(--gap) * -1);
  background: var(--bg);
}

/* Écran « Sur le terrain » : pleine largeur, au format de la France (voir .map). */
.terrain .map { height: auto; max-height: 560px; }

.map.leaflet-container { background: var(--bg); font: inherit; }

.map-marker { background: none; border: 0; }
.map-marker svg { display: block; filter: drop-shadow(0 1px 1px rgba(18, 40, 76, 0.25)); }

.map-marker--person {
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--grey-soft);
  box-shadow: 0 1px 4px rgba(18, 40, 76, 0.3);
  overflow: hidden;
}

.map-marker--person img { width: 100%; height: 100%; object-fit: cover; }

.map-detail { margin-top: 8px; display: grid; gap: 4px; }
.map-detail__kind { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.map-detail__text { color: var(--muted); font-size: 14px; }

/* Légende collée sous la carte : même cadre (arrondi, fond blanc cassé). Symboles = ceux de la carte. */
.map-box { overflow: hidden; border-radius: var(--radius-card); background: var(--card); }
.terrain .map-box { margin: 0; background: none; }
.terrain .map { margin: 0; border-radius: var(--radius-card); }
.home-map .map-box { border-radius: 0; background: none; }

.map-legend { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 14px 4px; background: var(--card); border-top: 1px solid var(--border); font-size: 14px; }
.terrain .map-legend { margin-top: 12px; border: 0; border-radius: var(--radius-card); box-shadow: var(--shadow); }
.map-legend__item {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 2px; min-height: 44px; margin: 0; padding: 2px 2px;
  border: 0; border-radius: 12px; background: none; color: var(--text); font: inherit; text-align: center; line-height: 1.2;
  transition: opacity 150ms ease, background-color 150ms ease, color 150ms ease;
}
.map-legend__item + .map-legend__item { border-left: 1px solid var(--border); border-radius: 0 12px 12px 0; }
button.map-legend__item { cursor: pointer; }
button.map-legend__item:hover { background: var(--grey-soft); }
.map-legend__symbol { position: relative; display: grid; place-items: center; flex: none; width: 28px; height: 28px; margin-bottom: 4px; transition: opacity 150ms ease; }
.map-legend__number { font-size: 17px; font-weight: 800; color: var(--navy); }
.map-legend__label { color: var(--text); font-size: 13.5px; hyphens: manual; white-space: normal; }
.map-legend__avatar { display: block; width: 28px; height: 28px; }
.map-legend__avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Filtre désactivé : entrée grisée, symbole barré. */
.map-legend__item[aria-pressed="false"] { color: var(--muted); }
.map-legend__item[aria-pressed="false"] .map-legend__symbol { opacity: 0.4; }
.map-legend__item[aria-pressed="false"] .map-legend__number, .map-legend__item[aria-pressed="false"] .map-legend__label { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.map-legend__item[aria-pressed="false"] .map-legend__symbol::after { content: ""; position: absolute; left: -3px; right: -3px; top: 50%; height: 2px; border-radius: 1px; background: var(--muted); transform: rotate(-45deg); }
@media (prefers-reduced-motion: reduce) { .map-legend__item, .map-legend__symbol { transition: none; } }


.invite__title, .invite__text { display: none; }

.person { display: grid; gap: 10px; margin-bottom: 12px; }
.person__title { font-size: 17px; }
.person__row { display: flex; align-items: center; gap: 12px; }
.person__photo { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; flex: none; }
.person__info { flex: 1; min-width: 0; }
.person__name { font-weight: 700; }
.person__meta { color: var(--muted); font-size: 14px; }
.person__notice { padding: 10px 12px; border-radius: 10px; background: var(--green-soft); font-size: 14px; }

.button--small { min-height: 44px; padding: 0 16px; font-size: 15px; }

.next-stop { display: grid; gap: 10px; margin-bottom: 12px; }
.next-stop h2 { font-size: 20px; }
.next-stop__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.next-stop__line { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.next-stop__count { color: var(--muted); font-size: 14px; }
.next-stop__count strong { color: var(--accent); }

.invite-button { min-height: 52px; font-size: 17px; }
.notice { margin-top: 10px; font-size: 14px; color: var(--muted); text-align: center; }
.notice:empty { display: none; }

.sheet {
  width: calc(100% - 2 * var(--gap));
  max-width: 398px;
  padding: var(--gap);
  border: 0;
  border-radius: var(--radius-card);
  background: var(--card);
  color: var(--text);
  box-shadow: 0 12px 40px rgba(18, 40, 76, 0.25);
}

.sheet::backdrop { background: rgba(18, 40, 76, 0.45); }
.sheet__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet__head h2 { font-size: 20px; }
.sheet__close { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--grey-soft); cursor: pointer; }

.form { display: grid; gap: 12px; }
.field { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-button);
  background: #fff;
  color: var(--text);
  font-size: 16px;
}
.form__errors { margin: 0; padding: 10px 12px 10px 28px; border-radius: 10px; background: var(--accent-soft); color: #B8321F; font-size: 14px; }

.map-wrap { position: relative; isolation: isolate; }

/* Boutons de zoom et de cadrage sous l'en-tête fixe. */
.map-wrap .leaflet-top { top: var(--map-inset-top, 0px); }
.leaflet-control-reset a { display: grid; place-items: center; width: 30px; height: 30px; color: var(--text); }

@media (min-width: 900px) {

  /* La bulle se pose sur la carte ; la légende reste dessous. */
  .map-wrap .map-detail { position: absolute; right: 16px; top: 16px; z-index: 1000; width: 340px; margin: 0; }
  .terrain .map-box { margin: 0; }
  .map-legend { padding: 12px max(40px, calc((100% - 1200px) / 2)); }
  .home-map .map-legend { padding: 12px 0; background: none; }

  .terrain__top { padding: 24px 40px 0; }
  .terrain__top .band__inner, .terrain__map .map-wrap, .terrain__side { max-width: 720px; }
  .terrain__map { padding: 16px 40px 0; }
  .terrain__map .map-wrap { margin: 0 auto; }
  .terrain .map { height: 520px; min-height: 0; }
  .terrain__cards { padding: 24px 40px 72px; }
  .terrain__side { margin: 0 auto; }
  .invite { margin: 0; padding: 28px; background: var(--card); border-radius: var(--radius-card); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
  .invite__title, .invite__text { display: block; }
  .invite__text { color: var(--muted); }
  .invite .invite-button { margin-top: auto; font-size: 18px; }
  .sheet { max-width: 440px; }
}

/* Page « Sur le terrain » : sélecteur, recherche, pastilles, cartes d'étapes ------------------ */
.terrain__top { padding: 0; }
.view-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 4px 0 14px; }
.view-switch__item { min-height: 48px; border: 0; border-radius: 999px; background: var(--card); color: var(--navy); font-size: 17px; font-weight: 600; box-shadow: var(--shadow); cursor: pointer; transition: background-color 150ms, color 150ms; }
.view-switch__item.is-active { background: var(--navy); color: #fff; }

.map-wrap .leaflet-top { top: var(--map-inset-top, 0px); }
.leaflet-control-locate button { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: var(--card); color: var(--navy); box-shadow: var(--shadow); cursor: pointer; }
.leaflet-bottom .leaflet-control-locate { margin: 0 8px 10px 0; }

.terrain__side { display: grid; gap: 14px; }
.search { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 16px; border-radius: 14px; background: var(--card); color: var(--muted); box-shadow: var(--shadow); }
.search:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.search__input { flex: 1; min-width: 0; min-height: 48px; border: 0; background: none; color: var(--text); font-size: 16px; }
.search__input:focus { outline: none; }
.search__input::placeholder { color: var(--muted); opacity: 1; }
.pills { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pills__item { min-height: 44px; border: 0; border-radius: 999px; background: var(--card); color: var(--navy); font-size: 16px; font-weight: 500; box-shadow: var(--shadow); cursor: pointer; transition: background-color 150ms, color 150ms; }
.pills__item.is-active { background: var(--navy); color: #fff; }

.stops-section { display: grid; gap: 12px; margin-top: 6px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-head h2 { font-size: 22px; color: var(--navy); }
.stops-list { display: grid; gap: 14px; }
.stops-empty { padding: 20px; border-radius: var(--radius-card); background: var(--card); text-align: center; color: var(--muted); }

.stop-card { position: relative; overflow: hidden; border-radius: var(--radius-card); background: var(--card); box-shadow: var(--shadow); }
.stop-photo { position: relative; aspect-ratio: 1200 / 260; min-height: 84px; overflow: hidden; background: linear-gradient(135deg, var(--navy), #5b3b5f 60%, var(--accent)); }
.stop-photo__img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center; } /* bandeau au format de l'image : rien n'est coupé */
.stop-photo__fallback { display: grid; place-items: center; width: 100%; height: 100%; color: #fff; }
.date-pill { position: absolute; left: 12px; top: 12px; display: grid; place-items: center; min-width: 56px; padding: 6px 8px; border-radius: 12px; background: #fff; color: var(--accent); line-height: 1; text-align: center; box-shadow: var(--shadow); }
.date-pill strong { font-size: 24px; font-weight: 800; }
.date-pill span { margin-top: 2px; font-size: 12px; font-weight: 800; letter-spacing: 0.04em; color: #C8341F; }
.stop-card__body { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px 4px; padding: 12px 14px 14px; }
.stop-card__info { display: grid; gap: 4px; min-width: 0; }
.stop-card__title { font-size: 17px; color: var(--navy); }
.stop-card__link { text-decoration: none; }
.stop-card__link::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.stop-card__action { position: relative; z-index: 2; grid-column: 2; grid-row: 1 / span 1; }
.stop-card__chevron { display: none; }
.stop-card__line { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 15px; color: var(--muted); }
.stop-card__count strong { color: #C8341F; font-weight: 700; }
.stop-card__tag { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: #C8341F; }
.stop-card__report { font-size: 15px; color: #3F4D63; }
.stop-card--past .stop-card__body { grid-template-columns: 1fr; }

.stop-detail__back { margin-bottom: 12px; }
.stop-detail__card { padding: 0; overflow: hidden; }
.stop-detail__body { display: grid; gap: 10px; padding: 18px 16px 20px; justify-items: start; }
.stop-detail__title { font-size: 26px; color: var(--navy); }
.stop-detail__text { font-size: 17px; color: #3F4D63; }
.correspondents-list { display: grid; gap: 12px; max-width: 720px; }

.person-card { padding: 14px; }
.person-card .person__row { flex-wrap: wrap; }
.person-card .person__photo { width: 56px; height: 56px; }
.person-card .person__photo--empty { background: var(--grey-soft); }
.person-card .person__info { flex: 1 1 140px; }
.person__count { color: var(--muted); font-size: 15px; }

@media (prefers-reduced-motion: reduce) { .view-switch__item, .pills__item { transition: none; } }

/* Géolocalisation proposée : invitation, repère « Vous êtes ici », bloc « Près de chez vous » ---------- */
.geoloc { display: grid; gap: 12px; margin: 0 0 12px; padding: 14px 16px; border-radius: var(--radius-card); background: var(--card); box-shadow: var(--shadow); }
.geoloc[hidden], .nearby[hidden] { display: none; }
.geoloc__title { display: flex; align-items: center; gap: 8px; font-size: 17px; color: var(--navy); }
.geoloc__title svg { flex: none; color: var(--accent); }
.geoloc__lead { margin: 6px 0 0; font-size: 15px; color: #3F4D63; }
.geoloc__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.geoloc__go { min-height: 44px; }
.geoloc__later { min-height: 44px; padding: 0 8px; border: 0; background: none; color: var(--navy); font: inherit; font-size: 15px; font-weight: 600; text-decoration: underline; cursor: pointer; }
/* Accueil : une ligne et un bouton, sous la carte. */
.geoloc--compact { grid-template-columns: 1fr auto; align-items: center; margin: 12px 0 0; padding: 10px 12px; box-shadow: none; background: var(--grey-soft); }
.geoloc--compact .geoloc__title { font-size: 15px; }
.geoloc--compact .geoloc__lead { display: none; }
.geoloc--compact.geoloc--denied .geoloc__lead { display: block; }
.geoloc--compact .geoloc__later { display: none; }
.geoloc--compact .geoloc__go { min-height: 44px; padding: 0 14px; font-size: 15px; }
@media (max-width: 380px) { .geoloc--compact { grid-template-columns: 1fr; } }

.you-marker { background: none; border: 0; }
.you-marker__dot { position: absolute; left: 7px; top: 7px; width: 14px; height: 14px; border: 3px solid #fff; border-radius: 50%; background: #1F4FB8; box-shadow: 0 1px 4px rgba(18, 40, 76, 0.5); }
.you-marker__halo { position: absolute; inset: 0; border-radius: 50%; background: rgba(31, 79, 184, 0.25); animation: you-halo 2s ease-out infinite; }
@keyframes you-halo { 0% { transform: scale(0.5); opacity: 0.9; } 100% { transform: scale(1.4); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .you-marker__halo { animation: none; } }

.nearby { display: grid; gap: 12px; margin-top: 12px; }
.nearby__message { margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--card); box-shadow: var(--shadow); font-size: 15px; }
.nearby__retry { justify-self: start; min-height: 44px; }
.nearby__result { display: grid; gap: 10px; padding: 16px; border-radius: var(--radius-card); background: var(--card); box-shadow: var(--shadow); }
.nearby__title { font-size: 19px; color: var(--navy); }
.nearby__stop { display: grid; gap: 2px; padding: 10px 12px; border-radius: 12px; background: var(--grey-soft); color: inherit; text-decoration: none; min-height: 44px; }
.nearby__label { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: #C8341F; }
.nearby__name { color: var(--navy); font-size: 17px; }
.nearby__meta { margin: 0; color: var(--muted); font-size: 14px; }
.nearby__person { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.nearby__person--none { justify-content: space-between; }
.nearby__none { flex: 1 1 200px; margin: 0; color: #3F4D63; }
.nearby__info { display: grid; flex: 1 1 140px; min-width: 0; }
.nearby__avatar { display: grid; place-items: center; flex: none; width: 48px; height: 48px; overflow: hidden; border-radius: 50%; background: var(--accent-soft); color: #A02B19; font-weight: 800; }
.nearby__avatar img { width: 100%; height: 100%; object-fit: cover; }
.nearby .button--small { min-height: 44px; }
