@font-face {
  font-family: "Montserrat";
  src: url("../fonts/montserrat-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

@font-face {
  font-family: "Libre Bodoni";
  src: url("../fonts/libre-bodoni-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  color-scheme: light;

  --brand: #283991;
  --brand-strong: #1e2c74;
  --brand-tint: #eef0fa;
  --brand-ring: rgba(40, 57, 145, 0.32);

  --ink: #16132a;
  --ink-soft: #4b4a5e;
  --paper: #f6f4ef;
  --card: #ffffff;
  --line: #dcd8ce;
  --line-strong: #b9b4a7;

  --danger: #b42318;
  --danger-tint: #fdf1ef;
  --warn-tint: #fbf6e6;
  --warn-line: #e2bb50;
  --success: #1d7a46;
  --success-tint: #edf7f0;

  --font-body: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: "Libre Bodoni", Georgia, "Times New Roman", serif;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(22, 19, 42, 0.04), 0 8px 24px rgba(22, 19, 42, 0.06);

  /* Pagina d'ingresso */
  --landing-bg: linear-gradient(180deg, #2b478d 0%, #2a4375 50%, #2c425e 100%);
  --landing-accent: #3c3d72;
  --landing-accent-strong: #2e2f5c;
  --landing-accent-tint: #efeff6;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 0.5em;
  color: var(--ink);
}

h1 {
  font-size: clamp(2rem, 1.4rem + 2.6vw, 2.9rem);
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.5rem;
}

h3 {
  font-size: 1.2rem;
}

p {
  margin: 0 0 1em;
}

a {
  color: var(--brand);
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--brand-strong);
}

:focus-visible {
  outline: 3px solid var(--brand-ring);
  outline-offset: 2px;
}

[tabindex="-1"]:focus {
  outline: none;
}

.container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 0 16px;
}

.muted {
  color: var(--ink-soft);
  font-size: 0.875rem;
}

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

/* Intestazione dei passi */

.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 68px;
}

.brand {
  display: block;
  flex: none;
}

.brand img {
  display: block;
  width: 232px;
  height: auto;
}

.site-header__tag {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-align: right;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main.container {
  flex: 1 0 auto;
  padding-top: 2.5rem;
  padding-bottom: 4rem;
}

/* Ingresso: presentazione a sinistra, azioni nel pannello bianco a destra */

.landing {
  display: grid;
  grid-template-columns: minmax(0, 59fr) minmax(0, 41fr);
  grid-template-rows: 1fr auto;
  grid-template-areas:
    "intro panel"
    "facts panel";
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--landing-bg);
  color: #fff;
}

.landing :focus-visible {
  outline-color: #fff;
}

.landing__intro {
  grid-area: intro;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 3rem;
  padding: 72px 56px 0;
}

.landing__logo {
  align-self: flex-start;
}

.landing__logo img {
  display: block;
  width: 382px;
  max-width: 100%;
  height: auto;
}

.landing h1 {
  margin: 0 0 0.6rem;
  font-size: clamp(2rem, 1.2rem + 2vw, 3.25rem);
  line-height: 1.15;
  text-wrap: balance;
  color: #fff;
}

.landing__lead {
  max-width: 50rem;
  margin: 0;
  font-size: clamp(1.0625rem, 0.95rem + 0.45vw, 1.375rem);
  line-height: 1.35;
}

.facts {
  grid-area: facts;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2.25rem;
  margin: 2.5rem 56px 72px;
  padding: 0;
  list-style: none;
}

.facts li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

.facts__icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
}

.facts__icon svg {
  width: 22px;
  height: 22px;
}

.landing__panel {
  grid-area: panel;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 10px 10px 10px 0;
  padding: 2rem 2rem 1.75rem;
  background: var(--card);
  border-radius: 16px;
  color: var(--ink);
}

.landing__actions {
  width: 100%;
  max-width: 370px;
  margin: auto 0;
  text-align: center;
}

.landing__label {
  margin-bottom: 2.5rem;
  font-size: 0.9375rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.landing__privacy {
  margin-top: 0.9rem;
}

.consent {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.9375rem;
  color: var(--ink-soft);
  cursor: pointer;
}

.consent input {
  flex: none;
  width: 1.05rem;
  height: 1.05rem;
  margin: 0;
  accent-color: var(--landing-accent);
}

.consent a {
  color: inherit;
}

.consent a:hover {
  color: var(--landing-accent);
}

.landing__privacy .field-error {
  font-size: 0.8125rem;
}

.landing .btn {
  min-height: 48px;
  border-radius: 8px;
}

.landing__panel .btn--primary {
  background: var(--landing-accent);
}

.landing__panel .btn--primary:hover {
  background: var(--landing-accent-strong);
}

.landing__panel :focus-visible {
  outline-color: var(--brand-ring);
}

/* Dichiarazioni: finestra modale con JavaScript, sezione prima del modulo senza */

.disclaimer {
  width: min(720px, calc(100% - 32px));
  max-height: min(85vh, 760px);
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 24px 64px rgba(22, 19, 42, 0.35);
}

.disclaimer[open] {
  display: flex;
}

.disclaimer::backdrop {
  background: rgba(22, 19, 42, 0.6);
}

.disclaimer__inner {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.disclaimer h2 {
  margin: 0;
  padding: 1.5rem 1.75rem 1rem;
  border-bottom: 1px solid var(--line);
}

.disclaimer__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 1.25rem 1.75rem 0.25rem;
  font-size: 0.9375rem;
}

.disclaimer__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.75rem 1.5rem;
  border-top: 1px solid var(--line);
}

.disclaimer__nojs {
  margin: 0;
  padding: 1rem 1.75rem 1.5rem;
  border-top: 1px solid var(--line);
  font-weight: 600;
}

.disclaimer__pdf {
  padding: 0.75rem 1rem;
  background: var(--brand-tint);
  border-radius: var(--radius-sm);
  font-weight: 600;
}

/* Avanzamento */

.progress {
  margin-bottom: 1.5rem;
}

.progress__label {
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.progress__steps {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: passo;
}

.progress__steps li {
  padding-top: 0.6rem;
  border-top: 4px solid var(--line);
  font-size: 0.8125rem;
  line-height: 1.3;
  color: var(--ink-soft);
}

.progress__steps li.is-done {
  border-top-color: var(--brand);
}

.progress__steps li.is-current {
  border-top-color: var(--brand);
  color: var(--ink);
  font-weight: 700;
}

/* Passi e domande */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
}

.step + .step {
  margin-top: 1.5rem;
}

.step__title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.step__num {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 700;
}

.q {
  margin: 0 0 1.75rem;
  padding: 0;
  border: 0;
  min-width: 0;
}

.q:last-child {
  margin-bottom: 0;
}

.q-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 1.25rem;
}

.q__label {
  display: block;
  margin-bottom: 0.35rem;
  padding: 0;
  font-weight: 600;
  line-height: 1.4;
}

.q__hint {
  margin: 0 0 0.6rem;
  font-size: 0.875rem;
  color: var(--ink-soft);
}

.q__hint--after {
  margin: 0.5rem 0 0 2.25rem;
}

.opt {
  margin-left: 0.25rem;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  white-space: nowrap;
}

/* Pallino dei campi obbligatori; il testo "obbligatorio" resta per i lettori di schermo. */
.req {
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  margin-left: 0.35rem;
  border-radius: 50%;
  background: var(--danger);
  vertical-align: 0.15em;
}

input[type="text"],
input[type="email"],
input[type="tel"],
textarea {
  display: block;
  width: 100%;
  padding: 0.7rem 0.85rem;
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea {
  min-height: 7rem;
  resize: vertical;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}

.has-error input[type="text"],
.has-error input[type="email"],
.has-error input[type="tel"],
.has-error textarea {
  border-color: var(--danger);
}

.field-error {
  margin: 0.4rem 0 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--danger);
}

.choices {
  display: grid;
  gap: 0.5rem;
}

.choices--inline {
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.8rem 1rem;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  line-height: 1.45;
  transition: border-color 0.15s, background-color 0.15s;
}

.choice:hover {
  border-color: var(--brand);
}

.choice input {
  flex: none;
  width: 1.15rem;
  height: 1.15rem;
  margin: 0.15rem 0 0;
  accent-color: var(--brand);
}

.choice:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-tint);
}

.choice:has(input:focus-visible) {
  box-shadow: 0 0 0 3px var(--brand-ring);
}

.choice--check {
  border: 0;
  padding: 0;
  background: none;
}

.choice--check:has(input:checked) {
  background: none;
}

.has-error .choice {
  border-color: var(--danger);
}

.cond {
  margin-bottom: 1.75rem;
  padding-left: 1rem;
  border-left: 3px solid var(--brand-tint);
}

.cond > .q:last-child {
  margin-bottom: 0;
}

/* Allegati */

.dropzone {
  position: relative;
  padding: 1.25rem;
  background: var(--paper);
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  text-align: center;
  transition: border-color 0.15s, background-color 0.15s;
}

.js .dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.dropzone:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}

.dropzone.is-over {
  border-color: var(--brand);
  background: var(--brand-tint);
}

.dropzone__text {
  margin: 0;
  font-weight: 600;
}

.link-like {
  color: var(--brand);
  text-decoration: underline;
}

.files {
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
}

.files li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
}

.files li + li {
  margin-top: 0.4rem;
}

.files__name {
  overflow-wrap: anywhere;
}

.files__size {
  color: var(--ink-soft);
  white-space: nowrap;
}

.files button {
  flex: none;
}

/* Riepilogo */

.review {
  margin: 0 0 1.75rem;
  padding: 1.5rem;
  background: var(--paper);
  border-radius: var(--radius);
}

.review__section + .review__section {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.review__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.review__head h4 {
  margin: 0;
  font-size: 1rem;
}

.review dl {
  margin: 0;
}

.review dt {
  margin-top: 0.6rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.review dd {
  margin: 0.1rem 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Bottoni */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.6rem 1.25rem;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.btn--primary {
  background: var(--brand);
  color: #fff;
}

.btn--primary:hover {
  background: var(--brand-strong);
  color: #fff;
}

.btn--ghost {
  background: transparent;
  border-color: var(--brand);
  color: var(--brand);
}

.btn--ghost:hover {
  background: var(--brand-tint);
  color: var(--brand-strong);
}

.btn--lg {
  min-height: 52px;
  padding: 0.8rem 1.75rem;
  font-size: 1.0625rem;
}

.btn--small {
  min-height: 32px;
  padding: 0.3rem 0.8rem;
  font-size: 0.875rem;
}

.btn--link {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.btn--block {
  display: flex;
  width: 100%;
}

.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.actions,
.step-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.step-nav {
  justify-content: space-between;
  margin-top: 1.5rem;
}

.step-nav [data-action="next"] {
  margin-left: auto;
}

.actions--final {
  margin-top: 1.5rem;
}

/* Invio, errori, esito */

.send-status {
  margin-top: 1.25rem;
}

.send-status p {
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.send-status progress {
  width: 100%;
  height: 10px;
  accent-color: var(--brand);
}

.send-error,
.error-summary {
  margin: 1.25rem 0 0;
  padding: 1rem 1.25rem;
  background: var(--danger-tint);
  border-left: 4px solid var(--danger);
  border-radius: var(--radius-sm);
}

.error-summary {
  margin: 0 0 1.5rem;
}

.error-summary h2 {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  color: var(--danger);
}

.error-summary ul,
.send-error ul {
  margin: 0;
  padding-left: 1.25rem;
}

.error-summary a {
  color: var(--danger);
  font-weight: 600;
}

.send-error p:last-child {
  margin-bottom: 0;
}

.back-hint {
  margin-top: 1.25rem;
}

.result h2 {
  margin-top: 2rem;
  font-size: 1.25rem;
}

.success {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding: 1rem 1.25rem;
  background: var(--success-tint);
  border-left: 4px solid var(--success);
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.success__icon {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  color: var(--success);
}

.success p {
  margin: 0;
}

/* Campo esca anti-spam */

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

/* Con JavaScript: prima l'ingresso, poi un passo alla volta */

.js .nojs-only,
.js .nojs-note {
  display: none;
}

.js:not(.in-wizard) .site-header,
.js:not(.in-wizard) #contenuto,
.js.in-wizard .landing {
  display: none;
}

.js .report-form .step:not(.is-active) {
  display: none;
}

.js .report-form .step + .step {
  margin-top: 0;
}

/* Senza JavaScript: tutto il modulo in un'unica pagina */

html:not(.js) .js-only {
  display: none !important;
}

.nojs-note {
  margin-bottom: 2rem;
  padding: 1rem 1.25rem;
  background: var(--warn-tint);
  border-left: 4px solid var(--warn-line);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
}

/* Il logo è già nell'ingresso: l'intestazione serve solo ai passi. */
html:not(.js) .landing ~ .site-header {
  display: none;
}

/* Le dichiarazioni compaiono solo dal link "informativa della privacy" (#dichiarazioni). */
html:not(.js) .disclaimer {
  position: static;
  width: calc(100% - 32px);
  max-width: 768px;
  max-height: none;
  margin: 2.5rem auto 0;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

html:not(.js) .disclaimer:target {
  display: block;
}

html:not(.js) .disclaimer__body {
  max-height: 22rem;
}

/* Senza JavaScript i campi condizionali si mostrano via CSS dove :has() è supportato;
   nei browser più vecchi restano tutti visibili e la Function ignora quelli non pertinenti. */
@supports selector(:has(*)) {
  html:not(.js) [data-show-if] {
    display: none;
  }

  html:not(.js) form:has(input[name="prove"][value="si"]:checked) [data-show-if="prove=si"],
  html:not(.js) form:has(input[name="altri_soggetti"][value="si"]:checked) [data-show-if="altri_soggetti=si"],
  html:not(.js) form:has(input[name="identita"][value="si"]:checked) [data-show-if="identita=si"],
  html:not(.js) form:has(input[name="contatto"][value="email"]:checked) [data-show-if="contatto=email"],
  html:not(.js) form:has(input[name="contatto"][value="telefono"]:checked) [data-show-if="contatto=telefono"],
  html:not(.js) form:has(input[name="contatto"][value="altro"]:checked) [data-show-if="contatto=altro"] {
    display: block;
  }
}

/* Schermi medi: i tre punti dell'ingresso restano su una riga, più compatti, poi vanno in colonna */

@media (max-width: 1399px) {
  .facts {
    column-gap: 1.5rem;
  }

  .facts li {
    gap: 0.6rem;
    font-size: 0.9375rem;
  }

  .facts__icon {
    width: 36px;
    height: 36px;
  }

  .facts__icon svg {
    width: 19px;
    height: 19px;
  }
}

@media (max-width: 1239px) {
  .facts {
    flex-direction: column;
  }
}

/* Schermi bassi: meno spazio intorno ai testi dell'ingresso */

@media (max-height: 820px) and (min-width: 901px) {
  .landing__intro {
    padding-top: 40px;
  }

  .facts {
    margin-top: 2rem;
    margin-bottom: 40px;
  }
}

/* Tablet e telefono: l'ingresso diventa una colonna, con le azioni subito dopo il titolo */

@media (max-width: 900px) {
  .landing {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas:
      "intro"
      "panel"
      "facts";
  }

  .landing__intro {
    gap: 2.5rem;
    padding: 32px 24px 0;
  }

  .landing__panel {
    margin: 2rem 16px 0;
    padding: 1.75rem 1.25rem 1.25rem;
  }

  .landing__label {
    margin-bottom: 1.5rem;
  }

  .facts {
    flex-direction: column;
    margin: 2.5rem 24px 40px;
  }
}

/* Telefono */

@media (max-width: 720px) {
  main.container {
    padding-top: 1.5rem;
  }

  .landing__logo img {
    width: 260px;
  }

  .disclaimer h2 {
    padding: 1.25rem 1.25rem 0.85rem;
    font-size: 1.3rem;
  }

  .disclaimer__body,
  .disclaimer__actions,
  .disclaimer__nojs {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }

  .disclaimer__actions .btn {
    flex: 1 1 auto;
  }

  .card {
    padding: 1.25rem;
  }

  .q-row {
    grid-template-columns: 1fr;
  }

  .progress__steps li {
    font-size: 0;
  }

  .progress__steps li.is-current {
    font-size: 0;
  }

  .site-header__tag {
    font-size: 0.6875rem;
  }

  .brand img {
    width: 174px;
  }

  .step-nav .btn,
  .actions--final .btn {
    flex: 1 1 auto;
  }
}

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