/* ============================================================================
   auth.css - everything visual about login: the top-bar button / profile picture,
   the success message, and the login / sign-up / account pages.
   File: accounts/static/accounts/auth.css   (loaded by the website AND the game)

   HOW TO EDIT
   1. Section 1 holds the colors and sizes. Change a value there and everything
      below follows.
   2. The colors default to the page's OWN palette (site.css on the website,
      style.css in the game), so light/dark mode and the orange accent match
      automatically. To force a color, replace the var(...) with a hex value.
   3. Each later section says which part of the page it styles.
   ============================================================================ */


/* ---------- 1. COLORS & SIZES ---------- */
:root {
  /* colors that follow the page's own palette */
  --auth-accent:        var(--accent, var(--orange, #f97316));            /* buttons, links, ring */
  --auth-accent-hover:  var(--accent-hover, var(--orange-hover, #ea580c));
  --auth-accent-light:  var(--accent-light, var(--orange-light, #fff7ed));/* soft orange fill */
  --auth-accent-glow:   var(--accent-glow, rgba(249, 115, 22, 0.35));     /* glow around the picture */
  --auth-text:          var(--text-dark, var(--black, #18181b));
  --auth-muted:         var(--text-muted, var(--gray, #71717a));
  --auth-card-bg:       var(--sidebar-bg, var(--card-bg, #ffffff));       /* login card, message box */
  --auth-page-bg:       var(--canvas-bg, var(--light, #f6f6f6));          /* page behind the login card */
  --auth-border:        var(--sidebar-border, var(--border, #e5e7eb));

  /* status colors (set directly, with a lighter pair for dark mode below) */
  --auth-danger:        #dc2626;   /* wrong password, field errors */
  --auth-success:       #16a34a;   /* "you are logged in" message */

  /* sizes */
  --auth-avatar-size:   36px;      /* the round profile picture in the top bar */
  --auth-card-width:    440px;     /* login / sign-up card */
  --auth-radius:        14px;      /* rounded corners of cards */
}

html[data-theme="dark"] {
  --auth-danger:  #f87171;
  --auth-success: #4ade80;
}


/* ---------- 2. TOP BAR: log-in button / profile picture ---------- */
.auth-widget {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}

/* Not logged in: the "ورود" button */
.auth-widget a.auth-login {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: calc(6px * var(--ui-scale, 1)) calc(14px * var(--ui-scale, 1));
  border: 1px solid var(--auth-accent);
  border-radius: 999px;
  color: var(--auth-accent);
  font-size: calc(13.5px * var(--ui-scale, 1));
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.auth-widget a.auth-login svg {
  width: calc(16px * var(--ui-scale, 1));
  height: calc(16px * var(--ui-scale, 1));
}
.auth-widget a.auth-login:hover {
  background: var(--auth-accent);
  color: #ffffff;
}

/* Logged in: the round profile picture (also used big on the account page) */
.auth-avatar {
  display: grid;
  place-items: center;
  width: calc(var(--auth-avatar-size) * var(--ui-scale, 1));
  height: calc(var(--auth-avatar-size) * var(--ui-scale, 1));
  border: 2px solid var(--auth-accent);
  border-radius: 50%;
  overflow: hidden;              /* clips the silhouette (or a photo) to the circle */
  background: var(--auth-accent-light);
  color: var(--auth-accent);
  transition: box-shadow 0.15s ease;
}
.auth-avatar svg,
.auth-avatar img {
  display: block;
  width: 100%;
  height: 100%;
}
.auth-avatar svg { fill: currentColor; }
.auth-avatar img { object-fit: cover; }
a.auth-avatar:hover { box-shadow: 0 0 0 3px var(--auth-accent-glow); }

.auth-widget a:focus-visible {
  outline: 2px solid var(--auth-accent);
  outline-offset: 2px;
}

/* Game page: the widget sits at the left end of the top bar, before the brand. */
.topbar-left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.topbar-left .brand { margin-left: 0; }

/* Small phones: the game's top bar is crowded, so the button shows only its icon. */
@media (max-width: 520px) {
  #topbar .auth-widget a.auth-login { padding: 7px 9px; }
  #topbar .auth-widget a.auth-login .auth-label { display: none; }
}


/* ---------- 3. SUCCESS MESSAGE (after login / sign-up / logout) ---------- */
.flash-stack {
  position: fixed;
  top: 104px;                    /* a little under the top bar (website header is ~90px) */
  left: 50%;
  transform: translateX(-50%);
  z-index: 6000;                 /* above the game's top bar (5000) */
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(440px, calc(100vw - 24px));
  pointer-events: none;
}

.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--auth-border);
  border-inline-start: 4px solid var(--auth-success);
  border-radius: 12px;
  background: var(--auth-card-bg);
  color: var(--auth-text);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.7;
  pointer-events: auto;
  animation: flash-in 0.25s ease-out;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.flash.error { border-inline-start-color: var(--auth-danger); }
.flash.leaving { opacity: 0; transform: translateY(-6px); }

.flash-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--auth-success);
  color: #ffffff;
  font-size: 13px;
  line-height: 1;
}
.flash.error .flash-icon { background: var(--auth-danger); }

.flash-text { flex: 1 1 auto; }

.flash-close {
  flex: 0 0 auto;
  border: 0;
  background: none;
  color: var(--auth-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.flash-close:hover { color: var(--auth-text); }

@keyframes flash-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .flash { animation: none; transition: none; }
}


/* ---------- 4. LOGIN / SIGN-UP PAGES ---------- */
/* keep the footer at the bottom even on a short page */
body.auth-body { display: flex; flex-direction: column; min-height: 100dvh; }
.auth-page {
  flex: 1 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 56px 16px 72px;
  background: var(--auth-page-bg);
}

.auth-card {
  width: min(var(--auth-card-width), 100%);
  padding: 32px;
  border: 1px solid var(--auth-border);
  border-radius: var(--auth-radius);
  background: var(--auth-card-bg);
  line-height: 1.7;              /* the site default (2) is too airy for a form */
}

.auth-title {
  margin-bottom: 6px;
  font-size: 26px;
  font-weight: 800;
  line-height: 1.5;
}
.auth-lead {
  margin-bottom: 24px;
  color: var(--auth-muted);
  font-size: 14px;
}

.auth-field { margin-bottom: 18px; }
.auth-field.has-error input { border-color: var(--auth-danger); }
.auth-hint {
  margin-top: 6px;
  color: var(--auth-muted);
  font-size: 12.5px;
}
.auth-field-error {
  margin-top: 6px;
  color: var(--auth-danger);
  font-size: 13px;
}

.auth-alert {
  margin-bottom: 18px;
  padding: 10px 14px;
  border: 1px solid var(--auth-danger);
  border-radius: 10px;
  background: color-mix(in srgb, var(--auth-danger) 10%, transparent);
  color: var(--auth-danger);
  font-size: 14px;
}

.auth-submit {
  width: 100%;
  margin-top: 6px;
  padding: 13px;
  font-size: 15px;
}
.auth-secondary {
  background: transparent;
  border: 1px solid var(--auth-border);
  color: var(--auth-text);
}
.auth-secondary:hover {
  background: var(--auth-accent-light);
  border-color: var(--auth-accent);
  color: var(--auth-accent);
}

.auth-switch {
  margin-top: 22px;
  color: var(--auth-muted);
  font-size: 14px;
  text-align: center;
}
.auth-switch a {
  color: var(--auth-accent);
  font-weight: 700;
}
.auth-switch a:hover { text-decoration: underline; }


/* ---------- 5. ACCOUNT PAGE (placeholder) ---------- */
.account-card { text-align: center; }
.account-avatar {
  --auth-avatar-size: 88px;
  margin: 0 auto 14px;
}
.account-stats {
  margin: 12px 0 24px;
  padding: 14px;
  border: 1px solid var(--auth-border);
  border-radius: 12px;
}
.account-stats dt { color: var(--auth-muted); font-size: 13px; }
.account-stats dd { font-size: 28px; font-weight: 800; color: var(--auth-accent); line-height: 1.4; }
