/* black-ledger-cloud / styles / auth.css  —  Auth screens (Phase 4a)
 *
 * Mobile-first, uses CSS variables from main.css so themes (light/dark)
 * and the 6 design presets stay consistent. Auth screens overlay the
 * main app and are shown by adding `.is-visible` to #authRoot.
 */

#authRoot {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: var(--bg, #faf6ee);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#authRoot.is-visible { display: block; }

body.auth-mode { overflow: hidden; }

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  box-sizing: border-box;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface, #fffdf6);
  border: 1px solid var(--border, #ddd0b0);
  border-radius: var(--radius-lg, 10px);
  box-shadow: var(--shadow, 0 8px 24px -12px rgba(42,34,24,0.10));
  padding: 32px 24px 28px;
  box-sizing: border-box;
}

/* v18 — Selah brand block at the top of every auth screen.
   3-line hierarchy: name · short tagline · long tagline. */
.auth-brand {
  text-align: center;
  margin-bottom: 28px;
  user-select: none;
}
.auth-brand-mark {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink, #2a2218);
  margin-bottom: 4px;
}
.auth-brand-tagline {
  font-size: 13px;
  color: var(--text-soft, #888);
  font-style: italic;
  margin-bottom: 10px;
  letter-spacing: 0.02em;
}
.auth-brand-long {
  font-size: 11px;
  color: var(--text-soft, #888);
  opacity: 0.7;
  line-height: 1.6;
  max-width: 28em;
  margin: 0 auto;
  padding: 0 8px;
}

@media (max-width: 480px) {
  .auth-brand-mark    { font-size: 18px; }
  .auth-brand-tagline { font-size: 12px; }
  .auth-brand-long    { font-size: 10px; }
}

.auth-title {
  margin: 0 0 4px 0;
  font-family: var(--serif, 'Times New Roman', serif);
  font-size: 26px;
  font-weight: 600;
  color: var(--ink, #2a2218);
  letter-spacing: -0.01em;
}

/* Phase 7: KO/EN language toggle on auth screens (login/signup/reset).
   Placed at the top of the auth card so users can switch language BEFORE
   signing in. Persists to the same settings localStorage key the main app
   uses, so the choice survives login. */
.auth-lang-toggle {
  display: inline-flex;
  align-self: flex-end;
  margin: -8px -6px 14px auto;
  border: 1px solid var(--border, #ddd0b0);
  border-radius: 999px;
  overflow: hidden;
  font-family: var(--sans, system-ui, sans-serif);
  background: var(--bg, #faf6ee);
}
.auth-lang-btn {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 5px 12px;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--muted, #8a7a5a);
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.auth-lang-btn:hover:not(.is-active) {
  color: var(--ink, #2a2218);
  background: var(--bg-tint, #f3ecda);
}
.auth-lang-btn.is-active {
  background: var(--accent-deep, #6e5230);
  color: #fffdf6;
  cursor: default;
}
.auth-lang-btn:focus-visible {
  outline: 2px solid var(--accent, #a87f4f);
  outline-offset: 1px;
}

.auth-sub {
  margin: 0 0 24px 0;
  font-size: 14px;
  color: var(--muted, #8a7a5a);
  line-height: 1.5;
}

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

.auth-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft, #4a3e2a);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.auth-form input[type="email"],
.auth-form input[type="password"],
.auth-form input[type="text"] {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  font-size: 16px;
  font-family: var(--sans, system-ui, sans-serif);
  color: var(--ink, #2a2218);
  background: var(--bg, #faf6ee);
  border: 1px solid var(--border, #ddd0b0);
  border-radius: var(--radius, 4px);
  box-sizing: border-box;
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
}

.auth-form input:focus {
  border-color: var(--accent, #a87f4f);
  box-shadow: 0 0 0 3px var(--accent-soft, rgba(168,127,79,0.10));
}

.auth-form input[aria-invalid="true"] { border-color: var(--warn, #a04535); }

.auth-hint { font-size: 12px; color: var(--muted, #8a7a5a); line-height: 1.4; }

.auth-error {
  font-size: 13px;
  color: var(--warn, #a04535);
  min-height: 0;
  line-height: 1.4;
}
.auth-error:empty { display: none; }

.auth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 20px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--sans, system-ui, sans-serif);
  border-radius: var(--radius, 4px);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 120ms, border-color 120ms, color 120ms;
  box-sizing: border-box;
  margin-top: 4px;
}

.auth-btn--primary {
  background: var(--accent-deep, #6e5230);
  color: #fffdf6;
  border-color: var(--accent-deep, #6e5230);
}
.auth-btn--primary:hover:not(:disabled) {
  background: var(--ink, #2a2218);
  border-color: var(--ink, #2a2218);
}

.auth-btn--secondary {
  background: var(--surface, #fffdf6);
  color: var(--ink, #2a2218);
  border-color: var(--border, #ddd0b0);
}
.auth-btn--secondary:hover:not(:disabled) {
  background: var(--bg-tint, #f3ecda);
  border-color: var(--accent, #a87f4f);
}

.auth-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.auth-btn.is-loading { pointer-events: none; }

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: auth-spin 0.8s linear infinite;
  vertical-align: -2px;
}
@keyframes auth-spin { to { transform: rotate(360deg); } }

.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 10px 0 6px;
  color: var(--muted, #8a7a5a);
  font-size: 12px;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-soft, #ebdfc2);
}
.auth-divider span { padding: 0 12px; }

.auth-links {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--muted, #8a7a5a);
}

.auth-link {
  color: var(--accent-deep, #6e5230);
  text-decoration: none;
  font-weight: 500;
}
.auth-link:hover { text-decoration: underline; }
.auth-link-sep { color: var(--border, #ddd0b0); }

.auth-confirm {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-confirm-icon {
  font-size: 32px;
  color: var(--accent, #a87f4f);
  margin: 4px auto 8px;
}

.auth-helplist {
  margin: 4px auto 12px;
  padding: 0 0 0 18px;
  text-align: left;
  font-size: 14px;
  color: var(--ink-soft, #4a3e2a);
  line-height: 1.6;
}

.auth-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9100;
  background: rgba(42, 34, 24, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.auth-modal {
  width: 100%;
  max-width: 420px;
  background: var(--surface, #fffdf6);
  border: 1px solid var(--border, #ddd0b0);
  border-radius: var(--radius-lg, 10px);
  box-shadow: var(--shadow-lg, 0 30px 80px -24px rgba(42,34,24,0.32));
  padding: 28px 24px;
  box-sizing: border-box;
}

.auth-modal-icon {
  font-size: 28px;
  color: var(--accent, #a87f4f);
  text-align: center;
  margin-bottom: 8px;
}

.auth-modal-title {
  margin: 0 0 6px 0;
  font-family: var(--serif, 'Times New Roman', serif);
  font-size: 20px;
  font-weight: 600;
  color: var(--ink, #2a2218);
  text-align: center;
}

.auth-modal-sub {
  margin: 0 0 18px 0;
  font-size: 14px;
  color: var(--muted, #8a7a5a);
  text-align: center;
  line-height: 1.5;
}

.auth-modal-options { display: flex; flex-direction: column; gap: 8px; }

.auth-modal-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  text-align: left;
  background: var(--bg, #faf6ee);
  border: 1px solid var(--border-soft, #ebdfc2);
  border-radius: var(--radius, 4px);
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: background 120ms, border-color 120ms;
}
.auth-modal-option:hover {
  background: var(--bg-tint, #f3ecda);
  border-color: var(--accent, #a87f4f);
}

.amo-icon {
  font-size: 22px;
  color: var(--accent, #a87f4f);
  width: 32px;
  text-align: center;
  flex-shrink: 0;
}
.amo-title { font-size: 14px; font-weight: 600; color: var(--ink, #2a2218); }
.amo-desc { font-size: 12px; color: var(--muted, #8a7a5a); margin-top: 2px; }

.auth-modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.auth-modal-actions .auth-btn { flex: 1; margin-top: 0; }
.auth-form--modal { gap: 12px; }

.auth-avatar-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  background: var(--accent-deep, #6e5230);
  color: #fffdf6;
  font-weight: 600;
  font-size: 14px;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-left: 8px;
  flex-shrink: 0;
}
.auth-avatar-btn:hover { background: var(--ink, #2a2218); }

.auth-account-menu {
  min-width: 240px;
  background: var(--surface, #fffdf6);
  border: 1px solid var(--border, #ddd0b0);
  border-radius: var(--radius, 4px);
  box-shadow: var(--shadow-lg, 0 30px 80px -24px rgba(42,34,24,0.32));
  z-index: 9200;
  padding: 8px 0;
  font-family: var(--sans, system-ui, sans-serif);
}

.aam-header { display: flex; align-items: center; gap: 12px; padding: 8px 14px 10px; }

.aam-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-deep, #6e5230);
  color: #fffdf6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex-shrink: 0;
}

.aam-email {
  font-size: 13px;
  color: var(--ink, #2a2218);
  font-weight: 500;
  word-break: break-all;
}
.aam-status { font-size: 11px; color: var(--muted, #8a7a5a); margin-top: 2px; }

.aam-divider { margin: 0; border: 0; border-top: 1px solid var(--border-soft, #ebdfc2); }

.aam-item {
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  background: transparent;
  border: none;
  font: inherit;
  color: var(--ink, #2a2218);
  font-size: 13px;
  cursor: pointer;
}
.aam-item:hover { background: var(--bg-tint, #f3ecda); }
.aam-item--danger { color: var(--warn, #a04535); }

.auth-toast-layer {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.auth-toast {
  padding: 10px 16px;
  border-radius: var(--radius, 4px);
  font-size: 13px;
  font-weight: 500;
  color: #fffdf6;
  background: var(--ink, #2a2218);
  box-shadow: var(--shadow, 0 8px 24px -12px rgba(42,34,24,0.10));
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 200ms, transform 200ms;
  pointer-events: auto;
  max-width: 90vw;
}
.auth-toast.show { opacity: 1; transform: translateY(0); }
.auth-toast--success { background: #2d5a3d; }
.auth-toast--error   { background: var(--warn, #a04535); }
.auth-toast--info    { background: var(--ink, #2a2218); }

@media (max-width: 480px) {
  .auth-wrap { padding: 16px 12px; }
  .auth-card { padding: 24px 18px 20px; }
  .auth-title { font-size: 22px; }
  .auth-modal { padding: 24px 18px; }
}

/* 6-design preset tweaks */

html[data-design="terminal"] .auth-card,
html[data-design="terminal"] .auth-modal,
html[data-design="terminal"] .auth-account-menu { border-radius: 0; }
html[data-design="terminal"] .auth-title,
html[data-design="terminal"] .auth-modal-title { font-family: var(--mono, monospace); font-size: 22px; }
html[data-design="terminal"] .auth-btn { border-radius: 0; font-family: var(--mono, monospace); }
html[data-design="terminal"] .auth-form input { border-radius: 0; font-family: var(--mono, monospace); }

html[data-design="swiss"] .auth-title { font-weight: 800; letter-spacing: -0.02em; }
html[data-design="swiss"] .auth-btn--primary { border-radius: 0; }

html[data-design="zen"] .auth-card {
  border: none;
  box-shadow: 0 1px 0 var(--border-soft, #ebdfc2);
  background: transparent;
}

html[data-design="editorial"] .auth-title { font-size: 30px; }

html[data-design="notebook"] .auth-card {
  background-image: linear-gradient(var(--border-soft, #ebdfc2) 1px, transparent 1px);
  background-size: 100% 26px;
  background-position: 0 24px;
}

html[data-design="bento"] .auth-card,
html[data-design="bento"] .auth-modal { border-radius: 16px; }
html[data-design="bento"] .auth-btn { border-radius: 10px; }
