:root {
  --bg: #0b0d10;
  --bg-alt: #111418;
  --fg: #e8eaed;
  --muted: #9aa1ab;
  --line: #22272e;
  --accent: #c9a96e;
  --up: #3fb68b;
  --down: #e0605a;
  --nav-bg: rgba(11, 13, 16, 0.85);
  --alt-bg: rgba(17, 20, 24, 0.78);
  --chart-boost: 1;
  --maxw: 1120px;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f7f5f0;
  --bg-alt: #eeeae1;
  --fg: #15171b;
  --muted: #555c68;
  --line: #dcd6ca;
  --accent: #8a6a2f;
  --up: #1f9467;
  --down: #cc4a42;
  --nav-bg: rgba(247, 245, 240, 0.85);
  --alt-bg: rgba(238, 234, 225, 0.8);
  --chart-boost: 1.25;
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 136px; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: Geist, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 300;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s, color .3s;
}
a { color: inherit; text-decoration: none; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* Market background */
.market-bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
main, .footer { position: relative; z-index: 1; }

/* Nav */
.nav {
  position: sticky; top: 0; z-index: 10;
  background: var(--nav-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 500; letter-spacing: 0.02em; }
.nav-end { display: flex; align-items: center; gap: 28px; }
.nav nav { display: flex; gap: 28px; }
.nav nav a { font-size: 14px; color: var(--muted); transition: color .2s; }
.nav nav a:hover { color: var(--fg); }
.menu-btn { display: none; background: none; border: 0; width: 40px; height: 40px; cursor: pointer; position: relative; }
.menu-btn span { position: absolute; left: 10px; right: 10px; height: 1.5px; background: var(--fg); transition: transform .2s, top .2s; }
.menu-btn span:first-child { top: 15px; }
.menu-btn span:last-child { top: 24px; }
.menu-btn[aria-expanded="true"] span:first-child { top: 19.5px; transform: rotate(45deg); }
.menu-btn[aria-expanded="true"] span:last-child { top: 19.5px; transform: rotate(-45deg); }

/* Theme toggle */
.theme-toggle {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line);
  background: none; color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color .2s, border-color .2s, transform .3s;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); transform: rotate(-20deg); }
.theme-toggle svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .icon-moon, [data-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* Ticker strip */
/* Sticky so it is always in view: the widget scrolls its items into view,
   and Chrome would otherwise scroll the whole page to follow it. */
.ticker {
  position: sticky; top: 64px; z-index: 9; min-height: 46px;
  background: var(--nav-bg); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
/* Match the embedded document's scheme so Chrome keeps the iframe transparent. */
.ticker iframe, .widget iframe { color-scheme: light; }
.ticker-loading {
  font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--muted);
  line-height: 46px; padding: 0 24px;
}

/* Widgets */
.hero-compact { padding: 112px 0 88px; }
.widget-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 48px; }
.widget-grid h2, .section .wrap > h2 { margin-top: 16px; }
.widget { border: 1px solid var(--line); background: var(--bg-alt); overflow: hidden; }
.widget-tall { height: 560px; }
.widget-chart { height: 600px; }
.widget .tradingview-widget-container, .widget .tradingview-widget-container__widget { height: 100%; width: 100%; }
/* Chart scroll guard (see widgets.js); top offset leaves the chart toolbar clickable. */
.widget[data-tv-guard] { position: relative; }
.chart-guard {
  position: absolute; inset: 38px 0 0 0; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  transition: background-color .25s;
}
.chart-guard.show-hint { background: rgba(0, 0, 0, 0.45); }
[data-live] .chart-guard { pointer-events: none; }
.chart-hint {
  padding: 10px 18px; border-radius: 6px;
  background: rgba(11, 13, 16, 0.85); color: #e8eaed;
  font-size: 15px; font-weight: 400;
  opacity: 0; transition: opacity .25s; pointer-events: none;
}
.chart-guard.show-hint .chart-hint { opacity: 1; }
.data-note { margin-top: 48px; font-size: 13px; opacity: 0.7; }
.nav nav a[aria-current="page"] { color: var(--fg); }

/* Research */
.card-link { display: flex; flex-direction: column; transition: background .2s; }
.card-link:hover { background: var(--bg); }
.card-link:hover h3 { color: var(--accent); }
.card-link time { margin-top: auto; padding-top: 24px; font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--muted); }
.article { padding: 72px 0 112px; border-bottom: 1px solid var(--line); }
.article .wrap { max-width: 760px; }
.article h1 { max-width: 20ch; }
.back { font-family: "JetBrains Mono", monospace; font-size: 13px; color: var(--muted); }
.back:hover { color: var(--accent); }
.article .eyebrow { margin-top: 40px; }
.meta { margin-top: 20px; font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--muted); }
.prose { margin-top: 48px; padding-top: 40px; border-top: 1px solid var(--line); }
.prose h2 { font-size: 24px; margin: 40px 0 12px; }
.prose p { color: var(--muted); font-size: 17px; }
.prose p + p { margin-top: 16px; }
.article .data-note { color: var(--muted); }

/* Focus */
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Hero */
.hero { position: relative; overflow: hidden; padding: 160px 0 140px; border-bottom: 1px solid var(--line); }
.hero .wrap { position: relative; z-index: 1; }
.eyebrow, .label {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent);
}
h1 { font-size: clamp(36px, 6vw, 68px); font-weight: 400; line-height: 1.08; letter-spacing: -0.03em; max-width: 16ch; margin: 20px 0 28px; }
.lede { font-size: clamp(17px, 2vw, 20px); color: var(--muted); max-width: 58ch; }
.grid-bg {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse at 80% 30%, #000 0%, transparent 65%);
  -webkit-mask-image: radial-gradient(ellipse at 80% 30%, #000 0%, transparent 65%);
  opacity: 0.7;
}

/* Sections */
.section { padding: 112px 0; border-bottom: 1px solid var(--line); }
.section.alt { background: var(--alt-bg); }
.two-col { display: grid; grid-template-columns: 220px 1fr; gap: 48px; }
h2 { font-size: clamp(28px, 3.6vw, 40px); font-weight: 400; letter-spacing: -0.025em; line-height: 1.15; margin-bottom: 24px; }
.section p { color: var(--muted); max-width: 62ch; }
.section p + p { margin-top: 16px; }
.section > .wrap > h2 { margin-top: 16px; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); margin-top: 48px; }
.card { background: var(--bg-alt); padding: 36px 32px; }
.card .num { font-family: "JetBrains Mono", monospace; color: var(--accent); font-size: 13px; }
.card h3 { font-size: 19px; font-weight: 500; letter-spacing: -0.015em; margin: 18px 0 12px; }
.card p { font-size: 15px; }

/* Assets */
.assets { list-style: none; display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); margin-top: 32px; max-width: 560px; }
.assets li { background: var(--bg); padding: 22px 24px; font-weight: 400; }
.assets li::before { content: ""; display: inline-block; width: 6px; height: 6px; background: var(--accent); margin-right: 14px; vertical-align: middle; }

/* Approach pipeline */
.pipeline { list-style: none; position: relative; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin-top: 56px; }
.pipeline::before {
  /* Runs from the first icon to the last (each column is 20% wide). */
  content: ""; position: absolute; left: 20px; right: calc(20% - 20px); top: 20px; height: 1px;
  background: var(--line); transform-origin: left;
}
.step { position: relative; padding-right: 28px; }
.step-node {
  position: relative; z-index: 1; display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%;
  background: var(--bg); color: var(--accent); transition: border-color .2s;
}
.step-node svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.step:hover .step-node { border-color: var(--accent); }
.step .num, .risk-band .num { display: block; font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--accent); }
.step .num { margin-top: 24px; }
.step h3, .risk-band h3 { font-size: 19px; font-weight: 500; letter-spacing: -0.015em; margin: 8px 0 10px; }
.step p, .risk-band p { font-size: 15px; }
.step-loop { display: block; margin-top: 14px; font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--muted); }
.risk-band {
  display: flex; gap: 24px; align-items: flex-start; margin-top: 56px; padding: 28px 32px;
  background: var(--bg-alt); border: 1px solid var(--line); border-left: 2px solid var(--accent);
}
.risk-band .step-node { flex: none; }
.risk-band h3 { margin-top: 6px; }

/* Scroll reveal: hidden only when JS is running (see theme-init.js and main.js). */
.js [data-reveal] .step, .js .risk-band[data-reveal] { opacity: 0; transform: translateY(16px); transition: opacity .6s ease, transform .6s ease; }
.js .pipeline[data-reveal]::before { transform: scaleX(0); transition: transform 1.2s ease; }
.js [data-reveal].in .step, .js .risk-band[data-reveal].in { opacity: 1; transform: none; }
.js .pipeline[data-reveal].in::before { transform: none; }
.js [data-reveal] .step:nth-child(2) { transition-delay: .1s; }
.js [data-reveal] .step:nth-child(3) { transition-delay: .2s; }
.js [data-reveal] .step:nth-child(4) { transition-delay: .3s; }
.js [data-reveal] .step:nth-child(5) { transition-delay: .4s; }
.js .risk-band[data-reveal] { transition-delay: .2s; }

/* Button */
.btn {
  display: inline-block; margin-top: 28px; padding: 12px 22px;
  border: 1px solid var(--accent); color: var(--accent);
  font-family: "JetBrains Mono", monospace; font-size: 14px;
  transition: background .2s, color .2s;
}
.btn:hover { background: var(--accent); color: var(--bg); }

/* Footer */
.footer { padding: 56px 0 64px; }
.copy { font-size: 13px; color: var(--muted); opacity: 0.6; }

/* Responsive */
@media (max-width: 1024px) {
  .nav-end, .nav nav { gap: 20px; }
  .pipeline { grid-template-columns: 1fr; gap: 36px; }
  .pipeline::before { left: 20px; right: auto; top: 0; bottom: 0; width: 1px; height: auto; transform-origin: top; }
  .js .pipeline[data-reveal]::before { transform: scaleY(0); }
  .step { padding: 0 0 0 64px; min-height: 40px; }
  .step .step-node { position: absolute; left: 0; top: 0; }
  .step .num { margin-top: 0; }
}
@media (max-width: 860px) {
  .menu-btn { display: block; }
  .nav-end { gap: 8px; }
  .nav nav {
    display: none; position: absolute; top: 64px; left: 0; right: 0;
    flex-direction: column; gap: 0; padding: 8px 24px 16px;
    background: var(--bg); border-bottom: 1px solid var(--line);
  }
  .nav nav.open { display: flex; }
  .nav nav a { font-size: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .nav nav a:last-child { border-bottom: 0; }
  .two-col { grid-template-columns: 1fr; gap: 16px; }
  .cards { grid-template-columns: 1fr; }
  .risk-band { padding: 24px 20px; gap: 20px; }
  .widget-grid { grid-template-columns: 1fr; gap: 64px; }
  .widget-chart { height: 460px; }
  .hero { padding: 112px 0 96px; }
  .section { padding: 80px 0; }
}
@media (max-width: 480px) {
  .wrap { padding: 0 16px; }
  .nav nav { padding: 8px 16px 16px; }
  .assets { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
