/* ============================================================
   Finance House — auth module styles (subtask 57)
   Extends css/style.css (design tokens, .btn, .field, .lightbox).
   Loaded AFTER style.css so page-specific rules win the cascade.
   ============================================================ */

/* ---- [hidden] guard ------------------------------------------------
   Author rules like .btn{display:inline-flex} would otherwise defeat
   the UA's [hidden]{display:none}; auth.js toggles the hidden
   attribute to switch UI states, so it must always win. */
.auth-form[hidden],
.auth-user[hidden],
.auth-nav-user[hidden],
.auth-card-page[hidden],
[data-auth][hidden],
[data-auth-logout][hidden] { display: none !important; }

/* ================= Auth modal overlay (reuses .lightbox) ================= */
/* z-index scale (style.css): header 900 · toTop 950 · video lightbox 9000
   · grain 9998 · cursor 10000/10001 · burst 12000. Auth sits at 9500. */
.lightbox.auth-lightbox { z-index: 9500; }

.lightbox.auth-lightbox .lb-box {
  aspect-ratio: auto;               /* base .lb-box is 16:9 video-shaped */
  width: min(440px, 100%);
  max-height: min(86vh, 760px);
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--surface);
  padding: 30px 28px 24px;
  text-align: left;
}

/* ================= Auth card (shared: modal + auth.html) ================= */
.auth-card { display: block; }

.auth-head { padding-right: 44px; margin-bottom: 4px; }  /* room for .lb-close */
.auth-title { font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.auth-subtitle { margin-top: 6px; font-size: 13.5px; color: var(--muted); line-height: 1.5; }

.auth-tabs {
  display: flex; gap: 6px;
  padding: 5px;
  margin: 18px 0 22px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(1, 3, 10, 0.6);
}
.auth-tab {
  flex: 1 1 0;
  border-radius: 999px;
  padding: 10px 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
  transition: color 0.25s var(--ease), background 0.25s var(--ease), box-shadow 0.25s;
}
.auth-tab:hover { color: var(--text); }
.auth-tab.is-active {
  color: #fff;
  background: linear-gradient(135deg, var(--base), #2E7BFF 55%, var(--accent));
  box-shadow: 0 6px 22px -8px rgba(0, 75, 255, 0.65);
}

/* Forms reuse .field / .field input / .invalid from style.css */
.auth-form .field { margin-bottom: 16px; }
.auth-form .field input { padding: 13px 15px; }
.auth-form .btn-block { margin-top: 6px; }
.auth-form button[disabled],
.auth-form .is-busy { opacity: 0.55; pointer-events: none; }

.auth-error {
  display: none;
  margin-top: 7px;
  font-size: 12.5px;
  line-height: 1.4;
  color: #FF7A7A;                 /* matches .invalid border tone in style.css */
}
.auth-error:not(:empty) { display: block; }

.auth-note {
  margin: 16px 0 0;
  font-size: 12px;
  line-height: 1.55;
  color: #5E6878;
  text-align: center;
}

/* ================= Logged-in header widget (desktop) ================= */
.auth-user:not([hidden]) {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 4px;
}
.auth-user-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.auth-user-balance {
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent);
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(111, 200, 255, 0.07);
  white-space: nowrap;
}

/* Logged-in block inside the mobile #nav drawer (desktop: hidden) */
#nav .auth-nav-user { display: none; }

/* ================= Standalone auth.html page ================= */
.auth-page {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 48px 18px;
}
.auth-card-page {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 30px 28px 26px;
  box-shadow: 0 30px 90px -40px rgba(0, 75, 255, 0.4);
}
.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 19px;
  margin-bottom: 20px;
}
.auth-brand b { color: var(--accent); font-weight: 600; }
.auth-row { display: grid; gap: 10px; margin-top: 20px; }

/* ================= Responsive ================= */
/* style.css L506 hides .header-inner > .btn at <=760px (v4 behavior for
   the "Request access" CTA). TARGETED override: ONLY the two auth
   buttons come back on phones. A global override of L506 is forbidden. */
@media (max-width: 760px) {
  .header-inner > .btn[data-auth] { display: inline-flex; }
  .header-inner .auth-user { display: none !important; }  /* desktop widget off */
  #nav .auth-nav-user:not([hidden]) {
    display: block;
    margin-top: 14px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
  }
  .auth-nav-name { font-family: var(--font-display); font-size: 16px; color: var(--text); }
  .auth-nav-balance {
    margin: 6px 0 14px;
    font-family: var(--font-display);
    font-size: 15px;
    color: var(--accent);
  }
}

/* Narrow tablets: the v4 header (logo + nav + CTA) fills the row here,
   so only the primary Sign up button stays; Log in remains reachable
   via the modal tabs. Only ever hides/shrinks the NEW auth buttons. */
@media (min-width: 761px) and (max-width: 1150px) {
  .header-inner > .btn[data-auth="login"] { display: none; }
  .header-inner > .btn[data-auth="register"] { padding: 9px 16px; font-size: 13px; }
}

/* Small phones: same reasoning — keep one compact primary button. */
@media (max-width: 540px) {
  .header-inner > .btn[data-auth="login"] { display: none; }
  .header-inner > .btn[data-auth="register"] { padding: 9px 14px; font-size: 13px; }
}

/* ---- QA instant mode (?authopen=<mode>&instant=1) --------------------
   Opens the modal during script execution with transitions disabled, so
   it is fully painted in headless captures taken at the load event. */
.auth-lightbox.auth-instant,
.auth-lightbox.auth-instant .lb-backdrop,
.auth-lightbox.auth-instant .lb-box { transition: none !important; }

/* ============================================================
   Email verification step (5-digit code) — added with the
   removal of Google / Microsoft / Facebook sign-in.
   ============================================================ */
.auth-card.is-verifying .auth-tabs { display: none; }

.auth-verify .field input.auth-code-input {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.45em;
  text-align: center;
  padding: 14px 15px;
}
.auth-code-input::placeholder { letter-spacing: 0.45em; color: var(--muted); opacity: 0.6; }

.auth-timer {
  margin: 12px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
  text-align: center;
}

.auth-devcode {
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px dashed var(--accent);
  border-radius: 12px;
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.5;
  text-align: center;
  background: rgba(111, 200, 255, 0.06);
}

.auth-resend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
}
.auth-back {
  background: none;
  border: none;
  padding: 0;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.auth-back:hover { color: var(--text); }

@media (max-width: 540px) {
  .auth-resend-row { flex-direction: column; gap: 12px; }
}

/* ============================================================
   Password management: forgot link, notices, pw lightbox
   ============================================================ */
.auth-forgot {
  display: block;
  margin: -4px 0 16px;
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
  cursor: pointer;
  text-align: right;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.auth-forgot:hover { color: var(--text); }

.auth-notice {
  margin: 0 0 16px;
  font-size: 13.5px;
  line-height: 1.55;
  color: #66FFB2;
}
.auth-notice[hidden] { display: none; }

.auth-done {
  margin: 14px 0 0;
  padding: 10px 14px;
  border: 1px solid rgba(102, 255, 178, 0.35);
  border-radius: 10px;
  background: rgba(102, 255, 178, 0.08);
  font-size: 13.5px;
  line-height: 1.5;
  color: #66FFB2;
  text-align: center;
}
.auth-done[hidden] { display: none; }

/* ============================================================
   Sign-up v1.1 — phone, date of birth, consent checkboxes
   ============================================================ */
.auth-form input[type="date"] { color-scheme: dark; }

.auth-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 2px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.auth-check input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  min-width: 18px;
  margin-top: 1px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(111, 200, 255, 0.04);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
  position: relative;
}
.auth-check input[type="checkbox"]:hover { border-color: rgba(111, 200, 255, 0.55); }
.auth-check input[type="checkbox"]:checked {
  background: linear-gradient(135deg, #2E7BFF, #6FC8FF);
  border-color: #6FC8FF;
  box-shadow: 0 0 12px rgba(0, 75, 255, 0.45);
}
.auth-check input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5.5px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.auth-check input[type="checkbox"].invalid {
  border-color: #FF7A7A;
  box-shadow: 0 0 0 3px rgba(255, 122, 122, 0.15);
}
.auth-check input[type="checkbox"]:focus-visible {
  outline: 2px solid rgba(111, 200, 255, 0.6);
  outline-offset: 2px;
}
.auth-check a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.auth-check a:hover { text-decoration: none; }
.auth-checks-error {
  display: block;
  margin: 2px 0 0;
}

/* ==== v11.4 DESIGN POLISH (auth) ==== */
.auth-form .field input { border-radius: 8px; transition: border-color .15s, box-shadow .15s; }
.auth-form .field input:focus { outline: none; }
.auth-check input[type="checkbox"] { transition: border-color .15s, box-shadow .15s; }
.auth-check input[type="checkbox"]:checked { border-color: rgba(240,185,11,.8); box-shadow: 0 0 0 3px rgba(240,185,11,.12); }
.auth-check a { border-bottom: 1px dotted rgba(111,200,255,.55); }
