/* SAMF identity pages. Every colour comes from the design-system tokens (samf-ds.css, generated from
   Shared/design-tokens/samf-tokens.json; it switches on data-ds-theme, dark by default). The layout writes data-theme and
   data-ds-theme together. No external fonts or CDN: the CSP allows 'self' only. */
:root {
  color-scheme: dark;
  --bg-page: var(--ds-bg-page);
  --bg-surface: var(--ds-bg-surface);
  --bg-input: var(--ds-bg-input);
  --border-input: var(--ds-border-input-a11y);
  --input-text: var(--ds-text-on-input);
  --text-primary: var(--ds-text-primary);
  --text-secondary: var(--ds-text-secondary);
  --text-accent: var(--ds-text-accent-a11y);
  --samf-error: var(--ds-text-error);
  --samf-info: var(--ds-samf-info);
  --samf-success: var(--ds-samf-success);
  --samf-focus: var(--ds-samf-focus);
  --btn-primary-bg: var(--ds-bg-primary);
  --btn-primary-bg-hover: var(--ds-bg-primary-hover);
  --btn-primary-text: var(--ds-text-on-primary);
  --shadow-card: var(--ds-elevation-lg);
}
[data-theme="dark"] { color-scheme: dark; }
/* Light: the DS status colours fail WCAG AA as text on white (Shared/design-tokens/contrast-report.md), so the text
   colours stay on AA-safe shades until the design system fixes them. */
[data-theme="light"] {
  color-scheme: light;
  --samf-error: #b42318;
  --samf-info: #1a5fa8;
  --samf-success: #0b6b3a;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg-page); color: var(--text-primary);
  font-family: var(--ds-font-family); line-height: 1.5; }
a { color: var(--ds-text-accent-a11y); }
:focus-visible { outline: var(--ds-focus-ring); outline-offset: 2px; }

/* Header: brand (to the website), language switch, theme toggle */
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 80px; margin: 24px auto 0; padding: 0 var(--ds-space-24);
  width: min(1380px, calc(100% - 2rem)); border: 1px solid var(--ds-border-default); border-radius: var(--ds-radius-full);
  background: var(--ds-bg-glass); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.site-brand .logo { height: 48px; width: auto; flex: none; direction: ltr; color: var(--text-primary); }
.site-brand { display: inline-flex; align-items: center; gap: .5rem; font-size: 1.25rem; font-weight: 700; color: var(--text-accent); text-decoration: none; }
.site-tools { display: flex; align-items: center; gap: .75rem; }
.lang-switch { color: var(--text-primary); font: var(--ds-type-desktop-label-l4); min-height: 44px; display: inline-flex; align-items: center; padding: 0 var(--ds-space-16); border-radius: var(--ds-radius-8); text-decoration: none; border: var(--ds-border-width) solid var(--ds-border-strong-a11y); white-space: nowrap; }
.lang-switch:hover { background: var(--ds-bg-hover); }
form.lang-form { margin: 0; display: inline; }
button.lang-switch { margin: 0; width: auto; background: transparent; cursor: pointer; }
button.theme-toggle { margin: 0; width: auto; min-height: 44px; padding: 0 var(--ds-space-16); background: transparent; color: var(--text-primary); border: var(--ds-border-width) solid var(--ds-border-strong-a11y); border-radius: var(--ds-radius-8); font: var(--ds-type-desktop-label-l4); white-space: nowrap; }
button.theme-toggle:hover { background: var(--ds-bg-hover); }
button.theme-toggle[aria-pressed="true"] { border-color: var(--ds-border-selected); color: var(--text-accent); }

/* Card */
.card { width: min(560px, calc(100% - 2rem)); margin: 1rem auto 2rem; background: var(--bg-surface); border-radius: var(--ds-radius-16); border: var(--ds-border-width) solid var(--ds-border-default); padding: var(--ds-space-32) 48px 48px;
  box-shadow: var(--shadow-card); }
@media (max-width: 600px) { .card { padding: var(--ds-space-24); } .site-header { padding: 0 var(--ds-space-12); gap: var(--ds-space-8); min-height: 64px; } .site-brand .logo { height: 36px; } .site-tools { gap: var(--ds-space-8); }
  .lang-switch, button.theme-toggle { padding: 0 var(--ds-space-12); font: var(--ds-type-desktop-label-l5); }
  .card h2.page-title { font: var(--ds-type-mobile-heading-h3); } }
.brand { margin: 0 0 1rem; font-size: 1.25rem; color: var(--text-accent); }
h1, h2 { margin: 0 0 var(--ds-space-16); font: var(--ds-type-desktop-heading-h5); }
h2.page-title { font: var(--ds-type-desktop-heading-h3); text-transform: uppercase; margin: 0 0 var(--ds-space-24); }
.page-lead { margin: 0 0 var(--ds-space-24); font: var(--ds-type-desktop-body-b3); color: var(--text-secondary); }
.req { color: var(--text-accent); }
.forgot-link { display: inline-block; margin-block-start: var(--ds-space-12); font: var(--ds-type-desktop-label-l4); text-decoration: none; }
.login-links { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--ds-space-6); margin-block-start: var(--ds-space-24); font: var(--ds-type-desktop-body-b4); color: var(--text-secondary); }
.login-links a { font-weight: 600; text-decoration: none; }
h3 { margin: 1rem 0 .5rem; font-size: 1rem; }
.muted, .lang { color: var(--text-secondary); }
.lang { margin: 1.25rem 0 0; text-align: center; font-size: .9rem; }

/* Fields */
label { display: block; margin-block: var(--ds-space-16) var(--ds-space-8); font: var(--ds-type-desktop-label-l4); }
input { width: 100%; min-height: 48px; padding: 0 var(--ds-space-12); border: var(--ds-border-width) solid var(--border-input); border-radius: var(--ds-radius-8); background: var(--bg-input); color: var(--input-text); font: var(--ds-type-desktop-body-b3); }
input:hover { border-color: var(--ds-border-strong-a11y); }
input:focus { border-color: var(--ds-border-selected); }
input::placeholder { color: var(--ds-text-placeholder); }
input[aria-invalid="true"] { border-color: var(--samf-error); }
input:disabled { background: var(--ds-bg-glass); border-color: var(--ds-border-default); color: var(--ds-text-disabled); cursor: not-allowed; }
.field-error { margin: var(--ds-space-4) 0 0; color: var(--samf-error); font: var(--ds-type-desktop-body-b4); }
.field-error::before { content: "! "; font-weight: 700; }
.pw-field { position: relative; }
.pw-field input { padding-inline-end: 6rem; }

/* Buttons: bare <button>, .btn, a.button and the secondary variants share one look */
button, .btn, .button { margin-block-start: var(--ds-space-24); width: 100%; min-height: 48px; padding: 0 var(--ds-space-20); border: var(--ds-border-width) solid transparent; border-radius: var(--ds-radius-8); display: flex; align-items: center; justify-content: center;
  background: var(--btn-primary-bg); color: var(--btn-primary-text); font: var(--ds-type-desktop-label-l4); text-align: center; text-decoration: none; cursor: pointer; }
button:hover, .btn:hover, .button:hover { background: var(--btn-primary-bg-hover); }
button:active, .btn:active, .button:active { background: var(--ds-bg-primary-pressed); color: var(--ds-text-on-primary-pressed); }
button.secondary, .btn-secondary { background: transparent; color: var(--text-primary); border-color: var(--ds-border-strong-a11y); }
button.secondary:hover, .btn-secondary:hover { background: var(--ds-bg-hover); }
button:focus-visible, .btn:focus-visible, .button:focus-visible { outline: var(--ds-focus-ring); outline-offset: 2px; }
button:disabled, .btn:disabled, .btn[aria-disabled="true"] { background: var(--ds-bg-hover); color: var(--ds-text-disabled); border-color: var(--ds-border-default); cursor: not-allowed; }
button.pw-toggle { position: absolute; inset-inline-end: .35rem; inset-block-start: 50%; transform: translateY(-50%); margin: 0; width: auto;
  min-height: 36px; padding: 0 var(--ds-space-8); background: transparent; color: var(--text-accent); border: 0; font: var(--ds-type-desktop-label-l4); }
button.pw-toggle:hover, button.pw-toggle:active { background: transparent; color: var(--text-accent); text-decoration: underline; }

/* Alerts: accent bar on the inline start, an icon and the text, so the meaning is never colour only.
   .error and .notice are the older names other pages still use. */
.alert, .error, .notice { --alert: var(--samf-info); display: flex; gap: .6rem; align-items: flex-start; margin: 0 0 var(--ds-space-16); padding: var(--ds-space-12) var(--ds-space-16); font: var(--ds-type-desktop-body-b3);
  border-radius: var(--ds-radius-8); border-inline-start: 4px solid var(--alert); color: var(--text-primary);
  background: color-mix(in srgb, var(--alert) 12%, var(--bg-surface)); }
.alert::before, .error::before, .notice::before { content: "i"; flex: none; display: inline-grid; place-items: center; width: 1.25rem; height: 1.25rem;
  border-radius: 50%; background: var(--alert); color: var(--bg-surface); font-weight: 700; font-size: .8rem; line-height: 1; margin-block-start: .15rem; }
.alert-error, .error { --alert: var(--samf-error); }
.alert-error::before, .error::before { content: "!"; }
.alert-success, .notice { --alert: var(--samf-success); }
.alert-success::before, .notice::before { content: "\2713"; }
.alert-info { --alert: var(--samf-info); }
.alert-info::before { content: "i"; }
.alert p, .alert h2 { margin: 0; }

/* OTP boxes (the markup and the script belong to the OTP pages) */
.otp-boxes { display: flex; gap: 12px; direction: ltr; justify-content: center; margin-block: .5rem 1rem; }
.otp-box { flex: 0 1 64px; min-width: 0; height: 72px; padding: 0; text-align: center; font-size: 1.75rem; font-weight: 600; }
.otp-box[aria-invalid="true"], .otp-boxes.error .otp-box { border-color: var(--samf-error); box-shadow: 0 0 0 1px var(--samf-error); }
.otp-box:disabled { opacity: .5; cursor: not-allowed; }
@media (max-width: 420px) { .otp-boxes { gap: 8px; } .otp-box { height: 56px; font-size: 1.4rem; } }

/* MFA and the rest */
.qr { width: 12rem; margin-inline: auto; background: #fff; padding: var(--ds-space-8); border-radius: var(--ds-radius-8); }
.qr svg { display: block; width: 100%; height: auto; }
.key code, .codes code { font-family: Consolas, "Courier New", monospace; letter-spacing: .05em; }
.key { word-break: break-all; text-align: center; }
.codes { columns: 2; list-style: none; padding: 0; margin: .5rem 0 1rem; }

/* Utilities the OTP partial relies on: [hidden] wins over every component display rule; .sr-only is read by screen readers only. */
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
