/* Auth overlay — sign-in / forgot-password / set-password.
   Card-overlay pattern adapted from Reverie's login-screen, in
   Fold's class-driven style (no inline styles). The three forms
   live inside one card; .auth-overlay[data-state="..."] toggles
   which one is visible.

   Bug noticed in this file? Cross-check Reverie + Practice — they
   share the Supabase flow, each has its own UI implementation. */

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: var(--space-lg);
  font-family: var(--font-ui);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: var(--space-xl) var(--space-lg);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-md);
}

.auth-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 2rem;
  letter-spacing: 0.04em;
  color: var(--fg-strong);
  margin: 0;
  text-align: center;
}

.auth-subtitle {
  margin: 0;
  font-size: 0.85rem;
  color: var(--fg-dim);
  text-align: center;
  letter-spacing: 0.02em;
}

.auth-creator {
  margin: 0 0 var(--space-md);
  font-size: 0.7rem;
  color: var(--fg-muted);
  text-align: center;
}

/* Hide all forms by default; data-state on overlay reveals one. */
.auth-form,
.auth-success,
.auth-link-forgot,
.auth-link-signup,
.auth-link-back-signin,
.auth-error-expired { display: none; }

/* Forms get display:flex (column layout); links + the signup-prompt
   line get display:block so text-align:center centers their text.
   Inline-anchor with display:flex would treat text-align as no-op. */
.auth-overlay[data-state="signin"] .auth-form-signin { display: flex; }
.auth-overlay[data-state="signin"] .auth-link-forgot,
.auth-overlay[data-state="signin"] .auth-link-signup { display: block; }

.auth-overlay[data-state="forgot"] .auth-form-forgot { display: flex; }
.auth-overlay[data-state="forgot"] .auth-link-back-signin { display: block; }

.auth-overlay[data-state="forgot-success"] .auth-success-forgot { display: flex; }
.auth-overlay[data-state="forgot-success"] .auth-link-back-signin { display: block; }

.auth-overlay[data-state="setpassword"] .auth-form-setpassword { display: flex; }

.auth-overlay[data-state="setpassword-expired"] .auth-error-expired { display: block; }
.auth-overlay[data-state="setpassword-expired"] .auth-link-back-signin { display: block; }

/* Form layout — column with consistent gap. */
.auth-form {
  flex-direction: column;
  gap: var(--space-sm);
  margin: 0;
}

.auth-instruction {
  margin: 0 0 var(--space-xs);
  font-size: 0.85rem;
  color: var(--fg);
  line-height: 1.5;
}

.auth-input {
  padding: 0.65rem 0.9rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--fg-strong);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color var(--t-fast);
}

.auth-input:focus {
  outline: none;
  border-color: var(--gold);
}

.auth-input::placeholder { color: var(--fg-muted); }

/* Password field with show/hide toggle on the right. */
.auth-pw-wrap {
  position: relative;
  display: flex;
}

.auth-pw-wrap .auth-input {
  flex: 1;
  padding-right: 3rem;
}

.auth-pw-toggle {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--fg-dim);
  font-family: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
}

.auth-pw-toggle:hover { color: var(--fg); }

.auth-submit {
  margin-top: var(--space-xs);
  padding: 0.7rem 1rem;
  border-radius: 4px;
  border: 1px solid var(--gold);
  background: transparent;
  color: var(--fg-strong);
  font-family: inherit;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background var(--t-fast);
}

.auth-submit:hover { background: var(--gold-faint); }

.auth-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.auth-link {
  margin: var(--space-xs) 0 0;
  font-size: 0.8rem;
  color: var(--fg-dim);
  text-decoration: none;
  text-align: center;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.auth-link:hover { color: var(--fg); }

.auth-link-signup {
  margin: 0;
  font-size: 0.8rem;
  color: var(--fg-dim);
  text-align: center;
}

.auth-link-signup a {
  color: var(--fg);
  margin-left: 0.3em;
}

.auth-link-signup a:hover { color: var(--fg-strong); }

.auth-success { flex-direction: column; gap: var(--space-sm); }

.auth-success h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 400;
  color: var(--fg-strong);
  text-align: center;
}

.auth-success p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--fg);
  text-align: center;
  line-height: 1.5;
}

.auth-error,
.auth-error-expired {
  margin: 0;
  font-size: 0.85rem;
  color: #c34a4a;
  min-height: 1em;
  text-align: center;
}

.auth-error:empty { min-height: 0; }

body.dark .auth-error,
body.dark .auth-error-expired { color: #e57878; }
