/*
 * SEC-7 (2026-11-15): customer TOTP second factor.
 *
 * Two surfaces share this file:
 *   1. Account -> Security card (#customer-totp-mount, .ctotp-* classes),
 *      rendered inside a .cd-card on the dark-gold customer dashboard.
 *   2. Login step-up panel (#login-mfa-mount, .login-mfa-* classes plus a
 *      few .ctotp-* helpers) inside the auth-reference login card.
 *
 * Both surfaces are dark, but each owns its token family: --cd-* on the
 * dashboard (customer-dashboard.css) and --auth-* on the login page
 * (assets/auth-reference.css). Layout rules below are un-scoped and token
 * free; colour rules are scoped per body class so neither page can inherit
 * the other theme's values. No external assets: the enrollment QR is an
 * inline SVG with its own white quiet zone and stays scannable on either
 * background.
 */

/* ---------- Shared structure ----------------------------------------- */

#customer-totp-mount[aria-busy='true'] {
  opacity: 0.85;
}

#customer-totp-mount h3 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.ctotp-chip {
  font: 800 9px var(--cd-mono, "JetBrains Mono", "DM Mono", monospace);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
}

.ctotp-meta {
  list-style: none;
  margin: 10px 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

.ctotp-actions,
.login-mfa-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.ctotp-password-form,
.ctotp-confirm-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  max-width: 360px;
}

.ctotp-password-form label,
.ctotp-confirm-form label {
  display: grid;
  gap: 6px;
}

.ctotp-key-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0;
}

.ctotp-manual-key {
  font-family: var(--cd-mono, "JetBrains Mono", "DM Mono", monospace);
  font-size: 13px;
  letter-spacing: 0.06em;
  word-break: break-all;
  padding: 8px 10px;
  border-radius: 8px;
}

.ctotp-authenticator-link {
  display: inline-block;
  margin: 10px 0 4px;
}

/* Inline-SVG enrollment QR: the viewBox keeps every module crisp at any
   display width; the white rect inside the SVG is the ISO quiet zone. */
.ctotp-qr-wrap {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin: 14px 0 6px;
}

.ctotp-qr-wrap .ctotp-note {
  margin: 0;
}

.ctotp-qr {
  width: min(224px, 72vw);
  height: auto;
  border-radius: 10px;
  background: #ffffff;
}

.ctotp-backup-list {
  list-style: none;
  margin: 12px 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.ctotp-backup-list code {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  font-family: var(--cd-mono, "JetBrains Mono", "DM Mono", monospace);
  text-align: center;
}

.ctotp-message[hidden],
.login-mfa-form .ctotp-message[hidden] {
  display: none;
}

.ctotp-message {
  margin: 8px 0 0;
  font-size: 13.5px;
  line-height: 1.6;
}

.ctotp-wait {
  display: block;
  margin-top: 4px;
}

/* ---------- Dashboard surface (--cd-* tokens) ------------------------- */

body.customer-account-page:not(.auth-reference) #customer-totp-mount .ctotp-note {
  color: var(--cd-muted);
  font-size: 13.5px;
  line-height: 1.7;
  margin: 8px 0;
  max-width: 620px;
}

body.customer-account-page:not(.auth-reference) .ctotp-meta {
  color: var(--cd-muted);
  font-size: 13px;
}

body.customer-account-page:not(.auth-reference) .ctotp-chip-on {
  color: var(--cd-ok);
  border: 1px solid oklch(0.78 0.13 145 / 0.5);
  background: oklch(0.78 0.13 145 / 0.1);
}

body.customer-account-page:not(.auth-reference) .ctotp-chip-off {
  color: var(--cd-faint);
  border: 1px solid var(--cd-line);
  background: oklch(1 0 0 / 0.04);
}

body.customer-account-page:not(.auth-reference) .ctotp-chip-pending {
  color: var(--cd-gold);
  border: 1px solid oklch(0.8 0.11 82 / 0.5);
  background: var(--cd-gold-soft);
}

body.customer-account-page:not(.auth-reference) .ctotp-manual-key,
body.customer-account-page:not(.auth-reference) .ctotp-backup-list code {
  border: 1px solid var(--cd-line);
  background: var(--cd-input);
  color: var(--cd-text);
}

body.customer-account-page:not(.auth-reference) .ctotp-authenticator-link {
  color: var(--cd-gold);
}

body.customer-account-page:not(.auth-reference) .ctotp-qr {
  border: 1px solid var(--cd-line);
}

body.customer-account-page:not(.auth-reference) .ctotp-warning {
  color: var(--cd-gold-light);
  border: 1px solid oklch(0.8 0.11 82 / 0.4);
  background: var(--cd-gold-soft);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 10px 0;
  font-size: 13.5px;
  line-height: 1.7;
}

body.customer-account-page:not(.auth-reference) .ctotp-message {
  color: var(--cd-muted);
}

body.customer-account-page:not(.auth-reference) .ctotp-message.is-error {
  color: var(--cd-danger);
}

body.customer-account-page:not(.auth-reference) button.ctotp-danger {
  color: var(--cd-danger);
}

body.customer-account-page:not(.auth-reference) button.ctotp-danger:hover {
  color: oklch(0.8 0.16 28);
}

/* ---------- Login step-up surface (--auth-* tokens) ------------------- */

#login-mfa-mount[hidden] {
  display: none;
}

#login-mfa-mount {
  margin-top: 22px;
  display: grid;
  gap: 12px;
}

.login-mfa-title {
  margin: 0;
  font: 400 32px/1.1 "Cormorant Garamond", Georgia, serif;
  color: var(--auth-text);
}

body.auth-reference .login-mfa-form {
  display: grid;
  gap: 14px;
}

body.auth-reference .login-mfa-form label {
  display: grid;
  gap: 6px;
}

.login-mfa-input {
  width: 100%;
  letter-spacing: 0.08em;
}

.login-mfa-countdown {
  margin: 0;
  font-size: 12px;
  color: var(--auth-muted);
}

.login-mfa-actions {
  margin-top: 0;
  justify-content: space-between;
}

body.auth-reference #login-mfa-mount .ctotp-note {
  color: var(--auth-muted);
  font: 400 13.5px/1.7 Jost, Arial, sans-serif;
  margin: 0;
}

body.auth-reference #login-mfa-mount .ctotp-message {
  color: var(--auth-text);
  font: 400 14px/1.5 Jost, Arial, sans-serif;
  overflow-wrap: anywhere;
}

body.auth-reference #login-mfa-mount .ctotp-message.is-error {
  color: #ffb4a6;
}

body.auth-reference .login-mfa-back {
  margin-left: 0;
}

@media (max-width: 560px) {
  .ctotp-backup-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  #customer-totp-mount *,
  #login-mfa-mount * {
    transition: none;
  }
}
