/*
  Prebuilt auth UI. Every colour, radius and font comes from a CSS custom
  property that the layout injects from the project's theme
  (config/projects/<key>.yml -> ui.theme), so one stylesheet serves every SaaS.
*/

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem 1rem;
  background: var(--auth-background);
  color: var(--auth-text);
  font-family: var(--auth-font-family);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.auth-card {
  width: 100%;
  max-width: 25.5rem;
  background: var(--auth-surface);
  border: 1px solid var(--auth-border);
  border-radius: var(--auth-radius);
  padding: 2rem;
  box-shadow: 0 1px 2px rgb(0 0 0 / 4%), 0 12px 32px -12px rgb(0 0 0 / 12%);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.auth-brand img { max-height: 2.5rem; max-width: 70%; }

.auth-brand h1 {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.auth-brand p {
  margin: 0;
  color: var(--auth-text-muted);
  font-size: 0.9375rem;
}

.auth-field { display: block; margin-bottom: 1rem; }

.auth-field > span {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 550;
  color: var(--auth-text-muted);
}

.auth-field input {
  width: 100%;
  padding: 0.6875rem 0.875rem;
  font: inherit;
  font-size: 1rem;
  color: var(--auth-text);
  background: var(--auth-surface);
  border: 1px solid var(--auth-border);
  border-radius: var(--auth-radius-small);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-field input:focus {
  outline: none;
  border-color: var(--auth-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--auth-accent) 22%, transparent);
}

.auth-field input::placeholder { color: color-mix(in srgb, var(--auth-text-muted) 70%, transparent); }

.auth-field-hint {
  display: block;
  margin-top: 0.3125rem;
  font-size: 0.75rem;
  color: var(--auth-text-muted);
}

.auth-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 2.875rem;
  padding: 0.6875rem 1rem;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--auth-accent-contrast);
  background: var(--auth-accent);
  border: 1px solid transparent;
  border-radius: var(--auth-radius-small);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.05s ease;
}

.auth-button:hover { background: var(--auth-accent-hover); }
.auth-button:active { transform: translateY(1px); }

.auth-button:focus-visible {
  outline: 2px solid var(--auth-accent);
  outline-offset: 2px;
}

.auth-button--secondary {
  color: var(--auth-text);
  background: var(--auth-surface);
  border-color: var(--auth-border);
}

.auth-button--secondary:hover { background: var(--auth-surface-muted); }

.auth-providers { display: flex; flex-direction: column; gap: 0.625rem; }

.auth-providers svg { width: 1.125rem; height: 1.125rem; flex: none; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0;
  color: var(--auth-text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--auth-border);
}

.auth-messages:empty { display: none; }

.auth-message {
  margin-bottom: 1rem;
  padding: 0.75rem 0.875rem;
  border-radius: var(--auth-radius-small);
  font-size: 0.875rem;
  border: 1px solid transparent;
}

.auth-message--alert {
  color: var(--auth-danger);
  background: color-mix(in srgb, var(--auth-danger) 10%, var(--auth-surface));
  border-color: color-mix(in srgb, var(--auth-danger) 35%, transparent);
}

.auth-message--notice {
  color: var(--auth-success);
  background: color-mix(in srgb, var(--auth-success) 10%, var(--auth-surface));
  border-color: color-mix(in srgb, var(--auth-success) 32%, transparent);
}

.auth-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 0.75rem;
  margin-top: 1.25rem;
  font-size: 0.875rem;
  color: var(--auth-text-muted);
}

.auth-links a,
.auth-inline-link {
  color: var(--auth-accent);
  font-weight: 550;
  text-decoration: none;
}

.auth-links a:hover,
.auth-inline-link:hover { text-decoration: underline; }

.auth-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 1rem;
  max-width: 25.5rem;
  color: var(--auth-text-muted);
  font-size: 0.75rem;
  text-align: center;
}

.auth-footer a { color: inherit; text-decoration: underline; }

/* --- account page --- */

.auth-card--wide { max-width: 34rem; }

.auth-section { margin-top: 1.75rem; }

.auth-section h2 {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--auth-text-muted);
}

.auth-rows { display: flex; flex-direction: column; gap: 0.5rem; }

.auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0.875rem;
  background: var(--auth-surface-muted);
  border: 1px solid var(--auth-border);
  border-radius: var(--auth-radius-small);
  font-size: 0.875rem;
}

.auth-row strong { font-weight: 600; }

.auth-row-meta {
  display: block;
  margin-top: 0.125rem;
  color: var(--auth-text-muted);
  font-size: 0.75rem;
}

.auth-pills { display: flex; flex-wrap: wrap; gap: 0.375rem; }

.auth-pill {
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 550;
  border-radius: 999px;
  color: var(--auth-accent);
  background: color-mix(in srgb, var(--auth-accent) 12%, var(--auth-surface));
  border: 1px solid color-mix(in srgb, var(--auth-accent) 28%, transparent);
}

.auth-pill--muted {
  color: var(--auth-text-muted);
  background: var(--auth-surface-muted);
  border-color: var(--auth-border);
}

.auth-plan {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.auth-plan strong { font-size: 1.125rem; }

.auth-button--link {
  width: auto;
  min-height: 0;
  padding: 0.25rem 0.5rem;
  color: var(--auth-danger);
  background: none;
  border: none;
  font-size: 0.8125rem;
  font-weight: 550;
  cursor: pointer;
}

.auth-button--link:hover { text-decoration: underline; }

@media (max-width: 30rem) {
  body { padding: 1rem 0.75rem; justify-content: flex-start; }
  .auth-card { padding: 1.5rem 1.25rem; border-radius: var(--auth-radius); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* --- Rodauth's generated pages ---------------------------------------------
   templates/auth/ (Rodauth's pages) comes from `rails g rodauth:views`, which emits Bootstrap
   class names. Mapping them here keeps those templates upgradeable with the
   gem while still matching the project's theme. */

.auth-rodauth .form-group { margin-bottom: 1rem; }

.auth-rodauth .form-label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 550;
  color: var(--auth-text-muted);
}

.auth-rodauth .form-control {
  width: 100%;
  padding: 0.6875rem 0.875rem;
  font: inherit;
  font-size: 1rem;
  color: var(--auth-text);
  background: var(--auth-surface);
  border: 1px solid var(--auth-border);
  border-radius: var(--auth-radius-small);
}

.auth-rodauth .form-control:focus {
  outline: none;
  border-color: var(--auth-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--auth-accent) 22%, transparent);
}

.auth-rodauth .form-control.is-invalid { border-color: var(--auth-danger); }

.auth-rodauth .invalid-feedback {
  display: block;
  margin-top: 0.3125rem;
  font-size: 0.75rem;
  color: var(--auth-danger);
}

.auth-rodauth .btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 2.875rem;
  padding: 0.6875rem 1rem;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--auth-accent-contrast);
  background: var(--auth-accent);
  border: 1px solid transparent;
  border-radius: var(--auth-radius-small);
  cursor: pointer;
}

.auth-rodauth .btn:hover { background: var(--auth-accent-hover); }

.auth-rodauth p { margin: 0 0 0.75rem; font-size: 0.9375rem; }

.auth-rodauth ul { margin: 0 0 1rem; padding-left: 1.125rem; font-size: 0.9375rem; }

.auth-rodauth li { margin-bottom: 0.375rem; }

.auth-rodauth a { color: var(--auth-accent); font-weight: 550; }

/* The OTP setup page prints the secret, the provisioning URI and a QR code. */
.auth-rodauth svg { max-width: 100%; height: auto; background: #fff; padding: 0.5rem; border-radius: var(--auth-radius-small); }

.auth-rodauth code,
.auth-rodauth .auth-secret {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8125rem;
  word-break: break-all;
  background: var(--auth-surface-muted);
  border-radius: 6px;
}

.auth-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: -0.25rem 0 1rem;
  font-size: 0.875rem;
  color: var(--auth-text-muted);
  cursor: pointer;
}

.auth-checkbox input { width: 1rem; height: 1rem; accent-color: var(--auth-accent); }

/* Provider sign-in starts with a CSRF-protected POST, so each button is a
   one-button form (OmniAuth's request phase). */
.auth-provider-form { margin: 0; }
