/* Portale documenti Effepi — stile condiviso.
   Palette "carta e inchiostro" del sito, con l'impostazione delle app Apple: superfici chiare a strati,
   materiali sfocati per le barre, controlli grandi (44 px), molle al posto delle curve fisse.
   Font: Playfair variabile (SIL OFL), lo stesso del sito, ospitato qui: nessuna richiesta a terzi. */

@font-face {
  font-family: 'Playfair';
  font-style: normal;
  font-weight: 400 700;
  font-stretch: 100%;
  font-display: swap;
  src: url(fonts/playfair-latin.woff2) format('woff2');
}

:root {
  --carta: #f6f1e8;
  --carta-2: #efe8da;
  --carta-3: #e4d9c5;
  --superficie: #fffdf9;
  --superficie-2: #faf6ef;
  --inchiostro: #12263f;
  --inchiostro-2: #1e3a5f;
  --inchiostro-3: #0b1a2c;
  --testo: #1f2a37;
  --testo-2: #586374;
  --testo-3: #8a929e;
  --linea: rgba(18, 38, 63, .1);
  --linea-forte: rgba(18, 38, 63, .18);
  --timbro: #b8452d;
  --timbro-scuro: #973520;
  --timbro-chiaro: #f7e4dd;
  --ottone: #8a6526;
  --ottone-chiaro: #f6ebd3;
  --verde: #2f6f55;
  --verde-chiaro: #dcebe3;
  --blu-chiaro: #e4ebf4;

  --font: 'Playfair', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --raggio: 20px;
  --raggio-m: 14px;
  --raggio-s: 10px;
  --ombra-1: 0 1px 2px rgba(18, 38, 63, .05);
  --ombra-2: 0 1px 2px rgba(18, 38, 63, .05), 0 12px 32px -12px rgba(18, 38, 63, .16);
  --ombra-3: 0 2px 8px rgba(18, 38, 63, .08), 0 32px 64px -16px rgba(18, 38, 63, .3);
  --anello: 0 0 0 4px rgba(30, 58, 95, .16);
  --materiale: rgba(246, 241, 232, .74);

  /* Riscritte da movimento.js con le molle calcolate (linear()). */
  --molla: cubic-bezier(.34, 1.3, .64, 1);
  --molla-durata: 380ms;
  --molla-elastica: cubic-bezier(.34, 1.56, .64, 1);
  --molla-elastica-durata: 600ms;
  --uscita: cubic-bezier(.22, 1, .36, 1);
}

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

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--carta);
  color: var(--testo);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
  font-optical-sizing: auto;
  font-variant-numeric: lining-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--inchiostro-2); text-underline-offset: .2em; }
h1, h2, h3, h4 { margin: 0; color: var(--inchiostro); line-height: 1.2; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--inchiostro-2); outline-offset: 2px; border-radius: 6px; }

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

.visivamente-nascosto {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.i {
  width: 1.25em; height: 1.25em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}

.mono { font-variant-numeric: tabular-nums lining-nums; letter-spacing: .01em; }

/* ---------- Tipografia ---------- */

.titolo-grande { font-size: clamp(1.9rem, 1.4rem + 1.6vw, 2.5rem); font-weight: 650; letter-spacing: -.02em; }
.titolo { font-size: 1.35rem; font-weight: 620; }
.sottotitolo { font-size: 1.05rem; color: var(--testo-2); }
.occhiello {
  font-size: .76rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--testo-3);
}
.tenue { color: var(--testo-2); }
.piccolo { font-size: .875rem; }

/* ---------- Pulsanti ---------- */

.pulsante {
  --sfondo: var(--inchiostro);
  --colore: #fff;
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 46px; padding: 0 20px;
  border: 0; border-radius: var(--raggio-m);
  background: var(--sfondo); color: var(--colore);
  font-weight: 600; font-size: 1rem; text-decoration: none; white-space: nowrap;
  cursor: pointer;
  transition: transform var(--molla-durata) var(--molla), background-color .2s, box-shadow .2s, opacity .2s;
  box-shadow: 0 1px 1px rgba(11, 26, 44, .2), inset 0 1px 0 rgba(255, 255, 255, .08);
}
.pulsante:hover { --sfondo: var(--inchiostro-2); }
.pulsante:active:not(:disabled) { transform: scale(.965); transition-duration: 90ms; transition-timing-function: ease-out; }
.pulsante:disabled { opacity: .45; cursor: not-allowed; }
.pulsante--largo { width: 100%; }
.pulsante--grande { min-height: 52px; padding: 0 26px; font-size: 1.05rem; border-radius: 16px; }
.pulsante--piccolo { min-height: 36px; padding: 0 14px; font-size: .9rem; border-radius: 11px; }
.pulsante--secondario { --sfondo: var(--superficie); --colore: var(--inchiostro); box-shadow: inset 0 0 0 1px var(--linea-forte); }
.pulsante--secondario:hover { --sfondo: var(--superficie-2); }
.pulsante--tenue { --sfondo: rgba(18, 38, 63, .07); --colore: var(--inchiostro); box-shadow: none; }
.pulsante--tenue:hover { --sfondo: rgba(18, 38, 63, .11); }
.pulsante--pericolo { --sfondo: var(--timbro-chiaro); --colore: var(--timbro-scuro); box-shadow: none; }
.pulsante--pericolo:hover { --sfondo: #f2d4ca; }
.pulsante--verde { --sfondo: var(--verde); }
.pulsante--verde:hover { --sfondo: #285f49; }
.pulsante--icona { width: 40px; min-height: 40px; padding: 0; border-radius: 12px; }
.pulsante .i { width: 1.15em; height: 1.15em; }

.pulsante.is-occupato { pointer-events: none; }
.pulsante__rotella {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; opacity: .8;
  animation: gira .7s linear infinite;
}
@keyframes gira { to { transform: rotate(360deg); } }

.collegamento {
  display: inline-flex; align-items: center; gap: .35em; padding: 0; border: 0; background: none;
  color: var(--inchiostro-2); font-weight: 600; cursor: pointer; text-decoration: none;
}
.collegamento:hover { text-decoration: underline; }

/* ---------- Campi ---------- */

.campo { display: grid; gap: 6px; }
.campo__etichetta { font-size: .9rem; font-weight: 600; color: var(--inchiostro); }
.campo__input, .campo select, .campo textarea {
  width: 100%; min-height: 48px; padding: 11px 14px;
  border: 1px solid var(--linea-forte); border-radius: var(--raggio-m);
  background: var(--superficie); color: var(--testo);
  font-size: 1rem;
  transition: border-color .2s, box-shadow .25s var(--uscita), background-color .2s;
}
.campo textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.campo select { appearance: none; padding-right: 40px; background-image: linear-gradient(45deg, transparent 50%, var(--testo-2) 50%), linear-gradient(135deg, var(--testo-2) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.campo__input:hover, .campo select:hover, .campo textarea:hover { border-color: rgba(18, 38, 63, .3); }
.campo__input:focus, .campo select:focus, .campo textarea:focus { outline: none; border-color: var(--inchiostro-2); box-shadow: var(--anello); }
.campo__input::placeholder, .campo textarea::placeholder { color: var(--testo-3); }
.campo__aiuto { font-size: .84rem; color: var(--testo-2); }
.campo__errore { font-size: .86rem; color: var(--timbro-scuro); }
.campo--errore .campo__input { border-color: var(--timbro); }

.riga-campi { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .riga-campi { grid-template-columns: 1fr; } }

.spunta-campo { display: flex; gap: 12px; align-items: flex-start; font-size: .92rem; color: var(--testo-2); cursor: pointer; }
.spunta-campo input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--inchiostro); flex: none; }

/* Interruttore (come UISwitch) */
.interruttore { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: .9rem; color: var(--testo-2); }
.interruttore input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.interruttore__binario {
  position: relative; width: 44px; height: 26px; border-radius: 13px; background: rgba(18, 38, 63, .16);
  transition: background-color .25s; flex: none;
}
.interruttore__binario::after {
  content: ''; position: absolute; left: 2px; top: 2px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .18), 0 0 1px rgba(0, 0, 0, .2);
  transition: transform var(--molla-durata) var(--molla);
}
.interruttore input:checked + .interruttore__binario { background: var(--verde); }
.interruttore input:checked + .interruttore__binario::after { transform: translateX(18px); }
.interruttore input:focus-visible + .interruttore__binario { box-shadow: var(--anello); }

/* ---------- Controllo segmentato ---------- */

.segmentato {
  position: relative; display: inline-flex; padding: 3px; gap: 2px;
  border-radius: 13px; background: rgba(18, 38, 63, .07);
  max-width: 100%; overflow-x: auto; scrollbar-width: none;
}
.segmentato::-webkit-scrollbar { display: none; }
.segmentato__cursore {
  position: absolute; left: 0; top: 3px; bottom: 3px; width: 0;
  border-radius: 10px; background: var(--superficie);
  box-shadow: 0 1px 2px rgba(18, 38, 63, .12), 0 3px 8px rgba(18, 38, 63, .08);
}
.segmentato__voce {
  position: relative; z-index: 1;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 16px; border: 0; border-radius: 10px; background: none;
  color: var(--testo-2); font-weight: 600; font-size: .93rem; white-space: nowrap; cursor: pointer;
  transition: color .2s;
}
.segmentato__voce[aria-selected='true'] { color: var(--inchiostro); }
.segmentato__conteggio {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--timbro); color: #fff; font-size: .74rem; line-height: 20px; text-align: center;
  font-variant-numeric: tabular-nums;
}
.segmentato--largo { display: flex; width: 100%; }
.segmentato--largo .segmentato__voce { flex: 1; justify-content: center; }

/* ---------- Schede, stati, elenchi ---------- */

.scheda {
  background: var(--superficie);
  border-radius: var(--raggio);
  box-shadow: var(--ombra-2), inset 0 0 0 1px var(--linea);
}
.scheda--imbottita { padding: clamp(18px, 3vw, 28px); }

.stato {
  display: inline-flex; align-items: center; gap: 7px;
  height: 26px; padding: 0 11px; border-radius: 13px;
  font-size: .8rem; font-weight: 600; white-space: nowrap;
  background: rgba(18, 38, 63, .07); color: var(--inchiostro-2);
}
.stato__punto { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.stato--attesa { background: var(--ottone-chiaro); color: var(--ottone); }
.stato--verifica { background: var(--blu-chiaro); color: var(--inchiostro-2); }
.stato--ok { background: var(--verde-chiaro); color: var(--verde); }
.stato--integrare { background: var(--timbro-chiaro); color: var(--timbro-scuro); }
.stato--neutro { background: rgba(18, 38, 63, .06); color: var(--testo-2); }
.stato--attesa .stato__punto { animation: respiro 2.4s ease-in-out infinite; }
@keyframes respiro { 50% { opacity: .35; } }

.vuoto {
  display: grid; justify-items: center; gap: 10px; padding: 48px 20px; text-align: center; color: var(--testo-2);
}
.vuoto__icona {
  display: grid; place-items: center; width: 64px; height: 64px; border-radius: 20px;
  background: rgba(18, 38, 63, .06); color: var(--inchiostro-2);
}
.vuoto__icona .i { width: 30px; height: 30px; stroke-width: 1.4; }
.vuoto h3 { font-size: 1.15rem; }

.da-confermare {
  display: inline-flex; align-items: center; padding: 1px 9px; border-radius: 999px;
  background: #fbf3df; border: 1px dashed #d8bd78; color: #6b5320;
  font-size: .68rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; vertical-align: middle;
}

.nota-sicurezza { display: flex; gap: 10px; align-items: flex-start; font-size: .86rem; color: var(--testo-2); }
.nota-sicurezza .i { color: var(--verde); margin-top: 1px; }

.messaggio-errore {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--raggio-m);
  background: var(--timbro-chiaro); color: var(--timbro-scuro); font-size: .93rem;
}
.messaggio-errore .i { margin-top: 2px; }

/* ---------- Messaggi (fumetti) ---------- */

.conversazione { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.fumetto {
  justify-self: start; max-width: min(540px, 86%); padding: 10px 14px;
  border-radius: 18px 18px 18px 6px; background: var(--blu-chiaro); color: var(--inchiostro);
  transform-origin: bottom left;
}
.fumetto p { white-space: pre-line; overflow-wrap: anywhere; }
.fumetto__piede { display: block; margin-top: 4px; color: var(--testo-2); font-size: .76rem; }
.fumetto--mio {
  justify-self: end; border-radius: 18px 18px 6px 18px;
  background: linear-gradient(160deg, var(--inchiostro-2), var(--inchiostro)); color: #fff;
  transform-origin: bottom right;
}
.fumetto--mio .fumetto__piede { color: rgba(255, 255, 255, .72); }

/* ---------- Avvisi (toast) ---------- */

.avvisi {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 90;
  display: grid; gap: 8px; justify-items: center; transform: translateX(-50%);
  width: min(92vw, 460px); pointer-events: none;
}
.avviso {
  display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-radius: 16px;
  background: rgba(11, 26, 44, .92); color: #fff; font-size: .95rem;
  box-shadow: var(--ombra-3);
  backdrop-filter: saturate(160%) blur(16px); -webkit-backdrop-filter: saturate(160%) blur(16px);
}
.avviso--ok .i { color: #8fd3b1; }
.avviso--errore .i { color: #f1a48f; }

/* ---------- Spunta disegnata ---------- */

.spunta { width: 52px; height: 52px; }
.spunta__cerchio { fill: var(--verde-chiaro); stroke: var(--verde); stroke-width: 2; }
.spunta__segno { fill: none; stroke: var(--verde); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Foglio (tessera del documento) e volo ---------- */

.foglio {
  position: relative; display: inline-grid; place-items: end center; flex: none;
  width: 38px; height: 48px; padding-bottom: 6px;
  border-radius: 5px 12px 5px 5px;
  background: linear-gradient(160deg, #fff, #f4efe6);
  box-shadow: 0 1px 2px rgba(18, 38, 63, .12), inset 0 0 0 1px rgba(18, 38, 63, .12);
}
.foglio::before {
  content: ''; position: absolute; top: 9px; left: 8px; right: 12px; height: 14px;
  background: repeating-linear-gradient(to bottom, rgba(18, 38, 63, .16) 0 1.5px, transparent 1.5px 4.5px);
}
.foglio::after {
  content: ''; position: absolute; top: 0; right: 0; width: 11px; height: 11px;
  background: linear-gradient(225deg, var(--carta) 50%, #e2d8c6 50%); border-radius: 0 12px 0 3px;
}
.foglio__tipo {
  position: relative; padding: 1px 4px; border-radius: 3px; font-size: .58rem; font-weight: 700; letter-spacing: .05em;
  background: var(--inchiostro-2); color: #fff;
}
.foglio--pdf .foglio__tipo { background: var(--timbro); }
.foglio--p7m .foglio__tipo { background: var(--verde); }
.foglio--jpg .foglio__tipo, .foglio--png .foglio__tipo { background: var(--ottone); }

.volo { position: fixed; z-index: 80; pointer-events: none; will-change: transform, opacity; }
.volo__copia { width: 100%; height: 100%; will-change: transform; }
.volo__copia.foglio { box-shadow: 0 12px 28px -6px rgba(18, 38, 63, .35), inset 0 0 0 1px rgba(18, 38, 63, .12); }

/* ---------- Busta ---------- */

.busta {
  position: relative; display: block; width: 132px; height: 92px; perspective: 520px;
}
.busta--volante { position: fixed; z-index: 85; pointer-events: none; }
.busta__retro, .busta__tasca, .busta__aletta, .busta__foglio { position: absolute; inset: 0; }
.busta__retro { border-radius: 10px; background: #e9dfcc; box-shadow: 0 18px 40px -12px rgba(18, 38, 63, .38); }
.busta__foglio { inset: 8px 12px 16px; border-radius: 4px; background: #fff; box-shadow: inset 0 0 0 1px rgba(18, 38, 63, .08); }
.busta__tasca {
  border-radius: 10px; background: linear-gradient(180deg, #f7f0e2, #efe5d2);
  clip-path: polygon(0 34%, 50% 70%, 100% 34%, 100% 100%, 0 100%);
}
.busta__aletta {
  bottom: auto; height: 62%; border-radius: 10px 10px 0 0;
  background: linear-gradient(180deg, #e2d5bd, #ece2cf);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: 50% 0; transform: rotateX(180deg); backface-visibility: visible;
}
.busta--chiusa .busta__aletta, .busta__aletta.is-chiusa { transform: rotateX(0deg); }
.busta__timbro {
  position: absolute; left: 50%; top: 62%; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #d0624a, var(--timbro) 60%, var(--timbro-scuro));
  color: #fbe9e2; font-size: .8rem; font-weight: 700;
  box-shadow: 0 2px 4px rgba(151, 53, 32, .4), inset 0 0 0 2px rgba(255, 255, 255, .18);
  transform: translate(-50%, -50%) rotate(-8deg); opacity: 0;
}
.busta--chiusa .busta__timbro { opacity: 1; }
.busta--chiusa .busta__foglio { opacity: 0; }

.is-partita { visibility: hidden; }

/* ---------- Schermata di accesso (comune alle due app) ---------- */

.accesso {
  min-height: 100dvh; display: grid; place-items: center; padding: 32px 16px;
}
.accesso__scheda {
  width: min(100%, 440px); padding: clamp(24px, 5vw, 40px);
  display: grid; gap: 22px;
}
.accesso__marchio { display: flex; align-items: center; gap: 14px; }
.accesso__marchio img { width: auto; height: 56px; }
.accesso__marchio-testo { display: grid; line-height: 1.25; }
.accesso__marchio-testo strong { color: var(--inchiostro); font-size: 1.05rem; }
.accesso__marchio-testo span { color: var(--testo-2); font-size: .88rem; }
.accesso__modulo { display: grid; gap: 16px; }
.accesso__piede { font-size: .82rem; color: var(--testo-3); text-align: center; }

.passi { display: grid; gap: 0; margin: 4px 0; padding: 0; list-style: none; }
.passo { position: relative; display: grid; grid-template-columns: 28px 1fr; gap: 12px; padding-bottom: 18px; }
.passo:last-child { padding-bottom: 0; }
.passo::before {
  content: ''; position: absolute; left: 13px; top: 28px; bottom: 2px; width: 2px; background: var(--linea-forte);
}
.passo:last-child::before { display: none; }
.passo__segno {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: rgba(18, 38, 63, .07); color: var(--testo-3); font-size: .8rem; font-weight: 700;
}
.passo--fatto .passo__segno { background: var(--verde); color: #fff; }
.passo--ora .passo__segno { background: var(--ottone-chiaro); color: var(--ottone); box-shadow: 0 0 0 4px rgba(138, 101, 38, .12); }
.passo strong { display: block; color: var(--inchiostro); }
.passo span { font-size: .88rem; color: var(--testo-2); }

.forza { display: grid; gap: 6px; }
.forza__barre { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.forza__barra { height: 4px; border-radius: 2px; background: rgba(18, 38, 63, .1); transition: background-color .3s; }
.forza[data-livello='1'] .forza__barra:nth-child(-n+1) { background: var(--timbro); }
.forza[data-livello='2'] .forza__barra:nth-child(-n+2) { background: var(--ottone); }
.forza[data-livello='3'] .forza__barra:nth-child(-n+3) { background: #5d8f62; }
.forza[data-livello='4'] .forza__barra { background: var(--verde); }
.forza__testo { font-size: .82rem; color: var(--testo-2); }

.demo-nota {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--raggio-m);
  background: #fbf3df; border: 1px dashed #d8bd78; color: #5e4818; font-size: .88rem;
}
.demo-nota a { color: inherit; font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
