/**
 * Visiva — form richiesta (lead)
 *
 * Stile unico per marketing e tool: usa i token di tokens.css, quindi si
 * adatta sia alle superfici chiare delle landing sia al tema dei tool.
 * Il form compare sotto il risultato della verifica (inizialmente nascosto)
 * e nelle landing commerciali; la CTA sticky è solo mobile.
 */

.lead-form-card {
  padding: clamp(22px, 3vw, 34px);
  border-radius: 20px;
  background: #ffffff;
  border: 1px solid var(--border);
  box-shadow: var(--sh-sm);
  margin-top: 22px;
}

.lead-form-card[hidden] {
  display: none;
}

.lead-form__head {
  max-width: 720px;
  margin-bottom: 20px;
}

.lead-form__head .section-eyebrow {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--blue-deep);
}

.lead-form__head h2,
.lead-form__head h3 {
  margin: 4px 0 8px;
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 2.4vw, 1.55rem);
  line-height: 1.2;
  color: var(--ink);
}

.lead-form__head p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--ink-soft);
}

.lead-form__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.lead-form__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.lead-form__field--wide {
  grid-column: 1 / -1;
}

.lead-form__field input,
.lead-form__field select,
.lead-form__field textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 13px;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background: #ffffff;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.94rem;
  font-weight: 400;
  line-height: 1.4;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.lead-form__field textarea {
  min-height: 96px;
  resize: vertical;
}

.lead-form__field input:focus,
.lead-form__field select:focus,
.lead-form__field textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-glow);
}

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

.lead-form__consent {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 16px 0 0;
  font-size: 0.81rem;
  line-height: 1.55;
  color: var(--muted);
}

.lead-form__consent input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--blue);
}

.lead-form__consent a {
  color: var(--blue-deep);
  font-weight: 600;
}

.lead-form__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
}

.lead-form__submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 13px 24px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 0.94rem;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(135deg, var(--blue), var(--blue-deep));
  box-shadow: 0 14px 28px -16px rgba(30, 136, 229, 0.9);
  cursor: pointer;
  transition: filter 0.18s, transform 0.18s;
}

.lead-form__submit:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.lead-form__submit:disabled {
  cursor: progress;
  filter: grayscale(0.15);
  transform: none;
}

.lead-form__note {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--muted);
}

.lead-form__status {
  margin: 14px 0 0;
  font-size: 0.86rem;
  line-height: 1.5;
}

.lead-form__status.is-error {
  padding: 11px 13px;
  border-radius: 10px;
  border-left: 3px solid var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

/* --- Conferma invio ------------------------------------------------------ */
/* Resta dentro la card del form: i campi vengono sostituiti dalla conferma,
   ma la sezione non sparisce e il cliente vede subito cosa succede dopo. */
.lead-form__success {
  display: none;
  gap: 18px;
  padding: clamp(20px, 3vw, 28px);
  border-radius: 18px;
  border: 1px solid rgba(30, 136, 229, 0.26);
  background:
    radial-gradient(120% 120% at 100% 0%, rgba(30, 136, 229, 0.10), transparent 55%),
    linear-gradient(180deg, #f8fbff 0%, #eef6ff 100%);
  box-shadow: 0 18px 40px -30px rgba(10, 26, 47, 0.55), inset 0 1px 0 #ffffff;
}

.lead-form__success:not([hidden]) {
  display: flex;
  animation: lead-success-in 0.32s ease both;
}

.lead-form__success-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-deep) 100%);
  color: #ffffff;
  font-size: 1.25rem;
  box-shadow: 0 12px 24px -12px rgba(21, 101, 192, 0.75);
}

.lead-form__success-content {
  min-width: 0;
}

.lead-form__success-eyebrow {
  display: inline-block;
  margin-bottom: 6px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--blue-deep);
}

.lead-form__success h3 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 2.2vw, 1.45rem);
  line-height: 1.2;
  color: var(--ink);
}

.lead-form__success [data-lead-success-text] {
  margin: 0 0 18px;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--ink-soft);
}

.lead-form__success-steps {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.lead-form__success-steps li {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px 6px 7px;
  border-radius: 999px;
  border: 1px solid rgba(30, 136, 229, 0.18);
  background: #ffffff;
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink-soft);
}

.lead-form__success-step-num {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue-deep);
  font-size: 0.68rem;
  font-weight: 800;
}

.lead-form__success-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.lead-form__success .whatsapp-button {
  margin-top: 0;
}

.lead-form__success-call {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: #ffffff;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.86rem;
  font-weight: 700;
  text-decoration: none;
}

.lead-form__success-note {
  margin: 14px 0 0;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--muted);
}

.lead-form__success-reset {
  margin-top: 10px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--blue-deep);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

@keyframes lead-success-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .lead-form__success:not([hidden]) {
    animation: none;
  }
}

@media (max-width: 640px) {
  .lead-form__success {
    flex-direction: column;
    gap: 14px;
    padding: 18px 16px;
  }

  .lead-form__success-icon {
    width: 46px;
    height: 46px;
    font-size: 1.05rem;
  }

  .lead-form__success-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .lead-form__success-actions .whatsapp-button,
  .lead-form__success-call {
    justify-content: center;
  }
}

/* --- CTA sticky mobile -------------------------------------------------- */
/* Compare solo nelle pagine che contengono un form (page-end.php la include
   quando il partial ha segnalato la presenza del form). Su desktop sarebbe
   un duplicato: da qui il limite di larghezza.

   --copyright-h e --lead-sticky-h sono misure reali impostate da
   js/lead-form.js: la barra copyright è fissa e va a capo sui telefoni
   stretti, quindi un offset fisso faceva finire la CTA dietro al testo. */
.lead-sticky {
  display: none;
}

@media (max-width: 780px) {
  .lead-form__grid {
    grid-template-columns: 1fr;
  }

  .lead-form__actions {
    flex-direction: column;
    align-items: stretch;
  }

  .lead-form__submit {
    width: 100%;
  }

  .lead-sticky {
    position: fixed;
    z-index: 1900;
    left: 12px;
    right: 12px;
    /* Sopra la barra copyright fissa (z-index 2000) e con un margine reale:
       su 320-360px la riga copyright va a capo, quindi l'altezza arriva dal
       JS e non da un valore fisso che faceva sovrapporre i due blocchi. */
    bottom: calc(var(--copyright-h, 56px) + 10px + env(safe-area-inset-bottom));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px 10px 16px;
    border-radius: 16px;
    background: rgba(10, 26, 47, 0.97);
    border: 1px solid rgba(148, 197, 255, 0.28);
    box-shadow: 0 18px 40px -18px rgba(10, 26, 47, 0.9);
  }

  .lead-sticky__text {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
    color: #eaf3ff;
  }

  .lead-sticky__text strong {
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 800;
    line-height: 1.2;
    overflow-wrap: anywhere;
  }

  .lead-sticky__text span {
    font-size: 0.72rem;
    line-height: 1.35;
    color: rgba(214, 231, 248, 0.72);
    overflow-wrap: anywhere;
  }

  /* Il prefisso `.lead-sticky` serve a vincere su `.tool-page button`
     (tool.css/tool-theme.css), che impone width:100%, min-height:52px e il
     gradiente blu: senza di esso la CTA diventava un bottone a tutta riga e
     il testo della barra collassava a larghezza zero. */
  .lead-sticky .lead-sticky__btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-height: 44px;
    gap: 7px;
    padding: 10px 16px;
    border: 0;
    border-radius: 999px;
    box-shadow: none;
    font-family: var(--font-display);
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    color: #ffffff;
    /* Colore aziendale (blu elettrico → blu profondo), non il verde
       WhatsApp riservato al pulsante di fallback. */
    background: linear-gradient(135deg, var(--blue) 0%, var(--blue-deep) 100%);
    cursor: pointer;
  }

  .lead-sticky .lead-sticky__btn:hover:not(:disabled) {
    transform: none;
    box-shadow: none;
  }

  .lead-sticky .lead-sticky__btn:active:not(:disabled) {
    transform: none;
  }

  /* Riserva spazio sotto il footer: la CTA è fissa, senza questo padding
     coprirebbe le ultime righe di testo quando si arriva a fine pagina. */
  body.marketing-page.has-lead-cta,
  body.tool-page.has-lead-cta {
    padding-bottom: calc(
      var(--copyright-h, 56px) + var(--lead-sticky-h, 64px) + 34px +
        env(safe-area-inset-bottom)
    );
  }
}
