/* The Stocks Data chapter's shell (showcase/chapters/_stocks.html, stocks.js) on /how-it-works/
   (#stocks): the tab bar, the tabpanels and the CTAs. Each panel has its own stylesheet
   (sd-dashboard.css, sd-movers.css, sd-volume.css); nothing here styles a panel. Same pattern as the Shorts
   shell (shorts.css) without its switch: three tabs that sit on one row, centred on wide screens,
   scrolling sideways inside the gutters below 640px (stocks.js keeps the active tab in sight).
   Everything is sd-* and scoped under .sd so it beats landing.css's element reset. Only transform and
   opacity animate, and nothing does under reduced motion. */

.sd-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: hidden until stocks.js runs (without it the three panels show stacked) ---- */
.sd-tabs-wrap { display: none; }
.sd.is-ready .sd-tabs-wrap { display: flex; justify-content: center; min-width: 0; margin: 0 0 var(--lp-sp-4); }
.sd-tabs {
  position: relative; display: flex; flex-wrap: nowrap; justify-content: center; gap: var(--lp-sp-2);
  padding: var(--lp-sp-1); width: fit-content; max-width: 100%; min-width: 0;
  border: 1px solid var(--lp-border); border-radius: var(--lp-r); background: var(--lp-surface-2);
}
.sd .sd-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;
}
.sd .sd-tab:hover { color: var(--lp-text); }
.sd .sd-tab[aria-selected="true"] {
  color: var(--lp-text); border-color: var(--lp-primary);
  background: color-mix(in srgb, var(--lp-primary) 24%, transparent);
}
.sd .sd-tab:focus-visible { outline: 2px solid var(--lp-accent); outline-offset: -2px; }
.sd-tab-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--lp-g-flow); }
.sd-tab-dot--dashboard { background: var(--lp-g-flow); }  /* violet */
.sd-tab-dot--movers { background: var(--lp-green); }      /* green */
.sd-tab-dot--volume { background: var(--lp-amber); }      /* amber */

/* The auto-rotation cue: a thin bar along the bottom of the active tab, shown only while the tabs will
   move on by themselves (.is-rotating, set by stocks.js). Panels say when they are done, so it sweeps
   instead of filling. */
.sd-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;
}
.sd-tab-prog i {
  position: absolute; inset: 0; width: 40%; border-radius: inherit; background: var(--lp-accent);
  transform: translateX(-100%);
}
.sd.is-rotating .sd-tab[aria-selected="true"] .sd-tab-prog { opacity: 1; }
.sd.is-rotating .sd-tab[aria-selected="true"] .sd-tab-prog i { animation: sd-sweep 1.8s var(--lp-ease) infinite; }
@keyframes sd-sweep { from { transform: translateX(-100%); } to { transform: translateX(250%); } }

/* ---- panels ---- */
.sd-panels { display: flex; flex-direction: column; gap: var(--lp-sp-7); }
.sd.is-ready .sd-panels { display: block; }
.sd .sd-panel { min-width: 0; }
.sd .sd-panel[hidden] { display: none !important; }
.sd .sd-panel-label {
  display: flex; align-items: center; gap: var(--lp-sp-2); margin: 0 0 var(--lp-sp-3);
  color: var(--lp-text); font: 700 var(--lp-fs-md)/1.3 var(--lp-font);
}
.sd.is-ready .sd-panel-label { display: none; }
.sd-panel.is-in { animation: sd-in .35s var(--lp-ease) both; }
@keyframes sd-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

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

/* ---- reduced motion: no fade, no sweep (stocks.js does not rotate either) ---- */
@media (prefers-reduced-motion: reduce) {
  .sd-panel.is-in { animation: none !important; }
  .sd-tab-prog { display: none !important; }
  .sd-tab-prog, .sd .sd-tab { transition: none !important; }
}

/* ---- phones: the tab bar scrolls sideways inside the 16px gutters, never the page ---- */
@media (max-width: 640px) {
  .sd.is-ready .sd-tabs-wrap { justify-content: flex-start; }
  .sd-tabs {
    justify-content: flex-start; width: auto;
    overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .sd-tabs::-webkit-scrollbar { display: none; }
  .sd .sd-tab { padding: 0 var(--lp-sp-3); }
  .sd-tab-prog { left: var(--lp-sp-3); right: var(--lp-sp-3); }
}
@media (max-width: 479.98px) {
  .sd-ctas, .sd-ctas .lp-btn { width: 100%; }
}
