/* TERA OPTIONS — sign in / create account. One centered card. Requires tokens.css + components.css. */
body { min-height: 100vh; min-height: 100svh; overflow-x: hidden; }

/* ---------- atmosphere ---------- */
.au-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: var(--c-bg); }
.orb { position: absolute; border-radius: 50%; filter: blur(70px); }
.o1 { width: 640px; height: 640px; left: calc(50% - 560px); top: -220px; background: radial-gradient(closest-side, rgba(49, 95, 234, 0.42), transparent); animation: drift1 24s var(--ease-in-out) infinite alternate; }
.o2 { width: 520px; height: 520px; right: calc(50% - 600px); bottom: -160px; background: radial-gradient(closest-side, rgba(56, 189, 248, 0.2), transparent); animation: drift2 28s var(--ease-in-out) infinite alternate; }
.o3 { width: 360px; height: 360px; left: 8%; bottom: 10%; background: radial-gradient(closest-side, rgba(49, 95, 234, 0.18), transparent); animation: drift1 32s var(--ease-in-out) infinite alternate-reverse; }
@keyframes drift1 { to { transform: translate3d(70px, 60px, 0) scale(1.08); } }
@keyframes drift2 { to { transform: translate3d(-60px, -50px, 0) scale(1.1); } }
.au-grid {
  position: absolute; inset: 0;
  background-image: linear-gradient(rgba(148, 163, 184, 0.055) 1px, transparent 1px), linear-gradient(90deg, rgba(148, 163, 184, 0.055) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(ellipse 60% 55% at 50% 40%, #000 15%, transparent 75%);
  mask-image: radial-gradient(ellipse 60% 55% at 50% 40%, #000 15%, transparent 75%);
}

.au-back {
  position: absolute; top: max(var(--s-5), var(--safe-t)); left: max(var(--gutter), var(--safe-l)); z-index: 2;
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px 12px; border-radius: var(--r-pill);
  color: var(--c-text-2); font-size: var(--fs-sm); font-weight: 500; -webkit-tap-highlight-color: transparent;
  border: 1px solid transparent; transition: color var(--dur-1), background var(--dur-1), border-color var(--dur-1);
}
@media (hover: hover) { .au-back:hover { color: var(--c-text); background: rgba(255, 255, 255, 0.04); border-color: var(--c-border); text-decoration: none; } }
.au-back:active { color: var(--c-text); background: rgba(255, 255, 255, 0.06); border-color: var(--c-border); }
.au-back svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- layout ---------- */
.au-main {
  min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 88px max(var(--s-4), var(--safe-r)) max(var(--s-6), var(--safe-b)) max(var(--s-4), var(--safe-l));
}
.au-brand { display: flex; direction: ltr; flex-direction: column; align-items: center; gap: var(--s-3); margin-bottom: var(--s-8); color: var(--c-text); animation: rise var(--dur-4) var(--ease-out) both; }
.au-brand:hover { text-decoration: none; }
.au-brand .wordmark { font-size: 14px; }

.au-card {
  position: relative; width: 100%; max-width: 440px;
  padding: var(--s-6) var(--s-8) var(--s-8);
  background: linear-gradient(180deg, rgba(20, 39, 64, 0.82), rgba(13, 26, 44, 0.86));
  border: 1px solid var(--c-border-strong); border-radius: 24px;
  box-shadow: 0 40px 100px -30px rgba(0, 0, 0, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(18px) saturate(1.2); -webkit-backdrop-filter: blur(18px) saturate(1.2);
  animation: rise var(--dur-4) var(--ease-out) 60ms both;
}
.au-card::before {
  content: ''; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none; padding: 1px;
  background: linear-gradient(160deg, rgba(56, 189, 248, 0.45), transparent 35%, transparent 70%, rgba(49, 95, 234, 0.35));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}
@keyframes rise { from { opacity: 0; transform: translate3d(0, 16px, 0); } }

/* ---------- tabs ---------- */
.au-tabs {
  position: relative; display: grid; grid-template-columns: 1fr 1fr; padding: 4px; margin-bottom: var(--s-8);
  background: rgba(7, 17, 31, 0.6); border: 1px solid var(--c-border); border-radius: var(--r-md);
}
.au-tabs a {
  position: relative; z-index: 1; display: grid; place-items: center; height: 40px; border-radius: 8px;
  color: var(--c-text-2); font-size: var(--fs-sm); font-weight: 600; transition: color var(--dur-2) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) { .au-tabs a:hover { color: var(--c-text); text-decoration: none; } }
.au-tabs a:active { color: var(--c-text); }
.au-tabs a[aria-current="page"] { color: var(--c-text); }
.au-tab-ind {
  position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); border-radius: 8px;
  background: var(--c-surface-3); box-shadow: 0 4px 14px -4px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: transform var(--dur-3) var(--ease-out);
}
.au-card[data-view="register"] .au-tab-ind { transform: translateX(100%); }
.au-card:not([data-view="login"]):not([data-view="register"]) .au-tabs { display: none; }

/* ---------- views ---------- */
.au-view { animation: viewIn var(--dur-3) var(--ease-out) both; }
.au-view.is-leaving { animation: viewOut var(--dur-2) var(--ease-in-out) both; }
@keyframes viewIn { from { opacity: 0; transform: translate3d(0, 8px, 0); } to { opacity: 1; transform: none; } }
@keyframes viewOut { to { opacity: 0; transform: translate3d(0, -6px, 0); } }
.au-title { margin: 0 0 var(--s-1); font-family: var(--font-display); font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; text-align: center; }
.au-sub { margin: 0 0 var(--s-6); color: var(--c-text-2); font-size: var(--fs-sm); text-align: center; }
.au-sub b { color: var(--c-text); }
.au-form { display: grid; gap: var(--s-4); }
.au-form > * { animation: fieldIn var(--dur-4) var(--ease-out) both; }
.au-form > *:nth-child(2) { animation-delay: 40ms; }
.au-form > *:nth-child(3) { animation-delay: 80ms; }
.au-form > *:nth-child(4) { animation-delay: 120ms; }
.au-form > *:nth-child(5) { animation-delay: 160ms; }
.au-form > *:nth-child(6) { animation-delay: 200ms; }
@keyframes fieldIn { from { opacity: 0; transform: translate3d(0, 8px, 0); } }
.au-form .input { background: rgba(7, 17, 31, 0.7); }
.au-form .btn-primary { margin-top: var(--s-2); }
.au-stack { display: grid; gap: var(--s-3); }
.au-link-sm { font-size: var(--fs-xs); font-weight: 500; }
.au-switch { margin: var(--s-6) 0 0; text-align: center; color: var(--c-text-2); font-size: var(--fs-sm); }
.au-switch a { font-weight: 600; }
.au-view .alert-info { margin-top: var(--s-4); }
.pw-rules { margin: 2px 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: var(--fs-xs); color: var(--c-text-3); }
.pw-rules li { display: flex; align-items: center; gap: 6px; transition: color var(--dur-2); }
.pw-rules li::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.6; }
.pw-rules li.ok { color: var(--c-up); }
.pw-rules li.ok::before { opacity: 1; }

.au-success {
  position: absolute; inset: 0; z-index: 3; display: grid; place-content: center; justify-items: center; gap: var(--s-2); text-align: center;
  border-radius: inherit; background: rgba(11, 23, 40, 0.97); animation: viewIn var(--dur-3) var(--ease-out) both;
}
.au-success-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: rgba(34, 179, 154, 0.12); color: var(--c-up); margin-bottom: var(--s-2); }
.au-success-icon svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.au-success b { font-size: var(--fs-xl); }
.au-success span { color: var(--c-text-2); }

/* ---------- footer ---------- */
.au-foot { margin-top: var(--s-8); display: grid; justify-items: center; gap: var(--s-3); text-align: center; animation: rise var(--dur-4) var(--ease-out) 120ms both; }
.au-risk { margin: 0; font-size: var(--fs-xs); color: var(--c-text-3); }
.au-foot nav { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s-2) var(--s-5); font-size: var(--fs-xs); }
.au-foot a { color: var(--c-text-2); }

@media (max-width: 520px) {
  .au-main { padding-top: 76px; justify-content: flex-start; }
  .au-brand { margin-bottom: var(--s-6); }
  .au-card { padding: var(--s-5) var(--s-5) var(--s-6); border-radius: 20px; }
}

/* ---------- touch screens ---------- */
@media (pointer: coarse) {
  .au-back, .au-tabs a { min-height: var(--tap); }
  /* small links get a finger-sized hit area; the negative margins keep the layout where it was */
  .au-link-sm { display: inline-flex; align-items: center; min-height: var(--tap-sm); margin: -9px 0; padding: 0 2px; }
  .au-switch a { display: inline-block; padding: 10px 6px; margin: -10px 0; }
  .au-foot nav { gap: 0 var(--s-2); }
  .au-foot nav a { display: inline-flex; align-items: center; min-height: var(--tap-sm); padding: 0 8px; }
  .au-card .check { padding: 8px 0; margin: -8px 0; }
}
/* phones: the same glow without the GPU cost (no 70px blur filters, no frosted glass over the whole card, and the
   glow holds still: the drift redraws three screen-sized layers every frame and tripled the idle CPU on a phone) */
@media (pointer: coarse), (max-width: 600px) {
  .orb { filter: none; animation: none; }
  .au-card { backdrop-filter: none; -webkit-backdrop-filter: none; background: linear-gradient(180deg, rgba(20, 39, 64, 0.94), rgba(13, 26, 44, 0.96)); }
}
/* short screens (iPhone SE, phones held sideways): the brand moves up beside the back link */
@media (max-width: 520px) and (max-height: 700px), (max-height: 520px) and (orientation: landscape) {
  .au-main { padding-top: max(var(--s-5), var(--safe-t)); justify-content: flex-start; }
  .au-main > .au-brand { flex-direction: row; gap: 10px; min-height: var(--tap); margin-bottom: var(--s-5); }
  .au-main > .au-brand .logo-mark { width: 32px; height: 32px; }
  .au-back ~ .au-main > .au-brand { align-self: flex-end; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .au-back ~ .au-main > .au-brand { align-self: center; }
}
@media (prefers-reduced-motion: reduce) {
  .orb { animation: none; }
  .au-view, .au-form > *, .au-success, .au-card, .au-brand, .au-foot { animation: none; }
  .au-tab-ind { transition: none; }
}

/* ---------- 404 ---------- */
.nf-card { text-align: center; padding-top: var(--s-8); }
.nf-code {
  margin: 0 0 var(--s-2); font-family: var(--font-display); font-weight: 700; font-size: 84px; line-height: 1; letter-spacing: -0.05em;
  background: linear-gradient(180deg, #f4f7fb 10%, rgba(56, 189, 248, 0.55)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.nf-card .au-stack { margin-top: var(--s-2); }

/* referral code (sign-up) */
.au-optional { margin-left: 6px; font-weight: 400; color: var(--c-text-3); font-size: .85em; }
.au-code { text-transform: uppercase; letter-spacing: .06em; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.au-ref-note { margin-top: 6px; font-size: 13px; color: var(--c-text-2); }
.au-otp { text-align: center; font: 600 28px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .4em; padding-inline-start: .4em; direction: ltr; }
#veEmail { word-break: break-all; }

/* Language switch: top corner opposite the Home link (both swap sides in Arabic). */
.au-lang { position: absolute; z-index: 2; top: max(var(--s-5), var(--safe-t)); right: max(var(--gutter), var(--safe-r, 0px)); }
html[dir="rtl"] .au-back { left: auto; right: max(var(--gutter), var(--safe-r, 0px)); }
html[dir="rtl"] .au-back svg { transform: scaleX(-1); }
html[dir="rtl"] .au-lang { right: auto; left: max(var(--gutter), var(--safe-l)); }
html[dir="rtl"] .au-tab-ind { left: auto; right: 4px; }
html[dir="rtl"] .au-card[data-view="register"] .au-tab-ind { transform: translateX(-100%); }
/* Emails and passwords are typed left to right, even on the Arabic page. */
html[dir="rtl"] input[type="email"], html[dir="rtl"] input[type="password"], html[dir="rtl"] input[name="referralCode"] { direction: ltr; text-align: right; }
/* An Arabic placeholder in a code box reads as words, not spaced-out code letters. */
html[lang="ar"] .au-code::placeholder { font-family: var(--font-sans); letter-spacing: 0; }
