/* Plein — chrome « bleu pétrole » posé sur une carte claire.
   L'élément fort est la pastille de prix : lecture façon afficheur de pompe,
   dernier chiffre en exposant. Tout le reste reste sobre. */

:root {
  --ink: #0f2430;
  --ink-2: #1d3a49;
  --ink-3: #2f5366;
  --paper: #f7f8f8;
  --panel: #ffffff;
  --rule: #d6dedc;
  --text: #0f2430;
  --dim: #5d7280;

  /* échelle de prix, du moins cher au plus cher */
  --p1: #0b7a6e;
  --p2: #5f9440;
  --p3: #c79a16;
  --p4: #c9682c;
  --p5: #9e3050;

  --yes: #0b6f64;
  --no: #93304b;

  --r: 7px;
  --shadow: 0 1px 2px rgba(15, 36, 48, .14), 0 8px 24px -10px rgba(15, 36, 48, .3);
  --gap: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0b1a22;
    --panel: #12262f;
    --rule: #28434f;
    --text: #e7eeec;
    --dim: #93a8b1;
    --ink: #e7eeec;
    --ink-2: #c6d6d4;
    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 8px 24px -10px rgba(0, 0, 0, .7);
  }
}

* { box-sizing: border-box; }

html {
  /* Teinte de la carte, pas du blanc : si iOS peint malgré tout une bande sous la page,
     elle se confond avec le fond de carte au lieu de trancher. */
  background: #e8e6e1;
}
@media (prefers-color-scheme: dark) { html { background: #16242c; } }

html, body {
  height: 100%;
  margin: 0;
  font: 400 16px/1.4 'Barlow Semi Condensed', system-ui, sans-serif;
  color: var(--text);
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

#map {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  /* iOS « standalone » peint la zone de l'indicateur d'accueil avec le fond de la page :
     on prolonge la carte dessous pour qu'aucune bande claire n'apparaisse.
     Ailleurs l'encart vaut 0 et rien ne change. */
  bottom: calc(-1 * env(safe-area-inset-bottom, 0px));
  /* Ceinture et bretelles : si la hauteur de mise en page est plus courte que l'écran
     (cas d'iOS en mode application), dvh rattrape la différence. */
  min-height: 100dvh;
  background: var(--paper);
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--p1);
  outline-offset: 2px;
}

/* ---------- barre haute ---------- */

.bar {
  position: fixed;
  z-index: 500;
  top: calc(env(safe-area-inset-top) + var(--gap));
  left: calc(env(safe-area-inset-left) + var(--gap));
  right: calc(env(safe-area-inset-right) + var(--gap));
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--gap);
  align-items: start;
  pointer-events: none;
}
.bar > * { pointer-events: auto; }

.find {
  display: flex;
  align-items: center;
  max-width: 300px;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.find input {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 4px 0 11px;
  border: 0;
  background: none;
  appearance: none;
}
.find input::-webkit-search-cancel-button { display: none; }

.icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border: 0;
  background: none;
  color: var(--dim);
}
.icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.icon.solo {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  color: var(--text);
}
.icon.solo[aria-pressed="true"] { color: var(--p1); }

.fuels {
  grid-column: 1 / -1;
  display: flex;
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 1px;
  margin: -1px;
}
.fuels::-webkit-scrollbar { display: none; }
.fuels button {
  flex: none;
  height: 31px;
  padding: 0 11px;
  border: 1px solid var(--rule);
  border-radius: var(--r);
  background: var(--panel);
  color: var(--dim);
  font-weight: 600;
  letter-spacing: .01em;
  box-shadow: var(--shadow);
}
.fuels button[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

/* ---------- résultats de recherche ---------- */

.results {
  position: fixed;
  z-index: 520;
  top: calc(env(safe-area-inset-top) + 56px);
  left: calc(env(safe-area-inset-left) + var(--gap));
  width: min(300px, calc(100vw - 2 * var(--gap)));
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.results button {
  display: block;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: 4px;
  background: none;
  text-align: left;
  line-height: 1.25;
}
.results button:hover, .results button:focus-visible { background: color-mix(in srgb, var(--p1) 10%, transparent); }
.results small { display: block; color: var(--dim); }

/* ---------- pastilles de prix ---------- */

/* Leaflet positionne une ancre de 0 × 0 ; la pastille est posée par rapport à elle et
   se dimensionne sur son contenu. Rien à recalculer quand l'enseigne apparaît. */
.anchor { overflow: visible; }

.pin {
  position: absolute;
  left: 0;
  bottom: 4px;
  transform: translateX(-50%);
  width: max-content;
  max-width: 132px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 3px 6px;
  border-radius: 5px;
  background: var(--c);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  line-height: 18px;
  letter-spacing: -.01em;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(15, 36, 48, .5);
}
.anchor.mid .pin { bottom: auto; top: 0; transform: translate(-50%, -50%); }

.pin b { font-weight: inherit; }
.pin sup {
  font-size: .64em;
  font-weight: 600;
  line-height: 1;
  vertical-align: baseline;
  position: relative;
  top: -.46em;
  opacity: .88;
}
.pin::after {                   /* la pointe qui désigne la station */
  content: '';
  position: absolute;
  left: 50%;
  bottom: -3px;
  width: 6px;
  height: 6px;
  margin-left: -3px;
  background: var(--c);
  transform: rotate(45deg);
  border-radius: 1px;
}
.anchor.mid .pin::after { display: none; }
.pin.es { box-shadow: 0 1px 3px rgba(15, 36, 48, .5), inset 0 -3px 0 rgba(255, 255, 255, .42); }

/* Le logo tient dans une pastille blanche : la plupart sont dessinés pour du blanc. */
.pin img {
  flex: none;
  width: 17px;
  height: 17px;
  border-radius: 3px;
  background: #fff;
  padding: 1px;
  object-fit: contain;
}

/* Enseigne et logo n'apparaissent qu'une fois les stations dégroupées. */
.pin i, .pin img { display: none; }
body.brands .pin img { display: block; }
body.brands .pin:not(.badged) { flex-direction: column; gap: 0; line-height: 1.1; }
body.brands .pin i {
  display: block;
  font-style: normal;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .01em;
  opacity: .88;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.brands .pin.group { flex-direction: row; }

.pin.group {
  border-radius: 13px;
  padding: 3px 5px 3px 9px;
  gap: 5px;
}
.pin.group em {
  font-style: normal;
  font-size: 11px;
  font-weight: 600;
  padding: 0 5px;
  border-radius: 9px;
  background: rgba(255, 255, 255, .26);
  line-height: 16px;
}

/* Repère « ma station habituelle » / « station comparée » : une lettre posée au-dessus
   de la pastille, au lieu de l'encadrer — le cadre noir faisait tache sur la carte. */
.tagpin {
  position: absolute;
  left: 0;
  bottom: 28px;
  transform: translateX(-50%);
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  border: 2px solid var(--panel);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(15, 36, 48, .45);
}
body.brands .tagpin { bottom: 32px; }

.s1 { --c: var(--p1); } .s2 { --c: var(--p2); } .s3 { --c: var(--p3); }
.s4 { --c: var(--p4); } .s5 { --c: var(--p5); }

.home-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--ink);
  border: 3px solid var(--panel);
  box-shadow: 0 1px 4px rgba(15, 36, 48, .5);
}

/* ---------- panneaux bas ---------- */

.sheet, .deal {
  position: fixed;
  z-index: 600;
  left: calc(env(safe-area-inset-left) + var(--gap));
  right: calc(env(safe-area-inset-right) + var(--gap));
  bottom: calc(env(safe-area-inset-bottom) + var(--gap));
  max-width: 370px;
  max-height: calc(100vh - 150px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 13px 15px 15px;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.sheet[hidden], .deal[hidden] { display: none; }
.deal { max-width: 335px; }
@media (min-width: 760px) {
  .sheet { left: auto; right: calc(env(safe-area-inset-right) + var(--gap)); width: 370px; }
  .deal { right: auto; left: calc(env(safe-area-inset-left) + var(--gap)); width: 335px; }
}

.close {
  float: right;
  margin: -4px -6px 0 6px;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border: 0; border-radius: 4px;
  background: none;
  color: var(--dim);
}
.close svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

.sheet h2, .deal h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.15;
}
.where { margin: 2px 0 11px; color: var(--dim); line-height: 1.3; }
.where b { color: var(--text); font-weight: 600; }

.prices { width: 100%; border-collapse: collapse; }
.prices td { padding: 4px 0; border-top: 1px solid var(--rule); vertical-align: baseline; }
.prices tr:first-child td { border-top: 0; }
.prices .f { font-weight: 600; }
.prices .v { text-align: right; font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.prices .v sup { font-size: .66em; font-weight: 600; top: -.45em; position: relative; }
.prices .age { text-align: right; width: 5.6em; color: var(--dim); }
.prices tr.off td { color: var(--dim); }
.prices tr.off .v { font-size: 16px; font-weight: 400; }
.prices tr.pick { color: var(--text); }
.prices tr.pick .f::before {
  content: '';
  display: inline-block;
  width: 3px; height: 13px;
  margin-right: 6px;
  background: var(--ink);
  vertical-align: -2px;
}

.acts { display: flex; gap: 7px; margin-top: 13px; }
.btn {
  flex: 1;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--ink);
  border-radius: var(--r);
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
  line-height: 1.15;
}
.btn.ghost { background: none; color: var(--text); }
.btn:disabled { opacity: .42; cursor: default; }

/* ---------- comparaison ---------- */

.versus {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin: 11px 0;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  overflow: hidden;
}
.side { padding: 7px 9px; background: var(--panel); min-width: 0; }
.tag {
  display: inline-block;
  width: 16px;
  font-weight: 700;
  color: var(--dim);
}
.side .who {
  font-weight: 600;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side .rate { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.side .rate sup { font-size: .66em; position: relative; top: -.45em; }
.side .rate small { font-size: 13px; font-weight: 400; color: var(--dim); }

.verdict { padding: 9px 11px; border-radius: var(--r); background: color-mix(in srgb, var(--yes) 13%, transparent); }
.verdict.bad { background: color-mix(in srgb, var(--no) 12%, transparent); }
.verdict.wait { background: color-mix(in srgb, var(--dim) 13%, transparent); }
.verdict p { margin: 0; }
.verdict .headline { font-size: 19px; font-weight: 700; line-height: 1.15; color: var(--yes); }
.verdict.bad .headline { color: var(--no); }
.verdict.wait .headline { color: var(--dim); font-size: 16px; font-weight: 600; }
.verdict .detail { margin-top: 2px; line-height: 1.3; color: var(--text); }
.verdict .detail:empty { display: none; }

.ledger { width: 100%; border-collapse: collapse; margin-top: 11px; }
.ledger td { padding: 3px 0; border-top: 1px solid var(--rule); }
.ledger tr:first-child td { border-top: 0; }
.ledger td + td { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.ledger tr.net td { border-top: 1.5px solid var(--text); font-weight: 700; padding-top: 5px; }
.ledger tr.note td { color: var(--dim); font-weight: 400; font-size: 14px; }
.ledger tr.note td + td { font-weight: 400; }

.mine { margin: 13px 0 0; padding: 0; border: 0; }
.mine legend { padding: 0; font-weight: 700; }
.mine label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
  border-top: 1px solid var(--rule);
  color: var(--dim);
}
.mine legend + label { border-top: 0; }
.mine input {
  width: 4.6em;
  height: 30px;
  padding: 0 6px;
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 4px;
  appearance: textfield;
}
.mine input::-webkit-outer-spin-button, .mine input::-webkit-inner-spin-button { appearance: none; margin: 0; }

.start { margin: 11px 0 0; color: var(--dim); line-height: 1.3; }
.start strong { color: var(--text); font-weight: 600; }
.link {
  border: 0;
  padding: 0;
  background: none;
  color: var(--p1);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ---------- pied + toast ---------- */

.credits {
  position: fixed;
  z-index: 450;
  bottom: calc(env(safe-area-inset-bottom) + 2px);
  left: calc(env(safe-area-inset-left) + var(--gap));
  margin: 0;
  max-width: 60vw;
  font-size: 11px;
  line-height: 1.35;
  color: var(--dim);
  text-shadow: 0 0 3px var(--paper), 0 0 6px var(--paper);
}
.credits a { color: inherit; }
#freshness { display: block; font-weight: 600; }
@media (max-width: 759px) { .credits .src { display: none; } }
body.busy .credits { visibility: hidden; }

.toast {
  position: fixed;
  z-index: 700;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 20px);
  transform: translate(-50%, 14px);
  max-width: calc(100vw - 32px);
  padding: 8px 14px;
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
}
.toast.up { opacity: 1; transform: translate(-50%, 0); }

/* Leaflet : on neutralise le chrome par défaut, il jure avec le reste. */
.leaflet-container { font: inherit; background: var(--paper); }
.leaflet-control-attribution { display: none; }
.leaflet-bar { border: 1px solid var(--rule); box-shadow: var(--shadow); border-radius: var(--r); overflow: hidden; }
.leaflet-bar a {
  background: var(--panel);
  color: var(--text);
  border-bottom-color: var(--rule);
  width: 32px; height: 32px; line-height: 32px;
}
.leaflet-bar a:hover { background: var(--paper); color: var(--text); }
.leaflet-touch .leaflet-bar a:first-child { border-radius: 0; }
.leaflet-touch .leaflet-bar a:last-child { border-radius: 0; }
.leaflet-control-zoom { margin: 0 !important; }
.leaflet-bottom.leaflet-right { margin: 0 calc(env(safe-area-inset-right) + var(--gap)) calc(env(safe-area-inset-bottom) + var(--gap)) 0; }
@media (max-width: 759px) { .leaflet-control-zoom { display: none; } }
/* Fond OSM calmé : c'est le prix qui doit porter la couleur, pas la carte. */
.leaflet-tile-pane { filter: saturate(.28) contrast(.88) brightness(1.08); }
@media (prefers-color-scheme: dark) {
  .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) saturate(.5) brightness(.82) contrast(1.1); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .leaflet-cluster-anim .leaflet-marker-icon { transition: none !important; }
}
