/* Auth pages: shared styles for /login, /signup, /forgot-password,
   /reset-password, /check-email, /verify-email, /accept-invitation.

   Design language: card-based split layout — left visual panel
   (deep green, Serochat brand reinforcement) + right form panel
   (clean white, focused form). Sits centered on a muted paper
   background. On small screens the visual panel collapses and the
   form takes the full card.
*/

/* ---------- Page shell ---------- */
.auth-body {
  min-height: 100vh;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
}

.auth-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 40px 20px;
  width: 100%;
  color: var(--ink);
}

/* Centered Serochat logo sitting above the auth card */
.auth-pagelogo {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--ink);
}
.auth-pagelogo svg { color: var(--ink); }

/* ---------- Card ---------- */
.auth-card {
  width: min(1080px, 100%);
  min-height: 640px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(26,43,60,0.04);
  animation: auth-card-in 520ms var(--ease-out-soft, cubic-bezier(0.16, 1, 0.3, 1)) both;
}
@keyframes auth-card-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .auth-card { animation: none; }
}

/* ============================================================
   LEFT — visual panel
============================================================ */
.auth-visual {
  --auth-ivory: #F2EFE8;
  position: relative;
  background: #0F3B2C;
  color: var(--auth-ivory);
  padding: 40px 44px 44px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.auth-visual__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 32px;
}


.auth-visual__back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  color: var(--auth-ivory);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid rgba(255,255,255,0.12);
  transition: background 180ms var(--ease, cubic-bezier(0.4,0,0.2,1));
}
.auth-visual__back:hover {
  background: rgba(255,255,255,0.14);
}

/* Body — editorial pull-quote */
.auth-visual__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px 0;
  max-width: 440px;
}

.auth-visual__eyebrow {
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: var(--tracking-eyebrow, 0.16em);
  text-transform: uppercase;
  color: var(--green-on-ink);
  margin: 0 0 22px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.auth-visual__eyebrow::before {
  content: '';
  width: 26px;
  height: 1px;
  background: var(--green-on-ink);
  opacity: 0.6;
}

.auth-visual__quote {
  font-family: 'Lora', Georgia, serif;
  font-size: 28px;
  font-weight: 500;
  line-height: 1.28;
  letter-spacing: -0.015em;
  color: var(--auth-ivory);
  margin: 0 0 28px;
  text-wrap: pretty;
}
.auth-visual__quote em {
  font-style: italic;
  color: var(--green-on-ink);
  font-weight: 500;
}

/* Footer — one quiet line */
.auth-visual__foot {
  margin-top: auto;
  padding-top: 28px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.auth-visual__note {
  margin: 0;
  font-size: 12.5px;
  color: var(--auth-ivory);
  opacity: 0.75;
}

/* ============================================================
   RIGHT — form panel
============================================================ */
.auth-form {
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

/* Per-page templates output <h1> + <p class="auth-sub"> + <form> */
.auth-form h1 {
  font-family: 'Lora', Georgia, serif;
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--ink);
  margin: 0 0 10px;
}

.auth-sub {
  font-size: 14.5px;
  color: var(--ink-muted);
  margin: 0 0 28px;
  line-height: 1.5;
}
.auth-sub a {
  color: var(--green-dark);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(15,110,86,0.35);
  text-decoration-thickness: 1px;
  transition: text-decoration-color 180ms var(--ease, cubic-bezier(0.4,0,0.2,1));
}
.auth-sub a:hover { text-decoration-color: var(--green-dark); }
[data-theme="dark"] .auth-sub a { color: var(--green); }

/* Form fields */
.auth-field {
  display: block;
  margin-bottom: 16px;
}
.auth-field label,
.auth-field > span {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}
.auth-field input {
  width: 100%;
  padding: 13px 15px;
  border: 1px solid var(--border-strong, var(--border));
  border-radius: 12px;
  font-family: inherit;
  font-size: 15px;
  background: var(--white);
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.auth-field input::placeholder { color: var(--ink-muted); }
.auth-field input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(15,110,86,0.12);
}

.auth-hint {
  font-size: 12.5px;
  color: var(--ink-muted);
  margin-top: 6px;
}

/* Primary submit button — flat pill, matches site CTAs */
.auth-submit {
  width: 100%;
  padding: 14px 18px;
  margin-top: 10px;
  border: 1px solid var(--green-darker);
  border-radius: 999px;
  background: var(--green);
  color: var(--on-green, #fff);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.005em;
  cursor: pointer;
  transition: background .2s ease, border-color .2s ease;
}
.auth-submit:hover:not(:disabled) {
  background: var(--green-darker);
}
.auth-submit:disabled { opacity: .6; cursor: not-allowed; }
.auth-submit:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }

/* Turnstile challenge — revealed by app.js only after the server demands it.
   [hidden] keeps it out of layout until then; the small top margin gives the
   iframe room above the submit button when it appears. */
.auth-captcha { margin-top: 14px; }
.auth-captcha[hidden] { display: none; }

/* Meta link row (Forgot password · Create an account) */
.auth-meta {
  margin-top: 22px;
  font-size: 13.5px;
  color: var(--ink-muted);
  text-align: center;
}
.auth-meta a {
  color: var(--green-dark);
  font-weight: 500;
  text-decoration: none;
}
.auth-meta a:hover { text-decoration: underline; text-underline-offset: 3px; }
[data-theme="dark"] .auth-meta a { color: var(--green); }

/* ---------- Error / success banners ---------- */
.auth-error,
.auth-success {
  display: block;
  max-height: 0;
  margin-bottom: 0;
  padding: 0 12px;
  border-width: 0;
  overflow: hidden;
  opacity: 0;
  border-radius: 12px;
  font-size: 13px;
  transition: max-height 240ms var(--ease-out-soft, cubic-bezier(0.16,1,0.3,1)),
              opacity 200ms var(--ease-out-soft, cubic-bezier(0.16,1,0.3,1)),
              margin-bottom 200ms var(--ease-out-soft, cubic-bezier(0.16,1,0.3,1)),
              padding-top 200ms var(--ease-out-soft, cubic-bezier(0.16,1,0.3,1)),
              padding-bottom 200ms var(--ease-out-soft, cubic-bezier(0.16,1,0.3,1));
}
.auth-error {
  border: 1px solid var(--red);
  background: var(--red-light);
  color: var(--red);
}
.auth-success {
  border: 1px solid var(--green);
  background: var(--green-light);
  color: var(--green-dark);
}
.auth-error.show,
.auth-success.show {
  max-height: 200px;
  opacity: 1;
  margin-bottom: 16px;
  padding: 10px 12px;
  border-width: 1px;
}

/* ---------- Inline flash banners ---------- */
.flash {
  width: 100%;
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  box-sizing: border-box;
  animation: auth-card-in 360ms var(--ease-out-soft, cubic-bezier(0.16,1,0.3,1)) both;
}
.flash-success { background: var(--green-light); color: var(--green-dark); border: 1px solid var(--green); }
.flash-error   { background: var(--red-light);   color: var(--red);        border: 1px solid var(--red);   }
.flash-info    { background: var(--paper-warm);  color: var(--ink-soft);   border: 1px solid var(--border); }

/* ---------- Per-field error region ---------- */
.auth-field-error {
  display: block;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  transition: max-height 220ms var(--ease-out-soft, cubic-bezier(0.16,1,0.3,1)),
              opacity 180ms var(--ease-out-soft, cubic-bezier(0.16,1,0.3,1)),
              margin-top 220ms var(--ease-out-soft, cubic-bezier(0.16,1,0.3,1));
  font-size: 12.5px;
  color: var(--red);
}
.auth-field-error:not(:empty) {
  max-height: 80px;
  opacity: 1;
  margin-top: 6px;
}

@keyframes field-shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(3px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}
.field-shake { animation: field-shake 320ms var(--ease, cubic-bezier(0.4,0,0.2,1)); }
.auth-field:has(.auth-field-error:not(:empty)) input {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(229,83,83,0.18);
}

/* ---------- Password show/hide toggle ---------- */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 46px; }
.pw-toggle {
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  width: 34px; height: 34px;
  border: none;
  background: transparent;
  border-radius: 8px;
  color: var(--ink-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 180ms var(--ease, cubic-bezier(0.4,0,0.2,1)),
              color 180ms var(--ease, cubic-bezier(0.4,0,0.2,1));
}
.pw-toggle:hover { background: var(--paper-warm); color: var(--ink); }
.pw-toggle:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.pw-toggle svg { width: 18px; height: 18px; }
.pw-toggle .pw-icon-off { display: none; }
.pw-toggle[aria-pressed="true"] .pw-icon-on { display: none; }
.pw-toggle[aria-pressed="true"] .pw-icon-off { display: inline-block; }

/* ---------- Password strength meter ---------- */
.pw-strength {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}
.pw-strength-bar {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  overflow: hidden;
  position: relative;
}
.pw-strength-bar::after {
  content: '';
  position: absolute; inset: 0;
  background: var(--green);
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 240ms var(--ease-out-soft, cubic-bezier(0.16,1,0.3,1)),
              background-color 200ms var(--ease, cubic-bezier(0.4,0,0.2,1));
}
.pw-strength[data-score="1"] .pw-strength-bar:nth-child(-n+1)::after,
.pw-strength[data-score="2"] .pw-strength-bar:nth-child(-n+2)::after,
.pw-strength[data-score="3"] .pw-strength-bar:nth-child(-n+3)::after,
.pw-strength[data-score="4"] .pw-strength-bar:nth-child(-n+4)::after {
  transform: scaleX(1);
}
.pw-strength[data-score="1"] .pw-strength-bar::after { background: var(--red); }
.pw-strength[data-score="2"] .pw-strength-bar::after { background: var(--amber); }
.pw-strength[data-score="3"] .pw-strength-bar::after { background: #C8A22A; }
.pw-strength[data-score="4"] .pw-strength-bar::after { background: var(--green); }
.pw-strength-label {
  font-size: 11.5px;
  color: var(--ink-muted);
  margin-top: 4px;
  min-height: 14px;
  transition: color 180ms var(--ease, cubic-bezier(0.4,0,0.2,1));
}
.pw-strength[data-score="1"] + .pw-strength-label { color: var(--red); }
.pw-strength[data-score="2"] + .pw-strength-label { color: var(--amber-text); }
.pw-strength[data-score="4"] + .pw-strength-label { color: var(--green-dark); }

/* CapsLock warning */
.pw-caps {
  position: absolute;
  right: 0; top: -10px;
  transform: translateY(-100%) scale(0.96);
  opacity: 0;
  pointer-events: none;
  background: var(--amber);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  transition: opacity 180ms var(--ease-out-soft, cubic-bezier(0.16,1,0.3,1)),
              transform 200ms var(--ease-out-soft, cubic-bezier(0.16,1,0.3,1));
  white-space: nowrap;
}
.pw-caps.is-on { opacity: 1; transform: translateY(-100%) scale(1); }

@media (prefers-reduced-motion: reduce) {
  .pw-caps, .pw-strength-bar::after, .field-shake { transition: none !important; animation: none !important; }
  .pw-strength-bar::after { transition: background-color 200ms !important; }
}

/* ============================================================
   Responsive — collapse to single column under 900px
============================================================ */
@media (max-width: 900px) {
  .auth-shell { padding: 16px; }
  .auth-card {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  /* The form leads on small screens — the quote panel pushed the first
     input below the fold on a 667px phone. Grid honours `order`, so the
     panel simply follows the form. */
  .auth-form { order: 1; }
  .auth-visual { order: 2; }
  .auth-visual {
    padding: 24px 28px 28px;
    min-height: auto;
  }
  .auth-visual__body { padding: 20px 0 16px; max-width: none; }
  .auth-visual__quote { font-size: 20px; margin-bottom: 18px; }
  .auth-visual__foot { padding-top: 16px; }
  .auth-form { padding: 32px 28px 36px; }
  .auth-form h1 { font-size: 26px; }
}

@media (max-width: 480px) {
  .auth-visual { padding: 20px 22px 22px; min-height: 180px; }
  .auth-form   { padding: 28px 22px 32px; }
  .auth-form h1 { font-size: 22px; }
}
