/* ==========================================================================
   Titraille, panneau de recherche, contrôles, messages.
   ========================================================================== */

/* --- Titraille ----------------------------------------------------------- */

.hero { margin-bottom: var(--sp-6); max-width: 46rem; }

.hero__title {
  font-size: var(--fs-display);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: var(--ls-display);
}

.hero__sub {
  margin-top: var(--sp-4);
  font-size: var(--fs-lg);
  line-height: 1.55;
  color: var(--fg-secondary);
}

/* --- Signature de l'éditeur, sous le titre -------------------------------
   Volontairement discrète : c'est un crédit, pas une seconde marque. Elle ne
   doit pas entrer en concurrence avec « Jauge ».
   ------------------------------------------------------------------------ */

.hero__byline {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-5);
  font-size: var(--fs-lg);
  color: var(--fg-muted);
}

.byline {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--fg);
  font-weight: 600;
  letter-spacing: var(--ls-heading);
  transition: color 0.18s;
}

.byline:hover { color: var(--accent); }

/* Proportions calées sur la viewBox (900 × 770). */
.byline__mark {
  width: 26px;
  height: 22px;
  color: currentColor;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-5);
  padding: var(--sp-1) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--bg-subtle);
  font-size: var(--fs-xs);
  color: var(--fg-secondary);
}

.pill__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/* --- Panneau ------------------------------------------------------------- */

.panel {
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel__body { padding: var(--sp-5); }

@media (min-width: 44em) {
  .panel__body { padding: var(--sp-6); }
}

.panel__body + .panel__body { border-top: 1px solid var(--border); }

.panel__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2) var(--sp-4);
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  font-size: var(--fs-sm);
  color: var(--fg-muted);
}

.panel__foot .linkbtn { margin-inline-start: auto; }

@media (min-width: 44em) {
  .panel__foot { padding-inline: var(--sp-6); }
}

.panel__foot a { color: var(--fg-secondary); text-decoration: underline; text-underline-offset: 2px; }
.panel__foot a:hover { color: var(--fg); }

/* --- Champs -------------------------------------------------------------- */

.field { display: grid; gap: var(--sp-2); }

.field__label {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--fg);
}

.field__label--value {
  font-weight: 600;
  color: var(--accent);
}

/* --- Curseur de fraîcheur ------------------------------------------------ */

.slider {
  width: 100%;
  height: 4px;
  accent-color: var(--accent);
  cursor: pointer;
  margin-block: var(--sp-1);
}

.slider__ticks {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-xs);
  color: var(--fg-muted);
  margin-top: var(--sp-1);
  user-select: none;
}

.legend {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--fg);
  margin-bottom: var(--sp-3);
}

.input,
.select {
  width: 100%;
  height: 38px;
  padding-inline: var(--sp-3);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  font-size: var(--fs-base);
  color: var(--fg);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.select {
  appearance: none;
  padding-inline-end: var(--sp-8);
  background-image: linear-gradient(45deg, transparent 49%, currentColor 50%),
                    linear-gradient(-45deg, transparent 49%, currentColor 50%);
  background-size: 5px 5px, 5px 5px;
  background-position: calc(100% - 1rem) 55%, calc(100% - 0.65rem) 55%;
  background-repeat: no-repeat;
  cursor: pointer;
}

/* --- Sélecteur d'enseigne (dropdown avec recherche) ---------------------- */

.brand-dd { position: relative; }

.brand-dd__trigger {
  position: relative;
}

.brand-dd__toggle {
  display: flex;
  align-items: center;
  width: 100%;
  height: 38px;
  padding-inline: var(--sp-3);
  padding-inline-end: calc(var(--sp-3) + 60px); /* espace pour les icônes */
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  font-size: var(--fs-base);
  color: var(--fg);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.brand-dd__toggle:hover { border-color: var(--fg-muted); }

.brand-dd__toggle:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
  outline: none;
}

.brand-dd__actions {
  position: absolute;
  right: var(--sp-3);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  pointer-events: none; /* le toggle capte le clic global */
}

.brand-dd__clear-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  color: var(--fg-secondary);
  cursor: pointer;
  padding: 0;
  pointer-events: auto;
  transition: background-color 0.12s, color 0.12s;
}

.brand-dd__clear-btn:hover { background: var(--border-strong); color: var(--fg); }

.brand-dd__chevron {
  width: 12px; height: 12px;
  color: var(--fg-muted);
  flex-shrink: 0;
  transition: transform 0.18s;
}

.brand-dd--open .brand-dd__chevron { transform: rotate(180deg); }

.brand-dd__panel {
  position: fixed;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.brand-dd__search-wrap {
  padding: var(--sp-2);
  border-bottom: 1px solid var(--border);
}

.brand-dd__search {
  height: 32px;
  font-size: var(--fs-sm);
}

.brand-dd__list {
  list-style: none;
  padding: var(--sp-1) 0;
  margin: 0;
  max-height: 200px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.brand-dd__item { display: block; }

.brand-dd__label {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-base);
  color: var(--fg-secondary);
  cursor: pointer;
  transition: background-color 0.1s, color 0.1s;
}

.brand-dd__label:hover { background: var(--bg-muted); color: var(--fg); }

.brand-dd__label input[type="checkbox"] {
  flex-shrink: 0;
  width: 14px; height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
}

.brand-dd__footer {
  padding: var(--sp-2) var(--sp-3);
  border-top: 1px solid var(--border);
  font-size: var(--fs-sm);
}

/* --- Autocomplétion d'adresse -------------------------------------------- */

.ac-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 50;
  list-style: none;
  padding: var(--sp-1) 0;
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  max-height: 260px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.ac-item {
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-base);
  color: var(--fg-secondary);
  cursor: pointer;
  transition: background-color 0.12s, color 0.12s;
}

.ac-item:hover,
.ac-item--active {
  background: var(--bg-muted);
  color: var(--fg);
}

/* --- Onglets de mode (autour / itinéraire) ------------------------------- */

.mode-tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-muted);
  margin-bottom: var(--sp-4);
}

.mode-tab {
  flex: 1;
  height: 32px;
  padding-inline: var(--sp-3);
  border-radius: var(--r-md);
  font-size: var(--fs-base);
  font-weight: 500;
  color: var(--fg-secondary);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.mode-tab:hover { color: var(--fg); }

.mode-tab--active {
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-sm);
}

/* Formulaire itinéraire : un champ par ligne, un peu plus d'espace */
.search--around { display: grid; gap: var(--sp-4); }
.search--route  { display: grid; gap: var(--sp-4); }

/* Champ texte + bouton icône sur la même ligne */
.input-row {
  display: flex;
  gap: var(--sp-2);
  position: relative; /* ancrage du dropdown autocomplete */
}

.input-row .input { flex: 1; min-width: 0; }

/* Le bouton icône s'aligne sur la hauteur du champ texte voisin */
.input-row .btn { height: 38px; }

/* Bouton icône seul, carré */
.btn--icon-only {
  flex: none;
  width: 38px;
  padding-inline: 0;
}

@media (max-width: 40em) {
  .btn--icon-only { width: 46px; }
}

.input::placeholder { color: var(--fg-muted); }

.input:hover,
.select:hover { border-color: var(--fg-muted); }

.input:focus-visible,
.select:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.select:disabled {
  background: var(--bg-muted);
  color: var(--fg-muted);
  cursor: not-allowed;
}

/* Champ numérique avec son unité posée à l'intérieur, à droite. */
.unitfield { position: relative; }

.unitfield .input { padding-inline-end: 3.6rem; }

/* Les flèches natives se superposeraient à l'unité. */
.unitfield .input::-webkit-outer-spin-button,
.unitfield .input::-webkit-inner-spin-button { appearance: none; margin: 0; }
.unitfield .input[type="number"] { appearance: textfield; -moz-appearance: textfield; }

.unitfield__unit {
  position: absolute;
  inset-inline-end: var(--sp-3);
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--fs-sm);
  color: var(--fg-muted);
  pointer-events: none;
}

.search__row { display: grid; gap: var(--sp-3); }

@media (min-width: 40em) {
  .search__row { grid-template-columns: 1fr auto auto; align-items: end; }
}

/* --- Boutons ------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 38px;
  padding-inline: var(--sp-4);
  border: 1px solid var(--fg);
  border-radius: var(--r-md);
  background: var(--fg);
  color: var(--bg);
  font-size: var(--fs-base);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
}

.btn:hover { background: var(--fg-secondary); border-color: var(--fg-secondary); }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--secondary {
  background: var(--bg);
  border-color: var(--border-strong);
  color: var(--fg);
}

.btn--secondary:hover { background: var(--bg-muted); border-color: var(--fg-muted); color: var(--fg); }

.btn--sm { height: 30px; padding-inline: var(--sp-3); font-size: var(--fs-sm); }

.btn__icon { width: 15px; height: 15px; }

.linkbtn {
  color: var(--accent);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.15s;
}

.linkbtn:hover { color: var(--accent-hover); }

/* --- Réglages ------------------------------------------------------------ */

.settings { display: grid; gap: var(--sp-6); grid-template-columns: minmax(0, 1fr); }

.settings > *,
.settings__row > * { min-width: 0; }

.settings__row { display: grid; gap: var(--sp-6); grid-template-columns: minmax(0, 1fr); }

@media (min-width: 44em) {
  .settings__row--pair { grid-template-columns: 1fr 1fr; }
}

fieldset { border: 0; padding: 0; margin: 0; }

/* --- Réglages avancés, repliables sur téléphone -------------------------- */

.more__toggle {
  display: none;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  min-height: 44px;
  padding: 0;
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--fg-secondary);
  cursor: pointer;
}

.more__toggle:hover { color: var(--fg); }

.more__chevron {
  width: 7px;
  height: 7px;
  border-inline-end: 1.6px solid currentColor;
  border-block-end: 1.6px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.2s;
}

.more__toggle[aria-expanded="true"] .more__chevron {
  transform: rotate(225deg) translateY(-2px);
}

.more__panel { display: grid; gap: var(--sp-6); }

/* `display: grid` l'emporte sur le `display: none` que le navigateur associe
   à l'attribut `hidden` : sans cette règle, le panneau replié continue
   d'occuper toute sa hauteur. */
.more__panel[hidden] { display: none; }

/* En dessous de cette largeur, le bouton apparaît et le panneau se replie. */
@media (max-width: 44em) {
  .more__toggle { display: flex; }
  .more__panel { padding-top: var(--sp-2); }
}

/* --- Carburants : boutons-jetons sélectionnables ------------------------- */

.fuels {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: 32px;
  padding-inline: var(--sp-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--bg);
  font-size: var(--fs-base);
  color: var(--fg-secondary);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}

.chip:hover { border-color: var(--fg-muted); color: var(--fg); }

.chip input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.chip__check {
  width: 14px;
  height: 14px;
  color: var(--accent);
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 0.14s, transform 0.14s;
}

.chip:has(input:checked) {
  border-color: var(--accent-border);
  background: var(--accent-subtle);
  color: var(--fg);
  font-weight: 500;
}

.chip:has(input:checked) .chip__check { opacity: 1; transform: none; }

.chip:has(input:focus-visible) { box-shadow: var(--ring); }

.chip__hint { font-size: var(--fs-xs); color: var(--fg-muted); }

/* --- Rayon : groupe segmenté -------------------------------------------- */

.segmented {
  display: flex;
  /* Les rayons passent à la ligne plutôt que de sortir du cadre : sur un
     téléphone, « 50 km » se retrouvait hors de l'écran. */
  flex-wrap: wrap;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-muted);
  gap: 2px;
  max-width: 100%;
}

.segment {
  flex: 1 0 auto;
  height: 30px;
  padding-inline: var(--sp-3);
  border-radius: var(--r-md);
  font-size: var(--fs-base);
  font-weight: 500;
  color: var(--fg-secondary);
  cursor: pointer;
  /* Sans cela, « 5 km » se coupe en deux lignes dans un segment étroit. */
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  transition: background-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.segment:hover { color: var(--fg); }

.segment[aria-pressed="true"] {
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-sm);
}

/* --- Interrupteurs ------------------------------------------------------- */

.checks { display: grid; gap: var(--sp-3); }

.check {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-base);
  color: var(--fg-secondary);
  cursor: pointer;
}

.check input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

.check:hover { color: var(--fg); }

/* --- Mentions ------------------------------------------------------------ */

.hint {
  font-size: var(--fs-sm);
  color: var(--fg-muted);
  max-width: var(--measure);
}

.hint--error { color: var(--danger); font-weight: 500; }

/* --- Messages ------------------------------------------------------------ */

.notice {
  display: grid;
  gap: var(--sp-1);
  padding: var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-subtle);
  margin-block: var(--sp-4);
}

.notice--warn { border-color: var(--warn-border); background: var(--warn-subtle); }
.notice--error { border-color: var(--danger); background: var(--danger-subtle); }

.notice__title { font-size: var(--fs-base); font-weight: 500; color: var(--fg); }

.notice--warn .notice__title { color: var(--warn); }
.notice--error .notice__title { color: var(--danger); }

.notice__body {
  font-size: var(--fs-sm);
  color: var(--fg-secondary);
  max-width: var(--measure);
}

.notice code {
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-muted);
  font-size: 0.85em;
}

/* ==========================================================================
   Adaptations mobiles.

   Deux exigences concrètes : des cibles tactiles d'au moins 44 px, et des
   champs à 16 px — en dessous, iOS zoome automatiquement sur le formulaire
   au moment de la saisie, ce qui décale toute la page.
   ========================================================================== */

/* Jusqu'à la taille tablette : iOS et iPadOS zooment sur un champ de moins de
   16 px au moment de la saisie, ce qui décale toute la page. */
@media (max-width: 48em) {
  .input,
  .select { font-size: 1rem; }
}

@media (max-width: 40em) {
  .input,
  .select { height: 46px; }

  .btn {
    height: 46px;
    font-size: var(--fs-md);
    padding-inline: var(--sp-3);
    min-width: 0;
  }

  /* Les deux boutons de recherche se partagent la largeur. */
  .search__row { grid-template-columns: 1fr 1fr; }
  .search__row .field { grid-column: 1 / -1; }
  .search__row > * { min-width: 0; }

  .linkbtn,
  .panel__foot a { display: inline-flex; align-items: center; min-height: 44px; }

  .chip { height: 40px; padding-inline: var(--sp-4); font-size: var(--fs-md); }

  .segment { height: 40px; font-size: var(--fs-md); }

  .checks { gap: var(--sp-1); }

  /* Toute la ligne devient cliquable, pas seulement la case. */
  .check {
    min-height: 44px;
    align-items: center;
    font-size: var(--fs-md);
  }

  .check input { width: 20px; height: 20px; }

  .hero { margin-bottom: var(--sp-8); }

  /* La signature est un lien : elle doit rester atteignable au doigt. */
  .hero__byline { margin-top: var(--sp-3); }
  .byline { min-height: 44px; }

  .panel__body { padding: var(--sp-4); }
  .panel__foot { padding: var(--sp-2) var(--sp-4); gap: var(--sp-1) var(--sp-3); }

  /* La mention passe sur sa propre ligne, les deux actions restent côte à côte. */
  .panel__note { flex-basis: 100%; }
}

/* Très petits écrans seulement (moins de 352 px) : les deux boutons ne
   tiennent plus côte à côte. Au-delà, ils restent sur une même ligne. */
@media (max-width: 22em) {
  .search__row { grid-template-columns: 1fr; }
  .panel__foot .linkbtn { margin-inline-start: 0; }
}

/* --- Carte Leaflet (itinéraire / autour de moi) -------------------------- */

.route-map {
  height: 360px;
  margin-top: var(--sp-5);
  border-radius: var(--r-xl);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

@media (max-width: 44em) {
  .route-map { height: 260px; }
}

/* Mode sombre : inversion des tuiles OpenStreetMap */
@media (prefers-color-scheme: dark) {
  .route-map .leaflet-tile-pane {
    filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.9);
  }
}

/* Label centré sur les circleMarkers de position (A / B / ●) */
.map-pin-label {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-family: system-ui, sans-serif;
  padding: 0 !important;
  text-shadow: 0 1px 2px rgba(0,0,0,.5);
  pointer-events: none;
}
