/* ================= live indicator demo ================= */
.demo {
  position: relative; padding: clamp(88px, 12vh, 140px) var(--gutter) clamp(72px, 10vh, 120px);
  background:
    radial-gradient(50% 40% at 15% 20%, rgba(217, 178, 106, 0.07), transparent 70%),
    radial-gradient(40% 40% at 90% 90%, rgba(57, 217, 138, 0.035), transparent 70%),
    var(--bg);
  border-top: 1px solid var(--line);
}
.demo__inner { max-width: 1240px; margin: 0 auto; }
.demo__head {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 32px 48px; flex-wrap: wrap;
  margin-bottom: clamp(32px, 5vh, 48px);
}
.demo__head .eyebrow { margin-bottom: 18px; }
.demo__h { margin: 0; font-family: var(--serif); font-weight: 600; font-size: clamp(36px, 4.2vw, 60px); line-height: 1.02; letter-spacing: -0.035em; }
.demo__h em {
  font-style: italic;
  background: linear-gradient(100deg, #b3843a, #f7dc9c 40%, #d9b26a 65%, #a27630);
  -webkit-background-clip: text; background-clip: text; color: transparent; padding-right: 0.05em;
}
.demo__lede { margin: 0; max-width: 430px; font-size: 15px; line-height: 1.7; color: var(--ink-2); }

.demo__frame {
  position: relative; padding: clamp(14px, 2vw, 22px);
  border: 1px solid var(--line); border-radius: 24px;
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.008));
  box-shadow: 0 40px 120px -60px rgba(0, 0, 0, 0.9);
  opacity: 0; transform: translateY(28px);
  transition: opacity 1s var(--ease), transform 1.1s var(--ease);
}
.demo.is-in .demo__frame { opacity: 1; transform: none; }

/* tabs */
.demo__bar { display: flex; justify-content: space-between; align-items: center; gap: 12px 20px; flex-wrap: wrap; }
.demo__tabs {
  display: inline-flex; gap: 4px; padding: 4px; max-width: 100%; overflow-x: auto; scrollbar-width: none;
  border: 1px solid var(--line); border-radius: 999px; background: rgba(0, 0, 0, 0.3);
}
.demo__tabs::-webkit-scrollbar { display: none; }
.demo__tab {
  flex: none; height: 36px; padding: 0 18px; border: 0; border-radius: 999px; cursor: pointer;
  font: 600 13px var(--sans); letter-spacing: 0.02em; color: var(--ink-2); background: transparent;
  transition: color 0.3s, background-color 0.3s, box-shadow 0.3s;
}
.demo__tab:hover { color: var(--ink); }
.demo__tab[aria-selected="true"] {
  color: #1a1408;
  background: linear-gradient(120deg, #c99a4c, #f5d896 55%, #d9b26a);
  box-shadow: 0 6px 24px -8px rgba(217, 178, 106, 0.7);
}
.demo__tab:focus-visible, .demo__btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* tools: zoom + "go to latest" (shown only after panning back) */
.demo__tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.demo__btn {
  height: 38px; padding: 0 16px; border-radius: 999px; cursor: pointer;
  font: 600 12.5px var(--sans); letter-spacing: 0.02em; color: var(--ink);
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.025);
  transition: border-color 0.3s, color 0.3s, background-color 0.3s, opacity 0.35s var(--ease), transform 0.35s var(--ease);
}
.demo__btn:hover { border-color: rgba(217, 178, 106, 0.6); color: var(--gold-2); }
.demo__btn--icon { width: 38px; padding: 0; font-size: 17px; }
.demo__last { opacity: 0; transform: translateX(8px); pointer-events: none; }
.demo__last.is-on { opacity: 1; transform: none; pointer-events: auto; }

/* chart */
.demo__chart { position: relative; margin-top: 16px; height: clamp(340px, 52vh, 540px); }
.demo__canvas {
  display: block; width: 100%; height: 100%; cursor: grab; touch-action: pan-y; outline: none;
  border-radius: 12px;
}
.demo__canvas:focus-visible { box-shadow: 0 0 0 2px rgba(217, 178, 106, 0.5); }
.demo__canvas.is-drag { cursor: grabbing; }
.demo__msg {
  position: absolute; left: 50%; top: 42%; translate: -50% -50%; max-width: min(420px, 90%);
  padding: 12px 18px; border-radius: 12px; text-align: center;
  font-size: 13px; line-height: 1.6; color: var(--ink-2);
  border: 1px solid var(--line); background: rgba(7, 7, 10, 0.85); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  pointer-events: none;
}

/* timeframe label on the chart */
.demo__tf {
  position: absolute; left: 10px; top: 8px; z-index: 2; pointer-events: none;
  padding: 4px 10px; border-radius: 6px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em; color: var(--ink-2);
  background: rgba(7, 7, 10, 0.7); border: 1px solid var(--line);
}
.demo__tf:empty { display: none; }

/* ---------- backtest results ---------- */
.bt { margin-top: clamp(28px, 4vw, 40px); padding-top: clamp(24px, 3vw, 32px); border-top: 1px solid var(--line); }
.bt:empty { display: none; }
.bt__head { display: flex; justify-content: flex-start; align-items: flex-end; gap: 20px 32px; flex-wrap: wrap; margin-bottom: 22px; }
.bt__eyebrow { margin: 0 0 10px; font-size: 10.5px; font-weight: 600; letter-spacing: 0.26em; text-transform: uppercase; color: var(--gold); }
.bt__title { margin: 0; font-variant-numeric: lining-nums; font-family: var(--serif); font-weight: 600; font-size: clamp(24px, 2.4vw, 32px); line-height: 1.05; letter-spacing: -0.03em; }
.bt__title span { font-family: var(--sans); font-size: 13px; font-weight: 500; letter-spacing: 0.02em; color: var(--ink-3); white-space: nowrap; }
.bt__stats { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; }
.bt__stat {
  min-width: 118px; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.02);
}
.bt__stat dt { font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.bt__stat dd { margin: 4px 0 0; font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap; }
.bt__ast { color: var(--gold); }
.demo__foot { margin: 18px 4px 0; font-size: 11.5px; line-height: 1.6; color: var(--ink-3); }
.bt__stat dd small { font-size: 11px; font-weight: 500; color: var(--ink-3); }
.bt__stat--main {
  border-color: rgba(217, 178, 106, 0.4);
  background: linear-gradient(150deg, rgba(217, 178, 106, 0.12), rgba(217, 178, 106, 0.02));
}
.bt__stat--main dd { font-size: 20px; }
.bt .is-up { color: var(--green); }
.bt .is-down { color: var(--red); }

.bt__grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px;
  margin: 0; padding: 0; list-style: none;
}
.bt__cell {
  position: relative; overflow: hidden; padding: 10px 12px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.018);
  display: flex; flex-direction: column; gap: 3px;
}
.bt__cell.is-up { border-color: rgba(57, 217, 138, 0.18); background: rgba(57, 217, 138, 0.04); }
.bt__cell.is-down { border-color: rgba(240, 80, 94, 0.18); background: rgba(240, 80, 94, 0.04); }
.bt__year { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; color: var(--ink-3); }
.bt__cell b { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bt__cell.is-flat b { color: var(--ink-2); }
.bt__cell i {
  position: absolute; left: 0; bottom: 0; height: 2px; width: var(--w); border-radius: 0 2px 2px 0;
  background: currentColor; opacity: 0.8;
}
.bt.is-anim .bt__cell { animation: bt-in 0.6s var(--ease) both; animation-delay: calc(var(--k) * 18ms); }
@keyframes bt-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.bt__note { margin: 16px 2px 0; font-size: 11.5px; line-height: 1.6; color: var(--ink-3); }

@media (max-width: 760px) {
  .demo__frame { border-radius: 18px; }
  .demo__chart { height: 360px; }
  .demo__tab { padding: 0 14px; font-size: 12.5px; }
  .demo__btn { padding: 0 13px; font-size: 12px; }
  .bt__stats { width: 100%; }
  .bt__stat { flex: 1; }
  .bt__grid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
  .bt__cell b { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  .bt.is-anim .bt__cell { animation: none; }
  .demo__frame { transition-duration: 0.01s; }
}
.demo__msg[data-kind="note"] { top: 14px; translate: -50% 0; font-size: 12px; padding: 8px 14px; }

/* screenshot/debug mode (?demo=) */
.debug-demo .hero, .debug-demo .trends { display: none; }
