/* Global theme palette. Dark by default; .light on <html> or <body> swaps.
 * Lifted from web/institutions/index.html and unified for all pages.
 * To toggle: localStorage.setItem('theme', 'light'|'dark'). The pre-render
 * script in each <head> applies the class before paint to avoid FOUC.
 */

:root {
  --bg:           #0f1117;
  --bg-card:      #141826;
  --bg-chip:      #1a2136;
  --bg-panel:     #0b0d14;
  --border:       #1e2535;
  --border-soft:  #141826;
  --text:         #e2e8f0;
  --text-strong:  #e8dfc0;
  --text-soft:    #cbd5e1;
  --muted:        #94a3b8;
  --muted-dim:    #3d526b;
  --accent:       #c8a84b;
  --up:           #22c55e;
  --down:         #ef4444;
  --bench:        #67e8f9;
  --badge-new-bg:  #134e3a; --badge-new-fg:  #34d399;
  --badge-exit-bg: #4b1818; --badge-exit-fg: #fca5a5;
  --badge-add-bg:  #133748; --badge-add-fg:  #67e8f9;
  --badge-trim-bg: #3a2d10; --badge-trim-fg: #fde68a;
  --tm-hold-fill: #1e2a3d; --tm-hold-stroke: #3d526b;
  --tm-new-fill:  #154935; --tm-new-stroke:  #34d399;
  --tm-add-fill:  #13445a; --tm-add-stroke:  #67e8f9;
  --tm-trim-fill: #4a3a10; --tm-trim-stroke: #fde68a;
  --tm-label:     #e8dfc0;
  --tm-sublabel:  #94a3b8;
  --grid:         #141826;
  --shadow:       0 4px 20px rgba(0,0,0,0.6);
}

/* Star icon (favorites toggle). Pages render <button class="star-icon"
 * data-star-type="stock|fund" data-star-id="..."> and stars.js wires
 * click + reflects the .is-starred state.
 */
.star-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  margin: 0;
  background: transparent;
  border: none;
  color: var(--muted-dim);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  border-radius: 3px;
  transition: color 0.12s, transform 0.08s;
  font-family: inherit;
}
.star-icon::before { content: "☆"; }
.star-icon:hover { color: var(--accent); }
.star-icon:active { transform: scale(0.92); }
.star-icon.is-starred { color: var(--accent); }
.star-icon.is-starred::before { content: "★"; }

html.light, body.light {
  --bg:           #f5f7fa;
  --bg-card:      #ffffff;
  --bg-chip:      #eef2f7;
  --bg-panel:     #f8fafc;
  --border:       #dde3ec;
  --border-soft:  #e8edf3;
  --text:         #1a2332;
  --text-strong:  #6b4e1a;
  --text-soft:    #334155;
  --muted:        #64748b;
  --muted-dim:    #94a3b8;
  --accent:       #8b6f1e;
  --up:           #15803d;
  --down:         #b91c1c;
  --bench:        #0e7490;
  --badge-new-bg:  #d1fae5; --badge-new-fg:  #065f46;
  --badge-exit-bg: #fee2e2; --badge-exit-fg: #991b1b;
  --badge-add-bg:  #cffafe; --badge-add-fg:  #155e75;
  --badge-trim-bg: #fef3c7; --badge-trim-fg: #78350f;
  --tm-hold-fill: #e2e8f0; --tm-hold-stroke: #94a3b8;
  --tm-new-fill:  #d1fae5; --tm-new-stroke:  #059669;
  --tm-add-fill:  #cffafe; --tm-add-stroke:  #0891b2;
  --tm-trim-fill: #fef3c7; --tm-trim-stroke: #d97706;
  --tm-label:     #1a2332;
  --tm-sublabel:  #475569;
  --grid:         #e2e8f0;
  --shadow:       0 4px 18px rgba(15,23,42,0.10);
}

/* ── Nav tap dropdown (STO-152) ───────────────────────────────────────
 * Wraps a top-level nav item ("Paper Trading" → Manage Portfolio +
 * Leaderboard). The menu opens on click/tap — toggled by initNavDropdown
 * in web/js/auth.js — so it works on touch (hover does not). The menu is
 * position:fixed (auth.js sets top/left from the toggle) so the mobile
 * tab bar's overflow-x:auto cannot clip it. Unscoped class selectors so
 * it works in both .tab-nav and the stock page's .site-nav.
 */
.nav-dropdown { position: relative; display: inline-flex; }
.nav-dropdown-toggle { cursor: pointer; }
.nav-caret {
  display: inline-block; font-size: 0.7em; opacity: 0.6;
  margin-left: 3px; transition: transform .15s;
}
.nav-dropdown.open .nav-caret { transform: rotate(180deg); }
.nav-menu {
  display: none;
  position: fixed;
  min-width: 170px;
  background: var(--bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 300;
}
.nav-dropdown.open .nav-menu { display: block; }
.nav-menu a {
  display: block;
  padding: 9px 14px;
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  border: 0;
  border-bottom: 1px solid var(--border);
}
.nav-menu a:last-child { border-bottom: 0; }
.nav-menu a:hover { color: var(--text); background: var(--bg-chip); }
