/* Mathwizards — shared design tokens.
   Single source of truth for every surface: the React SPA (src/), the
   standalone public/*.html tool pages, and the periodic table. Linked via
   <link rel="stylesheet" href="/theme.css"> — plain CSS, no build step, so it
   works identically whether Vite serves it or a static page loads it raw.

   Foundation = the Budget Tracker's dark-slate/teal system (it was already
   consistent across 4 pages and accessibility-checked — see CLAUDE.md's W4
   notes on --text-faint contrast). The game's purple/pink identity survives
   as the --purple/--pink accent tokens, used for the brand wordmark and as
   one of the six palette colors below — not as the whole surface.

   Do not hand-copy these values into a page's own <style> block. If a page
   needs a new color, add it here so every consumer gets it.
*/

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Space+Mono:wght@400;700&display=swap');

:root {
  /* Surface */
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-hover: #273449;
  --border: rgba(148, 163, 184, 0.15);
  --border-hover: rgba(148, 163, 184, 0.3);

  /* Text */
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-faint: #475569;

  /* Six-color semantic palette — every card/badge/accent in the app should
     draw from one of these six, not an arbitrary hex. Each has a base, a
     ~12% "dim" fill (for badge/chip backgrounds), and a ~35% "border" tint. */
  --teal: #2dd4bf;
  --teal-dim: rgba(45, 212, 191, 0.12);
  --teal-border: rgba(45, 212, 191, 0.35);
  --amber: #fbbf24;
  --amber-dim: rgba(251, 191, 36, 0.12);
  --amber-border: rgba(251, 191, 36, 0.35);
  --red: #f87171;
  --red-dim: rgba(248, 113, 113, 0.12);
  --red-border: rgba(248, 113, 113, 0.35);
  --green: #4ade80;
  --green-dim: rgba(74, 222, 128, 0.1);
  --green-border: rgba(74, 222, 128, 0.3);
  --blue: #60a5fa;
  --blue-dim: rgba(96, 165, 250, 0.12);
  --blue-border: rgba(96, 165, 250, 0.35);
  --purple: #a78bfa;
  --purple-dim: rgba(167, 139, 250, 0.12);
  --purple-border: rgba(167, 139, 250, 0.35);
  /* Seventh accent — the game's original pink. Used for the Mathwizards
     wordmark gradient AND as GameEngine/CreatorMode's second equation color
     (eq1/eq2 need two distinct hues; purple/pink already carried that
     meaning before this pass, so it earned full dim/border variants like
     the other six rather than staying a wordmark-only special case). */
  --pink: #f472b6;
  --pink-dim: rgba(244, 114, 182, 0.12);
  --pink-border: rgba(244, 114, 182, 0.35);

  /* Radius + border-width scale. 0.5px (not 1px) is deliberate: browsers
     round it up to 1 device pixel on non-retina and render a true hairline
     on retina, which is what the whole tracker suite already shipped with. */
  --radius-lg: 20px;
  --radius: 12px;
  --radius-sm: 8px;
  --border-width: 0.5px;

  /* Fonts. Display = Space Grotesk (already loaded for the periodic table;
     now the app's one distinctive display font, for h1/h2/brand/buttons).
     Body = the system stack every other page already used, for dense text. */
  --font-display: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'Space Mono', Menlo, Monaco, Consolas, 'Courier New', monospace;
}

/* ---------- Shared chrome classes ----------
   Used verbatim by the standalone HTML pages; the React app reads the same
   tokens via Tailwind utilities (see tailwind.config.js) but these classes
   are also available there for anything not worth a Tailwind roundtrip. */

.mw-header { display: flex; align-items: center; gap: 12px; margin-bottom: 2rem; }

/* Constant top nav banner — one per Budget Tracker suite page. All links are
   plain same-tab navigation (no window.open/named tabs/opener tricks — that
   multi-tab model produced unfixable "back goes to the wrong tab" bugs; the
   browser's own history is the back mechanism now). */
.mw-topnav {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  background: var(--bg-card); border: var(--border-width) solid var(--border);
  border-radius: var(--radius-sm); padding: 6px 10px; margin-bottom: 1.5rem;
  font-size: 13px;
}
.mw-topnav a {
  color: var(--text-muted); text-decoration: none; padding: 5px 10px;
  border-radius: var(--radius-sm); transition: all 0.15s;
  border: var(--border-width) solid transparent;
}
.mw-topnav a:hover { color: var(--text); background: var(--bg-hover); }
.mw-topnav a.active { color: var(--teal); background: var(--teal-dim); border-color: var(--teal-border); }
.mw-topnav .mw-topnav-brand {
  font-family: var(--font-display); font-weight: 600; color: var(--text); margin-right: 6px;
}

/* Right-aligned auth cluster inside the banner — avatar + name + sign out
   when signed in, a sign-in link otherwise. Same cluster on every page so
   the top bar reads identically suite-wide (the React pages render it
   themselves; the static how-to pages use public/topnav-auth.js). */
.mw-topnav-auth { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.mw-auth-avatar {
  width: 24px; height: 24px; border-radius: 50%; display: block; flex-shrink: 0;
  border: var(--border-width) solid var(--border); object-fit: cover;
}
.mw-auth-avatar-fallback {
  display: flex; align-items: center; justify-content: center;
  background: var(--teal-dim); color: var(--teal); font-size: 12px; font-weight: 600;
}
.mw-auth-name {
  font-size: 12px; color: var(--text-muted); max-width: 130px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mw-auth-signout, .mw-auth-signin {
  font-size: 12px; color: var(--text-muted); background: none; border: none;
  cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
  padding: 0; font-family: var(--font-body); flex-shrink: 0;
}
.mw-auth-signout:hover, .mw-auth-signin:hover { color: var(--text); }
.mw-back-link {
  background: none; border: var(--border-width) solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-muted); cursor: pointer; padding: 6px 12px; font-size: 13px;
  display: flex; align-items: center; gap: 6px; transition: all 0.15s; font-family: var(--font-body);
  text-decoration: none;
}
.mw-back-link:hover { border-color: var(--border-hover); color: var(--text); background: var(--bg-hover); }
.mw-header-title { font-family: var(--font-display); font-size: 22px; font-weight: 600; color: var(--text); }
.mw-header-sub { font-size: 14px; color: var(--text-muted); margin-top: 2px; }

.mw-card {
  background: var(--bg-card); border: var(--border-width) solid var(--border);
  border-radius: var(--radius); padding: 1.5rem;
}

.mw-btn {
  border-radius: var(--radius-sm); border: var(--border-width) solid var(--border);
  background: var(--bg-card); color: var(--text); font-family: var(--font-body);
  font-size: 14px; font-weight: 600; padding: 10px 18px; cursor: pointer; transition: all 0.15s;
}
.mw-btn:hover { border-color: var(--border-hover); background: var(--bg-hover); }
