/* =============================================================================
   AUTH.CSS  —  Login, registration, passkeys, trust-device, recovery
   Loaded in {% block extra_head %} on auth page templates only.
   Architecture 6 — Executive Console (§6). Single-column, max 420px,
   Heavy Cardstock card on bone canvas. No tier-pro blue, no auth-teal,
   no mkt-slate accents. Ink fills primary CTAs; Oxblood signals error.
   ============================================================================= */

@layer components {

/* ============================================================
   SHARED — Auth, Trust-Device, Recovery card shells
   ============================================================ */

.auth-wrap,
.td-wrap,
.recovery-page {
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 24px 100px;
  background: var(--c-bone);
}

.recovery-page {
  min-height: 100vh;
}

/* Heavy Cardstock card (§8.1) */
.auth-card,
.td-card,
.recovery-card {
  width: 100%;
  max-width: 420px;
  background: var(--c-white);
  border: 1px solid var(--c-rule);
  border-radius: 0;
  padding: 48px 40px 40px;
  box-shadow: none;
}

.recovery-card {
  max-width: 400px;
  padding: 48px 40px 40px;
}

/* ============================================================
   AUTH HEADER — Trusted device + standard sign-in
   ============================================================ */

/* Icon well — neutral hairline-bordered square (no tier-blue tint) */
.auth-icon,
.td-icon {
  width: 52px;
  height: 52px;
  border-radius: 0;
  background: transparent;
  border: 1px solid var(--c-ink);
  color: var(--c-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}
.td-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 28px;
}

.auth-title,
.td-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--c-ink);
  margin: 0 0 8px;
  line-height: 1.2;
}

.auth-email,
.td-sub {
  font-size: 14px;
  font-weight: 300;
  color: var(--c-muted);
  line-height: 1.6;
  margin: 0 0 28px;
}

/* ============================================================
   PRIMARY CTA — Passkey + Long & Lean variants (§8.2)
   ============================================================ */

.btn-passkey {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 32px;
  background: var(--c-ink);
  color: var(--c-white);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: none;
  border: 1px solid var(--c-ink);
  border-radius: 0;
  cursor: pointer;
  white-space: nowrap;
  margin-bottom: 12px;
  transition: opacity 0.2s ease, box-shadow 0.2s ease;
}
.btn-passkey:hover {
  background: var(--c-ink);
  border-color: var(--c-ink);
  color: var(--c-white);
  opacity: 0.8;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}
.btn-passkey:active {
  opacity: 0.7;
}
.btn-passkey:disabled {
  background: var(--c-muted);
  border-color: var(--c-muted);
  color: var(--c-white);
  cursor: not-allowed;
  opacity: 0.6;
  box-shadow: none;
}

/* Ghost passkey button — secondary "use a passkey instead" affordance
   on first-visit / unknown-device. Lives below the primary password form. */
.btn-passkey-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 9px 24px;
  margin-top: 14px;
  background: transparent;
  color: var(--c-ink);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: none;
  border: 1px solid var(--c-ink);
  border-radius: 0;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.2s ease;
}
.btn-passkey-link:hover {
  background: transparent;
  opacity: 0.7;
}
.btn-passkey-link:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ============================================================
   ERROR + NOTICE BANNERS — Oxblood for alerts, neutral for notices
   ============================================================ */

.auth-error {
  display: none;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--c-oxblood);
  background: transparent;
  border: 1px solid var(--c-oxblood);
  border-radius: 0;
  padding: 10px 14px;
  margin-bottom: 12px;
  letter-spacing: 0.02em;
  line-height: 1.5;
}

/* Notice / disclaimer block — neutral hairline + oxblood left rule */
.auth-notice {
  margin: 0 0 16px;
  font-size: 12px;
  line-height: 1.6;
  background: transparent;
  color: var(--c-muted);
  padding: 12px 14px;
  border: 1px solid var(--c-rule);
  border-left: 2px solid var(--c-oxblood);
}

/* ============================================================
   DIVIDER — "or use password"
   ============================================================ */

.auth-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--c-pale);
  margin: 24px 0;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--c-rule);
}

/* ============================================================
   FORM — Labels, inputs, consent rows
   ============================================================ */

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.auth-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--c-muted);
  margin: 16px 0 6px;
  display: block;
}
.auth-label:first-child {
  margin-top: 0;
}

/* Password fallback collapse */
.auth-details summary {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--c-ink);
  cursor: pointer;
  list-style: none;
  margin: 8px 0 16px;
  text-align: center;
  text-decoration: underline;
  text-decoration-color: var(--c-rule);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}
.auth-details summary:hover {
  text-decoration-color: var(--c-ink);
}
.auth-details summary::-webkit-details-marker {
  display: none;
}
.auth-details[open] summary {
  margin-bottom: 18px;
}

/* Consent checkbox rows */
.auth-consent-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  margin-top: 12px;
  font-size: 12px;
  color: var(--c-muted);
  line-height: 1.6;
}
.auth-consent-row input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  accent-color: var(--c-ink);
}
.auth-consent-row .hint {
  margin: 0;
  line-height: 1.6;
}

.auth-consent-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--c-rule);
}

/* ============================================================
   FOOTER LINKS
   ============================================================ */

.auth-foot {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--c-rule);
  font-size: 12px;
  color: var(--c-muted);
  text-align: center;
}
.auth-foot a {
  color: var(--c-ink);
  text-decoration: underline;
  text-decoration-color: var(--c-rule);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.auth-foot a:hover {
  text-decoration-color: var(--c-ink);
}

.auth-forget {
  display: block;
  text-align: center;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--c-pale);
  margin-top: 20px;
  text-decoration: none;
}
.auth-forget:hover {
  color: var(--c-ink);
}

/* Signup CTA — prominent footer for first-time visitors.
   Heavier than .auth-foot because for unknown-device users this is
   the most likely action they need to take. */
.auth-signup-cta {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--c-rule);
  font-size: 13px;
  color: var(--c-muted);
  text-align: center;
}
.auth-signup-cta a {
  color: var(--c-ink);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--c-rule);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  margin-left: 4px;
}
.auth-signup-cta a:hover {
  text-decoration-color: var(--c-ink);
}

.auth-link {
  color: var(--c-ink);
  text-decoration: underline;
  text-decoration-color: var(--c-rule);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.auth-link:hover {
  text-decoration-color: var(--c-ink);
}

/* ============================================================
   TRUST DEVICE PAGE
   ============================================================ */

.td-card {
  text-align: center;
}

.td-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.td-detail {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--c-rule);
  font-size: 11px;
  color: var(--c-pale);
  line-height: 1.6;
}
.td-detail a {
  color: var(--c-ink);
  text-decoration: underline;
  text-decoration-color: var(--c-rule);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.td-detail a:hover {
  text-decoration-color: var(--c-ink);
}

/* ============================================================
   RECOVERY LOGIN — Emergency Access
   ============================================================ */

.recovery-icon {
  width: 56px;
  height: 56px;
  border: 1px solid var(--c-oxblood);
  color: var(--c-oxblood);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  margin-bottom: 24px;
}

.recovery-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--c-ink);
  margin: 0 0 8px;
  line-height: 1.2;
}

.recovery-sub {
  font-size: 13px;
  font-weight: 300;
  color: var(--c-muted);
  margin: 0 0 32px;
  line-height: 1.6;
}

.recovery-label {
  display: block;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--c-muted);
  margin: 0 0 6px;
}

.recovery-input {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--c-rule);
  border-radius: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  margin-bottom: 16px;
  background: var(--c-white);
  color: var(--c-ink);
  box-sizing: border-box;
  transition: border-color 0.15s, background 0.15s;
}
.recovery-input:focus {
  outline: none;
  border-color: var(--c-ink);
  background: var(--c-bone);
}
.recovery-input--mono {
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
}

.recovery-submit {
  width: 100%;
  padding: 12px 32px;
  background: var(--c-ink);
  color: var(--c-white);
  border: 1px solid var(--c-ink);
  border-radius: 0;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  cursor: pointer;
  margin-top: 4px;
  transition: opacity 0.2s ease, box-shadow 0.2s ease;
}
.recovery-submit:hover {
  opacity: 0.8;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.recovery-error {
  background: transparent;
  border: 1px solid var(--c-oxblood);
  border-radius: 0;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--c-oxblood);
  margin-bottom: 20px;
  letter-spacing: 0.02em;
  line-height: 1.5;
}

.recovery-warning-bar {
  background: transparent;
  border: 1px solid var(--c-rule);
  border-left: 2px solid var(--c-oxblood);
  border-radius: 0;
  padding: 12px 14px;
  font-size: 11px;
  color: var(--c-muted);
  margin-bottom: 24px;
  line-height: 1.6;
}

.recovery-back {
  display: block;
  text-align: center;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--c-rule);
  font-size: 11px;
  font-weight: 400;
  color: var(--c-pale);
  text-decoration: none;
}
.recovery-back:hover {
  color: var(--c-ink);
}

/* ============================================================
   PASSKEYS MANAGEMENT PAGE
   ============================================================ */

.pk-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 80px 24px 120px;
}

.pk-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 40px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--c-rule);
  gap: 16px;
  flex-wrap: wrap;
}

.pk-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--c-ink);
  margin: 0;
  line-height: 1.2;
}

.pk-subtitle {
  font-size: 13px;
  font-weight: 300;
  color: var(--c-muted);
  margin: 6px 0 0;
  line-height: 1.5;
}

.btn-add-key {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 32px;
  background: var(--c-ink);
  color: var(--c-white);
  border: 1px solid var(--c-ink);
  border-radius: 0;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.2s ease, box-shadow 0.2s ease;
}
.btn-add-key:hover {
  opacity: 0.8;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

/* ── Key cards ── */
.pk-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-top: 1px solid var(--c-rule);
}

.pk-card {
  background: var(--c-white);
  border: none;
  border-bottom: 1px solid var(--c-rule);
  border-radius: 0;
  padding: 20px 0;
  display: flex;
  align-items: center;
  gap: 16px;
}

.pk-card__icon {
  width: 36px;
  height: 36px;
  border-radius: 0;
  background: var(--c-stone);
  border: 1px solid var(--c-rule);
  color: var(--c-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pk-card__body {
  flex: 1;
  min-width: 0;
}

.pk-card__name {
  font-size: 14px;
  font-weight: 500;
  color: var(--c-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.pk-card__meta {
  font-size: 11px;
  font-weight: 400;
  color: var(--c-pale);
  margin-top: 4px;
  letter-spacing: 0.02em;
}

.pk-card__actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* ── Toggle switch — Ink-on (active), Rule-off ── */
.pk-toggle {
  position: relative;
  width: 40px;
  height: 22px;
  cursor: pointer;
}
.pk-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.pk-toggle__track {
  position: absolute;
  inset: 0;
  border-radius: 0;
  background: var(--c-rule);
  border: 1px solid var(--c-rule);
  transition: background 0.2s, border-color 0.2s;
}
.pk-toggle input:checked ~ .pk-toggle__track {
  background: var(--c-ink);
  border-color: var(--c-ink);
}
.pk-toggle__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--c-white);
  border: 1px solid var(--c-ink);
  box-shadow: none;
  transition: left 0.2s;
}
.pk-toggle input:checked ~ .pk-toggle__thumb {
  left: 22px;
}

/* ── Status badges — White-on-Ink active, transparent muted off ── */
.pk-badge {
  font-size: 9px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 0;
  background: var(--c-ink);
  color: var(--c-white);
  border: 1px solid var(--c-ink);
  text-transform: uppercase;
  letter-spacing: 0.18em;
}
.pk-badge--off {
  background: transparent;
  color: var(--c-muted);
  border: 1px solid var(--c-rule);
}

/* Delete button */
.btn-del {
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  padding: 6px;
  color: var(--c-pale);
  border-radius: 0;
  display: flex;
  align-items: center;
  transition: color 0.15s, border-color 0.15s;
}
.btn-del:hover {
  color: var(--c-oxblood);
  border-color: var(--c-oxblood);
  background: transparent;
}

/* Empty state */
.pk-empty {
  text-align: center;
  padding: 80px 24px;
  color: var(--c-muted);
  font-size: 13px;
  font-weight: 300;
  border: 1px dashed var(--c-rule);
  border-radius: 0;
  background: transparent;
}

/* ── Overlay dialog ── */
.pk-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 26, 0.55);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.pk-overlay.open {
  display: flex;
  animation: astor-rise 0.22s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.pk-dialog {
  background: var(--c-white);
  border: 1px solid var(--c-rule);
  border-radius: 0;
  padding: 40px 36px 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: none;
  position: relative;
}

.pk-dialog__title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--c-ink);
  margin: 0 0 20px;
  line-height: 1.2;
}

.pk-dialog__body {
  font-size: 13px;
  font-weight: 300;
  color: var(--c-muted);
  line-height: 1.6;
}

.pk-dialog input[type=text] {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--c-rule);
  border-radius: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  margin-top: 12px;
  background: var(--c-white);
  color: var(--c-ink);
  box-sizing: border-box;
  transition: border-color 0.15s, background 0.15s;
}
.pk-dialog input:focus {
  outline: none;
  border-color: var(--c-ink);
  background: var(--c-bone);
}

.pk-dialog__msg {
  margin-top: 14px;
  font-size: 12px;
  font-weight: 500;
  min-height: 22px;
  letter-spacing: 0.02em;
}
.pk-dialog__msg--ok {
  color: var(--c-ink);
}
.pk-dialog__msg--err {
  color: var(--c-oxblood);
}

.pk-dialog__foot {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--c-rule);
}

/* ── Dialog buttons — Long & Lean small variants ── */
.btn-primary-sm,
.btn-ghost-sm,
.btn-danger-sm {
  padding: 8px 24px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: none;
  border-radius: 0;
  cursor: pointer;
  transition: opacity 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
}

.btn-primary-sm {
  background: var(--c-ink);
  color: var(--c-white);
  border: 1px solid var(--c-ink);
}
.btn-primary-sm:hover {
  opacity: 0.8;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}
.btn-primary-sm:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-ghost-sm {
  background: transparent;
  color: var(--c-ink);
  border: 1px solid var(--c-ink);
}
.btn-ghost-sm:hover {
  background: transparent;
  opacity: 0.7;
  box-shadow: none;
}

.btn-danger-sm {
  background: var(--c-oxblood);
  color: var(--c-white);
  border: 1px solid var(--c-oxblood);
}
.btn-danger-sm:hover {
  background: var(--c-oxblood-dk);
  border-color: var(--c-oxblood-dk);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  opacity: 1;
}

.pk-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--c-pale);
  padding: 2px 8px;
  border-radius: 0;
  transition: color 0.15s, border-color 0.15s;
}
.pk-close:hover {
  color: var(--c-ink);
  border-color: var(--c-rule);
  background: transparent;
}

/* ============================================================
   RESPONSIVE — Mobile baseline
   ============================================================ */

@media (max-width: 768px) {
  /* iOS zoom prevention — inputs must be ≥ 16px */
  .recovery-input,
  .pk-dialog input[type=text] {
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .auth-wrap,
  .td-wrap,
  .recovery-page {
    padding: 56px 18px 80px;
  }
  .auth-card,
  .td-card,
  .recovery-card {
    padding: 36px 28px 28px;
  }
  .pk-page {
    padding: 56px 18px 80px;
  }
  .pk-card {
    flex-wrap: wrap;
  }
}

} /* end @layer components */
