/* Beta Briefing dashboard — form + auth design system.
 *
 * The dashboard shell (dashboard.css) ships tokens + reading-surface chrome
 * (cards, rails, segmented toggles) but NO general form controls — the portal
 * owned every input-driven page. This stylesheet adds the form vocabulary the
 * relocated portal pages (login, onboarding, claim, settings, smart edit) need,
 * built entirely from the dashboard tokens so theme (cream/graphite) +
 * accent (clay/indigo/forest/plum) + density (regular/compact) all apply for
 * free. Aesthetic matches dashboard.css: 0.5px --rule borders, 5–10px radii,
 * Spectral-italic display, Geist body, Geist-Mono uppercase meta, --accent
 * focus rings, the --ink/--bg-paper high-emphasis pair (the avatar treatment).
 */

/* Form-scoped tokens (danger + control sizing). Kept here so the base token
 * surface in dashboard.css stays focused on the reading experience. */
:root {
  --form-danger:      oklch(0.55 0.16 25);
  --form-danger-soft: color-mix(in oklch, var(--form-danger) 12%, transparent);
  --control-h:        38px;
  --control-radius:   8px;
}
[data-tone="graphite"] {
  --form-danger:      oklch(0.72 0.16 25);
  --form-danger-soft: color-mix(in oklch, var(--form-danger) 18%, transparent);
}
[data-density="compact"] {
  --control-h: 34px;
}

/* ------------------------------------------------------------------ *
 * Fields                                                              *
 * ------------------------------------------------------------------ */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }

.field__label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-65);
}
.field__label .req { color: var(--form-danger); margin-left: 2px; }

.field__hint { font-size: 12.5px; line-height: 1.5; color: var(--ink-50); }
.field__error {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--form-danger);
}

/* Text controls — input / textarea / select. */
.input, .textarea, .select {
  width: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
  background: var(--bg-paper);
  border: 0.5px solid var(--rule-strong);
  border-radius: var(--control-radius);
  padding: 0 12px;
  height: var(--control-h);
  transition: border-color 120ms ease, box-shadow 120ms ease;
  -webkit-appearance: none;
  appearance: none;
}
.textarea {
  height: auto;
  min-height: calc(var(--control-h) * 2);
  padding: 10px 12px;
  line-height: 1.55;
  resize: vertical;
}
.input::placeholder, .textarea::placeholder { color: var(--ink-40); }
.input:hover, .textarea:hover, .select:hover { border-color: var(--ink-40); }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 18%, transparent);
}
.input:disabled, .textarea:disabled, .select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: var(--paper-soft);
}
.input[aria-invalid="true"], .textarea[aria-invalid="true"] {
  border-color: var(--form-danger);
}

/* Native select chevron (appearance:none stripped it). */
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' stroke='%23999' stroke-width='1.2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

/* ------------------------------------------------------------------ *
 * Buttons                                                            *
 * ------------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1;
  height: var(--control-h);
  padding: 0 18px;
  border: 0.5px solid transparent;
  border-radius: var(--control-radius);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 120ms ease, border-color 120ms ease, opacity 120ms ease, transform 60ms ease;
}
.btn:active { transform: translateY(0.5px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn--block { width: 100%; }
.btn--sm { height: 30px; padding: 0 12px; font-size: 12.5px; }

/* Primary = the --ink/--bg-paper high-emphasis pair (matches the avatar),
 * theme-adaptive and always high-contrast. */
.btn--primary { background: var(--ink); color: var(--bg-paper); }
.btn--primary:hover:not(:disabled) { background: var(--ink-80); }

.btn--secondary {
  background: var(--paper-soft);
  border-color: var(--rule-strong);
  color: var(--ink);
}
.btn--secondary:hover:not(:disabled) { border-color: var(--ink-40); }

.btn--ghost { background: transparent; color: var(--ink-65); }
.btn--ghost:hover:not(:disabled) { background: var(--paper-soft); color: var(--ink); }

.btn--danger {
  background: transparent;
  border-color: var(--form-danger);
  color: var(--form-danger);
}
.btn--danger:hover:not(:disabled) { background: var(--form-danger-soft); }

/* ------------------------------------------------------------------ *
 * Toggles / checkboxes / radios                                      *
 * ------------------------------------------------------------------ */
.checkrow { display: flex; align-items: flex-start; gap: 10px; }
.checkrow input[type="checkbox"], .checkrow input[type="radio"] {
  margin-top: 2px;
  width: 16px; height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
.checkrow__label { font-size: 13.5px; color: var(--ink-80); line-height: 1.5; }

/* iOS-style switch for boolean settings. Markup: a <label class="switch">
 * wrapping a hidden checkbox + a <span class="switch__track">. */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
  position: absolute; inset: 0;
  background: var(--ink-30);
  border-radius: 999px;
  transition: background 140ms ease;
}
.switch__track::before {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: var(--bg-paper);
  border-radius: 999px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 140ms ease;
}
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track::before { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Range slider (weights). */
.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: var(--ink-20);
  cursor: pointer;
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px; height: 18px;
  border-radius: 999px;
  background: var(--accent);
  border: 2px solid var(--bg-paper);
  box-shadow: 0 0.5px 2px rgba(0, 0, 0, 0.25);
}
.range::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 999px;
  background: var(--accent);
  border: 2px solid var(--bg-paper);
}
.range:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

/* ------------------------------------------------------------------ *
 * Form layout primitives (settings/smart-edit/onboard reuse these)   *
 * ------------------------------------------------------------------ */
.form-card {
  background: var(--bg-paper);
  border: 0.5px solid var(--rule);
  border-radius: 12px;
  padding: 22px;
  margin-bottom: 18px;
}
.form-card__title {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  font-size: 18px;
  margin: 0 0 4px;
}
.form-card__desc { font-size: 13px; color: var(--ink-50); line-height: 1.55; margin: 0 0 18px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 18px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > .field { flex: 1 1 160px; }

/* Inline status / banner messages inside forms. */
.form-note {
  font-size: 12.5px;
  line-height: 1.5;
  padding: 10px 12px;
  border-radius: 8px;
  border: 0.5px solid var(--rule);
}
.form-note--ok { color: var(--accent-ok); border-color: color-mix(in oklch, var(--accent-ok) 35%, transparent); background: color-mix(in oklch, var(--accent-ok) 8%, transparent); }
.form-note--error { color: var(--form-danger); border-color: color-mix(in oklch, var(--form-danger) 35%, transparent); background: var(--form-danger-soft); }

/* ------------------------------------------------------------------ *
 * Pre-auth shell (login / onboard / claim) — base_public.html.j2     *
 * ------------------------------------------------------------------ */
.auth-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  gap: 18px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-paper);
  border: 0.5px solid var(--rule);
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: 0 24px 64px -32px rgba(0, 0, 0, 0.28);
}
.auth-card--wide { max-width: 760px; }
.auth-brand {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  font-size: 26px;
  letter-spacing: -0.01em;
  text-align: center;
  color: var(--ink);
  display: block;
  text-decoration: none;
}
.auth-subtitle {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-50);
  text-align: center;
  margin-top: 6px;
  margin-bottom: 26px;
}
.auth-legal {
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--ink-40);
  text-align: center;
  margin-top: 18px;
}
.auth-legal a { color: var(--ink-65); text-decoration: underline; }
.auth-footer {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-40);
}
.auth-footer a { color: var(--ink-50); text-decoration: none; }
.auth-footer a:hover { color: var(--ink-80); }

/* Login "check your email" confirmation state. */
.auth-sent { text-align: center; }
.auth-sent__icon { font-size: 34px; line-height: 1; margin-bottom: 14px; }
.auth-sent__title {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  font-size: 22px;
  margin: 0 0 8px;
}
.auth-sent__body { font-size: 14px; color: var(--ink-65); line-height: 1.6; }
.auth-sent__email { color: var(--ink); font-weight: 500; }
.auth-sent__expire {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-40);
  margin-top: 18px;
}

/* Verify interstitial (GH #423). */
.auth-verify { text-align: center; }
.auth-verify__spinner {
  width: 52px; height: 52px;
  margin: 0 auto 22px;
  border-radius: 999px;
  border: 3px solid var(--ink-20);
  border-top-color: var(--accent);
  animation: auth-spin 0.9s linear infinite;
}
@keyframes auth-spin { to { transform: rotate(360deg); } }
.no-js .auth-verify__spinner { display: none; }
.no-js .auth-verify__js-copy { display: none; }
.auth-verify__nojs-copy { display: none; }
.no-js .auth-verify__nojs-copy { display: block; }

/* The impersonation-banner rules moved to dashboard.css: the banner lives in
   the shared top_bar.html.j2 chrome (rendered on EVERY full dashboard page),
   but dashboard_forms.css is only loaded by the settings / smart-edit / public
   shells — so an impersonating admin on a normal page (the impersonation
   landing) got an unstyled banner. They belong with the other top_bar rules. */

@media (max-width: 520px) {
  .auth-card { padding: 28px 22px; }
}
