/* ============================================================
   Shared primitives for every page that links this file — the music shell
   (index.html) and the standalone pages (admin / genles / investments / login /
   account).

   Only rules that are identical everywhere live here: the colour + layout
   tokens, the self-hosted @font-face blocks, the reset, the wordmark, and the
   shared chrome (nav pills + the language selector). Each page keeps its
   page-specific CSS in an inline
   <style> (or styles.css / app.css) that loads AFTER this file, so page rules
   (body padding, .container width, h1, forms) still win by source order. The
   sign-in gate lives in /gate.css.
   ============================================================ */
:root,
[data-theme='default'] {
  /* Default palette: pure black, one crisp blue, white — high contrast and
     minimal. The shell (styles.css `:root`) mirrors this block exactly. The
     `[data-theme='default']` arm lets the worlds game force this palette on its
     own panel even when the site is on another theme (see public/js/worlds). */
  --bg: #000000;
  --surface: #0a0a0c;
  --surface-2: #121216;
  --surface-3: #1c1c22;
  --border: #2e2e38;
  --border-strong: #45454f;
  --text: #f5f5f7;
  --text-strong: #ffffff;
  --dim: #9a9aa8;
  --dimmer: #66666f;
  --accent: #3b82f6;
  --accent-soft: #10233f;
  /* The accent as TEXT (links, the chat's translated row). One token so a theme only
     has to make the accent legible ON A SURFACE once — test/theme-contrast.spec.js
     holds the 4.5:1 floor. */
  --accent-fg: #3b82f6;
  --green: #22c55e;
  --green-soft: #08281a;
  --red: #ff5a5a;
  --btn-bg: #0a0a0c;
  --btn-fg: #ffffff;

  /* Layout tokens (theme-independent; the shell mirrors these exactly). Sizes
     favour powers of two. See "Aesthetic guidelines" in docs/ARCHITECTURE.md. */
  --gutter: 16px;
  --content-max: 800px; /* an intentional in-between: a readable line length */
  --radius-sm: 8px;
  --radius: 16px;

  /* The ONE type token for the whole site — every page and panel sets its text
     from this. Its DEFAULT is the self-hosted Ubuntu Mono (the @font-face blocks
     below) first, then whatever mono the device has; it is served from OUR OWN
     origin — never a third-party font host (mainland China). A signed-in fan may
     re-point it at a DEVICE-GENERIC family from the account tab (#font-select):
     the `html[data-font=...]` blocks below override this token, so the name is
     historical — it may hold a sans or serif stack once a fan picks one. */
  --font-mono: 'Ubuntu Mono', 'JetBrains Mono', ui-monospace, 'Consolas', 'Courier New', monospace;
}

/* ---------- the font: self-hosted Ubuntu Mono (Ubuntu Font Licence 1.0) ----------
   The one typeface for the site; `--font-mono` above names it and every page
   links this file, so this is the only place it is declared. It is served from
   OUR OWN origin (/fonts), never a third-party font host: Google Fonts is
   blocked/unreliable in mainland China, and a first-party file needs no extra
   CSP host (`font-src 'self'` already allows it) — see the no-Google-Fonts rule
   in docs/ARCHITECTURE.md. The licence travels with the files: /fonts/UFL.txt.

   Four faces (regular / bold / italic / bold-italic) x two subsets (latin +
   latin-ext). The browser downloads only the faces a page actually uses and only
   the subset whose `unicode-range` its text hits (a page with no latin-ext
   character fetches one ~27KB file). The filenames carry the upstream version
   (`-v19`) so /fonts/* is served immutable (public/_headers) — bump that version
   in the name here (and re-download) if the font ever changes.

   Coverage: Ubuntu Mono has NO emoji and NO CJK, so 👾 / 💬 / Chinese text falls
   through to the system fonts — do not strip the tails off the font stacks. */
@font-face {
  font-family: 'Ubuntu Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/ubuntumono-latin-400-v19.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Ubuntu Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/ubuntumono-latin-ext-400-v19.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Ubuntu Mono';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/ubuntumono-latin-700-v19.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Ubuntu Mono';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/ubuntumono-latin-ext-700-v19.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Ubuntu Mono';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/ubuntumono-italic-latin-400-v19.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Ubuntu Mono';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/ubuntumono-italic-latin-ext-400-v19.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Ubuntu Mono';
  font-style: italic;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/ubuntumono-italic-latin-700-v19.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Ubuntu Mono';
  font-style: italic;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/ubuntumono-italic-latin-ext-700-v19.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- the fan's font family (the account tab's #font-select) ----------
   public/js/theme.js reads the versu_font cookie (or localStorage for anonymous
   visitors) in <head> and sets `data-font` on <html> before first paint, so a
   choice never flashes. Each block re-points the ONE type token above; the
   attribute selector out-specifies both `:root` copies (base.css + styles.css)
   whatever the load order. 'default' has no block — it is the :root stack.

   Only 'default' ships font bytes: it is our own Ubuntu Mono. Every other key is
   a DEVICE-GENERIC family the browser resolves locally, so a choice adds no
   download and needs no third-party host (Google Fonts is blocked/unreliable in
   mainland China — see the no-third-party-font rule in docs/ARCHITECTURE.md).
   Keep these keys in step with ALLOWED_FONT_FAMILIES in src/users.js. Every
   stack keeps a generic tail, and none carries emoji / CJK, so those still fall
   through to the system fonts exactly as they did before. */
html[data-font='system-mono'] {
  --font-mono: ui-monospace, 'SFMono-Regular', 'SF Mono', Menlo, 'Cascadia Mono', 'Segoe UI Mono', Consolas, 'Liberation Mono', 'Courier New', monospace;
}
html[data-font='system-sans'] {
  --font-mono: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
}
html[data-font='system-serif'] {
  --font-mono: Georgia, 'Times New Roman', Times, 'Noto Serif', serif;
}

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

.brand {
  font-family: var(--font-mono);
  font-size: 24px;
  letter-spacing: 0.5px;
  font-weight: 400;
  color: var(--text);
  /* Every wordmark links home; keep it looking like plain text. */
  text-decoration: none;
}
.brand .am { color: var(--accent); font-weight: 700; }

/* ---------- Shared chrome primitives ----------
   The nav pills and the language selector are identical on the music shell
   (styles.css) and the standalone pages (app.css), so they live here once and
   every page reuses them. Page-specific layout (the nav's flex order, a
   narrower container) stays in those two files. */
nav a,
nav button {
  background-color: transparent;
  color: var(--dim);
  border: 1px solid var(--border-strong);
  padding: 8px 16px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-family: inherit;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}
nav a:hover,
nav button:hover {
  color: var(--text-strong);
  border-color: var(--accent);
}
nav a.active-nav,
nav button.active-nav {
  color: var(--text-strong);
  border-color: var(--accent);
  background-color: var(--accent-soft);
}

#language-selector {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  cursor: pointer;
}
#language-selector option {
  background: var(--surface-2);
  color: var(--text);
}

/* Wordmark steps: 24px -> 18px -> 16px, same as the portfolio's. */
@media (max-width: 768px) {
  .brand { font-size: 18px; }
}
@media (max-width: 480px) {
  .brand { font-size: 16px; }
}

/* ---------- Keyboard-navigation cursor ----------
   The element WASD/JK has moved onto (public/site/keynav.js). One shared rule so
   every page that loads the module shows the same selection ring. */
.keynav-focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------- Shared chat chrome ----------
   One chat row is the same row everywhere: the /chat page (site/pages/chat.js),
   the console's chat inbox (js/admin/chat.js) and the worlds chat
   (.worlds-chat-row in worlds.css). `.comment-avatar` / `.comment-main` used to
   be declared in index.html's inline <style> and `.chat-time` / `.chat-presence`
   in styles.css; both pages need them, so they live here once (the worlds chat
   rows override the avatar size with their own 26px, and a page's own layout
   rules still win by source order). `.chat-empty` is the empty log's line, in the
   console's inbox too. */
.comment-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--surface-2); }
.comment-main { flex: 1; min-width: 0; }
.chat-presence {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--dim);
}
.chat-presence::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dimmer);
}
.chat-presence.online::before { background: var(--green); }
.chat-time {
  margin-left: auto;
  color: var(--dim);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.chat-empty { color: var(--dim); font-size: 12px; padding: 14px 0; }
/* The ⌨️ owner tag beside a name (shell comments, the worlds chat and the
   console's inbox all render it; badge-tip.js anchors its touch tooltip here). */
.comment-admin-tag { margin-left: 6px; color: var(--accent-fg); font-size: 10px; text-transform: uppercase; letter-spacing: 1px; }

/* ---------- The chat composer's emoji picker ----------
   public/js/emoji-picker.js builds the 🙂 toggle + the panel; this is their only
   styling. It is deliberately SELF-CONTAINED — every colour is a token and nothing is
   read from .worlds-chat-* / .mini-btn — because the same module is meant to serve the
   /chat page (styles.css + worlds.css) and, later, the worlds game's chat drawer, and a
   component that takes its look from one page's stylesheet breaks on the other. The
   panel is `position: fixed`, so it is out of the composer's flex row; the module pins
   it under its button (the #fontsize-panel recipe in site/pages/account.js).
   z-index 60: ABOVE the music player's fixed bottom bar (.mini-player, 50) — the picker
   opens upward out of the composer, which is exactly where that bar sits when a fan is
   at the bottom of the page — and BELOW the shell's own overlays (the notification panel
   105, the avatar-crop modal 130/140), which must still cover it. */
.emoji-picker-toggle {
  flex: 0 0 auto;
  min-width: 34px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1;
  color: var(--text);
  background-color: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.emoji-picker-toggle:hover,
.emoji-picker-toggle[aria-expanded='true'] { border-color: var(--accent); }
.emoji-picker {
  position: fixed;
  z-index: 60;
  width: min(320px, calc(100vw - 16px));
  padding: 6px;
  background-color: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.emoji-picker[hidden] { display: none; }
.emoji-picker-tabs { display: flex; flex-wrap: wrap; gap: 2px; padding-bottom: 4px; }
.emoji-picker-tab {
  min-width: 30px;
  padding: 4px 6px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1;
  color: var(--text);
  background-color: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.emoji-picker-tab:hover { border-color: var(--border-strong); }
/* The open tab reads as the accent the shell already uses for "this is the current
   one" (.active-nav: accent border + accent-soft fill). */
.emoji-picker-tab.active { border-color: var(--accent); background-color: var(--accent-soft); }
.emoji-picker-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  max-height: min(260px, 40vh);
  overflow-y: auto;
}
.emoji-picker-cell {
  padding: 4px 0;
  font-family: inherit;
  font-size: 18px;
  line-height: 1.2;
  text-align: center;
  color: var(--text);
  background-color: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.emoji-picker-cell:hover,
.emoji-picker-cell:focus { background-color: var(--surface-3); outline: none; }
