/**
 * coin-history.css — 币种历史页：页眉条、价格区、涨幅、图表、表、时间线
 * 目录：style/coin-history.css（用于 index.php 阶段①样板，后续 eth/ltc/bnb 复用）
 */

/* 页内标题条：大标题 + 副标题水平居中（项目规则约定） */
.page-hero {
  padding: 12px 0 10px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 12px;
  text-align: center;
}
.page-hero h1 {
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}
.page-hero p {
  margin: 6px auto 0;
  color: var(--color-muted);
  font-size: 14px;
  max-width: 42rem;
}

.dashboard-block {
  margin-bottom: 20px;
}

/* 价格网格 */
.price-cards-container {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
/* data/ 按年页仅 3 张卡 */
.price-cards-container.price-cards-3 {
  grid-template-columns: 1.2fr 1fr 1fr;
}
.price-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  /* 同行卡片被最高块撑高时，正文在标题下方剩余区域垂直居中 */
  display: flex;
  flex-direction: column;
  min-height: 100%;
}
.price-card-primary {
  border-color: color-mix(in srgb, var(--color-brand) 35%, var(--color-border));
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--color-brand) 6%, #fff), #fff);
}
.price-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  flex-shrink: 0;
}
.price-card-header h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-muted);
}
.realtime-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-brand);
  border: 1px solid color-mix(in srgb, var(--color-brand) 40%, transparent);
  border-radius: 999px;
  padding: 2px 8px;
}
.price-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center; /* H/L 等内容在下方空白区垂直居中 */
  min-height: 0;
}
.price-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 6px;
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.4;
}
.price-item:last-child {
  margin-bottom: 0;
}
.price-label {
  font-weight: 600;
  color: var(--color-muted);
}
.price-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  color: var(--color-text);
}
.price-usd,
.price-date {
  font-size: 12px;
  color: var(--color-muted);
}

/* 实时价（live_btc126.js） */
.live-wrap { font-size: 14px; }
.live-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-bottom: 8px;
  line-height: 1.4;
}
.live-row:last-child { margin-bottom: 0; }
.live-price {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.live-change { font-size: 13px; font-weight: 600; color: var(--color-muted); }
.live-change.live-up { color: var(--color-up); }
.live-change.live-down { color: var(--color-down); }
.live-label { font-weight: 600; color: var(--color-muted); }
.live-hl { font-family: var(--font-mono); font-weight: 700; margin-right: 6px; }
.live-na { color: var(--color-muted); }
.red { color: var(--color-up); }
.blue { color: var(--color-down); }

/* 阶段涨幅 */
.performance-card,
.exchange-card,
.site-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}
.performance-header,
.exchange-header,
.site-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-2);
}
.performance-body,
.exchange-body,
.site-panel-body {
  padding: 16px;
}
.performance-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}
.performance-item {
  text-align: center;
  padding: 12px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
}
.performance-label {
  font-size: 12px;
  color: var(--color-muted);
  margin-bottom: 6px;
}
.performance-value {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
}
.performance-value.positive { color: var(--color-up); }
.performance-value.negative { color: var(--color-down); }
.performance-value.special { color: var(--color-brand); }

.bnb-burn-btn {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  color: var(--color-text);
  font-size: 13px;
}
.bnb-burn-btn:hover {
  border-color: var(--color-brand);
  color: var(--color-brand);
}

/* 交易所按钮 */
.exchange-subtitle {
  font-size: 12px;
  color: var(--color-muted);
}
.exchange-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s var(--ease), background 0.15s var(--ease), border-color 0.15s var(--ease);
}
.btn:hover {
  border-color: var(--color-brand);
  color: var(--color-brand);
}
.btn:active {
  transform: scale(0.98);
}
.btn-primary {
  background: var(--color-brand);
  border-color: var(--color-brand);
  color: #fff;
}
.btn-primary:hover {
  background: var(--color-brand-hover);
  border-color: var(--color-brand-hover);
  color: #fff;
}
.btn-sm {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}
.year-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 12px;
}

/* 图表 */
.chart-section {
  margin: 8px 0 20px;
}
/* 主栏末块少留白：与 .site-main 底 padding、页脚间距对齐（today 仅图表时、含 footer_coin 时均适用） */
.site-main > .chart-section:last-child,
.site-main > .dashboard-block:last-child {
  margin-bottom: 0;
}
.chart-shell {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  position: relative;
}
.chart-shell::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: var(--color-brand);
  border-radius: var(--radius) var(--radius) 0 0;
}
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 480px;
  background: var(--color-surface-2);
  border-radius: 6px;
}
.loading-spinner {
  width: 36px;
  height: 36px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-brand);
  border-radius: 50%;
  margin-bottom: 14px;
}
@media (prefers-reduced-motion: no-preference) {
  .loading-spinner {
    animation: spin 0.8s linear infinite;
  }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.loading-text {
  color: var(--color-muted);
  font-size: 14px;
}

/* Tab */
.site-tabs-nav {
  display: flex;
  gap: 4px;
  padding: 8px 12px 0;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-2);
}
.site-tabs-nav button {
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  background: transparent;
  color: var(--color-muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.site-tabs-nav button.is-active {
  color: var(--color-text);
  border-bottom-color: var(--color-brand);
}
.site-tabs-panel {
  display: none;
  padding: 16px;
}
.site-tabs-panel.is-active {
  display: block;
}

/* 表格 */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th,
.data-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--color-border);
  text-align: center;
  white-space: nowrap;
}
.data-table th {
  font-weight: 600;
  color: var(--color-muted);
  background: var(--color-surface-2);
}
.data-table a {
  color: var(--color-text);
}
.data-table a:hover {
  color: var(--color-brand);
}
.data-table tbody tr {
  position: relative; /* 供 .data-row-stretch::after 铺满整行 */
  transition: background-color 0.15s var(--ease);
}
.data-table tbody tr:hover {
  background-color: color-mix(in srgb, var(--color-brand) 8%, #fff);
}
.data-table tbody tr:hover a {
  color: var(--color-brand);
}
/* 历史价格表：整行可点（伪元素铺满 tr，仍走首列真实 <a>） */
.data-table tbody tr:has(.data-row-stretch) {
  cursor: pointer;
}
.data-table a.data-row-stretch {
  color: var(--color-brand);
  text-decoration: none;
  font-weight: 600;
}
.data-table a.data-row-stretch::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* 时间线 */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 12px;
  border-left: 2px solid var(--color-border);
}
.timeline-item {
  position: relative;
  padding: 0 0 14px 16px;
}
.timeline-item:last-child {
  padding-bottom: 0;
}
.dashboard-block:last-child {
  margin-bottom: 0;
}
.site-panel:last-child {
  margin-bottom: 0;
}
.timeline-item::before {
  content: "";
  position: absolute;
  left: -17px;
  top: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-brand);
  border: 2px solid var(--color-surface);
}
.timeline-title {
  font-size: 14px;
  color: var(--color-text);
  line-height: 1.5;
}

@media (max-width: 1024px) {
  .price-cards-container,
  .price-cards-container.price-cards-3 {
    grid-template-columns: 1fr 1fr;
  }
  .performance-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 767px) {
  .price-cards-container,
  .price-cards-container.price-cards-3 {
    grid-template-columns: 1fr;
  }
  .performance-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .loading-container {
    min-height: 360px;
  }
  .exchange-buttons {
    flex-direction: column;
  }
  .exchange-buttons .btn {
    width: 100%;
  }
}
