/* =============================================================================
   auth.css — pagine pubbliche cauzioni.org (login, recupera_password,
   reset_password, setup).

   Direzione: tutto light, slate cool come il resto dell'app (cc theme).
   Brand identity restituita via ACCENTO navy MIA Consulting (#1a3766) su
   button, focus ring, brand shield, link hover. Niente pannello scuro,
   niente glassmorphism, niente side-stripe, niente bullet marketing.

   Layout: single-column centrato. Topbar minimale (brand + helpline),
   form al centro, mini footer. Stessa struttura per le 4 pagine; setup
   usa solo una card più larga.
   ============================================================================= */

/* Tutti i design token sono in assets/css/tokens.css, caricato prima
   di questo file. Qui solo regole UI specifiche delle pagine auth. */

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body.auth-body {
  font-family: 'Figtree', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--auth-surface);
  color: var(--auth-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ----------------------------- shell -------------------------------------- */

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 1.5rem clamp(1rem, 4vw, 2rem);
}

/* Topbar minimale: brand a sinistra, link assistenza a destra.
   Non è una full app shell, è il minimo per non lasciare l'utente smarrito. */
.auth-topbar {
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 0 0;
}
.auth-topbar a { text-decoration: none; }
.auth-topbar .topbar-help {
  color: var(--auth-muted);
  font-size: 0.875rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  /* Touch target ≥ 44px su mobile senza spostare il layout
     (negative margin compensa il padding). Audit P2 fix. */
  padding: 0.5rem 0.75rem;
  margin: -0.5rem -0.75rem;
  border-radius: var(--auth-radius-md);
}
.auth-topbar .topbar-help:hover { color: var(--auth-accent); }

.auth-brandline {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.015em;
  color: var(--auth-ink);
}
.auth-brandline .brand-shield {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border-radius: 7px;
  background: var(--auth-accent);  /* navy MIA — l'unico accento brand */
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.auth-brandline .brand-mark { color: var(--auth-ink); }
.auth-brandline .brand-tld  { color: var(--auth-muted); font-weight: 500; }

/* ----------------------------- main: form centrato ----------------------- */

.auth-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(2rem, 6vh, 4rem) 0;
}

.auth-card {
  width: 100%;
  max-width: 25rem;
  background: var(--auth-card);
  border: 1px solid var(--auth-line);
  border-radius: var(--auth-radius-lg);
  box-shadow: var(--auth-shadow-md);
  padding: clamp(1.75rem, 4vw, 2.4rem);
  animation: auth-rise 0.45s var(--auth-ease) both;
}

@keyframes auth-rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* Rispetta la preferenza utente per il movimento ridotto.
   Audit positive finding → made explicit. */
@media (prefers-reduced-motion: reduce) {
  .auth-card { animation: none; }
}

.auth-eyebrow {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--auth-muted);
  margin: 0;
}

.auth-title {
  margin: 0.55rem 0 0.45rem;
  font-size: 1.625rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--auth-ink);
  line-height: 1.22;
}

/* Variante editorial: solo sulla "porta d'ingresso" (login.php).
   Serif Fraunces italic + opsz alto come segno istituzionale italiano.
   Niente effetto su recupera/reset/setup, che restano Figtree per non
   trascinare il peso del font dove non serve. */
.auth-title-editorial {
  font-family: 'Fraunces', 'Georgia', serif;
  font-size: clamp(2rem, 4vw, 2.5rem);
  font-weight: 400;
  font-style: italic;
  font-variation-settings: 'opsz' 96;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--auth-ink);
  margin: 0.4rem 0 0.55rem;
}

.auth-lead {
  margin: 0 0 1.5rem;
  font-size: 0.94rem;
  color: var(--auth-body);
  max-width: 36ch;
}

/* ----------------------------- form fields -------------------------------- */

.auth-field { display: block; margin-bottom: 1rem; }
.auth-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
  margin-bottom: 1rem;
}
.auth-field-row > .auth-field { margin-bottom: 0; }

.auth-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--auth-strong);
  margin-bottom: 0.35rem;
}

.auth-control {
  display: block;
  width: 100%;
  background: var(--auth-card);
  border: 1px solid var(--auth-line);
  border-radius: var(--auth-radius-md);
  padding: 0.72rem 0.85rem;
  font: inherit;
  color: var(--auth-ink);
  transition: border-color 0.18s var(--auth-ease), box-shadow 0.18s var(--auth-ease);
}
.auth-control::placeholder { color: var(--auth-muted); }
.auth-control:hover { border-color: oklch(0.86 0.007 264); }
.auth-control:focus {
  outline: 0;
  border-color: var(--auth-accent);
  box-shadow: 0 0 0 3px var(--auth-accent-ring);
}

.auth-control.with-icon { padding-left: 2.4rem; }
.auth-field-icon { position: relative; }
.auth-field-icon > .bi {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--auth-muted);
  font-size: 1rem;
  pointer-events: none;
}

.auth-row-helper {
  display: flex;
  justify-content: flex-end;
  margin-top: -0.55rem;
  margin-bottom: 1.1rem;
}
.auth-row-helper a {
  font-size: 0.8125rem;
  color: var(--auth-body);
  text-decoration: none;
  font-weight: 500;
  /* Hit area ≥ 44px senza spostare il layout. Audit P2 fix. */
  padding: 0.5rem 0.625rem;
  margin: -0.5rem -0.625rem;
  border-radius: var(--auth-radius-sm);
}
.auth-row-helper a:hover { color: var(--auth-accent); text-decoration: underline; }

/* ----------------------------- button (navy MIA) ------------------------- */

.auth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.78rem 1rem;
  background: var(--auth-accent);
  color: #ffffff;
  border: 1px solid var(--auth-accent);
  border-radius: var(--auth-radius-md);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s var(--auth-ease), border-color 0.18s var(--auth-ease), transform 0.12s var(--auth-ease);
  text-decoration: none;
}
.auth-btn:hover {
  background: var(--auth-accent-hover);
  border-color: var(--auth-accent-hover);
  color: #ffffff;
  transform: translateY(-1px);
}
.auth-btn:active {
  background: var(--auth-accent-active);
  border-color: var(--auth-accent-active);
  transform: translateY(0);
}
.auth-btn:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px var(--auth-accent-ring);
}
.auth-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.auth-btn .bi { font-size: 0.95rem; }

.auth-btn-quiet {
  background: var(--auth-card);
  border-color: var(--auth-line);
  color: var(--auth-ink);
}
.auth-btn-quiet:hover {
  background: var(--auth-line-soft);
  border-color: oklch(0.86 0.007 264);
  color: var(--auth-ink);
}

/* ----------------------------- alerts ------------------------------------- */

.auth-alert {
  display: grid;
  grid-template-columns: 1.25rem 1fr;
  gap: 0.65rem;
  align-items: start;
  padding: 0.75rem 0.9rem;
  border-radius: var(--auth-radius-md);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}
.auth-alert .bi { margin-top: 0.2rem; }
/* Allineato ai --sem-* di app.css: stessa palette semantica in tutta l'app. */
.auth-alert-danger  { background: oklch(0.95 0.04 25);  color: oklch(0.46 0.16 27);  border: 1px solid oklch(0.88 0.06 25); }
.auth-alert-success { background: oklch(0.95 0.05 150); color: oklch(0.42 0.13 150); border: 1px solid oklch(0.87 0.06 150); }
.auth-alert-info    { background: var(--auth-line-soft); color: var(--auth-ink);     border: 1px solid var(--auth-line); }

/* ----------------------------- helper text -------------------------------- */

.auth-helper {
  margin-top: 1.25rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--auth-body);
}
.auth-helper a {
  color: var(--auth-accent);
  font-weight: 600;
  text-decoration: none;
}
.auth-helper a:hover { text-decoration: underline; }

.auth-hint {
  font-size: 0.8125rem;
  margin-top: 0.35rem;
  min-height: 1em;
  color: var(--auth-muted);
}
.auth-hint.ok { color: oklch(0.5 0.14 150); }
.auth-hint.ko { color: oklch(0.52 0.18 27); }

/* ----------------------------- footer ------------------------------------- */

.auth-foot {
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--auth-muted);
  padding: 0.5rem 0;
}
.auth-foot a { color: var(--auth-muted); text-decoration: none; }
.auth-foot a:hover { color: var(--auth-accent); }

@media (max-width: 540px) {
  .auth-foot { flex-direction: column; gap: 0.35rem; text-align: center; }
}

/* ----------------------------- logo image --------------------------------- */
/* Il marchio MIA Consulting reale, sostituisce il brand-shield "MC" placeholder. */
.auth-logo-img {
  height: 30px;
  width: auto;
  display: block;
}

/* ----------------------------- variante setup ----------------------------- */
/* setup.php ha più campi: stessa griglia, card più ampia. Nessuna divergenza
   visiva: solo +7rem di larghezza per ospitare i 2 form-row. */
.auth-shell-wide .auth-card { max-width: 32rem; }

/* ----------------------------- variante split (login con foto) ----------- */
/* login.php ha trattamento "porta d'ingresso": split layout con foto
   istituzionale sinistra + form destra. La foto NON viene scurita con un
   overlay navy heavy (era esattamente quello che ci ha portato fuori strada):
   solo un wash chiaro per ammorbidire. Mobile: la foto sparisce, il form
   occupa tutto lo schermo come nelle altre pagine. */

.auth-shell-split {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
}

.auth-photo {
  position: relative;
  background-size: cover;
  background-position: center;
  isolation: isolate;
  overflow: hidden;
}
/* La foto viene caricata SOLO da desktop ≥ 960px, dove è effettivamente
   visibile. Su mobile il pannello è display:none e risparmiamo 100-300 KB
   di banda (audit P2 fix). */
@media (min-width: 960px) {
  .auth-photo {
    background-image: url('https://images.unsplash.com/photo-1486406146926-c627a92ad1ab?w=1600&q=80&auto=format&fit=crop');
  }
}

.auth-photo::after {
  content: "";
  position: absolute;
  inset: 0;
  /* Wash chiaro: ammorbidisce la foto senza scurirla. Niente navy heavy. */
  background:
    linear-gradient(160deg, oklch(0.985 0.003 264 / 0.18) 0%, oklch(0.92 0.006 264 / 0.05) 60%, transparent 100%);
  pointer-events: none;
}

/* Overlay localizzato sotto il tag bottom-left: garantisce contrast ≥ 4.5:1
   sul tag bianco anche se la zona della foto è bright (skyscrapers riflettenti).
   Audit P2 fix. */
.auth-photo::before {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 8rem;
  background: linear-gradient(to top,
    oklch(0.21 0.012 264 / 0.55) 0%,
    oklch(0.21 0.012 264 / 0.25) 50%,
    transparent 100%);
  pointer-events: none;
  z-index: 0;
}

.auth-photo-tag {
  position: absolute;
  left: clamp(1.5rem, 3vw, 2.5rem);
  bottom: clamp(1.5rem, 3vw, 2.5rem);
  color: oklch(0.98 0.003 264);
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(15, 23, 42, 0.45);
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.auth-photo-tag::before {
  content: "";
  display: inline-block;
  width: 28px; height: 1px;
  background: oklch(0.98 0.003 264);
  opacity: 0.85;
}

.auth-split-form-area {
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 1.5rem clamp(1rem, 4vw, 2rem);
}

@media (max-width: 960px) {
  .auth-shell-split { grid-template-columns: 1fr; min-height: 100vh; }
  .auth-photo { display: none; }
}
