/* ============================================================
   MonOn AI — Auth pages (login, signup, email verification,
   password reset) in the calm design system.
   Depends on monon-ds.css (tokens, base, component classes).
   Centered single card on a warm radial wash — matches the DS
   Auth mock and the migrated landing page.
   ============================================================ */

body.auth {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(110% 70% at 50% 0%, var(--bg-tint-blue) 0%, var(--bg-page) 55%);
  background-attachment: fixed;
  color: var(--text-body);
  overflow-x: hidden;
}

/* ---------- Shell & card ---------- */
.auth-shell {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

.auth-card-wrap {
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  display: flex;
  justify-content: center;
  width: 100%;
  margin: 0 auto 22px;
}

.auth-card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  padding: 28px;
}

.auth-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 24px;
  color: var(--text-strong);
  margin: 0 0 4px;
  text-align: left;
}

.auth-sub {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 20px;
}

.auth-continue-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 8px;
}

.auth-continue-panel[hidden] {
  display: none !important;
}

.auth-continue-email {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-strong);
  margin: 0 0 4px;
  word-break: break-word;
}

.auth-continue-other {
  margin-top: 4px;
}

.auth-form { display: flex; flex-direction: column; gap: 14px; }

/* ---------- Fields (floating-label markup, DS look) ---------- */
.custom-form-floating { position: relative; }

.custom-label {
  display: block;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-strong);
  margin-bottom: 6px;
}

.auth-control { position: relative; display: block; }

.auth-input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: 17px;
  pointer-events: none;
  line-height: 1;
}

.custom-input {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--text-body);
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  transition: border-color var(--duration-normal) var(--ease-out),
              box-shadow var(--duration-normal) var(--ease-out);
}
.custom-input.has-icon { padding-left: 40px; }
.custom-input.has-toggle { padding-right: 44px; }
.custom-input::placeholder { color: var(--text-faint); }
.custom-input:hover { border-color: var(--border-strong); }
.custom-input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }

.custom-input.error { border-color: var(--clay-400); }
.custom-input.error:focus { box-shadow: 0 0 0 4px rgba(185, 123, 104, 0.18); }

/* Password visibility toggle */
.auth-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  font-size: 17px;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}
.auth-toggle:hover { background: var(--bg-sunken); color: var(--text-strong); }
.auth-toggle:focus-visible { outline: none; box-shadow: var(--ring); }

/* Inline field validation (clay, never red) */
.field-error {
  display: block;
  margin-top: 0.3rem;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--status-caution);
}

/* Two-column name row (signup) */
.auth-row { display: flex; gap: 12px; }
.auth-row .custom-form-floating { flex: 1; min-width: 0; }

/* ---------- Password strength meter (signup) ---------- */
.password-strength {
  position: relative;
  margin-top: 2px;
  padding-top: 13px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  min-height: 13px;
}
.password-strength::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--sand-200);
}
.password-strength::after {
  content: "";
  position: absolute;
  top: 0; left: 0;
  height: 6px;
  width: 0;
  border-radius: var(--radius-pill);
  background: var(--secondary);
  transition: width var(--duration-normal) var(--ease-out),
              background var(--duration-normal) var(--ease-out);
}
.password-strength.very-weak::after { width: 20%; background: var(--status-caution); }
.password-strength.weak::after { width: 40%; background: var(--status-caution); }
.password-strength.fair::after { width: 60%; background: var(--blue-600); }
.password-strength.good::after { width: 80%; background: var(--secondary); }
.password-strength.strong::after { width: 100%; background: var(--secondary); }
.password-strength.very-weak, .password-strength.weak { color: var(--status-caution); }
.password-strength.fair { color: var(--blue-700); }
.password-strength.good, .password-strength.strong { color: var(--secondary-hover); }

/* ---------- Buttons / divider ---------- */
.auth-form .mon-btn { width: 100%; }

.btn-spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  margin-right: 0.5em;
  border: 2px solid rgba(30, 39, 48, 0.25);
  border-top-color: var(--on-primary);
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
  vertical-align: middle;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text-faint);
  font-family: var(--font-sans);
  font-size: 13px;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

/* Google button — outline; keeps Google's own logo colours */
.google-btn { gap: 10px; }
.google-btn svg { flex: none; }

/* Terms acknowledgement text (signup) */
.auth-terms {
  margin: 2px 0 0;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}
.auth-terms a { color: var(--text-link); font-weight: 600; }

/* Forgot-password link under the password field */
.auth-forgot {
  margin: -4px 0 0;
  text-align: right;
  font-family: var(--font-sans);
  font-size: 13px;
}
.auth-forgot a { color: var(--text-link); }

/* Links under the card */
.auth-inline-link {
  margin: 14px 0 0;
  text-align: center;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-muted);
}
.auth-inline-link a { color: var(--text-link); cursor: pointer; }

.auth-alt {
  margin: 18px 0 0;
  text-align: center;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-muted);
}
.auth-alt a { color: var(--text-link); font-weight: 600; }

/* ---------- Email-verification specifics ---------- */
.auth-verify-icon {
  width: 72px;
  height: 72px;
  margin: 4px auto 18px;
  border-radius: var(--radius-pill);
  background: var(--primary-soft);
  color: var(--blue-600);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}
.auth-verify-email {
  display: inline-block;
  margin-top: 4px;
  color: var(--text-link);
  font-weight: 700;
}
.auth-note {
  margin-top: 8px;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-faint);
  text-align: center;
}

/* ---------- Google OAuth return overlay (calm re-skin) ---------- */
.auth-signing-in-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 5000;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: rgba(251, 248, 243, 0.94);
  color: var(--text-strong);
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 600;
}
.auth-signing-in-overlay:not([hidden]) { display: flex; }
.auth-signing-in-spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--primary-active);
  border-radius: 50%;
  animation: btn-spin 0.8s linear infinite;
}
html.auth-signing-in #authSigningInOverlay { display: flex; }
html.auth-signing-in .login-form,
html.auth-signing-in .signup-form {
  visibility: hidden;
  pointer-events: none;
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  .auth-card { padding: 22px; }
  .auth-row { flex-direction: column; gap: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .password-strength::after,
  .custom-input { transition: none; }
  .auth-signing-in-spinner, .btn-spinner { animation-duration: 1.4s; }
}

/* ---------- Account access policy modes (set by /api/auth_config.php) ---------- */

/* Educational-email hint: only when the require-edu flag is on. */
.auth-edu-hint {
  display: none;
  margin: 8px 2px 0;
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
}
html.monon-require-edu .auth-edu-hint { display: block; }

/* Unified "Continue with Google" intro: only in Google-only mode. */
.auth-google-intro { display: none; }
.auth-google-intro .auth-google-title {
  font-family: var(--font-serif);
  color: var(--text-strong);
  text-wrap: balance;
}
.auth-google-intro .auth-google-sub {
  margin-top: 6px;
  font-family: var(--font-sans);
  color: var(--text-muted);
  text-wrap: pretty;
}
html.monon-google-only .auth-google-intro { display: block; }

/* Google-only mode hides every email/password + guest affordance, keeping only
   the Google button. The edu hint is moot here (its field is hidden). */
html.monon-google-only .auth-title,
html.monon-google-only .auth-sub,
html.monon-google-only .auth-row,
html.monon-google-only .auth-form .custom-form-floating,
html.monon-google-only .auth-forgot,
html.monon-google-only .auth-terms,
html.monon-google-only #passwordStrength,
html.monon-google-only .auth-edu-hint,
html.monon-google-only .auth-form button[type="submit"],
html.monon-google-only .auth-divider,
html.monon-google-only .auth-alt,
html.monon-google-only #anonymousSignInBtn {
  display: none !important;
}
