/* =========================================================
   VERIDION MARKETS — Shared Design System
   Theme: Dark Wealth Intelligence
   ========================================================= */

:root,
:root[data-theme="dark"] {
  --obsidian: #0B0D10;
  --graphite: #151922;
  --graphite-2: #1C2230;
  --gold: #C6A66B;
  --gold-dim: #8C7649;
  --ivory: #E8E6E3;
  --ivory-dim: #9A9893;
  --emerald: #2D6A4F;
  --emerald-bright: #3F9D77;
  --crimson: #7F1D1D;
  --crimson-bright: #B83A3A;
  --glass: rgba(20, 24, 32, 0.72);
  --hairline: rgba(232, 230, 227, 0.08);
  --hairline-strong: rgba(232, 230, 227, 0.14);
  --gold-glow: rgba(198, 166, 107, 0.15);
  --on-gold: #0B0D10;
  --bar-bg: rgba(11, 13, 16, 0.92);
  --nav-bg: rgba(11, 13, 16, 0.78);
}

:root[data-theme="light"] {
  /* Warmer paper-tone background (less plain white). */
  --obsidian: #EDE8DC;          /* warm cream base */
  --graphite: #F7F3E9;          /* card surface — warm ivory */
  --graphite-2: #DFD9C8;        /* secondary surface */
  --gold: #A88847;              /* deeper gold for contrast on light */
  --gold-dim: #6E5826;
  --ivory: #1A1D22;             /* primary text */
  --ivory-dim: #5C5E62;         /* secondary text */
  --emerald: #1F5037;
  --emerald-bright: #1F7A50;
  --crimson: #7F1D1D;
  --crimson-bright: #983333;
  --glass: rgba(247, 243, 233, 0.85);
  --hairline: rgba(26, 29, 34, 0.14);
  --hairline-strong: rgba(26, 29, 34, 0.22);
  --gold-glow: rgba(168, 136, 71, 0.18);
  --on-gold: #FAF8F2;
  --bar-bg: rgba(237, 232, 220, 0.92);
  --nav-bg: rgba(237, 232, 220, 0.85);
  /* Subtle drop shadow for cards in light mode */
  --card-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset, 0 2px 8px rgba(99, 76, 36, 0.06), 0 1px 2px rgba(99, 76, 36, 0.04);
}

/* Light-mode card depth — applies wherever .card or .stat-card or .news-item appears */
:root[data-theme="light"] .card,
:root[data-theme="light"] .stat-card,
:root[data-theme="light"] .trade-card,
:root[data-theme="light"] .lb-row {
  box-shadow: var(--card-shadow);
}
:root[data-theme="light"] nav,
:root[data-theme="light"] .ticker-bar {
  box-shadow: 0 1px 0 rgba(99, 76, 36, 0.06);
}
/* Paper texture: subtle warm gradient + grain on light mode */
:root[data-theme="light"] body {
  background:
    radial-gradient(ellipse at top, #F5F0E2 0%, #EDE8DC 50%, #E5DECF 100%);
}
:root[data-theme="light"] body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.18'/></svg>");
  opacity: 0.4;
  pointer-events: none;
  z-index: 0;
  mix-blend-mode: multiply;
}

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

html, body {
  background: var(--obsidian);
  color: var(--ivory);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 300;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.mono { font-family: 'JetBrains Mono', monospace; }

/* Grid background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--hairline) 1px, transparent 1px),
    linear-gradient(90deg, var(--hairline) 1px, transparent 1px);
  background-size: 80px 80px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
}

/* Top ticker (Row 1 — scrolling marquee, 36px) */
.ticker-bar {
  position: fixed; top: 0; left: 0; right: 0;
  height: 36px;
  background: var(--bar-bg);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--hairline);
  overflow: hidden;
  z-index: 100;
  display: flex; align-items: center;
}
.ticker-track {
  display: inline-flex;
  gap: 46px;
  white-space: nowrap;
  animation: scroll 90s linear infinite;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px; font-weight: 400; letter-spacing: 0.04em;
}
.ticker-item { display: inline-flex; gap: 8px; align-items: center; }
.ticker-symbol { color: var(--ivory-dim); font-weight: 500; letter-spacing: 0.06em; }
.ticker-price { color: var(--ivory); }
.ticker-up { color: var(--emerald-bright); }
.ticker-down { color: var(--crimson-bright); }
.ticker-spark { opacity: 0.95; flex-shrink: 0; }
@keyframes scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* Markets bar (Row 2 — static majors strip, 64px) */
.markets-bar {
  position: fixed; top: 36px; left: 0; right: 0;
  height: 64px;
  background: var(--bar-bg);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--hairline);
  z-index: 99;
  display: flex; align-items: stretch;
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--hairline-strong) transparent;
}
.markets-bar::-webkit-scrollbar { height: 4px; }
.markets-bar::-webkit-scrollbar-track { background: transparent; }
.markets-bar::-webkit-scrollbar-thumb { background: var(--hairline-strong); border-radius: 2px; }
.markets-bar::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }
.markets-bar-track {
  display: flex; align-items: stretch;
  min-width: 100%;
  padding-left: 0;
}
.market-cell {
  display: flex; flex-direction: column; justify-content: center;
  padding: 8px 22px;
  border-left: 1px solid var(--hairline);
  min-width: 188px;
  cursor: pointer;
  text-decoration: none;
  color: var(--ivory);
  transition: background 0.2s ease;
  flex-shrink: 0;
}
.market-cell:first-child { border-left: none; }
.market-cell:hover { background: rgba(198, 166, 107, 0.08); }
.market-cell-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 3px;
  line-height: 1.2;
}
.market-cell-price {
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  font-weight: 400;
  color: var(--ivory);
  letter-spacing: -0.005em;
  line-height: 1.15;
  margin-bottom: 2px;
}
.market-cell-row {
  display: flex; align-items: center; gap: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  line-height: 1.2;
}
.market-cell-change { letter-spacing: 0.02em; white-space: nowrap; }
.market-cell-change.up { color: var(--emerald-bright); }
.market-cell-change.down { color: var(--crimson-bright); }
.market-cell-spark { margin-left: auto; opacity: 0.95; flex-shrink: 0; }
.market-cell-loading {
  display: flex; align-items: center; justify-content: center;
  width: 100%;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--ivory-dim);
  text-transform: uppercase;
}
@media (max-width: 1100px) {
  .market-cell { min-width: 168px; padding: 8px 16px; }
  .market-cell-price { font-size: 14px; }
}

/* Nav */
nav {
  position: fixed; top: 100px; left: 0; right: 0;
  height: 64px;
  background: var(--nav-bg);
  backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--hairline);
  z-index: 98;
  display: flex; align-items: center; padding: 0 48px;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 500; letter-spacing: 0.18em; font-size: 13px; text-transform: uppercase; color: var(--ivory); text-decoration: none; }
.brand-mark { width: 26px; height: 26px; border: 1px solid var(--gold); position: relative; transform: rotate(45deg); }
.brand-mark::after { content: ''; position: absolute; inset: 4px; background: var(--gold); opacity: 0.85; }
nav { height: 72px; }
nav .links { margin-left: auto; display: flex; gap: 40px; font-size: 15px; color: var(--ivory-dim); font-weight: 500; align-items: center; letter-spacing: 0.005em; }
nav .links a { color: var(--ivory-dim); text-decoration: none; transition: color 0.2s; position: relative; padding: 8px 2px; }
nav .links a:hover { color: var(--ivory); }
nav .links a.active { color: var(--gold); }
nav .links a.active::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: var(--gold); }

.btn-ghost { border: 1px solid var(--hairline-strong); padding: 9px 18px; color: var(--ivory); background: transparent; cursor: pointer; font-family: inherit; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; transition: all 0.25s; text-decoration: none; display: inline-block; }
.btn-ghost:hover { border-color: var(--gold); color: var(--gold); }
.btn-gold { background: var(--gold); color: var(--on-gold); border: 1px solid var(--gold); padding: 10px 22px; cursor: pointer; font-family: inherit; font-size: 12px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; transition: all 0.25s; text-decoration: none; display: inline-block; }
.btn-gold:hover { background: transparent; color: var(--gold); box-shadow: 0 0 32px var(--gold-glow); }

/* Mobile nav hamburger — injected by veridion-shared.js, hidden on desktop */
.nav-toggle { display: none; width: 40px; height: 40px; border: 1px solid var(--hairline-strong); background: transparent; cursor: pointer; padding: 0; margin-left: auto; align-items: center; justify-content: center; transition: all 0.25s; color: var(--ivory); }
.nav-toggle:hover { border-color: var(--gold); color: var(--gold); }
.nav-toggle span { display: block; width: 18px; height: 1px; background: currentColor; position: relative; transition: all 0.25s; }
.nav-toggle span::before, .nav-toggle span::after { content: ''; position: absolute; left: 0; width: 18px; height: 1px; background: currentColor; transition: all 0.25s; }
.nav-toggle span::before { top: -6px; }
.nav-toggle span::after { top: 6px; }
nav.is-open .nav-toggle span { background: transparent; }
nav.is-open .nav-toggle span::before { top: 0; transform: rotate(45deg); }
nav.is-open .nav-toggle span::after { top: 0; transform: rotate(-45deg); }

/* Theme toggle button in nav */
.theme-toggle { width: 36px; height: 36px; border: 1px solid var(--hairline-strong); background: transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: all 0.25s; padding: 0; color: var(--ivory-dim); }
.theme-toggle:hover { border-color: var(--gold); color: var(--gold); }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .icon-light { display: none; }
.theme-toggle .icon-dark { display: block; }
:root[data-theme="light"] .theme-toggle .icon-light { display: block; }
:root[data-theme="light"] .theme-toggle .icon-dark { display: none; }

/* Layout */
.container { max-width: 1320px; margin: 0 auto; padding: 0 48px; position: relative; z-index: 1; }

/* Page header */
.page-header { padding-top: 180px; padding-bottom: 60px; border-bottom: 1px solid var(--hairline); }
.eyebrow { display: inline-flex; align-items: center; gap: 12px; font-family: 'JetBrains Mono', monospace; font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--gold); margin-bottom: 24px; }
.eyebrow::before { content: ''; width: 32px; height: 1px; background: var(--gold); }
.page-title { font-size: clamp(40px, 5.4vw, 76px); font-weight: 200; line-height: 1.04; letter-spacing: -0.025em; margin-bottom: 24px; max-width: 18ch; }
.page-title .accent { color: var(--gold); font-style: italic; font-weight: 300; }
.page-sub { font-size: 18px; color: var(--ivory-dim); max-width: 64ch; line-height: 1.65; }

/* Section */
.section { padding: 96px 0; position: relative; }
.section-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 56px; border-bottom: 1px solid var(--hairline); padding-bottom: 24px; }
.section-title { font-size: clamp(28px, 3vw, 44px); font-weight: 200; letter-spacing: -0.015em; }
.section-title .num { font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--gold); margin-right: 18px; vertical-align: middle; }
.section-tag { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--ivory-dim); letter-spacing: 0.18em; text-transform: uppercase; }

/* Footer */
footer { border-top: 1px solid var(--hairline); padding: 56px 0 32px; margin-top: 80px; }
.foot-grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr; gap: 48px; margin-bottom: 56px; }
.foot-grid h4 { font-family: 'JetBrains Mono', monospace; font-size: 11px; letter-spacing: 0.2em; color: var(--gold); margin-bottom: 18px; text-transform: uppercase; }
.foot-grid ul { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.foot-grid li a { color: var(--ivory-dim); text-decoration: none; font-size: 13px; }
.foot-grid li a:hover { color: var(--ivory); }
.foot-grid .foot-brand p { color: var(--ivory-dim); font-size: 13px; line-height: 1.7; margin-top: 16px; max-width: 32ch; }
.foot-bottom { border-top: 1px solid var(--hairline); padding-top: 24px; display: flex; justify-content: space-between; font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--ivory-dim); letter-spacing: 0.06em; }

/* Tag chips */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--hairline-strong); font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ivory-dim); }
.chip.bull { color: var(--emerald-bright); border-color: rgba(63, 157, 119, 0.4); }
.chip.bear { color: var(--crimson-bright); border-color: rgba(184, 58, 58, 0.4); }
.chip.gold { color: var(--gold); border-color: rgba(198, 166, 107, 0.4); }

/* Card */
.card { background: var(--glass); backdrop-filter: blur(20px); border: 1px solid var(--hairline-strong); padding: 28px; transition: border-color 0.3s; }
.card:hover { border-color: rgba(198, 166, 107, 0.3); }

/* Responsive */
@media (max-width: 980px) {
  nav { padding: 0 20px; }
  .nav-toggle { display: inline-flex; }
  /* Collapse the desktop links into an off-canvas drawer */
  nav .links {
    position: fixed;
    top: 172px; /* below the ticker (36) + markets-bar (64) + nav (72) */
    left: 0;
    right: 0;
    background: var(--nav-bg);
    backdrop-filter: blur(24px);
    border-bottom: 1px solid var(--hairline);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 20px 24px;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.2s ease;
    opacity: 0;
    pointer-events: none;
  }
  nav.is-open .links {
    max-height: 80vh;
    opacity: 1;
    pointer-events: auto;
    overflow-y: auto;
  }
  nav .links a { padding: 14px 0; font-size: 16px; border-bottom: 1px solid var(--hairline); color: var(--ivory); }
  nav .links a.active::after { display: none; }
  nav .links a.active { color: var(--gold); }
  nav .links .btn-ghost, nav .links .btn-gold { margin-top: 12px; padding: 14px 22px; text-align: center; }
  nav .links .theme-toggle { align-self: flex-start; margin-top: 12px; }
  .container { padding: 0 20px; }
  .page-header { padding-top: 200px; }
  .foot-grid { grid-template-columns: 1fr 1fr; gap: 32px; }
  /* On mobile, never reserve right-gutter for the (hidden) side panel */
  body[data-side-panel="true"] .container { padding-right: 20px; }
}

/* =========================================================
   VERIDION SIDE PANEL (Yahoo-style right rail, v28)
   ========================================================= */
.veridion-side-panel {
  position: fixed;
  top: 184px;
  right: 24px;
  width: 320px;
  max-height: calc(100vh - 210px);
  overflow-y: auto;
  z-index: 50;
  background: var(--glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--hairline-strong);
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--hairline-strong) transparent;
}
.veridion-side-panel::-webkit-scrollbar { width: 5px; }
.veridion-side-panel::-webkit-scrollbar-track { background: transparent; }
.veridion-side-panel::-webkit-scrollbar-thumb { background: var(--hairline-strong); border-radius: 2px; }
.veridion-side-panel::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }

.vsp-section { padding: 16px 18px; border-bottom: 1px solid var(--hairline); }
.vsp-section:last-child { border-bottom: none; }
.vsp-section-header {
  display: flex; align-items: center; justify-content: space-between;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.22em;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--hairline);
}
.vsp-section-header a {
  color: var(--ivory-dim);
  text-decoration: none;
  font-size: 9px;
  letter-spacing: 0.16em;
  transition: color 0.2s;
}
.vsp-section-header a:hover { color: var(--gold); }

.vsp-search-form { display: flex; gap: 0; border: 1px solid var(--hairline-strong); transition: border-color 0.2s; }
.vsp-search-form:focus-within { border-color: var(--gold); }
.vsp-search-input {
  flex: 1;
  padding: 10px 12px;
  background: var(--obsidian);
  border: none;
  color: var(--ivory);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  outline: none;
  min-width: 0;
}
.vsp-search-input::placeholder { color: var(--ivory-dim); }
.vsp-search-btn {
  background: var(--gold);
  color: var(--on-gold);
  border: none;
  padding: 0 14px;
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: background 0.2s;
}
.vsp-search-btn:hover { background: var(--ivory); }

.vsp-row {
  display: grid;
  grid-template-columns: 56px 60px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--hairline);
  text-decoration: none;
  color: var(--ivory);
  font-family: 'JetBrains Mono', monospace;
  transition: padding-left 0.15s;
}
.vsp-row:last-of-type { border-bottom: none; }
.vsp-row:hover { padding-left: 3px; }
.vsp-row.no-spark { grid-template-columns: 70px 1fr auto; }
.vsp-ticker {
  font-size: 12px;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.04em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vsp-spark { opacity: 0.95; }
.vsp-spark-empty { width: 60px; height: 16px; }
.vsp-price {
  font-size: 11px;
  color: var(--ivory);
  text-align: right;
  letter-spacing: 0.02em;
}
.vsp-change {
  font-size: 11px;
  font-weight: 500;
  text-align: right;
  white-space: nowrap;
  min-width: 56px;
}
.vsp-change.up { color: var(--emerald-bright); }
.vsp-change.down { color: var(--crimson-bright); }
.vsp-empty {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--ivory-dim);
  text-align: center;
  padding: 10px 0;
  letter-spacing: 0.06em;
}
.vsp-empty a {
  color: var(--gold);
  text-decoration: none;
  letter-spacing: 0.12em;
  font-size: 10px;
  text-transform: uppercase;
  transition: color 0.2s;
}
.vsp-empty a:hover { color: var(--ivory); }

/* When the side panel is active, reserve gutter on the right of .container so it doesn't overlap */
@media (min-width: 1280px) {
  body[data-side-panel="true"] .container {
    padding-right: 380px;
  }
}
@media (max-width: 1279px) {
  .veridion-side-panel { display: none !important; }
}
