/* ==========================================================================
   ACE Driver Allocation — sign-in page (Liquid Glass)
   ========================================================================== */

/* Design tokens + Inter come from theme-tokens.css (shared with the app —
   REVIEW FIX: they were duplicated here and could drift on a rebrand). */

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: var(--lg-font);
  color: var(--lg-text);
  min-height: 100dvh;
  background-color: #f5f5f7;
}

/* REVIEW FIX: gradients on a fixed pseudo-element, not
   background-attachment: fixed (scroll-repaint cost; ignored on iOS anyway). */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(42rem 42rem at 15% 10%, rgba(0, 113, 227, 0.16), transparent 60%),
    radial-gradient(46rem 46rem at 85% 25%, rgba(120, 86, 255, 0.13), transparent 65%),
    radial-gradient(50rem 40rem at 50% 110%, rgba(0, 199, 190, 0.12), transparent 60%);
}

@media (prefers-color-scheme: dark) {
  :root {
    --lg-text: #f5f5f7;
    --lg-text-secondary: #b9b9c0;
    --lg-text-tertiary: #98989f;
    --lg-accent: #0a84ff;
    --lg-accent-strong: #409cff;
    /* FIX: success/danger were left at their light-mode values on the
       standalone pages, so dark-on-dark. The green password-rule ticks were
       only 3.2:1 on the dark card. Use the brighter dark-mode variants. */
    --lg-success: #32d74b;
    --lg-danger: #ff453a;
  }
  body { background-color: #0d0d12; }
  body::before {
    background-image:
      radial-gradient(42rem 42rem at 15% 10%, rgba(10, 132, 255, 0.14), transparent 60%),
      radial-gradient(46rem 46rem at 85% 25%, rgba(120, 86, 255, 0.1), transparent 65%);
  }
}

.login-wrapper {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  padding-top: max(1.25rem, env(safe-area-inset-top));
  padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 2.5rem 2rem;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.6);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.85), transparent 24%);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  border: 1px solid rgba(20, 24, 40, 0.08);
  box-shadow: 0 16px 48px rgba(31, 38, 63, 0.14), 0 2px 4px rgba(31, 38, 63, 0.06);
  text-align: center;
  animation: card-in 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-color-scheme: dark) {
  .login-card {
    background: rgba(28, 28, 34, 0.6);
    background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.1), transparent 24%);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  }
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .login-card { animation: none; }
}

.login-logo {
  max-width: 180px;
  height: auto;
  margin-bottom: 1rem;
}

/* Theme-aware wordmark: show the dark-art SVG on the light card, the
   light-art SVG in dark mode. Transparent SVGs, so no blend-mode hack. */
.login-logo-light { display: inline-block; }
.login-logo-dark  { display: none; }

@media (prefers-color-scheme: dark) {
  .login-logo-light { display: none; }
  .login-logo-dark  { display: inline-block; }
}

.login-card h1 {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.login-subtitle {
  color: var(--lg-text-secondary);
  font-size: 0.925rem;
  margin-bottom: 1.75rem;
}

.login-field {
  text-align: left;
  margin-bottom: 1rem;
}

.login-field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--lg-text-secondary);
  margin-bottom: 0.35rem;
}

.login-field input {
  width: 100%;
  min-height: 48px;
  padding: 0.65rem 0.95rem;
  font: inherit;
  font-size: 1rem; /* prevents iOS zoom-on-focus */
  color: var(--lg-text);
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(20, 24, 40, 0.12);
  border-radius: 12px;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

@media (prefers-color-scheme: dark) {
  .login-field input {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.14);
  }
}

.login-field input:focus {
  outline: none;
  border-color: var(--lg-accent);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.18);
}

.login-submit {
  width: 100%;
  min-height: 48px;
  margin-top: 0.5rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--lg-accent);
  border: none;
  border-radius: 980px;
  cursor: pointer;
  transition: background-color 200ms ease, transform 150ms ease, box-shadow 200ms ease;
}

.login-submit:hover {
  background: var(--lg-accent-strong);
  box-shadow: 0 6px 18px rgba(0, 113, 227, 0.35);
}

.login-submit:active { transform: scale(0.98); }

.login-submit:focus-visible {
  outline: 2px solid var(--lg-accent);
  outline-offset: 3px;
}

/* DEV ONLY — bypass button. Intentionally loud/amber so nobody mistakes it
   for a real control. Only rendered in the Development environment. */
.login-dev-bypass {
  display: block;
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.6rem 0.95rem;
  font-size: 0.875rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  color: #7a4d00;
  background: rgba(255, 176, 32, 0.18);
  border: 1px dashed rgba(176, 120, 0, 0.6);
  border-radius: 12px;
  transition: background-color 200ms ease;
}

.login-dev-bypass:hover { background: rgba(255, 176, 32, 0.3); }

@media (prefers-color-scheme: dark) {
  .login-dev-bypass {
    color: #ffd479;
    background: rgba(255, 176, 32, 0.14);
    border-color: rgba(255, 200, 90, 0.5);
  }
}

.login-footer {
  margin-top: 1.5rem;
  font-size: 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.login-footer a {
  color: var(--lg-accent);
  text-decoration: none;
}

.login-footer a:hover { text-decoration: underline; }

/* Register prompt sits under "Forgotten password?", separated by a hairline */
.login-footer-sep {
  color: var(--lg-text-secondary);
  padding-top: 0.6rem;
  border-top: 1px solid rgba(20, 24, 40, 0.08);
}

@media (prefers-color-scheme: dark) {
  .login-footer-sep { border-top-color: rgba(255, 255, 255, 0.1); }
}

/* ==========================================================================
   Register page — live validation (red = still to do, green = satisfied)
   ========================================================================== */

/* Field border reflects validity as the user types. */
.login-field input.input-valid {
  border-color: var(--lg-success);
  box-shadow: 0 0 0 4px rgba(29, 125, 63, 0.14);
}
.login-field input.input-invalid {
  border-color: var(--lg-danger);
  box-shadow: 0 0 0 4px rgba(215, 0, 21, 0.12);
}

/* One-line hint under each field. */
.field-hint {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  min-height: 1em;      /* reserve space so the layout doesn't jump */
  line-height: 1.3;
}
.field-hint.ok  { color: var(--lg-success); }
.field-hint.bad { color: var(--lg-danger); }
.field-hint.ok::before  { content: "\2713\00a0"; }   /* ✓ */
.field-hint.bad::before { content: "\2715\00a0"; }   /* ✕ */

/* Password requirements checklist. */
.pw-rules {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.3rem;
}
.pw-rules li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--lg-danger);          /* starts red — "still to do" */
  transition: color 160ms ease;
}
.pw-rules li .pw-mark {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  position: relative;
}
.pw-rules li .pw-mark::before {
  content: "";
  position: absolute;
  inset: 0;
  display: flex;
}
.pw-rules li.met {
  color: var(--lg-success);          /* turns green once satisfied */
}
/* Draw a check inside the dot when the rule is met. */
.pw-rules li.met .pw-mark {
  background: var(--lg-success);
  border-color: var(--lg-success);
}
.pw-rules li.met .pw-mark::after {
  content: "";
  position: absolute;
  left: 4.5px;
  top: 1.5px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Server-side errors (e.g. duplicate user name). */
.login-server-errors {
  text-align: left;
  margin-bottom: 1.25rem;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  background: rgba(215, 0, 21, 0.08);
  border: 1px solid rgba(215, 0, 21, 0.25);
}
.login-server-errors p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--lg-danger);
}
.login-server-errors p + p { margin-top: 0.25rem; }

@media (prefers-color-scheme: dark) {
  .login-server-errors {
    background: rgba(255, 69, 58, 0.12);
    border-color: rgba(255, 69, 58, 0.3);
  }
}
