/*
  Auth surface styles. Shared by /login (public/login.html) and /signup
  (public/signup.html, public/signup-check-email.html). Ported verbatim
  from demo/demo-atelier/css/style.css (the :root variables, base reset,
  and .login-* rules). Class names keep the .login-* prefix from the
  demo even though signup reuses them — cosmetic naming only.

  This file is plain vanilla CSS — no Tailwind, no @apply, no @theme, no
  @layer. The demo is plain CSS too, so byte-identical render is the goal.

  Source mapping:
    :root           -> demo style.css lines 1-24
    base reset      -> demo style.css lines 26-55
    .login-* rules  -> demo style.css lines 57-283 (omitting .login-hint)
    @media <980px   -> demo style.css lines 1517-1519 (login-only subset)
    .login-signup-link -> NEW rule (not in demo; for the
                         "New here? Create your workspace" link)
*/

/* Thmanyah (owner-licensed) self-hosted for the static auth pages — same faces
   as the Next app (next/font/local) and the same role mapping: Serif Display for
   headings, Serif Text for body/UI. JetBrains stays the mono. woff2 live in
   public/fonts/ (these static passthrough pages can't use the app's next/font
   output, so they carry their own copies — like public/asas does for landing). */
@font-face {
  font-family: 'Thmanyah Serif Display';
  src: url('/fonts/thmanyah-serif-display-light.woff2') format('woff2');
  font-weight: 300; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Thmanyah Serif Display';
  src: url('/fonts/thmanyah-serif-display-regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Thmanyah Serif Display';
  src: url('/fonts/thmanyah-serif-display-medium.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Thmanyah Serif Text';
  src: url('/fonts/thmanyah-serif-text-regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Thmanyah Serif Text';
  src: url('/fonts/thmanyah-serif-text-medium.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Thmanyah Serif Text';
  src: url('/fonts/thmanyah-serif-text-bold.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  --ink: #0B1E36;
  --ink-2: #1E3554;
  --ink-soft: #4A5F7A;
  --slate: #8195AD;
  --slate-soft: #B8C5D4;
  --paper: #F4F1EA;
  --paper-2: #ECE7DC;
  --paper-3: #E3DCC9;
  --white: #FBF9F4;
  --accent: #C9501C;
  --accent-soft: #E8B89C;
  --ok: #2D6A4F;
  --warn: #B08900;
  --err: #9B2226;
  --line: rgba(11, 30, 54, 0.12);
  --line-strong: rgba(11, 30, 54, 0.24);
  --shadow-sm: 0 1px 2px rgba(11, 30, 54, 0.06);
  --shadow: 0 4px 16px rgba(11, 30, 54, 0.08);
  --shadow-lg: 0 12px 40px rgba(11, 30, 54, 0.12);
  /* Role tokens (replacing the old per-language --font-ar / --font-en). Both
     faces cover Arabic + Latin, so the dir-based switches below resolve to the
     same face in either language — only the role (heading vs body) differs. */
  --font-display: 'Thmanyah Serif Display', Georgia, serif;
  --font-text: 'Thmanyah Serif Text', Georgia, serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 15px; }

body {
  font-family: var(--font-text);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

body[dir="ltr"] { font-family: var(--font-text); }

/* Paper texture background — matches demo body::before */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 10%, rgba(201, 80, 28, 0.03) 0%, transparent 40%),
    radial-gradient(circle at 80% 90%, rgba(11, 30, 54, 0.04) 0%, transparent 40%);
  pointer-events: none;
  z-index: 0;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* ========== LOGIN SCREEN ========== */
.login-screen {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  z-index: 1000;
  background: var(--paper);
}

.login-brand {
  background: var(--ink);
  color: var(--white);
  padding: 4rem;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.login-brand::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse at center, black 40%, transparent 80%);
}

.login-brand > * { position: relative; z-index: 1; }

.brand-mark {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.brand-mark-icon {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255,255,255,0.3);
  display: grid;
  place-items: center;
  font-weight: 600;
}

.login-hero-text {
  margin: auto 0;
}

.login-hero-text h1 {
  font-family: var(--font-display);
  font-weight: 300;
  /* LTR only: the 47-char English headline must fit ONE line in the split
     brand panel (~50vw − 8rem padding), so it scales with viewport and caps at
     2.4rem — the same size as the Arabic. The Arabic keeps its fixed 2.4rem via
     the body[dir="rtl"] override below (shorter string). clamp (not nowrap) so
     it wraps without overflow in the narrow ~981–1150px band; ≤980px the whole
     brand panel is hidden. Mirrors the landing fix (de6854e). */
  font-size: clamp(1.5rem, 2vw, 2.4rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin-bottom: 1.5rem;
}

.login-hero-text h1 em {
  font-style: italic;
  font-weight: 400;
  color: var(--accent-soft);
}

body[dir="rtl"] .login-hero-text h1 {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 300;
}

.login-hero-text p {
  color: rgba(255,255,255,0.7);
  max-width: 90%;
  line-height: 1.7;
}

.login-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.login-form-wrap {
  display: grid;
  place-items: center;
  padding: 4rem;
  position: relative;
}

/* ============================================================
   Signup-only overrides. All rules below are scoped via the
   #signupScreen ID on public/signup.html's .login-screen root so
   /login and /signup/check-email are not affected.
   ============================================================ */

/* Anchor the form to the TOP of the column (was `safe center` shared,
   then incorrectly `place-items: safe start` here) so the title sits
   close to the lang-toggle instead of being vertically centered.

   The axes are split intentionally:
   - `align-items: safe start` — block axis only. Anchors the form to
     the top of the column.
   - `justify-items: center` — inline axis. Keeps the form horizontally
     centered in its column, exactly like /login's shared
     `place-items: center`. Without this, `safe start` on both axes
     glues the form to the inline-start side of its column — in LTR
     that's the form's LEFT edge butting up against the brand-panel
     boundary, which reads as the brand panel "extending further" than
     on /login. The block-end column is the form column on both pages
     identically; this rule only affects the form's position WITHIN
     that column.

   `overflow-y: auto` remains as a safety net so the column scrolls
   internally on very short viewports. */
#signupScreen .login-form-wrap {
  align-items: safe start;
  justify-items: center;
  overflow-y: auto;
}

/* Tighter vertical rhythm in the form column. The shared rules in
   auth.css produce a rhythm tuned for /login's 2-field form; with
   5 fields the same scale reads as too spread out. These overrides
   compress the inter-element gaps without going flat. */
#signupScreen .login-form h2 {
  margin-bottom: 0.35rem; /* was 0.5rem */
}
#signupScreen .login-form-sub {
  margin-bottom: 1.5rem; /* was 2.5rem — the biggest contributor */
}
#signupScreen .field {
  margin-bottom: 0.85rem; /* was 1.25rem; applies to all 5 fields */
}
#signupScreen .field label {
  margin-bottom: 0.35rem; /* was 0.5rem */
}

/* Move the login link into normal flow below the submit button.
   The shared rule pins .login-signup-link to the column bottom via
   absolute positioning; on signup it should flow inline with the
   form so it sits directly under the submit button. text-align,
   color, and font-size are inherited from the shared rule. */
#signupScreen .login-signup-link {
  position: static;
  margin-top: 1.25rem;
}

/* ============================================================
   Shared auth toast (used by both /login and /signup).
   ============================================================

   .auth-submit-row is a positioning context for the absolutely-
   positioned .auth-toast. Wrap the submit button in this row on
   both pages; the toast anchors to the row's top edge via
   `inset-block-end: calc(100% + …)`. The row has no styling beyond
   `position: relative` — it exists purely so the toast can anchor
   without depending on the form column wrapper's geometry.

   .auth-toast is the floating error surface. Absolutely positioned
   above the submit button so it overlays without displacing the
   button, fields, or the footer link. Driven by login.js /
   signup.js: showXxxToast() adds .show, hideXxxToast() removes it.
   Hover pauses the auto-dismiss timer; mouseleave restarts a fresh
   5.5s window.

   The visibility transition uses a 0.28s delay on hide so opacity
   has time to fade out before visibility flips to hidden; on show,
   the visibility delay is zero so the element appears instantly
   while opacity and transform animate. translateY (not translateX)
   keeps the slide direction RTL-independent; scale(0.98) at the
   start adds a subtle "lift" as the toast rises into place.

   Palette: cream surface, burnt-orange (--accent) inline-start
   stripe, navy text, --shadow-lg for the elevated feel. Logical
   properties throughout so RTL mirrors automatically. */
.auth-submit-row {
  position: relative;
}

.auth-toast {
  position: absolute;
  inset-block-end: calc(100% + 0.5rem);
  inset-inline-start: 0;
  inset-inline-end: 0;
  z-index: 5;

  padding-block: 0.7rem;
  padding-inline-start: 0.9rem;
  padding-inline-end: 2.25rem;

  background: var(--white);
  border: 1px solid var(--line);
  border-inline-start: 4px solid var(--accent);
  border-radius: 4px;

  color: var(--ink);
  font-size: 0.85rem;
  line-height: 1.5;
  box-shadow: var(--shadow-lg);

  opacity: 0;
  visibility: hidden;
  transform: translateY(4px) scale(0.98);
  transform-origin: center bottom;
  transition:
    opacity 0.28s ease-out,
    transform 0.28s ease-out,
    visibility 0s linear 0.28s;
}

.auth-toast.show {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition:
    opacity 0.28s ease-out,
    transform 0.28s ease-out,
    visibility 0s linear 0s;
}

.auth-toast-close {
  position: absolute;
  inset-block-start: 0.2rem;
  inset-inline-end: 0.2rem;
  width: 1.75rem;
  height: 1.75rem;
  display: grid;
  place-items: center;
  color: var(--ink-soft);
  font-size: 1.25rem;
  line-height: 1;
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.auth-toast-close:hover {
  color: var(--ink);
  background: rgba(11, 30, 54, 0.04);
}

.lang-toggle {
  position: absolute;
  top: 2rem;
  left: 2rem;
  display: flex;
  gap: 0;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  overflow: hidden;
  font-size: 0.75rem;
  font-family: var(--font-mono);
}
body[dir="rtl"] .lang-toggle { left: auto; right: 2rem; }

.lang-toggle button {
  padding: 0.4rem 0.8rem;
  color: var(--ink-soft);
}
.lang-toggle button.active { background: var(--ink); color: var(--white); }

.login-form {
  width: 100%;
  max-width: 380px;
}

.login-form h2 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}
body[dir="rtl"] .login-form h2 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 600;
}

.login-form-sub {
  color: var(--ink-soft);
  margin-bottom: 2.5rem;
  font-size: 0.9rem;
}

.field {
  margin-bottom: 1.25rem;
}

.field label {
  display: block;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin-bottom: 0.5rem;
}
body[dir="rtl"] .field label { font-family: var(--font-text); letter-spacing: normal; font-size: 0.8rem; }

.field input, .field select, .field textarea {
  width: 100%;
  padding: 0.75rem 0;
  border: none;
  border-bottom: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
  font-size: 0.95rem;
  transition: border-color 0.2s;
  outline: none;
}

.field input:focus, .field select:focus, .field textarea:focus {
  border-bottom-color: var(--accent);
}

.btn-primary {
  width: 100%;
  background: var(--ink);
  color: var(--white);
  padding: 0.9rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: background 0.2s;
  margin-top: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-primary:hover { background: var(--accent); }
.btn-primary:disabled { opacity: 0.7; cursor: not-allowed; }

/* Signup link — NEW rule, not in demo. Anchored to the form column
   footer so it sits below the centered form without affecting the
   form's vertical centering. */
.login-signup-link {
  position: absolute;
  bottom: 2rem;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.login-signup-link a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 4px;
  transition: color 0.2s;
}
.login-signup-link a:hover {
  color: var(--accent);
}

/* Below 980px the brand panel collapses; form column takes full
   viewport. Demo style.css:1517-1519. */
@media (max-width: 980px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-brand { display: none; }
}
