/*
 * Sign in and sign up.
 *
 * Loaded on top of styles.css so the tokens, buttons and fields are the platform's own — this page
 * is the first thing a customer sees, and it should look like the product they are about to enter.
 *
 * Both languages are present in the markup and one is hidden, the same way the landing page does
 * it. That keeps the switch instant and, more importantly, keeps the two translations next to each
 * other in the source where a mismatch is obvious.
 */

:root[data-ui-lang="ar"] [lang="en"] { display: none !important; }
:root[data-ui-lang="en"] [lang="ar"] { display: none !important; }

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px 48px;
}

/* A single wash of brand colour behind the card, the same gradient the masthead rule uses. */
.auth-page::after {
  content: "";
  position: fixed;
  inset-inline: 0;
  top: 0;
  height: 3px;
  background: linear-gradient(to right, var(--brand-green), var(--brand-cyan));
  z-index: 1;
}

.auth {
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ------------------------------------------------------------------ brand */

.auth__brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: inherit;
  justify-content: center;
  /* Same lockup, same direction, as every other page. */
  direction: ltr;
  unicode-bidi: isolate;
}
.auth__brand img { width: 52px; height: 52px; object-fit: contain; flex: none; }
.auth__brand strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: -0.01em;
}
.auth__brand em {
  display: block;
  font-style: normal;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ------------------------------------------------------------------ card */

.auth__card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.auth__switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.auth__tab {
  font: inherit;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}
.auth__tab:hover { color: var(--text-primary); }
.auth__tab.is-active {
  background: var(--brand-green);
  border-color: var(--brand-green);
  color: var(--accent-ink);
  box-shadow: var(--accent-glow);
}

/* Shown only on a platform nobody has claimed yet. Deliberately not an error colour — nothing has
   gone wrong, there is simply nobody here. */
.auth__first-run {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: color-mix(in srgb, var(--brand-green) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand-green) 40%, transparent);
}

.auth__tab:disabled { opacity: 0.4; cursor: not-allowed; }

/* ------------------------------------------------------------------ fields */

.auth__form { display: flex; flex-direction: column; gap: 15px; }
/* A class that sets `display` outranks the browser's own rule for [hidden], so the inactive form
   stays on screen unless this is said explicitly. */
.auth__form[hidden] { display: none; }

.auth__field { display: flex; flex-direction: column; gap: 5px; }
/* Both translations of the label, not just the first — the hidden one is still the first child, so
   `:first-child` would style the invisible span and leave the visible one unstyled in one language. */
.auth__field > span[lang] {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.auth__field input { width: 100%; padding: 10px 12px; }

.auth__hint {
  font-style: normal;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/*
 * The reveal button sits inside the field. `direction: ltr` is pinned here rather than inherited:
 * a password is a Latin string and typing one inside an RTL page otherwise puts the caret and the
 * punctuation in bewildering places.
 */
.auth__password { position: relative; display: block; direction: ltr; }
.auth__password input { padding-inline-end: 42px; }
.auth__peek {
  position: absolute;
  inset-inline-end: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: 0;
  padding: 4px 6px;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.55;
  color: var(--text-primary);
}
.auth__peek:hover { opacity: 1; }

/* Advisory only — the server decides. Colour is paired with width so it never carries alone. */
.auth__meter {
  --fill: 0%;
  display: block;
  height: 4px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.auth__meter i {
  display: block;
  height: 100%;
  width: var(--fill);
  border-radius: 999px;
  background: var(--status-critical);
  transition: width 0.18s ease, background 0.18s ease;
}
.auth__meter[data-level="fair"] i { background: var(--status-warning); }
.auth__meter[data-level="good"] i { background: var(--status-good); }

/* ------------------------------------------------------------------ state */

.auth__error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.85rem;
  color: var(--text-primary);
  background: color-mix(in srgb, var(--status-critical) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--status-critical) 45%, transparent);
}

/* The confirmation half of recovery: same shape as an error, opposite colour, so a page that has
   just told somebody bad news does not use the same box to tell them good. */
.auth__note {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-primary);
  background: color-mix(in srgb, var(--status-good) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--status-good) 40%, transparent);
}
.auth__note[hidden] { display: none; }

.auth__lede {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.65;
  color: var(--text-secondary, var(--text-muted));
}
.auth__lede[hidden] { display: none; }

/* A button that reads as a link, because "forgotten your password" is a way out of this form
   rather than an action competing with the one the form is for. */
.auth__link {
  align-self: center;
  background: none;
  border: 0;
  padding: 2px 4px;
  font: inherit;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.auth__link:hover { color: var(--text-primary); }

.auth__submit { justify-content: center; padding: 11px 16px; }
.auth__submit:disabled { opacity: 0.6; cursor: progress; transform: none; box-shadow: none; }
.auth__submit.is-busy span::after {
  content: "…";
}

.auth__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.85rem;
}
.auth__foot a { color: var(--text-secondary); text-decoration: none; }
.auth__foot a:hover { color: var(--text-primary); text-decoration: underline; }

@media (max-width: 480px) {
  .auth__card { padding: 18px 16px; }
  .auth__brand { justify-content: flex-start; }
}

/* ------------------------------------------------------------------ the pilot notice */

/* A reading page rather than a form: wider, and set for paragraphs. */
.auth.legal { max-width: 820px; }
.legal__card { line-height: 1.75; }
.legal__card h1 { font-family: var(--font-display); font-size: 1.45rem; margin: 0 0 4px; }
.legal__card h2 { font-size: 1.02rem; margin: 26px 0 8px; color: var(--text-primary); }
.legal__card p, .legal__card li { color: var(--text-secondary); }
.legal__card ul { padding-inline-start: 20px; margin: 6px 0; }
.legal__card li { margin: 5px 0; }
.legal__card strong { color: var(--text-primary); }
.legal__card a { color: var(--brand-cyan); }
.legal__meta { font-size: 0.85rem; color: var(--text-muted); margin: 0; }
.legal__warn {
  margin-top: 26px;
  padding: 4px 16px 10px;
  border-inline-start: 3px solid var(--status-warning);
  background: color-mix(in srgb, var(--status-warning) 8%, transparent);
  border-radius: 8px;
}
.auth__foot { flex-wrap: wrap; }

/* Consent on sign-up: a real checkbox beside words, not a sentence under the button. */
.auth__consent {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
}
.auth__consent input { width: 18px; height: 18px; margin-top: 3px; flex: none; }
.auth__consent a { color: var(--brand-cyan); }
