@import url("https://fonts.googleapis.com/css2?family=Archivo:wght@400;600;700&display=swap");
@import '../design-system/tokens.css';
@import '../design-system/primitives.css';

:root {
  color-scheme: dark;
  --bg: var(--af-bg);
  --panel: var(--af-panel);
  --active: var(--af-active);
  --text: var(--af-text);
  --muted: var(--af-muted);
  --line: var(--af-line);
  --accent: var(--af-brand);
  --accent-text: var(--af-link);
  --on-accent: var(--af-on-brand);
  --danger: var(--af-danger);
  --sans: var(--af-sans);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  display: flex;
  flex-direction: column;
  isolation: isolate;
}

a { color: inherit; }

button, input { font: inherit; }

button { border: 0; cursor: pointer; }

button:focus-visible, a:focus-visible, input:focus-visible {
  outline: var(--af-focus-width) solid var(--af-primary);
  outline-offset: var(--af-focus-offset);
}

.login-header {
  min-height: 80px;
  padding: var(--af-space-4) var(--af-gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--af-space-6);
}

.brand { display: inline-flex; min-height: 44px; align-items: center; }
.brand img { width: 142px; height: auto; display: block; }

.back {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-size: var(--af-text-sm);
  text-decoration: none;
}

.back:hover { color: var(--text); }

.login-shell {
  width: 100%;
  padding: var(--af-space-8) var(--af-gutter) var(--af-space-12);
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.login-card {
  width: min(480px, 100%);
  padding: var(--af-space-6);
  display: flex;
  flex-direction: column;
  gap: var(--af-space-3);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--af-radius-choice);
}

.eyebrow {
  color: var(--muted);
  font-size: var(--af-text-sm);
  font-weight: 600;
  line-height: var(--af-line-height);
}

.state[hidden] { display: none; }
.state:not([hidden]) { display: flex; flex-direction: column; gap: var(--af-space-6); }

.state h1 {
  margin: 0;
  font-size: var(--af-title);
  font-weight: 400;
  line-height: 1.214;
  letter-spacing: -.025em;
}

.lead {
  color: var(--muted);
  font-size: var(--af-text-md);
  line-height: var(--af-line-height);
  margin: calc(-1 * var(--af-space-3)) 0 0;
}

.lead strong, .account-email { color: var(--text); overflow-wrap: anywhere; }

form { display: grid; gap: var(--af-space-2); }

label { font-size: var(--af-text-sm); font-weight: 600; line-height: var(--af-line-height); }

input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--af-radius-field);
  background: var(--af-surface);
  color: var(--text);
  padding: 0 var(--af-space-4);
  font-size: var(--af-text-md);
}

input:hover { border-color: rgba(255,255,255,.34); }
input:focus { border-color: var(--accent); outline-color: var(--accent); }
input[aria-invalid="true"] { border-color: var(--danger); }

button, .primary-link {
  min-height: 48px;
  border-radius: var(--af-radius-action);
  padding: 13px 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
  font-weight: 700;
  line-height: 1.35;
}

form button, #retry-button, .primary-link {
  background: var(--af-primary);
  color: var(--af-on-primary);
}
form button { margin-top: var(--af-space-4); }

.primary-link { width: 100%; }

form button:hover, #retry-button:hover, .primary-link:hover { background: #ddd; }
button:disabled { cursor: wait; opacity: .6; }

.secondary {
  width: 100%;
  margin-top: var(--af-space-3);
  background: var(--active);
  color: var(--text);
}

.secondary:hover { background: #444; }

.social-actions { display: grid; gap: var(--af-space-3); }
.social-actions[hidden], .social-button[hidden], .login-divider[hidden] { display: none; }

.social-button {
  width: 100%;
  min-height: 52px;
  gap: 12px;
  border: 1px solid transparent;
  font-size: 14px;
  line-height: 20px;
}

.social-button__icon { width: 24px; height: 24px; flex: none; object-fit: contain; }
.social-button > svg.social-button__icon { width: 24px; height: 24px; fill: currentColor; stroke: none; }

.social-button--google {
  background: #131314;
  border-color: #8e918f;
  color: #e3e3e3;
}

.social-button--google:hover { background: #232426; border-color: #c4c7c5; }

.social-button--github {
  background: #24292f;
  border-color: #57606a;
  color: #fff;
}

.social-button--github:hover { background: #32383f; border-color: #8c959f; }

.login-divider {
  display: flex;
  align-items: center;
  gap: var(--af-space-3);
  margin: 0;
  color: var(--muted);
  font-size: var(--af-text-sm);
  text-align: center;
}

.login-divider::before, .login-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--line);
}

.form-status {
  min-height: 22px;
  margin: var(--af-space-3) 0 0;
  color: var(--danger);
  font-size: var(--af-text-sm);
  line-height: var(--af-line-height);
}

.form-status:empty { display: none; }

.fine-print, .hint {
  color: var(--muted);
  font-size: var(--af-text-sm);
  line-height: var(--af-line-height);
}

.fine-print { margin: 0; }
.hint { margin: -12px 0 26px; }

.resend-note {
  margin: -12px 0 26px;
  color: var(--muted);
  font-size: var(--af-text-sm);
  line-height: var(--af-line-height);
}

.success-mark {
  width: 52px;
  height: 52px;
  margin-bottom: var(--af-space-6);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 28px;
  font-weight: 700;
}

#loading-state { min-height: 290px; place-items: center; align-content: center; text-align: center; }
#loading-state:not([hidden]) { display: grid; }
#loading-state p { margin: var(--af-space-4) 0 0; color: var(--muted); }

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.login-footer {
  padding: var(--af-space-6) var(--af-gutter) var(--af-space-8);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--af-space-3);
  color: var(--muted);
  font-size: var(--af-text-sm);
  line-height: var(--af-line-height);
}

.login-footer a { min-height: 44px; display: inline-flex; align-items: center; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 600px) {
  .login-header { padding-inline: var(--af-space-5); }
  .login-shell { padding-inline: var(--af-space-5); }
  .login-footer { padding-inline: var(--af-space-5); }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; border-top-color: var(--line); }
}
