/*
 * Universal auth-page foundation. Brand-agnostic: consumes only the --brand-* tokens
 * defined by the active skin (brand.css) and mirrors the admin console's AuthShell
 * (centered card on the hero-colored backdrop).
 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --foreground: var(--brand-foreground, #1f2937);
  --muted-foreground: color-mix(in oklab, var(--foreground), var(--brand-canvas, #fff) 42%);
  --border: color-mix(in oklab, var(--foreground), transparent 87%);
  --input-border: color-mix(in oklab, var(--foreground), transparent 75%);
  --ring: var(--brand-success, #18ab42);
  --radius: var(--brand-radius, 0.25rem);
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--brand-font, -apple-system, 'Segoe UI', sans-serif);
  color: var(--foreground);
  background-color: var(--brand-hero, #005e3f);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.auth-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
  padding: 2rem 1.25rem;
}

.auth-card {
  width: 100%;
  max-width: 456px;
  background: var(--brand-canvas, #ffffff);
  border-radius: calc(var(--radius) + 4px);
  box-shadow:
    0 20px 25px -5px color-mix(in oklab, var(--foreground), transparent 88%),
    0 8px 10px -6px color-mix(in oklab, var(--foreground), transparent 88%);
  padding: 3rem 3rem 2.75rem;
  display: grid;
  justify-items: center;
  gap: 0.75rem;
  text-align: center;
  animation: auth-card-in 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes auth-card-in {
  from {
    opacity: 0;
    transform: translateY(0.75rem);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-card {
    animation: none;
  }
}

@media (max-width: 480px) {
  .auth-shell {
    padding: 1.5rem 1rem;
  }
  .auth-card {
    padding: 2.25rem 1.5rem 2rem;
  }
}

.auth-glyph {
  width: 56px;
  height: 56px;
  margin-bottom: 1rem;
  border-radius: 12px;
}

.auth-step {
  display: inline-block;
  margin: 0;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: var(--brand-tint, #eef4f1);
  color: var(--brand-primary, #005e3f);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.auth-title {
  margin: 0;
  font-size: 1.75rem;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--brand-primary, #005e3f);
  text-wrap: balance;
}

.auth-sub {
  margin: 0;
  font-size: 0.96875rem;
  line-height: 1.5;
  color: var(--muted-foreground);
  text-wrap: pretty;
}

.auth-alert {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.75rem 1rem;
  border: 1px solid color-mix(in oklab, var(--brand-destructive, #b3261e), transparent 80%);
  border-radius: var(--radius);
  background: color-mix(in oklab, var(--brand-destructive, #b3261e), transparent 92%);
  color: var(--brand-destructive, #b3261e);
  font-size: 0.875rem;
  line-height: 1.45;
  text-align: left;
}

.auth-alert--info {
  border-color: color-mix(in oklab, var(--brand-primary, #005e3f), transparent 80%);
  background: var(--brand-tint, #eef4f1);
  color: var(--brand-primary, #005e3f);
}

.auth-form {
  width: 100%;
  margin-top: 1.25rem;
  display: grid;
  gap: 1rem;
}

.field {
  display: grid;
  gap: 0.5rem;
  text-align: left;
}

.field > label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--foreground);
}

.field > input {
  width: 100%;
  height: 2.75rem;
  padding: 0 0.75rem;
  font: inherit;
  font-size: 1rem;
  color: var(--foreground);
  background: var(--brand-canvas, #ffffff);
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field > input:focus-visible {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring), transparent 50%);
}

.otp-input {
  height: 3.25rem !important;
  text-align: center;
  font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace !important;
  font-size: 1.5rem !important;
  letter-spacing: 0.4em;
  font-variant-numeric: tabular-nums;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 2.75rem;
  padding: 0 1.25rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--brand-primary-foreground, #ffffff);
  background: var(--brand-primary, #005e3f);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color 0.15s;
}

.btn:hover {
  background: color-mix(in oklab, var(--brand-primary, #005e3f), black 12%);
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring), transparent 50%);
}

.auth-steps {
  width: 100%;
  margin: 0.25rem 0 0;
  padding: 0 0 0 1.25rem;
  text-align: left;
  color: var(--muted-foreground);
  font-size: 0.875rem;
  line-height: 1.55;
  display: grid;
  gap: 0.375rem;
}

.auth-steps b {
  color: var(--foreground);
  font-weight: 600;
}

.qr-frame {
  margin-top: 0.5rem;
  padding: 0.75rem;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  line-height: 0;
}

.qr-frame > img {
  width: 176px;
  height: 176px;
  image-rendering: pixelated;
}

.manual-key {
  width: 100%;
  text-align: left;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

.manual-key > summary {
  cursor: pointer;
  color: var(--brand-primary, #005e3f);
  font-weight: 600;
  text-align: center;
}

.manual-key-value {
  display: block;
  margin-top: 0.625rem;
  padding: 0.625rem 0.75rem;
  background: var(--brand-tint, #eef4f1);
  border-radius: var(--radius);
  font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  font-size: 0.9375rem;
  letter-spacing: 0.08em;
  color: var(--foreground);
  text-align: center;
  user-select: all;
  word-break: break-all;
}

.requirements {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.25rem;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}

.requirements > li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: color 0.15s;
}

.requirements > li::before {
  content: '';
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--border);
  flex: none;
  transition: background-color 0.15s;
}

.requirements > li.met {
  color: var(--brand-success, #18ab42);
}

.requirements > li.met::before {
  background: var(--brand-success, #18ab42);
}

.auth-footer {
  padding-top: 2.5rem;
  font-size: 0.8125rem;
  color: color-mix(in oklab, var(--brand-hero-foreground, #ffffff), transparent 30%);
}
