/* =========================================================================
   TradeKit Marketing — the blog's chart demos

   The framed screens the demo shortcode prints into a post
   ({% demo "breakout" %}, eleventy.config.js) and js/blog-demos.js plays:
   a trigger order on a little candlestick chart, drawn the way the app's
   chart draws it. post.njk links this file on posts that have a demo, and
   the homepage for its trigger-orders reel (at the end: the homepage's
   chart demo, then these, in one screen).

   The frame is the homepage's .tk-screen at the blog's volume: an ink
   border, a HUD bar, the category's plate. It runs the article column's
   full width, like the cover, rather than the text's measure. Inside,
   every color is a palette role, so every theme re-inks the chart live,
   and sizes are px: the chart draws at its real size, its type at the
   chart's 10px (11px on a wide screen: --bd-fs, set by the script, with
   --bd-chip-h).
   ========================================================================= */

/* The column the demos span (and size themselves by). */
.blog-article__body > .blog-article__main {
  container-type: inline-size;
}

.blog-prose .blog-demo {
  position: relative;
  width: min(60rem, 100cqi);
  margin: 1.9em 0 calc(1.9em + 0.6rem);
  border: 1px solid var(--ink);
  background: var(--paper-2);
  box-shadow: 0.6rem 0.6rem 0 0 var(--cat, var(--ink-1));
  line-height: 1;
}

/* The HUD bar: the drawing // its order's state, and the market. */
.blog-demo__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 2.2rem;
  padding-inline: 0.8rem;
  border-bottom: 1px solid var(--ink);
  background: var(--paper);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
}

.blog-demo__title {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.blog-demo__state.is-filled {
  color: var(--success);
}

.blog-demo__market {
  color: var(--ink-soft);
}

.blog-demo__body {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: var(--bd-fs, 10px);
  -webkit-user-select: none;
  user-select: none;
}

/* The RSI's pane needs the room. */
[data-blog-demo='rsi'] .blog-demo__body {
  aspect-ratio: 16 / 10;
}

@media (max-width: 640px) {
  .blog-demo__body {
    aspect-ratio: 4 / 3;
  }

  [data-blog-demo='rsi'] .blog-demo__body {
    aspect-ratio: 1 / 1;
  }
}

/* The narrowest phones keep the bar's state and drop the market. */
@media (max-width: 360px) {
  .blog-demo__market {
    display: none;
  }
}

/* ----- The chart (SVG) ----- */
.bd-svg {
  position: absolute;
  inset: 0;
  display: block;
  overflow: hidden;
}

.bd-grid line {
  stroke: var(--border);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.bd-grid line.bd-rule {
  stroke: var(--rule-soft);
}

.bd-axis {
  fill: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: var(--bd-fs, 10px);
  font-variant-numeric: tabular-nums;
}

.bd-pane {
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.bd-candles rect {
  shape-rendering: crispEdges;
}

.bd-up {
  fill: var(--success);
}

.bd-down {
  fill: var(--danger);
}

/* An armed line: the marching candy-cane band. Filled: solid go-green. */
.bd-stripes {
  fill: var(--ink);
}

.bd-solid {
  fill: none;
  stroke: var(--ink-6);
  stroke-width: 6;
}

/* The order's triangle on a diagonal or spline: hollow while it rests. */
.bd-icon {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.5;
  stroke-linejoin: miter;
}

.bd-icon.is-done {
  fill: var(--ink);
}

.bd-rsi {
  fill: none;
  stroke: var(--ink-7);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

/* A fill's marker: the chart's ink triangle, outlined in the chart's
   paper, in its dotted ring. */
.bd-mark__tri {
  fill: var(--ink);
  stroke: var(--paper-2);
  stroke-width: 1;
}

.bd-mark__ring {
  fill: none;
  stroke: var(--ink-soft);
  stroke-width: 1;
  stroke-dasharray: 2 2;
}

/* The hero's ripple rings, where the line was touched. */
.bd-ring {
  fill: none;
  stroke: var(--ink-6);
  stroke-width: 2;
}

/* ----- Chips, tags and labels (DOM, over the chart) ----- */
.bd-chips {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.bd-chip {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  align-items: center;
  height: var(--bd-chip-h, 16px);
  padding-inline: 6px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.bd-chip--probe {
  visibility: hidden;
}

.bd-chip--axis {
  justify-content: center;
  padding-inline: 0;
  letter-spacing: 0;
}

/* The app's quiet separator between a tag's state and its order. */
.bd-tag .tk-sep {
  padding-inline: 0.45em;
  color: inherit;
  opacity: 0.55;
}

/* Filled, a horizontal line's tag and chip go green with it; the live
   price chips are green or red with their candle; the RSI's is its ink. */
.bd-chip.is-filled,
.bd-chip--live.is-up {
  --fill: var(--ink-6);
}

.bd-chip--live.is-down {
  --fill: var(--ink-4);
}

.bd-chip--rsi {
  --fill: var(--ink-7);
}

.bd-chip.is-filled,
.bd-chip--live,
.bd-chip--rsi {
  background-color: var(--fill);
  color: var(--on-ink);
  color: oklch(from var(--fill) clamp(0, calc((0.6 - l) * 100000), 1) 0 0);
}

/* What filled: the chart's ruled panel (a rule hairline over a hard
   plate). */
.bd-label {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 1;
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 5px 7px;
  border: 1px solid var(--rule);
  background: var(--paper-2);
  box-shadow: 3px 3px 0 0 var(--rule);
  color: var(--ink);
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.bd-label b {
  font-weight: 700;
}

.bd-label .is-up {
  color: var(--success);
}

.bd-label .is-down {
  color: var(--danger);
}

/* The mock pointer (the homepage demos'): a translucent ink dot. */
.bd-cursor {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border: 1.5px solid color-mix(in srgb, var(--ink) 60%, transparent);
  border-radius: 50%;
  background: color-mix(in srgb, var(--ink) 22%, transparent);
  opacity: 0;
  pointer-events: none;
}

/* =========================================================================
   A reel ([data-demo-reel]): one .tk-screen playing its demos in turn —
   the homepage's trigger orders (index.njk) — its items stacked in the
   screen, one showing at a time, and their captions in its bar. The GSAP
   chart demo fades as a layer; these demos fade their own chart.
   ========================================================================= */
[data-demo-reel] [data-reel-item] {
  position: absolute;
  inset: 0;
  aspect-ratio: auto;
  visibility: hidden;
}

[data-demo-reel] [data-reel-item].is-on {
  visibility: visible;
}

[data-demo-reel] .demo[data-reel-item] {
  opacity: 0;
  transition: opacity 0.4s ease, visibility 0s linear 0.4s;
}

[data-demo-reel] .demo[data-reel-item].is-on {
  opacity: 1;
  transition: opacity 0.4s ease;
}

.tk-screen__bar > .demo-reel__cap {
  display: none;
  flex: 1;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-width: 0;
}

.tk-screen__bar > .demo-reel__cap.is-on {
  display: flex;
}

.demo-reel__cap > span {
  display: inline-flex;
  align-items: center;
}

/* The screen's caption sets the market in ink, as the chart demo's does. */
.demo-reel__cap .blog-demo__market {
  color: inherit;
}
