/* weke-id hosted login — the front door of the Weke ecosystem.
 *
 * Direction: a private, unmistakably trustworthy identity gate — near-black
 * blue-slate surfaces, a single warm gold accent, clean gold focus rings.
 * Echoes the weke-metals Price Desk gate's palette (see
 * apps/weke-metals-desk/web/src/ui/theme.css) but re-created here in plain CSS:
 * no framework, no external fonts, no build step. System font stack only.
 * Every color below is also load-bearing for the CSP's style-src 'self' —
 * nothing here or in index.html is an inline style attribute.
 */

:root {
  color-scheme: light;

  /* Surfaces — the nexlink persona: cool white sheets with hairline rules,
     matching the Account Center SPA behind this gate. */
  --surface-0: #fdfdff;   /* page background */
  --surface-1: #ffffff;   /* card */
  --surface-2: #f7f7fa;   /* inputs, raised chips */
  --surface-3: #f2f2f6;   /* hover / active raised */
  --surface-border: #eeeef3;
  --surface-border-strong: #dee2e6;

  /* Ink — warm off-white down to slate-blue muted. ink-2 clears WCAG AA
     4.5:1 for body text on every surface tone above; ink-3 is placeholder
     / decorative-only text and clears the 3:1 floor. */
  --ink-0: #0c243c;
  --ink-1: #43536b;
  --ink-2: #696981;
  --ink-3: #97a1c0;

  /* Gold — the single accent, used for the brand mark, primary action, and
     focus rings. Text set on gold-400 uses --surface-0 (contrast ~9.6:1). */
  --gold-300: #6f6bdb;
  --gold-400: #5955d1;
  --gold-500: #504dbc;
  --gold-600: #242254;

  /* Danger — reserved for error copy only, always paired with text (never
     the sole signal — see the icon + text pattern on .login-error). Tuned
     for ~7:1 contrast against every surface tone above. */
  --danger: #631616;
  --danger-dim: #fff3f3;

  --radius-card: 1rem;
  --radius-control: 0.5rem;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--surface-0);
  color: var(--ink-0);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--gold-600);
  color: var(--ink-0);
}

.login-shell {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  padding: 1.5rem;
  overflow: hidden;
}

/* Ambient gold vignette above the card — quiet, not a spotlight. Purely
   decorative, hence aria-hidden in the markup. */
.login-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    55% 45% at 50% 28%,
    rgba(89, 85, 209, 0.12) 0%,
    rgba(89, 85, 209, 0) 70%
  );
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 26rem;
  background: var(--surface-1);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-card);
  padding: 2.25rem 2rem;
  box-shadow:
    0 1px 0 0 rgba(12, 36, 60, 0.03) inset,
    0 30px 80px -30px rgba(12, 36, 60, 0.5);
}

.login-footer {
  position: relative;
  margin: 0;
  font-size: 0.75rem;
  color: var(--ink-3);
  text-align: center;
}

.login-locale-field {
  display: flex;
  justify-content: flex-end;
  margin-block-end: 1rem;
}

.login-locale-field select {
  appearance: none;
  background: rgba(12, 36, 60, 0.05);
  border: 1px solid rgba(12, 36, 60, 0.12);
  border-radius: 0.55rem;
  color: inherit;
  font: inherit;
  min-width: 9rem;
  padding-block: 0.55rem;
  padding-inline: 0.75rem;
}

[dir="rtl"] .login-card,
[dir="rtl"] .login-form,
[dir="rtl"] .login-field {
  text-align: right;
}

/* ── Brand mark ─────────────────────────────────────────────────────── */

.login-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 1.75rem;
}

.login-brand-mark {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  color: var(--gold-400);
}

.login-brand-name {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink-0);
}

.login-brand-dot {
  color: var(--gold-400);
}

/* ── Shared state chrome ────────────────────────────────────────────── */

.login-heading {
  margin: 0 0 0.375rem;
  font-size: 1.3125rem;
  font-weight: 650;
  line-height: 1.3;
  color: var(--ink-0);
}

/* Headings and the error alert are focus targets during state transitions
   (see login.js) but should never show a focus ring themselves — the
   transition is programmatic, not a user-driven tab stop. */
.login-heading:focus,
.login-error:focus {
  outline: none;
}

.login-subtitle {
  margin: 0 0 1.25rem;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--ink-1);
}

.login-muted {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--ink-1);
  text-align: center;
}

.login-state[data-state="context"],
.login-state[data-state="launching"],
.login-state[data-state="done"] {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0 0.25rem;
}

/* login.js toggles visibility with the `hidden` content attribute, not a
   class — but the display:flex rule above has higher specificity than the
   UA stylesheet's `[hidden] { display: none }`, so it would otherwise win
   and leave hidden sections visually stacked on top of the active one.
   This rule must stay last (or !important) so `hidden` always wins. */
.login-state[hidden] {
  display: none !important;
}

/* ── Error / status copy ────────────────────────────────────────────── */

/* Errors are never signaled by color alone: the icon glyph (::before) and
   the text itself both carry the meaning, independent of the red hue. */
.login-error {
  display: none;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0 0 1rem;
  padding: 0.625rem 0.75rem;
  border: 1px solid rgba(99, 22, 22, 0.3);
  border-radius: var(--radius-control);
  background: var(--danger-dim);
  color: var(--danger);
  font-size: 0.875rem;
  line-height: 1.45;
}

.login-error:not(:empty) {
  display: flex;
}

.login-error::before {
  content: "!";
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.125rem;
  height: 1.125rem;
  margin-top: 0.0625rem;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  font-size: 0.6875rem;
  font-weight: 700;
}

.login-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  margin: 0 0 0.25rem;
  border-radius: 50%;
}

.login-icon-fatal {
  background: var(--danger-dim);
  color: var(--danger);
}

/* ── Forms ──────────────────────────────────────────────────────────── */

.login-form {
  display: flex;
  flex-direction: column;
}

.login-field {
  display: flex;
  flex-direction: column;
  margin-bottom: 1rem;
}

label {
  margin: 0 0 0.375rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink-1);
}

input {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.625rem 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--surface-border-strong);
  border-radius: var(--radius-control);
  color: var(--ink-0);
  font-family: inherit;
  font-size: 1rem;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input::placeholder {
  color: var(--ink-3);
}

input:hover {
  border-color: var(--ink-2);
}

input:focus-visible {
  outline: 2px solid var(--gold-400);
  outline-offset: 1px;
  border-color: var(--gold-400);
}

input:disabled {
  opacity: 0.6;
}

/* ── Buttons ────────────────────────────────────────────────────────── */

.login-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  margin-top: 0.5rem;
  padding: 0.625rem 1rem;
  border: none;
  border-radius: var(--radius-control);
  background: var(--gold-400);
  color: var(--surface-0);
  font-family: inherit;
  font-weight: 650;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: background-color 120ms ease, transform 120ms ease;
}

.login-button:hover:not(:disabled) {
  background: var(--gold-300);
}

.login-button:active:not(:disabled) {
  transform: translateY(1px);
}

.login-button:disabled {
  cursor: progress;
  background: var(--gold-600);
  color: rgba(253, 253, 255, 0.7);
}

.login-button:focus-visible {
  outline: 2px solid var(--ink-0);
  outline-offset: 2px;
}

.login-button-secondary {
  background: transparent;
  border: 1px solid var(--surface-border-strong);
  color: var(--ink-0);
}

.login-button-secondary:hover:not(:disabled) {
  background: var(--surface-2);
}

.login-button-secondary:focus-visible {
  outline: 2px solid var(--gold-400);
  outline-offset: 2px;
}

.login-button-spinner {
  display: none;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: 2px solid rgba(253, 253, 255, 0.4);
  border-top-color: rgba(253, 253, 255, 0.88);
  animation: login-spin 700ms linear infinite;
}

.login-button[data-pending="true"] .login-button-spinner {
  display: inline-block;
}

.login-link-button {
  margin-top: 0.875rem;
  padding: 0.25rem 0;
  background: none;
  border: none;
  color: var(--ink-1);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  align-self: center;
}

.login-link-button:hover {
  color: var(--gold-300);
}

.login-link-button:focus-visible {
  outline: 2px solid var(--gold-400);
  outline-offset: 2px;
  border-radius: 0.25rem;
}

/* ── Loading / launching spinner ────────────────────────────────────── */

.login-spinner {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  border: 3px solid var(--surface-border-strong);
  border-top-color: var(--gold-400);
  animation: login-spin 800ms linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .login-spinner,
  .login-button-spinner {
    animation-duration: 1ms;
  }
}

/* ── Utility ────────────────────────────────────────────────────────── */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.login-noscript {
  padding: 1rem;
  text-align: center;
  color: var(--ink-1);
  background: var(--surface-0);
}

/* Keep the card usable at 200% browser zoom: let it shrink toward full
   width and drop the outer padding rather than clipping content. */
@media (max-width: 26rem) {
  .login-card {
    padding: 1.75rem 1.25rem;
  }
}
