/* The stage before the app (core/stage.js): sign-in, loading, offline and the error page, from
   design/v5/V5Login, V5Loading, V5Offline and V5Error. Ava, the brand line, one centred column. */

.stage {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 48px;
  min-height: 100%;
  padding: max(48px, env(safe-area-inset-top)) 16px max(48px, env(safe-area-inset-bottom));
  text-align: center;
}
.stage-top { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.stage-ava { display: grid; flex: none; place-items: center; width: 150px; height: 120px; overflow: visible; }
.stage-brand { margin: 0; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; }

.stage-body { --disc-gap: 16px; box-sizing: border-box; display: flex; flex-direction: column; align-items: stretch; gap: 16px; width: 100%; max-width: 360px; }
/* sign-in is a little narrower and airier, through You're In too */
.stage-body[aria-label="Sign in"] { --disc-gap: 24px; gap: 24px; max-width: 340px; }

.stage-title { margin: 0; color: var(--fg-strong); font-size: 22px; font-weight: 600; line-height: 28px; }
.stage-text { margin: 0; color: var(--muted); }
.stage-ref { margin: 0; color: var(--muted); font-size: 12px; }
.stage-ref .mono { color: var(--fg); user-select: all; -webkit-user-select: all; }

.stage-form { --disc-gap: 12px; display: flex; flex-direction: column; gap: 12px; margin: 0; }
.stage-label { display: flex; flex-direction: column; }
.stage-field {
  box-sizing: border-box;
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--sep);
  border-radius: 10px;
  background: var(--card);
  color: var(--fg-strong);
  font: inherit;
  font-size: 15px;
  text-align: center;
  transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease);
}
.stage-field { -webkit-user-select: text; user-select: text; }
.stage-field::placeholder { color: var(--placeholder); opacity: 1; }
.stage-field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.stage-field[aria-invalid="true"] { border-color: var(--drift); }
.stage-field[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px var(--drift-soft); }
.stage-field.is-code { height: 48px; font-family: var(--font-mono); font-size: 22px; font-weight: 600; letter-spacing: .12em; }

.stage-line { margin: 0; color: var(--drift-text); font-size: 12px; }
.stage-line.quiet { color: var(--muted); }

/* the view's one primary action */
.stage-pri {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: var(--pri);
  color: var(--fg-strong);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  transition: background-color 120ms var(--ease), opacity 120ms var(--ease);
}
@media (hover: hover) { .stage-pri:hover:not(:disabled) { background: var(--pri-hover); } }
.stage-pri:active:not(:disabled) { background: var(--pri-press); }
.stage-pri:disabled:not(.is-busy) { opacity: .45; }
.stage-spin {
  box-sizing: border-box;
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--ring-faint);
  border-top-color: var(--fg-strong);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
/* reduced motion slows the spinner rather than leaving a frozen arc that looks stuck */
@media (prefers-reduced-motion: reduce) { .stage-spin { animation-duration: 2.4s !important; } }

/* the code step's bottom row: ‹ · Resend Code */
.stage-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) 28px; align-items: center; justify-items: center; }
.stage-back { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 14px; color: var(--muted); }
.stage-resend { height: 28px; padding: 0 10px; border: 0; border-radius: 10px; color: var(--accent-text); font: inherit; font-size: 12px; }
.stage-resend:disabled { color: var(--faint); }
.stage-quiet { align-self: center; height: 28px; padding: 0 10px; border: 0; border-radius: 10px; color: var(--muted); font: inherit; font-size: 12px; }

.stage-in { display: grid; align-self: center; place-items: center; width: 44px; height: 44px; border-radius: 22px; background: var(--good-soft); color: var(--good-text); }

/* over the page: while the app opens, and signing in again mid-use */
.stage-cover,
.signin-gate { position: fixed; z-index: 1000; inset: 0; overflow-y: auto; background: var(--bg); }
.stage-cover { transition: opacity 200ms var(--ease); }
.stage-cover.is-gone { opacity: 0; pointer-events: none; }

/* signing in again mid-use: the app is kept, unseen, with its unsaved edits */
body.signed-out .app { display: none; }
