/* ================================================================
   Bitcoin Observatory — Institutional Position Paper
   Design system: Inter (sans) + Source Serif 4 (serif)
   Aesthetic: Knight Capital-inspired, minimal, data-first
   ================================================================ */

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

:root {
  --bg: #fafafa;
  --alt-bg: #f5f5f5;
  --card: #ffffff;
  --text: #0a0a0a;
  --secondary: #404040;
  --muted: #737373;
  --border: #e5e5e5;
  --accent: #e8740c;
  --red: #dc2626;
  --green: #16a34a;
  --serif: 'Source Serif 4', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Nav ──────────────────────────────────────────────── */
.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 48px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 100;
}

.nav-brand {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-price {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.nav-price .price-value {
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.nav-price .live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.nav-cta {
  padding: 8px 20px;
  background: var(--text);
  color: white;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}

.nav-cta:hover { background: #262626; }

/* ── Layout ──────────────────────────────────────────── */
.narrow {
  max-width: 780px;
  margin: 0 auto;
  padding: 80px 48px;
}

.wide {
  max-width: 1080px;
  margin: 0 auto;
  padding: 80px 48px;
}

.alt-bg { background: var(--alt-bg); }

/* ── Typography ──────────────────────────────────────── */
.beat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 20px;
  font-weight: 600;
}

h1 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(32px, 4.5vw, 48px);
  line-height: 1.15;
  letter-spacing: -0.025em;
  margin-bottom: 32px;
}

h2 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 32px;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 24px;
}

p {
  font-size: 16px;
  color: var(--secondary);
  line-height: 1.8;
  margin-bottom: 20px;
}

p:last-child { margin-bottom: 0; }

/* ── Hero ────────────────────────────────────────────── */
.hero {
  max-width: 780px;
  margin: 0 auto;
  padding: 120px 48px 80px;
}

.hero-lead {
  font-size: 18px;
  color: var(--secondary);
  line-height: 1.8;
  max-width: 620px;
}

.hero-stats {
  margin-top: 56px;
  padding: 40px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 40px;
}

.stat .stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 500;
}

.stat .stat-value {
  font-family: var(--serif);
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat .stat-context {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

/* ── Table ────────────────────────────────────────────── */
.vol-table {
  width: 100%;
  border-collapse: collapse;
  margin: 40px 0;
  font-size: 14px;
}

.vol-table thead th {
  text-align: left;
  padding: 14px 20px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 2px solid var(--text);
}

.vol-table tbody td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  color: var(--secondary);
  font-variant-numeric: tabular-nums;
}

.vol-table tbody td:first-child {
  color: var(--text);
  font-weight: 500;
}

.vol-table .hl {
  background: #fafaf5;
  color: var(--text);
  font-weight: 600;
}

/* ── Three-Lens Chart ────────────────────────────────── */
.lens-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
}

.lens-tab {
  padding: 14px 24px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  color: var(--muted);
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  font-family: var(--sans);
  transition: all 0.2s;
}

.lens-tab:hover { color: var(--text); }
.lens-tab.active {
  color: var(--text);
  border-bottom-color: var(--text);
}

.lens-chart {
  background: var(--card);
  border: 1px solid var(--border);
  border-top: none;
  padding: 32px;
}

.lens-chart-area {
  height: 440px;
  position: relative;
}

.lens-chart-area canvas {
  width: 100% !important;
  height: 100% !important;
}

.lens-metrics {
  display: flex;
  justify-content: space-between;
  padding-top: 20px;
  margin-top: 20px;
  border-top: 1px solid var(--border);
}

.lens-metric { text-align: center; }

.lens-metric .m-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 500;
}

.lens-metric .m-value {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.lens-desc {
  margin-top: 24px;
  padding: 20px 24px;
  background: var(--alt-bg);
  border-left: 3px solid var(--text);
  font-size: 14px;
  color: var(--secondary);
  line-height: 1.7;
}

/* ── Kelly Grid ──────────────────────────────────────── */
.kelly-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0;
  border: 1px solid var(--border);
  margin: 40px 0;
}

.kelly-cell {
  padding: 32px;
  border-right: 1px solid var(--border);
  text-align: center;
}

.kelly-cell:last-child { border-right: none; }

.kelly-cell .kc-pos {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
}

.kelly-cell .kc-alloc {
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 700;
}

.kelly-cell .kc-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.kelly-cell.below .kc-alloc { color: var(--green); }
.kelly-cell.at .kc-alloc { color: var(--text); }
.kelly-cell.above .kc-alloc { color: var(--accent); }

/* ── Now Box ─────────────────────────────────────────── */
.now-box {
  margin: 40px 0;
  padding: 40px;
  background: var(--text);
  color: white;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 32px;
  text-align: center;
}

.now-item .ni-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #a3a3a3;
  margin-bottom: 8px;
  font-weight: 500;
}

.now-item .ni-value {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 700;
}

.now-item .ni-value.orange { color: var(--accent); }
.now-item .ni-value.green { color: #4ade80; }

/* ── Backtest Cards ──────────────────────────────────── */
.bt-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin: 40px 0;
}

.bt-card {
  padding: 32px;
  border: 1px solid var(--border);
  background: var(--card);
}

.bt-card.pl {
  border-color: var(--text);
  border-width: 2px;
}

.bt-card .bt-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--muted);
}

.bt-card.pl .bt-label { color: var(--accent); }

.bt-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #f5f5f5;
  font-size: 14px;
}

.bt-row:last-child { border-bottom: none; }
.bt-row .bt-k { color: var(--muted); }

.bt-row .bt-v {
  font-weight: 600;
  font-family: var(--serif);
  font-variant-numeric: tabular-nums;
}

/* ── Backtest Chart ──────────────────────────────────── */
.bt-chart-area {
  height: 320px;
  position: relative;
  margin: 40px 0;
}

.bt-chart-area canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ── Cost Box ────────────────────────────────────────── */
.cost-box {
  margin: 48px 0;
  padding: 48px;
  background: var(--text);
  color: white;
  text-align: center;
}

.cost-box .cb-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #a3a3a3;
  margin-bottom: 12px;
  font-weight: 500;
}

.cost-box .cb-value {
  font-family: var(--serif);
  font-size: 56px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}

.cost-box .cb-note {
  font-size: 15px;
  color: #a3a3a3;
  max-width: 480px;
  margin: 0 auto;
}

/* ── Formula Box ─────────────────────────────────────── */
.formula-box {
  margin: 32px 0;
  padding: 24px 32px;
  background: var(--alt-bg);
  border: 1px solid var(--border);
  font-size: 14px;
  line-height: 1.8;
}

.formula-box .formula {
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  margin: 8px 0;
}

.formula-box .formula-note {
  font-size: 13px;
  color: var(--muted);
}

/* ── Credits ─────────────────────────────────────────── */
.credits {
  margin-top: 32px;
  padding: 24px 0;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
}

/* ── CTA ─────────────────────────────────────────────── */
.cta {
  max-width: 780px;
  margin: 0 auto;
  padding: 80px 48px 120px;
  text-align: center;
}

.cta h2 { margin-bottom: 16px; }

.cta p {
  max-width: 480px;
  margin: 0 auto 40px;
}

.cta-btn {
  display: inline-block;
  padding: 16px 48px;
  background: var(--text);
  color: white;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-decoration: none;
  transition: background 0.2s;
  border: none;
  cursor: pointer;
}

.cta-btn:hover { background: #262626; }

.cta-meta {
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
}

/* ── Footer ──────────────────────────────────────────── */
.footer {
  padding: 32px 48px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
  line-height: 1.7;
  max-width: 780px;
  margin: 0 auto;
}

/* ── Simulator ───────────────────────────────────────── */
.sim-controls {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 24px;
  margin: 40px 0;
  padding: 32px;
  background: var(--alt-bg);
  border: 1px solid var(--border);
}

.sim-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
}

.sim-input-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sim-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}

.sim-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
}

.sim-slider:disabled { opacity: 0.3; cursor: not-allowed; }

.sim-slider-green::-webkit-slider-thumb { background: var(--green); }
.sim-slider-orange::-webkit-slider-thumb { background: var(--accent); }

.sim-value {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 48px;
  text-align: right;
}

.sim-toggles {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
}

.sim-toggle {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--sans);
  background: var(--card);
  border: none;
  border-right: 1px solid var(--border);
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
}

.sim-toggle:last-child { border-right: none; }

.sim-toggle.active {
  background: var(--text);
  color: white;
}

.sim-toggle:hover:not(.active) {
  background: var(--alt-bg);
  color: var(--text);
}

.sim-period {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sim-select {
  padding: 8px 12px;
  font-size: 13px;
  font-family: var(--sans);
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
}

.sim-dash {
  color: var(--muted);
  font-size: 16px;
}

.sim-reset-wrap {
  display: flex;
  align-items: flex-end;
}

.sim-reset {
  font-size: 12px;
  color: var(--muted);
  text-decoration: underline;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--sans);
  padding: 8px 0;
}

.sim-reset:hover { color: var(--text); }

.sim-chart-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
  margin-top: 32px;
}

.sim-chart-area {
  height: 360px;
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  padding: 16px;
}

.sim-chart-area canvas {
  width: 100% !important;
  height: 100% !important;
}

.sim-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin: 32px 0;
  border: 1px solid var(--border);
}

.sim-metrics-col {
  padding: 24px 32px;
}

.sim-metrics-hl {
  border-left: 2px solid var(--text);
  background: #fafaf5;
}

.sim-metrics-header {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 16px;
}

.sim-metrics-hl .sim-metrics-header { color: var(--accent); }

.sim-metric-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 14px;
}

.sim-metric-row:last-child { border-bottom: none; }

.sim-mk { color: var(--muted); }

.sim-mv {
  font-weight: 600;
  font-family: var(--serif);
  font-variant-numeric: tabular-nums;
}

.sim-log-toggle {
  text-align: center;
  margin: 24px 0;
}

.sim-log-btn {
  font-size: 13px;
  font-weight: 600;
  font-family: var(--sans);
  color: var(--muted);
  background: none;
  border: 1px solid var(--border);
  padding: 10px 24px;
  cursor: pointer;
  transition: all 0.15s;
}

.sim-log-btn:hover {
  color: var(--text);
  border-color: var(--text);
}

.sim-log { margin: 24px 0; }

.sim-log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.sim-log-table thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 2px solid var(--text);
}

.sim-log-table tbody td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.sim-log-table .action-increase {
  color: var(--green);
  font-weight: 600;
}

.sim-log-table .action-reduce {
  color: var(--accent);
  font-weight: 600;
}

.sim-log-table .action-hold {
  color: #888;
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
  .hero { padding: 80px 24px 60px; }
  .narrow, .wide { padding: 60px 24px; }
  .nav { padding: 12px 24px; }
  .nav-cta { display: none; }
  .hero-stats { grid-template-columns: 1fr; gap: 24px; }
  .kelly-grid { grid-template-columns: 1fr; }
  .kelly-cell { border-right: none; border-bottom: 1px solid var(--border); }
  .kelly-cell:last-child { border-bottom: none; }
  .now-box { grid-template-columns: 1fr; }
  .bt-grid { grid-template-columns: 1fr; }
  .lens-tabs { overflow-x: auto; }
  .lens-metrics { flex-wrap: wrap; gap: 16px; }
  .lens-metric { flex: 1 1 45%; }
  .cost-box .cb-value { font-size: 40px; }
  .sim-controls { grid-template-columns: 1fr; }
  .sim-metrics { grid-template-columns: 1fr; }
  .sim-metrics-hl { border-left: none; border-top: 2px solid var(--text); }
  .sim-log-table { font-size: 11px; }
  .sim-log-table thead th,
  .sim-log-table tbody td { padding: 8px; }
}

@media print {
  .nav { position: static; }
  .nav-cta, .cta-btn { display: none; }
  .live-dot { display: none; }
  body { font-size: 12px; }
}
