/* MeMori — accesso e benvenuto nello stile «Ritagli» (28/10/2026, prova in tools/prova-accesso).
 * Accesso (#auth-view): sul PC a sinistra il «manifesto» (nome, «La tua libreria, a modo tuo», la pila
 * di dorsi dritti sul piano senape), a destra il foglio di carta con l'ombra d'inchiostro: Accedi /
 * Registrati in una pillola, campi arrotondati, l'occhio per la password, la barra della robustezza,
 * il codice d'invito come un biglietto tratteggiato, il grande bottone senape. Sul telefono il
 * manifesto si accorcia (senza la pila) e il foglio viene subito.
 * Benvenuto (#welcome-dialog): il foglio delle finestre (sul telefono sale dal basso), i passi come
 * barrette, un bollino con l'icona di ogni passo, le scelte in pillole, «Così ti vedranno», i tre
 * ritagli dell'ultimo passo. Caratteri e colori: ritagli.css. */

/* --- Accesso -------------------------------------------------------------------------------- */
#auth-view {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 3rem;
  align-items: center;
  min-height: calc(100dvh - 4rem);
  font-family: var(--rt-body);
  color: var(--rt-ink);
}

#auth-view[hidden] {
  display: none;
}

#auth-view > :not(.ax-blobs) {
  position: relative;
  z-index: 1;
}

.ax-blobs {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: clip;
  pointer-events: none;
}

.ax-blob {
  position: absolute;
}

.ax-blob path,
.ax-blob circle {
  fill: currentColor;
}

.ax-blob-1 {
  right: -160px;
  top: -80px;
  width: 520px;
  color: var(--rt-blush);
}

.ax-blob-2 {
  left: -70px;
  bottom: -70px;
  width: 260px;
  color: var(--rt-sage);
}

.ax-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.6rem;
}

.ax-brand .wordmark {
  font: 800 1.6rem var(--rt-display);
  letter-spacing: -0.02em;
}

.ax-brand .wordmark small {
  margin-left: 0.3rem;
  color: var(--muted);
  font: 600 0.9rem var(--rt-body);
}

.ax-claim {
  margin: 0;
  font: 800 clamp(2.3rem, 5.5vw, 4rem) / 0.9 var(--rt-display);
  letter-spacing: -0.05em;
  text-transform: none;
}

.ax-claim em {
  font-style: normal;
  background: radial-gradient(closest-side, var(--rt-accent) 98%, transparent) 0 92% / 100% 30% no-repeat;
}

.ax-sub {
  max-width: 34ch;
  margin: 1rem 0 1.6rem;
  color: var(--muted);
  font-size: 1.05rem;
}

/* La pila di dorsi dritti, come nella Pila. */
.ax-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 360px;
}

.ax-stack i {
  display: block;
  margin-top: -1px;
  border-radius: 4px 8px 6px 3px;
}

.ax-stack i:nth-child(1) { width: 330px; height: 32px; margin-left: 4px; background: #b0453a; }
.ax-stack i:nth-child(2) { width: 290px; height: 24px; margin-left: 18px; background: #7d8c6e; }
.ax-stack i:nth-child(3) { width: 250px; height: 30px; margin-left: 40px; background: #c29a2c; }
.ax-stack i:nth-child(4) { width: 320px; height: 22px; margin-left: 10px; background: #a65a3e; }
.ax-stack i:nth-child(5) { width: 270px; height: 36px; margin-left: 30px; background: #2f5d62; }
.ax-stack i:nth-child(6) { width: 300px; height: 26px; margin-left: 0; background: #5b4b8a; }

.ax-floor {
  display: block;
  width: 100%;
  height: 10px;
  margin-top: 2px;
  border-radius: 3px 6px 30px 26px;
  background: var(--rt-accent);
  box-shadow: 0 4px 0 var(--rt-ink);
}

/* Il foglio. */
.ax-sheet {
  padding: 1.8rem;
  border: 2px solid var(--rt-ink);
  border-radius: 30px 24px 34px 26px;
  background: var(--rt-paper);
  box-shadow: 8px 8px 0 var(--rt-ink);
}

.ax-tabs {
  display: inline-flex;
  margin-bottom: 1.3rem;
  padding: 3px;
  border: 2px solid var(--rt-ink);
  border-radius: 999px;
}

.ax-tabs[hidden] {
  display: none;
}

.ax-tabs .tab {
  padding: 0.45rem 1.1rem;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--rt-ink);
  font: 700 0.95rem var(--rt-body);
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
}

.ax-tabs .tab[aria-selected="true"] {
  background: var(--rt-ink);
  color: var(--rt-paper);
}

.ax-form {
  display: block;
}

.ax-form[hidden] {
  display: none;
}

.ax-form h2 {
  margin: 0 0 0.4rem;
  font: 800 1.6rem/1 var(--rt-display);
  letter-spacing: -0.02em;
  text-transform: none;
}

.ax-hint {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Campi: arrotondati col bordo d'inchiostro (anche nel benvenuto). */
.ax-field {
  display: grid;
  gap: 0.3rem;
  margin-bottom: 0.9rem;
  font-weight: 700;
  font-size: 0.85rem;
}

:is(#auth-view, #welcome-dialog) .ax-field input,
#welcome-dialog .username-field {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 2px solid var(--rt-ink);
  border-radius: 16px;
  background: var(--rt-bg);
  color: var(--rt-ink);
  font: 500 0.95rem var(--rt-body);
  box-shadow: none;
}

:is(#auth-view, #welcome-dialog) .ax-field input:focus-visible,
#welcome-dialog .username-field:focus-within {
  outline: 3px solid var(--rt-accent);
  outline-offset: 2px;
}

.ax-field small {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.76rem;
}

/* La password con l'occhio dentro il campo. */
.ax-pass {
  position: relative;
  display: block;
}

#auth-view .ax-pass input {
  padding-right: 3rem;
}

/* Solo il nostro occhio: niente quello di Edge. */
#auth-view .ax-pass input::-ms-reveal,
#auth-view .ax-pass input::-ms-clear {
  display: none;
}

.ax-eye {
  position: absolute;
  top: 50%;
  right: 0.5rem;
  translate: 0 -50%;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  font-size: 1rem;
  cursor: pointer;
  opacity: 0.55;
}

.ax-eye[aria-pressed="true"] {
  opacity: 1;
  background: var(--rt-accent);
}

.ax-eye:focus-visible {
  outline: 3px solid var(--rt-accent);
  opacity: 1;
}

/* La robustezza: quattro tacche che si colorano (corallo → salvia scura). */
.ax-strength {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
  margin-top: 0.35rem;
}

.ax-strength i {
  height: 6px;
  border-radius: 99px;
  background: var(--rt-bg);
  box-shadow: inset 0 0 0 1px var(--rt-ink);
}

.ax-strength i.on {
  box-shadow: none;
}

.ax-strength[data-score="0"] i.on,
.ax-strength[data-score="1"] i.on {
  background: #e9785a;
}

.ax-strength[data-score="2"] i.on {
  background: #e0a518;
}

.ax-strength[data-score="3"] i.on {
  background: #c3cbb0;
}

.ax-strength[data-score="4"] i.on {
  background: #7d8c6e;
}

/* Il codice d'invito come un biglietto. */
.ax-ticket {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1rem;
  padding: 0.8rem 1rem;
  border: 2px dashed var(--rt-ink);
  border-radius: 18px;
  background: #f3cfc3;
  color: #161616;
  font-weight: 700;
  font-size: 0.8rem;
}

.ax-ticket > i {
  font-style: normal;
  font-size: 1.6rem;
}

.ax-ticket > span {
  display: grid;
  flex: 1;
  gap: 0.2rem;
  min-width: 0;
}

#auth-view .ax-ticket input {
  width: 100%;
  padding: 0.2rem 0;
  border: 0;
  border-bottom: 2px solid #161616;
  border-radius: 0;
  background: none;
  color: #161616;
  font: 800 1.1rem var(--rt-display);
  letter-spacing: 0.08em;
  box-shadow: none;
}

#auth-view .ax-ticket input::placeholder {
  color: rgb(22 22 22 / 0.4);
}

#auth-view .ax-ticket input:focus-visible {
  outline: 3px solid var(--rt-accent);
  outline-offset: 2px;
}

.ax-ticket small {
  color: rgb(22 22 22 / 0.7);
  font-weight: 400;
  font-size: 0.74rem;
}

.ax-go {
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.85rem 1.2rem;
  border: 0;
  border-radius: 22px 28px 24px 26px;
  background: var(--rt-accent);
  color: var(--rt-accent-ink);
  font: 800 1.05rem var(--rt-display);
  box-shadow: 4px 4px 0 var(--rt-ink);
  cursor: pointer;
}

.ax-go:disabled {
  opacity: 0.6;
  cursor: progress;
}

.ax-go:focus-visible {
  outline: 3px solid var(--rt-ink);
  outline-offset: 3px;
}

.ax-link {
  display: block;
  margin: 0.9rem auto 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--rt-ink);
  font: 600 0.88rem var(--rt-body);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.ax-link:focus-visible {
  outline: 3px solid var(--rt-accent);
  outline-offset: 2px;
}

/* «Controlla la posta» dopo l'iscrizione e «Ancora un passo» (il codice dell'accesso in due
   passaggi): l'icona in un bollino senape (.ax-icon), l'indirizzo in evidenza. */
.ax-sent,
.ax-code {
  text-align: center;
}

.ax-code .ax-field {
  text-align: left;
}

/* Il codice dell'app: cifre grandi e spaziate, centrate. */
#auth-view .ax-code input[name="code"] {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.3em;
}

.ax-icon {
  display: inline-grid;
  place-items: center;
  width: 4.2rem;
  height: 4.2rem;
  margin-bottom: 0.8rem;
  border-radius: 50%;
  background: var(--rt-accent);
  box-shadow: 4px 4px 0 var(--rt-ink);
  font-size: 2rem;
}

.ax-sent strong {
  color: var(--rt-ink);
  overflow-wrap: anywhere;
}

.ax-lock {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

#auth-view .form-error:empty,
#auth-view .form-success:empty {
  display: none;
}

#auth-view .form-error {
  margin: 0 0 0.8rem;
  padding: 0.55rem 0.8rem;
  border-radius: 14px;
  background: color-mix(in srgb, var(--rt-coral) 22%, transparent);
  color: var(--rt-ink);
  font-size: 0.85rem;
  font-weight: 600;
}

#auth-view .form-success {
  margin: 0 0 0.8rem;
  padding: 0.55rem 0.8rem;
  border-radius: 14px;
  background: #c3cbb0;
  color: #161616;
  font-size: 0.85rem;
  font-weight: 600;
}

.auth-lang {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  margin: 1.2rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.auth-lang .ax-link {
  display: inline;
  margin: 0;
}

/* --- Benvenuto ------------------------------------------------------------------------------ */
dialog.welcome-dialog {
  width: min(620px, calc(100vw - 64px));
  max-height: calc(100vh - 64px);
  padding: 0;
  overflow: hidden;
  border: 2px solid var(--rt-ink);
  border-radius: 30px 24px 34px 26px;
  background: var(--rt-paper);
  color: var(--rt-ink);
  font-family: var(--rt-body);
  box-shadow: 8px 8px 0 var(--rt-ink);
}

dialog.welcome-dialog::backdrop {
  background: color-mix(in srgb, var(--rt-ink) 38%, transparent);
}

.wl-form {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 68px);
}

.wl-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 26px 26px 18px;
}

#welcome-dialog .welcome-progress {
  display: flex;
  gap: 0.4rem;
  margin: 0 0 1.2rem;
  padding: 0;
  list-style: none;
}

#welcome-dialog .welcome-progress li {
  flex: 1;
  height: 8px;
  border-radius: 99px;
  background: var(--rt-bg);
  box-shadow: inset 0 0 0 1.5px var(--rt-ink);
  opacity: 1;
}

#welcome-dialog .welcome-progress li.done {
  background: var(--rt-ink);
  box-shadow: none;
}

#welcome-dialog .welcome-progress li.current {
  background: var(--rt-accent);
  box-shadow: none;
}

.welcome-step[hidden] {
  display: none;
}

.wl-top {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 0.6rem;
}

.wl-bubble {
  display: grid;
  flex: none;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 55% 45% 50% 50% / 50% 55% 45% 50%;
  font-size: 1.7rem;
  box-shadow: 3px 3px 0 var(--rt-ink);
  rotate: -6deg;
}

.wl-b-accent { background: #e0a518; }
.wl-b-sage { background: #c3cbb0; }
.wl-b-blush { background: #f3cfc3; }
.wl-b-coral { background: #e9785a; }

.wl-count {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.78rem;
}

#welcome-dialog h2 {
  margin: 0;
  font: 800 1.9rem/1 var(--rt-display);
  letter-spacing: -0.03em;
  text-transform: none;
}

.wl-hint {
  margin: 0.5rem 0 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Username con la @ davanti, dentro il campo. */
#welcome-dialog .username-field {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0 0.9rem;
}

#welcome-dialog .username-field > span {
  color: var(--muted);
  font-weight: 700;
}

#welcome-dialog .username-field input {
  flex: 1;
  min-width: 0;
  padding: 0.65rem 0;
  border: 0;
  border-radius: 0;
  background: none;
  outline: none;
}

.username-state {
  justify-self: start;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: #c3cbb0;
  color: #161616;
  font-size: 0.75rem;
  font-weight: 700;
}

.username-state:empty {
  display: none;
}

.username-state.taken {
  background: #e9785a;
}

/* «Così ti vedranno»: come un profilo in Lettori. */
.wl-card {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 0.9rem;
  border-radius: 18px;
  background: var(--rt-bg);
}

.wl-ini {
  display: grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 55% 45% 50% 50% / 50% 55% 45% 50%;
  background: hsl(var(--hue, 30) 55% 72%);
  color: #161616;
  font: 800 1.2rem var(--rt-display);
  box-shadow: 2px 2px 0 var(--rt-ink);
}

.wl-card b {
  display: block;
  font: 800 1rem var(--rt-display);
  overflow-wrap: anywhere;
}

.wl-card small {
  color: var(--muted);
  font-size: 0.76rem;
}

/* Pillole: lingua dell'app e aspetto (una sola), lingue e generi (quante si vuole). */
.wl-toggle {
  display: inline-flex;
  flex-wrap: wrap;
  min-width: 0;
  margin: 0;
  padding: 3px;
  border: 2px solid var(--rt-ink);
  border-radius: 999px;
}

.wl-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

:is(.wl-toggle, .wl-chips) label {
  position: relative;
  cursor: pointer;
}

:is(.wl-toggle, .wl-chips) input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.wl-toggle span {
  display: block;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  font-weight: 600;
}

.wl-toggle input:checked + span {
  background: var(--rt-ink);
  color: var(--rt-paper);
}

.wl-chips span,
#welcome-dialog .interest-chip {
  display: block;
  padding: 0.4rem 0.9rem;
  border: 2px solid var(--rt-ink);
  border-radius: 999px;
  background: none;
  color: var(--rt-ink);
  font: 600 0.85rem var(--rt-body);
  letter-spacing: 0;
  text-transform: none;
  text-decoration: none;
  opacity: 1;
  cursor: pointer;
}

.wl-chips input:checked + span {
  background: #e0a518;
  color: #161616;
}

#welcome-dialog .welcome-interests {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

#welcome-dialog .interest-chip[aria-pressed="true"] {
  background: #e0a518;
  color: #161616;
}

#welcome-dialog .interest-chip:nth-child(4n + 2)[aria-pressed="true"] { background: #e9785a; }
#welcome-dialog .interest-chip:nth-child(4n + 3)[aria-pressed="true"] { background: #c3cbb0; }
#welcome-dialog .interest-chip:nth-child(4n + 4)[aria-pressed="true"] { background: #f3cfc3; }

:is(.wl-toggle, .wl-chips) input:focus-visible + span,
#welcome-dialog .interest-chip:focus-visible {
  outline: 3px solid var(--rt-accent);
  outline-offset: 2px;
}

/* L'ultimo passo: tre ritagli. */
#welcome-dialog .welcome-start {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
}

.wl-tile {
  display: grid;
  align-content: start;
  gap: 0.2rem;
  padding: 1rem;
  border: 2px solid var(--rt-ink);
  border-radius: 22px 18px 24px 20px;
  color: #161616;
  font-family: var(--rt-body);
  text-align: left;
  cursor: pointer;
  transition: translate 0.15s ease, box-shadow 0.15s ease;
}

.wl-t-accent { background: #e0a518; }
.wl-t-blush { background: #f3cfc3; }
.wl-t-sage { background: #c3cbb0; }

.wl-tile i {
  font-style: normal;
  font-size: 1.5rem;
}

.wl-tile b {
  font: 800 1rem var(--rt-display);
}

.wl-tile span {
  font-size: 0.75rem;
  opacity: 0.8;
}

.wl-tile:hover {
  translate: -2px -2px;
  box-shadow: 4px 4px 0 var(--rt-ink);
}

.wl-tile:focus-visible {
  outline: 3px solid var(--rt-ink);
  outline-offset: 3px;
}

#welcome-dialog .form-error:empty {
  display: none;
}

.wl-foot {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 14px 26px 18px;
  border-top: 2px dashed color-mix(in srgb, var(--muted) 45%, transparent);
}

.wl-foot .spacer {
  flex: 1;
}

.wl-skip {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: 600 0.92rem var(--rt-body);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.wl-back {
  padding: 0.55rem 1rem;
  border: 2px solid var(--rt-ink);
  border-radius: 999px;
  background: none;
  color: var(--rt-ink);
  font: 700 0.92rem var(--rt-body);
  cursor: pointer;
}

.wl-next {
  padding: 0.65rem 1.3rem;
  border: 0;
  border-radius: 22px 28px 24px 26px;
  background: var(--rt-accent);
  color: var(--rt-accent-ink);
  font: 800 1rem var(--rt-display);
  box-shadow: 4px 4px 0 var(--rt-ink);
  cursor: pointer;
}

:is(.wl-skip, .wl-back, .wl-next):focus-visible {
  outline: 3px solid var(--rt-accent);
  outline-offset: 2px;
}

:is(.wl-skip, .wl-back, .wl-next)[hidden] {
  display: none;
}

/* --- Telefono -------------------------------------------------------------------------------- */
@media (max-width: 760px) {
  #auth-view {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.4rem;
    align-content: start;
    min-height: 0;
  }

  .ax-brand {
    margin-bottom: 1rem;
  }

  .ax-sub {
    margin: 0.7rem 0 0;
    font-size: 0.95rem;
  }

  .ax-stack {
    display: none;
  }

  .ax-sheet {
    padding: 1.3rem 1.1rem;
    box-shadow: 5px 5px 0 var(--rt-ink);
  }

  dialog.welcome-dialog {
    width: 100vw;
    max-width: 100vw;
    max-height: calc(100dvh - 38px);
    margin: auto 0 0;
    border-width: 2px 0 0;
    border-radius: 28px 28px 0 0;
    box-shadow: none;
  }

  .wl-form {
    max-height: calc(100dvh - 40px);
  }

  .wl-body {
    padding: 22px 16px 14px;
  }

  #welcome-dialog h2 {
    font-size: 1.5rem;
  }

  #welcome-dialog .welcome-start {
    grid-template-columns: minmax(0, 1fr);
  }

  .wl-foot {
    padding: 12px 16px 18px;
  }
}
