/* Mente Pedagogica · modulo di richiesta
   Colori armonizzati con il rosa del logo (#F496BA, tinta 337°) e verificati con tools/contrast.py */
/* Font da Google Fonts (licenza OFL), ospitati qui: sottoinsieme latino, accenti italiani inclusi */
@font-face {
  font-family: "Fraunces"; font-style: normal; font-weight: 560; font-display: swap;
  src: url("assets/fonts/fraunces-560-soft-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Nunito"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("assets/fonts/nunito-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg:          #FFFFFF;
  --bg-soft:     #FFF7FA;
  --pink-100:    #FCEDF3;
  --pink-200:    #F8D8E4;
  --pink-400:    #ECACC5;
  --pink-600:    #A4466A;  /* CTA ed errori: 5.7:1 con il bianco */
  --pink-700:    #8A3857;
  --blue-100:    #EEF5FB;
  --blue-200:    #D5E7F4;
  --blue-500:    #6E9CC0;  /* solo progress bar (decorativa) */
  --blue-700:    #3E6E96;
  --ink:         #3A2F36;
  --ink-soft:    #6E5F68;
  --line:        #F0E2E8;  /* divisori decorativi */
  --line-strong: #9A8490;  /* bordi dei campi: 3:1 */
  --placeholder: #7D6C76;
  --focus-ring:  #4A7AA3;
  --on-cta:      #FFFFFF;

  --radius-card: 22px;
  --radius-field: 16px;
  --shadow-soft: 0 10px 30px -12px rgba(164, 70, 106, .22);
  --shadow-card: 0 30px 80px -30px rgba(164, 70, 106, .28);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --font-title: "Fraunces", Georgia, "Times New Roman", serif;
  --font-ui: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 106.25%; -webkit-text-size-adjust: 100%; } /* 17px */
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img, svg { display: block; }
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--pink-600); text-underline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 3px; border-radius: 12px; }

/* ---------- sfondo: due forme morbide e discrete ---------- */
.blob {
  position: fixed; z-index: -1; pointer-events: none;
  width: 420px; height: 420px; border-radius: 50%;
  filter: blur(60px); opacity: .55;
}
.blob--pink { background: var(--pink-200); top: -180px; left: -160px; }
.blob--blue { background: var(--blue-200); bottom: -200px; right: -170px; opacity: .5; }

/* ---------- contenitore ---------- */
.app {
  position: relative;
  max-width: 560px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}
.screen { flex: 1; padding: 8px 20px 28px; }
.screen:focus { outline: none; }

/* ---------- barra superiore: indietro + progresso ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 2px 12px;
  padding: 6px 20px 12px 8px;
  background: rgba(255, 255, 255, .92);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.back {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 48px; padding: 0 14px 0 8px;
  border: 0; border-radius: 999px; background: transparent;
  color: var(--ink-soft); font-weight: 600; font-size: .94rem; cursor: pointer;
}
.back svg { width: 22px; height: 22px; }
.back:hover { background: var(--pink-100); color: var(--ink); }
.progress { display: contents; }
.progress__label { font-size: .85rem; font-weight: 700; color: var(--blue-700); letter-spacing: .01em; text-align: right; }
.progress__track { grid-column: 1 / -1; margin-left: 12px; height: 8px; border-radius: 999px; background: var(--blue-200); overflow: hidden; }
.progress__fill {
  height: 100%; width: 20%; border-radius: inherit; background: var(--blue-500);
  transition: width .5s var(--ease);
}

/* ---------- tipografia ---------- */
h1, h2 {
  font-family: var(--font-title);
  font-variation-settings: "SOFT" 100, "WONK" 0;
  font-weight: 560;
  letter-spacing: -.01em;
  margin: 0;
  text-wrap: balance;
}
h1 { font-size: clamp(1.75rem, 6.4vw, 2.2rem); line-height: 1.15; }
h2 { font-size: clamp(1.5rem, 5.6vw, 1.8rem); line-height: 1.2; }
h2:focus, h1:focus { outline: none; }
.lead { margin: 12px 0 0; color: var(--ink-soft); font-size: 1.05rem; text-wrap: pretty; }
.hint { margin: 10px 0 0; color: var(--ink-soft); font-size: .94rem; }
.small { font-size: .85rem; color: var(--ink-soft); }

/* ---------- benvenuto ---------- */
.welcome { text-align: center; padding-top: 28px; }
.welcome__logo { width: min(250px, 70%); height: auto; margin: 0 auto 28px; }
.welcome .lead { max-width: 30ch; margin-inline: auto; }
.reassure {
  list-style: none; padding: 0; margin: 28px auto 0; max-width: 320px;
  display: grid; gap: 12px; text-align: left;
}
.reassure li { display: flex; align-items: center; gap: 14px; font-weight: 600; }
.badge-icon {
  flex: none; display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 14px;
  background: var(--pink-100); color: var(--pink-600);
}
.badge-icon svg { width: 22px; height: 22px; }
.badge-icon--blue { background: var(--blue-100); color: var(--blue-700); }
.welcome .small { margin-top: 20px; }

/* ---------- step ---------- */
.step__head { margin: 8px 0 22px; }
.step__head--legend { margin-bottom: 0; padding: 0; }
.step__hint { margin: 10px 0 22px; }
.group { border: 0; padding: 0; margin: 0 0 26px; min-width: 0; }
.group legend, .field__label {
  padding: 0; margin-bottom: 12px;
  font-weight: 700; font-size: 1.05rem;
}
.subhead {
  display: inline-block; margin: 6px 0 14px; padding: 4px 12px;
  border-radius: 999px; background: var(--blue-100); color: var(--blue-700);
  font-size: .85rem; font-weight: 700; letter-spacing: .02em;
}
.block + .block { margin-top: 8px; padding-top: 20px; border-top: 1px dashed var(--line); }

/* card grandi (step 1) */
.cards { display: grid; gap: 12px; }
.card { position: relative; display: block; cursor: pointer; }
.card input, .chip input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.card__inner {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  min-height: 88px; padding: 14px 14px 14px 12px;
  border: 1.5px solid var(--line); border-radius: var(--radius-card);
  background: var(--bg); box-shadow: var(--shadow-soft);
  transition: border-color .2s, background-color .2s, transform .2s var(--ease);
}
.card__icon {
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px;
  background: var(--pink-100); color: var(--pink-600);
}
.card__icon svg { width: 24px; height: 24px; }
.card__title { display: block; font-weight: 700; font-size: 1.06rem; line-height: 1.3; }
.card__text { display: block; margin-top: 2px; color: var(--ink-soft); font-size: .92rem; line-height: 1.4; }
.card__check {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  border: 1.5px solid var(--line-strong); color: transparent;
  transition: background-color .2s, border-color .2s, color .2s;
}
.card__check svg { width: 16px; height: 16px; }
.card:hover .card__inner { border-color: var(--pink-400); background: var(--bg-soft); }
.card input:checked + .card__inner { border-color: var(--pink-600); background: var(--pink-100); }
.card input:checked + .card__inner .card__icon { background: var(--pink-200); }
.card input:checked + .card__inner .card__check { background: var(--pink-600); border-color: var(--pink-600); color: var(--on-cta); }
.card input:focus-visible + .card__inner { outline: 3px solid var(--focus-ring); outline-offset: 3px; }

/* chip */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { position: relative; cursor: pointer; }
.chip span {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 48px; padding: 10px 18px;
  border: 1.5px solid var(--pink-200); border-radius: 999px;
  background: var(--bg); font-weight: 600; font-size: .96rem; line-height: 1.2;
  transition: background-color .2s, border-color .2s, transform .2s var(--ease);
}
.chip span::before {
  content: ""; width: 0; height: 16px; margin-right: -6px; opacity: 0;
  background: currentColor;
  -webkit-mask: var(--check-mask) center / 16px no-repeat; mask: var(--check-mask) center / 16px no-repeat;
  transition: width .2s var(--ease), opacity .2s, margin .2s;
}
.chip:hover span { border-color: var(--pink-400); background: var(--bg-soft); }
.chip input:checked + span { background: var(--pink-200); border-color: var(--pink-600); color: var(--ink); }
.chip input:checked + span::before { width: 16px; margin-right: 0; opacity: 1; color: var(--pink-600); }
.chip input:focus-visible + span { outline: 3px solid var(--focus-ring); outline-offset: 3px; }
:root { --check-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E"); }

.pop { animation: pop .28s var(--ease); }
@keyframes pop { 0% { transform: scale(1); } 45% { transform: scale(1.035); } 100% { transform: scale(1); } }

/* ---------- campi ---------- */
.field { margin: 0 0 20px; }
.field__label { display: block; margin-bottom: 8px; }
.field__label .opt { font-weight: 600; color: var(--ink-soft); font-size: .88rem; }
.input {
  width: 100%; min-height: 52px; padding: 12px 16px;
  border: 1.5px solid var(--line-strong); border-radius: var(--radius-field);
  background: var(--bg); font-size: 1.02rem;
  transition: border-color .2s, box-shadow .2s;
}
.input::placeholder { color: var(--placeholder); opacity: 1; }
.input:hover { border-color: var(--ink-soft); }
.input:focus { outline: none; border-color: var(--focus-ring); box-shadow: 0 0 0 3px rgba(74, 122, 163, .28); }
.input[aria-invalid="true"] { border-color: var(--pink-600); }
textarea.input { resize: none; overflow: hidden; line-height: 1.45; min-height: 84px; }
.reveal { margin-top: 12px; animation: reveal .25s var(--ease); }
@keyframes reveal { from { opacity: 0; transform: translateY(-6px); } }

.error {
  display: flex; align-items: flex-start; gap: 6px;
  margin: 8px 0 0; color: var(--pink-600); font-size: .92rem; font-weight: 600;
}
.error:empty { display: none; }
.error svg { flex: none; width: 18px; height: 18px; margin-top: 2px; }

.consent { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; cursor: pointer; font-size: .94rem; }
.consent input { width: 24px; height: 24px; margin: 2px 0 0; accent-color: var(--pink-600); cursor: pointer; }
.consent-wrap { padding: 14px; border-radius: var(--radius-field); background: var(--bg-soft); }

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

/* ---------- barra inferiore (zona del pollice) ---------- */
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 72%, rgba(255, 255, 255, 0));
}
.bottombar__inner { max-width: 520px; margin: 0 auto; }
.app--with-bar .screen { padding-bottom: 130px; }
.cta {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 56px; padding: 14px 24px;
  border: 0; border-radius: 999px;
  background: var(--pink-600); color: var(--on-cta);
  font-weight: 700; font-size: 1.06rem; letter-spacing: .01em; cursor: pointer;
  box-shadow: 0 12px 24px -10px rgba(164, 70, 106, .55);
  transition: background-color .2s, transform .15s var(--ease), box-shadow .2s, opacity .2s;
}
.cta:hover { background: var(--pink-700); }
.cta:active { transform: scale(.98); }
.cta[aria-disabled="true"] { opacity: .45; box-shadow: none; cursor: not-allowed; }
.cta[aria-busy="true"] { cursor: progress; }
.cta svg { width: 20px; height: 20px; }
.cta--ghost {
  background: var(--bg); color: var(--pink-600); border: 1.5px solid var(--pink-400); box-shadow: none;
}
.cta--ghost:hover { background: var(--pink-100); }
.bar-note { margin: 8px 0 0; text-align: center; font-size: .85rem; color: var(--ink-soft); }
.bar-hint {
  margin: 0 auto 10px; padding: 8px 14px; width: fit-content; max-width: 100%;
  border-radius: 14px; background: var(--pink-100); box-shadow: var(--shadow-soft);
  text-align: center; font-size: .92rem; font-weight: 700; color: var(--pink-600);
}
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, .45); border-top-color: #fff;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* errore di invio */
.send-error {
  margin: 0 0 18px; padding: 14px 16px; border-radius: var(--radius-field);
  background: var(--pink-100); border: 1.5px solid var(--pink-400);
}
.send-error p { margin: 0 0 10px; font-weight: 600; }
.send-error .actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-small {
  display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 18px;
  border-radius: 999px; border: 1.5px solid var(--pink-600); background: var(--bg);
  color: var(--pink-600); font-weight: 700; text-decoration: none; cursor: pointer;
}
.btn-small svg { width: 18px; height: 18px; }

/* ---------- grazie ---------- */
.thanks { text-align: center; padding-top: 48px; }
.thanks__check { width: 96px; height: 96px; margin: 0 auto 24px; }
.thanks__check circle { fill: var(--pink-100); stroke: var(--pink-400); stroke-width: 2; }
.thanks__check path {
  fill: none; stroke: var(--pink-600); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 60; stroke-dashoffset: 60;
}
.thanks.is-in .thanks__check circle { animation: circle-in .45s var(--ease) both; transform-origin: center; }
.thanks.is-in .thanks__check path { animation: draw .5s .3s var(--ease) forwards; }
@keyframes circle-in { from { transform: scale(.6); opacity: 0; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
.thanks .lead { max-width: 32ch; margin-inline: auto; }
.thanks .cta {
  display: inline-flex; width: auto; max-width: 100%; margin: 32px auto 0; padding: 14px 20px;
  font-size: .94rem; white-space: nowrap; text-decoration: none;
}
.emergency { max-width: 36ch; margin: 36px auto 0; }

/* ---------- transizioni tra step ---------- */
.enter-fwd { animation: enter-fwd .25s var(--ease) both; }
.enter-back { animation: enter-back .25s var(--ease) both; }
@keyframes enter-fwd { from { opacity: 0; transform: translateX(12px); } }
@keyframes enter-back { from { opacity: 0; transform: translateX(-12px); } }

/* ---------- tablet e desktop: card centrata ---------- */
@media (min-width: 768px) {
  body { background: var(--bg-soft); }
  .blob { width: 560px; height: 560px; opacity: .7; }
  .blob--pink { top: 8%; left: calc(50% - 720px); }
  .blob--blue { bottom: 4%; right: calc(50% - 720px); top: auto; }
  .app {
    min-height: 0; margin: 48px auto;
    background: var(--bg); border-radius: 32px; box-shadow: var(--shadow-card);
    overflow: clip;
  }
  .topbar { padding: 14px 40px 14px 18px; }
  .progress__track { margin-left: 22px; }
  .screen { padding: 12px 40px 36px; }
  .app--with-bar .screen { padding-bottom: 12px; }
  .bottombar { position: sticky; padding: 16px 40px 32px; background: var(--bg); }
  .welcome { padding-top: 44px; }
}

/* tastiera aperta su telefoni: la barra torna nel flusso per non coprire i campi */
@media (max-height: 520px) and (max-width: 767px) {
  .bottombar { position: static; background: var(--bg); }
  .app--with-bar .screen { padding-bottom: 12px; }
}

/* dentro un iframe: niente sfondo decorativo, altezza naturale */
.is-embed body, body.is-embed { background: transparent; }
.is-embed .blob { display: none; }
.is-embed .app { margin: 0 auto; min-height: 0; box-shadow: none; }
.is-embed .bottombar { position: static; background: var(--bg); }
.is-embed .app--with-bar .screen { padding-bottom: 12px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
  .thanks__check path { stroke-dashoffset: 0; }
}
