/* 17-auth.css — the sign-in page.
   Uses the app's own tokens from 01-tokens.css, so it themes and mirrors
   (RTL/LTR) exactly like the rest of TradePad.
   TradePad · loaded only by login.html. */

/* ── Shell ────────────────────────────────────────────────────────────── */

.auth-body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  overflow-x: hidden;
}

.auth-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}

@media (max-width: 980px) {
  .auth-shell { grid-template-columns: minmax(0, 1fr); }
}

/* ── Brand side ───────────────────────────────────────────────────────── */

.auth-brand {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 56px clamp(32px, 5vw, 76px);
  overflow: hidden;
  border-inline-end: 1px solid var(--line);
  background:
    radial-gradient(120% 90% at 18% 8%, color-mix(in srgb, var(--acc) 9%, transparent) 0%, transparent 58%),
    linear-gradient(160deg, var(--surf) 0%, var(--bg) 70%);
}

@media (max-width: 980px) { .auth-brand { display: none; } }

/* Scanner brackets from the app mark, drawn large and faint behind the copy. */
.auth-brand::before,
.auth-brand::after {
  content: "";
  position: absolute;
  width: clamp(90px, 12vw, 150px);
  height: clamp(90px, 12vw, 150px);
  border: 2px solid var(--acc);
  opacity: .12;
  pointer-events: none;
}
.auth-brand::before {
  inset-block-start: 44px;
  inset-inline-start: 44px;
  border-width: 2px 0 0 2px;
  border-start-start-radius: 26px;
}
.auth-brand::after {
  inset-block-end: 44px;
  inset-inline-end: 44px;
  border-width: 0 2px 2px 0;
  border-end-end-radius: 26px;
}
html[dir="rtl"] .auth-brand::before { border-width: 2px 2px 0 0; border-start-start-radius: 0; border-start-end-radius: 26px; }
html[dir="rtl"] .auth-brand::after  { border-width: 0 0 2px 2px; border-end-end-radius: 0; border-end-start-radius: 26px; }

.auth-brand-inner { position: relative; z-index: 1; max-width: 460px; }

.auth-logo {
  width: 76px;
  height: 76px;
  border-radius: 18px;
  display: block;
  margin-bottom: 26px;
  box-shadow: 0 18px 50px -20px color-mix(in srgb, var(--acc) 55%, transparent);
}

.auth-wordmark {
  font-size: clamp(30px, 3.6vw, 44px);
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.05;
  color: var(--ink);
  margin-bottom: 12px;
}
html[dir="rtl"] .auth-wordmark { letter-spacing: 0; }

.auth-tagline {
  font-size: 14.5px;
  color: var(--dim);
  line-height: 1.75;
  margin-bottom: 34px;
  max-width: 34ch;
}

.auth-points { list-style: none; display: flex; flex-direction: column; gap: 15px; }

.auth-point {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  font-size: 13px;
  color: var(--dim);
  line-height: 1.7;
}
.auth-point .ic { width: 17px; height: 17px; color: var(--acc); flex: 0 0 auto; margin-top: 2px; }
.auth-point b { color: var(--ink); font-weight: 600; display: block; margin-bottom: 1px; }

/* ── Form side ────────────────────────────────────────────────────────── */

.auth-main {
  display: flex;
  flex-direction: column;
  padding: 22px clamp(20px, 4vw, 40px) 30px;
  min-width: 0;
}

.auth-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: auto;
  padding-bottom: 18px;
}

.auth-mark-sm { display: none; align-items: center; gap: 10px; margin-inline-end: auto; }
.auth-mark-sm img { width: 30px; height: 30px; border-radius: 8px; display: block; }
.auth-mark-sm span { font-weight: 800; font-size: 14px; color: var(--ink); }
@media (max-width: 980px) { .auth-mark-sm { display: flex; } }
@media (min-width: 981px) { .auth-top { justify-content: flex-end; } }

/* ── Card ─────────────────────────────────────────────────────────────── */

.auth-card {
  width: 100%;
  max-width: 408px;
  margin: 0 auto;
  padding: clamp(24px, 4vw, 34px);
  background: var(--surf);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-3), var(--hl);
  position: relative;
}

@media (max-width: 480px) {
  .auth-card { border: 0; background: transparent; box-shadow: none; padding: 8px 0 0; }
}

.auth-view[hidden] { display: none; }

.auth-eyebrow {
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: .16em;
  color: var(--mute);
  margin-bottom: 9px;
}
html[dir="rtl"] .auth-eyebrow { letter-spacing: 0; }

.auth-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--ink);
  line-height: 1.3;
  margin-bottom: 7px;
}

.auth-sub {
  font-size: var(--fs-sm);
  color: var(--mute);
  line-height: 1.75;
  margin-bottom: 24px;
}
.auth-sub strong { color: var(--dim); font-weight: 600; overflow-wrap: anywhere; }

/* ── Fields ───────────────────────────────────────────────────────────── */

.auth-field { margin-bottom: 15px; }

.auth-field > label {
  display: block;
  font-size: var(--fs-xs);
  color: var(--dim);
  margin-bottom: 7px;
  font-weight: 600;
}

/* The app's .inp is centre-aligned for numeric entry; credentials read better
   from the start edge. */
.auth-field .inp {
  height: 48px;
  text-align: start;
  font-family: var(--sans);
  font-size: 14px;
  background: var(--surf2);
  border-radius: var(--r-md);
}
.auth-field .inp::placeholder { color: var(--mute); opacity: 1; }
.auth-field .inp:focus { border-color: var(--acc); box-shadow: var(--ring); }
.auth-field .inp[type="email"],
.auth-field .inp[type="password"],
.auth-field .inp[type="text"] { direction: ltr; text-align: start; }
html[dir="rtl"] .auth-field .inp[type="text"]:not(.ltr) { direction: rtl; }

.auth-field.invalid .inp { border-color: var(--dn); }
.auth-field.invalid .inp:focus { box-shadow: 0 0 0 3px var(--dn-dim); }

.auth-hint { font-size: var(--fs-2xs); color: var(--mute); margin-top: 6px; line-height: 1.6; }
.auth-hint.err { color: var(--dn); }

/* Password reveal.
   The wrapper is pinned to LTR to match the input inside it, which is forced
   LTR above because an address or a password always reads left-to-right. Both
   then resolve inline-end to the same edge: without this the input reserved
   its 46px on the right while the button sat on the left, straight on top of
   the text, on every RTL page. */
.auth-pass { position: relative; direction: ltr; }
.auth-pass .inp { padding-inline-end: 46px; }
.auth-pass-toggle {
  position: absolute;
  inset-inline-end: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  color: var(--mute);
  transition: color .12s, background .12s;
}
.auth-pass-toggle:hover { color: var(--ink); background: var(--surf3); }
.auth-pass-toggle .ic { width: 16px; height: 16px; }

/* ── Password strength ────────────────────────────────────────────────── */

.auth-strength { display: flex; align-items: center; gap: 9px; margin-top: 9px; }
.auth-strength-bar {
  flex: 1 1 auto;
  height: 4px;
  border-radius: 99px;
  background: var(--surf3);
  overflow: hidden;
}
.auth-strength-fill {
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: var(--dn);
  transition: width .25s, background .25s;
}
.auth-strength-fill[data-level="2"] { background: var(--warn); }
.auth-strength-fill[data-level="3"] { background: var(--acc); }
.auth-strength-fill[data-level="4"] { background: var(--up); }
.auth-strength-label { font-size: var(--fs-2xs); color: var(--mute); min-width: 62px; text-align: end; }

/* ── Row: remember + forgot ───────────────────────────────────────────── */

.auth-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 4px 0 20px;
}

.auth-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--dim);
  cursor: pointer;
  user-select: none;
}
.auth-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.auth-check .box {
  width: 17px;
  height: 17px;
  border-radius: 5px;
  border: 1.5px solid var(--line2);
  background: var(--surf2);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  transition: background .12s, border-color .12s;
}
.auth-check .box .ic { width: 11px; height: 11px; opacity: 0; color: var(--acc-ink); transition: opacity .12s; }
.auth-check input:checked + .box { background: var(--acc-fill); border-color: var(--acc-fill); }
.auth-check input:checked + .box .ic { opacity: 1; }
.auth-check input:focus-visible + .box { outline: 2px solid var(--acc); outline-offset: 2px; }

.auth-link {
  color: var(--acc);
  font-size: 12px;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}
.auth-link:hover { text-decoration: underline; }
.auth-row .auth-link { margin-inline-start: auto; }

/* ── Buttons ──────────────────────────────────────────────────────────── */

.auth-submit {
  width: 100%;
  height: 48px;
  border-radius: var(--r-md);
  font-size: var(--fs-md);
  font-weight: 700;
  box-shadow: 0 14px 30px -16px color-mix(in srgb, var(--acc-fill) 80%, transparent), inset 0 1px 0 rgba(255, 255, 255, .35);
  background: var(--acc-fill);
  color: var(--acc-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: filter .12s, opacity .12s;
}
.auth-submit:hover:not(:disabled) { filter: brightness(1.06); }
.auth-submit:disabled { opacity: .6; cursor: not-allowed; }

.auth-google {
  width: 100%;
  height: 48px;
  border-radius: var(--r-md);
  font-size: var(--fs-md);
  font-weight: 600;
  background: var(--surf2);
  color: var(--ink);
  border: 1px solid var(--line2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background .12s, border-color .12s;
}
.auth-google:hover { background: var(--surf3); border-color: var(--line2); }
.auth-google svg { width: 18px; height: 18px; flex: 0 0 auto; }

/* Spinner shown while a request is in flight. */
.auth-spinner {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, currentColor 30%, transparent);
  border-top-color: currentColor;
  animation: auth-spin .6s linear infinite;
}
@keyframes auth-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .auth-spinner { animation-duration: 2s; } }

/* ── Divider ──────────────────────────────────────────────────────────── */

.auth-or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  font-size: var(--fs-2xs);
  color: var(--mute);
  letter-spacing: .1em;
}
.auth-or::before, .auth-or::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--line);
}
html[dir="rtl"] .auth-or { letter-spacing: 0; }

/* ── Alerts ───────────────────────────────────────────────────────────── */

.auth-alert {
  display: none;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  font-size: var(--fs-xs);
  line-height: 1.7;
  margin-bottom: 18px;
  border: 1px solid;
}
.auth-alert.show { display: flex; }
.auth-alert .ic { width: 15px; height: 15px; flex: 0 0 auto; margin-top: 2px; }
.auth-alert.err  { background: var(--dn-dim);   border-color: var(--dn);   color: var(--dn); }
.auth-alert.ok   { background: var(--up-dim);   border-color: var(--up);   color: var(--up); }
.auth-alert.warn { background: var(--warn-dim); border-color: var(--warn); color: var(--warn); }
.auth-alert.info { background: var(--acc-dim);  border-color: var(--acc);  color: var(--acc); }

/* ── Switch between sign in / sign up ─────────────────────────────────── */

.auth-switch {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--mute);
  text-align: center;
}
.auth-switch .auth-link { font-size: 12.5px; font-weight: 600; margin-inline-start: 5px; }

.auth-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
  font-size: 12px;
  color: var(--mute);
  background: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
}
.auth-back:hover { color: var(--ink); }
.auth-back .ic { width: 13px; height: 13px; }
html[dir="rtl"] .auth-back .ic { transform: scaleX(-1); }

/* ── Success panel ────────────────────────────────────────────────────── */

.auth-figure {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  background: var(--acc-dim);
  color: var(--acc);
}
.auth-figure .ic { width: 25px; height: 25px; }
.auth-figure.warn { background: var(--warn-dim); color: var(--warn); }

/* ── Footer ───────────────────────────────────────────────────────────── */

.auth-foot {
  margin-top: auto;
  padding-top: 26px;
  text-align: center;
  font-size: var(--fs-2xs);
  color: var(--mute);
  line-height: 1.9;
}
.auth-foot a { color: var(--dim); text-decoration: none; }
.auth-foot a:hover { color: var(--acc); }
.auth-foot-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 8px; }

/* "By creating an account, you agree to …" under the sign-up button. */
.auth-legal {
  margin-top: 12px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--mute);
  text-align: center;
}
.auth-legal a { color: var(--dim); text-decoration: underline; text-underline-offset: 2px; }
.auth-legal a:hover { color: var(--acc); }

/* ── Language menu ────────────────────────────────────────────────────── */

.auth-langwrap { position: relative; }

.auth-langmenu {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 8px);
  z-index: 40;
  min-width: 190px;
  padding: 6px;
  background: var(--surf);
  border: 1px solid var(--line2);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-3), var(--hl);
  display: none;
}
.auth-langmenu.open { display: block; }

.auth-langitem {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  color: var(--dim);
  text-align: start;
  transition: background .1s, color .1s;
}
.auth-langitem:hover { background: var(--surf2); color: var(--ink); }
.auth-langitem[aria-current="true"] { color: var(--ink); background: var(--acc-dim); }
.auth-langitem .ic { width: 14px; height: 14px; margin-inline-start: auto; opacity: 0; }
.auth-langitem[aria-current="true"] .ic { opacity: 1; }

/* ── The app shell stays hidden until the guard has run ───────────────── */

html.auth-blocked body > .shell,
html.auth-blocked body > .mnav { display: none !important; }

/* Arrived through an invite link (login?ref=CODE): who invited them. */
.auth-invite {
  display: flex; align-items: center; gap: 10px;
  margin: -6px 0 18px; padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--acc) 45%, var(--line));
  background: var(--acc-dim); color: var(--ink);
  border-radius: var(--r-md); font-size: var(--fs-sm); font-weight: 600; line-height: 1.6;
}
.auth-invite[hidden] { display: none; }
.auth-invite .ic { width: 18px; height: 18px; color: var(--acc); flex: 0 0 auto; }

/* Two-step sign-in: the code field reads like a code, in any language.
   As specific as html[dir="rtl"] .auth-field .inp[type="text"]:not(.ltr) above,
   and later, so it wins in both directions. */
html .auth-field .inp.auth-code[type="text"]:not(.ltr) {
  font-family: var(--mono);
  font-size: 22px; letter-spacing: .32em; text-align: center;
  direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums;
}
html .auth-field .inp.auth-code.rc[type="text"]:not(.ltr) { font-size: 17px; letter-spacing: .14em; text-transform: uppercase; }
.auth-field .inp.auth-code::placeholder { letter-spacing: .32em; opacity: .35; }

/* ── Phone intro: what TradePad is, in three short lines (the brand panel is hidden below 980px) ── */
.auth-mini { display: none; list-style: none; margin: -4px 0 18px; padding: 0; flex-direction: column; gap: 6px; }
.auth-mini li { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; line-height: 1.6; color: var(--dim); }
.auth-mini .ic { width: 15px; height: 15px; flex: none; margin-top: 3px; color: var(--acc); }
@media (max-width: 980px) { .auth-mini { display: flex; } }
