/* ════════════════════════════════════════════════════════════
   AUTH SCREENS (Counsel)
   lg-*  the sign-in form parts, shared by join (/join), forgot and
         reset password, and the platform admin gate (adminportal.html,
         where .lg-card stays a white sheet on the navy page).
   au-*  the two-pane layout of the Counsel sign-in concept: an
         Obsidian panel with the mark on its ivory tile, a serif line
         and four facts, and the form on ivory paper. Used by join,
         forgot and reset password. Tokens only, except the panel's
         fixed on-dark inks (Pure White / Pure Mint), set once below.

   Mobile first (prompt 034): the rules with no media query are the
   phone's (the form alone, with the full lock-up); the panel joins it
   from 900 px.
════════════════════════════════════════════════════════════ */

.lg-body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--surface-canvas);
  font-family: var(--font-sans);
  color: var(--text-primary);
}

.lg-shell {
  width: 100%;
  min-height: 100vh;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  box-sizing: border-box;
}

/* ── Card (a white sheet; bare inside the two-pane layout) ─── */

.lg-card {
  width: 100%;
  max-width: 420px;
  box-sizing: border-box;
  padding: 28px 24px 24px;
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xl);
  box-shadow: none;
}

.lg-card__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}
.lg-card__brand.xy-logo { display: inline-flex; }
.lg-card__logo { height: 40px; width: auto; }

.lg-card__badge {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--surface-recessed);
  color: var(--text-secondary);
  padding: 3px 8px;
  border-radius: var(--r-sm);
}

.lg-card__heading { margin-bottom: 32px; }

.lg-card__heading h1 {
  margin: 0;
  font-family: var(--font-title, 'Newsreader', Georgia, serif);
  font-size: 26px;
  font-weight: 450;
  line-height: 1.15;
  letter-spacing: -0.012em;
  color: var(--text-primary);
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.lg-card__heading p {
  margin: 12px 0 0;
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--text-muted);
  text-wrap: pretty;
}
.lg-card__heading p strong { color: var(--text-primary); font-weight: 600; overflow-wrap: anywhere; }

/* ── Form ──────────────────────────────────────────────────── */

.lg-form { display: flex; flex-direction: column; gap: 20px; }

.lg-field { display: flex; flex-direction: column; gap: 6px; }

.lg-field label {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--text-primary);
}

.lg-field input {
  width: 100%;
  box-sizing: border-box;
  height: var(--ctl-h-lg);
  padding: 0 14px;
  border: 1px solid var(--border-control);
  border-radius: var(--r-md);
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--text-primary);
  background: var(--surface-input);
  outline: none;
  transition: border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}
.lg-field input::placeholder { color: var(--text-faint); }
.lg-field input:hover { border-color: var(--border-control-hover); }
.lg-field input:focus { border-color: var(--border-focus); box-shadow: var(--ring); }
.lg-field input.is-invalid,
.lg-field input[aria-invalid="true"] { border-color: var(--status-danger); }
.lg-field input.is-invalid:focus,
.lg-field input[aria-invalid="true"]:focus { box-shadow: var(--ring-danger); }

/* A value shown but not changed (the invited email) */
.lg-field input[readonly] { background: var(--surface-recessed); color: var(--text-secondary); cursor: default; }
.lg-field input[readonly]:hover,
.lg-field input[readonly]:focus { border-color: var(--border-control); box-shadow: none; }

.lg-hint { margin: 0; font-size: 13px; line-height: 1.45; color: var(--text-muted); }

/* Password with a show / hide toggle */
.lg-field__pw-wrap { position: relative; }
.lg-field__pw-wrap input { padding-right: 52px; }

.lg-field__toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: none;
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
  color: var(--text-secondary);
  transition: color var(--dur) var(--ease-out), background-color var(--dur) var(--ease-out);
}
.lg-field__toggle:hover { color: var(--text-primary); background: var(--surface-hover); }
.lg-field__toggle:active { scale: 1; }
.lg-field__toggle svg { width: 18px; height: 18px; }
.lg-field__toggle .lg-eye-off { display: none; }
.lg-field__toggle[aria-pressed="true"] .lg-eye { display: none; }
.lg-field__toggle[aria-pressed="true"] .lg-eye-off { display: block; }

/* Live password rules: a dot that becomes a tick */
.lg-rules {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 2px 0 0;
  padding: 0;
  list-style: none;
}
.lg-rules li {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text-muted);
  transition: color var(--dur) var(--ease-out);
}
.lg-rules li::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  border: 1px solid var(--border-control-hover);
  box-sizing: border-box;
}
.lg-rules li.is-met { color: var(--text-primary); }
.lg-rules li.is-met::before { border: 0; background: var(--dot-ready); }

/* ── Messages ──────────────────────────────────────────────── */

.lg-error {
  margin: 0;
  padding: 12px 14px;
  background: var(--status-danger-soft);
  border: 1px solid var(--status-danger);
  border-radius: var(--r-md);
  color: var(--status-danger);
  font-size: 13.5px;
  line-height: 1.5;
}

/* ── Submit (mirrors .btn--primary .btn--lg) ───────────────── */

.lg-submit {
  margin-top: 8px;
  width: 100%;
  height: var(--ctl-h-lg);
  padding: 0 24px;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
  border: 1px solid var(--btn-primary-bg);
  border-radius: var(--r-md);
  box-shadow: none;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-sizing: border-box;
}
.lg-submit:hover:not(:disabled) {
  background: var(--btn-primary-bg-hover);
  border-color: var(--btn-primary-bg-hover);
  color: var(--btn-primary-fg);
}
.lg-submit:active:not(:disabled) {
  background: var(--btn-primary-bg-press);
  border-color: var(--btn-primary-bg-press);
  scale: 1;
  translate: 0 1px;
}
.lg-submit:disabled { opacity: 0.55; cursor: not-allowed; }
.lg-submit:focus-visible { outline: none; box-shadow: 0 0 0 1px var(--border-focus), var(--ring); }

.lg-submit__spinner {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  opacity: 0.85;
  animation: lg-spin 0.7s linear infinite;
}
@keyframes lg-spin { to { transform: rotate(360deg); } }

/* ── Status screens (sent, done, link problem) ─────────────── */

.lg-state-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-bottom: 24px;
  border-radius: 50%;
  border: 1px solid var(--border-control);
  color: var(--status-success);
}
.lg-state-icon svg { width: 22px; height: 22px; }
.lg-state-icon--warn { color: var(--status-warning); }
.lg-state-icon--info { color: var(--text-secondary); }

.lg-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 28px; }
.lg-actions .lg-submit { margin-top: 0; }

.lg-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0 16px;
  font-size: 15px;
  color: var(--text-secondary);
}
.lg-loading__spinner {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border: 2px solid var(--border-control);
  border-top-color: var(--text-primary);
  border-radius: 50%;
  animation: lg-spin 0.7s linear infinite;
}

/* ── "Already have an account?" line ───────────────────────── */

.lg-card__footer {
  margin: 28px 0 0;
  padding-top: 24px;
  border-top: 1px solid var(--border-subtle);
  font-size: 14px;
  color: var(--text-muted);
}

.lg-card__footer a,
.lg-link {
  color: var(--text-primary);
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  border: 0;
  border-bottom: 1px solid var(--border-control);
  padding: 0 0 1px;
  margin-left: 4px;
  background: none;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease-out);
}
.lg-link { margin-left: 0; }
.lg-card__footer a:hover,
.lg-link:hover { border-bottom-color: var(--text-primary); }

.lg-help { margin: 20px 0 0; font-size: 13px; line-height: 1.5; color: var(--text-muted); }
.lg-help a { color: var(--text-secondary); border-bottom: 1px solid var(--border-control); text-decoration: none; }
.lg-help a:hover { color: var(--text-primary); border-bottom-color: var(--text-primary); }

/* Headings that take focus when the screen changes */
.lg-card [tabindex="-1"]:focus,
.lg-card [tabindex="-1"]:focus-visible { outline: none; }

/* ════════════════════════════════════════════════════════════
   Two-pane layout (join, forgot, reset)
════════════════════════════════════════════════════════════ */

.au {
  display: block;
  grid-template-columns: minmax(420px, 600px) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.au-side {
  /* The panel is always Obsidian, in both themes: fixed on-dark inks */
  --au-ink: #F3FAFF;
  --au-ink-2: rgba(243, 250, 255, 0.74);
  --au-rule: rgba(243, 250, 255, 0.16);
  --au-accent: var(--ai-accent);
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: none;
  flex-direction: column;
  padding: 48px 64px;
  box-sizing: border-box;
  background: var(--surface-sidebar);
  color: var(--au-ink);
  overflow: hidden;
}
.au-side .xy-logo { color: var(--au-ink); }
.au-side .xy-logo__tile { width: 36px; height: 36px; border-radius: var(--r-lg); }
.au-side .xy-logo__tile .xy-logo__mark { width: 24px; height: 24px; }

.au-quote {
  margin: auto 0 0;
  font-family: var(--font-title, 'Newsreader', Georgia, serif);
  font-weight: 450;
  font-size: 56px;
  line-height: 1.04;
  letter-spacing: -0.022em;
  color: var(--au-ink);
}
.au-quote em { font-style: italic; color: var(--au-accent); }

.au-facts {
  list-style: none;
  margin: 56px 0 0;
  padding: 0;
  border-top: 1px solid var(--au-rule);
}
.au-facts li {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--au-rule);
  font-size: 14px;
  color: var(--au-ink-2);
}
.au-facts svg { width: 17px; height: 17px; flex-shrink: 0; color: var(--au-accent); }

.au-main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px 16px 20px;
  box-sizing: border-box;
  background: var(--surface-canvas);
}

.au-form {
  width: 100%;
  max-width: 400px;
  margin: 0 auto auto;
  padding: 8px 0 32px;
}
.au .lg-card {
  max-width: 400px;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
}

/* On a phone the form carries the full lock-up; from 900 px the side
   panel carries the wordmark and the form shows the mark alone, as in
   the concept */
.au .lg-card__brand { margin-bottom: 40px; }
.au .lg-card__heading h1 { font-size: 34px; font-weight: 400; line-height: 1.06; letter-spacing: -0.02em; }
.au .lg-card__brand .xy-logo__mark { width: 28px; height: 28px; }
.au .lg-card__brand .xy-logo__word { display: inline; }

/* The footer: 13 px, its two links 44 px tall */
.au-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 16px;
  font-size: 13px;
  color: var(--text-muted);
}
.au-foot nav { display: flex; gap: 20px; }
.au-foot a { display: inline-flex; align-items: center; min-height: 44px; color: var(--text-muted); text-decoration: none; }
.au-foot a:hover { color: var(--text-primary); }

/* Large phones and small tablets */
@media (min-width: 600px) {
  .lg-shell { padding: 40px 24px; justify-content: center; }
  .lg-card { padding: 40px 40px 32px; }
  .au-main { padding: 24px 20px 28px; }
  .au-form { padding-top: 32px; }
  .au .lg-card__heading h1 { font-size: 42px; }
}

/* Tablets and up: the two panes */
@media (min-width: 900px) {
  .lg-hint, .lg-rules li { font-size: 12.5px; }
  .au { display: grid; }
  .au-side { display: flex; }
  .au-main { padding: 48px 64px 40px; }
  .au-form { margin: auto; padding: 48px 0; }
  .au .lg-card__brand { margin-bottom: 32px; }
  .au .lg-card__brand .xy-logo__mark { width: 44px; height: 44px; }
  .au .lg-card__brand .xy-logo__word { display: none; }
  .au-foot { flex-wrap: nowrap; align-items: normal; gap: 16px; font-size: 12.5px; }
  .au-foot a { display: inline; min-height: 0; }

  /* On a status screen (sent, done, link problem) the state icon leads;
     the side panel already carries the mark */
  .au .lg-card:has(> div:not([hidden]) > .lg-state-icon) > .lg-card__brand { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .lg-submit__spinner, .lg-loading__spinner { animation-duration: 1.6s; }
}
