/* Strade pericolose - alVolante
   Rosso del marchio alVolante (#CC0000, lo stesso del logo e di --color-primary
   nel tema del sito) per azioni e segnali di pericolo, asfalto e bianco della
   segnaletica orizzontale per il resto. */

@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap; src: url(../fonts/barlow-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-display: swap; src: url(../fonts/barlow-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap; src: url(../fonts/barlow-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 600; font-display: swap; src: url(../fonts/barlow-semi-condensed-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 700; font-display: swap; src: url(../fonts/barlow-semi-condensed-latin-700-normal.woff2) format("woff2"); }

:root {
  /* Rosso del marchio alVolante: #CC0000, come il logo e --color-primary del
     tema del sito. Le due varianti sono sue derivate, non colori a sé:
     più scura per l'ombra dei pulsanti, più chiara per gli avvisi. */
  --rosso: #cc0000;
  --rosso-scuro: #a80000;
  --rosso-chiaro: #fbebeb;
  --asfalto: #2c2f32;
  --asfalto-chiaro: #4c5156;
  --sfondo: #f1f2f2;
  --carta: #ffffff;
  --testo: #2c2f32;
  --testo-2: #62686e;
  --bordo: #cdd1d4;
  --errore: #cc0000;
  --verde: #2f7d4a;
  --focus: #1a5fb4;

  --display: "Barlow Semi Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --gutter: 16px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--sfondo);
  color: var(--testo);
  font: 400 17px/1.5 var(--body);
}
body > main { flex: 1; width: 100%; }
.wrap { max-width: 600px; margin: 0 auto; padding: 0 var(--gutter); }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- Barra con il logo ---------- */
.topbar {
  background: var(--carta);
  border-bottom: 4px solid var(--rosso);
  padding: calc(10px + env(safe-area-inset-top)) 0 10px;
}
.brand { display: inline-flex; align-items: center; min-height: 34px; text-decoration: none; }
.brand img { display: block; height: 30px; width: auto; }
.brand-text { font: 700 24px/1 var(--display); color: var(--rosso); letter-spacing: -0.01em; }

/* ---------- Testata ---------- */
.masthead {
  background: var(--asfalto);
  color: #fff;
  padding: 26px 0 18px;
}
/* Mezzeria tratteggiata bianca che chiude la testata */
.masthead::after {
  content: "";
  display: block;
  height: 5px;
  margin-top: 24px;
  background: repeating-linear-gradient(90deg, #fff 0 34px, transparent 34px 56px);
  opacity: .9;
}
.masthead h1 {
  font: 700 clamp(46px, 13vw, 64px)/0.92 var(--display);
  letter-spacing: -0.01em;
  margin: 0 0 12px;
}
.lede { margin: 0; max-width: 34em; color: #d6d9db; }

/* ---------- Passi del modulo ---------- */
form { padding: 28px 0 8px; }
.step { position: relative; padding: 0 0 34px 50px; }
/* Il percorso tratteggiato che unisce i passi */
.step::before {
  content: "";
  position: absolute;
  left: 17px;
  top: 40px;
  bottom: 4px;
  width: 3px;
  background: repeating-linear-gradient(to bottom, var(--bordo) 0 12px, transparent 12px 22px);
}
/* Triangolo di pericolo con il numero del passo */
.marker {
  position: absolute;
  left: 0;
  top: 0;
  width: 36px;
  height: 32px;
  overflow: visible;
}
.marker path { fill: #fff; stroke: var(--rosso); stroke-width: 4; stroke-linejoin: round; }
.marker text { font: 700 15px var(--display); fill: var(--asfalto); text-anchor: middle; }
.step.is-done .marker path { fill: var(--rosso); }
.step.is-done .marker text { fill: #fff; }

.step h2 { font: 700 27px/1.1 var(--display); margin: 2px 0 16px; }

/* ---------- Foto ---------- */
.picker {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 26px 16px 22px;
  background: var(--carta);
  border: 2px dashed var(--asfalto-chiaro);
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  color: var(--asfalto);
}
.picker svg { color: var(--rosso); }
.picker:hover { border-color: var(--rosso); }
.picker:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.picker input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.picker-title { font: 700 21px/1.2 var(--display); margin-top: 4px; }
.picker-sub { font-size: 15px; color: var(--testo-2); }
.picker.is-compact { grid-auto-flow: column; justify-content: center; align-items: center; gap: 10px; padding: 14px; }
.picker.is-compact svg { width: 22px; height: 22px; }
.picker.is-compact .picker-title { font-size: 18px; margin: 0; }
.picker.is-compact .picker-sub { display: none; }
.picker.is-full { display: none; }

.thumbs {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px 8px;
}
.thumbs:empty { display: none; }
/* La scheda della foto: l'anteprima sopra, il menù del problema sotto. Il
   riquadro quadrato resta com'era, e la tendina non gli sta sopra. */
.thumb { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.thumb-box { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--asfalto-chiaro); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .noprev { position: absolute; inset: 0; display: grid; place-items: center; padding: 8px; text-align: center; color: #fff; font-size: 13px; line-height: 1.3; }
.thumb.is-busy img { opacity: .4; }
.thumb.is-busy .thumb-box::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 26px;
  height: 26px;
  border: 3px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.thumb .remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(30,32,34,.78);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.thumb .gps {
  position: absolute;
  left: 4px;
  bottom: 4px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px 7px 2px 4px;
  border-radius: 99px;
  background: #fff;
  color: var(--asfalto);
  font: 600 12px/1.4 var(--body);
}
.thumb .gps svg { color: var(--rosso); }
.thumb.is-error .thumb-box { outline: 3px solid var(--errore); }
.thumb .err { position: absolute; inset: auto 0 0 0; background: var(--errore); color: #fff; font-size: 12px; line-height: 1.3; padding: 4px 6px; }

/* La tendina del problema, sotto la sua foto. Il bordo è sempre visibile,
   non solo al passaggio del mouse: è un campo da compilare. */
.thumb-problema { display: block; }
.thumb-problema select {
  width: 100%;
  font: 400 13px/1.2 var(--body);
  color: var(--testo);
  padding: 7px 24px 7px 8px;
  border: 1.5px solid var(--bordo);
  border-radius: 6px;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23555' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 4px center;
  background-size: 18px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  text-overflow: ellipsis;
  min-height: 38px;
}
.thumb-problema select.is-invalid { border-color: var(--errore); background-color: #fff5f5; }
.thumb-problema select:focus-visible { outline: 3px solid var(--rosso); outline-offset: 1px; }

.note {
  margin: 14px 0 0;
  padding-left: 12px;
  border-left: 4px solid var(--rosso);
  font-size: 15px;
  color: var(--testo-2);
}

/* ---------- Posizione ---------- */
.loc-status { margin: 0 0 12px; color: var(--testo-2); font-size: 16px; }
.loc-status.is-set { color: var(--testo); }
.loc-status strong { font-weight: 600; }
.loc-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.map { height: 240px; border-radius: 12px; border: 1.5px solid var(--bordo); margin-bottom: 18px; z-index: 0; }
.leaflet-container { font-family: var(--body); }

/* ---------- Campi ---------- */
.field { display: block; margin: 0 0 16px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.label { display: block; font-weight: 600; font-size: 16px; margin-bottom: 5px; }
.opt { font-weight: 400; color: var(--testo-2); }
.hint { display: block; font-size: 14px; color: var(--testo-2); margin-top: 5px; }
/* Un'azione dentro una riga di testo: "Usa questa via". Sembra un link, è un
   pulsante, e deve restare raggiungibile da tastiera come tale. */
.link-btn {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--rosso);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
input[type="text"], input[type="email"], textarea {
  width: 100%;
  font: inherit;
  font-size: 17px; /* evita lo zoom automatico su iOS */
  color: var(--testo);
  background: var(--carta);
  border: 1.5px solid var(--bordo);
  border-radius: 8px;
  padding: 12px 13px;
  appearance: none;
}
textarea { resize: vertical; min-height: 110px; }
input:focus, textarea:focus { border-color: var(--asfalto); outline: 3px solid var(--focus); outline-offset: 0; }
::placeholder { color: #979da2; }
.is-invalid { border-color: var(--errore) !important; }

/* ---------- Autorizzazioni ---------- */
.consents { display: grid; gap: 4px; }
.consents .group-label { font-size: 15px; color: var(--testo-2); margin: 14px 0 4px; }
.consents .group-label:first-child { margin-top: 0; }
.check {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--carta);
  border: 1.5px solid transparent;
  cursor: pointer;
  font-size: 16px;
  line-height: 1.4;
}
.check input {
  appearance: none;
  width: 26px;
  height: 26px;
  margin: 0;
  border: 2px solid var(--asfalto-chiaro);
  border-radius: 6px;
  background: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.check input:checked { background: var(--rosso); border-color: var(--rosso); }
.check input:checked::after {
  content: "";
  width: 7px; height: 13px;
  border: solid #fff;
  border-width: 0 3px 3px 0;
  transform: translateY(-2px) rotate(45deg);
}
.check.is-invalid { border-color: var(--errore); }
.check a { color: var(--rosso); font-weight: 500; text-decoration-thickness: 1.5px; text-underline-offset: 2px; }

/* ---------- Errori ---------- */
.field-error, .form-error { color: var(--errore); font-weight: 500; font-size: 15px; margin: 8px 0 0; }
.form-error { background: var(--rosso-chiaro); border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; }
[hidden] { display: none !important; }

/* ---------- Pulsanti ---------- */
button { font: inherit; }
.btn-primary {
  position: relative;
  overflow: hidden;
  width: 100%;
  min-height: 60px;
  border: 0;
  border-radius: 12px;
  background: var(--rosso);
  color: #fff;
  font: 700 22px/1 var(--display);
  cursor: pointer;
  box-shadow: inset 0 -4px 0 var(--rosso-scuro);
}
.btn-primary:hover { background: #a3261c; }
.btn-primary:active { box-shadow: none; transform: translateY(2px); }
.btn-primary:disabled { cursor: progress; background: var(--rosso-scuro); }
.btn-primary .progress {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--rosso);
  transition: width .2s ease-out;
}
.btn-primary .btn-label { position: relative; }
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 48px;
  padding: 8px 12px;
  border: 1.5px solid var(--asfalto);
  border-radius: 10px;
  background: var(--carta);
  color: var(--asfalto);
  font-weight: 600;
  font-size: 15.5px;
  line-height: 1.15;
  cursor: pointer;
}
.btn-secondary svg { color: var(--rosso); flex: none; }
.btn-secondary:active { background: var(--sfondo); }
.btn-secondary:disabled { opacity: .6; cursor: progress; }

.send { padding: 4px 0 40px; }

/* ---------- Conferma ---------- */
.done { padding: 40px 0 56px; outline: none; }
.done-mark { width: 64px; height: 64px; display: grid; place-items: center; background: var(--verde); color: #fff; border-radius: 50%; }
.done h2 { font: 700 36px/1.05 var(--display); margin: 20px 0 12px; }
.done p { margin: 0 0 12px; }
.done .code { font: 700 20px/1 var(--display); letter-spacing: .04em; background: var(--carta); padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.done .btn-secondary { margin-top: 16px; }

/* ---------- Piede ---------- */
.foot { background: var(--asfalto); color: #c8ccd0; font-size: 15px; padding: 22px 0 calc(22px + env(safe-area-inset-bottom)); }
.foot .wrap { display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: space-between; }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Su schermo stretto tre colonne lasciano alla tendina una settantina di
   pixel: "Guardrail danneggiato" non ci sta. Due colonne danno il doppio
   dello spazio alle anteprime e ai testi. */
@media (max-width: 560px) {
  .thumbs { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 360px) {
  .row, .loc-actions { grid-template-columns: 1fr; }
  .step { padding-left: 46px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
