/* ==========================================================================
   PIX — website accounts (scripts/pix-auth.js)
   The log in / create account modal and the header account chip.
   Dark card on a dimmed page, Barlow + Barlow Condensed, Pin Point orange.
   Every class is prefixed pixa- so nothing collides with the page or game.

   Per-page colours: set these on <body> (or :root) of a game page; unset,
   everything is Pin Point's orange and the chip is white, as before.
     --pixa-accent        the modal's accent (kicker, buttons, tabs, links)
     --pixa-accent-hi     its hover shade
     --pixa-accent-soft   the notice background (the accent at 14%)
     --pixa-accent-ring   the input focus ring (the accent at 28%)
     --pixa-chip-ink      header "Log in" and chip text
     --pixa-chip-bg       chip background; --pixa-chip-bg-hi on hover / open
     --pixa-chip-ring     focus outline of "Log in" and the chip (the dark menu keeps white)
   Puzzle Pix (<body data-pix-game="puzzle">) gets its gold below, Time Trial
   (<body data-pix-game="tt">) its pink, Club & Country (<body
   data-pix-game="cc">) its teal. The modal stays dark on every page; the
   accent's fills keep the #161616 ink text (7.3:1 on the teal).
   ========================================================================== */

[data-pix-game="puzzle"] {
  --pixa-accent: #F5A623;
  --pixa-accent-hi: #FFB940;
  --pixa-accent-soft: rgba(245, 166, 35, 0.14);
  --pixa-accent-ring: rgba(245, 166, 35, 0.28);
}
[data-pix-game="tt"] {
  --pixa-accent: #FF2D6B;
  --pixa-accent-hi: #FF5287;
  --pixa-accent-soft: rgba(255, 45, 107, 0.14);
  --pixa-accent-ring: rgba(255, 45, 107, 0.28);
}
[data-pix-game="cc"] {
  --pixa-accent: #11B9A6;
  --pixa-accent-hi: #2BCDB9;
  --pixa-accent-soft: rgba(17, 185, 166, 0.14);
  --pixa-accent-ring: rgba(17, 185, 166, 0.28);
}

.pixa-overlay {
  --pixa-orange: var(--pixa-accent, #FF7A1A);
  --pixa-orange-hi: var(--pixa-accent-hi, #FF8F3D);
  --pixa-card: #1A1A1F;
  --pixa-field: #161616;
  --pixa-line: rgba(255, 255, 255, 0.12);
  --pixa-line-hi: rgba(255, 255, 255, 0.22);
  --pixa-text: #FFFFFF;
  --pixa-muted: rgba(255, 255, 255, 0.72);
  --pixa-faint: rgba(255, 255, 255, 0.5);
  --pixa-bad: #FF7A7A;
  --pixa-ok: #4ADE80;

  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(0, 0, 0, 0.72);
  -webkit-tap-highlight-color: transparent;
}
.pixa-overlay[hidden] { display: none; }

.pixa-card {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  max-width: 420px;
  margin: auto;
  padding: 28px 24px 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  background: var(--pixa-card);
  color: var(--pixa-text);
  font-family: Barlow, system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.45;
  text-align: left;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  animation: pixa-in 0.22s ease-out both;
}
.pixa-card *, .pixa-card *::before, .pixa-card *::after { box-sizing: border-box; }
.pixa-card:focus { outline: none; }

@keyframes pixa-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

.pixa-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--pixa-muted);
  cursor: pointer;
}
.pixa-close:hover { background: rgba(255, 255, 255, 0.08); color: var(--pixa-text); }
.pixa-close[hidden] { display: none; }

.pixa-icon { display: inline-flex; line-height: 0; }

.pixa-kicker {
  margin: 0 0 6px;
  font-family: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--pixa-orange);
}
.pixa-title {
  margin: 0 44px 8px 0;
  font-family: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  font-weight: 900;
  font-size: 34px;
  line-height: 1;
  text-transform: uppercase;
  color: var(--pixa-text);
}
.pixa-handle { text-transform: none; color: var(--pixa-orange); overflow-wrap: anywhere; }
.pixa-sub { margin: 0 0 18px; color: var(--pixa-muted); font-size: 16px; }
.pixa-small { margin: 12px 0 0; color: var(--pixa-faint); font-size: 14px; }
.pixa-small b { color: var(--pixa-muted); font-weight: 700; word-break: break-all; }

/* Tabs: Log in / Create account */
.pixa-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 0 0 18px;
  padding: 4px;
  border-radius: 14px;
  background: var(--pixa-field);
}
.pixa-tab {
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--pixa-muted);
  font: 700 15px/1 Barlow, system-ui, sans-serif;
  cursor: pointer;
}
.pixa-tab:hover { color: var(--pixa-text); }
.pixa-tab[aria-selected="true"] { background: var(--pixa-orange); color: #161616; }

.pixa-notice {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--pixa-accent-soft, rgba(255, 122, 26, 0.14));
  color: var(--pixa-text);
  font-size: 15px;
}
.pixa-notice.is-error { background: rgba(255, 122, 122, 0.14); color: var(--pixa-bad); }
/* A guest about to log in: their guest runs stay with the guest account. */
.pixa-notice.is-warn { background: rgba(255, 255, 255, 0.06); color: var(--pixa-muted); font-size: 14px; box-shadow: inset 3px 0 0 var(--pixa-orange); }

/* Buttons */
.pixa-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  margin: 0;
  padding: 0 18px;
  border: 0;
  border-radius: 14px;
  font-family: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  font-weight: 900;
  font-size: 20px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.08s ease, background-color 0.15s ease, opacity 0.15s ease;
}
.pixa-btn:active:not(:disabled) { transform: scale(0.98); }
.pixa-btn:disabled { opacity: 0.45; cursor: default; }
.pixa-primary { background: var(--pixa-orange); color: #161616; }
.pixa-primary:hover:not(:disabled) { background: var(--pixa-orange-hi); }
.pixa-secondary { background: transparent; color: var(--pixa-text); box-shadow: inset 0 0 0 1px var(--pixa-line-hi); }
.pixa-secondary:hover:not(:disabled) { background: rgba(255, 255, 255, 0.06); }
.pixa-ghost {
  min-height: 44px;
  margin-top: 6px;
  background: transparent;
  color: var(--pixa-muted);
  font: 700 16px/1 Barlow, system-ui, sans-serif;
  letter-spacing: 0;
  text-transform: none;
}
.pixa-ghost:hover { color: var(--pixa-text); }
.pixa-google {
  min-height: 50px;
  background: #FFFFFF;
  color: #161616;
  font: 700 16px/1 Barlow, system-ui, sans-serif;
  letter-spacing: 0;
  text-transform: none;
}
.pixa-google:hover:not(:disabled) { background: #F1F1F1; }

.pixa-or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--pixa-faint);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.pixa-or::before, .pixa-or::after { content: ""; flex: 1; height: 1px; background: var(--pixa-line); }

/* Fields */
.pixa-form { display: flex; flex-direction: column; gap: 14px; margin: 0; }
.pixa-field { display: flex; flex-direction: column; gap: 6px; }
.pixa-label {
  color: var(--pixa-muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.pixa-input {
  width: 100%;
  height: 48px;
  margin: 0;
  padding: 0 14px;
  border: 1px solid var(--pixa-line);
  border-radius: 12px;
  background: var(--pixa-field);
  color: var(--pixa-text);
  font: 500 16px/1.2 Barlow, system-ui, sans-serif; /* 16px: no zoom-on-focus on iPhone */
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.pixa-input::placeholder { color: rgba(255, 255, 255, 0.35); }
.pixa-input:focus { border-color: var(--pixa-orange); box-shadow: 0 0 0 3px var(--pixa-accent-ring, rgba(255, 122, 26, 0.28)); }
.pixa-input[aria-invalid="true"] { border-color: var(--pixa-bad); }
.pixa-affix { position: relative; display: flex; align-items: center; }
.pixa-prefix {
  position: absolute;
  left: 14px;
  color: var(--pixa-orange);
  font: 800 17px/1 Barlow, system-ui, sans-serif;
  pointer-events: none;
}
.pixa-affix .pixa-input { padding-left: 32px; }
.pixa-hint { margin: 0; color: var(--pixa-faint); font-size: 14px; }
.pixa-hint.is-ok { color: var(--pixa-ok); }
.pixa-hint.is-bad { color: var(--pixa-bad); }
.pixa-forgot { align-self: flex-end; font-size: 14px; }
.pixa-error { margin: 0; color: var(--pixa-bad); font-size: 15px; font-weight: 700; }
.pixa-error:empty { display: none; }

.pixa-link, .pixa-legal a { color: var(--pixa-orange); font-weight: 700; text-decoration: none; }
.pixa-link:hover, .pixa-legal a:hover { text-decoration: underline; }
.pixa-legal { margin: 18px 0 0; color: var(--pixa-faint); font-size: 13px; text-align: center; }

/* Username suggestions */
.pixa-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.pixa-suggest {
  padding: 8px 12px;
  border: 1px solid var(--pixa-line-hi);
  border-radius: 999px;
  background: transparent;
  color: var(--pixa-text);
  font: 700 14px/1 Barlow, system-ui, sans-serif;
  cursor: pointer;
}
.pixa-suggest:hover { border-color: var(--pixa-orange); color: var(--pixa-orange); }

/* "Save N boards" */
.pixa-days { margin: 14px 0 0; padding: 0; list-style: none; border-top: 1px solid var(--pixa-line); }
.pixa-days li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--pixa-line);
  font-family: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 0.04em;
}
.pixa-days b { color: var(--pixa-orange); font-weight: 900; }
.pixa-days .pixa-more { color: var(--pixa-faint); font-family: Barlow, system-ui, sans-serif; font-weight: 500; font-size: 14px; letter-spacing: 0; }
.pixa-actions { display: grid; gap: 10px; margin-top: 18px; }

.pixa-spinner {
  width: 32px;
  height: 32px;
  margin: 4px 0 6px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--pixa-orange);
  border-radius: 50%;
  animation: pixa-spin 0.8s linear infinite;
}
@keyframes pixa-spin { to { transform: rotate(360deg); } }

.pixa-btn:focus-visible, .pixa-tab:focus-visible, .pixa-close:focus-visible, .pixa-suggest:focus-visible,
.pixa-link:focus-visible, .pixa-legal a:focus-visible {
  outline: 3px solid var(--pixa-orange);
  outline-offset: 2px;
}
.pixa-primary:focus-visible, .pixa-tab[aria-selected="true"]:focus-visible { outline-color: #FFFFFF; }

@media (max-width: 480px) {
  .pixa-card { padding: 24px 18px 18px; border-radius: 18px; }
  .pixa-title { font-size: 30px; }
}

/* ---- Header account chip (inside [data-pix-account], on the orange hero) ---- */
[data-pixa-hid] { display: none !important; }
[data-pix-account] { position: relative; }

.pixa-account { position: relative; display: inline-flex; min-width: 0; }
.pixa-chip, .pixa-login {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: min(46vw, 260px);
  margin: 0;
  border: 0;
  color: var(--pixa-chip-ink, #FFFFFF);
  font: 700 16px/1 Barlow, system-ui, sans-serif;
  cursor: pointer;
}
.pixa-chip {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--pixa-chip-bg, rgba(255, 255, 255, 0.18));
}
.pixa-chip:hover, .pixa-chip[aria-expanded="true"] { background: var(--pixa-chip-bg-hi, rgba(255, 255, 255, 0.28)); }
.pixa-login { padding: 8px 0; background: transparent; }
.pixa-chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pixa-caret { font-size: 13px; opacity: 0.9; }
.pixa-chip:focus-visible, .pixa-login:focus-visible { outline: 3px solid var(--pixa-chip-ring, #FFFFFF); outline-offset: 2px; }
.pixa-menu-item:focus-visible { outline: 3px solid #FFFFFF; outline-offset: 2px; } /* on the dark menu: always white */

.pixa-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 50;
  min-width: 220px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: #161616;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  font-family: Barlow, system-ui, sans-serif;
}
.pixa-menu[hidden] { display: none; }
.pixa-menu-who {
  margin: 0;
  padding: 8px 10px 10px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pixa-menu-item {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #FFFFFF;
  font: 700 16px/1 Barlow, system-ui, sans-serif;
  text-align: left;
  cursor: pointer;
}
.pixa-menu-item:hover { background: rgba(255, 255, 255, 0.08); }
.pixa-menu-item:disabled { opacity: 0.5; }
/* The links to the player's own page (/profile/): the same rows as Log out, which sits under a hairline.
   The links carry no colour of their own: they take the menu's item colour (white here, the game's own ink on a
   page with a light menu), as Log out does. :where() keeps the hover rule below a page's light-menu rule. */
.pixa-menu a.pixa-menu-item { display: flex; align-items: center; box-sizing: border-box; text-decoration: none; }
a.pixa-menu-item:where(:hover) { color: #FFFFFF; }
.pixa-menu-out { margin-top: 6px; border-top: 1px solid rgba(128, 128, 128, 0.3); border-radius: 0 0 10px 10px; }

@media (max-width: 640px) {
  /* The phone header is one nowrap row: the account slot takes what the logo and breadcrumb leave,
     and the label shortens with an ellipsis instead of running off the screen. */
  [data-pix-account] { min-width: 0; flex: 0 1 auto; }
  .pixa-account { max-width: 100%; }
  .pixa-chip { min-height: 36px; padding: 0 12px; font-size: 15px; max-width: 100%; }
  .pixa-menu { max-width: calc(100vw - 32px); }
}

@media (prefers-reduced-motion: reduce) {
  .pixa-card { animation: none; }
  .pixa-spinner { animation-duration: 2.4s; }
  .pixa-btn { transition: none; }
  .pixa-btn:active:not(:disabled) { transform: none; }
}
