/* ==========================================================================
   Authentication — standalone login shell
   Self-contained (deliberate token copy from reading_training core.css so
   the auth app has no cross-app static dependency). Token names and values
   mirror core.css/theme-dark.css — when one side changes, sync the other
   by hand.
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #f9fafb;
  --surface: #ffffff;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --border-input: #6b7280; /* form-control borders — non-text AA needs 3:1 */
  --text: #111827;
  --text-muted: #4b5563;
  --brand: #1e3a8a;
  --action: #2b4fa8;
  --action-hover: #24438f;
  --on-action: #ffffff;
  --danger: #b42318;
  --danger-tint: #fbdad7;
  --danger-tint-soft: #fef3f2;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-2: 0 4px 16px rgba(17, 24, 39, 0.12);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --speed: 160ms;
}

/* Pre-auth pages can only follow the device setting — the visitor is not
   signed in, so their stored theme preference is unknowable. Accepted
   quirk: an explicit-light participant on a dark OS sees a dark login
   page. Values mirror theme-dark.css. */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0b111e;
    --surface: #111827;
    --border: #374151;
    --border-strong: #4b5563;
    --border-input: #9ca3af;
    --text: #f3f4f6;
    --text-muted: #d1d5db;
    --brand: #adc6f6;
    --action: #8ab1f2;
    --action-hover: #adc6f6;
    --on-action: #111827;
    --danger: #f0938b;
    --danger-tint: #301311;
    --danger-tint-soft: #301311;
    --shadow-2: 0 4px 16px rgba(0, 0, 0, 0.5);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

body {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-5) var(--space-4);
}

input,
button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--action);
  outline-offset: 2px;
  border-radius: 2px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: 32px var(--space-5);
}

.auth-brand {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--brand);
  text-align: center;
}

.auth-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: var(--space-1) 0 var(--space-5);
}

.auth-alert {
  background: var(--danger-tint-soft);
  border: 1px solid var(--danger-tint);
  border-left: 4px solid var(--danger);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  font-size: 0.9rem;
  margin-bottom: var(--space-4);
}

.field {
  margin-bottom: var(--space-4);
}

.field__label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: var(--space-1);
}

.field input {
  width: 100%;
  min-height: 44px;
  padding: 10px var(--space-3);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.field__error {
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: var(--space-1);
}

.btn {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--action);
  color: var(--on-action);
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--speed);
  margin-top: var(--space-2);
}

.btn:hover:not(:disabled) {
  background: var(--action-hover);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.auth-help {
  margin-top: var(--space-4);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
  }
}
