/* ===== Login stage =====
 * Single-column layout for /auth/login + /auth/signin: King medallion
 * floating above a centred form panel. Replaces the older two-column
 * .auth-shell on those two routes. Mobile-first; desktop just inherits
 * the same column with extra breathing room. */

/* Atmospheric background on every auth page — Libyan café scene with
 * lantern, dallah, cards, and the Libyan flag. The image sits under
 * a vertical scrim that darkens the top and bottom a touch so the
 * King medallion and form panel stay legible. Uses :has() so no
 * template wiring is needed; body picks it up whenever one of its
 * descendants is .screen.auth. */
body:has(.screen.auth) {
  background:
    linear-gradient(180deg,
      rgba(7, 8, 18, 0.55) 0%,
      rgba(7, 8, 18, 0.20) 38%,
      rgba(7, 8, 18, 0.55) 100%),
    url('/static/images/auth/background.jpg') center / cover no-repeat,
    var(--midnight-deep, #070812) !important;

  /* iOS Safari + RTL guard: pin width/overflow explicitly so the body
   * never ends up wider than the viewport, which in RTL surfaces as
   * the whole layout shifting visibly to the right past the safe
   * area. Mirrors the fix already in place at <=760px in hayya-theme,
   * applied here on every breakpoint for auth pages where the new
   * background + king + modal stack pushed the bug back into view. */
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  position: relative;
}

/* The Hayya theme paints abstract orbs/grid via body::before/::after.
 * Mute both on auth pages so the photo isn't competing with noise. */
body:has(.screen.auth)::before,
body:has(.screen.auth)::after {
  display: none !important;
}

/* `background-attachment: fixed` is intentionally NOT used here. iOS
 * Safari renders fixed backgrounds at viewport dimensions while the
 * body uses safe-area-inset padding, and the mismatch surfaces as a
 * visible rightward shift in RTL. Scrolling background is fine; the
 * auth pages barely scroll anyway. */

.login-stage {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 32px 16px 48px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 28px;
  position: relative;
  z-index: 1;
}

/* The signup data form has 8 fields, so it gets a wider lane on desktop
 * to keep the panel from feeling cramped. Still narrower than the old
 * two-column shell. */
.login-stage.login-stage-wide {
  max-width: 640px;
}

/* Pull the medallion a touch toward the panel — the float animation
 * adds its own vertical motion so a tight gap reads as deliberate. */
.login-stage .king {
  margin-bottom: -56px;
  align-self: center;
}

/* (Decorative ::after "tab" removed — it was clipped by .king's
 * overflow:hidden anyway, and iOS Safari occasionally exposed its
 * negative `right` offset during the float animation, contributing
 * to the rightward layout shift users reported.) */

.login-panel {
  background: var(--panel, rgba(9, 12, 20, 0.78));
  border: 1px solid var(--line, rgba(201, 169, 97, 0.32));
  border-radius: 18px;
  padding: 56px 28px 28px;
  box-shadow:
    0 30px 60px -30px rgba(0, 0, 0, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.login-title {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  color: var(--gold-bright, #ffd700);
  text-align: start;
  letter-spacing: 0.5px;
}

.login-sub {
  margin: -8px 0 6px;
  color: var(--sand, #e8dcc4);
  opacity: 0.75;
  font-size: 14px;
  text-align: start;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* /auth/login chooser stack (2026-05-21): 3 stacked CTAs replace the
 * old in-page signin form so a first-time visitor doesn't see a
 * username/password field on landing ("بتخاف"). Mirrors `.login-form`'s
 * column layout; tighter 12px gap because button-to-button rhythm
 * reads better than the 16px form-field rhythm. The form lives at
 * /auth/signin now. */
.login-cta-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Remember-me + forgot-password row. checkbox on the visually-leading
 * edge (right in RTL), link on the trailing edge. */
.login-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: -2px;
  font-size: 13px;
}

.login-remember {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--sand, #e8dcc4);
  cursor: pointer;
  user-select: none;
}

.login-remember input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1.5px solid var(--line, rgba(201, 169, 97, 0.32));
  background: transparent;
  cursor: pointer;
  position: relative;
  transition: border-color 120ms ease, background 120ms ease;
}

.login-remember input[type="checkbox"]:checked {
  background: var(--gold-bright, #ffd700);
  border-color: var(--gold-bright, #ffd700);
}

.login-remember input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 4px;
  height: 9px;
  border: solid #0a0d18;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Make the main submit visibly bigger than the regular .btn-block — the
 * screenshot shows it as the dominant call to action. */
.login-form .btn-primary {
  padding-block: 14px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.4px;
}

/* "أو" divider — short gold-lined separator with a single Arabic word. */
.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--sand, #e8dcc4);
  opacity: 0.65;
  font-size: 13px;
  margin: 2px 0;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line-soft, rgba(201, 169, 97, 0.16));
}

.login-guest {
  padding-block: 13px;
  font-size: 15px;
  font-weight: 700;
}

/* Sign in with Google — ghost button + a Google-coloured "G" badge.
   Inline-flex centres the badge + label as one unit; logical gap keeps
   it correct in the RTL layout. min-height matches the 44px tap floor. */
.login-google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  font-size: 15px;
  font-weight: 700;
}

.login-google-g {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  /* Google blue — the recognisable brand mark colour. */
  color: #4285f4;
  font-family: Arial, "Helvetica Neue", sans-serif;
  font-weight: 800;
  font-size: 15px;
  line-height: 1;
}

.login-foot {
  margin: 4px 0 0;
  text-align: center;
  color: var(--sand, #e8dcc4);
  opacity: 0.8;
  font-size: 14px;
}

.login-foot .form-link {
  color: var(--gold-bright, #ffd700);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.login-foot .form-link:hover {
  text-decoration: underline;
}

/* Mobile-first tap targets (CLAUDE.md rule 0): the auth links and the
 * remember-me row render ~20-26px tall, under the 44px touch minimum.
 * Expand the hit area with padding + an equal negative margin so the
 * tappable box is >=44px while the visible text, colour and inline
 * position stay exactly as before (same technique as the documented
 * .switch hit-extension). Scoped to .login-stage so no other
 * .form-link usage is affected. */
.login-stage .form-link {
  display: inline-block;
  padding: 13px 8px;
  margin: -13px -8px;
}
.login-stage .login-remember {
  min-height: 44px;
}

/* Bullet separator between foot links — kept opaque enough to read but
 * faint so the gold links stay the visual anchor. */
.login-foot .dot-sep {
  opacity: 0.45;
  margin: 0 4px;
}

/* Mobile-first: 375px is the design baseline. Tighten paddings + sizes. */
@media (max-width: 480px) {
  .login-stage {
    padding: 20px 12px 32px;
    gap: 20px;
  }
  .login-stage .king {
    margin-bottom: -40px;
  }
  .login-panel {
    padding: 44px 20px 22px;
    border-radius: 16px;
  }
  .login-title {
    font-size: 22px;
  }
}

/* ===== Guest onboarding modal =====
 * Opens on "العب كضيف". Welcomes them, explains the dev status + ELO
 * + guest-not-persisted tradeoff, then asks for a name. Replaces the
 * native prompt() which couldn't carry brand styling or the info copy. */
.guest-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 20px;
}

.guest-modal[hidden] { display: none; }

.guest-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 8, 18, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: guestFade 220ms ease both;
  cursor: pointer;
}

.guest-modal-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  background: rgba(15, 18, 30, 0.96);
  border: 1px solid var(--line, rgba(201, 169, 97, 0.32));
  border-radius: 20px;
  padding: 32px 26px 24px;
  box-shadow:
    0 40px 70px -20px rgba(0, 0, 0, 0.75),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  animation: guestPop 320ms cubic-bezier(0.34, 1.2, 0.64, 1) both;
  text-align: center;
}

@keyframes guestFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes guestPop {
  from { opacity: 0; transform: scale(0.92) translateY(20px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

.guest-modal-close {
  position: absolute;
  top: 8px;
  inset-inline-end: 10px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--sand, #e8dcc4);
  opacity: 0.55;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  transition: opacity 120ms ease, color 120ms ease, transform 120ms ease;
}

.guest-modal-close:hover {
  opacity: 1;
  color: var(--gold-bright, #ffd700);
  transform: rotate(90deg);
}

.guest-modal-emblem {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255, 215, 0, 0.18), rgba(201, 169, 97, 0.05));
  border: 1px solid var(--line, rgba(201, 169, 97, 0.32));
  color: var(--gold-bright, #ffd700);
  box-shadow: 0 8px 24px -10px rgba(255, 215, 0, 0.4);
}

.guest-modal-title {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 800;
  color: var(--gold-bright, #ffd700);
  letter-spacing: 0.3px;
}

.guest-modal-sub {
  margin: 0 0 18px;
  color: var(--sand, #e8dcc4);
  opacity: 0.78;
  font-size: 14px;
}

.guest-modal-info {
  list-style: none;
  padding: 14px 14px;
  margin: 0 0 18px;
  background: rgba(201, 169, 97, 0.06);
  border: 1px solid var(--line-soft, rgba(201, 169, 97, 0.16));
  border-radius: 12px;
  text-align: start;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.guest-modal-info li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: var(--ivory, #fff8e7);
  opacity: 0.92;
  line-height: 1.55;
}

.guest-modal-info strong {
  color: var(--gold-bright, #ffd700);
  font-weight: 700;
}

.guest-modal-info .info-emoji {
  font-size: 16px;
  flex-shrink: 0;
  line-height: 1.4;
}

.guest-modal-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: start;
}

.guest-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.guest-modal-actions .btn {
  flex: 1;
  padding-block: 12px;
  font-weight: 700;
}

.guest-modal-actions .btn-primary {
  flex: 1.4;
}

body.modal-open {
  overflow: hidden;
}

@media (max-width: 480px) {
  .guest-modal {
    padding: 14px;
  }
  .guest-modal-card {
    padding: 28px 18px 20px;
    border-radius: 18px;
  }
  .guest-modal-title {
    font-size: 19px;
  }
  .guest-modal-info {
    padding: 12px;
  }
  .guest-modal-info li {
    font-size: 12.5px;
  }
}
