/* PRANDI MFA – tema per auth.prandi.net (Authelia 4.39)
 * Solo CSS, nessuno script. Caricato da Caddy con un <link> iniettato nella pagina.
 * Selettori basati sugli id stabili di Authelia (#first-factor-stage, #sign-in-button...)
 * e sulla struttura, non sulle classi utility (Tailwind dalla 4.39.28). Se Authelia cambia, al massimo si perde lo stile:
 * il login continua a funzionare.
 */
:root {
  --pz-night: #020b1f;
  --pz-navy: #04163a;
  --pz-deep: #0a2a6b;
  --pz-blue: #1d5cff;
  --pz-blue-2: #2f7bff;
  --pz-cyan: #2ec5ff;
  --pz-ink: #eaf2ff;
  --pz-muted: #a9bddf;
  --pz-line: rgba(90, 160, 255, .45);
  --pz-glass: rgba(10, 30, 70, .55);
  --pz-font: "Segoe UI Variable Display", "Segoe UI", "SF Pro Display", -apple-system, system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
}

html, body {
  background-color: var(--pz-night) !important;
  background-image:
    radial-gradient(1200px 700px at 22% 70%, rgba(30, 110, 255, .28), transparent 60%),
    radial-gradient(900px 600px at 85% 30%, rgba(46, 197, 255, .14), transparent 60%),
    linear-gradient(160deg, #031029 0%, #020b1f 55%, #010714 100%) !important;
  background-attachment: fixed !important;
  color: var(--pz-ink);
  font-family: var(--pz-font) !important;
}
#root, #root * { font-family: var(--pz-font) !important; }
#root > div { background: transparent !important; }

/* ---------- colonna sinistra (iniettata) ---------- */
.pz-hero { display: none; }

@media (min-width: 1000px) {
  .pz-hero {
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    width: 55vw;
    padding: 5vh 3vw 0 6vw;
    box-sizing: border-box;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
  }
  .pz-brand { display: flex; align-items: center; gap: 22px; }
  .pz-brand img { width: 78px; height: auto; }
  .pz-brand span {
    border-left: 2px solid rgba(255, 255, 255, .35);
    padding-left: 24px;
    font-size: 40px; font-weight: 600; letter-spacing: .14em; color: #fff;
  }
  .pz-brand b { color: var(--pz-cyan); font-weight: 700; }
  .pz-title {
    margin: 5vh 0 0; font-size: clamp(40px, 4.4vw, 78px); line-height: 1.04;
    font-weight: 700; color: #fff; letter-spacing: -.01em; text-wrap: balance;
  }
  .pz-title em {
    font-style: normal;
    background: linear-gradient(90deg, #1fb6ff, #2f7bff);
    -webkit-background-clip: text; background-clip: text; color: transparent;
  }
  .pz-badges { display: flex; flex-wrap: wrap; gap: 0; margin-top: 3.2vh; padding: 0; list-style: none; }
  .pz-badges li {
    display: flex; align-items: center; gap: 10px;
    padding: 0 22px; font-size: 18px; color: #dce8ff;
    border-left: 1px solid rgba(255, 255, 255, .22);
  }
  .pz-badges li:first-child { padding-left: 0; border-left: 0; }
  .pz-badges svg { width: 30px; height: 30px; stroke: var(--pz-blue-2); fill: none; stroke-width: 1.7; }
  .pz-owl {
    margin-top: auto; align-self: flex-start;
    width: min(46vw, 820px); height: auto;
    filter: drop-shadow(0 0 40px rgba(30, 120, 255, .35));
  }

  /* contenuto di Authelia spostato a destra */
  [id$="-stage"] {
    margin-left: 52vw !important;
    width: 48vw !important;
    position: relative; z-index: 1;
  }
}
@media (min-width: 1000px) and (max-height: 760px) {
  .pz-owl { width: min(34vw, 560px); }
}


/* ---------- card ----------
 * Authelia 4.39.28 ha sostituito MUI con Tailwind: la card è il primo figlio
 * dello stage (div.mx-auto.w-full.px-8.max-w-[444px]). Selettori su id e struttura,
 * non sulle classi utility, così un cambio di classi non rompe nulla. */
[id$="-stage"] { color: var(--pz-ink); }
[id$="-stage"] > div:first-child {
  position: relative;
  box-sizing: border-box;
  max-width: 520px !important;
  padding: 44px 40px 34px !important;
  border-radius: 28px;
  background: linear-gradient(160deg, rgba(20, 50, 110, .55), rgba(6, 20, 52, .72)) !important;
  border: 1px solid var(--pz-line);
  box-shadow:
    0 0 0 1px rgba(46, 140, 255, .15) inset,
    0 0 40px rgba(30, 110, 255, .35),
    0 30px 80px rgba(0, 0, 0, .55);
  backdrop-filter: blur(14px) saturate(130%);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
  text-align: left;
}
@media (max-width: 560px) {
  [id$="-stage"] { align-items: flex-start !important; padding-top: 8px; }
  [id$="-stage"] > div:first-child {
    width: auto !important;
    margin: 8px 14px 70px !important;
    padding: 30px 22px 26px !important;
    border-radius: 24px;
  }
}

/* logo di Authelia: su desktop c'è già il brand a sinistra */
[id$="-stage"] > div:first-child img { width: 72px !important; margin: 0 0 6px !important; }
@media (min-width: 1000px) {
  #first-factor-stage > div:first-child img { display: none !important; }
}

/* titolo "Bentornato" + sottotitolo (il testo originale resta per i lettori di schermo) */
#first-factor-stage h5 {
  font-size: 0 !important; text-align: left !important; line-height: 1 !important; margin: 0;
}
#first-factor-stage h5::before {
  content: "Bentornato";
  display: block; font-size: 42px; font-weight: 700; color: #fff; letter-spacing: -.01em;
}
#first-factor-stage h5::after {
  content: "Accedi al tuo ambiente privato e protetto";
  display: block; margin-top: 10px; font-size: 17px; font-weight: 400; color: var(--pz-muted); line-height: 1.35;
}
@media (max-width: 560px) {
  #first-factor-stage h5::before { font-size: 36px; }
  #first-factor-stage h5::after { font-size: 16px; }
}

/* testi generici */
[id$="-stage"] h5, [id$="-stage"] h6, [id$="-stage"] p, [id$="-stage"] label { color: var(--pz-ink); }

/* ---------- campi ---------- */
[id$="-stage"] input:not([type="checkbox"]) {
  border-radius: 14px !important;
  background: rgba(6, 18, 45, .65) !important;
  border: 1px solid rgba(120, 170, 255, .35) !important;
  color: #fff !important;
  caret-color: var(--pz-cyan);
  transition: border-color .15s ease, box-shadow .15s ease;
}
[id$="-stage"] input:not([type="checkbox"]):hover { border-color: rgba(120, 180, 255, .6) !important; }
[id$="-stage"] input:not([type="checkbox"]):focus {
  outline: none !important;
  border: 2px solid var(--pz-cyan) !important;
  box-shadow: 0 0 0 4px rgba(46, 197, 255, .15) !important;
}
[id$="-stage"] input + label { color: var(--pz-muted) !important; }
[id$="-stage"] input:focus + label { color: var(--pz-cyan) !important; }
[id$="-stage"] input:-webkit-autofill {
  -webkit-text-fill-color: #fff !important;
  -webkit-box-shadow: 0 0 0 100px #0a1d45 inset !important;
}
/* occhio della password */
[id$="-stage"] form button[type="button"] { color: var(--pz-muted) !important; }
[id$="-stage"] form button[type="button"]:hover { color: #fff !important; }

/* checkbox Ricordami */
#remember-checkbox {
  border-color: rgba(170, 200, 255, .8) !important;
  border-radius: 5px !important;
  background: transparent;
}
#remember-checkbox[data-state="checked"] {
  background: var(--pz-blue) !important; border-color: var(--pz-cyan) !important; color: #fff !important;
}

/* ---------- pulsanti ---------- */
#sign-in-button, [id$="-stage"] button[type="submit"] {
  width: 100%;
  border-radius: 14px !important;
  min-height: 52px;
  font-size: 18px !important; font-weight: 600 !important;
  text-transform: none !important; letter-spacing: .01em;
  color: #fff !important;
  background: linear-gradient(90deg, #1546e8, #2f7bff) !important;
  box-shadow: 0 8px 24px rgba(30, 90, 255, .45), 0 0 0 1px rgba(120, 180, 255, .35) inset !important;
  transition: filter .15s ease, box-shadow .15s ease;
}
#sign-in-button:hover { filter: brightness(1.12); box-shadow: 0 10px 30px rgba(30, 110, 255, .6) !important; }
#sign-in-button:focus-visible, #passkey-sign-in-button:focus-visible { outline: 3px solid var(--pz-cyan); outline-offset: 3px; }
#sign-in-button::after { content: "\2192"; margin-left: 12px; font-size: 20px; }

#passkey-sign-in-button {
  width: 100%;
  min-height: 52px;
  border-radius: 14px !important;
  font-size: 17px !important; font-weight: 600 !important;
  text-transform: none !important;
  color: #fff !important;
  background: rgba(4, 16, 40, .55) !important;
  border: 1px solid rgba(140, 190, 255, .55) !important;
  box-shadow: none !important;
}
#passkey-sign-in-button:hover { background: rgba(20, 50, 110, .6) !important; }

/* divisore "oppure" */
[id$="-stage"] .bg-border { background: rgba(150, 190, 255, .35) !important; }
[id$="-stage"] .bg-border + span { color: var(--pz-muted) !important; font-size: 15px; text-transform: none !important; }

/* link "Hai dimenticato la password?" (ora è un bottone) */
#reset-password-button {
  color: #6aa6ff !important; font-size: 16px !important; text-transform: none !important;
  text-decoration: underline; text-underline-offset: 3px; background: transparent !important;
}
#reset-password-button:hover { color: var(--pz-cyan) !important; }
#reset-password-button:focus-visible { outline: 2px solid var(--pz-cyan); outline-offset: 2px; }

/* "Powered by Authelia" */
[id$="-stage"] a[href*="authelia.com"] { color: rgba(170, 195, 235, .55) !important; font-size: 12px; text-decoration: none; }

/* nota MFA sotto la card */
#first-factor-stage > div:first-child::after {
  content: "\1F6E1\FE0E  Accesso con autenticazione a più fattori (MFA)";
  position: absolute; left: 0; right: 0; bottom: -46px;
  text-align: center; font-size: 15px; color: #cfe0ff;
}

/* barra in alto (lingua) */
#root header { background: transparent !important; box-shadow: none !important; }
#root header, #root header button, #root header span, #root header p { color: #cfe0ff !important; }

@media (prefers-reduced-motion: reduce) {
  #sign-in-button, [id$="-stage"] input { transition: none; }
}

/* gufo nuovo al posto del logo di Authelia (URL nuovo = niente cache vecchia) */
[id$="-stage"] > div:first-child img { content: url("/_prandi/owl-logo.png?v=1"); }

/* mobile/tablet: il gufo grande del desktop in alto, la card ci si appoggia sopra */
@media (max-width: 999px) {
  .pz-hero {
    display: block;
    position: absolute; left: 0; right: 0; top: 0; height: 0;
    pointer-events: none; z-index: 0;
  }
  .pz-hero > :not(.pz-owl) { display: none; }
  .pz-hero .pz-owl {
    position: absolute; left: 50%; top: 34px;
    transform: translateX(-50%);
    width: min(80vw, 440px); height: auto;
    filter: drop-shadow(0 0 36px rgba(30, 120, 255, .4));
  }
  #root { position: relative; z-index: 1; }
  /* la card parte sotto il gufo (altezza gufo = larghezza / 1.47) e copre le nuvole */
  [id$="-stage"] {
    align-items: flex-start !important;
    padding-top: calc(34px + min(80vw, 440px) / 1.47 - 70px) !important;
    min-height: 0 !important;
  }
  /* il gufetto piccolo nella card sarebbe un doppione */
  #first-factor-stage > div:first-child img { display: none !important; }
  [id$="-stage"] > div:first-child {
    background: linear-gradient(160deg, rgba(20, 50, 110, .78), rgba(6, 20, 52, .9)) !important;
  }
}

/* selettore lingua nascosto: le traduzioni sono già in italiano */
#language-button { display: none !important; }

/* mobile: intro senza JavaScript. Il gufo parte grande al centro dello schermo,
   dopo mezzo secondo sale al suo posto e la card entra dal basso. */
@keyframes pz-owl-intro {
  from { transform: translate(-50%, 22vh) scale(1.3); }
  to   { transform: translate(-50%, 0) scale(1); }
}
@keyframes pz-card-in {
  from { opacity: 0; transform: translateY(60px); }
  to   { opacity: 1; transform: none; }
}
@media (max-width: 999px) {
  .pz-hero .pz-owl { animation: pz-owl-intro .6s cubic-bezier(.2, .8, .2, 1) .5s both; }
  #first-factor-stage > div:first-child { animation: pz-card-in .6s cubic-bezier(.2, .8, .2, 1) .55s both; }
}
@media (max-width: 999px) and (prefers-reduced-motion: reduce) {
  .pz-hero .pz-owl, #first-factor-stage > div:first-child { animation: none; }
}

/* mobile: testi e pulsanti più compatti (-4px circa) */
@media (max-width: 999px) {
  #first-factor-stage h5::before { font-size: 32px; }
  #first-factor-stage h5::after { font-size: 13px; margin-top: 8px; }
  [id$="-stage"] input:not([type="checkbox"]) { height: 48px !important; font-size: 14px !important; }
  [id$="-stage"] input + label { font-size: 12px !important; }
  [id$="-stage"] form label:not(input + label), [id$="-stage"] form p { font-size: 13px !important; }
  #sign-in-button, [id$="-stage"] button[type="submit"] { min-height: 46px; height: 46px; font-size: 14px !important; }
  #sign-in-button::after { font-size: 16px; margin-left: 10px; }
  #passkey-sign-in-button { min-height: 46px; height: 46px; font-size: 13px !important; }
  [id$="-stage"] .bg-border + span { font-size: 12px; }
  #reset-password-button { font-size: 13px !important; }
  #first-factor-stage > div:first-child::after { font-size: 12px; bottom: -38px; }
}
@media (max-width: 560px) {
  /* la card occupa sempre tutta la larghezza (meno i margini), anche con testi più piccoli */
  [id$="-stage"] > div:first-child { width: calc(100vw - 28px) !important; flex: none; }
}

/* titolo: "Login su Prandi MFA", niente sottotitolo */
#first-factor-stage h5::before { content: "Login su Prandi MFA"; font-size: 26px; font-weight: 700; }
#first-factor-stage h5::after { content: none; display: none; }
#first-factor-stage h5 { margin-bottom: 4px !important; }
@media (max-width: 999px) {
  #first-factor-stage h5::before { font-size: 17px; }
}

/* ---------- secondo fattore: pagina del codice (2026-11-12) ----------
 * Su telefono i 6 campi andavano a capo (4+2) e, con il riquadro alto 200px fissi,
 * "Inserisci password monouso" finiva sopra "Gestisci dispositivi". */

/* "Ciao Nome Cognome" più piccolo */
#second-factor-stage h5 { font-size: 24px !important; font-weight: 700; line-height: 1.2; color: #fff; margin: 0 0 6px; }

/* Esci | Cambia utente | Metodi: link sobri invece dei pulsanti rossi maiuscoli */
#logout-button, #switch-user-button, #methods-button {
  color: #6aa6ff !important; text-transform: none !important; letter-spacing: 0 !important;
  font-size: 14px !important; height: auto !important; padding: 4px 6px !important;
  background: transparent !important;
}
#logout-button:hover, #switch-user-button:hover, #methods-button:hover { color: var(--pz-cyan) !important; }

/* riquadro del metodo: altezza libera, niente sovrapposizioni */
#second-factor-stage [id="2fa-container"] { height: auto !important; min-height: 200px; padding: 8px 0; }
#second-factor-stage div:has(> [id$="-method"]) {
  border-color: rgba(120, 170, 255, .3) !important; border-radius: 18px !important;
  background: rgba(6, 18, 45, .35);
}
#second-factor-stage [id$="-method"] h6 { color: #fff; font-size: 20px !important; }

/* 6 caselle sempre su una riga: si stringono se lo schermo è stretto */
#otp-input { display: block !important; width: 100%; }
#otp-input > [role="group"] { display: flex; justify-content: center; gap: 8px; flex-wrap: nowrap; }
#otp-input input:not([type="checkbox"]) {
  flex: 0 1 46px; min-width: 0; width: auto !important;
  height: 54px !important; margin: 0 !important; padding: 0 !important;
  border-radius: 12px !important; font-size: 24px !important; font-weight: 600;
}

/* "Gestisci dispositivi" / "Registra dispositivo" staccato dal testo sopra */
#register-link, #selection-link { display: block; margin: 12px auto 0; font-size: 14px !important; color: #6aa6ff !important; }

@media (max-width: 999px) {
  /* il gufo grande è già in alto: niente gufetto doppione nella card */
  #second-factor-stage > div:first-child img { display: none !important; }
  #second-factor-stage h5 { font-size: 19px !important; }
  #second-factor-stage div:has(> [id$="-method"]) { min-width: 0 !important; padding: 20px 12px !important; }
  #second-factor-stage [id$="-method"] h6 { font-size: 17px !important; }
  #otp-input > [role="group"] { gap: 6px; }
  #otp-input input:not([type="checkbox"]) { flex-basis: 42px; height: 50px !important; font-size: 22px !important; }
  #second-factor-stage [id="2fa-container"] p { font-size: 13px !important; }
}

/* ---------- pagine senza login (impostazioni, consenso...) (2026-11-16) ----------
 * La colonna col gufo è fissa e copriva /settings/*: la mostro solo dove cè uno

/* ---------- pagine senza login: impostazioni, consenso... (2026-11-16) ----------
 * La colonna col gufo e' fissa e copriva /settings/*: la mostro solo dove c'e' uno
 * stage di accesso (first-factor-stage, second-factor-stage...). */
body:not(:has([id$="-stage"])) .pz-hero { display: none !important; }
