/* The Trend panel (showcase/chapters/analytics/_trend.html, sa-trend.js), the Trend tab of the Stock Analytics
   chapter on /how-it-works/.
   One app window with two real pages: intrinio_stock/templates/darkpool_chart/stock_movers.html and
   stock_data/seasonal_returns.html. Colours inside the window are the pages' own: --bg-card #1a1a2e, --accent
   #6759d1, --accent-2 #8b5cf6, --text-muted #8892b0, --border rgba(103,89,209,.25) (stock_movers.html:8-18,
   seasonal_returns.html:6-16); the header box and ticker label (stock_movers.html:33-55), the search box and Go
   (:60-97), the heading with its dot, VS badge in --bear and violet ticker (:100-138), the chart card and its
   divider (:141-152), the EMA Cross Lines pill (:240); the heatmap card with the violet title bar
   (seasonal_returns.html:106-137), the tiles (.cube_box :177-204, 48px, radius 8px, bold 12px white), the
   violet month and row label cells (:228-236), "#444" for no value (:486) and the dark hover box (:259-270).
   The panel around the window uses landing.css tokens. Everything is sa-trend-* and scoped under .sa-trend.
   JS state classes (all is-*): on the root is-ready (data drawn), is-nodata, is-paused, is-still (reduced
   motion); on a view is-new (just opened); on a tag or grid row is-wait (not drawn yet); on a grid row is-new
   (just re-shaded); on a grid cell is-hot (the autoplay's hover); on pressed controls is-press; on a search box
   is-typing; on the auto label is-idle / is-stopped. Data attribute on a chart card: data-sa-trend-ema-off.
   Only transform and opacity animate (the chart's clip width is set by the JS loop). Reduced motion (landing.css
   section 13, plus .is-still) and the paused state (.is-paused) stop it all. */

.sa-trend {
  --sa-trend-card: #1a1a2e; --sa-trend-accent: #6759d1; --sa-trend-accent2: #8b5cf6; --sa-trend-muted: #8892b0;
  --sa-trend-border: rgba(103, 89, 209, .25); --sa-trend-bear: #e24e4c; --sa-trend-text: #e2e8f0;
  --sa-trend-bg: #1f2238; --sa-trend-rh: 64px;
  position: relative; min-width: 0;
}
.sa-trend [hidden] { display: none !important; }
html:not(.js) .sa-trend-js, .sa-trend.is-nodata .sa-trend-js { display: none !important; }

/* ---- panel head ---- */
.sa-trend-head { max-width: 72ch; margin: 0 auto var(--lp-sp-5); text-align: center; }
.sa-trend .sa-trend-title { margin: 0; color: var(--lp-text); font: 700 var(--lp-fs-lg)/1.25 var(--lp-font-title); letter-spacing: -.01em; }
.sa-trend .sa-trend-lead { margin: var(--lp-sp-2) 0 0; color: var(--lp-muted); font-size: var(--lp-fs-base); line-height: 1.6; }

/* ---- the window ---- */
.sa-trend-window {
  position: relative; overflow: hidden; min-width: 0;
  border: 1px solid var(--lp-border-strong); border-radius: 16px; background: var(--sa-trend-bg);
  box-shadow: var(--lp-shadow), 0 0 80px color-mix(in srgb, var(--lp-primary) 10%, transparent);
}
.sa-trend-chrome {
  display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 14px;
  background: #0c0a17; border-bottom: 1px solid rgba(255, 255, 255, .07); white-space: nowrap; overflow: hidden;
}
.sa-trend-lights { display: inline-flex; gap: 6px; flex: none; }
.sa-trend-lights i { width: 10px; height: 10px; border-radius: 50%; background: #ff5f57; }
.sa-trend-lights i + i { background: #febc2e; }
.sa-trend-lights i + i + i { background: #28c840; }
.sa-trend-chrome-tab { overflow: hidden; text-overflow: ellipsis; padding: 4px 12px; border-radius: 8px 8px 0 0; background: var(--sa-trend-bg); color: #a7a3c9; font-size: 12px; }
.sa-trend-chrome-tab b { color: #f4f2ff; font-weight: 800; letter-spacing: -.01em; }
.sa-trend-chrome-url { overflow: hidden; text-overflow: ellipsis; color: #8e8ab4; font: 11.5px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.sa-trend-app {
  min-width: 0; color: var(--sa-trend-text); font-size: 13px; line-height: 1.45;
  background: radial-gradient(900px 420px at 92% -10%, rgba(103, 89, 209, .16), transparent 60%), var(--sa-trend-bg);
}
.sa-trend .sa-trend-app p { margin: 0; }

/* green page header, as the other panels */
.sa-trend-pghead {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 18px;
  background: linear-gradient(90deg, #5aae8c, #6dbf9d); color: #fff;
}
.sa-trend .sa-trend-pgname { color: #fff; font: 700 18px/1.2 var(--lp-font-title); letter-spacing: .01em; }
.sa-trend-pghead .lp-tier { --lp-tier-c: #fff; }
.sa-trend-pghead-end { margin-left: auto; }
.sa-trend-pghead .lp-sample { border-color: rgba(255, 255, 255, .7); color: #fff; background: rgba(12, 10, 23, .25); }

/* the two pages, as tabs inside the window */
.sa-trend-switch {
  display: flex; gap: 4px; padding: 8px 18px 0; overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid rgba(139, 125, 232, .16); background: rgba(255, 255, 255, .02);
}
.sa-trend-switch::-webkit-scrollbar { display: none; }
.sa-trend .sa-trend-swbtn {
  flex: none; margin: 0 0 -1px; padding: 8px 14px; border: 1px solid transparent; border-bottom: 0; border-radius: 10px 10px 0 0;
  background: transparent; color: rgba(255, 255, 255, .65); font: 600 12.5px/1.2 var(--lp-font); cursor: pointer; white-space: nowrap;
  transition: background-color .2s var(--lp-ease), color .2s var(--lp-ease);
}
.sa-trend .sa-trend-swbtn[aria-selected="true"] { border-color: rgba(139, 125, 232, .16); background: #292d4a; color: #fff; }
.sa-trend .sa-trend-swbtn:hover:not([aria-selected="true"]) { color: #fff; background: rgba(255, 255, 255, .05); }
.sa-trend .sa-trend-swbtn:focus-visible { outline: 2px solid var(--lp-accent); outline-offset: -2px; }
.sa-trend .sa-trend-swbtn.is-press { background: rgba(103, 89, 209, .35); }

/* ---- the stage: the two pages, one at a time once JS runs (each scrolls inside itself) ---- */
.sa-trend-stage { position: relative; display: flex; flex-direction: column; gap: 26px; min-width: 0; padding: 16px 18px; }
html.js .sa-trend:not(.is-nodata) .sa-trend-stage { height: 760px; padding: 0; }
@media (min-width: 1100px) { html.js .sa-trend:not(.is-nodata) .sa-trend-stage { height: 800px; } }
html.js .sa-trend:not(.is-ready):not(.is-nodata) .sa-trend-view + .sa-trend-view { display: none; }
.sa-trend-view { position: relative; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
html.js .sa-trend:not(.is-nodata) .sa-trend-view {
  height: 100%; padding: 16px 18px; overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: rgba(103, 89, 209, .7) transparent;
}
.sa-trend-view.is-new { animation: sa-trend-in .32s var(--lp-ease) both; }
@keyframes sa-trend-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.sa-trend .sa-trend-poster-l { margin: 4px 0 0; color: #fff; font: 700 15px/1.3 var(--lp-font-title); }
html.js .sa-trend:not(.is-nodata) .sa-trend-poster-l { display: none; }

/* header box / toolbar (.sm-header-box, .heatmap-toolbar) */
.sa-trend-tb {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
  padding: 12px 20px; border: 1px solid var(--sa-trend-border); border-radius: 12px; background: rgba(26, 26, 46, .9);
}
.sa-trend .sa-trend-tk { color: var(--sa-trend-text); font: 800 30px/1.1 var(--lp-font); letter-spacing: .5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sa-trend-sgroup { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; margin: 0; }
.sa-trend .sa-trend-search {
  display: flex; align-items: center; gap: 6px; min-width: 170px; height: 40px; margin: 0; padding: 8px 12px; box-sizing: border-box;
  border: 1px solid var(--sa-trend-border); border-radius: 8px; background: rgba(103, 89, 209, .15); color: var(--sa-trend-muted);
  transition: border-color .2s var(--lp-ease), background-color .2s var(--lp-ease);
}
.sa-trend .sa-trend-search:focus-within, .sa-trend .sa-trend-search.is-typing { border-color: var(--sa-trend-accent); background: rgba(103, 89, 209, .28); }
.sa-trend .sa-trend-search input {
  width: 100%; min-width: 0; margin: 0; padding: 0; border: 0; outline: 0; background: transparent; color: #fff;
  font: 500 13px/1.2 var(--lp-font); text-transform: uppercase; -webkit-appearance: none; appearance: none;
}
.sa-trend .sa-trend-search input::placeholder { color: var(--sa-trend-muted); text-transform: none; }
.sa-trend .sa-trend-search:has(input:focus-visible) { outline: 2px solid var(--lp-accent); outline-offset: 2px; }
.sa-trend .sa-trend-go {
  height: 40px; margin: 0; padding: 0 22px; border: 0; border-radius: 8px; background: var(--sa-trend-accent); color: #fff;
  font: 700 14px/1 var(--lp-font); cursor: pointer; transition: opacity .2s var(--lp-ease), transform .18s var(--lp-ease);
}
.sa-trend .sa-trend-go:hover { opacity: .82; }
.sa-trend .sa-trend-go:focus-visible { outline: 2px solid var(--lp-accent); outline-offset: 2px; }
.sa-trend .sa-trend-go.is-press { transform: scale(.94); }
.sa-trend .sa-trend-msg { padding: 8px 12px; border: 1px solid rgba(167, 139, 250, .45); border-radius: 10px; background: rgba(20, 18, 40, .9); color: #c4b5fd; font-size: 12.5px; }

/* section heading (.sm-section-heading) */
.sa-trend .sa-trend-hd { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; color: #cbd5e1; font: 600 15px/1.35 var(--lp-font); letter-spacing: .01em; }
.sa-trend-hd-dot { flex: none; width: 8px; height: 8px; margin-right: 4px; border-radius: 50%; background: var(--sa-trend-accent); box-shadow: 0 0 8px rgba(103, 89, 209, .7); }
.sa-trend-vs {
  display: inline-block; padding: 1px 6px; border: 1px solid rgba(226, 78, 76, .25); border-radius: 4px; background: rgba(226, 78, 76, .12);
  color: var(--sa-trend-bear); font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
}
.sa-trend-hd-tk { color: var(--sa-trend-accent2); font-weight: 700; }

/* chart card (.sm-chart-card) */
.sa-trend-card {
  position: relative; min-width: 0; padding: 16px 18px 12px; border: 1px solid var(--sa-trend-border); border-radius: 16px;
  background: var(--sa-trend-card); box-shadow: 0 8px 32px rgba(0, 0, 0, .4);
}
.sa-trend-card-top { display: flex; justify-content: flex-end; margin-bottom: 6px; }
.sa-trend .sa-trend-ema {
  display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 4px 10px; border-radius: 20px; background: rgba(255, 255, 255, .08);
  color: #fff; font: 600 11px/1.3 var(--lp-font); cursor: pointer; transition: transform .18s var(--lp-ease);
}
.sa-trend .sa-trend-ema input { width: 13px; height: 13px; margin: 0; accent-color: var(--sa-trend-accent); cursor: pointer; }
.sa-trend .sa-trend-ema input:focus-visible { outline: 2px solid var(--lp-accent); outline-offset: 2px; }
.sa-trend .sa-trend-ema.is-press { transform: scale(.94); }
.sa-trend .sa-trend-divider { margin: 10px 0; border: 0; border-top: 1px solid rgba(103, 89, 209, .15); }
.sa-trend-chart { position: relative; min-width: 0; max-width: 1060px; margin: 0 auto; }
.sa-trend-svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.sa-trend-grid { stroke: rgba(255, 255, 255, .2); stroke-width: 1; }
.sa-trend-ax { fill: #fff; font: 12px/1 var(--lp-font); font-variant-numeric: tabular-nums; }
.sa-trend-ax--y { text-anchor: end; }
.sa-trend-ax--x, .sa-trend-ax--t { text-anchor: middle; }
.sa-trend-ax--t { font-size: 12.5px; }
.sa-trend-leg text { fill: #fff; font: 12px/1 var(--lp-font); }
.sa-trend-wm { fill: rgba(211, 211, 211, .2); font: 18px/1 Arial, sans-serif; text-anchor: middle; pointer-events: none; }
.sa-trend-band { stroke: none; }
.sa-trend-ln { fill: none; stroke-linejoin: round; stroke-linecap: round; }
.sa-trend-ln--e { stroke-width: 2; }
.sa-trend-ln--p { stroke: #fff; stroke-width: 2.2; }
.sa-trend-tag text { fill: #fff; font: 700 10.5px/1 var(--lp-font); text-anchor: middle; }
.sa-trend-tag { transform-box: fill-box; transform-origin: center; transition: opacity .28s var(--lp-ease); }
.sa-trend-tag.is-wait { opacity: 0; }
html.js .sa-trend:not(.is-still) .sa-trend-tag:not(.is-wait) { animation: sa-trend-pop .36s var(--lp-ease) both; }
@keyframes sa-trend-pop { from { opacity: 0; transform: scale(.7); } to { opacity: 1; transform: none; } }
.sa-trend-card[data-sa-trend-ema-off] .sa-trend-tags { display: none; }
.sa-trend-hov line { stroke: rgba(255, 255, 255, .35); stroke-width: 1; }
.sa-trend-hov circle { stroke: #fff; stroke-width: 1.5; }

/* the hover box (Chart.js tooltip on the charts, #tooltip on the grid) */
.sa-trend-tip {
  position: absolute; z-index: 4; top: 8px; min-width: 150px; padding: 7px 10px; border-radius: 6px; pointer-events: none;
  background: rgba(0, 0, 0, .85); color: #fff; font: 12px/1.45 var(--lp-font); font-variant-numeric: tabular-nums; white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
}
.sa-trend-tip b { display: block; margin-bottom: 2px; font-weight: 700; }
.sa-trend-tip i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px; border: 1px solid rgba(255, 255, 255, .6); }

/* ---- Seasonal Returns: the heatmap card and the grid (.heatmap-card, .cube_box) ---- */
.sa-trend-scard {
  position: relative; min-width: 0; padding: 18px 18px 12px; border: 1px solid var(--sa-trend-border); border-radius: 16px;
  background: var(--sa-trend-card); box-shadow: 0 8px 32px rgba(0, 0, 0, .4);
}
.sa-trend .sa-trend-scard-h { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; color: var(--sa-trend-text); font: 700 18px/1.25 var(--lp-font); }
.sa-trend-scard-h::before { content: ""; flex: none; width: 4px; height: 22px; border-radius: 2px; background: linear-gradient(180deg, var(--sa-trend-accent), var(--sa-trend-accent2)); }
.sa-trend .sa-trend-sum-line { margin: -4px 0 12px; color: var(--sa-trend-muted); font-size: 13px; }
.sa-trend-sq { display: inline-block; width: 11px; height: 11px; margin: 0 6px 0 2px; border-radius: 2px; vertical-align: -1px; background: var(--sa-trend-bear); }
.sa-trend-sq--up { margin-left: 12px; background: #4cd68f; }
.sa-trend-sea-wrap {
  position: relative; min-width: 0; overflow-x: auto; padding-bottom: 6px;
  scrollbar-width: thin; scrollbar-color: rgba(103, 89, 209, .7) transparent;
}
.sa-trend-sea-wrap:focus-visible { outline: 2px solid var(--lp-accent); outline-offset: 2px; border-radius: 8px; }
.sa-trend .sa-trend-sea { width: 100%; min-width: 960px; margin: 0; border-collapse: separate; border-spacing: 5px; table-layout: fixed; font-variant-numeric: tabular-nums; }
.sa-trend .sa-trend-sea--sum { min-width: 980px; }
.sa-trend .sa-trend-sea th, .sa-trend .sa-trend-sea td { padding: 0 4px; border: 0; text-align: center; white-space: nowrap; }
.sa-trend .sa-trend-sea-mh, .sa-trend .sa-trend-sea-rh, .sa-trend .sa-trend-sea-corner {
  height: 36px; border: 1px solid rgba(103, 89, 209, .45); border-radius: 8px; color: #fff; font: 700 11px/1.2 var(--lp-font);
  background: linear-gradient(135deg, rgba(103, 89, 209, .4) 0%, rgba(139, 92, 246, .25) 100%), var(--sa-trend-card);
}
.sa-trend .sa-trend-sea-rh, .sa-trend .sa-trend-sea-corner { position: sticky; left: 0; z-index: 2; width: var(--sa-trend-rh); box-shadow: -6px 0 0 var(--sa-trend-card); }
.sa-trend .sa-trend-sea-rh { height: 48px; }
.sa-trend .sa-trend-sea-rh--wide { width: 150px; white-space: normal; }
.sa-trend .sa-trend-sea-cell {
  position: relative; height: 48px; border: 1px solid rgba(255, 255, 255, .05); border-radius: 8px; color: #fff; font: 700 12px/1.2 var(--lp-font);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25); transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background-color .3s ease, opacity .28s var(--lp-ease);
}
.sa-trend .sa-trend-sea-cell:hover, .sa-trend .sa-trend-sea-cell.is-hot { z-index: 1; transform: scale(1.08); border-color: rgba(255, 255, 255, .25); box-shadow: 0 6px 20px rgba(0, 0, 0, .4); }
.sa-trend .sa-trend-sea-row.is-wait > td { opacity: 0; }
.sa-trend .sa-trend-sea-row.is-new > td::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; background: rgba(255, 255, 255, .28);
  animation: sa-trend-flash 1s ease-out both;
}
@keyframes sa-trend-flash { from { opacity: 1; } to { opacity: 0; } }
.sa-trend-tip--sea { top: 0; left: 0; }

/* ---- the readout: what the demo shows now ---- */
.sa-trend .sa-trend-readout {
  display: flex; align-items: flex-start; gap: 10px; min-height: 60px; margin: 0; padding: 11px 18px 13px;
  border-top: 1px solid rgba(139, 125, 232, .16); background: rgba(103, 89, 209, .1); color: #fff; font-size: 13px; line-height: 1.5;
}
.sa-trend-readout-dot { flex: none; width: 9px; height: 9px; margin-top: 6px; border-radius: 50%; background: var(--lp-accent); }

/* ---- controls under the window (as the other panels) ---- */
.sa-trend-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); }
.sa-trend-play { display: flex; flex-wrap: wrap; align-items: center; gap: var(--lp-sp-2); }
.sa-trend-auto {
  position: relative; display: inline-flex; align-items: center; gap: var(--lp-sp-2); min-height: 38px; padding: 0 var(--lp-sp-3);
  border: 1px solid var(--lp-border); border-radius: var(--lp-r-sm); background: var(--lp-surface-2);
  color: var(--lp-muted); font-size: var(--lp-fs-xs); font-weight: 600;
}
.sa-trend-auto-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--lp-green); }
.sa-trend-auto.is-idle .sa-trend-auto-dot, .sa-trend-auto.is-stopped .sa-trend-auto-dot { background: var(--lp-amber); }
.sa-trend-auto-bar { position: absolute; left: 12px; right: 12px; bottom: 5px; height: 2px; overflow: hidden; border-radius: 2px; background: color-mix(in srgb, var(--lp-text) 10%, transparent); }
.sa-trend-auto-bar i { display: block; height: 100%; background: var(--lp-primary); transform-origin: 0 50%; transform: scaleX(0); }
.sa-trend-auto.is-idle .sa-trend-auto-bar i, .sa-trend-auto.is-stopped .sa-trend-auto-bar i { background: var(--lp-amber); }
.sa-trend-ico-play, .sa-trend.is-paused .sa-trend-ico-pause { display: none; }
.sa-trend.is-paused .sa-trend-ico-play { display: inline; }
.sa-trend .sa-trend-sample-note { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--lp-sp-2); margin: 0; color: var(--lp-muted); font-size: var(--lp-fs-xs); }
.sa-trend.is-still .sa-trend-play { display: none; }

/* ---- motion off ---- */
.sa-trend.is-paused *, .sa-trend.is-paused *::before, .sa-trend.is-paused *::after { animation-play-state: paused !important; }
.sa-trend.is-still *, .sa-trend.is-still *::before, .sa-trend.is-still *::after { animation: none !important; transition: none !important; }

/* ---- smaller screens ---- */
@media (max-width: 640px) {
  .sa-trend { --sa-trend-rh: 54px; }
  .sa-trend-chrome-url { display: none; }
  .sa-trend-pghead { padding: 10px 12px; }
  .sa-trend .sa-trend-pgname { font-size: 16px; }
  .sa-trend-switch { padding: 6px 10px 0; }
  .sa-trend .sa-trend-swbtn { padding: 8px 11px; font-size: 12px; }
  .sa-trend-stage { padding: 12px; gap: 18px; }
  html.js .sa-trend:not(.is-nodata) .sa-trend-stage { height: 620px; }
  html.js .sa-trend:not(.is-nodata) .sa-trend-view { padding: 12px; gap: 10px; }
  .sa-trend-tb { padding: 10px 12px; }
  .sa-trend .sa-trend-tk { font-size: 22px; }
  .sa-trend-sgroup { flex: 1 1 100%; flex-wrap: nowrap; }
  .sa-trend .sa-trend-search { flex: 1 1 auto; min-width: 0; }
  .sa-trend .sa-trend-hd { font-size: 13.5px; }
  .sa-trend-card { padding: 10px 8px 8px; }
  .sa-trend-ax { font-size: 15px; }
  .sa-trend-ax--x { font-size: 14px; }
  .sa-trend-tag text { font-size: 10.5px; }
  .sa-trend-scard { padding: 14px 10px 10px; }
  .sa-trend .sa-trend-scard-h { font-size: 16px; }
  .sa-trend .sa-trend-sea { min-width: 860px; border-spacing: 4px; }
  .sa-trend .sa-trend-sea-cell, .sa-trend .sa-trend-sea-rh { height: 42px; }
  .sa-trend .sa-trend-sea-rh--wide { width: 120px; }
  .sa-trend .sa-trend-readout { min-height: 84px; padding: 10px 12px 12px; font-size: 12.5px; }
  .sa-trend-controls { justify-content: center; }
  .sa-trend .sa-trend-sample-note { justify-content: center; text-align: center; }
}
