/* ==========================================================================
   login.css — matches login_Screen.png + SKILL.md design-system-sign-in
   SKILL foundations applied:
   - font.family.primary = Open Sans, stack Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif
   - font.size.base = 16px, font.size.xs = 16px, font.weight.base = 400, lineHeight = normal
   - color.text.primary = #000000
   - semantic tokens only (no raw hex in components), all states defined
   - WCAG 2.2 AA: keyboard-first, focus-visible, contrast, 48px touch targets
   ========================================================================== */

:root {
  /* Typography — from SKILL.md + user request exact stack */
  --font-family-primary: Open Sans,Helvetica Neue,Helvetica,Arial,sans-serif;
  --font-size-xs: 13px;
  --font-size-base: 14px;
  --font-size-lg: 20px;
  --font-size-xl: 28px;
  --font-weight-base: 400;
  --font-weight-strong: 600;
  --font-weight-bold: 700;
  --line-height-base: normal;

  /* Color — semantic tokens, values matched to screenshot */
  --color-text-primary: #000000;
  --color-text-secondary: #4a4a4a;
  --color-text-inverse: #ffffff;
  --color-text-danger: #99054b;
  --color-text-brand: #0f7ac1;
  --color-text-link: #1565d8;

  --color-surface: #ffffff;
  --color-surface-muted: #eef2f8;
  --color-surface-active: #dfe8f5;

  --color-border: #6b7280;
  --color-border-strong: #000000;
  --color-border-error: #99054b;

  /* Action = screenshot blue button */
  --color-action: #1459b3;
  --color-action-hover: #0f4da1;
  --color-action-active: #0c438d;
  --color-action-text: #ffffff;

  --color-danger: #99054b;
  --color-danger-surface: #ffffff;
  --color-focus: #000000;

  /* Spacing / shape / motion — scaled up to match screenshot exact */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --radius-sm: 6px;
  --radius-card: 12px;
  --shadow-card: 0 12px 40px rgba(0, 0, 0, 0.35);
  --shadow-logo: 0 1px 6px rgba(0, 0, 0, 0.35);
  --control-height: 52px;
  --content-width: 360px;
  --motion-fast: 150ms ease;
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--font-family-primary);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-base);
  line-height: var(--line-height-base);
  color: var(--color-text-primary);
  background: var(--color-text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, p { margin: 0; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  clip: rect(0 0 0 0); clip-path: inset(50%);
  overflow: hidden; white-space: nowrap;
}

.skip-link {
  position: absolute; left: var(--space-4); top: var(--space-4); z-index: 10;
  padding: var(--space-2) var(--space-4);
  background: var(--color-surface);
  color: var(--color-text-primary);
  font-weight: var(--font-weight-strong);
  transform: translateY(-200%);
}
.skip-link:focus-visible { transform: none; }

/* ===== Background — local file background_login.jpg (matches login_Screen.png) ===== */
.page-bg {
  position: fixed; inset: 0; z-index: 0;
  background-image: url("background_login.jpg"), url("https://images.unsplash.com/photo-1534430480872-3498386e7856?auto=format&fit=crop&w=1920&q=80");
  background-size: cover;
  background-position: center 60%;
  background-repeat: no-repeat;
  background-color: var(--color-text-primary);
}
.page-shade {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(5,15,35,.55) 0%, rgba(5,15,35,.15) 22%, transparent 40%),
    linear-gradient(to top, rgba(0,0,0,.18), transparent 30%);
}

/* ===== Top logo ===== */
.brand {
  position: relative; z-index: 2;
  display: flex; justify-content: center;
  padding-top: 34px;
}
.logo-box {
  background: transparent;
  padding: 0;
  line-height: 1;
  text-align: center;
  box-shadow: none;
  user-select: none;
  display: inline-flex;
  align-items: center;
}
.logo-box img {
  height: 40px;
  width: auto;
  max-width: 220px;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 1px 4px rgba(0,0,0,.5));
}
.logo-main {
  display: block;
  font-size: var(--font-size-xl);
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--color-text-brand);
}
.logo-blue { color: #29a6de; }
.logo-globe { font-size: 22px; }
.logo-sub {
  display: block;
  font-size: 12px;
  font-weight: var(--font-weight-bold);
  color: var(--color-text-brand);
  margin-top: 2px;
}

/* ===== Center card — gap locked like screenshot: logo top, card ~9vh below ===== */
.stage {
  position: relative; z-index: 2;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 9vh 16px 40px;
  min-height: 60vh;
}
.card {
  width: min(92vw, var(--content-width));
  background: var(--color-surface);
  border-radius: 8px;
  padding: 22px 20px 18px;
  box-shadow: var(--shadow-card);
}

form, .success { display: grid; gap: 14px; }

/* Labels — compact like screenshot */
.label {
  display: block;
  font-size: 13.5px;
  font-weight: var(--font-weight-base);
  color: var(--color-text-secondary);
  margin-bottom: 2px;
}
.label-maroon {
  color: var(--color-text-danger);
  font-weight: var(--font-weight-bold);
  font-size: 13.5px;
}
.label-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 2px;
}
.label-row .label { margin-bottom: 0; }

/* Inputs — thin underline only, compact */
.field { display: grid; gap: 4px; }
/* When field has error: label turns maroon like screenshot */
.field.is-error .label {
  color: var(--color-text-danger);
  font-weight: var(--font-weight-bold);
}

input[type="text"],
input[type="password"] {
  width: 100%;
  height: 32px;
  padding: 0 2px;
  font: inherit;
  font-size: 14px;
  color: var(--color-text-primary);
  background: var(--color-surface);
  border: 0;
  border-bottom: 1.5px solid var(--color-border);
  border-radius: 0;
}
input:hover { border-bottom-color: var(--color-border-strong); }
input:focus { outline: none; border-bottom-color: var(--color-action); box-shadow: none; }
input:focus-visible {
  outline: none;
  box-shadow: none;
  border-bottom-color: var(--color-action);
}
input[aria-invalid="true"] {
  border-bottom-color: var(--color-border-error);
  background: var(--color-danger-surface);
}
input:disabled {
  color: var(--color-text-secondary);
  background: var(--color-surface-muted);
  cursor: not-allowed;
}

/* Hint + error — compact */
.hint {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px;
  color: var(--color-text-danger);
  margin-top: 2px;
}
.error {
  font-size: 12px;
  font-weight: var(--font-weight-strong);
  color: var(--color-text-danger);
}
.form-alert {
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-xs);
  color: var(--color-text-danger);
  background: var(--color-danger-surface);
  border: 1px solid var(--color-danger);
  border-radius: var(--radius-sm);
}

/* Show — compact */
.link-show {
  border: 0; background: transparent; padding: 4px 0 4px 12px; cursor: pointer;
  font: inherit;
  font-size: 13.5px;
  font-weight: var(--font-weight-bold);
  color: var(--color-text-link);
  min-height: 32px;
}
.link-show:hover { text-decoration: underline; }
.link-show:active { color: var(--color-action-active); }
.link-show:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
.link-show:disabled { opacity: 0.6; cursor: not-allowed; }

/* Checkboxes — compact */
.checks {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-top: 0;
}
.check {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px;
  color: #5a5a5a;
  cursor: pointer;
  min-height: 32px;
  user-select: none;
}
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check .box {
  width: 16px; height: 16px; flex: none;
  border: 1.5px solid #7a869a;
  border-radius: 3px;
  background: var(--color-surface);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--color-action-text); line-height: 1;
}
.check:hover .box { border-color: var(--color-border-strong); }
.check input:checked + .box {
  background: var(--color-action);
  border-color: var(--color-action);
}
.check input:checked + .box::after { content: "✓"; }
.check input:focus-visible + .box {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

/* Primary button — compact */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 42px;
  padding: 0 var(--space-4);
  border: 1px solid var(--color-action);
  border-radius: var(--radius-sm);
  background: var(--color-action);
  color: var(--color-action-text);
  font: inherit;
  font-size: 14.5px;
  font-weight: var(--font-weight-base);
  cursor: pointer;
  transition: background-color var(--motion-fast);
}
.btn-primary:hover {
  background: var(--color-action-hover);
  border-color: var(--color-action-hover);
}
.btn-primary:active {
  background: var(--color-action-active);
  border-color: var(--color-action-active);
}
.btn-primary:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 3px;
}
.btn-primary:disabled {
  opacity: 0.7;
  cursor: wait;
}
.button__spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: var(--color-text-inverse);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Divider — compact */
.divider { display: flex; align-items: center; gap: 12px; margin: 0; }
.divider .line { flex: 1; height: 1px; background: #7a869a; opacity: .8; }
.divider .or { font-size: 12.5px; color: #5a6b82; }

/* Secondary — compact */
.btn-secondary {
  width: 100%;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--color-surface-muted);
  color: var(--color-action);
  font: inherit;
  font-size: 14px;
  font-weight: var(--font-weight-bold);
  cursor: pointer;
  transition: background-color var(--motion-fast);
}
.btn-secondary:hover { background: var(--color-surface-active); }
.btn-secondary:active { background: var(--color-surface-active); }
.btn-secondary:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 3px;
}

/* Bottom links — compact */
.links { display: grid; gap: 6px; margin-top: 0; }
.links a {
  font-size: 13px;
  font-weight: var(--font-weight-base);
  color: var(--color-text-link);
  text-decoration: none;
  width: fit-content;
  padding: 2px 0;
  min-height: 28px;
  display: inline-flex; align-items: center; gap: 6px;
}
.links a:hover { text-decoration: underline; }
.links a:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
.chev { font-size: 18px; font-weight: 700; line-height: 1; }

/* Screenshot exact: username underline is maroon (error state shown by default) */
#username { border-bottom-color: var(--color-border-error); border-bottom-width: 1.5px; }
#password { border-bottom-color: #6b7686; border-bottom-width: 1.5px; }

/* Success */
.success { text-align: center; }
.success h2 { font-size: var(--font-size-lg); font-weight: var(--font-weight-bold); }

/* ===== Site footer — from provided image, Open Sans per SKILL.md ===== */
.site-footer {
  position: relative; z-index: 2;
  background: var(--color-surface);
  border-top: 1px solid rgba(0,0,0,.08);
  padding: 10px 16px 14px;
  text-align: center;
  font-family: var(--font-family-primary);
}
.social {
  display: flex; align-items: center; justify-content: center;
  gap: 32px;
  padding: 2px 0 8px;
}
.social a {
  color: #5b6f82;
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  text-decoration: none;
}
.social a:hover { opacity: .75; background: transparent; }
.social a:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}
.legal {
  display: flex; flex-wrap: wrap;
  align-items: center; justify-content: center;
  gap: 4px 18px;
  max-width: 1100px;
  margin: 0 auto;
}
.legal a {
  font-size: 12.5px;
  color: #333;
  text-decoration: underline;
  text-decoration-color: #999;
  text-underline-offset: 2px;
  padding: 6px 0;
  min-height: 32px;
  display: inline-flex; align-items: center;
}
.legal a:hover { color: var(--color-text-primary); }
.legal a:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}
.meta {
  display: flex; flex-wrap: wrap;
  align-items: center; justify-content: center;
  gap: 4px 22px;
  margin-top: 4px;
  font-size: 12.5px;
  color: #333;
}
.meta a { color: #333; text-decoration: underline; text-decoration-color: #999; text-underline-offset: 2px; }
.meta a:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.housing { display: inline-flex; align-items: center; gap: 5px; }
.copyright {
  margin-top: 6px;
  font-size: 12.5px;
  color: #333;
  text-align: center;
}

/* Footer sits in normal flow below card — no extra stage offset needed (gap locked above) */

/* Responsive + edge cases */
@media (max-width: 480px) {
  .brand { padding-top: 12px; }
  .stage { padding-top: 18px; align-items: flex-start; }
  .card { padding: var(--space-4); }
  .checks { gap: var(--space-2); }
}

@media (prefers-reduced-motion: reduce) {
  .btn-primary, .btn-secondary, .button__spinner { transition: none; animation: none; }
}
