/* cadence 展示端 —— 深色黑胶/频谱风。设计计划见 frontend-design 流程：
   墨蓝黑底 + 琥珀金主强调 + 频谱青次级；窄高粗体标题 + 等宽数据；频谱条为 signature。 */

:root {
  --bg: #0e1116;
  --surface: #161c24;
  --surface-2: #1c232e;
  --line: #262f3b;
  --ink: #e8ecf1;
  --ink-soft: #b9c2cd;
  --muted: #8b95a5;
  --amber: #e8a33d;
  --amber-soft: rgba(232, 163, 61, 0.14);
  --teal: #57c9c5;
  --up: #46c07a;
  --down: #e0616b;
  --radius: 12px;

  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  --font-display: "Helvetica Neue", Helvetica, "Arial Narrow", "PingFang SC",
    sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
    monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(900px 500px at 10% 110%, rgba(87, 201, 197, 0.06), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  min-height: 100vh;
}

/* ---- 顶部 ---- */

.site-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 26px 28px 8px;
  max-width: 960px;
  margin: 0 auto;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-mark {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 12px rgba(232, 163, 61, 0.8);
  align-self: center;
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 3px;
}
.brand-tag { color: var(--muted); font-size: 13px; }
.updated { color: var(--muted); font-size: 12px; font-family: var(--font-mono); }

/* ---- Hero（本周/本期 #1）---- */

.hero {
  max-width: 960px;
  margin: 22px auto 4px;
  padding: 0 28px;
  animation: rise 0.5s ease backwards;
}
.hero-card {
  display: flex;
  align-items: center;
  gap: 22px;
  background: linear-gradient(135deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 24px;
  position: relative;
  overflow: hidden;
}
.hero-card::after {
  content: "";
  position: absolute;
  right: -80px; top: -80px;
  width: 240px; height: 240px;
  background: radial-gradient(circle, rgba(232, 163, 61, 0.16), transparent 70%);
}
.hero-rank {
  font-family: var(--font-mono);
  font-size: 54px;
  font-weight: 700;
  color: var(--amber);
  line-height: 1;
  min-width: 72px;
}
.hero-cover {
  width: 92px; height: 92px;
  border-radius: 10px;
  background-size: cover;
  background-position: center;
  background-color: var(--surface-2);
  background-image: linear-gradient(135deg, rgba(232, 163, 61, 0.5), rgba(87, 201, 197, 0.5));
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
}
.hero-info { min-width: 0; position: relative; z-index: 1; }
.hero-kicker {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.hero-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 30px;
  letter-spacing: -0.3px;
  line-height: 1.1;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hero-artist { color: var(--muted); margin-top: 4px; }
.hero-stats {
  display: flex;
  gap: 14px;
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}
.hero-stats b { color: var(--ink-soft); font-weight: 600; }

/* ---- Tab ---- */

nav.set-tabs, nav.board-tabs {
  display: flex;
  gap: 6px;
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 28px 0;
}
nav.board-tabs { padding-top: 8px; }

nav button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 6px 18px;
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: inherit;
}
nav button:hover { color: var(--ink); border-color: var(--muted); }
nav button.active {
  background: var(--amber);
  border-color: var(--amber);
  color: #14100a;
  font-weight: 600;
}

/* ---- 表格 ---- */

main { max-width: 960px; margin: 0 auto; padding: 6px 28px 40px; }

.board-meta { color: var(--muted); font-size: 13px; margin: 16px 0 10px; }

/* 月/年榜底部历史翻页 */
.board-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.board-pager[hidden] { display: none; }
.board-pager .pager-btn, .board-pager .snap-dot {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.board-pager .pager-btn:disabled { opacity: 0.4; cursor: default; }
.board-pager .snap-dot.active { background: var(--amber); color: #14100a; border-color: var(--amber); }
.board-pager .pager-label { color: var(--muted); font-size: 12px; font-family: var(--font-mono); }

/* 榜单表格区域：融入页面（墨蓝黑底），仅边框/分隔用低饱和橙 */
.table-wrap {
  --line: #6d5233;
  --amber-soft: rgba(216, 154, 78, 0.14);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  overflow-x: auto;
}

table.chart {
  width: 100%;
  table-layout: fixed;          /* 列宽由表头决定，避免内容把列撑宽导致横向溢出 */
  border-collapse: collapse;
  font-size: 14px;
  min-width: 640px;
}
table.chart thead { background: var(--amber-soft); }
table.chart th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
/* 数字列与「各源」列数据右对齐，表头跟随（对齐一致性） */
table.chart th.c-num,
table.chart th.c-src { text-align: right; }
/* 固定列宽（table-layout: fixed，配合表头使用；歌曲列自动占剩余宽度） */
table.chart th.c-rank { width: 52px; }
table.chart th.c-title { width: 240px; }
table.chart th.c-change { width: 92px; }
table.chart th.c-num { width: 52px; }
table.chart th.c-release { width: 92px; text-align: right; }
table.chart th.c-artist { width: 160px; }
table.chart th.c-src { width: 110px; }
table.chart td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  overflow: hidden;             /* 固定行高下，超长内容裁剪而不是撑高行 */
}
table.chart tbody tr:last-child td { border-bottom: none; }
table.chart tbody tr { background: transparent; animation: rise 0.32s ease backwards; }
table.chart tbody tr:nth-child(1) { animation-delay: 0.02s; }
table.chart tbody tr:nth-child(2) { animation-delay: 0.04s; }
table.chart tbody tr:nth-child(3) { animation-delay: 0.06s; }
table.chart tbody tr:nth-child(4) { animation-delay: 0.08s; }
table.chart tbody tr:nth-child(5) { animation-delay: 0.10s; }
table.chart tbody tr:nth-child(6) { animation-delay: 0.12s; }
table.chart tbody tr:nth-child(7) { animation-delay: 0.14s; }
table.chart tbody tr:nth-child(8) { animation-delay: 0.16s; }
table.chart tbody tr:nth-child(9) { animation-delay: 0.18s; }
table.chart tbody tr:nth-child(10) { animation-delay: 0.20s; }
/* 行融入页面底；hover 琥珀微光 */
table.chart tbody tr:hover { background: rgba(216, 154, 78, 0.10); }

td.rank {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 15px;
  color: var(--muted);
  width: 44px;
}

/* 封面缩略图 / 无封面占位：40px 宽 flex 并排（不遮挡），无封面占位保证歌名对齐 */
.cover-img, .cover-placeholder {
  width: 40px; height: 40px;
  border-radius: 6px;
  flex-shrink: 0;
}
.cover-img { object-fit: cover; background: var(--surface-2); }
.cover-placeholder { background: transparent; }
table.chart tr:nth-child(-n+3) td.rank { color: var(--amber); }

td.change { width: 78px; white-space: nowrap; font-family: var(--font-mono); }
.change-sep { color: var(--muted); margin: 0 2px; }
.peak { color: var(--muted); }

/* 固定行高：以「华语周榜 #1」单行信息高度（63px）为标准 */
table.chart tbody tr { height: 63px; }
table.chart td { vertical-align: middle; }
td.title {
  font-weight: 500;
  color: var(--ink-soft);
}
/* 歌名格保持标准 table-cell（vertical-align: middle 才生效），flex 布局放到内层 */
td.title .title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
td.title .album {
  display: block;
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
  white-space: nowrap;      /* 专辑单行，不撑行高 */
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.title-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;      /* 歌名单行截断，hover 用 tooltip 看全名 */
}
td.artist {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
td.num {
  text-align: right;
  color: var(--muted);
  width: 52px;
  font-family: var(--font-mono);
  font-size: 13px;
}
td.num.score { color: var(--ink-soft); font-weight: 600; }
/* 各源列：标签上下排版（每源一行，至多 3 个），列宽按最宽标签留 */
table.chart td.sources {
  text-align: right;
  font-size: 12px;
  padding-top: 6px;
  padding-bottom: 6px;
}

span.up { color: var(--up); font-weight: 600; }
span.down { color: var(--down); font-weight: 600; }
span.flat { color: var(--muted); }
span.badge.new {
  background: var(--amber);
  color: #14100a;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  letter-spacing: 1px;
}
span.src {
  display: block;               /* 上下排版，每源一行 */
  width: fit-content;
  margin: 0 0 2px auto;         /* 右对齐 */
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 7px;
  font-size: 10px;
  line-height: 1.3;
  white-space: nowrap;
}

/* 悬停 Tooltip（JS 挂到 body，避免被表格 overflow 裁剪） */
.tooltip {
  position: fixed;
  z-index: 60;
  max-width: 340px;
  background: #0b0e13;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.5;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

p.empty {
  color: var(--muted);
  text-align: center;
  padding: 48px 0;
  letter-spacing: 1px;
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 8px 0 28px;
}

/* ---- 动效 ---- */

@keyframes rise {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ---- 响应式 ---- */

@media (max-width: 640px) {
  .site-head { padding: 20px 16px 4px; }
  .brand-tag { display: none; }
  .hero { padding: 0 16px; }
  .hero-card { gap: 14px; padding: 16px; }
  .hero-rank { font-size: 40px; min-width: 54px; }
  .hero-cover { width: 68px; height: 68px; }
  .hero-title { font-size: 22px; }
  nav.set-tabs, nav.board-tabs { padding: 12px 16px 0; }
  main { padding: 4px 16px 32px; }

  /* 移动端表格：整表横向滚动，歌名列统一 264px（与月榜/年度一致） */
  .table-wrap {
    margin: 0 -16px;          /* 通栏滚动区 */
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  /* fixed 布局必须给明确总宽：宽度 auto 时表格会按不换行内容自适应（更宽）。
     表格总宽 = 列宽之和，歌名列固定 264px，不参与剩余宽度分配。 */
  table.chart { min-width: 676px; }               /* 6 列：周榜 */
  table.chart th.c-title { width: 264px; }
  table.chart[data-cols="5"] { min-width: 624px; } /* 5 列：总流量 */
  table.chart[data-cols="4"] { min-width: 560px; } /* 4 列：月榜/年度 */
  table.chart th, table.chart td { padding-left: 10px; padding-right: 10px; }
  table.chart th.c-change, table.chart td.change { width: 64px; }
  table.chart th.c-artist, table.chart td.artist { width: 140px; }
  table.chart th.c-src, table.chart td.sources { width: 104px; }
}
