/* Market Movers, Gap Scanner and Volume Scanner, shared by the homepage and the dashboard
   (templates/partials/market_movers.html, static/js/market-movers.js). */

.mm-block {
  --mm-up: #22c55e;
  --mm-down: #f43f5e;
  --mm-amber: #f59e0b;
  --mm-blue: #60a5fa;
  --mm-line: rgba(148, 163, 184, .12);
  margin-bottom: 24px;
}

/* Header */
.mm-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 12px 24px; margin-bottom: 20px;
}
.mm-eyebrow {
  margin: 0 0 6px; font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent-soft, var(--accent));
}
.mm-title {
  margin: 0 0 6px; font-size: clamp(24px, 3.2vw, 32px); font-weight: 800; line-height: 1.15;
  letter-spacing: -.02em; color: var(--text-main);
}
.mm-sub { margin: 0; max-width: 60ch; font-size: 14.5px; line-height: 1.6; color: var(--text-muted); }
.mm-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.mm-session, .mm-live {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px;
  border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
}
.mm-session { color: var(--text-muted); background: rgba(148, 163, 184, .08); border: 1px solid var(--mm-line); }
.mm-session[data-session="MARKET OPEN"] { color: var(--mm-up); border-color: rgba(34, 197, 94, .35); background: rgba(34, 197, 94, .08); }
.mm-session[data-session="PREMARKET"] { color: var(--mm-amber); border-color: rgba(245, 158, 11, .35); background: rgba(245, 158, 11, .08); }
.mm-session[data-session="AFTER HOURS"] { color: #a78bfa; border-color: rgba(167, 139, 250, .35); background: rgba(167, 139, 250, .08); }
.mm-live { color: var(--mm-up); background: rgba(34, 197, 94, .1); border: 1px solid rgba(34, 197, 94, .28); }
.mm-live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--mm-up); box-shadow: 0 0 0 0 rgba(34, 197, 94, .6); animation: mm-pulse 1.8s ease-out infinite; }
@keyframes mm-pulse { 0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, .55); } 100% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); } }
.mm-updated { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* Cards */
.mm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.mm-card {
  position: relative; overflow: hidden; border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .025), rgba(255, 255, 255, 0)), var(--card);
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px -18px rgba(0, 0, 0, .7);
}
.mm-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 2px; background: var(--mm-line); }
.mm-card--up::before { background: linear-gradient(90deg, var(--mm-up), transparent); }
.mm-card--down::before { background: linear-gradient(90deg, var(--mm-down), transparent); }
.mm-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 14px 18px 12px; border-bottom: 1px solid var(--mm-line);
}
.mm-card-head h3 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 15px; font-weight: 700; color: var(--text-main); }
.mm-card--up .mm-arrow { color: var(--mm-up); font-size: 11px; }
.mm-card--down .mm-arrow { color: var(--mm-down); font-size: 11px; }
.mm-tag { padding: 3px 9px; border-radius: 999px; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.mm-tag--amber { color: var(--mm-amber); background: rgba(245, 158, 11, .1); border: 1px solid rgba(245, 158, 11, .25); }
.mm-tag--blue { color: var(--mm-blue); background: rgba(96, 165, 250, .1); border: 1px solid rgba(96, 165, 250, .25); }
.mm-card-body { padding: 4px 6px 8px; }

/* Tables */
.mm-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.mm-table th {
  padding: 9px 12px 7px; font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-muted); text-align: right;
}
.mm-table th:first-child, .mm-table td:first-child { text-align: left; }
.mm-table td { position: relative; padding: 0 12px; height: 38px; font-size: 13.5px; text-align: right; color: var(--text-muted); border-top: 1px solid rgba(148, 163, 184, .06); }
.mm-table tbody tr { transition: background .2s; }
.mm-table tbody tr:hover { background: rgba(148, 163, 184, .06); }
.mm-sym a, .mm-sym { font-weight: 800; color: var(--text-main); text-decoration: none; letter-spacing: .01em; }
.mm-sym a:hover { color: var(--accent); }
.mm-pill {
  display: inline-block; min-width: 72px; padding: 4px 8px; border-radius: 8px;
  font-weight: 700; font-size: 12.5px; text-align: right;
}
.mm-pill--up { color: var(--mm-up); background: rgba(34, 197, 94, .12); }
.mm-pill--down { color: var(--mm-down); background: rgba(244, 63, 94, .12); }
.mm-up { color: var(--mm-up); font-weight: 600; }
.mm-down { color: var(--mm-down); font-weight: 600; }
.mm-rvol { color: var(--mm-amber); font-weight: 700; }
.mm-dvol { color: var(--mm-blue); font-weight: 600; }
/* Size of the move, drawn behind the row: the largest mover fills the row. */
.mm-bar { position: absolute; inset: 6px auto 6px 0; border-radius: 0 6px 6px 0; pointer-events: none; }
.mm-card--up .mm-bar { background: linear-gradient(90deg, rgba(34, 197, 94, .14), rgba(34, 197, 94, 0)); }
.mm-card--down .mm-bar { background: linear-gradient(90deg, rgba(244, 63, 94, .14), rgba(244, 63, 94, 0)); }
.mm-table td > :not(.mm-bar) { position: relative; }
.mm-news {
  display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 8px;
  color: var(--mm-blue); background: rgba(96, 165, 250, .1); border: 1px solid rgba(96, 165, 250, .18);
  text-decoration: none; font-size: 12px; transition: background .2s, transform .2s;
}
.mm-news:hover { background: rgba(96, 165, 250, .22); transform: translateY(-1px); }
.mm-flash-up { animation: mm-flash-up .8s ease; }
.mm-flash-down { animation: mm-flash-down .8s ease; }
@keyframes mm-flash-up { from { background: rgba(34, 197, 94, .18); } to { background: transparent; } }
@keyframes mm-flash-down { from { background: rgba(244, 63, 94, .18); } to { background: transparent; } }
.mm-empty { margin: 0; padding: 28px 16px; text-align: center; font-size: 13.5px; color: var(--text-muted); }
.mm-empty a { color: var(--accent); }

/* Skeleton: the same row height as the loaded tables, so nothing jumps when data arrives. */
.mm-skeleton { padding-top: 31px; }
.mm-skel-row { display: flex; align-items: center; gap: 16px; height: 38px; padding: 0 12px; border-top: 1px solid rgba(148, 163, 184, .06); }
.mm-skel-row span { flex: 1; height: 10px; border-radius: 6px; background: linear-gradient(90deg, rgba(148, 163, 184, .08), rgba(148, 163, 184, .16), rgba(148, 163, 184, .08)); background-size: 200% 100%; animation: mm-shimmer 1.4s linear infinite; }
.mm-skel-row span:first-child { flex: .7; }
@keyframes mm-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  .mm-live-dot, .mm-skel-row span, .mm-flash-up, .mm-flash-down { animation: none; }
}
@media (max-width: 760px) {
  .mm-grid { grid-template-columns: 1fr; }
  .mm-table td, .mm-table th { padding-left: 8px; padding-right: 8px; }
  .mm-pill { min-width: 64px; }
}

/* Homepage placement */
.hm-movers { padding: 8px 0 40px; scroll-margin-top: 72px; }
