/* === Auth pages — signup / login / reset =================================
 * Adds the bits the Saqqar shell doesn't already ship: email chip,
 * OTP input, link-style buttons, resend row, step fade.
 * All other styling (.t-text, .t-input, .btn-gradient, .btn-ghost, etc)
 * comes from the existing app.css / chat-v2.css. */

[hidden] { display: none !important; }

/* ==========================================================================
 * Auth layout — self-contained, single centered card (no Tailwind needed).
 * The previous two-panel layout relied on Tailwind's `lg:flex` to reveal the
 * branding panel, but app.css ships `.hidden { display:none !important }`,
 * which always won — so the logo/identity never rendered. This replaces it.
 * ====================================================================== */
.auth-shell {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  overflow: hidden;
  background-color: var(--bg);
}
/* Hyperspace warp — canvas of stars streaking radially from centre.
   Rendered by the inline script in _auth_shell.html; sits behind the card. */
.auth-warp-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
  pointer-events: none;
}

.auth-topbar {
  position: absolute;
  top: 18px;
  inset-inline-end: 22px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 10;
}

.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 410px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 38px 34px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(16px);
  box-sizing: border-box;
}

/* Old-TV "signal" border — a bright segment sweeps the perimeter while
   flickering like a screen locking onto a signal. Border only; content is
   untouched. Uses the mask gradient-border trick. */
@property --tv-angle {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}
.auth-card::before {
  content: "";
  position: absolute;
  inset: -1.5px;
  border-radius: 22px;
  padding: 1.5px;
  background:
    conic-gradient(from var(--tv-angle),
      transparent 0deg,
      rgba(6, 182, 212, 0) 55deg,
      rgba(34, 211, 238, 0.95) 92deg,
      rgba(255, 255, 255, 0.95) 110deg,
      rgba(139, 92, 246, 0.95) 128deg,
      rgba(6, 182, 212, 0) 165deg,
      transparent 360deg);
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
  z-index: 0;
  animation: tv-sweep 4s linear infinite, tv-flicker 3s steps(1, end) infinite;
}
@keyframes tv-sweep {
  to { --tv-angle: 360deg; }
}
@keyframes tv-flicker {
  0%, 100% { opacity: 1; }
  6%  { opacity: 0.35; }
  8%  { opacity: 1; }
  9%  { opacity: 0.6; }
  11% { opacity: 1; }
  43% { opacity: 0.85; }
  45% { opacity: 0.25; }
  47% { opacity: 1; }
  68% { opacity: 0.5; }
  70% { opacity: 1; }
  85% { opacity: 0.8; }
  86% { opacity: 0.4; }
  88% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .auth-card::before { animation: none; opacity: 0.6; }
}

/* Chromatic-aberration jitter — a faint border ring whose red/cyan fringes are
   split apart and twitch, like an analog TV's RGB misalignment. */
.auth-card::after {
  content: "";
  position: absolute;
  inset: -1.5px;
  border-radius: 22px;
  padding: 1.5px;
  background: rgba(255, 255, 255, 0.16);
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
  z-index: 0;
  filter:
    drop-shadow(1.5px 0 rgba(255, 0, 90, 0.6))
    drop-shadow(-1.5px 0 rgba(0, 220, 255, 0.6));
  animation: tv-aberration 1.1s steps(1, end) infinite;
}
@keyframes tv-aberration {
  0%   { transform: translate(0, 0); }
  18%  { transform: translate(0.5px, -0.5px); }
  36%  { transform: translate(-0.5px, 0.5px); }
  52%  { transform: translate(2px, 0); }     /* glitch jump */
  54%  { transform: translate(-2px, 0.5px); }
  57%  { transform: translate(0.5px, -1px); }
  74%  { transform: translate(-0.5px, 0); }
  90%  { transform: translate(1px, 0.5px); }
  100% { transform: translate(0, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .auth-card::after { animation: none; }
}

/* Brand / logo */
.auth-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 26px;
}
.auth-logo { width: 80%; max-width: 300px; height: auto; opacity: 0.97; }
html[data-theme="dark"]  .auth-logo--dark,
html.dark                .auth-logo--dark  { display: none; }
html[data-theme="light"] .auth-logo--light,
html.light               .auth-logo--light { display: none; }

.auth-foot {
  position: absolute;
  z-index: 1;
  bottom: 18px;
  inset-inline: 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

/* Inputs — kill the ugly default focus outline, give a soft branded ring. */
.auth-card .t-input,
.t-input {
  background: var(--input-bg, var(--surface-2));
  transition: border-color 0.15s, box-shadow 0.15s;
}
.t-input:focus,
.t-input:focus-visible {
  outline: none;
  border-color: var(--brand-cyan);
  box-shadow: 0 0 0 3px var(--brand-cyan-soft);
}
/* Tame browser autofill so it doesn't paint a white/yellow box. */
.t-input:-webkit-autofill,
.t-input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--input-bg, var(--surface-2)) inset;
  caret-color: var(--text);
}

/* Divider label should sit on the CARD, not the page bg, or it looks chipped. */
.auth-divider span { background: var(--card-bg); }

/* Buttons: drop the harsh default focus outline. Keep an accessible, on-brand
   ring for keyboard users only (focus-visible) — nothing shows on mouse click. */
.auth-card button:focus,
.auth-card a.btn-ghost:focus,
.auth-card .link-action:focus { outline: none; }
.auth-card button:focus-visible,
.auth-card a.btn-ghost:focus-visible,
.auth-card .link-action:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--brand-cyan-soft);
}

.auth-step {
  display: grid;
  gap: 18px;
  animation: auth-fade 0.22s ease;
}

@keyframes auth-fade {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Email chip (shown above OTP / password steps to remind user) */
.email-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface2, var(--surface-1, rgba(15,23,42,0.6)));
  font-size: 13px;
  animation: auth-fade 0.22s ease;
}

.email-chip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #22D3EE;
  flex-shrink: 0;
}

.email-chip-text {
  flex: 1;
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  text-align: start;
}

.email-chip-edit {
  background: none;
  border: 0;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  color: #22D3EE;
  cursor: pointer;
  border-radius: 6px;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.email-chip-edit:hover { background: rgba(6,182,212,0.10); }

/* OTP input */
.otp-input {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 22px;
  letter-spacing: 0.6em;
  text-align: center;
  font-weight: 600;
  padding-block: 16px;
}
.otp-input::placeholder { letter-spacing: 0.6em; font-weight: 400; }

/* Field help text */
.field-help {
  margin: 0;
  font-size: 12px;
  color: var(--muted, #94A3B8);
  line-height: 1.5;
}

/* Resend row inside OTP step */
.resend-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  flex-wrap: wrap;
}

.resend-link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: #22D3EE;
  font-weight: 600;
  cursor: pointer;
}
.resend-link:hover { text-decoration: underline; }
.resend-link[disabled] {
  color: var(--muted, #94A3B8);
  cursor: not-allowed;
  text-decoration: none;
}

.resend-timer { color: var(--muted, #94A3B8); font-size: 12px; }
.resend-timer b { color: var(--text); font-weight: 600; }

/* Divider with centered label */
.auth-divider {
  position: relative;
  text-align: center;
  margin: 4px 0;
}
.auth-divider::before {
  content: "";
  position: absolute;
  top: 50%;
  inset-inline: 0;
  height: 1px;
  background: var(--border);
}
.auth-divider span {
  position: relative;
  z-index: 1;
  background: var(--bg);
  padding: 0 14px;
  font-size: 11px;
  color: var(--muted, #94A3B8);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* Link-style buttons used to switch flow (not action buttons) */
.link-row {
  text-align: center;
  padding-top: 4px;
}

.link-action {
  background: none;
  border: 0;
  padding: 6px 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: #22D3EE;
  cursor: pointer;
}
.link-action:hover { text-decoration: underline; }

/* Inline form error */
.auth-error {
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.25);
  color: #EF4444;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
}

/* Forgot link aligned inside password field label row */
.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.field-row .field-hint-link {
  font-size: 11px;
  font-weight: 600;
  color: #22D3EE;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-decoration: none;
}
.field-row .field-hint-link:hover { text-decoration: underline; }

/* ==========================================================================
 * Tailwind-independent fallbacks
 * --------------------------------------------------------------------------
 * The auth pages were authored against the Tailwind *Play* CDN
 * (https://cdn.tailwindcss.com), which is a dev-only tool: it is frequently
 * blocked, slow, or simply not applied in production, which left the login /
 * signup / reset pages with a broken layout (form jammed left, branding panel
 * missing, toggle mis-positioned, divider chip showing). These rules recreate
 * exactly the utility classes those templates use so the pages render
 * correctly with or without the CDN. If Tailwind *does* load, its injected
 * <style> comes after this file and harmlessly wins (identical semantics).
 * ====================================================================== */

/* --- display / position --- */
.block { display: block; }
.flex { display: flex; }
.hidden { display: none; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1 1 0%; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.relative { position: relative; }
.absolute { position: absolute; }
.inset-0 { inset: 0; }
.overflow-hidden { overflow: hidden; }
.pointer-events-none { pointer-events: none; }
.z-10 { z-index: 10; }
.gap-2 { gap: 0.5rem; }

/* --- sizing --- */
.min-h-screen { min-height: 100vh; }
.w-full { width: 100%; }
.w-56 { width: 14rem; }
.h-auto { height: auto; }
.max-w-md { max-width: 28rem; }
.max-w-sm { max-width: 24rem; }
.max-w-\[420px\] { max-width: 420px; }
.object-contain { object-fit: contain; }
.rounded-full { border-radius: 9999px; }
.rounded-xl { border-radius: 0.75rem; }
.w-\[400px\] { width: 400px; }
.h-\[400px\] { height: 400px; }
.w-\[500px\] { width: 500px; }
.h-\[500px\] { height: 500px; }

/* --- margin / padding --- */
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-8 { margin-bottom: 2rem; }
.mb-10 { margin-bottom: 2.5rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-14 { margin-top: 3.5rem; }
.my-8 { margin-top: 2rem; margin-bottom: 2rem; }
.pt-6 { padding-top: 1.5rem; }
.pb-0 { padding-bottom: 0; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.px-8 { padding-left: 2rem; padding-right: 2rem; }
.px-10 { padding-left: 2.5rem; padding-right: 2.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.-top-20 { top: -5rem; }
.-left-20 { left: -5rem; }
.-bottom-32 { bottom: -8rem; }
.-right-20 { right: -5rem; }
.top-4 { top: 1rem; }
.end-4 { inset-inline-end: 1rem; }
.space-y-5 > * + * { margin-top: 1.25rem; }

/* --- typography --- */
.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-2xl { font-size: 1.5rem; line-height: 2rem; }
.text-3xl { font-size: 1.875rem; line-height: 2.25rem; }
.text-\[15px\] { font-size: 15px; }
.text-\[11px\] { font-size: 11px; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-extrabold { font-weight: 800; }
.uppercase { text-transform: uppercase; }
.tracking-wide { letter-spacing: 0.025em; }
.tracking-wider { letter-spacing: 0.05em; }
.leading-tight { line-height: 1.25; }
.leading-relaxed { line-height: 1.625; }
.text-center { text-align: center; }
.text-white { color: #fff; }
.text-slate-400 { color: #94A3B8; }
.text-slate-500 { color: #64748B; }

/* --- decorative effects (best-effort) --- */
.blur-\[80px\] { filter: blur(80px); }
.opacity-25 { opacity: 0.25; }
.scale-150 { transform: scale(1.5); }
.drop-shadow-2xl { filter: drop-shadow(0 25px 25px rgba(0,0,0,0.35)); }
.animate-fade-in { animation: auth-fade 0.35s ease both; }

/* --- responsive: sm (>=640px) --- */
@media (min-width: 640px) {
  .sm\:px-12 { padding-left: 3rem; padding-right: 3rem; }
}

/* --- responsive: lg (>=1024px) --- */
@media (min-width: 1024px) {
  .lg\:flex { display: flex; }
  .lg\:hidden { display: none; }
  .lg\:w-1\/2 { width: 50%; }
  .lg\:py-12 { padding-top: 3rem; padding-bottom: 3rem; }
}

/* --- direction / theme variants --- */
[dir="rtl"] .rtl\:flex-row-reverse { flex-direction: row-reverse; }
.dark .dark\:block,
html[data-theme="dark"] .dark\:block { display: block; }
.dark .dark\:hidden,
html[data-theme="dark"] .dark\:hidden { display: none; }
