/* Pagina pubblica di emissione attestazioni (stile condiviso con la pagina di verifica del Verifier).
   Nessuno stile inline e nessun font esterno: la CSP ammette solo risorse dello stesso sito. */

:root {
  --paper: #f4f6f9;
  --surface: #ffffff;
  --ink: #14202e;
  --muted: #566475;
  --line: #d5dce5;
  --brand: #0b5cab;
  --brand-deep: #083f77;
  --on-brand: #ffffff;
  --ok: #14774a;
  --danger: #b3261e;
  --danger-soft: #fbeceb;
  --on-status: #ffffff;
  --focus: #0b5cab;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --radius: 0.75rem;
  --card-ratio: 1.586; /* carta ID-1: 85,6 x 54 mm */
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f1722;
    --surface: #172131;
    --ink: #e8edf3;
    --muted: #9aa8b8;
    --line: #2a3648;
    --brand: #5ba2ea;
    --brand-deep: #8bbcf0;
    --on-brand: #08213f;
    --ok: #55c58f;
    --danger: #ff8a80;
    --danger-soft: #3a1d1b;
    --on-status: #0b1a14;
    --focus: #8bbcf0;
  }
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.55 var(--sans);
}

.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;
}

[hidden] {
  display: none !important;
}

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

/* ---------------------------------------------------------------- struttura */

.page {
  max-width: 44rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 4rem;
}

/* Logo e titolo centrati nella pagina; il titolo e' il marchio della pagina, quindi non piu' piccolo
   dell'intestazione della vista sottostante. */
.masthead {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  min-height: 3.5rem;
  margin-bottom: 2.5rem;
  text-align: center;
}

.masthead__title {
  font: 700 clamp(1.5rem, 1.1rem + 1.8vw, 2.125rem) / 1.15 var(--serif);
  letter-spacing: -0.01em;
  color: var(--ink);
  overflow-wrap: anywhere;
}

/* Da tablet in su logo e titolo restano sulla stessa riga: e' il titolo ad andare a capo, non il logo. */
@media (min-width: 31rem) {
  .masthead {
    flex-wrap: nowrap;
    text-align: left;
  }

  .masthead__logo {
    flex-shrink: 0;
  }

  .masthead__title {
    min-width: 0;
  }
}

.masthead__title[hidden] {
  display: none;
}

.masthead__logo {
  display: block;
  max-width: 13rem;
  max-height: 3.5rem;
  width: auto;
  height: auto;
}

.view {
  display: block;
}

.view__title {
  margin: 0 0 0.75rem;
  font: 600 clamp(1.375rem, 1.1rem + 1.4vw, 1.875rem) / 1.2 var(--serif);
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.view__title:focus {
  outline: none;
}

.lead {
  margin: 0 0 2rem;
  color: var(--muted);
  font-size: 1.125rem;
  text-wrap: pretty;
}

.section-title {
  margin: 0 0 0.75rem;
  font: 600 1.125rem/1.3 var(--sans);
}

/* ---------------------------------------------------- scelta del documento */

.docs {
  margin: 0 0 2rem;
  padding: 0;
  border: 0;
}

.docs__legend {
  padding: 0;
  margin: 0 0 0.75rem;
  font: 600 1.125rem/1.3 var(--sans);
}

/* Colonne esplicite (1 su telefono, 2 sui medi, 3 da 40rem): il numero di tessere per riga non dipende dal contenuto, quindi
   una sola attestazione nel catalogo occupa una colonna e non si allarga a tutta la riga (con le proporzioni di una carta
   diventerebbe altissima). */
.docs__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
}

@media (min-width: 31rem) {
  .docs__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Tre colonne solo con esattamente tre tessere: con quattro la griglia resta 2x2, senza una tessera isolata
   nella seconda riga (come la pagina /verify del Verifier). */
@media (min-width: 40rem) {
  .docs__grid:has(> :nth-child(3):last-child) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
/* La cella della griglia e' un contenitore flex perche' la tessera interna ne riempia l'altezza: le tessere di una riga
   hanno cosi' tutte l'altezza della piu' alta (ad esempio quando un titolo va a capo). */
.doc {
  position: relative;
  display: flex;
  min-width: 0;
  cursor: pointer;
}

.doc__input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.doc__card {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
  aspect-ratio: var(--card-ratio);
  padding: 1rem 1.125rem;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

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

.doc__input:checked + .doc__card {
  border-color: var(--brand);
  box-shadow: 0 0 0 1.5px var(--brand), 0 0.5rem 1.25rem -0.75rem var(--brand);
  transform: translateY(-2px);
}

.doc__input:focus-visible + .doc__card {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* chip della carta, disegnato in CSS: contatti laterali e riquadro centrale */
.doc__chip {
  position: relative;
  width: 2.5rem;
  height: 1.9rem;
  border: 1.5px solid var(--muted);
  border-radius: 0.4rem;
  color: var(--muted);
  background:
    linear-gradient(currentColor, currentColor) 0 34% / 100% 1.5px no-repeat,
    linear-gradient(currentColor, currentColor) 0 66% / 100% 1.5px no-repeat,
    color-mix(in srgb, currentColor 10%, transparent);
  transition: color 120ms ease, border-color 120ms ease;
}

.doc__chip::after {
  content: "";
  position: absolute;
  inset: 22% 30%;
  border: 1.5px solid currentColor;
  border-radius: 0.25rem;
  background: var(--surface);
}
.doc__input:checked + .doc__card .doc__chip {
  color: var(--brand);
  border-color: var(--brand);
}

.doc__text {
  display: block;
}

.doc__label {
  display: block;
  font-size: 1.125rem;
  font-weight: 650;
  line-height: 1.25;
}

.doc__desc {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.4;
}

.doc__mark {
  position: absolute;
  top: 0.9rem;
  right: 1rem;
  width: 1.4rem;
  height: 1.4rem;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.doc__input:checked + .doc__card .doc__mark {
  background: var(--brand);
  border-color: var(--brand);
}

.doc__input:checked + .doc__card .doc__mark::after {
  content: "";
  position: absolute;
  left: 0.43rem;
  top: 0.2rem;
  width: 0.35rem;
  height: 0.7rem;
  border: solid var(--on-brand);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ---------------------------------------------------------------- azioni */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0.7rem 1.25rem;
  border: 1.5px solid var(--brand);
  border-radius: var(--radius);
  background: transparent;
  color: var(--brand);
  font: 600 1rem/1.2 var(--sans);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

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

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

.btn--primary:hover {
  background: var(--brand-deep);
  border-color: var(--brand-deep);
  color: var(--on-brand);
}

.btn--quiet {
  border-color: transparent;
  color: var(--muted);
}

/* il testo di "Annulla" si allinea al bordo della colonna quando e' il primo elemento */
.actions > .btn--quiet:first-child {
  margin-left: -1.25rem;
}

.btn--quiet:hover {
  color: var(--ink);
  border-color: transparent;
  text-decoration: underline;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

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

.btn--primary:disabled:hover {
  background: var(--brand);
  color: var(--on-brand);
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9375rem;
}

.link {
  color: var(--brand);
  text-underline-offset: 0.2em;
}

.link:hover {
  color: var(--brand-deep);
}

.notice {
  margin: 1rem 0 0;
  padding: 0.75rem 1rem;
  border-left: 4px solid var(--danger);
  border-radius: 0.25rem;
  background: var(--danger-soft);
  color: var(--ink);
}

.notice--info {
  border-left-color: var(--brand);
  background: var(--surface);
  color: var(--muted);
}

@media (max-width: 30rem) {
  .actions .btn {
    width: 100%;
  }

  /* su telefono le tessere diventano righe compatte: i bottoni restano raggiungibili senza lungo scroll */
  .doc__card {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 1rem;
    aspect-ratio: auto;
    min-height: 5.75rem;
    padding: 0.875rem 3rem 0.875rem 1rem;
  }

  .doc__chip {
    flex: none;
  }

  .doc__mark {
    top: 50%;
    margin-top: -0.7rem;
  }
}

/* ------------------------------------------------------ attesa del wallet */

.wait {
  display: grid;
  gap: 2rem;
  align-items: start;
  margin-top: 1.5rem;
}

@media (min-width: 40rem) {
  .wait--qr {
    grid-template-columns: auto 1fr;
    gap: 2.5rem;
  }
}

.qr {
  justify-self: start; /* il pannello avvolge il QR invece di allargarsi alla riga */
  display: inline-block;
  padding: 1rem;
  background: #ffffff; /* il QR code richiede sempre fondo chiaro e margine */
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.qr__img {
  display: block;
  width: min(16rem, calc(100vw - 4.5rem));
  height: auto;
  aspect-ratio: 1;
  image-rendering: pixelated;
}

.steps {
  margin: 0 0 1.5rem;
  padding-left: 1.4rem;
}

.steps li {
  margin-bottom: 0.5rem;
  padding-left: 0.25rem;
}

.steps li::marker {
  color: var(--brand);
  font-weight: 700;
}

.status {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1.25rem;
  color: var(--muted);
}

.status__dot {
  flex: none;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: var(--brand);
  animation: pulse 1.6s ease-in-out infinite;
}

.spinner {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.35;
    transform: scale(0.7);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ----------------------------------------------------------------- esito */

.outcome__icon {
  position: relative;
  width: 3.5rem;
  height: 3.5rem;
  margin-bottom: 1.25rem;
  border-radius: 50%;
  background: var(--ok);
}

.outcome__icon::after {
  content: "";
  position: absolute;
  left: 1.2rem;
  top: 0.65rem;
  width: 0.75rem;
  height: 1.5rem;
  border: solid var(--on-status);
  border-width: 0 3px 3px 0;
  transform: rotate(45deg);
}

.outcome__icon--bad {
  background: var(--danger);
}

/* X ottenuta con due barre incrociate */
.outcome__icon--bad::before,
.outcome__icon--bad::after {
  content: "";
  position: absolute;
  left: calc(50% - 1.5px);
  top: calc(50% - 0.8rem);
  width: 3px;
  height: 1.6rem;
  border: 0;
  background: var(--on-status);
}

.outcome__icon--bad::before {
  transform: rotate(-45deg);
}

.outcome__icon--bad::after {
  transform: rotate(45deg);
}

/* --------------------------------------------------- dettaglio dell'errore */

.reasons {
  max-width: 52ch;
  margin: 0 0 1.5rem;
  padding-left: 1.25rem;
}

.reasons li {
  margin-bottom: 0.35rem;
}

.notice .reasons {
  margin: 0.5rem 0 0;
}

/* ------------------------------------------------------ scelta del flusso */

.flows {
  margin: 0 0 2rem;
  padding: 0;
  border: 0;
}

.flows__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
}

@media (min-width: 31rem) {
  .flows__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.flow {
  position: relative;
  display: flex;
  min-width: 0;
  cursor: pointer;
}

.flow__input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.flow__box {
  flex: 1 1 0;
  min-width: 0;
  padding: 0.875rem 1rem 0.875rem 2.75rem;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

/* pallino del radio disegnato in CSS */
.flow__box::before {
  content: "";
  position: absolute;
  left: 1rem;
  top: 1.05rem;
  width: 1.05rem;
  height: 1.05rem;
  border: 1.5px solid var(--muted);
  border-radius: 50%;
  background: var(--surface);
}

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

.flow__input:checked + .flow__box {
  border-color: var(--brand);
  box-shadow: 0 0 0 1.5px var(--brand);
}

.flow__input:checked + .flow__box::before {
  border-color: var(--brand);
  background: radial-gradient(circle, var(--brand) 0 45%, var(--surface) 50%);
}

.flow__input:focus-visible + .flow__box {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.flow__label {
  display: block;
  font-weight: 650;
  line-height: 1.3;
}

.flow__desc {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.4;
}

/* ------------------------------------------------------------ dati (claim) */

.claims-form {
  margin: 0 0 2rem;
  padding: 0;
  border: 0;
}

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

@media (min-width: 31rem) {
  .fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.field--wide {
  grid-column: 1 / -1;
}

.field__label {
  font-weight: 600;
  font-size: 0.9375rem;
}

.field__optional {
  color: var(--muted);
  font-weight: 400;
}

.field__input {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.55rem 0.75rem;
  border: 1.5px solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.field__input:hover {
  border-color: var(--muted);
}

.field__input:focus {
  border-color: var(--brand);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent);
}

.field__input[aria-invalid="true"] {
  border-color: var(--danger);
}

.field__input--country {
  text-transform: uppercase;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 2.75rem;
  cursor: pointer;
}

.check__input {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  accent-color: var(--brand);
}

.more {
  margin-top: 1.25rem;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.more > summary {
  color: var(--brand);
  font-weight: 600;
  cursor: pointer;
}

.more[open] > summary {
  margin-bottom: 1rem;
}

.group {
  grid-column: 1 / -1;
  margin: 0.5rem 0 0;
  padding: 0;
  border: 0;
}

.group__legend {
  margin-bottom: 0.75rem;
  padding: 0;
  font-weight: 650;
}

/* ---------------------------------------------------------------- tx_code */

.txcode {
  margin: 0 0 1.5rem;
  padding: 1rem 1.25rem;
  border: 1.5px dashed var(--brand);
  border-radius: var(--radius);
  background: var(--surface);
}

.txcode__label {
  display: block;
  color: var(--muted);
  font-size: 0.9375rem;
}

.txcode__value {
  display: block;
  margin-top: 0.25rem;
  font: 700 2rem/1.2 ui-monospace, "Cascadia Mono", Consolas, monospace;
  letter-spacing: 0.3em;
}

.summary {
  margin: 0 0 1.5rem;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .doc__input:checked + .doc__card {
    transform: none;
  }
}
