/* Isochrones Suisse — feuille de la fiche */
:root {
  --ink: #1d2733;          /* encre bleu-noir des cartes topographiques */
  --ink-2: #4a5666;
  --ink-3: #7c8796;
  --paper: #ffffff;
  --wash: #eef1f4;
  --rule: #d6dbe1;
  --focus: #2763b0;
  --a: #2763b0; --b: #b0277a; --c: #0e8a7a; --d: #c46a10; --e: #6a4bb8;
  --ground: #dfe3e6;
  --panel-w: 352px;
  --radius-panel: 14px;
  --radius-ctl: 8px;
  --shadow: 0 1px 2px rgba(29, 39, 51, .12), 0 8px 28px rgba(29, 39, 51, .16);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e7ebf0; --ink-2: #b4bdc8; --ink-3: #8994a2;
    --paper: #1a222c; --wash: #232d39; --rule: #34404e; --focus: #7aa7e6;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 28px rgba(0,0,0,.45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #e7ebf0; --ink-2: #b4bdc8; --ink-3: #8994a2;
  --paper: #1a222c; --wash: #232d39; --rule: #34404e; --focus: #7aa7e6;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 28px rgba(0,0,0,.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--ground);
  color: var(--ink);
  font: 15px/1.45 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
}
#carte { position: fixed; inset: 0; background: var(--ground); }
.leaflet-container { font: inherit; background: var(--ground); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Panneau ---------- */
#panneau {
  position: fixed; z-index: 1000;
  top: 12px; left: 12px; bottom: 12px;
  width: var(--panel-w);
  display: flex; flex-direction: column;
  background: var(--paper);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.tete { padding: 16px 18px 10px; }
.tete h1 { margin: 0; font-size: 21px; line-height: 1.15; font-weight: 650; letter-spacing: -.01em; }
.tete p { margin: 4px 0 0; color: var(--ink-2); font-size: 13px; }
.tete p button { background: none; border: 0; padding: 0; color: var(--focus); text-decoration: underline; cursor: pointer; font-size: 13px; }
.poignee { display: none; }
.defile { overflow-y: auto; padding: 0 18px 16px; flex: 1; overscroll-behavior: contain; }
section { padding: 14px 0; border-top: 1px solid var(--rule); }
section:first-child { border-top: 0; padding-top: 4px; }
h2 { font-size: 13px; font-weight: 650; margin: 0 0 8px; color: var(--ink-2); }

/* recherche */
.recherche { position: relative; }
.recherche input {
  width: 100%; padding: 10px 12px 10px 36px;
  border: 1px solid var(--rule); border-radius: var(--radius-ctl);
  background: var(--wash);
}
.recherche svg { position: absolute; left: 11px; top: 11px; width: 16px; height: 16px; stroke: var(--ink-3); fill: none; stroke-width: 2; }
.suggestions { list-style: none; margin: 4px 0 0; padding: 4px; border: 1px solid var(--rule); border-radius: var(--radius-ctl); background: var(--paper); }
.suggestions:empty { display: none; }
.suggestions li button { width: 100%; text-align: left; background: none; border: 0; padding: 7px 8px; border-radius: 6px; cursor: pointer; font-size: 14px; display: grid; grid-template-columns: 24px 1fr; gap: 8px; align-items: start; }
.suggestions .picto { font-size: 16px; line-height: 20px; text-align: center; }
.suggestions .sugg-nom { display: block; line-height: 1.3; }
.suggestions small { display: block; font-size: 12.5px; line-height: 1.3; }
.suggestions .vide { padding: 6px 8px; color: var(--ink-3); }
.suggestions li button:hover, .suggestions li button:focus-visible { background: var(--wash); }
.suggestions small { color: var(--ink-3); }
.astuce { color: var(--ink-3); font-size: 13px; margin: 8px 0 0; }

/* points */
.points { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.points li { display: grid; grid-template-columns: 26px 1fr auto auto; gap: 8px; align-items: center; }
.pastille { width: 24px; height: 24px; border-radius: 50%; color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.points .nom { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.points .nom small { display: block; color: var(--ink-3); font-size: 12px; }
.icone { background: none; border: 0; width: 30px; height: 30px; border-radius: 6px; cursor: pointer; color: var(--ink-3); display: grid; place-items: center; }
.icone:hover { background: var(--wash); color: var(--ink); }
.icone svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }

/* segments */
.segments { display: flex; background: var(--wash); border-radius: var(--radius-ctl); padding: 3px; gap: 2px; }
.segments button { flex: 1; border: 0; background: none; padding: 6px 4px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--ink-2); }
.segments button[aria-pressed="true"] { background: var(--paper); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(29,39,51,.18); }
.segments button:disabled { opacity: .4; cursor: default; }

/* temps */
.temps { display: flex; align-items: baseline; gap: 8px; }
.temps output { font-size: 40px; font-weight: 600; letter-spacing: -.02em; line-height: 1; }
.temps span { color: var(--ink-2); }
input[type="range"] { width: 100%; margin: 12px 0 4px; accent-color: var(--ink); }
.ligne { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; font-size: 14px; }
.ligne select, .ligne input[type="number"] { padding: 5px 8px; border: 1px solid var(--rule); border-radius: 6px; background: var(--wash); max-width: 60%; }
.ligne input[type="number"] { width: 72px; }
.aide { color: var(--ink-3); font-size: 12.5px; margin: 6px 0 0; }

/* légende */
.legende { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; font-size: 13.5px; }
.legende li { display: grid; grid-template-columns: 18px 1fr auto; gap: 8px; align-items: center; }
.legende i { width: 18px; height: 12px; border-radius: 3px; display: block; }
.legende b { font-weight: 600; }
.legende span:last-child { color: var(--ink-3); }
.resume { font-size: 13px; color: var(--ink-2); margin: 8px 0 0; }

/* trajets, rendez-vous */
.trajet { margin: 0 0 12px; }
.trajet h3 { font-size: 14px; margin: 0 0 6px; display: flex; gap: 8px; align-items: center; }
.trajet h3 .pastille { width: 20px; height: 20px; font-size: 11px; }
.trajet ol { list-style: none; margin: 0; padding: 0 0 0 9px; border-left: 2px solid var(--rule); }
.trajet li { position: relative; padding: 2px 0 6px 14px; font-size: 13.5px; }
.trajet li::before { content: ""; position: absolute; left: -6px; top: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--paper); border: 2px solid var(--ink-3); }
.trajet li.ride::before { background: var(--ink); border-color: var(--ink); }
.trajet li small { display: block; color: var(--ink-3); }
.code { font-weight: 650; padding: 0 5px; border-radius: 4px; background: var(--wash); }
.rdv { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.rdv button { width: 100%; text-align: left; border: 1px solid var(--rule); background: none; border-radius: var(--radius-ctl); padding: 7px 10px; cursor: pointer; font-size: 13.5px; }
.rdv button:hover { background: var(--wash); }
.rdv small { color: var(--ink-3); }

details summary { cursor: pointer; font-size: 13px; font-weight: 650; color: var(--ink-2); padding: 2px 0; }
details[open] summary { margin-bottom: 4px; }

.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.bouton { border: 1px solid var(--rule); background: var(--paper); border-radius: var(--radius-ctl); padding: 7px 11px; cursor: pointer; font-size: 13.5px; }
.bouton:hover { background: var(--wash); }
.bouton.plein { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.etat { font-size: 12.5px; color: var(--ink-3); padding: 8px 18px; border-top: 1px solid var(--rule); background: var(--paper); }
.etat.erreur { color: #b42318; }

/* ---------- Carte ---------- */
.repere { width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); display: grid; place-items: center; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.repere b { transform: rotate(45deg); color: #fff; font-size: 13px; }
.rdv-mark { width: 14px; height: 14px; background: #fff; border: 3px solid var(--ink); border-radius: 3px; transform: rotate(45deg); }
.infobulle { position: fixed; z-index: 900; pointer-events: none; background: var(--paper); color: var(--ink); border-radius: 6px; padding: 4px 8px; font-size: 13px; box-shadow: var(--shadow); white-space: nowrap; transform: translate(14px, -50%); }
.infobulle[hidden] { display: none; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }
.leaflet-popup-content-wrapper { border-radius: 10px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--ink-3); }
.leaflet-container a.leaflet-popup-close-button:hover { color: var(--ink); }
.leaflet-popup-content .bouton { background: var(--ink); color: var(--paper); border-color: var(--ink); font-weight: 600; }
.leaflet-popup-content .bouton:hover { background: var(--ink-2); border-color: var(--ink-2); }
.leaflet-control-attribution { background: color-mix(in srgb, var(--paper) 85%, transparent) !important; color: var(--ink-2); }
.leaflet-control-attribution a { color: var(--focus); }
.leaflet-popup-content { margin: 10px 12px; font-size: 13.5px; line-height: 1.4; }
.popup-temps { display: grid; gap: 2px; margin-bottom: 8px; }
.popup-temps b { font-weight: 650; }
.popup-temps span { display: flex; align-items: center; gap: 6px; }
.pastille.mini { width: 18px; height: 18px; font-size: 11px; flex: none; }
.fonds { position: fixed; z-index: 1000; right: 12px; top: 12px; }
.fonds .segments { background: var(--paper); box-shadow: var(--shadow); }
.boutons-carte { position: fixed; z-index: 1000; right: 12px; bottom: 28px; display: grid; gap: 6px; }
.boutons-carte button { width: 40px; height: 40px; border-radius: 10px; border: 0; background: var(--paper); box-shadow: var(--shadow); cursor: pointer; display: grid; place-items: center; color: var(--ink); }
.boutons-carte svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }
.leaflet-control-zoom { display: none; }

dialog { border: 0; border-radius: var(--radius-panel); padding: 0; max-width: min(620px, calc(100vw - 32px)); background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(29,39,51,.4); }
dialog .contenu { padding: 20px 22px; max-height: min(80vh, 760px); overflow: auto; }
dialog h2 { font-size: 18px; color: var(--ink); margin: 0 0 8px; }
dialog h3 { font-size: 15px; margin: 18px 0 4px; }
dialog p, dialog li { font-size: 14px; max-width: 68ch; }
dialog table { border-collapse: collapse; font-size: 13.5px; width: 100%; }
dialog td, dialog th { border-bottom: 1px solid var(--rule); padding: 5px 6px; text-align: left; vertical-align: top; }
dialog form { text-align: right; padding: 0 22px 18px; }
a { color: var(--focus); }

/* ---------- Téléphone : feuille du bas ---------- */
@media (max-width: 720px) {
  #panneau {
    top: auto; left: 0; right: 0; bottom: 0; width: auto;
    max-height: 72vh; border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    transition: max-height .25s ease;
  }
  #panneau.replie { max-height: 128px; }
  .poignee { display: block; width: 100%; border: 0; background: none; padding: 8px 0 0; cursor: pointer; }
  .poignee::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--rule); margin: 0 auto; }
  .tete { padding-top: 6px; }
  .tete h1 { font-size: 18px; }
  .fonds { top: calc(10px + env(safe-area-inset-top)); left: 12px; right: auto; }
  .boutons-carte { bottom: auto; top: calc(10px + env(safe-area-inset-top)); }
  .infobulle { display: none; }
}
@media (prefers-reduced-motion: reduce) { #panneau { transition: none; } }
