/* Nexus Game — shared design system (loaded by every page) */

/* ===== Tokens ===== */
:root {
  --bg: #0a0d16;
  --bg-2: #0d1120;
  --surface: #11131f;
  --surface-2: #161928;
  --border: rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .15);
  --field: rgba(255, 255, 255, .04);
  --text: #eef1f8;
  --muted: #8b93a7;
  --muted-2: #5f6678;
  --accent: #5b8cff;
  --accent-2: #8a7cff;
  --accent-soft: rgba(91, 140, 255, .14);
  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, .12);
  --warning: #ffa726;
  --warning-soft: rgba(255, 167, 38, .12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, .12);
  --radius: 12px;
  --radius-lg: 18px;
  --shadow: 0 12px 34px rgba(0, 0, 0, .35);
  --ease: cubic-bezier(.4, 0, .2, 1);
  --font: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'Cascadia Code', 'Consolas', 'JetBrains Mono', monospace;
}
[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-2: #eef1f8;
  --surface: #ffffff;
  --surface-2: #f7f9fd;
  --border: rgba(15, 23, 42, .1);
  --border-strong: rgba(15, 23, 42, .18);
  --field: rgba(15, 23, 42, .03);
  --text: #0f172a;
  --muted: #5a6478;
  --muted-2: #8a93a6;
  --accent-soft: rgba(59, 99, 235, .1);
  --shadow: 0 12px 30px rgba(15, 23, 42, .12);
}

/* ===== Base ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background .15s, color .15s;
}
::selection { background: var(--accent-soft); }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
img { max-width: 100%; }
.icon { width: 1.1em; height: 1.1em; flex: none; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
[data-hidden="true"] { display: none !important; }

/* ===== Header ===== */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.site-header-inner {
  max-width: 1320px; margin: 0 auto; padding: 12px 22px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.brand {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 800; font-size: 1.06rem; letter-spacing: -.01em; white-space: nowrap;
}
.brand img, .brand svg { width: 30px; height: 30px; }
.brand .brand-accent { color: var(--accent); }
.site-nav { display: flex; align-items: center; gap: 4px; margin-left: 6px; }
.site-nav a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; border-radius: 8px;
  font-size: .88rem; font-weight: 600; color: var(--muted);
  transition: color .12s, background .12s;
}
.site-nav a:hover { color: var(--text); background: var(--field); }
.site-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.nav-toggle {
  display: none; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
}
@media (max-width: 760px) {
  .site-nav {
    display: none; flex-basis: 100%; flex-direction: column; align-items: stretch;
    padding: 8px 0 4px; margin-left: 0;
  }
  .site-nav.open { display: flex; }
  .site-nav a { padding: 11px 12px; }
  .nav-toggle { display: inline-flex; }
  /* One row: brand, then the actions and the menu button on the right; the
     opened menu drops below them. */
  .site-header-inner { padding: 10px 16px; gap: 8px; }
  .site-header-inner > .brand { order: 1; }
  .site-header-inner > .header-actions { order: 2; gap: 6px; }
  .site-header-inner > .nav-toggle { order: 3; }
  .site-header-inner > .site-nav { order: 4; }
}
/* On a phone the secondary header buttons (Code, Account, Logout) keep only
   their icon; the label stays in the accessibility tree as the button name. */
@media (max-width: 600px) {
  .header-actions .btn-sm:not(.btn-primary) {
    width: 38px; height: 38px; padding: 0; gap: 0; font-size: 0; border-radius: 10px;
  }
  .header-actions .btn-sm:not(.btn-primary) .icon { width: 17px; height: 17px; }
  .header-actions .icon-btn, .nav-toggle { width: 36px; height: 36px; }
}
/* Signed in, a narrow phone cannot fit the brand name next to every button:
   keep the logo, and leave the subscription badge to the Account dialog. */
@media (max-width: 440px) {
  .site-header-inner:has(.header-actions .btn-ghost:not([data-hidden="true"])) .brand { font-size: 0; gap: 0; }
  .site-header-inner:has(.header-actions .btn-ghost:not([data-hidden="true"])) .header-actions .badge { display: none; }
}
@media (max-width: 360px) {
  .site-header-inner { padding: 10px 12px; }
  .site-header-inner > .header-actions { gap: 4px; }
  .header-actions .btn-sm:not(.btn-primary), .header-actions .icon-btn, .nav-toggle { width: 34px; height: 34px; }
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: 10px; font-weight: 700; font-size: .86rem;
  padding: 9px 15px; border: 1px solid transparent;
  white-space: nowrap; transition: background .12s, border-color .12s, color .12s, transform .08s, filter .12s;
}
.btn:active { transform: scale(.98); }
.btn:disabled, .btn[aria-busy="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.09); }
.btn-secondary { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn-secondary:hover:not(:disabled) { border-color: var(--border-strong); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--border-strong); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.1); }
.btn-sm { padding: 6px 11px; font-size: .8rem; border-radius: 8px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  transition: border-color .12s, color .12s;
}
.icon-btn:hover:not(:disabled) { border-color: var(--border-strong); }
.icon-btn:disabled { opacity: .5; cursor: not-allowed; }
/* Used by store.html and partner.html; no stylesheet defined it, so these
   buttons rendered at inline width instead of filling their column. */
.btn-block { display: flex; width: 100%; }
.btn-block + .btn-block { margin-top: 8px; }
.form-note { font-size: .86rem; margin-bottom: 12px; }

/* ===== Forms ===== */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: .78rem; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.field .hint { font-size: .74rem; color: var(--muted-2); }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--field); color: var(--text); font-size: .92rem;
  outline: none; transition: border-color .12s, box-shadow .12s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.field input::placeholder, .field textarea::placeholder { color: var(--muted-2); }
.field input:user-invalid { border-color: var(--danger); }
.field textarea { resize: vertical; min-height: 84px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.form-error { color: var(--danger); font-size: .82rem; min-height: 1.2em; margin-top: 4px; }
.form-message { font-size: .85rem; min-height: 1.2em; margin-top: 6px; }
.form-message.ok { color: var(--success); }
.form-message.err { color: var(--danger); }
.input-wrap { position: relative; display: flex; }
.input-wrap input { padding-right: 42px; }
.input-wrap .input-action {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
}
.input-wrap .input-action:hover { color: var(--text); }

/* ===== Badges ===== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; white-space: nowrap;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--muted);
}
.badge-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* ===== Dialogs ===== */
dialog.dialog {
  /* Always centered, whatever the page scroll position is. */
  position: fixed; inset: 0; margin: auto;
  width: min(520px, calc(100vw - 32px));
  max-height: min(86vh, 720px);
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--text);
  padding: 0; box-shadow: var(--shadow);
  overflow: auto;
}
dialog.dialog::backdrop { background: rgba(5, 7, 12, .7); backdrop-filter: blur(4px); }
.dialog-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.dialog-header h2 { font-size: 1.05rem; font-weight: 800; letter-spacing: -.01em; }
.dialog-body { padding: 18px 20px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }

/* ===== Empty state ===== */
.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  text-align: center; padding: 48px 20px; color: var(--muted);
}
.empty-state .empty-icon {
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--surface-2); display: grid; place-items: center; color: var(--muted-2);
}
.empty-state .empty-icon .icon { width: 22px; height: 22px; }
.empty-state p { font-size: .9rem; max-width: 42ch; }

/* ===== Toasts ===== */
.toast-host {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 200; pointer-events: none; width: max-content; max-width: calc(100vw - 32px);
}
.toast {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text);
  padding: 10px 18px; border-radius: 999px; font-size: .86rem; font-weight: 600;
  box-shadow: var(--shadow); opacity: 0; transform: translateY(8px);
  transition: opacity .22s, transform .22s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.toast-success .toast-dot { background: var(--success); }
.toast-error .toast-dot { background: var(--danger); }

/* ===== Layout helpers ===== */
.page-width { max-width: 1320px; margin: 0 auto; padding: 0 22px; }
.topbar { height: 3px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

/* ===== Footer ===== */
.site-footer { border-top: 1px solid var(--border); margin-top: 64px; background: var(--surface); }
.footer-inner {
  max-width: 1320px; margin: 0 auto; padding: 36px 22px 22px;
  display: grid; grid-template-columns: 1fr auto; gap: 28px; align-items: start;
}
@media (max-width: 640px) { .footer-inner { grid-template-columns: 1fr; } }
.footer-desc { font-size: .82rem; color: var(--muted); max-width: 300px; line-height: 1.6; margin-top: 8px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 10px 18px; justify-content: flex-end; }
.footer-link {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: .84rem; color: var(--muted); transition: color .12s; white-space: nowrap;
}
.footer-link:hover { color: var(--accent); }
.footer-bottom {
  max-width: 1320px; margin: 0 auto; padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.footer-bottom, .footer-bottom a { font-size: .76rem; color: var(--muted-2); }
.footer-bottom a:hover { color: var(--muted); }
.footer-nav { display: flex; gap: 16px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
