/* Base della pagina, mappa, pannello, testata, campi di partenza/meta/passaggi, impostazioni, pulsante Trova */

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; -webkit-font-smoothing: antialiased; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }  /* niente ingrandimento automatico dei testi */
/* la pagina si scorre ma non si ingrandisce (pizzico e doppio tocco); la mappa ha i suoi gesti (vedi index.html) */
html, body { touch-action: pan-x pan-y; }
body { font-family: var(--font); font-size: 15px; line-height: 1.45; color: var(--ink); background: var(--nebbia); }
/* aperta dentro Instagram, Facebook o TikTok e il rimando al browser non e' riuscito: come uscire (vedi index.html) */
.esci-app { position: fixed; top: 0; left: 0; right: 0; z-index: 100; padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: #121216; color: #FFFFFF; font-size: 13.5px; line-height: 1.4; text-align: center; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25); }
.esci-app a { display: inline-block; margin-top: 6px; padding: 7px 14px; border-radius: 999px; background: var(--blu); color: #FFFFFF;
  font-weight: 800; text-decoration: none; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2.5px solid var(--blu); outline-offset: 2px; }
/* niente riquadro blu del telefono al tocco: il pulsante premuto si scurisce un po' (si schiarisce col tema scuro) */
* { -webkit-tap-highlight-color: transparent; }
:where(button, [role="button"], a, label, summary, select):active { filter: brightness(0.9); }
:root[data-theme="dark"] :where(button, [role="button"], a, label, summary, select):active { filter: brightness(1.2); }

#map { position: fixed; inset: 0; }

.panel {
  position: fixed; top: 18px; left: 18px; bottom: 18px; width: 406px; z-index: 2;
  background: var(--carta);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid var(--linea);
  border-radius: var(--panel-radius);
  box-shadow: 0 24px 50px -12px rgba(0, 0, 0, 0.25);
  /* clip: il pannello non deve mai scorrere da solo (il focus di un campo lo spostava e nascondeva l'intestazione) */
  display: flex; flex-direction: column; overflow: hidden; overflow: clip;
}

.plate {
  margin: 14px 14px 0; padding: 13px 16px;
  background: var(--header-bg);
  color: var(--head-ink); border-radius: 16px;
  box-shadow: 0 8px 20px -6px rgba(0, 0, 0, 0.25);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand-wrap { display: flex; align-items: center; gap: 12px; }
.brand-badge {
  width: 40px; height: 40px; border-radius: 11px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
  display: grid; place-items: center; flex: none;
}
.brand-badge svg { width: 36px; height: 28px; }
.plate h1 { margin: 0; font-family: var(--cond); font-weight: 800; font-size: 25px; line-height: 1.05; }
.plate p { margin: 2px 0 0; font-size: 12.5px; opacity: 0.85; font-weight: 500; }
.maptoggle {
  display: none; flex: none; align-self: center; padding: 6px 14px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid rgba(255,255,255,0.5); background: rgba(255,255,255,0.12); color: #fff; font-weight: 600; font-size: 13px;
}
.maptoggle[aria-pressed="true"] { background: #fff; color: var(--blu); }
.plate-actions { display: flex; align-items: center; gap: 8px; flex: none; }

.scroll { flex: 1; overflow-y: auto; padding: 16px 16px 22px; scrollbar-width: thin; display: flex; flex-direction: column; }
.scroll > * { flex: none; }
body.typing .scroll { padding-bottom: 75vh; padding-bottom: 75dvh; }

.seg {
  position: relative; display: grid; grid-template-columns: 1fr 1fr; padding: 4px;
  background: var(--nebbia); border-radius: 13px; border: 1px solid var(--linea);
}
.seg::before {
  content: ""; position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px);
  background: var(--seg-on); border-radius: 9px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  transition: transform .25s cubic-bezier(0.22, 1, 0.36, 1);
}
.seg[data-mode="oneway"]::before, .seg[data-stile="veloce"]::before { transform: translateX(100%); }
.seg.stile { margin-top: 10px; }
.seg.stile button svg.largo { width: auto; aspect-ratio: 26 / 20; }  /* serpentina: piu' larga che alta */
.seg[hidden] { display: none; }
.seg button {
  position: relative; border: 0; background: none; padding: 8px 10px; border-radius: 9px;
  cursor: pointer; font-weight: 700; font-size: 13.5px; color: var(--muto);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.seg button svg { width: 16px; height: 16px; }
.seg button[aria-checked="true"] { color: var(--blu-testo); }

.route-points {
  margin-top: 14px; padding: 13px; border-radius: 15px;
  background: var(--carta-solida); border: 1px solid var(--linea);
}
.route-points .field { margin-top: 0; }
.route-points .field + .field { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--linea); }

.field { margin-top: 14px; border: 0; padding: 0; min-width: 0; }
.card-section {
  padding: 13px; border-radius: 15px; background: var(--carta-solida); border: 1px solid var(--linea);
}
/* etichette per i lettori di schermo: a vista basta il testo dentro la casella */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.field > label, .field legend, .kmhead label {
  display: block; font-weight: 700; font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muto); margin-bottom: 7px; padding: 0;
}
.inputrow { display: flex; gap: 8px; position: relative; }
.inputrow input {
  flex: 1; min-width: 0; height: 42px; padding: 0 12px 0 34px;
  border: 1.5px solid var(--linea); border-radius: 11px; background: var(--input-bg);
  color: var(--ink); font-size: 14.5px; font-weight: 500; transition: border-color .2s, box-shadow .2s;
}
.inputrow input:focus { border-color: var(--blu); outline: none; box-shadow: 0 0 0 3px var(--blu-glow); }
.pin { position: absolute; left: 12px; top: 50%; width: 11px; height: 11px; margin-top: -5.5px; border-radius: 50%; pointer-events: none; }
.pin.start { background: var(--blu); }
.pin.via { width: 16px; height: 16px; margin-top: -8px; left: 10px; background: var(--ink); color: var(--input-bg);
  display: grid; place-items: center; font: 800 10px/1 system-ui, sans-serif; }
.via-row + .via-row { margin-top: 8px; }
/* riordino di passaggi e meta: maniglia a sinistra, la riga segue il dito e le altre si spostano */
.drag { flex: none; width: 30px; height: 42px; display: grid; place-items: center; border: 0; border-radius: 8px; background: none;
  color: var(--muto); cursor: grab; touch-action: none; padding: 0; }
.drag svg { width: 18px; height: 18px; }
.drag:active { cursor: grabbing; color: var(--blu-testo); }
.drag:not([hidden]) ~ .pin { left: 50px; }
.via-row, #f-end .inputrow { transition: transform .18s cubic-bezier(0.22, 1, 0.36, 1); }
.dragging-row { transition: none !important; position: relative; z-index: 3; }
.dragging-row input { box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22); border-color: var(--blu); }
.pin.end { width: 15px; height: 15px; margin-top: -8px; left: 11px; border-radius: 0; background: none; color: var(--ink); }
.pin.end svg { width: 15px; height: 15px; display: block; }
.icon {
  flex: none; width: 42px; height: 42px; display: grid; place-items: center; cursor: pointer;
  border: 1.5px solid var(--linea); border-radius: 11px; background: var(--input-bg); color: var(--blu-testo);
}
.icon:hover { border-color: var(--blu); }
.icon svg { width: 18px; height: 18px; }
/* attesa della posizione GPS: al posto del mirino un cerchietto che gira */
.inputrow.locating #geo svg { display: none; }
.inputrow.locating #geo::after { content: ""; width: 16px; height: 16px; border-radius: 50%;
  border: 2.5px solid var(--linea); border-top-color: var(--blu); animation: geo-spin .8s linear infinite; }
@keyframes geo-spin { to { transform: rotate(360deg); } }

.sug {
  list-style: none; margin: 6px 0 0; padding: 5px; border: 1px solid var(--linea); border-radius: 11px;
  background: var(--carta-solida); box-shadow: 0 12px 28px rgba(0,0,0,0.18); max-height: 200px; overflow-y: auto;
}
.sug li { padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: 14px; }
.sug li small { display: block; color: var(--muto); font-size: 12px; }
.sug li[aria-selected="true"], .sug li:hover { background: var(--nebbia); color: var(--blu-testo); }


.kmhead { display: flex; align-items: baseline; justify-content: space-between; }
.kmtitle { display: flex; align-items: center; gap: 7px; }
.kmtitle label { margin: 0; }
.kmtitle .cippo { width: 16px; height: 16px; flex: none; color: var(--blu); }  /* contachilometri */
.kmhead output { font-family: var(--cond); font-size: 28px; font-weight: 800; color: var(--blu-testo); line-height: 1; }
.kmhead output small { font-family: var(--font); font-size: 13px; font-weight: 600; color: var(--muto); margin-left: 3px; }
input[type="range"] { width: 100%; margin: 8px 0 2px; accent-color: var(--blu); height: 22px; cursor: pointer; }
.scale { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muto); font-weight: 600; }

/* blocco unico delle impostazioni: le righe visibili sono separate da una linea sottile */
.settings { margin-top: 14px; border: 1px solid var(--linea); border-radius: 15px; background: var(--carta-solida); overflow: hidden; }
.settings > * { margin: 0 !important; border: 0 !important; border-radius: 0 !important; background: none !important; box-shadow: none !important; padding: 13px !important; }
.settings > :not([hidden]) ~ :not([hidden]) { border-top: 1px solid var(--linea) !important; }
.settings > fieldset > legend { float: left; width: 100%; }
.settings > fieldset > legend + * { clear: both; }
.toggle {
  position: relative;  /* tiene la checkbox invisibile dentro l'interruttore */
  display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px;
  padding: 11px 13px; border-radius: 13px; background: var(--carta-solida); border: 1px solid var(--linea);
  cursor: pointer; font-weight: 600; font-size: 13.5px;
}
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.track { flex: none; width: 44px; height: 24px; border-radius: 12px; background: var(--linea); position: relative; transition: background .2s; }
.track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.toggle input:checked + .track { background: var(--blu); }
.toggle input:checked + .track::after { transform: translateX(20px); }
.toggle input:focus-visible + .track { outline: 2.5px solid var(--blu); outline-offset: 2px; }

.chips { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
/* tendina della direzione, con bussola a sinistra e freccia a destra */
.selrow { position: relative; }
.selrow select {
  width: 100%; height: 42px; padding: 0 34px 0 38px; appearance: none; -webkit-appearance: none; cursor: pointer;
  border: 1.5px solid var(--linea); border-radius: 11px; background: var(--input-bg); color: var(--ink);
  font-size: 14.5px; font-weight: 600;
}
.selrow select:focus { border-color: var(--blu); outline: none; box-shadow: 0 0 0 3px var(--blu-glow); }
.selicon { position: absolute; left: 12px; top: 50%; width: 18px; height: 18px; margin-top: -9px; color: var(--blu); pointer-events: none; }
.selchev { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); color: var(--muto); pointer-events: none; font-size: 13px; }
.chips button {
  border: 1.5px solid var(--linea); background: var(--input-bg); border-radius: 9px;
  padding: 7px 4px; cursor: pointer; font-weight: 600; font-size: 12.5px; color: var(--muto);
  transition: background .18s, border-color .18s, color .18s; text-align: center;
}
.chips button[aria-pressed="true"] { background: var(--blu); border-color: var(--blu); color: var(--on-acc); }

.go {
  width: 100%; margin-top: 16px; height: 48px; border: 0; border-radius: 13px; cursor: pointer;
  background: var(--btn-bg); color: var(--on-acc); font-family: var(--cond); font-weight: 700; font-size: 18px;
  box-shadow: 0 8px 20px -6px var(--blu-glow); transition: transform .2s, filter .2s;
}
.go:hover { transform: translateY(-1px); filter: brightness(1.06); }
.go:disabled { opacity: .6; cursor: progress; transform: none; }
.back-results { width: 100%; margin-top: 8px; height: 42px; border-radius: 13px; cursor: pointer;
  border: 1.5px solid var(--blu); background: var(--carta-solida); color: var(--blu-testo); font-weight: 700; font-size: 14px; }
