@font-face {
  font-family: "Nunito Sans";
  src: url("./fonts/nunito-sans-latin.woff2") format("woff2");
  font-weight: 200 1000;
  font-display: swap;
}

/* Tokens mirror the Flutter app theme (lib/theme/app_colors_data/app_colors_data.dart). */
:root {
  --bg: #fafafa;
  --card: #ffffff;
  --text: #2f4858;
  --muted: #5f6568;
  --border: #e0e0e0;
  /* Input outlines need 3:1 against the field (WCAG 1.4.11); --border stays for dividers. */
  --field-border: #8a949a;
  --field: #ffffff;
  --primary: #e4bb00;
  --button: #1a3445;
  --button-text: #ffffff;
  --focus: #1a3445;
  --success: #147d4e;
  --danger: #c4362f;
  --info: #2f4858;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 8px 24px rgb(0 0 0 / 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a2026;
    --card: #232c34;
    --text: #ffffff;
    --muted: #afd0e6;
    --border: #3a4650;
    --field-border: #6b7a86;
    --field: #1a2026;
    --primary: #f5cc30;
    --button: #f5cc30;
    --button-text: #1a3445;
    --focus: #f5cc30;
    --success: #4dd88f;
    --danger: #ff6b6a;
    --info: #c6dde8;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3);
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--text);
  font-family: "Nunito Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

.shell {
  width: 100%;
  max-width: 420px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 28px 20px;
}

.card-header {
  text-align: center;
  margin-bottom: 20px;
}

.logo {
  border-radius: 14px;
  margin-bottom: 12px;
}

h1 {
  margin: 0 0 6px;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

h2 {
  margin: 0 0 6px;
  font-size: 1.15rem;
  font-weight: 800;
}

.subtitle,
.help {
  margin: 0;
  color: var(--muted);
}

.help {
  margin-bottom: 16px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.tab {
  min-height: 44px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.tab[aria-selected="true"] {
  background: var(--primary);
  color: #1a3445;
}

.social-auth {
  display: grid;
  gap: 10px;
}

.social-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--field);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0 14px;
  color: var(--muted);
  font-size: 0.875rem;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* The divider only makes sense when at least one provider button is shown. */
.social-auth:not(:has(.social-button:not([hidden]))) {
  display: none;
}

form {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

.field > label:not(.checkbox) {
  font-weight: 700;
  font-size: 0.9375rem;
}

.field-hint,
.field-error {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
}

.field-hint {
  color: var(--muted);
}

.field-hint.is-met {
  color: var(--success);
}

.field-error {
  display: flex;
  gap: 6px;
  color: var(--danger);
}

/* Not colour alone: a mark precedes every error. */
.field-error::before {
  content: "!";
  /* Empty alt text: screen readers read the message only. */
  content: "!" / "";
  flex: none;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--danger);
  color: var(--card);
  font-size: 0.75rem;
  font-weight: 900;
  line-height: 1;
}

.input-wrap {
  position: relative;
}

.input-wrap input {
  padding-right: 52px;
}

.reveal {
  position: absolute;
  top: 2px;
  right: 2px;
  bottom: 2px;
  width: 46px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.reveal svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.reveal:focus-visible {
  outline-offset: -2px;
}

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

.reveal .icon-hide,
.reveal[aria-pressed="true"] .icon-show {
  display: none;
}

.reveal[aria-pressed="true"] .icon-hide {
  display: block;
}

input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--field-border);
  border-radius: 12px;
  background: var(--field);
  color: var(--text);
  transition: border-color 0.15s ease-out;
  /* 16px keeps iOS from zooming on focus. */
  font: inherit;
  font-size: 16px;
  font-weight: 400;
}

input[readonly] {
  color: var(--muted);
  cursor: default;
}

input:focus {
  border-color: var(--focus);
}

input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: inset 0 0 0 1px var(--danger);
}

/* Full opacity: the faded version fell under 4.5:1 in light mode. */
input::placeholder {
  color: var(--muted);
  opacity: 1;
}

::selection {
  background: var(--primary);
  color: #1a3445;
}

:is(input, button, a):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 44px;
  padding: 2px 0;
  font-size: 0.9375rem;
  cursor: pointer;
}

.checkbox input {
  width: 22px;
  height: 22px;
  margin: 0;
  flex: none;
  accent-color: var(--button);
}

a {
  color: inherit;
  font-weight: 700;
  text-underline-offset: 0.18em;
}

.primary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 50px;
  border: 0;
  border-radius: 12px;
  background: var(--button);
  color: var(--button-text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.link-button {
  display: block;
  min-height: 44px;
  margin: 10px auto 0;
  padding: 8px 12px;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.18em;
  cursor: pointer;
}

button:disabled,
input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* The button that started the action: stays opaque and focusable, shows a spinner. */
button.is-loading {
  cursor: progress;
}

.spinner,
button.is-loading::before {
  content: "";
  flex: none;
  width: 18px;
  height: 18px;
  border: 2.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.social-button.is-loading svg {
  display: none;
}

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

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

.account {
  display: grid;
  gap: 2px;
  margin: -4px 0 20px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  text-align: center;
}

.account-label {
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 700;
}

.account-email {
  font-weight: 800;
  overflow-wrap: anywhere;
}

/* Redirect return: the form would only invite a second, conflicting sign-in. */
.card.is-pending > :not(.card-header, .account, .pending, .status) {
  display: none;
}

.pending {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 24px 0 8px;
  color: var(--muted);
  font-weight: 700;
}

.pending p {
  margin: 0;
}

.spinner-large {
  width: 32px;
  height: 32px;
  border-width: 3px;
  color: var(--text);
}

.status:empty {
  display: none;
}

.status {
  margin: 18px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid currentColor;
  font-weight: 600;
}

.status.error {
  color: var(--danger);
}

.status.success {
  color: var(--success);
}

.status.info {
  color: var(--info);
}

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

  /* Keep a sign of progress, without the rotation. */
  .spinner,
  button.is-loading::before {
    border-right-color: currentColor;
    animation: pulse 1.6s ease-in-out infinite;
  }
}
