/* Stili complementari a Tailwind (componenti riutilizzati).
   Tailwind è caricato via CDN; qui usiamo @apply-like utility inline
   tramite classi custom definite con CSS semplice per non dipendere
   da un build step. */

:root {
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
}

/* ---- Informativa privacy (HTML iniettato in #privacy-text) ---- */
#privacy-text h3 {
  margin: 1.25rem 0 0.4rem;
  font-size: 1rem;
  font-weight: 800;
  color: #0f172a;
}
#privacy-text h3:first-child {
  margin-top: 0;
}
#privacy-text h4 {
  margin: 0.9rem 0 0.3rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: #1e293b;
}
#privacy-text p {
  margin: 0 0 0.75rem;
}
#privacy-text p:first-child {
  margin-top: 0;
}
#privacy-text a {
  color: #1d52d4;
  font-weight: 600;
  text-decoration: underline;
}

/* ---- Stepper dots ---- */
.step-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.2);
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  transition: all 0.25s ease;
}
.step-dot.is-active {
  background: #fff;
  color: #1840ab;
  transform: scale(1.1);
}
.step-dot.is-done {
  background: #22c55e;
  color: #fff;
}

/* ---- Bottoni ---- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 1rem;
  background: #1D6BBA;
  padding: 0.9rem 1.6rem;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 8px 20px -8px rgba(29, 82, 212, 0.6);
  transition: transform 0.12s ease, background 0.2s ease, opacity 0.2s ease;
  min-height: 3.25rem; /* comodo per il tocco su tablet */
}
.btn-primary:hover:not(:disabled) {
  background: #1840ab;
}
.btn-primary:active:not(:disabled) {
  transform: scale(0.97);
}
.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 1rem;
  background: #f1f5f9;
  padding: 0.9rem 1.6rem;
  font-size: 1rem;
  font-weight: 700;
  color: #475569;
  transition: background 0.2s ease, transform 0.12s ease;
  min-height: 3.25rem;
}
.btn-ghost:hover {
  background: #e2e8f0;
}
.btn-ghost:active {
  transform: scale(0.97);
}

/* ---- Form ---- */
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.35rem;
}
.form-input {
  width: 100%;
  border-radius: 0.9rem;
  border: 2px solid #e2e8f0;
  background: #fff;
  padding: 0.8rem 1rem;
  font-size: 1rem;
  color: #0f172a;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  min-height: 3.25rem;
}
.form-input:focus {
  outline: none;
  border-color: #2f6fef;
  box-shadow: 0 0 0 4px rgba(47, 111, 239, 0.15);
}
.form-input.has-error {
  border-color: #f43f5e;
}
.form-error {
  margin-top: 0.3rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: #e11d48;
}

/* ---- Checkbox custom (consensi + servizi, tablet friendly) ----
   Markup:
     <label class="check-card">
       <input type="checkbox" class="check-input" />
       <span class="check-box"></span>
       <span>…testo…</span>
     </label>
   Il checkbox nativo è nascosto ma resta accessibile (tab/spazio, focus). */
.check-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  border-radius: 1rem;
  border: 2px solid #e2e8f0;
  background: #fff;
  padding: 0.85rem 1rem;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, transform 0.1s ease;
  min-height: 3.5rem;
}
.check-card:hover {
  border-color: #8ebdff;
  background: #f8faff;
}
.check-card:active {
  transform: scale(0.995);
}

/* Checkbox nativo nascosto visivamente ma presente per accessibilità */
.check-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

/* Quadratino disegnato */
.check-box {
  position: relative;
  flex-shrink: 0;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 0.55rem;
  border: 2px solid #cbd5e1;
  background: #fff;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}
/* Spunta (SVG via mask), nascosta finché non selezionato */
.check-box::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #fff;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round' d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 70% no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round' d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 70% no-repeat;
  transform: scale(0.5);
  opacity: 0;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

/* Stato selezionato: card evidenziata + quadratino pieno + spunta */
.check-card:has(.check-input:checked) {
  border-color: #1D6BBA;
  background: #eef5ff;
  box-shadow: 0 8px 18px -12px rgba(47, 111, 239, 0.7);
}
.check-input:checked ~ .check-box {
  border-color: #1D6BBA;
  background: #1D6BBA;
}
.check-input:checked ~ .check-box::after {
  transform: scale(1);
  opacity: 1;
}
.check-card:has(.check-input:checked) span:last-child {
  color: #1D6BBA;
}

/* Focus da tastiera: anello attorno al quadratino */
.check-input:focus-visible ~ .check-box {
  box-shadow: 0 0 0 4px rgba(47, 111, 239, 0.25);
  border-color: #2f6fef;
}

/* ---- Risposte quiz ---- */
.answer-btn {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  text-align: left;
  border-radius: 1rem;
  border: 2px solid #e2e8f0;
  background: #fff;
  padding: 1.05rem 1.25rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: #1e293b;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
  min-height: 3.75rem;
}
.answer-btn:hover:not(:disabled) {
  border-color: #8ebdff;
  background: #f8faff;
}
.answer-btn:active:not(:disabled) {
  transform: scale(0.99);
}
.answer-btn:disabled {
  cursor: default;
}
.answer-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  flex-shrink: 0;
  border-radius: 0.7rem;
  background: #eef2f7;
  font-weight: 800;
  color: #475569;
}

/* Stati risposta dopo il click */
.answer-btn.is-correct {
  border-color: #22c55e;
  background: #f0fdf4;
  color: #15803d;
}
.answer-btn.is-correct .answer-letter {
  background: #22c55e;
  color: #fff;
}
.answer-btn.is-wrong {
  border-color: #f43f5e;
  background: #fff1f2;
  color: #be123c;
}
.answer-btn.is-wrong .answer-letter {
  background: #f43f5e;
  color: #fff;
}
.answer-btn.is-muted {
  opacity: 0.55;
}

/* Feedback box varianti */
.feedback-ok {
  border-color: #bbf7d0;
  background: #f0fdf4;
}
.feedback-ko {
  border-color: #fecdd3;
  background: #fff1f2;
}

/* ---- Card selezione geografica (tablet friendly) ---- */
.picker-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.25rem;
  min-height: 5rem;
  border-radius: 1rem;
  border: 2px solid #e2e8f0;
  background: #fff;
  padding: 1rem 1.1rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
.picker-card:hover {
  border-color: #8ebdff;
  background: #f8faff;
}
.picker-card:active {
  transform: scale(0.98);
}
.picker-card.is-selected {
  border-color: #2f6fef;
  background: #eef5ff;
  box-shadow: 0 8px 20px -12px rgba(47, 111, 239, 0.7);
}
.picker-card .pc-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.2;
}
.picker-card .pc-sub {
  font-size: 0.8rem;
  font-weight: 500;
  color: #64748b;
}

/* Chip del breadcrumb */
.crumb {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 9999px;
  padding: 0.35rem 0.8rem;
  font-weight: 600;
  background: #eef5ff;
  color: #1840ab;
}
.crumb-sep {
  color: #94a3b8;
}

/* Skeleton di caricamento */
.picker-skeleton {
  min-height: 5rem;
  border-radius: 1rem;
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 37%, #f1f5f9 63%);
  background-size: 400% 100%;
  animation: shimmer 1.2s ease infinite;
}
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* ---- Transizione tra viste ---- */
.view {
  animation: fadeInUp 0.35s ease both;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Toast / avviso non bloccante ----
   Usato per segnalare al visitatore eventi come la registrazione del contatto
   non riuscita, senza interrompere il flusso del quiz. */
.toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  z-index: 50;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  max-width: min(92vw, 34rem);
  border-radius: 1rem;
  border: 1px solid #fcd34d;
  background: #fffbeb;
  color: #92400e;
  padding: 0.9rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.35;
  box-shadow: 0 16px 32px -16px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast-close {
  flex-shrink: 0;
  margin-left: auto;
  width: 1.6rem;
  height: 1.6rem;
  line-height: 1.4rem;
  border-radius: 0.5rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: #92400e;
  background: transparent;
  cursor: pointer;
}
.toast-close:hover {
  background: rgba(146, 64, 14, 0.1);
}
