/* The Net Flow chapter (showcase/chapters/_netflow.html, netflow-demo.js) on /how-it-works/ (#netflow).
   Tabs over one app frame that renders the real Net Flow / 0DTE / Weekly DTE / 7 DTE pages as a clean
   card stack. Colours, radii and type come from the real page (intrinio_options/templates/intrinio/
   netflow-redis.html: tokens :13-19, top bar :36-98, cards :100-160, Replay button :175-188); the
   section around it uses landing.css, and the tab bar matches the Regimes chapter's (regimes.css).
   Everything is nfd-* and scoped under .nfd so it beats landing.css's element reset. JS state classes
   on the section: is-ready (data drawn), is-nodata, is-auto (autoplay running), is-held (visitor input),
   is-paused (Pause pressed), is-still (reduced motion), is-cvd-off (a tab without the CVD card).
   Only opacity and transform animate, and nothing does under reduced motion. */

.nfd {
  --nfd-bg: #16162a; --nfd-card: #1e1e30; --nfd-card2: #252540;
  --nfd-border: rgba(103, 89, 209, .18); --nfd-border-h: rgba(103, 89, 209, .4);
  --nfd-accent: #6759d1; --nfd-accent-2: #7c6fe0;
  --nfd-text: #e2e2f0; --nfd-muted: #8888aa; --nfd-soft: #b4b4d0; --nfd-legend: #c8c8e8;
  --nfd-call: rgb(51, 184, 144); --nfd-put: rgb(236, 75, 94);
  --nfd-up: #4CD68F; --nfd-down: #E24E4C; --nfd-cvd: #a99cf5;
}

/* Without JS, before the data is drawn, or if it fails: the poster shows and the app stays hidden. */
.nfd:not(.is-ready) .nfd-js { display: none !important; }
.nfd.is-ready .nfd-poster { display: none; }

.nfd .nfd-sample {
  display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--lp-sp-2);
  color: var(--lp-muted); font-size: var(--lp-fs-xs);
}

/* ---- tabs (as regimes.css) ---- */
.nfd-tabs-wrap { display: flex; justify-content: center; margin: 0 0 var(--lp-sp-4); }
.nfd-tabs {
  position: relative; display: flex; gap: var(--lp-sp-2);
  padding: var(--lp-sp-1); width: fit-content; max-width: 100%;
  border: 1px solid var(--lp-border); border-radius: var(--lp-r-pill); background: var(--lp-surface-2);
}
.nfd .nfd-tab {
  position: relative; flex: 0 0 auto; display: inline-flex; align-items: center; gap: var(--lp-sp-2);
  min-height: 40px; padding: 0 var(--lp-sp-4); overflow: hidden;
  border: 1px solid transparent; border-radius: var(--lp-r-pill); background: none; cursor: pointer;
  color: var(--lp-muted); font: 600 var(--lp-fs-sm)/1.2 var(--lp-font); white-space: nowrap;
}
.nfd .nfd-tab:hover { color: var(--lp-text); }
.nfd .nfd-tab[aria-selected="true"] {
  color: var(--lp-text); border-color: var(--lp-primary);
  background: color-mix(in srgb, var(--lp-primary) 24%, transparent);
}
.nfd .nfd-tab:focus-visible { outline: 2px solid var(--lp-accent); outline-offset: 2px; }
/* How far the active tab is through its stream and hold (set per frame by netflow-demo.js).
   Full strength while the autoplay runs, dimmed while it waits for the visitor. */
.nfd-tab-prog {
  position: absolute; left: var(--lp-sp-4); right: var(--lp-sp-4); bottom: 4px; height: 2px;
  overflow: hidden; border-radius: 2px; background: color-mix(in srgb, var(--lp-accent) 18%, transparent);
  opacity: 0; transition: opacity .2s var(--lp-ease); pointer-events: none;
}
.nfd-tab-prog i {
  position: absolute; inset: 0; border-radius: inherit; background: var(--lp-accent);
  transform: scaleX(0); transform-origin: 0 50%;
}
.nfd .nfd-tab[aria-selected="true"] .nfd-tab-prog { opacity: .4; }
.nfd.is-auto .nfd-tab[aria-selected="true"] .nfd-tab-prog { opacity: 1; }
.nfd.is-still .nfd-tab-prog { display: none; }

/* ---- the app frame ---- */
.nfd-frame {
  position: relative; padding: 18px;
  border: 1px solid var(--lp-border-strong); border-radius: var(--lp-r-lg); background: var(--nfd-bg);
  box-shadow: var(--lp-shadow), 0 0 80px color-mix(in srgb, var(--lp-primary) 10%, transparent);
  color: var(--nfd-text);
}
.nfd-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 10px; }
.nfd .nfd-ticker {
  display: flex; align-items: baseline; gap: 8px; margin: 0;
  color: var(--nfd-text); font: 700 1.5rem/1.2 var(--lp-font); letter-spacing: .5px;
}
.nfd-price { font-variant-numeric: tabular-nums; }
.nfd-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.nfd-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 14px;
  border: 1px solid var(--nfd-border); border-radius: 999px; background: rgba(103, 89, 209, .12);
  color: var(--nfd-text); font: 500 12px/1.2 var(--lp-font); white-space: nowrap;
}
.nfd-pill--select { background: var(--nfd-card2); }
.nfd-pill svg { flex: none; color: var(--nfd-muted); }
.nfd-search {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 4px 4px 14px;
  border: 1px solid var(--nfd-border); border-radius: 999px; background: var(--nfd-card2); color: var(--nfd-muted);
}
.nfd-search svg { flex: none; }
.nfd-search-ph { min-width: 112px; font: 600 11px/1.2 var(--lp-font); letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.nfd-go { padding: 5px 16px; border-radius: 999px; background: var(--nfd-accent); color: #fff; font: 600 13px/1.2 var(--lp-font); }
.nfd-replay {
  display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); color: #fff;
  box-shadow: 0 4px 16px rgba(245, 158, 11, .4);
}
.nfd .nfd-caption {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 0 0 14px;
  color: var(--nfd-soft); font-size: 13px; line-height: 1.5;
}
.nfd-scope {
  padding: 2px 10px; border: 1px solid rgba(103, 89, 209, .45); border-radius: 999px;
  background: rgba(103, 89, 209, .16); color: #d4ceff; font-size: 12px; font-weight: 600; white-space: nowrap;
}

/* ---- cards ---- */
.nfd-card {
  min-width: 0; padding: 14px 16px;
  border: 1px solid var(--nfd-border); border-radius: 14px; background: var(--nfd-card);
  transition: border-color .2s;
}
.nfd-card:hover { border-color: var(--nfd-border-h); }
.nfd-card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin: 0 0 8px; }
.nfd .nfd-card-title { margin: 0; color: var(--nfd-text); font: 600 14px/1.3 var(--lp-font); letter-spacing: .3px; }
.nfd-card-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.nfd .nfd-legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin: 0 0 6px;
  color: var(--nfd-legend); font-size: 12px; line-height: 1.5;
}
.nfd-lg { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.nfd-lg i { flex: none; width: 22px; height: 3px; border-radius: 2px; background: #fff; }
.nfd-lg--call i { background: var(--nfd-call); }
.nfd-lg--put i { background: var(--nfd-put); }
.nfd-lg--buy i { background: var(--nfd-up); }
.nfd-lg--sell i { background: var(--nfd-down); }
.nfd-axes-note { margin-left: auto; color: var(--nfd-muted); font-size: 11px; }
.nfd-val { color: var(--nfd-legend); font: 600 12px/1.3 var(--lp-font); font-variant-numeric: tabular-nums; white-space: nowrap; }
.nfd-card--vol .nfd-val { color: var(--nfd-up); }
.nfd-card--vol .nfd-val.is-down { color: var(--nfd-down); }
.nfd-card--cvd .nfd-val { color: var(--nfd-cvd); }
.nfd .nfd-check {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 20px;
  background: rgba(255, 255, 255, .08); color: #fff; font: 500 11px/1.3 var(--lp-font); cursor: pointer;
}
.nfd .nfd-check input { width: 14px; height: 14px; margin: 0; accent-color: var(--nfd-accent); cursor: pointer; }
.nfd .nfd-check input:focus-visible { outline: 2px solid var(--lp-accent); outline-offset: 2px; }

/* ---- chart stages ---- */
.nfd-stage { position: relative; touch-action: pan-y; }
.nfd-stage canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.nfd .nfd-stage canvas:focus-visible { outline: 2px solid var(--lp-accent); outline-offset: 2px; border-radius: 6px; }
.nfd-stage--main { height: 400px; }
.nfd-stage--sm { height: 170px; }
.nfd-stage--pat { height: 240px; }

/* The crosshair readout on the main graph (netflow-redis.html tooltip colours :1459-1462). */
.nfd-tip {
  position: absolute; top: 0; left: 0; z-index: 2; min-width: 210px; padding: 8px 10px;
  border: 1px solid rgba(103, 89, 209, .3); border-radius: 8px; background: rgba(18, 18, 30, .95);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  color: var(--nfd-text); font: 500 12px/1.5 var(--lp-font);
  opacity: 0; transition: opacity .12s; pointer-events: none;
}
.nfd-stage.is-hover .nfd-tip { opacity: 1; }
.nfd-tip b { display: block; margin: 0 0 2px; color: #9999bb; font-weight: 600; }
.nfd-tip-row { display: flex; align-items: center; gap: 6px; }
.nfd-tip-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; }
.nfd-tip-dot--gap { background: linear-gradient(90deg, var(--nfd-call) 50%, var(--nfd-put) 50%); }
.nfd-tip-k { color: var(--nfd-soft); }
.nfd-tip-v { margin-left: auto; padding-left: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* What you're seeing: one line describing the point under the crosshair (or the playhead). */
.nfd .nfd-read {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; min-height: 2.6em;
  margin: 10px 0 0; padding: 10px 0 0; border-top: 1px solid rgba(255, 255, 255, .06);
  color: var(--nfd-text); font-size: 13px; line-height: 1.5; font-variant-numeric: tabular-nums;
}
.nfd-read-k { color: var(--nfd-muted); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }

/* ---- the card grid ---- */
.nfd-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.nfd-card--pat { grid-column: 1 / -1; }
.nfd.is-cvd-off .nfd-card--vol { grid-column: 1 / -1; }

/* ---- autoplay controls ---- */
.nfd-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--lp-sp-3) var(--lp-sp-5); margin-top: var(--lp-sp-4); }
.nfd-play { display: flex; gap: var(--lp-sp-2); }
.nfd-ico-play, .nfd.is-paused .nfd-ico-pause { display: none; }
.nfd.is-paused .nfd-ico-play { display: inline; }
.nfd.is-still .nfd-play { display: none; }
.nfd .nfd-hint { margin: 0; color: var(--lp-muted); font-size: var(--lp-fs-xs); }

/* ---- the poster (no JS, or no data) ---- */
.nfd .nfd-poster { margin: 0; }
.nfd-poster-card { padding: 14px 16px; border: 1px solid var(--nfd-border); border-radius: var(--lp-r-lg); background: var(--nfd-card); }
.nfd .nfd-poster-title { margin: 0 0 6px; color: var(--nfd-text); font: 600 14px/1.3 var(--lp-font); }
.nfd-poster-svg { display: block; width: 100%; height: auto; }
.nfd-p-grid { stroke: rgba(255, 255, 255, .07); stroke-width: 1; }
.nfd-p-t { fill: rgba(255, 255, 255, .86); font: 500 11px var(--lp-font); }
.nfd-p-band-c { fill: rgba(51, 184, 144, .16); }
.nfd-p-band-p { fill: rgba(236, 75, 94, .16); }
.nfd-p-call, .nfd-p-put, .nfd-p-px { fill: none; stroke-linejoin: round; }
.nfd-p-call { stroke: var(--nfd-call); stroke-width: 2; }
.nfd-p-put { stroke: var(--nfd-put); stroke-width: 2; }
.nfd-p-px { stroke: #fff; stroke-width: 1.5; }
.nfd-p-wm { fill: rgba(211, 211, 211, .13); font: 600 22px var(--lp-font); }
.nfd .nfd-poster-cap {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--lp-sp-2);
  margin-top: var(--lp-sp-3); color: var(--lp-muted); font-size: var(--lp-fs-xs); text-align: center;
}

/* ---- CTAs ---- */
.nfd-foot { display: flex; flex-direction: column; align-items: center; gap: var(--lp-sp-4); margin-top: var(--lp-sp-6); text-align: center; }
.nfd-ctas { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--lp-sp-3); }
.nfd .nfd-foot-note { max-width: 62ch; margin: 0; color: var(--lp-muted); font-size: var(--lp-fs-sm); }
.nfd .nfd-foot-note a { color: var(--lp-accent); font-weight: 600; }
.nfd .nfd-foot-note a:hover { color: var(--lp-text); text-decoration: underline; }

/* ---- reduced motion: no progress bar, no fades (netflow-demo.js does not stream or rotate) ---- */
@media (prefers-reduced-motion: reduce) {
  .nfd-tab-prog { display: none !important; }
  .nfd-tip, .nfd-card, .nfd .nfd-tab, .nfd-tab-prog { transition: none !important; }
}

/* ---- narrower screens ---- */
@media (max-width: 860px) {
  .nfd-grid { grid-template-columns: minmax(0, 1fr); }
  .nfd-card--pat, .nfd.is-cvd-off .nfd-card--vol { grid-column: auto; }
}
@media (max-width: 767px) {
  .nfd-stage--main { height: 320px; }
  .nfd-top { flex-direction: column; align-items: flex-start; }
  .nfd-tools { width: 100%; }
  .nfd-search { flex: 1; min-width: 0; }
  .nfd-search-ph { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .nfd-axes-note { width: 100%; margin-left: 0; }
  .nfd-controls { justify-content: center; }
  .nfd .nfd-hint { text-align: center; }
}
/* phones: the tab bar scrolls sideways inside the 16px gutters (as regimes.css) */
@media (max-width: 640px) {
  .nfd-tabs-wrap { justify-content: flex-start; }
  .nfd-tabs {
    width: auto; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
    -webkit-overflow-scrolling: touch; border-radius: var(--lp-r);
  }
  .nfd-tabs::-webkit-scrollbar { display: none; }
  .nfd .nfd-tab { padding: 0 var(--lp-sp-3); }
  .nfd-tab-prog { left: var(--lp-sp-3); right: var(--lp-sp-3); }
}
@media (max-width: 575px) {
  .nfd-frame { padding: 12px 10px; border-radius: var(--lp-r); }
  .nfd-card, .nfd-poster-card { padding: 12px 10px 10px; border-radius: 10px; }
  .nfd .nfd-ticker { font-size: 1.2rem; }
  .nfd-card-tools { gap: 6px; }
  .nfd-card-tools .nfd-pill { padding: 4px 10px; font-size: 11px; }
  .nfd-stage--main { height: 270px; }
  .nfd-stage--sm { height: 150px; }
  .nfd-stage--pat { height: 210px; }
  .nfd-tip { min-width: 176px; padding: 6px 8px; font-size: 11px; }
  .nfd-tip-v { padding-left: 8px; }
}
@media (max-width: 479.98px) {
  .nfd-ctas, .nfd-ctas .lp-btn { width: 100%; }
}
