/* ─── FORM MULTI-STEP "RICHIEDI PREVENTIVO" ─────────────────────────────
   Componente autonomo, scoped con prefisso "mstep-". Il wrapper ha
   anche la classe "card" (css/cobalto.css): è una superficie CHIARA
   (--n-0) che galleggia dentro .hp-cta-final.sec-dark. Per questo tutti
   i testi/bordi qui dentro usano i token "su chiaro" del design system
   (--text-heading, --text-body, --n-*, --blu-600 come accento/focus),
   mai gli alias "su scuro" (--azz-300 ecc.): quelli restano riservati
   al testo che sta DIRETTAMENTE sul gradiente scuro della sezione,
   fuori da questa card. I bottoni riusano .btn/.btn--primary/
   .btn--secondary di css/cobalto.css così come sono. */

.mstep-wrapper {
  max-width: 640px;
  margin: 1rem auto 0.5rem;
  padding: clamp(0.9rem, 2.2vw, 1.4rem) clamp(1rem, 2.8vw, 1.6rem);
  text-align: left;
  color: var(--text-body);
}

/* ─── Progress bar ────────────────────────────────────────────────────
   "Step X di 3" è un indicatore di avanzamento testuale, non un
   eyebrow/badge decorativo: nessun trattamento a pillola colorata. */
.mstep-progress {
  margin-bottom: 0.85rem;
}

.mstep-progress-track {
  height: 6px;
  border-radius: 999px;
  background: var(--n-200);
  overflow: hidden;
}

.mstep-progress-fill {
  height: 100%;
  width: 33%;
  border-radius: 999px;
  background: var(--blu-600);
  transition: width 0.35s ease;
}

.mstep-progress-label {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

/* Contiene form + schermate finali. Non ha un cap proprio: l'eventuale
   scroll interno vive sul pannello esterno .mstep-wrapper (vedi sopra),
   così package-selector e progress restano sempre visibili in cima. */
.mstep-scroll {
  overflow: visible;
}

.mstep-step[hidden] {
  display: none;
}

.mstep-fade-out {
  animation: mstep-fade-out 0.18s ease forwards;
}

.mstep-fade-in {
  animation: mstep-fade-in 0.28s ease;
}

@keyframes mstep-fade-out {
  to { opacity: 0; transform: translateY(-6px); }
}

@keyframes mstep-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.mstep-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.3rem, 2vw, 1.6rem);
  line-height: 1.2;
  margin-bottom: 0.35rem;
}

/* Specificità maggiore di ".on-dark h1..h4" (css/cobalto.css): il wrapper
   sta dentro una sezione .on-dark, ma è una card CHIARA — il titolo deve
   restare scuro anche qui, non ereditare il bianco della sezione. */
.mstep-wrapper .mstep-title {
  color: var(--text-heading);
}

.mstep-sub {
  font-size: clamp(0.875rem, 1.3vw, 0.95rem);
  line-height: 1.45;
  color: var(--text-secondary);
  margin-bottom: 0.85rem;
}

/* ─── Step 1: card selezionabili — 2 colonne da 480px in su ─────────── */
.mstep-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
}

@media (min-width: 480px) {
  .mstep-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

.mstep-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--n-300);
  border-radius: 12px;
  background: var(--n-0);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.mstep-card:hover {
  border-color: var(--blu-200);
}

.mstep-card input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.mstep-card-check {
  position: relative;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  border-radius: 50%;
  border: 1.5px solid var(--n-400);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.mstep-card-check::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -60%) rotate(45deg);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.mstep-card input:focus-visible ~ .mstep-card-check {
  outline: 2px solid var(--blu-600);
  outline-offset: 2px;
}

.mstep-card.is-selected {
  border-color: var(--blu-600);
  background: var(--blu-50);
}

.mstep-card.is-selected .mstep-card-check {
  border-color: var(--blu-600);
  background: var(--blu-600);
}

.mstep-card.is-selected .mstep-card-check::after {
  opacity: 1;
}

.mstep-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.mstep-card-title {
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.25;
  color: var(--text-heading);
}

.mstep-card-desc {
  font-size: 0.875rem;
  line-height: 1.3;
  color: var(--text-muted);
}

/* ─── Campi form (step 2 e 3) ──────────────────────────────────────── */
.mstep-field {
  margin-bottom: 0.9rem;
}

.mstep-field label,
.mstep-field-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--n-700);
  margin-bottom: 0.35rem;
}

.mstep-field textarea,
.mstep-field input[type="text"],
.mstep-field input[type="email"],
.mstep-field input[type="tel"] {
  width: 100%;
  padding: 0.8rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--n-300);
  background: var(--n-0);
  color: var(--text-body);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.mstep-field textarea {
  min-height: 84px;
  resize: vertical;
}

.mstep-field textarea::placeholder,
.mstep-field input::placeholder {
  color: var(--n-400);
}

.mstep-field textarea:focus,
.mstep-field input:focus {
  outline: none;
  border-color: var(--blu-600);
  background: var(--n-0);
  box-shadow: 0 0 0 3px rgba(26, 63, 204, 0.14);
}

/* Chip di scelta singola */
.mstep-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.mstep-chip {
  position: relative;
}

.mstep-chip input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.mstep-chip span {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--n-300);
  background: var(--n-0);
  color: var(--n-700);
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.mstep-chip:hover span {
  border-color: var(--blu-200);
}

.mstep-chip input:focus-visible ~ span {
  outline: 2px solid var(--blu-600);
  outline-offset: 2px;
}

.mstep-chip.is-selected span {
  border-color: var(--blu-600);
  background: var(--blu-600);
  color: #fff;
}

/* Azienda opzionale, collassata */
.mstep-add-azienda {
  display: inline-block;
  background: none;
  border: none;
  padding: 0;
  margin-bottom: 0.9rem;
  color: var(--blu-600);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* "display" esplicito su .mstep-add-azienda e su .btn (mstep-back)
   vince sempre sull'attributo hidden: senza questa regola, l'attributo
   da solo non li nasconde davvero (stesso problema già risolto sopra
   per .mstep-step[hidden]). */
.mstep-add-azienda[hidden],
.mstep-back[hidden] {
  display: none;
}

/* Checkbox privacy */
.mstep-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--n-700);
  cursor: pointer;
}

.mstep-checkbox input {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 0.2rem;
  accent-color: var(--blu-600);
  cursor: pointer;
}

.mstep-checkbox a {
  color: var(--blu-600);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.mstep-error {
  margin-top: 0.4rem;
  font-size: 0.875rem;
  color: var(--error);
}

/* Honeypot Netlify — nascosto visivamente, non da display:none */
.mstep-hidden-field {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  left: -9999px;
}

/* ─── Navigazione step ─────────────────────────────────────────────── */
/* I bottoni riusano .btn/.btn--inverse/.btn--inverse-outline di
   css/cobalto.css così come sono (le varianti "inverse" sono pensate
   apposta per CTA su sezioni scure, §7.1): qui aggiungiamo SOLO layout
   (larghezza/spaziatura), mai colore o forma. .mstep-wrapper .btn è
   l'unica eccezione: i browser applicano uno stile nativo (bordo/sfondo
   di sistema) ai <button> che .btn non aveva mai dovuto sovrascrivere
   finora, perché nel resto del sito .btn viene usata perlopiù su <a> —
   senza appearance:none quello stile nativo faceva capolino dietro il
   pill, dando l'aria di un bottone "fatto in casa" invece del bottone
   primario del brand. */
.mstep-wrapper .btn {
  appearance: none;
  -webkit-appearance: none;
  background-image: none;
}

.mstep-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.1rem;
}

.mstep-nav .btn {
  flex: 1 1 140px;
  justify-content: center;
  /* Solo l'altezza (troppo spessi rispetto al resto dell'interfaccia
     compatta del form): padding verticale ridotto + line-height più
     stretto invece dell'1.6 ereditato dal body, mai il colore/forma
     di .btn/.btn--inverse/.btn--inverse-outline. Resta comodamente
     sopra i 40px di tap target. */
  padding-block: 0.7rem;
  line-height: 1.2;
}

.mstep-wrapper .btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
  transform: none;
}

/* ─── Schermate finali (conferma / errore) ────────────────────────── */
.mstep-confirm,
.mstep-error-screen {
  text-align: center;
  padding: 1.5rem 0.5rem 0.5rem;
}

.mstep-confirm-icon,
.mstep-error-icon {
  position: relative;
  width: 52px;
  height: 52px;
  margin: 0 auto 1.25rem;
  border-radius: 50%;
}

.mstep-confirm-icon {
  border: 1.5px solid var(--success);
  background: var(--success-bg);
}

.mstep-confirm-icon::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 20px;
  border: solid var(--success);
  border-width: 0 3px 3px 0;
  transform: translate(-50%, -60%) rotate(45deg);
}

.mstep-error-icon {
  border: 1.5px solid var(--error);
  background: var(--error-bg);
}

.mstep-error-icon::before,
.mstep-error-icon::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 3px;
  background: var(--error);
  transform-origin: center;
}

.mstep-error-icon::before { transform: translate(-50%, -50%) rotate(45deg); }
.mstep-error-icon::after  { transform: translate(-50%, -50%) rotate(-45deg); }

.mstep-confirm .mstep-title,
.mstep-error-screen .mstep-title {
  margin-bottom: 0.75rem;
}

.mstep-confirm .mstep-sub,
.mstep-error-screen .mstep-sub {
  margin-bottom: 1.25rem;
}

.mstep-error-screen .mstep-sub a {
  color: var(--blu-600);
  text-decoration: underline;
}

.mstep-home-link {
  display: inline-block;
  color: var(--blu-600);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.mstep-error-screen .mstep-nav {
  justify-content: center;
}

.mstep-error-screen .btn {
  flex: 0 1 auto;
  min-width: 140px;
}

/* ─── Riduzione motion ─────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .mstep-fade-out,
  .mstep-fade-in,
  .mstep-scroll,
  .mstep-progress-fill {
    animation: none !important;
    transition: none !important;
  }
}
