/* ==========================================================================
   Labour Life practice system: the signed-out screens (SPEC 7.3, 7.4).
   Owner: core (M0). Sign in, forgot password, set a password, first-time setup.

   Each screen is the coal top bar with the logo (.top and .brand from
   shell.css), then one white card on the page colour: 420px at most, 640px
   for setup (.auth--wide). On a phone the card is the full width. Sign-in
   fields are --control-h-lg. Markup comes from js/views/auth.js and setup.js.
   main.js mounts them into <main class="auth-page" id="main">.
   ========================================================================== */

.auth-page {
  display: flex; flex-direction: column;
  min-height: 100vh; min-height: 100dvh;
  background: var(--bg);
}

.auth {
  flex: 1;
  width: 100%; max-width: calc(420px + 2 * var(--gutter));
  margin: 0 auto;
  padding: var(--s4) var(--s3) calc(var(--s6) + env(safe-area-inset-bottom, 0px));
}
.auth--wide { max-width: calc(640px + 2 * var(--gutter)); }

.auth__card { padding: var(--s5) var(--s4); }

@media (min-width: 520px) {
  .auth { padding: clamp(var(--s5), 8vh, var(--s8)) var(--gutter) var(--s7); }
  .auth__card { padding: var(--s6); box-shadow: var(--shadow-lift); }
}

.auth__h { font-size: var(--fs-h1); margin-bottom: var(--s4); overflow-wrap: anywhere; }
.auth__lead { margin-bottom: var(--s4); }
.auth__note { margin-bottom: var(--s4); }
.auth__card .note[tabindex="-1"]:focus { outline: none; }

/* The big fields and the big button of the signed-out forms. */
.auth__form .input { min-height: var(--control-h-lg); }
.auth__form .btn--block { margin-top: var(--s2); }

.auth__alt { margin-top: var(--s4); text-align: center; }
.auth__alt .link { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--s2); }
.auth__fine { margin-top: var(--s1); text-align: center; }

/* The email an invite or a reset link is for, as text. */
.auth__who { margin-bottom: var(--s4); }
.auth__who dd { font-weight: 600; overflow-wrap: anywhere; }

/* The empty and loading states sit inside the card, so they need less air. */
.auth__card > .empty, .auth__card > .loading { padding: var(--s5) 0; }

/* ---------- first-time setup ---------- */

.setup__code { margin-bottom: var(--s5); }
.setup__code .field { margin-bottom: var(--s2); }
.setup__code .input { min-height: var(--control-h-lg); font-family: var(--font-mono); }

/* The two steps as a track. The number sits in a ring: filled for the step
   you are on, a tick for the one that is done. */
.setup__steps {
  display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5);
  margin-bottom: var(--s5); padding: var(--s3) 0;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.setup__step { display: flex; align-items: center; gap: var(--s2); color: var(--ink-mute); font-weight: 500; }
.setup__n {
  display: inline-grid; place-items: center; flex: none;
  width: 28px; height: 28px; border-radius: var(--r-pill);
  border: 1px solid var(--field-line); background: var(--surface); color: var(--ink-soft);
  font: 600 var(--fs-sm)/1 var(--font-body); font-variant-numeric: tabular-nums;
}
.setup__step.is-on { color: var(--ink); font-weight: 600; }
.setup__step.is-on .setup__n { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.setup__step.is-done { color: var(--ink-soft); }
.setup__step.is-done .setup__n { background: var(--success-bg); border-color: var(--success-line); color: var(--success-ink); }

.setup__h { font-size: var(--fs-h3); margin-bottom: var(--s2); }
.setup__form > .muted { margin-bottom: var(--s4); }
.setup__form > .note { margin-bottom: var(--s4); }
.setup__form .btn--block { margin-top: var(--s2); }

/* The server checks: a tick or a cross, the word, and why when it failed. */
.setup__checks { display: grid; gap: var(--s2); margin-bottom: var(--s4); }
.setup__check { display: flex; align-items: flex-start; gap: var(--s3); line-height: var(--lh-snug); }
.setup__mark {
  display: inline-grid; place-items: center; flex: none;
  width: 22px; height: 22px; border-radius: var(--r-pill);
  border: 1px solid var(--success-line); background: var(--success-bg); color: var(--success-ink);
}
.setup__check.is-bad .setup__mark { border-color: var(--danger-line); background: var(--danger-bg); color: var(--danger-ink); }
.setup__check.is-bad .setup__check-t { font-weight: 600; }
.setup__check-t { min-width: 0; padding-top: 1px; }
.setup__why { display: block; margin-top: 2px; font-weight: 400; color: var(--ink-soft); overflow-wrap: anywhere; }

.setup__grid { display: grid; gap: 0 var(--s4); }
@media (min-width: 520px) { .setup__grid { grid-template-columns: minmax(0, 1fr) 8rem; } }

/* The .env lines to paste when PHP may not write the file. */
.setup__manual { display: grid; gap: var(--s3); margin-bottom: var(--s4); }
.setup__env {
  font: 400 1rem/1.5 var(--font-mono);
  white-space: pre; overflow: auto; resize: vertical;
}

@media (forced-colors: active) {
  .setup__n, .setup__mark { border: 1px solid; }
}

/* ---------- the second sign-in step (2 Oct 2026) ----------
   The code step of the sign-in card, the setup screen of an admin who owes
   it, and the setup steps of js/components/second-step.js. index.php links
   every CSS file on every page, so the card of My account uses these too. */

/* A link that is a button: "Use a recovery code", "Start again", "Sign out". */
.auth__linkbtn { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--s2); cursor: pointer; }
.auth__alt--tight { margin-top: 0; }

.second__step { display: grid; gap: var(--s3); }
.second__step > .field { margin-bottom: 0; }
.second__p { line-height: var(--lh-body); margin-bottom: var(--s3); }
.second__step > .second__p { margin-bottom: 0; }
.second__note { margin-bottom: var(--s3); }
.second__row { margin: 0; }
.second__state { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); margin-bottom: var(--s3); }
.acct__second > .note { margin-bottom: var(--s3); }

/* The code field: wide digits, easy to check against the phone. */
.second__code { font-family: var(--font-mono); font-size: 1.125rem; letter-spacing: 0.12em; }

/* The QR code: always black on white, also in the dark setting, so a phone can scan it. */
.second__qrbox { display: grid; place-items: center; min-height: 220px; }
.second__qr {
  display: block; width: 220px; height: 220px; max-width: 100%;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-sm, 4px);
}

/* The key as text, in groups of four. */
.second__keyrow { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); }
.second__key {
  font: 600 1rem/1.5 var(--font-mono); letter-spacing: 0.04em;
  overflow-wrap: anywhere; user-select: all;
}

/* The ten recovery codes, in two columns. */
.second__codes {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2) var(--s4);
  margin: 0; padding: var(--s3) var(--s4); list-style: none;
  border: 1px solid var(--line); border-radius: var(--r-sm, 4px); background: var(--bg);
  font: 600 1rem/1.5 var(--font-mono); letter-spacing: 0.04em;
}
.second__codes li { white-space: nowrap; user-select: all; }

/* ---------- the setup in four steps (9 Oct 2026) ----------
   js/components/second-step.js: "Step n of 4", a bar of four, the title of
   the step, then the step. Big buttons, so a thumb finds them on a phone. */

.second--steps .second__step { gap: var(--s4); }
.second__of {
  margin: 0 0 var(--s2); color: var(--ink-soft);
  font-size: var(--fs-sm); font-weight: 600; letter-spacing: .02em;
}
.second__bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s1); margin-bottom: var(--s4); }
.second__bar span { display: block; height: 4px; border-radius: var(--r-pill); background: var(--line); }
.second__bar span.is-on { background: var(--ink); }
.second__h { font-size: var(--fs-h3); margin: 0 0 var(--s3); }
.second__h:focus { outline: none; }
.second__pw[hidden] { display: none; }

/* The two store links: big enough to tap. */
.second__stores { display: grid; gap: var(--s1); margin: 0; padding: 0; list-style: none; }
.second__store { display: inline-flex; align-items: center; min-height: var(--tap); font-weight: 600; overflow-wrap: anywhere; }

/* The "Add to Google Authenticator" button and the line of a quieter choice under a step. */
.second__app { justify-content: center; text-align: center; }
.second__alt { margin: 0; text-align: center; }
.second__listed { font-weight: 600; overflow-wrap: anywhere; }

/* "Can't scan? Type this key". */
.second__keybox {
  display: grid; gap: var(--s2);
  padding: var(--s3); border: 1px solid var(--line); border-radius: var(--r-sm, 4px); background: var(--bg);
}
.second__keyh { margin: 0; font-weight: 600; }
.second__keybox .fine { margin: 0; }

/* The code of step 3: big digits in the middle. */
.second__code--big { min-height: var(--control-h-lg); font-size: 1.5rem; letter-spacing: .3em; text-align: center; }

.second__codebtns { flex-wrap: wrap; }
.second__help { margin-top: var(--s4); }

/* Print the recovery codes alone (printCodes()): the sheet is on <body> and
   only the printer sees it. */
.second-print { display: none; }
@media print {
  html.is-printing-codes body > *:not(.second-print) { display: none !important; }
  html.is-printing-codes .second-print { display: block; color: #000; background: #fff; font: 12pt/1.5 Arial, Helvetica, sans-serif; }
  .second-print h1 { font-size: 16pt; margin: 0 0 8pt; }
  .second-print ol { font: 600 14pt/1.8 "Courier New", monospace; }
}

@media (forced-colors: active) {
  .second__qr { forced-color-adjust: none; }
  .second__bar span { border: 1px solid; }
}

/* AI apps (MCP), 9 Nov 2026 (SPEC 6.32): My account's card, the consent
   screen /ai/connect, and Admin, Settings, AI apps. */
.ai-body { display: grid; gap: var(--s3); }
.ai-copy { display: flex; gap: var(--s2); align-items: center; }
.ai-copy__v { flex: 1 1 auto; min-width: 0; font-family: var(--font-mono, ui-monospace, monospace); }
.ai-h3 { margin: var(--s2) 0 0; font-size: var(--fs-lg); }
.ai-steps { margin: 0; padding-left: 1.4em; display: grid; gap: var(--s1); list-style: decimal; }
.ai-conns { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.ai-conn { display: flex; gap: var(--s3); align-items: center; justify-content: space-between; padding: var(--s2) 0; border-bottom: 1px solid var(--line); }
.ai-conn:last-child { border-bottom: 0; }
.ai-conn__t { display: grid; gap: var(--s1); min-width: 0; }
.ai-conn__tags { display: flex; flex-wrap: wrap; gap: var(--s1); align-items: center; }
.ai-fs { border: 0; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.ai-fs > legend { font-weight: 600; margin-bottom: var(--s1); padding: 0; }
.ai-parts__grid { display: grid; gap: var(--s1) var(--s3); grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.ai-choice .check__t small { display: block; }
.ai-config { margin: 0; padding: var(--s2); background: var(--sunken); border-radius: var(--radius-sm, 6px); font-size: var(--fs-sm); overflow-x: auto; white-space: pre; }
.ai-tools > summary { cursor: pointer; font-weight: 600; padding: var(--s3) 0; }
.ai-tools__part h4 { margin: var(--s2) 0 0; }
.ai-tools__part ul, .ai-recent { margin: var(--s1) 0 0; padding-left: 1.2em; list-style: disc; }
.ai-tools__w, .ai-recent__no { color: var(--ink-mute); }
.ai-connect { display: grid; gap: var(--s3); }
@media (max-width: 719px) {
  .ai-conn { flex-direction: column; align-items: stretch; }
  .ai-copy { flex-direction: column; align-items: stretch; }
}
.ai-form { display: grid; gap: var(--s3); }
.ai-guides { display: grid; gap: var(--s2); }
.ai-guides > .fine { margin: 0; }
.ai-guide { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.ai-guide[open] { border-color: var(--line-strong); }
.ai-guide__s { cursor: pointer; display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s1) var(--s2); padding: var(--s3) var(--s4); min-height: 44px; list-style: none; }
.ai-guide__s::-webkit-details-marker { display: none; }
.ai-guide__s::before { content: '+'; font-weight: 600; width: 1em; flex: 0 0 auto; }
.ai-guide[open] > .ai-guide__s::before { content: '\2212'; }
.ai-guide > .ai-steps, .ai-guide > .fine { margin: 0 var(--s4) var(--s3); }
.ai-guide > .ai-steps { padding-left: 1.6em; }

