/* StoxCredit perps redesign v7 (perps.html: markets explorer and trade terminal).
   Colors: existing tokens only. Changes are spacing, sizing, density, and motion.
   Selectors are scoped to the page's own containers. */

/* ---------- Layout: remove oversized wrappers and reserved height ---------- */
html body main#marketsView.wrap,
html body main#tradeView.wrap,
html body main#portfolioView.wrap {
  min-height: 0 !important;
  padding-top: 16px !important;
}
html body footer.site-foot {
  margin-top: 32px !important;
  min-height: 0 !important;
}

/* ---------- Markets header: compact, no landing-page scale ---------- */
html body #marketsView header.mk-head h1 {
  font-size: clamp(30px, 3vw, 40px) !important;
  line-height: 1.05 !important;
  margin: 2px 0 4px !important;
}
html body #marketsView header.mk-head p.sub {
  font-size: 14px !important;
  margin: 0 !important;
}
html body #marketsView section.dash-stats {
  margin-top: 12px !important;
  gap: 10px !important;
}
html body #marketsView section.dash-stats .dash-stat {
  min-height: 0 !important;
  padding: 12px 14px !important;
  transition: border-color .3s ease, transform .3s ease;
}
html body #marketsView section.dash-stats .dash-stat:hover {
  border-color: var(--sc-brand, currentColor);
  transform: translateY(-1px);
}
html body #marketsView section.dash-stats .dash-stat b {
  font-variant-numeric: tabular-nums;
}

/* ---------- Movers: two compact panels with staggered rows ---------- */
html body #marketsView section.mk-movers {
  gap: 12px !important;
  margin-top: 12px !important;
}
html body #marketsView section.mk-movers .mv-card {
  padding: 12px 14px !important;
}
html body #marketsView section.mk-movers .mv-card h3 {
  margin: 0 0 6px !important;
  font-size: 12px !important;
  letter-spacing: .06em;
  text-transform: uppercase;
  opacity: .66;
}
html body #marketsView section.mk-movers .mv-card ul {
  margin: 0 !important;
  padding: 0 !important;
  list-style: none;
}
html body #marketsView section.mk-movers .mv-card li {
  animation: sc-pv7-in .5s cubic-bezier(.22, 1, .36, 1) both;
  animation-delay: calc(var(--i, 0) * 50ms);
}
/* Three leading movers per panel keeps the explorer near the top of the first viewport. The full lists stay in the DOM. */
html body #marketsView section.mk-movers .mv-card li:nth-child(n+4) {
  display: none !important;
}
html body #marketsView section.mk-movers .mv-card li a,
html body #marketsView section.mk-movers .mv-card li button {
  transition: background-color .25s ease, transform .25s ease;
}
@media (hover: hover) and (pointer: fine) {
  html body #marketsView section.mk-movers .mv-card li a:hover,
  html body #marketsView section.mk-movers .mv-card li button:hover {
    background: color-mix(in srgb, currentColor 4%, transparent);
    transform: translateX(2px);
  }
}
@keyframes sc-pv7-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Explorer: dense rows, paging, clear selection ---------- */
html body #marketsView section.mk-table {
  margin-top: 14px !important;
}
html body #marketsView section.mk-table .mk-toolbar {
  margin-bottom: 8px !important;
}
html body #marketsView section.mk-table table td,
html body #marketsView section.mk-table table th {
  padding-top: 8px !important;
  padding-bottom: 8px !important;
}
html body #marketsView section.mk-table table tbody tr {
  transition: background-color .25s ease;
}
@media (hover: hover) and (pointer: fine) {
  html body #marketsView section.mk-table table tbody tr:hover {
    background: color-mix(in srgb, currentColor 3.5%, transparent);
  }
}
html body #marketsView section.mk-table table tbody tr.sc-pg-hidden {
  display: none !important;
}
html body #marketsView .sc-pg-more {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, currentColor 16%, transparent);
  background: transparent;
  color: var(--sc-brand, currentColor);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .25s ease, background-color .25s ease;
}
html body #marketsView .sc-pg-more:hover {
  border-color: var(--sc-brand, currentColor);
  background: color-mix(in srgb, var(--sc-brand, currentColor) 6%, transparent);
}
html body #marketsView .sc-pg-more:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 2px;
}
html body #marketsView .sc-pg-more[hidden] { display: none; }

/* ---------- Trade terminal: chart sized to the viewport (about 450 to 580px) ---------- */
html body #tradeView .trade-left > .panel:first-child #chart.chart {
  box-sizing: border-box !important;
  height: clamp(440px, calc(100vh - 360px), 580px) !important;
  max-height: 580px !important;
  min-height: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}
html body #tradeView .trade-left > .panel:first-child #tvW,
html body #tradeView .trade-left > .panel:first-child #tv.tv {
  height: 100% !important;
  min-height: 0 !important;
}
html body #tradeView .trade .panel.op {
  position: sticky;
  top: 96px;
  align-self: start;
}
html body #tradeView .trade .panel {
  overflow: visible;
}
html body #tradeView section.discover {
  margin-top: 12px !important;
  padding-top: 10px !important;
}

/* ---------- Mobile: no horizontal overflow, controls stay reachable ---------- */
@media (max-width: 960px) {
  html body #tradeView .trade .panel.op {
    position: static;
  }
  html body #tradeView .trade-left > .panel:first-child #chart.chart {
    height: clamp(340px, 62vh, 480px) !important;
  }
  html body #tradeView .trade-head .price-row {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px 16px !important;
    min-width: 0 !important;
  }
  html body #tradeView .trade-head #tMark.mark {
    font-size: clamp(22px, 7vw, 30px) !important;
    white-space: nowrap;
    max-width: 100%;
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html body #marketsView section.mk-movers .mv-card li,
  html body #marketsView section.mk-movers .mv-card li a,
  html body #marketsView section.dash-stats .dash-stat,
  html body #marketsView .sc-pg-more { animation: none !important; transition: none !important; transform: none !important; }
}
