/* Recovery keys and the self-service password reset (#155). Uses only
   existing tokens. */

/* ---- Sign-in: "Forgot password?" ---- */
.forgot-password { margin: -0.5rem 0 0; text-align: right; font-size: 0.85rem; }
.forgot-password a { display: inline-block; padding-block: 0.75rem; color: var(--text-muted); text-underline-offset: 0.15em; }
.forgot-password a:hover { color: var(--text); }

/* ---- Card modes: reset form, second factor for a reset, key step ---- */
.auth-card[data-mode] .auth-tabs,
.auth-card[data-mode] #login-form,
.auth-card[data-mode] #register-form,
.auth-card[data-mode] .guest-entry,
.auth-card[data-mode="reset"] #mfa-login-panel,
.auth-card[data-mode="key"] #mfa-login-panel,
.auth-card[data-mode="key"] #password-reset { display: none !important; }

/* ---- The reset form ---- */
.password-reset h2 { margin: 0; font-family: var(--display-font); font-weight: 400; font-size: 1.75rem; line-height: 1.15; }
.password-reset > p { margin: 0; color: var(--text-muted); }
.password-reset-back { justify-self: start; min-height: 2.75rem; padding: 0; border: 0; background: none; box-shadow: none; color: var(--signature-text); font-weight: 600; text-decoration: underline; text-underline-offset: 0.15em; }
.password-reset-help { font-size: 0.85rem; }
.password-reset .error-text:empty { display: none; }
.recovery-key-input { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: 0.06em; text-transform: uppercase; }
.recovery-key-input::placeholder { text-transform: none; letter-spacing: 0.04em; }
.password-field { display: grid; gap: 0.4rem; }
.password-field > label { display: block; color: var(--text-muted); font-size: 0.92rem; }
.password-field-row { position: relative; }
.password-field-row input { padding-right: 3.25rem; }
.password-toggle {
  position: absolute;
  inset: 0 0.25rem 0 auto;
  width: 2.75rem;
  height: 2.75rem;
  margin: auto 0;
  transform: none;
  transition: none;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 0.6rem;
  background: transparent;
  color: var(--text-muted);
}
.password-toggle[aria-pressed="true"] { color: var(--signature-text); }
.password-toggle:focus-visible { outline: 2px solid var(--signature-text); outline-offset: -2px; }

/* ---- "Save your recovery key" ---- */
.recovery-key-step h2 { margin: 0; font-family: var(--display-font); font-weight: 400; font-size: 1.75rem; line-height: 1.15; }
.recovery-key-step h2:focus { outline: none; }
.recovery-key-step > p { margin: 0; }
.recovery-eyebrow { color: var(--signature-text); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.recovery-notice { padding: 0.6rem 0.8rem; border-radius: 0.7rem; background: var(--raised); }
.recovery-key {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  padding: 1rem 1.1rem;
  border: 1px dashed var(--line);
  border-radius: 1rem;
  background: var(--raised);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  user-select: all;
}
.recovery-key-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.recovery-key-status { min-height: 1.2em; color: var(--text-muted); font-size: 0.85rem; }
.recovery-key-status:empty { min-height: 0; }
.recovery-advice { color: var(--text-muted); font-size: 0.9rem; }
.recovery-confirm { color: var(--text); font-weight: 600; }
.recovery-key-step > .primary-button { justify-self: stretch; }
.recovery-dialog { width: min(34rem, calc(100vw - 2rem)); }
.recovery-dialog > .recovery-key-step { padding: 1.5rem; }
.recovery-dialog > .recovery-key-step > .primary-button { justify-self: start; }

/* ---- The nudge in the chat shell ---- */
.recovery-nudge {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin: 0;
  padding: 0.55rem 0.9rem;
  border: 1px solid color-mix(in srgb, var(--signature) 45%, var(--line));
  border-radius: 0.8rem;
  background: color-mix(in srgb, var(--signature) 10%, var(--surface));
  color: var(--text);
  font-size: 0.9rem;
}
.recovery-nudge > span { flex: 1 1 16rem; min-width: 0; }
.recovery-nudge .secondary-button { padding-block: 0.35rem; }
.chat-shell > .recovery-nudge { grid-column: 1 / -1; }
.chat-shell:has(> .recovery-nudge:not(.hidden)) { grid-template-rows: auto minmax(0, 1fr); }
/* Never alongside lockdown or the guest strip; possibly alongside the rules strip (#160) and the new-look note. */
.chat-shell:has(> .recovery-nudge:not(.hidden)):has(> :is(.rules-banner, .new-look-note):not(.hidden)) { grid-template-rows: auto auto minmax(0, 1fr); }
.chat-shell:has(> .recovery-nudge:not(.hidden)):has(> .rules-banner:not(.hidden)):has(> .new-look-note:not(.hidden)) { grid-template-rows: auto auto auto minmax(0, 1fr); }

/* ---- Account ---- */
.recovery-row { display: grid; gap: 0.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.recovery-row h3 { margin: 0; font-size: 1rem; }
.recovery-row p { margin: 0; }

@media (max-width: 760px) {
  .chat-shell > .recovery-nudge { border-radius: 0; border-width: 0 0 1px; font-size: 0.8rem; }
  .recovery-key { font-size: 1.15rem; }
}

@media (forced-colors: active) {
  .recovery-key, .recovery-nudge { border-color: CanvasText; }
}
