/* JoeQUIZ · le schermate di servizio: accesso, registrazione, attivazione, recupero
   password, uscita. Vivono nel guscio pubblico, quindi token, caratteri, testata e piede
   arrivano da joequiz.css e joequiz-pubblico.css: qui c'e' solo la scheda. */

:root {
  --auth-scheda: color-mix(in oklch, var(--ink-soft) 66%, transparent);
  --auth-campo:  color-mix(in oklch, var(--ink) 84%, black);
  --auth-tenue:  color-mix(in oklch, var(--paper) 78%, transparent);
}

/* ---------- la sezione ---------- */

.jq-auth {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(40px, 6vw, 84px) var(--pub-gutter);
  overflow: hidden;
}

/* gli stessi aloni dell'eroe: la pagina di accesso e' la seconda che si vede, e deve
   sembrare la stessa casa. */
.jq-auth__aloni {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(48% 54% at 18% 16%, color-mix(in oklch, var(--answer-a) 50%, transparent), transparent 72%),
    radial-gradient(44% 50% at 84% 26%, color-mix(in oklch, var(--answer-d) 46%, transparent), transparent 72%),
    radial-gradient(40% 46% at 54% 96%, color-mix(in oklch, var(--flame) 32%, transparent), transparent 74%);
  filter: blur(36px);
  opacity: 0.55;
}

/* ---------- la scheda ---------- */

.jq-auth-card {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  max-width: 440px;
  padding: clamp(28px, 4vw, 40px);
  background: var(--auth-scheda);
  border: 1px solid var(--pub-bordo);
  border-radius: var(--radius);
  box-shadow: 0 28px 64px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.jq-auth-card *,
.jq-auth-card *::before,
.jq-auth-card *::after { box-sizing: border-box; }

.jq-auth .card-header { margin-bottom: 26px; }
.jq-auth .card-header h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.75rem, 3vw, 2.15rem);
  letter-spacing: -0.025em;
  line-height: 1.08;
  margin: 0 0 10px;
}
.jq-auth .card-header p {
  margin: 0;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--auth-tenue);
}
.jq-auth .card-header .email-highlight { color: var(--azzurro); font-weight: 700; }

/* il tondo dell'icona: azzurro, che nel gioco e' il colore della conferma. */
.jq-auth .card-icon {
  width: 64px;
  height: 64px;
  margin: 0 0 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: color-mix(in oklch, var(--azzurro) 18%, transparent);
}
.jq-auth .card-icon svg {
  width: 32px; height: 32px;
  stroke: var(--azzurro); fill: none;
  stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- campi ---------- */

.jq-auth .form-group,
.jq-auth .email-input-group { margin-bottom: 18px; text-align: left; }

.jq-auth .form-row { display: flex; gap: 14px; }
.jq-auth .form-row .form-group { flex: 1; }

.jq-auth label,
.jq-auth .field-label {
  display: block;
  margin-bottom: 8px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-ink);
}

/* stessa forma di .jq-campo in joequiz.css, ma su una scheda gia' schiarita: il fondo
   del campo va piu' scuro dell'ink, o il bordo non si legge. */
.jq-auth input[type=text],
.jq-auth input[type=email],
.jq-auth input[type=tel],
.jq-auth input[type=date],
.jq-auth input[type=password],
.jq-auth select {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid color-mix(in oklch, var(--paper) 16%, transparent);
  border-radius: var(--radius);
  background: var(--auth-campo);
  color: var(--paper);
  font-family: var(--font-sans);
  font-size: 1.02rem;
  transition: border-color 0.15s;
}
.jq-auth input::placeholder { color: color-mix(in oklch, var(--paper) 40%, transparent); }
.jq-auth input:focus,
.jq-auth select:focus {
  border-color: var(--azzurro);
  outline: 3px solid var(--azzurro);
  outline-offset: 3px;
}
.jq-auth input[type=date] { color-scheme: dark; }

.jq-auth select {
  appearance: none;
  padding-right: 2.6rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23F9EFDB' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
}
.jq-auth select option { background: var(--ink); color: var(--paper); }

.jq-auth .hint { margin-top: 8px; font-size: 0.84rem; color: var(--muted-ink); }

.jq-auth .pw-wrap,
.jq-auth .input-wrapper { position: relative; }
.jq-auth .pw-wrap input,
.jq-auth .input-wrapper input { padding-right: 3.2rem; }
.jq-auth .pw-toggle,
.jq-auth .toggle-pw {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  padding: 4px;
  border: none;
  background: none;
  color: var(--muted-ink);
  cursor: pointer;
  transition: color 0.15s;
}
.jq-auth .pw-toggle:hover,
.jq-auth .toggle-pw:hover { color: var(--azzurro); }
.jq-auth .pw-toggle svg,
.jq-auth .toggle-pw svg {
  width: 20px; height: 20px;
  stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- le caselle del codice ---------- */

.jq-auth .otp-group {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 22px;
}
/* il codice e' un numero: mono e tabellare, come ogni cifra di JoeQUIZ. */
.jq-auth .otp-group input {
  flex: 1 1 0;
  min-width: 0;
  height: 66px;
  padding: 0;
  border: 2px solid color-mix(in oklch, var(--paper) 26%, transparent);
  border-radius: var(--radius);
  background: var(--auth-campo);
  color: var(--paper);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.7rem;
  font-weight: 600;
  text-align: center;
  caret-color: var(--azzurro);
}
.jq-auth .otp-group input.filled {
  border-color: var(--azzurro);
  background: color-mix(in oklch, var(--azzurro) 14%, var(--auth-campo));
}
.jq-auth .otp-group input.error { border-color: var(--flame); }

/* ---------- opzioni e spunte ---------- */

.jq-auth .form-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
  font-size: 0.94rem;
}
.jq-auth .form-options .remember,
.jq-auth .checkbox-group label {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  font-family: var(--font-sans);
  font-size: 0.94rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--auth-tenue);
}
.jq-auth .checkbox-group {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  font-size: 0.92rem;
  color: var(--auth-tenue);
}
.jq-auth input[type=checkbox] {
  width: 1.05rem;
  height: 1.05rem;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--azzurro);
}

/* ---------- bottoni: quelli di joequiz.css, non altri ---------- */

.jq-auth .btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--azzurro);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: filter 0.16s, transform 0.12s;
}
body.jq-pubblico .jq-auth a.btn-primary { color: var(--ink); }
.jq-auth .btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.jq-auth .btn-primary:active { transform: scale(0.985); }
.jq-auth .btn-primary:disabled,
.jq-auth .btn-primary.disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
  transform: none;
  filter: none;
}

.jq-auth .btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 10px;
  padding: 15px 16px;
  border: none;
  border-radius: var(--radius);
  outline: 2px solid var(--pub-bordo);
  outline-offset: -2px;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 0.98rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.16s;
}
body.jq-pubblico .jq-auth a.btn-secondary { color: var(--auth-tenue); }
.jq-auth .btn-secondary:hover { background: color-mix(in oklch, var(--paper) 8%, transparent); }

.jq-auth .button-container { text-align: center; }

/* ---------- errore ---------- */

.jq-auth .error-msg {
  margin-bottom: 14px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--flame);
}
.jq-auth .error-msg.visible { display: block; }

.jq-auth .callout.alert {
  background-color: color-mix(in oklch, var(--flame) 22%, var(--ink)) !important;
  color: var(--paper) !important;
  border: 1px solid var(--flame);
  border-radius: var(--radius);
}
.jq-auth .error-container {
  margin-bottom: 0 !important;
  padding: 0 !important;
  background-color: transparent !important;
  color: var(--flame) !important;
  font-size: initial !important;
}

/* ---------- link di servizio ---------- */

/* body.jq-pubblico a e' (0,1,2): senza prefisso queste perderebbero contro di lui. */
body.jq-pubblico .jq-auth .card-footer a,
body.jq-pubblico .jq-auth .form-options a,
body.jq-pubblico .jq-auth .checkbox-group a,
body.jq-pubblico .jq-auth .resend-link {
  color: var(--azzurro);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
body.jq-pubblico .jq-auth .card-footer a:hover,
body.jq-pubblico .jq-auth .form-options a:hover,
body.jq-pubblico .jq-auth .checkbox-group a:hover,
body.jq-pubblico .jq-auth .resend-link:hover { text-decoration: underline; }

.jq-auth .card-footer {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--pub-bordo);
  text-align: center;
  font-size: 0.94rem;
  color: var(--auth-tenue);
}

.jq-auth .resend-section {
  margin-top: 20px;
  font-size: 0.92rem;
  color: var(--auth-tenue);
}
.jq-auth .resend-link {
  border: none;
  background: none;
  padding: 0;
  font-family: var(--font-sans);
  font-size: 0.92rem;
}
body.jq-pubblico .jq-auth .resend-link.disabled,
.jq-auth .resend-link:disabled {
  color: var(--muted-ink);
  pointer-events: none;
  text-decoration: none;
}
.jq-auth .resend-section .timer {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--muted-ink);
}

.jq-auth .back-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 22px;
  font-size: 0.9rem;
  text-decoration: none;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: color 0.2s;
}
body.jq-pubblico .jq-auth .back-link { color: var(--muted-ink); }
body.jq-pubblico .jq-auth .back-link:hover { color: var(--paper); }
.jq-auth .back-link svg {
  width: 16px; height: 16px;
  stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- robustezza della password ---------- */

.jq-auth .password-strength { display: flex; gap: 5px; margin: 10px 0 5px; }
/* spigoli vivi: e' una barra, e le barre di JoeQUIZ non si arrotondano. */
.jq-auth .password-strength .bar {
  flex: 1;
  height: 5px;
  background: color-mix(in oklch, var(--paper) 14%, transparent);
  transition: background 0.3s;
}
.jq-auth .password-strength.strength-1 .bar:nth-child(1) { background: var(--flame); }
.jq-auth .password-strength.strength-2 .bar:nth-child(-n+2) { background: var(--answer-b); }
.jq-auth .password-strength.strength-3 .bar:nth-child(-n+3) { background: var(--azzurro); }
.jq-auth .password-strength.strength-4 .bar { background: var(--azzurro); }
.jq-auth .strength-label {
  margin-bottom: 8px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: left;
  color: var(--muted-ink);
}

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

.jq-auth .success-state { display: none; }
.jq-auth .success-state.visible { display: block; }
.jq-auth .success-state .success-icon {
  width: 64px;
  height: 64px;
  margin: 0 0 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: color-mix(in oklch, var(--azzurro) 20%, transparent);
}
.jq-auth .success-state .success-icon svg {
  width: 32px; height: 32px;
  stroke: var(--azzurro); fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.jq-auth .success-state h2 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.7rem;
  letter-spacing: -0.025em;
  line-height: 1.1;
}
.jq-auth .success-state p {
  margin-bottom: 26px;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--auth-tenue);
}

/* il template chiede questa classe per nascondere il passo che non tocca ancora, e
   nessun foglio del tema la definiva: i due passi restavano visibili insieme. */
.jq-auth .hidden,
.jq-auth .form-state.hidden { display: none; }

/* ---------- le differenze fra le cinque schermate ---------- */

.jq-auth .register-card { max-width: 520px; }
.jq-auth .verify-card,
.jq-auth .recovery-card,
.jq-auth .logout-card { max-width: 460px; }

/* qui il riquadro dell'errore sta sempre nel flusso: senza altezza minima la scheda
   sobbalza quando il messaggio compare. */
.jq-auth .login-card .error-msg,
.jq-auth .register-card .error-msg { min-height: 1.1rem; }

/* negli altri due il messaggio nasce dal template gia' scritto: resta fuori finche' il
   codice non e' sbagliato davvero. */
.jq-auth .verify-card .error-msg,
.jq-auth .recovery-card .error-msg { display: none; margin-top: -6px; }

.jq-auth .logout-card .subtitle {
  margin: 0 0 26px;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--auth-tenue);
}

/* ---------- telefono ---------- */

@media (max-width: 640px) {
  .jq-auth { padding: 28px 18px 44px; }
  .jq-auth .form-row { flex-direction: column; gap: 0; }
  /* affiancati andrebbero a capo tutti e due: meglio due righe intere che quattro spezzate. */
  .jq-auth .form-options { flex-direction: column; align-items: flex-start; gap: 12px; }
  .jq-auth .otp-group { gap: 6px; }
  .jq-auth .otp-group input { height: 58px; font-size: 1.4rem; }
}
