/* Verdex — Schermata di ingresso / sblocco (solo smartphone): all'apertura dell'app e subito dopo «Esci».
 * L'aspetto della schermata (anche come schermata di sblocco Face ID / Passkey), la sua dissolvenza d'ingresso
 * (6500 ms) e il passaggio verso la Home dopo l'accesso (schermata e Home insieme in 2300 ms) sono nel CSS incorporato nell'<head> di index.html, così valgono dal primo disegno senza attendere
 * questo foglio di stile. Qui restano il menu delle lingue, il riquadro «Accedi / Registrati» sopra la schermata e
 * l'invito ad attivare Face ID / Passkey. Stessa palette scura istituzionale del footer «Verdex — Sicurezza digitale». */
:root {
  /* Blu notte pieno e uniforme della schermata d'accesso: nessuna sfumatura e nessuna trasparenza. */
  --gate-night: #0B132B;
  /* Curva naturale comune a tutte le animazioni d'ingresso (come le app native). */
  --gate-ease: cubic-bezier(0.16, 1, 0.3, 1);   /* curva vellutata: partenza decisa ma morbida, assestamento lungo */
  --gate-bg: none;
  /* Apertura e chiusura del riquadro «Accedi / Registrati» dalla schermata d'ingresso: 2300 ms, morbide e continue,
     stesso ritmo uniforme del resto dell'app (LOGIN_IN / LOGIN_OUT in shield-gate.js). */
  --gate-login-ms: 2300ms;
  --gate-login-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Selettore lingua compatto «IT v» del riquadro «Accedi / Registrati» (quello della schermata d'ingresso ha le sue
   regole nell'<head> di index.html): pillola blu notte traslucida con bordo chiaro sottile, sotto la barra di stato e
   allineata al bordo destro della card. Selettori con l'id: la regola di base «.lang-dd { position: relative }»
   dell'header non deve riportarlo sotto la card. */
#auth-modal > .gate-lang {
  position: absolute; z-index: 5; left: auto; bottom: auto; margin: 0;
  top: calc(env(safe-area-inset-top, 0px) + .75rem);
}
/* Bordo destro della card «Accedi / Registrati»: 24.5rem e .75rem di margine (26rem e 1.5rem da 640px in su). */
#auth-modal > .gate-lang { right: max(calc(.75rem + env(safe-area-inset-right, 0px)), calc((100% - 24.5rem) / 2)); }
@media (min-width: 640px) {
  #auth-modal > .gate-lang { top: calc(env(safe-area-inset-top, 0px) + 1.25rem); right: max(1.5rem, calc((100% - 26rem) / 2)); }
}
.gate-lang .gate-lang-btn {
  display: inline-flex; flex-direction: row; align-items: center; justify-content: center; gap: .3rem;
  height: 2.375rem; min-height: 2.375rem; min-width: 3.6rem; padding: 0 .6rem 0 .85rem; margin: 0;
  border-radius: 9999px; border: 1px solid rgba(255, 255, 255, .24);
  background: rgba(15, 30, 62, .55); color: #FFFFFF;
  -webkit-backdrop-filter: blur(10px) saturate(1.2); backdrop-filter: blur(10px) saturate(1.2);
  font: inherit; font-size: .86rem; font-weight: 700; line-height: 1; white-space: nowrap; cursor: pointer;
  -webkit-appearance: none; appearance: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .08) inset, 0 6px 18px rgba(2, 6, 23, .32);
  transition: background-color .15s ease, border-color .15s ease, transform .1s ease;
}
.gate-lang .gate-lang-btn:hover { background: rgba(30, 58, 138, .55); border-color: rgba(255, 255, 255, .34); }
.gate-lang .gate-lang-btn:active { transform: scale(.97); }
.gate-lang .gate-lang-btn[aria-expanded="true"] { background: rgba(30, 58, 138, .7); border-color: rgba(255, 255, 255, .42); }
.gate-lang .gate-lang-btn:focus-visible { outline: 3px solid #F59E0B; outline-offset: 3px; }
.gate-lang .lang-current { font-size: .95rem; font-weight: 700; letter-spacing: .06em; color: #FFFFFF; }
.gate-lang .lang-chevron { display: block; flex-shrink: 0; width: 15px; height: 15px; color: rgba(255, 255, 255, .85); transition: transform .15s ease; }
.gate-lang .gate-lang-btn[aria-expanded="true"] .lang-chevron { transform: rotate(180deg); }
.gate-lang .gate-lang-menu {
  position: absolute; top: calc(100% + .4rem); right: 0; z-index: 6; margin: 0; padding: .35rem; list-style: none;
  width: max-content; min-width: 13rem; max-width: calc(100vw - 1.5rem); max-height: min(70vh, 26rem);
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  background: #FFFFFF; border: 2px solid #CBD5E1; border-radius: 1rem; color: #0F172A;
  box-shadow: 0 16px 40px rgba(2, 6, 23, .45); color-scheme: light; font-family: inherit;
}
.gate-lang .gate-lang-menu[hidden] { display: none; }
.gate-lang .lang-opt { display: flex; align-items: center; gap: .65rem; min-height: 3rem; padding: .5rem .75rem; border-radius: .7rem; cursor: pointer; font-size: 1.05rem; font-weight: 700; color: #0F172A; text-align: left; }
.gate-lang .lang-opt + .lang-opt { margin-top: .1rem; }
.gate-lang .lang-opt:hover, .gate-lang .lang-opt.is-active { background: #F1F5F9; }
.gate-lang .lang-opt[aria-selected="true"] { background: #EFF6FF; color: #1E3A8A; }
.gate-lang .lang-opt-code { flex-shrink: 0; min-width: 2.9rem; font-size: .78rem; font-weight: 900; letter-spacing: .03em; color: #475569; }
.gate-lang .lang-opt[aria-selected="true"] .lang-opt-code { color: #1E3A8A; }
.gate-lang .lang-opt-name { flex: 1; }
.gate-lang .gl-check { flex-shrink: 0; visibility: hidden; color: #1E3A8A; }
.gate-lang .lang-opt[aria-selected="true"] .gl-check { visibility: visible; }
html.large-text .gate-lang .gate-lang-btn { font-size: .9rem; height: 2.75rem; min-height: 2.75rem; }
html.large-text .gate-lang .lang-current { font-size: 1.05rem; }
html.large-text .gate-lang .lang-opt { font-size: 1.25rem; min-height: 3.5rem; }
html.high-contrast .gate-lang .gate-lang-btn { background: #000000; color: #FFFFFF; border: 2px solid #FFFFFF; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
html.high-contrast .gate-lang :is(.lang-current, .lang-chevron) { color: #FFFFFF; }
html.high-contrast .gate-lang .gate-lang-menu { background: #FFFFFF; border-color: #000000; }
html.high-contrast .gate-lang .lang-opt, html.high-contrast .gate-lang .lang-opt-code { color: #000000; }
html.high-contrast .gate-lang .lang-opt.is-active, html.high-contrast .gate-lang .lang-opt:hover { background: #FFFFFF; outline: 3px solid #000000; outline-offset: -3px; }
html.high-contrast .gate-lang .lang-opt[aria-selected="true"] { background: #000000; color: #FFFFFF; }
html.high-contrast .gate-lang .lang-opt[aria-selected="true"] :is(.lang-opt-code, .gl-check) { color: #FFFFFF; }
@media (prefers-reduced-motion: reduce) { .gate-lang .gate-lang-btn, .gate-lang .lang-chevron { transition: none; } }

/* «Accedi con Email o Password»: solo il riquadro «Accedi» sopra lo sfondo della schermata d'ingresso.
   La pagina principale resta coperta finché l'utente non ha effettuato l'accesso. */
html.gate-on.gate-login #auth-modal { z-index: 10001; }
/* Il contenuto della schermata si nasconde solo mentre il riquadro è davvero visibile: se il riquadro non c'è, logo e
   opzioni restano sempre visibili, mai uno sfondo blu vuoto. All'apertura del riquadro titolo, pulsanti e lingua si
   dissolvono (2300 ms, cubic-bezier(0.22, 1, 0.36, 1)) mentre la card emerge sopra di loro, e alla chiusura
   riaffiorano con la stessa durata e la stessa curva: nessuno stacco.
   Il logo si nasconde subito sotto la sua copia che plana verso il logo compatto del riquadro (mai due loghi). */
#entry-gate :is(.gate-top, .gate-center, .gate-lang) { transition: opacity var(--gate-login-ms) var(--gate-login-ease), visibility 0s linear 0s; }
html.gate-on.gate-login:has(#auth-modal:not(.hidden)) #entry-gate :is(.gate-top, .gate-center, .gate-lang) {
  opacity: 0; visibility: hidden; transition: opacity var(--gate-login-ms) var(--gate-login-ease), visibility 0s linear var(--gate-login-ms);
}
html.gate-on.gate-login:has(#auth-modal:not(.hidden)) #entry-gate .gate-top { transition: opacity .16s ease, visibility 0s linear .16s; }
html.gate-on.gate-login #entry-gate { overflow: hidden; }
/* Lo sfondo blu notte resta quello della schermata d'ingresso, fermo: il riquadro è trasparente sopra di esso, così
   durante il passaggio non cambia nulla dietro al logo e alla card. (Senza :has il riquadro resta opaco, come prima.) */
@supports selector(:has(*)) {
  html.gate-on.gate-login:has(#auth-modal:not(.hidden)) #auth-modal { background: transparent none; -webkit-backdrop-filter: none; backdrop-filter: none; }
}
/* Chiusura del riquadro senza accesso (classe «calm-leave», shield-calm.js): il riquadro resta sopra la schermata,
   trasparente e intoccabile, e si dissolve in 2300 ms mentre sotto riaffiorano logo, saluto e opzioni.
   Il suo logo compatto si nasconde subito sotto la copia che torna planando sul logo della schermata (mai due loghi). */
html.gate-on #auth-modal.calm-leave.hidden {
  z-index: 10001; pointer-events: none; background: transparent none; -webkit-backdrop-filter: none; backdrop-filter: none;
}
#auth-modal.auth-flyback.calm-leave .auth-brand-logo { visibility: hidden; }

/* Finestra «Accedi / Registrati»: lo stesso sfondo blu notte della schermata d'ingresso,
   con il logo Verdex compatto sopra la card bianca. */
#auth-modal { background-color: var(--gate-night); background-image: var(--gate-bg); color-scheme: dark; }
/* Sopra il sito (computer e tablet) il riquadro «Accedi / Registrati» ha lo stesso fondo pieno #0B132B: dietro la scheda
   d'accesso non traspare mai alcun elemento dell'area di lavoro. */
html:not(.gate-on) #auth-modal { background-color: #0B132B; background-image: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
html #auth-modal .auth-shell { flex-direction: column; align-items: center; justify-content: center; }
#auth-modal .auth-brand {
  position: relative; isolation: isolate; flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: center; gap: .5rem;
  margin: .25rem 0 1.05rem; pointer-events: none; user-select: none;
}
#auth-modal .auth-brand::before {
  content: ''; position: absolute; z-index: -1; left: 50%; top: 1.6rem;
  width: 12rem; height: 12rem; transform: translate(-50%, -50%); border-radius: 50%;
  background: radial-gradient(closest-side, rgba(59, 130, 246, .38) 0%, rgba(37, 99, 235, .18) 45%, rgba(30, 64, 175, 0) 100%);
}
#auth-modal .auth-brand-logo {
  display: block; width: 3.25rem; height: 3.25rem; border-radius: .9rem; background: #FFFFFF; object-fit: contain;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .14), 0 8px 22px rgba(2, 6, 23, .5), 0 0 30px rgba(59, 130, 246, .25);
}
#auth-modal .auth-brand-name { font-size: 1.15rem; font-weight: 800; line-height: 1.1; letter-spacing: -.01em; color: #FFFFFF; }
#auth-modal .auth-card {
  background: #FFFFFF;
  border: 1px solid rgba(255, 255, 255, .9);
  box-shadow: 0 24px 60px rgba(2, 6, 23, .55), 0 2px 8px rgba(2, 6, 23, .3);
}
@media (max-height: 640px) {
  #auth-modal .auth-brand { flex-direction: row; gap: .55rem; margin-bottom: .75rem; }
  #auth-modal .auth-brand::before { top: 50%; left: 1.25rem; width: 8rem; height: 8rem; }
  #auth-modal .auth-brand-logo { width: 2.5rem; height: 2.5rem; border-radius: .7rem; }
}
html.high-contrast #auth-modal { background: #000000; -webkit-backdrop-filter: none; backdrop-filter: none; }
html.high-contrast #auth-modal .auth-brand::before { display: none; }
html.high-contrast #auth-modal .auth-brand-logo { box-shadow: 0 0 0 2px #FFFFFF; }
html.high-contrast #auth-modal .auth-card { background: #FFFFFF; border: 2px solid #FFFFFF; }

@keyframes gate-in-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes gate-in-rise { from { opacity: 0; } to { opacity: 1; } }
@keyframes gate-in-halo { from { opacity: 0; } to { opacity: 1; } }
/* «Accedi con Email o Password» / «Registrati»: lo sfondo resta fermo, il logo della schermata plana su quello
   compatto del riquadro (shield-gate.js), il nome e l'alone compaiono con dolcezza e la card si apre in altezza e
   opacità (crescendo verso il basso, con l'intestazione ferma in alto). Tutto insieme in 2300 ms sulla stessa curva
   cubic-bezier(0.22, 1, 0.36, 1): un solo movimento morbido e continuo, senza velocità improvvise. */
#auth-modal.auth-intro .auth-brand::before { will-change: opacity; animation: gate-in-halo var(--gate-login-ms) var(--gate-login-ease) both; }
#auth-modal.auth-intro .auth-brand-name { will-change: opacity; animation: gate-in-rise var(--gate-login-ms) var(--gate-login-ease) both; }
#auth-modal.auth-intro > .gate-lang { will-change: opacity; animation: gate-in-fade var(--gate-login-ms) var(--gate-login-ease) both; }
@media (prefers-reduced-motion: reduce) {
  #auth-modal.auth-intro :is(.auth-brand-name, .gate-lang), #auth-modal.auth-intro .auth-brand::before { animation: none; }
  #entry-gate :is(.gate-top, .gate-center, .gate-lang),
  html.gate-on.gate-login:has(#auth-modal:not(.hidden)) #entry-gate :is(.gate-top, .gate-center, .gate-lang) { transition: none; }
}

/* Invito ad attivare Face ID / Passkey dopo l'accesso: foglio chiaro sovrapposto, ancorato al bordo inferiore dello
   schermo (position: fixed; bottom: 0; left: 0; right: 0; z-index: 50). È un livello indipendente: entra solo con
   transform, translateY(100%) → translateY(0) in 650 ms su cubic-bezier(0.22, 1, 0.36, 1), senza spingere,
   ridimensionare o far scorrere la pagina sottostante (nessun cambio di misura, margine o scorrimento della pagina) e
   senza toccare l'intestazione Verdex / IT / PRO. Su schermi larghi resta un foglio centrato di al massimo 30 rem. */
.pk-sheet {
  position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; top: auto;
  box-sizing: border-box; width: auto; max-width: 30rem; margin: 0 auto;
  padding: 1.1rem calc(env(safe-area-inset-right, 0px) + 1.1rem) calc(env(safe-area-inset-bottom, 0px) + .9rem) calc(env(safe-area-inset-left, 0px) + 1.1rem);
  border-radius: 1.25rem 1.25rem 0 0;
  display: flex; flex-direction: column; gap: .5rem;
  background: #FFFFFF; border: 1px solid #E2E8F0; border-bottom: 0; color: #0F172A;
  box-shadow: 0 -12px 36px rgba(15, 23, 42, .16), 0 -2px 8px rgba(15, 23, 42, .06);
  transform: translate3d(0, 100%, 0); visibility: hidden; pointer-events: none;
  will-change: transform; -webkit-backface-visibility: hidden; backface-visibility: hidden;
  contain: layout paint style; overscroll-behavior: contain;
  transition: transform 650ms cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear 650ms;
}
.pk-sheet[hidden] { display: none; }
.pk-sheet.is-open {
  transform: translate3d(0, 0, 0); visibility: visible; pointer-events: auto;
  transition: transform 650ms cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear 0s;
}
/* Passkey collegata o attivata: il foglio mostra la conferma e si dissolve da solo in 800 ms (shield-passkey.js), senza
   scivolare né restare fermo sullo schermo. */
.pk-sheet.is-open.is-fading {
  opacity: 0; pointer-events: none;
  will-change: opacity;
  transition: opacity 800ms cubic-bezier(0.22, 1, 0.36, 1);
}
.pk-sheet-title { margin: 0; font-size: 1rem; font-weight: 800; line-height: 1.3; }
.pk-sheet-text { margin: 0; font-size: .92rem; line-height: 1.45; color: #334155; }
.pk-sheet-msg { margin: 0; font-size: .88rem; font-weight: 600; line-height: 1.35; color: #047857; }
.pk-sheet-msg[data-tone="err"] { color: #991B1B; }
.pk-sheet-msg[hidden] { display: none; }
.pk-sheet-actions { display: flex; flex-direction: column; align-items: stretch; gap: .2rem; margin-top: .2rem; }
.pk-sheet-btn {
  min-height: 3rem; padding: .6rem 1rem; border-radius: .9rem; border: 1px solid #1E3A8A;
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  background: #1E3A8A; color: #FFFFFF; font: inherit; font-size: 1rem; font-weight: 700; line-height: 1.2;
  cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.pk-sheet-btn:disabled { opacity: .6; cursor: default; }
.pk-sheet-btn[hidden], .pk-sheet-later[hidden] { display: none; }
.pk-sheet-ico { flex: 0 0 auto; width: 1.2rem; height: 1.2rem; }
.pk-sheet-later {
  align-self: center; min-height: 2.6rem; padding: 0 .8rem; border: 0; background: none; border-radius: .6rem;
  font: inherit; font-size: .92rem; font-weight: 600; color: #475569; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.pk-sheet-btn:focus-visible, .pk-sheet-later:focus-visible { outline: 3px solid #F59E0B; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .pk-sheet, .pk-sheet.is-open { transition: none; } }
html.large-text .pk-sheet-title { font-size: 1.15rem; }
html.large-text .pk-sheet-text { font-size: 1.05rem; }
html.high-contrast .pk-sheet { border: 2px solid #000000; box-shadow: none; }
html.high-contrast .pk-sheet-text, html.high-contrast .pk-sheet-later { color: #000000; }
html.high-contrast .pk-sheet-btn { background: #000000; border: 2px solid #000000; }
