/* ==========================================================================
   Auth page (log in / register / reset) — builds on styles.css
   ========================================================================== */

.auth-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- background: grid + faint chart lines ---------- */
.auth-bg {
  position: fixed; inset: 0; z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(700px 420px at 50% 0%, rgba(37, 99, 235, 0.16), transparent 70%),
    var(--bg);
}
.auth-bg::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(125, 155, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(125, 155, 255, 0.06) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 30%, #000 30%, transparent 80%);
  mask-image: radial-gradient(ellipse 80% 70% at 50% 30%, #000 30%, transparent 80%);
}
.auth-lines { position: absolute; inset: 0; width: 100%; height: 100%; }
.auth-lines path {
  fill: none;
  stroke: rgba(96, 165, 250, 0.2);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}
.auth-lines .glow {
  stroke: rgba(96, 165, 250, 0.45);
  stroke-width: 1.5;
  filter: drop-shadow(0 0 6px rgba(59, 130, 246, 0.8));
}

/* above the fixed background; the header keeps its own sticky z-index: 50 from styles.css */
.auth-main, .auth-footer { position: relative; z-index: 1; }

/* ---------- header controls ---------- */
.auth-nav .nav-actions { gap: 10px; }

.lang { position: relative; }
.lang-btn {
  display: flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-2);
  cursor: pointer;
}
.lang-btn svg:last-child { transition: transform 0.2s; }
.lang-btn[aria-expanded="true"] svg:last-child { transform: rotate(180deg); }

.flag {
  display: block; flex: none;
  width: 24px; height: 16px;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
}
.flag svg { width: 100%; height: 100%; }

.lang-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 60;
  min-width: 190px;
  list-style: none; margin: 0; padding: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: 0 24px 48px -16px rgba(0, 0, 0, 0.85);
}
.lang-menu button {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 44px; padding: 0 12px;
  border: 0; border-radius: 8px;
  background: none;
  color: var(--text-2);
  font-size: 15px; text-align: left;
  cursor: pointer;
}
.lang-menu button[aria-pressed="true"] { background: var(--blue-soft); color: var(--text); }

.user-btn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-2);
}

@media (hover: hover) {
  .lang-btn:hover, .user-btn:hover { color: var(--text); border-color: rgba(96, 165, 250, 0.45); }
  .lang-menu button:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }
}

/* ---------- layout ---------- */
.auth-main {
  flex: 1;
  width: 100%; max-width: 480px;
  margin: 0 auto;
  padding: 48px max(var(--gutter), env(safe-area-inset-right)) 32px max(var(--gutter), env(safe-area-inset-left));
  display: flex; flex-direction: column; gap: 16px;
}
.auth-wrap { position: relative; }

/* glowing panel behind the top of the card */
.auth-glow {
  position: absolute;
  top: -32px; left: calc(-1 * var(--gutter)); right: calc(-1 * var(--gutter));
  height: 300px;
  border: 1px solid rgba(96, 165, 250, 0.14);
  border-bottom: 0;
  background:
    radial-gradient(ellipse 60% 80% at 50% 0%, rgba(59, 130, 246, 0.38), transparent 70%),
    linear-gradient(180deg, rgba(37, 99, 235, 0.12), transparent);
  -webkit-mask-image: linear-gradient(#000 45%, transparent);
  mask-image: linear-gradient(#000 45%, transparent);
  pointer-events: none;
}

/* ---------- card ---------- */
.auth-card {
  position: relative;
  padding: 36px 28px 28px;
  border-radius: 22px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, rgba(17, 24, 43, 0.97), rgba(11, 16, 30, 0.98));
  box-shadow: 0 30px 80px -40px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  text-align: center;
}
.auth-card h1 {
  font-family: var(--font-display);
  font-size: 32px; font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.auth-card h1:focus { outline: none; }
.auth-sub { margin: 8px 0 28px; color: var(--text-2); }
.auth-card h1 + .auth-form { margin-top: 28px; } /* views without a subtitle */

/* ---------- form ---------- */
.auth-form { display: grid; gap: 18px; text-align: left; }

.field > label,
.label-row label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-2);
  font-size: 14px; font-weight: 500;
}

.auth-form input[type="email"],
.auth-form input[type="text"],
.auth-form input[type="password"] {
  display: block;
  width: 100%; height: 54px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: #060911;
  color: var(--text);
  font: inherit;
  font-size: 16px; /* 16px+ stops iOS zooming in on focus */
  transition: border-color 0.2s, box-shadow 0.2s;
}
.auth-form input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25); }

/* keep browser autofill dark */
.auth-form input:-webkit-autofill {
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  box-shadow: 0 0 0 1000px #060911 inset;
  transition: background-color 9999s;
}
.auth-form input:-webkit-autofill:focus { box-shadow: 0 0 0 1000px #060911 inset, 0 0 0 3px rgba(59, 130, 246, 0.25); }

.field.invalid input { border-color: var(--down); }
.field.invalid input:focus { box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.22); }
/* label with a link beside it, e.g. Referral code (Don't have a code?) */
.label-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; margin-bottom: 8px; }
.label-row label { margin-bottom: 0; }
.label-link { padding: 4px 0; color: var(--blue-bright); font-size: 14px; font-weight: 500; }
.field-error { margin-top: 6px; color: var(--down); font-size: 13px; }
.field-error:empty { display: none; }
.field-hint { margin-top: 6px; color: var(--muted); font-size: 13px; }
.field.invalid .field-hint { display: none; }

.password-wrap { position: relative; }
.password-wrap input { padding-right: 56px; }
.reveal-btn {
  position: absolute; top: 50%; right: 5px;
  transform: translateY(-50%);
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 0; border-radius: 10px;
  background: none;
  color: var(--text-2);
  cursor: pointer;
}
.reveal-btn .eye-off { display: none; }
.reveal-btn[aria-pressed="true"] .eye { display: none; }
.reveal-btn[aria-pressed="true"] .eye-off { display: block; }

/* status message (e.g. "not connected yet", server errors) */
.form-status {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(96, 165, 250, 0.3);
  background: var(--blue-soft);
  color: var(--text);
  font-size: 14px;
}
.form-status:empty { display: none; }
.form-status.error { border-color: rgba(248, 113, 113, 0.4); background: rgba(248, 113, 113, 0.1); }

/* submit button with loading spinner */
.submit-btn { position: relative; height: 54px; margin-top: 4px; font-size: 17px; }
.submit-btn[disabled] { cursor: progress; }
.submit-btn.loading .btn-label { visibility: hidden; }
.submit-btn.loading::after {
  content: "";
  position: absolute; inset: 0;
  width: 22px; height: 22px; margin: auto;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* links */
.auth-link { color: var(--blue-bright); font-weight: 600; }
.forgot-link { display: inline-block; margin-top: 18px; padding: 8px; }
.auth-legal { margin-top: 16px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.auth-legal a { color: var(--text-2); text-decoration: underline; text-underline-offset: 2px; }
.auth-switch { margin-top: 12px; color: var(--text-2); }
.auth-switch a { display: inline-block; padding: 8px 2px; color: var(--blue-bright); font-weight: 600; }
.forgot-link + .auth-switch { margin-top: 4px; }
@media (hover: hover) {
  .auth-link:hover, .auth-switch a:hover, .label-link:hover { text-decoration: underline; }
  .auth-legal a:hover { color: var(--text); }
}

/* ---------- help card ---------- */
.help-card {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 22px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.help-icon {
  flex: none;
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(96, 165, 250, 0.25);
  background: var(--blue-soft);
  color: var(--blue-bright);
}
.help-card h2 {
  margin: 2px 0 4px;
  font-family: var(--font);
  font-size: 17px; font-weight: 700;
  letter-spacing: 0; line-height: 1.3;
}
.help-card p { margin-bottom: 8px; color: var(--text-2); font-size: 14px; }
.help-card .auth-link { display: inline-block; padding: 4px 0; font-size: 15px; }

/* ---------- footer ---------- */
.auth-footer { padding: 8px var(--gutter) 28px; text-align: center; color: var(--muted); font-size: 12.5px; }

/* ---------- phones ---------- */
@media (max-width: 640px) {
  .auth-main { padding-top: 32px; }
  .auth-card { padding: 30px 20px 22px; border-radius: 20px; }
  .auth-card h1 { font-size: 28px; }
  .auth-sub { margin-bottom: 24px; }
  .lang-btn { padding: 0 10px; }
  .help-card { padding: 18px; gap: 14px; }
  .help-icon { width: 44px; height: 44px; }
}
