/* PathKEY — sign in, password reset and invitation (design §12.5). The shell
 * draws the brand panel and the form column; this styles what auth.js puts
 * in the column, and the signed-in "choose a password" card.
 * Owned by the admin, access & settings workstream. Role tokens only. */

.auth { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: var(--sp-3); }
.auth > .eyebrow { margin-bottom: calc(-1 * var(--sp-1)); }
.auth h1 { font-size: var(--fs-32); line-height: var(--lh-32); letter-spacing: var(--track-display); }
.auth-sub { font-size: var(--fs-16); line-height: var(--lh-16); color: var(--text-muted); }
.auth-sub strong { color: var(--text); font-weight: var(--fw-medium); overflow-wrap: anywhere; }
.auth > .icon-tile { margin-bottom: var(--sp-2); }

.auth-form { display: flex; flex-direction: column; gap: var(--sp-4); margin-top: var(--sp-3); }
/* T1.33: the sign-in field height of the CodeXR composition (T1.16 #4, tokens.css --field-h). */
.auth-form :where(input:not([type=checkbox]):not([type=radio])) { min-height: var(--field-h, var(--h-lg)); font-size: var(--fs-14); }
.auth-form .field.has-error input { border-color: var(--crit); }
.auth-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); }
.auth-label-row label { font-size: var(--fs-12); line-height: var(--lh-12); font-weight: var(--fw-medium); color: var(--text-2); }
.auth-forgot { font-size: var(--fs-12); font-weight: var(--fw-medium); text-decoration: none; }
.auth-forgot:hover { text-decoration: underline; }
.auth-password { position: relative; display: block; }
.auth-password input { padding-right: 44px; }
.auth-password .auth-reveal { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.auth-submit { width: 100%; margin-top: var(--sp-1); }
.auth-error {
  display: flex; align-items: flex-start; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-control);
  background: var(--crit-soft); color: var(--crit-text); font-size: var(--fs-13); line-height: var(--lh-13);
  animation: auth-in var(--dur-3) var(--ease-enter);
}
.auth-error .icon { margin-top: 3px; flex: none; }
.auth-error a { color: inherit; font-weight: var(--fw-semibold); text-decoration: underline; text-underline-offset: 2px; }
@keyframes auth-in { from { opacity: 0; transform: translateY(calc(-1 * var(--lift))); } to { opacity: 1; transform: none; } }

.auth-more { display: flex; flex-direction: column; gap: var(--sp-3); margin-top: var(--sp-6); padding-top: var(--sp-5); border-top: 1px solid var(--line-soft); }
.auth-assessment > summary {
  display: inline-flex; align-items: center; gap: var(--sp-2); list-style: none; cursor: pointer; border-radius: var(--r-4);
  font-size: var(--fs-13); font-weight: var(--fw-medium); color: var(--text-link);
}
.auth-assessment > summary::-webkit-details-marker { display: none; }
.auth-assessment > summary:hover span { text-decoration: underline; text-underline-offset: 2px; }
.auth-assessment-form { display: flex; flex-direction: column; gap: 6px; margin-top: var(--sp-3); animation: auth-in var(--dur-3) var(--ease-enter); }
.auth-assessment-row { display: flex; gap: var(--sp-2); }
.auth-assessment-row input { flex: 1; min-width: 0; height: var(--h-lg); min-height: var(--h-lg); font-size: var(--fs-14); }
.auth-assessment-row input[aria-invalid="true"] { border-color: var(--crit); }
.auth-note { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-12); color: var(--text-muted); }
.auth-note .icon { color: var(--accent); }
.auth-back { font-size: var(--fs-13); color: var(--text-muted); margin-top: var(--sp-2); }
.auth-back a { display: inline-flex; align-items: center; gap: 6px; font-weight: var(--fw-medium); text-decoration: none; }
.auth-back a:hover { text-decoration: underline; }
.auth-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-2); }
.auth-textbtn { padding: 0; border: 0; background: none; cursor: pointer; color: var(--text-link); font: var(--fw-medium) var(--fs-13)/var(--lh-13) var(--font-ui); border-radius: var(--r-4); }
.auth-textbtn:hover { text-decoration: underline; }
.auth-textbtn { display: inline-flex; align-items: center; gap: 6px; }

/* Signed in from a reset or invitation email: the sign-in frame (auth.js
 * splitFrame) fills the page, without the onboarding header, until the
 * password is saved. */
.app[data-layout="onboarding"]:has(.auth-split) .bare-top { display: none; }
.auth-split { min-height: calc(100vh - var(--topline-h)); min-height: calc(100dvh - var(--topline-h)); }

/* #/reset opened on purpose ("Change your password"): a page in the app's
 * own layout, the form in one card. */
.auth-page-card { max-width: 560px; }
.auth-page .auth-form { margin-top: 0; }
.auth-page .auth-actions { margin-top: var(--sp-1); }
/* Signed in on someone else's invitation: the address in the title may be long. */
[data-auth^="invite-"] .empty-title { overflow-wrap: anywhere; }

@media screen and (max-width: 767px) {
  .auth h1 { font-size: var(--fs-26); line-height: var(--lh-26); }
}

/* v5 WS-E: two-step sign-in (auth/two-step): the code step and the
 * enrolment's four numbered steps. */
.mfa-page { display: flex; justify-content: center; padding-top: var(--sp-10); }
.mfa { max-width: 520px; }
.mfa-steps { list-style: none; margin: var(--sp-3) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.mfa-step { display: flex; gap: var(--sp-3); padding: var(--sp-4); border: 1px solid var(--line-soft); border-radius: var(--r-control); background: var(--bg-surface); }
.mfa-step.is-current { border-color: var(--accent-line); box-shadow: inset 3px 0 0 var(--accent); }
.mfa-step-mark { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--accent); color: var(--accent-text); font-weight: var(--fw-semibold); font-size: var(--fs-13); }
.mfa-step-text { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; color: var(--text-2); font-size: var(--fs-13); line-height: var(--lh-13); }
.mfa-step-text strong { color: var(--text); font-size: var(--fs-14); font-weight: var(--fw-semibold); }
.mfa-qr { width: 176px; height: 176px; padding: var(--sp-2); border: 1px solid var(--line); border-radius: var(--r-control); background: var(--n-0); image-rendering: pixelated; }
.mfa-key { font-family: var(--font-code); font-size: var(--fs-13); padding: 2px 6px; border-radius: var(--r-2); background: var(--bg-subtle); overflow-wrap: anywhere; user-select: all; }
.mfa-form { margin-top: 0; }

/* T1.33: the code as six cells with one real input over them (the CodeXR code pattern, T1.16 #5).
 * The cells are drawing only (aria-hidden); the input keeps its label, autofill (one-time-code),
 * paste and the screen reader. Each digit sits in its cell: one digit plus its letter-spacing is
 * one cell and one gap. The cells narrow with the field (container units) so a 390px screen
 * needs no sideways scroll; the input's spare width is clipped inside the group. */
.mfa-field { container-type: inline-size; }
.mfa-field .hint { margin: 0; }
.mfa-cells {
  --cell-w: var(--otp-cell-w);
  --cell-w: min(var(--otp-cell-w), calc((100cqi - 5 * var(--otp-gap)) / 6));
  position: relative; width: calc(6 * var(--cell-w) + 5 * var(--otp-gap)); max-width: 100%; height: var(--otp-cell-h);
  /* clip, not hidden: a hidden box is still a scroll container, and when the sixth digit is typed the
   * browser scrolls it (by about half a cell) to show the caret in the input's spare width, cutting the
   * first cell off on its left. A clipped box cannot scroll, so the six cells stay whole. */
  overflow: hidden; overflow: clip; border-radius: var(--r-10);
}
.mfa-cells-row { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(6, var(--cell-w)); gap: var(--otp-gap); pointer-events: none; }
.mfa-cells-row span {
  border: 1px solid var(--line-field); border-radius: var(--r-10); background: var(--bg-surface);
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.auth .mfa-cells .mfa-code,
.auth .mfa-cells .mfa-code:focus,
.auth .mfa-cells .mfa-code:focus-visible,
.auth .mfa-cells .mfa-code[aria-invalid="true"] {
  position: absolute; left: 0; top: 0; z-index: 1; width: calc(100% + var(--cell-w)); height: 100%; min-height: 0; max-width: none;
  padding: 0 0 0 calc((var(--cell-w) - 1ch) / 2); margin: 0;
  border: 0; border-radius: 0; background: transparent; box-shadow: none; outline: none;
  font: var(--fw-medium) 24px/var(--otp-cell-h) var(--font-ui); font-variant-numeric: tabular-nums;
  letter-spacing: calc(var(--cell-w) + var(--otp-gap) - 1ch); color: var(--text); caret-color: var(--accent);
}
/* Focus: every cell takes the brand teal at double weight, drawn inside the cell (never clipped). */
.mfa-cells:focus-within .mfa-cells-row span { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.mfa-cells.is-invalid .mfa-cells-row span { border-color: var(--crit); }
.mfa-cells.is-invalid:focus-within .mfa-cells-row span { box-shadow: inset 0 0 0 1px var(--crit); }
.mfa-form[aria-busy="true"] .mfa-cells { opacity: .72; }
@media (forced-colors: active) {
  .mfa-cells-row span { border-color: CanvasText; }
  .mfa-cells:focus-within .mfa-cells-row span { border-color: Highlight; box-shadow: inset 0 0 0 1px Highlight; }
}
