/* ==========================================================================
   Pantoufle — /ascolto/ (questionario di ascolto famiglie)
   --------------------------------------------------------------------------
   Foglio di stile dedicato alla pagina questionario. È separato da
   assets/css/style.css perché /ascolto/ è uno strumento temporaneo di
   discovery, con un layout a colonna singola stretta che il design system
   della LP non prevede.

   Vincoli rispettati:
   - stessi token di palette di assets/css/style.css (nessun colore inventato);
   - body ≥ 18px (CLAUDE.md §7.7);
   - contrast ≥ 4.5:1 su tutti i testi;
   - supporto .high-contrast / .fs-125 / .fs-150 (stesso cookie 'a11y' del sito);
   - nessuno style="" inline nell'HTML → la CSP di /ascolto/ non ha
     'unsafe-inline' su style-src.
   ========================================================================== */

:root {
  /* Palette — allineata 1:1 a assets/css/style.css */
  --blue-50:  #F4FBFE;
  --blue-100: #E8F4FA;
  --blue-200: #CFE7F4;
  --blue-300: #A8D6EA;
  --blue-500: #5FB3E0;
  --blue-600: #4FA1CF;
  --blue-700: #2F7BAA;
  --green-100: #DEF2E5;
  --green-600: #4AA178;

  --ink-900: #0F2F44;
  --ink-700: #2C3E50;
  --ink-500: #476478;
  --ink-300: #7B8FA1;
  --ink-100: #DCE6EE;

  --bg:      #F8FCFE;
  --surface: #FFFFFF;
  --warn-bg: #FFF1EC;

  /* Ruoli locali.
     --accent: il #5FB3E0 del logo non regge testo bianco sopra (2.2:1);
     si usa il tono 700 della stessa scala → 4.8:1 su bianco.
     --warn: il #FF8E72 del sito scurito per essere leggibile come testo. */
  --accent:      var(--blue-700);
  --accent-dark: var(--ink-900);
  --accent-soft: var(--blue-100);
  --ink:         var(--ink-700);
  --muted:       var(--ink-500);
  --line:        var(--ink-100);
  --ok:          var(--green-600);
  --warn:        #C2553A;

  --radius-sm: 8px;
  --radius:    14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

/* Font-scaling: stessa meccanica di assets/css/style.css (scala il root,
   tutti i rem seguono). Classi applicate da ascolto.js leggendo il cookie. */
html { font-size: 100%; -webkit-text-size-adjust: 100%; }
html.fs-125 { font-size: 125%; }
html.fs-150 { font-size: 150%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.125rem;   /* 18px @ root 100% — minimo imposto da CLAUDE.md §7.7 */
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; height: auto; display: block; }

a { color: var(--accent); }
a:hover { text-decoration: underline; }

[hidden] { display: none !important; }

.wrap { max-width: 680px; margin: 0 auto; padding: 0 20px; }

/* ============================ Skip link ============================ */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 100;
  font-weight: 600;
}
.skip-link:focus,
.skip-link:focus-visible { left: 0; outline: 3px solid var(--blue-300); outline-offset: 2px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ============================ Focus (WCAG 2.2 AA) ============================ */

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
.opt:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* ============================ Barra brand ============================ */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar__inner {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
  padding-top: 10px;
  padding-bottom: 10px;
}
.topbar__logo img { width: 132px; height: auto; }

/* Toggle a11y — stesso cookie 'a11y' delle pagine PHP, qui pilotato da JS
   perché /ascolto/ è HTML statico e non può leggere il cookie server-side. */
.a11y-toggle { display: flex; flex-direction: row; align-items: center; gap: 6px; }
.a11y-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 22px;
  padding: 0;
  border: 1px solid var(--blue-200);
  border-radius: 6px;
  background: var(--surface);
  color: var(--accent);
  cursor: pointer;
  line-height: 0;
}
.a11y-btn--fs { width: 30px; }  /* l'icona "aA" è più larga del disco contrasto */
.a11y-btn:hover { background: var(--blue-100); }
.a11y-btn.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Lang switcher — stessi valori di assets/css/style.css (32×16, bandiera
   corrente muted e non cliccabile). Duplicati qui perché /ascolto/ non carica
   il foglio del design system: se cambiano lì, allinearli anche qui. */
.lang-switcher { display: inline-flex; flex-direction: row; align-items: center; gap: 4px; }

.lang-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 16px;
  border: 1px solid var(--ink-100);
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
  text-decoration: none;
  padding: 0;
  transition: opacity .15s, transform .15s, border-color .15s;
}
.lang-flag svg { width: 100%; height: 100%; display: block; }
.lang-flag:hover { transform: translateY(-1px); border-color: var(--blue-500); text-decoration: none; }
.lang-flag.is-current { opacity: .45; pointer-events: none; border-color: var(--accent); }

@media (max-width: 520px) {
  .lang-flag { width: 28px; height: 14px; }
}

/* ============================ Testata ============================ */

header.page-head { padding: 40px 0 8px; }
.brand {
  font-size: .85rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}
h1 {
  font-size: clamp(1.75rem, 6vw, 2.4rem);
  line-height: 1.18;
  margin: 14px 0 16px;
  letter-spacing: -.02em;
  color: var(--ink-900);
}
.lede { font-size: 1.1rem; color: var(--muted); margin: 0 0 10px; }

section { padding: 26px 0; }
h2 { font-size: 1.3rem; margin: 0 0 14px; letter-spacing: -.01em; color: var(--ink-900); }
h3 {
  font-size: .9rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--accent);
  margin: 34px 0 4px;
}

/* ============================ Blocchi ============================ */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}
.card > p:first-child { margin-top: 0; }
.card > p:last-child  { margin-bottom: 0; }

.isnot { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 0; padding: 0; list-style: none; }
.isnot li { display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start; }
.yes { color: var(--ok);   font-weight: 700; }
.no  { color: var(--warn); font-weight: 700; }

.note { font-size: .95rem; color: var(--muted); }
.note--tight { margin: 0 0 18px; }

.cta-band {
  background: var(--accent-soft);
  border: 1px solid var(--blue-200);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
}
.cta-band h2 { margin-bottom: 6px; }

/* ============================ Bottoni ============================ */

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 15px 26px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  -webkit-appearance: none;
  appearance: none;
}
.btn:hover { background: var(--accent-dark); text-decoration: none; }
.btn[disabled] { opacity: .6; cursor: progress; }
.btn-wrap { text-align: center; margin: 8px 0 0; }

/* ============================ Form ============================ */

form { margin-top: 8px; }

fieldset { border: 0; padding: 0; margin: 0 0 26px; min-width: 0; }
legend { font-weight: 650; font-size: 1rem; margin-bottom: 2px; padding: 0; }

/* I due rami (famiglia / struttura) sono <fieldset>: quando sono nascosti
   vengono anche disabilitati, così i loro campi NON finiscono nel payload.
   Senza questo, le risposte del ramo inattivo venivano inviate comunque. */
fieldset.branch { margin: 0; }

.hint { font-size: .95rem; color: var(--muted); margin: 2px 0 12px; }
.fac  { font-weight: 400; font-size: .95rem; color: var(--muted); }
.req  { color: var(--warn); }

.opts { display: grid; gap: 8px; }
.opt {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px 14px;
  cursor: pointer;
}
.opt:hover { border-color: var(--blue-300); }
.opt input { margin: 4px 0 0; flex: 0 0 auto; width: 19px; height: 19px; accent-color: var(--accent); }
.opt > span { flex: 1; }

.field { display: grid; gap: 5px; }
.field > span { font-size: .95rem; color: var(--muted); }

input[type=text],
input[type=email],
input[type=tel],
textarea {
  width: 100%;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px 14px;
}
textarea { min-height: 88px; resize: vertical; }

.privacy {
  font-size: .95rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}
.privacy p { margin: 0 0 8px; }
.privacy p:last-child { margin: 0; }
.consent-wrap { margin-top: 12px; }

/* Honeypot anti-bot: fuori viewport, mai focusabile, invisibile ai lettori
   di schermo (aria-hidden nell'HTML). Stessa convenzione del form Vesper. */
.hp-field {
  position: absolute !important;
  left: -9999px !important;
  width: 1px; height: 1px;
  overflow: hidden;
}

.err {
  color: var(--warn);
  background: var(--warn-bg);
  border: 1px solid var(--warn);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: .95rem;
  margin-top: 12px;
}

/* ============================ Footer / grazie ============================ */

.site-foot {
  padding: 34px 0 56px;
  font-size: .95rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  margin-top: 28px;
}
.site-foot p { margin: 0 0 6px; }
.site-foot p:last-child { margin: 0; }

#grazie { text-align: center; padding: 56px 0; }
#grazie h2 { font-size: 1.6rem; }

.hidden-frame { position: absolute; width: 0; height: 0; border: 0; visibility: hidden; }

.noscript-warn {
  margin: 20px 0 0;
  background: var(--warn-bg);
  border: 1px solid var(--warn);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  color: var(--warn);
  font-size: .95rem;
}

@media (min-width: 560px) {
  .isnot { grid-template-columns: 1fr 1fr; gap: 12px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ==========================================================================
   Alto contrasto (WCAG AAA) — attivato da ascolto.js via cookie 'a11y'.
   Stessi valori usati da assets/css/style.css: bianco/nero, link #0033CC,
   focus arancio 3px, niente gradienti né ombre.
   ========================================================================== */

html.high-contrast,
html.high-contrast body { background: #FFFFFF; color: #000000; }

html.high-contrast h1,
html.high-contrast h2,
html.high-contrast h3,
html.high-contrast legend { color: #000000; }

html.high-contrast a { color: #0033CC; text-decoration: underline; }
html.high-contrast a:hover { color: #001A66; }

html.high-contrast :focus-visible {
  outline: 3px solid #FF6600 !important;
  outline-offset: 3px !important;
}

html.high-contrast .topbar,
html.high-contrast .card,
html.high-contrast .opt,
html.high-contrast .privacy,
html.high-contrast input[type=text],
html.high-contrast input[type=email],
html.high-contrast input[type=tel],
html.high-contrast textarea {
  background: #FFFFFF;
  border-color: #000000;
  color: #000000;
}

html.high-contrast .topbar { border-bottom: 2px solid #000000; }
html.high-contrast .brand,
html.high-contrast h3 { color: #000000; }
html.high-contrast .note,
html.high-contrast .hint,
html.high-contrast .lede,
html.high-contrast .fac,
html.high-contrast .field > span,
html.high-contrast .privacy,
html.high-contrast .site-foot { color: #000000; }

html.high-contrast .cta-band { background: #FFFFFF; border: 2px solid #000000; }

html.high-contrast .btn,
html.high-contrast .a11y-btn.is-active {
  background: #000000;
  color: #FFFFFF;
  border: 2px solid #000000;
}
html.high-contrast .btn:hover { background: #0033CC; border-color: #0033CC; }
html.high-contrast .a11y-btn { border: 2px solid #000000; color: #000000; background: #FFFFFF; }

/* Bandiere: bordo nero, colori della bandiera preservati (sono informativi) */
html.high-contrast .lang-flag { border: 2px solid #000000; background: #FFFFFF; }
html.high-contrast .lang-flag.is-current { opacity: .5; border-color: #000000; }

html.high-contrast .yes { color: #006600; }
html.high-contrast .no,
html.high-contrast .req { color: #A30000; }

html.high-contrast .err,
html.high-contrast .noscript-warn {
  background: #FFFFFF;
  border: 2px solid #A30000;
  color: #A30000;
}

html.high-contrast .site-foot { border-top: 2px solid #000000; }
