/* Base: caratteri, token, tipografia, bottoni, campi, micro-interazioni */

@font-face {
  font-family: "Newsreader";
  src: url("../fonts/newsreader-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 200 800;
  font-style: normal;
  font-display: fallback;
}
@font-face {
  font-family: "Figtree";
  src: url("../fonts/figtree-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 300 900;
  font-style: normal;
  font-display: fallback;
}

:root {
  color-scheme: light;
  --verde-bosco: #004f2d;
  --verde-bosco-2: #0a6a3f;
  --verde-sirio: #009640;
  --salvia: #80bc99;
  --menta: #d9eddc;
  --menta-2: #eef6ef;
  --carta: #f6f7f4;
  --bianco: #ffffff;
  --grafite: #2f3b3d;
  --grafite-2: #4f5d5f;
  --linea: #dde3dc;
  --errore: #b3261e;
  --oro: #f8c05a;

  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Figtree", "Segoe UI", system-ui, -apple-system, sans-serif;

  --t-xs: 0.875rem;   /* 14 px: il pavimento */
  --t-s: 0.9375rem;
  --t-m: 1.0625rem;   /* testo */
  --t-l: 1.25rem;
  --t-xl: clamp(1.5rem, 1.1rem + 1.6vw, 2rem);
  --t-2xl: clamp(1.875rem, 1.2rem + 2.8vw, 2.75rem);
  --t-3xl: clamp(2.375rem, 1.3rem + 4.6vw, 4.25rem);

  --r-card: 16px;
  --r-campo: 12px;
  --ombra-1: 0 1px 2px rgba(0, 40, 20, .06), 0 2px 8px rgba(0, 40, 20, .05);
  --ombra-2: 0 6px 18px rgba(0, 40, 20, .10), 0 18px 40px rgba(0, 40, 20, .08);
  --larghezza: 1240px;
  --gutter: clamp(16px, 4vw, 40px);
  --testata: 72px;
  --curva: cubic-bezier(.2, .7, .2, 1);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--testata) + 16px);
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--carta);
  color: var(--grafite);
  font-family: var(--sans);
  font-size: var(--t-m);
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; }
img { height: auto; }

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 560;
  line-height: 1.12;
  letter-spacing: -0.01em;
  margin: 0 0 .5em;
  color: var(--verde-bosco);
  text-wrap: balance;
}
h1 { font-size: var(--t-3xl); }
h2 { font-size: var(--t-2xl); }
h3 { font-size: var(--t-xl); }
h4 { font-size: var(--t-l); }
p { margin: 0 0 1em; text-wrap: pretty; }
small, .piccolo { font-size: var(--t-xs); }

a {
  color: var(--verde-bosco);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--verde-sirio);
  outline-offset: 3px;
  border-radius: 6px;
}

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

.salta {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--verde-bosco); color: #fff;
  padding: 12px 18px; border-radius: 999px;
}
.salta:focus { top: 12px; }

.contenitore {
  width: 100%;
  max-width: calc(var(--larghezza) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.fascia { padding: clamp(56px, 8vw, 112px) 0; }
.fascia--menta { background: var(--menta); }
.fascia--bianca { background: var(--bianco); }
.fascia--bosco { background: var(--verde-bosco); color: #fff; }
.fascia--bosco h2, .fascia--bosco h3 { color: #fff; }

.occhiello {
  display: inline-block;
  font-family: var(--sans);
  font-size: var(--t-xs);
  font-weight: 650;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--verde-bosco-2);
  margin-bottom: 12px;
}
.fascia--bosco .occhiello { color: var(--menta); }

.intro { font-size: var(--t-l); color: var(--grafite-2); max-width: 46ch; }
.fascia--bosco .intro { color: #e4f1e7; }

/* Bottoni: pillola come l'originale, 48 px */
.bottone {
  --b-fondo: var(--verde-bosco);
  --b-testo: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 12px 26px;
  border: 1.5px solid var(--b-fondo);
  border-radius: 999px;
  background: var(--b-fondo);
  color: var(--b-testo);
  font: 600 var(--t-m)/1.2 var(--sans);
  text-decoration: none;
  cursor: pointer;
  transition: transform .15s var(--curva), box-shadow .2s, background-color .2s, color .2s;
  -webkit-tap-highlight-color: transparent;
}
.bottone:active { transform: scale(.97); }
.bottone--chiaro { --b-fondo: #fff; --b-testo: var(--verde-bosco); }
.bottone--contorno { background: transparent; color: var(--verde-bosco); }
.bottone--contorno-chiaro { background: transparent; color: #fff; border-color: rgba(255,255,255,.7); }
.bottone--piccolo { min-height: 44px; padding: 10px 18px; font-size: var(--t-s); }
.bottone--largo { width: 100%; }
.bottone svg { width: 20px; height: 20px; flex: none; }
.bottone[disabled], .bottone[aria-busy="true"] { cursor: progress; opacity: .85; }
.bottone.esito-ok { --b-fondo: var(--verde-bosco-2); }
.bottone.esito-ko { --b-fondo: var(--errore); }

@media (hover: hover) and (pointer: fine) {
  .bottone:hover { box-shadow: var(--ombra-2); transform: translateY(-1px); }
  .bottone--contorno:hover { background: var(--verde-bosco); color: #fff; }
  .bottone--contorno-chiaro:hover { background: #fff; color: var(--verde-bosco); }
}

/* Link con freccia: interni → , esterni ↗ */
.freccia {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px;
  font-weight: 600; text-decoration: none;
}
.freccia::after { content: "→"; transition: transform .2s var(--curva); }
.freccia[target="_blank"]::after { content: "↗"; }
@media (hover: hover) and (pointer: fine) {
  .freccia:hover::after { transform: translateX(4px); }
  .freccia[target="_blank"]:hover::after { transform: translate(2px, -2px); }
}

/* Campi */
.campo { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.campo label, .campo .etichetta { font-size: var(--t-s); font-weight: 600; color: var(--grafite); }
.campo .aiuto { font-size: var(--t-xs); color: var(--grafite-2); }
.campo input, .campo select, .campo textarea {
  font: inherit;
  font-size: var(--t-m);
  color: var(--grafite);
  background: #fff;
  min-height: 48px;
  padding: 11px 14px;
  border: 1.5px solid #c9d2c8;
  border-radius: var(--r-campo);
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.campo textarea { min-height: 120px; resize: vertical; }
.campo select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%23004f2d' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}
.campo input:focus, .campo select:focus, .campo textarea:focus {
  outline: none;
  border-color: var(--verde-bosco);
  box-shadow: 0 0 0 4px rgba(0, 150, 64, .18);
}
.campo [aria-invalid="true"] { border-color: var(--errore); }
.errore { color: var(--errore); font-size: var(--t-xs); font-weight: 600; margin: 4px 0 0; }
.campi-2 { display: grid; gap: 0 16px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .campi-2 { grid-template-columns: 1fr 1fr; } }

/* Casella di spunta: il bersaglio e' tutta l'etichetta */
.spunta {
  position: relative;
  display: flex; align-items: flex-start; gap: 12px;
  min-height: 44px;
  padding: 10px 0;
  font-size: var(--t-s);
  cursor: pointer;
}
.spunta input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.spunta .casella {
  flex: none;
  width: 22px; height: 22px; margin-top: 1px;
  border: 1.5px solid #9fb0a2; border-radius: 6px; background: #fff;
  display: grid; place-items: center;
  transition: background-color .15s, border-color .15s;
}
.spunta .casella::after {
  content: ""; width: 10px; height: 6px;
  border: 2px solid #fff; border-top: 0; border-right: 0;
  transform: rotate(-45deg) translate(1px, -1px) scale(0);
  transition: transform .15s var(--curva);
}
.spunta input:checked + .casella { background: var(--verde-bosco); border-color: var(--verde-bosco); }
.spunta input:checked + .casella::after { transform: rotate(-45deg) translate(1px, -1px) scale(1); }
.spunta input:focus-visible + .casella { outline: 3px solid var(--verde-sirio); outline-offset: 2px; }
.spunta input[aria-invalid="true"] + .casella { border-color: var(--errore); }
.documenti { display: flex; flex-wrap: wrap; gap: 0 20px; margin-top: -4px; }
.documenti a { display: inline-flex; align-items: center; min-height: 44px; font-size: var(--t-s); }

/* Esca per i robot: fuori dallo schermo, non hidden (alcuni robot saltano i campi hidden) */
.esca { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Comparse morbide: lo stato senza JS e' quello finale */
@media (prefers-reduced-motion: no-preference) {
  .js .compare { opacity: 0; transform: translateY(18px); transition: opacity .7s var(--curva), transform .7s var(--curva); transition-delay: var(--ritardo, 0ms); }
  .js .compare.visto { opacity: 1; transform: none; }
}

/* Quadrifoglio: rotella d'attesa */
.attesa { width: 22px; height: 22px; flex: none; }
@media (prefers-reduced-motion: no-preference) {
  .attesa { animation: gira 1.1s linear infinite; }
}
@keyframes gira { to { transform: rotate(360deg); } }

@media print {
  .noprint, .testata, .piede, .barra-mobile { display: none !important; }
  body { background: #fff; }
}
