/* ─── Auth page — clinical light theme ─────────────────────────────────────
   Aligned with the app's design tokens (tokens.css): off-blue page, white
   card with a crisp border and small shadow, one accent colour. Passkey is
   the primary action; password sign-in is the secondary path. */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Respect the OS "reduce motion" setting. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

body {
  font-family: "Manrope", "Segoe UI", "Avenir Next", system-ui, sans-serif;
  font-size: 14px;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1100px 520px at 85% -10%, rgba(30, 111, 168, 0.10), transparent 60%),
    radial-gradient(900px 480px at 5% 110%, rgba(30, 111, 168, 0.08), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ── Page wrap ─────────────────────────────────────────────────────────────── */
.auth-page {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  padding: 20px;
}

/* ── Card ──────────────────────────────────────────────────────────────────── */
.auth-card {
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow:
    0 1px 2px rgba(18, 28, 46, 0.04),
    0 12px 32px rgba(18, 28, 46, 0.08);
  overflow: hidden;
  animation: auth-card-in 0.35s ease-out;
}
@keyframes auth-card-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.auth-card-header {
  padding: 40px 32px 22px;
  text-align: center;
}
.auth-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px; height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, #2b7cb6 0%, #1e6fa8 100%);
  box-shadow: 0 6px 16px rgba(30, 111, 168, 0.28);
  margin: 0 auto 16px;
}
.auth-logo svg {
  width: 28px; height: 28px;
  fill: none; stroke: #fff;
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
.auth-card-title    { font-size: 23px; font-weight: 800; letter-spacing: -0.4px; color: var(--navy-dark); margin-bottom: 5px; }
.auth-card-subtitle { font-size: 14px; color: var(--muted); }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.auth-btn-primary,
.auth-btn-secondary {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 46px; padding: 11px 16px;
  border-radius: 12px;
  font-size: 15px; font-weight: 700; letter-spacing: 0.01em;
  cursor: pointer; font-family: inherit;
  transition: box-shadow .15s, border-color .15s, background .15s, filter .15s, transform .1s;
}
.auth-btn-primary {
  background: linear-gradient(135deg, #2b7cb6 0%, #1e6fa8 100%);
  color: #fff; border: none;
  box-shadow: 0 4px 14px rgba(30, 111, 168, 0.30);
}
.auth-btn-primary:hover    { filter: brightness(1.07); box-shadow: 0 6px 20px rgba(30, 111, 168, 0.38); }
.auth-btn-primary:active   { transform: scale(.98); }
.auth-btn-primary:disabled { opacity: 0.55; cursor: not-allowed; transform: none; filter: none; }
.auth-btn-secondary {
  background: var(--surface); color: var(--navy);
  border: 1px solid var(--line);
}
.auth-btn-secondary:hover    { background: var(--accent-soft); border-color: var(--accent); }
.auth-btn-secondary:active   { transform: scale(.98); }
.auth-btn-secondary:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.auth-btn-icon { width: 19px; height: 19px; flex-shrink: 0; }

/* ── Primary passkey section ───────────────────────────────────────────────── */
.auth-passkey-section { padding: 2px 32px 0; }
.auth-passkey-section .auth-error:not(:empty) { margin-bottom: 12px; }

/* ── Divider ───────────────────────────────────────────────────────────────── */
.auth-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 20px 32px 0; font-size: 12.5px; color: var(--muted);
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--line);
}

/* ── Form ──────────────────────────────────────────────────────────────────── */
.auth-form     { padding: 20px 32px 32px; display: flex; flex-direction: column; gap: 14px; }
.auth-label    { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: #3d5068; }
.auth-hint     { font-weight: 400; color: var(--muted); font-size: 11.5px; }
.auth-pw-wrap  { position: relative; display: flex; align-items: center; }
.auth-pw-wrap .auth-input { flex: 1; padding-right: 44px; }
.auth-pw-eye {
  position: absolute; right: 12px;
  background: none; border: none; padding: 4px; cursor: pointer;
  color: var(--muted); display: flex; align-items: center; transition: color .15s;
}
.auth-pw-eye:hover { color: var(--text); }
.eye-icon { width: 18px; height: 18px; display: block; }
.auth-input {
  min-height: 46px;
  padding: 11px 14px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 12px;
  /* 16px minimum so iOS Safari does not auto-zoom on focus */
  font-size: 16px; color: var(--text); outline: none; width: 100%;
  transition: border-color .15s, background .15s, box-shadow .15s;
  font-family: inherit;
}
.auth-input::placeholder { color: #93a5b8; }
.auth-input:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(30, 111, 168, 0.15);
}
.auth-check-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 13.5px; color: var(--muted); cursor: pointer;
}
.auth-check-row input { width: 16px; height: 16px; accent-color: var(--accent); }
.auth-error {
  font-size: 13px; color: var(--warn);
  background: #fef2f2;
  border: 1px solid #f3c2c2;
  border-left: 3px solid var(--warn);
  border-radius: 10px; padding: 10px 12px; display: none;
}
.auth-error:not(:empty) { display: block; }
.auth-success {
  font-size: 13px; color: #1a7f4b;
  background: #effaf3;
  border: 1px solid #b7e4c9;
  border-left: 3px solid #1a7f4b;
  border-radius: 10px; padding: 10px 12px; display: none;
}
.auth-success:not(:empty) { display: block; }
.auth-recovery-link {
  display: block; text-align: center; margin-top: 4px;
  font-size: 13px; color: var(--muted); text-decoration: none;
  transition: color .15s;
}
.auth-recovery-link:hover { color: var(--accent); text-decoration: underline; }

/* ── Global keyboard-focus ring (inputs keep their own box-shadow ring) ────── */
button:focus-visible, a:focus-visible, [role="button"]:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid rgba(30, 111, 168, 0.65);
  outline-offset: 2px;
}

/* ── Mobile: edge-to-edge card, vertically centred by the body ──────────────
   The card keeps its natural height and the body's flex centring places it —
   no forced 100dvh on the card, so the page can never scroll into empty
   space when the content already fits. */
@media (max-width: 480px) {
  /* Auto margins centre the card cross-axis when it fits, and collapse to
     zero when content overflows — so the top never gets clipped. */
  .auth-page { max-width: none; padding: 0; margin-top: auto; margin-bottom: auto; }
  .auth-card {
    border-radius: 0;
    border-left: none;
    border-right: none;
    box-shadow: none;
    animation: none;
  }
  .auth-card-header { padding-top: calc(32px + env(safe-area-inset-top)); }
  .auth-form { padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
}
