/* styles/auth.css — standalone styling for /login, /accept-invite, /reset-password.
 *
 * Mobile-first per STYLE.md §4. A premium design-bible entry: deep-black canvas,
 * a graphite card with a hairline border + top rim-light, mono UPPERCASE eyebrow
 * voice, a Saira headline, and ONE charge of Energy Red on the CTA. The local
 * --auth-* layer now maps onto the bible tokens (tokens.css + bible.css load
 * first) so it inherits the same Light / Dark(MAX) / Auto cascade — no flash,
 * no redefined values. Light stays calm; Dark IS the MAX performance layer.
 */

:root {
  --auth-bg:           var(--bg);
  --auth-card:         var(--panel);
  --auth-fg:           var(--text-primary);
  --auth-muted:        var(--text-muted);
  --auth-border:       var(--border);
  --auth-input:        var(--bg-sunken);
  --auth-accent:       var(--brand);          /* Energy Red brand CTA */
  --auth-accent-hover: var(--brand);
  --auth-ms:           #2f2f2f;
  --auth-ms-hover:     #181818;
  --auth-err:          var(--red);
  --auth-ok:           var(--green);
  --auth-shadow:       var(--edge-highlight), var(--sh-2);
}
[data-theme="dark"] {
  --auth-ms:           #ffffff;
  --auth-ms-hover:     #ebebeb;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--auth-bg);
  color: var(--auth-fg);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  touch-action: pan-x pan-y;
}

.auth-shell {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
/* Ember glow rising behind the card — the bible's signature top-of-frame flare.
   Pinned behind content (card establishes its own stacking via box-shadow). */
.auth-shell::before {
  content: '';
  position: fixed;
  inset: -20% 0 auto 0;
  height: 70vh;
  background: var(--gradient-ember);
  pointer-events: none;
  z-index: 0;
}

.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  background: var(--auth-card);
  border: 1px solid var(--auth-border);
  border-radius: var(--r-lg);
  box-shadow: var(--auth-shadow);
  padding: 32px 28px 28px;
}

.auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}
.auth-logo img { height: 36px; width: auto; }
.auth-logo .logo-dark { display: none; }
[data-theme="dark"] .auth-logo .logo-light { display: none; }
[data-theme="dark"] .auth-logo .logo-dark  { display: inline; }

.auth-h1 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: var(--tracking-tight, -0.015em);
  font-size: 24px;
  line-height: var(--lh-snug, 1.18);
  color: var(--text-primary);
  text-align: center;
  margin: 6px 0 4px;
}
.auth-subtitle {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: var(--tracking-eyebrow, 0.2em);
  text-align: center;
  color: var(--auth-muted);
  font-size: var(--fs-xs, 11.5px);
  margin: 0 0 22px;
}

.auth-btn {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  border: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: var(--fw-semi, 600);
  cursor: pointer;
  transition: background var(--hover-dur, 0.15s) var(--hover-ease, ease),
              box-shadow var(--hover-dur, 0.15s) var(--hover-ease, ease),
              transform 0.05s ease;
}
.auth-btn:active { transform: translateY(1px); }
.auth-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.auth-btn:focus-visible { outline: none; box-shadow: var(--ring-focus); }

.auth-btn-primary {
  background: var(--auth-accent);
  color: #fff;
}
.auth-btn-primary:hover:not(:disabled) {
  background: var(--auth-accent-hover);
  box-shadow: var(--glow-red);
}
.auth-btn-primary:focus-visible { box-shadow: var(--glow-red), var(--ring-focus); }

.auth-btn-ms {
  background: var(--auth-ms);
  color: #fff;
  margin-bottom: 16px;
}
[data-theme="dark"] .auth-btn-ms { color: #111; }
.auth-btn-ms:hover:not(:disabled) { background: var(--auth-ms-hover); }
.auth-btn-ms svg { width: 18px; height: 18px; flex: 0 0 18px; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--auth-muted);
  font-family: var(--font-mono);
  font-size: var(--fs-2xs, 10.5px);
  text-transform: uppercase;
  letter-spacing: var(--tracking-eyebrow, 0.2em);
  margin: 16px 0;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--auth-border);
}

.auth-field { margin-bottom: 14px; }
.auth-field-mfa { margin-bottom: 18px; }
.auth-label {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--fs-2xs, 10.5px);
  font-weight: var(--fw-semi, 600);
  text-transform: uppercase;
  letter-spacing: var(--tracking-eyebrow, 0.2em);
  margin-bottom: 7px;
  color: var(--auth-muted);
}
.auth-input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--auth-border);
  border-radius: var(--r-sm);
  background: var(--auth-input);
  color: var(--auth-fg);
  font-family: var(--font-sans);
  font-size: 16px;
  outline: none;
  transition: border-color var(--dur-fast, 0.12s) var(--ease-standard, ease),
              box-shadow var(--dur-fast, 0.12s) var(--ease-standard, ease);
}
.auth-input:focus {
  border-color: var(--auth-accent);
  box-shadow: var(--ring-focus);
}

.auth-code-input {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.3em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.auth-msg {
  font-family: var(--font-sans);
  font-size: 13px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  margin-bottom: 14px;
  display: none;
}
.auth-msg.err {
  background: var(--error-tint);
  color: var(--auth-err);
  border: 1px solid color-mix(in srgb, var(--red) 32%, transparent);
  display: block;
}
.auth-msg.ok {
  background: color-mix(in srgb, var(--green) 10%, transparent);
  color: var(--auth-ok);
  border: 1px solid color-mix(in srgb, var(--green) 28%, transparent);
  display: block;
}

.auth-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  font-size: 13px;
}
.auth-link {
  color: var(--auth-accent);
  text-decoration: none;
  font-weight: var(--fw-medium, 500);
  padding: 8px 0;
}
.auth-link:hover { text-decoration: underline; }
.auth-link:focus-visible {
  outline: none;
  border-radius: var(--r-xs);
  box-shadow: var(--ring-focus);
}

.auth-hint {
  color: var(--auth-muted);
  font-size: 12px;
  line-height: var(--lh-normal, 1.35);
  margin: 7px 0 0;
}

.auth-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 0;
  color: var(--auth-muted);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 13px;
  padding: 8px 0;
  margin-top: 10px;
  transition: color var(--hover-dur, 0.15s) var(--hover-ease, ease);
}
.auth-back:hover { color: var(--text); }
.auth-back:focus-visible {
  outline: none;
  border-radius: var(--r-xs);
  box-shadow: var(--ring-focus);
}

.hidden { display: none !important; }

@media (max-width: 480px) {
  .auth-card { padding: 24px 20px 22px; border-radius: var(--r-lg); }
  .auth-h1 { font-size: 20px; }
}

/* ================================================================ AUTH LOGO ANIMATION
   The sign-in .max-lockup lives in .auth-logo. We give it:
   1. A one-time turbine spool-up on page load (auth-logo-spinup, 2.2s):
      slow catch → explosive acceleration to ~2 rotations → eases to rest at 45°.
   2. After the spool-up settles, a perpetual gentle orbit (auth-logo-orbit, 3.6s):
      a slow lazy arc that keeps the ring feeling alive — a running engine at idle.
   The energy layer (.mk-energy) gets the orbit. The brand mark host gets the
   one-time glow bloom. prefers-reduced-motion: skip all motion, show a soft
   static Energy Red ring glow instead.

   The lockup uses --d:58px (set inline on login.html). The animation targets
   .auth-logo .max-lockup so it only fires on the auth pages, never the dashboard. */

/* spool-up keyframes: identical signature to design-bible turbine, scaled to 2 turns */
@keyframes auth-spinup {
  0%   { transform: rotate(0deg); }
  6%   { transform: rotate(14deg); }
  14%  { transform: rotate(80deg); }
  26%  { transform: rotate(360deg); }
  50%  { transform: rotate(600deg); }
  74%  { transform: rotate(700deg); }
  88%  { transform: rotate(717deg); }
  96%  { transform: rotate(718deg); }
  100% { transform: rotate(720deg); }  /* rest at 45° = 2 full turns so arc lands back at 45° */
}

/* blur band: ring smears to a hot band at peak RPM mid-spool, clears by end */
@keyframes auth-spinup-blur {
  0%, 6%  { filter: blur(0); }
  28%     { filter: blur(1.5px); }
  48%     { filter: blur(4px); }
  62%     { filter: blur(6px); }
  76%     { filter: blur(2px); }
  88%     { filter: blur(0.5px); }
  100%    { filter: blur(0); }
}

/* steady-state gentle orbit at idle: one lazy arc per ~3.6s */
@keyframes auth-logo-orbit {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* glow bloom: energy-red halo on the lockup during the spool peak */
@keyframes auth-logo-bloom {
  0%   { filter: drop-shadow(0 0 4px  color-mix(in srgb, var(--brand, #ff381f) 12%, transparent)); }
  40%  { filter: drop-shadow(0 0 18px color-mix(in srgb, var(--brand, #ff381f) 72%, transparent)) brightness(1.1); }
  70%  { filter: drop-shadow(0 0 10px color-mix(in srgb, var(--brand, #ff381f) 48%, transparent)); }
  100% { filter: drop-shadow(0 0 6px  color-mix(in srgb, var(--brand, #ff381f) 24%, transparent)); }
}

/* ---------- Apply the animation sequence to the auth-logo lockup ---------- */

/* CONSISTENT slow spin — no spool-up. The whole ring (band + energy + shadow) turns as
   one rigid unit at a calm, constant rate from load; the hot spot + its opposite shadow
   stay locked 180° apart. The .max-mark--fade mask is static so the "max" wordmark threads
   cleanly through the fixed gap while the ring turns behind it. */
.auth-logo .max-lockup .mk-band,
.auth-logo .max-lockup .mk-energy,
.auth-logo .max-lockup .mk-shadow {
  animation: auth-logo-orbit 9s linear infinite;
  transform-origin: 50% 50%;
}

/* Sign-in wordmark nudged ~2px lower than the shared lockup default — at this large
   (58px) size it read a touch high in the ring; this optically re-centers it. Scoped to
   .auth-logo so the header / favicon / other lockups are untouched. */
.auth-logo .max-lockup .mk-word {
  transform: translate(-50%, calc(-50% - var(--d, 58px) * 0.05));
}

/* (No spool-up bloom — the ring just spins slowly with the static resting glow below.) */

/* The lock at rest: subtle energy red aura on the ring in dark mode (brand presence).
   In light mode it's a lighter tint so it reads on the card background. */
.auth-logo .max-lockup .max-mark {
  transition: filter 0.4s ease;
  filter: drop-shadow(0 0 calc(var(--d, 58px) * 0.11) color-mix(in srgb, var(--brand, #ff381f) 20%, transparent));
}
[data-theme="dark"] .auth-logo .max-lockup .max-mark {
  filter: drop-shadow(0 0 calc(var(--d, 58px) * 0.15) color-mix(in srgb, var(--brand, #ff381f) 35%, transparent));
}

/* ---------- prefers-reduced-motion — static red glow, no spin ---------- */
@media (prefers-reduced-motion: reduce) {
  .auth-logo .max-lockup .mk-band,
  .auth-logo .max-lockup .mk-energy,
  .auth-logo .max-lockup .mk-shadow {
    animation: none;
  }
  .auth-logo .max-lockup {
    animation: none;
  }
  .auth-logo .max-lockup .max-mark {
    filter: drop-shadow(0 0 calc(var(--d, 58px) * 0.22) color-mix(in srgb, var(--brand, #ff381f) 55%, transparent));
  }
}
