/*
 * Look of the identity provider's sign-in pages (Login, Mfa, RecoveryCode, EnrolMfa), so they read as the same product
 * as payplus-web. Colours, fonts and radius are copied from payplus-web src/styles/tokens.css and the brand treatment
 * from its /auth pages (src/components/ui/plainPage.ts); change them there first, then here.
 *
 * Served as a same-origin static file because the pages' Content Security Policy allows stylesheets from 'self' only:
 * no inline styles, no web fonts, no CDN. Fonts are the system stacks payplus-web uses until its fonts are approved.
 */
:root {
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-serif: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 0.25rem;
  --background: #f0ebe0;
  --foreground: #1a1614;
  --card: #faf8f3;
  --primary: #1d3528;
  --primary-foreground: #f0ebe0;
  --muted: #e6dece;
  --muted-foreground: #5c5244;
  --destructive: #b83232;
  --destructive-text: #b83232;
  --border: rgba(26, 22, 20, 0.1);
  --input-background: #ede8dd;
  --input-border: rgba(26, 22, 20, 0.5);
  --ring: #1d3528;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #0f1a14;
    --foreground: #e8e3d8;
    --card: #162010;
    --primary: #e8e3d8;
    --primary-foreground: #1d3528;
    --muted: #1f2e24;
    --muted-foreground: #9a9286;
    --destructive-text: #e07a7a;
    --border: rgba(232, 227, 216, 0.08);
    --input-background: rgba(232, 227, 216, 0.08);
    --input-border: rgba(232, 227, 216, 0.45);
    --ring: #e8e3d8;
    color-scheme: dark;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  line-height: 1.5;
}

/* The centred card that holds the brand and the page. */
.card {
  width: 100%;
  max-width: 26rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 2);
  padding: 2rem;
}

/* PayPlus wordmark in the serif face with the small upper-case caption, as in payplus-web. */
.brand {
  margin: 0 0 1.5rem;
}

.brand-name {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.25rem;
  letter-spacing: 0.025em;
}

.brand-caption {
  margin: 0.25rem 0 0;
  font-size: 0.625rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

h1 {
  margin: 0 0 1rem;
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1.3;
}

h2 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1rem;
  font-weight: 500;
}

p {
  margin: 0 0 1rem;
  font-size: 0.875rem;
}

main > p {
  color: var(--muted-foreground);
}

/* Form rows: label above a full-width control. */
form p {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-bottom: 1.25rem;
}

form p br {
  display: none;
}

label {
  font-size: 0.875rem;
  font-weight: 500;
}

input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  background: var(--input-background);
  color: var(--foreground);
  font: inherit;
  font-size: 1rem;
}

input[inputmode="numeric"] {
  font-family: var(--font-mono);
  letter-spacing: 0.2em;
}

button {
  width: 100%;
  padding: 0.625rem 1rem;
  border: 0;
  border-radius: var(--radius);
  background: var(--primary);
  color: var(--primary-foreground);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
}

button:hover,
.continue a:hover {
  opacity: 0.9;
}

/* "I have saved my recovery codes" is the page's main action, so it looks like a button. */
.continue a {
  display: block;
  padding: 0.625rem 1rem;
  border-radius: var(--radius);
  background: var(--primary);
  color: var(--primary-foreground);
  font-weight: 500;
  text-align: center;
  text-decoration: none;
}

a {
  color: var(--foreground);
  font-size: 0.875rem;
  text-underline-offset: 0.2em;
}

/* Visible keyboard focus on every control (PS 13.2), as payplus-web draws it. */
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

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

/* Error messages. */
[role="alert"] {
  padding: 0.75rem 1rem;
  border: 1px solid var(--destructive);
  border-left-width: 4px;
  border-radius: var(--radius);
  color: var(--destructive-text);
  background: transparent;
  font-size: 0.875rem;
}

/* Confirmation (authenticator added). */
[role="status"] {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  color: var(--foreground);
  border-radius: var(--radius);
  background: var(--muted);
  font-size: 0.875rem;
}

/* Authenticator enrolment: the QR code stays dark on white in both themes so phones can scan it. */
figure {
  margin: 0 0 1.5rem;
  text-align: center;
}

figure [role="img"] {
  display: inline-block;
  padding: 0.75rem;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  line-height: 0;
}

figure svg {
  max-width: 100%;
  height: auto;
}

figcaption {
  margin-top: 0.75rem;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  overflow-wrap: anywhere;
}

code {
  font-family: var(--font-mono);
  color: var(--foreground);
}

/* Recovery codes in a two-column grid. */
main ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 0 0 1.5rem;
  padding: 1rem;
  list-style: none;
  background: var(--muted);
  border-radius: var(--radius);
}

main ul code {
  font-size: 0.875rem;
}

/* Secondary links under a form (use a recovery code, continue). */
.links {
  margin: 1rem 0 0;
  text-align: center;
}

@media (max-width: 30rem) {
  body {
    align-items: flex-start;
    padding: 1rem 0.75rem;
  }

  .card {
    padding: 1.5rem 1.25rem;
  }
}
