/**
 * [INPUT]: 依赖 lore-ui.css 的纸面令牌与 wish.ts 输出的祈愿、轶闻、典当统计摘要、原生表格、连续排行和品质状态类
 * [OUTPUT]: 提供排行页次级分析区的扁平分区、可比较数据栅格、表格、连续排行、响应式规则与可访问反馈
 * [POS]: public 的排行分析视觉层；A7 首屏与三分段榜单由 wish-rank.css 承接，本文件只组织可展开的概率和价值统计
 * [PROTOCOL]: 变更时更新此头部，然后检查 CLAUDE.md
 */

.container {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 0 24px 64px;
  display: grid;
}

.page-header {
  padding: 30px 0 26px;
}

.eyebrow {
  display: block;
  margin-bottom: 7px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.1em;
}

.page-header h1 {
  max-width: none;
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(32px, 4.5vw, 40px);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: 0;
}

.page-header h1 br {
  display: none;
}

.subtitle {
  max-width: 700px;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.wish-panel,
.lore-panel,
.pawn-panel,
.collection-panel,
.heritage-panel {
  padding: 26px 0 30px;
  border-top: 1px solid var(--line);
}

.section-head {
  margin-bottom: 22px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
}

.section-head > div:first-child {
  min-width: 0;
}

.section-head h2,
.stats-card h3 {
  margin: 0;
  color: var(--ink);
  font-weight: 700;
}

.section-head h2 {
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: 0;
}

.section-head p {
  max-width: 570px;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.section-metrics {
  min-width: min(340px, 100%);
  display: flex;
  justify-content: flex-end;
  flex: 0 0 auto;
}

.wish-metrics {
  min-width: min(440px, 100%);
}

.metric-item {
  min-width: 88px;
  padding: 0 14px;
  display: grid;
  gap: 3px;
  text-align: right;
  border-left: 1px solid var(--line);
}

.metric-item strong {
  color: var(--ink);
  font-size: 20px;
  font-weight: 720;
  line-height: 1;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.metric-item small {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.stats-grid {
  display: grid;
  grid-template-columns: minmax(200px, 0.72fr) repeat(2, minmax(240px, 1fr));
  grid-template-areas:
    "quality prop seal"
    "luck luck luck";
  gap: 24px 28px;
  align-items: start;
}

.stats-grid > .quality-card { grid-area: quality; }
.stats-grid > .prop-card { grid-area: prop; }
.stats-grid > .seal-card { grid-area: seal; }
.stats-grid > .luck-card { grid-area: luck; }

.lore-grid,
.pawn-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.78fr) minmax(440px, 1.22fr);
  gap: 28px;
  align-items: start;
}

.heritage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px 28px;
}

.collection-grid {
  display: grid;
}

.collection-ranking {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 28px;
}

.collection-rank-row {
  min-height: 64px;
}

.collection-breakdown {
  display: flex;
  align-items: center;
  gap: 3px 11px;
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}

.collection-title-score {
  font-weight: 700;
}

.collection-title-score.level-0 { color: var(--muted); }
.collection-title-score.level-1 { color: #267a55; }
.collection-title-score.level-2 { color: #2f6fb0; }
.collection-title-score.level-3 { color: #7654a0; }
.collection-title-score.level-4 { color: #c73434; }
.collection-title-score.level-5 { color: #b43a74; }

.collection-score {
  min-width: 64px;
  color: var(--accent);
}

.collection-unavailable {
  padding: 12px 0 2px;
  display: grid;
  gap: 3px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 11px;
  line-height: 1.5;
}

.collection-unavailable strong {
  color: var(--ink-2);
  font-size: 11px;
}

.heritage-grid > .stats-card:nth-child(even) {
  padding-left: 28px;
  border-left: 1px solid var(--line);
}

.heritage-score {
  color: #3e7596;
}

.stats-card {
  min-width: 0;
}

.stats-grid > .prop-card,
.stats-grid > .seal-card,
.lore-grid > .luck-card,
.pawn-grid > .luck-card {
  padding-left: 28px;
  border-left: 1px solid var(--line);
}

.stats-grid > .luck-card {
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.stats-card h3 {
  margin-bottom: 4px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.stats-table {
  width: 100%;
  min-width: 420px;
  border-collapse: collapse;
  font-size: 12px;
}

.quality-card .stats-table {
  min-width: 0;
}

.stats-table th,
.stats-table td {
  padding: 8px 6px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
}

.stats-table th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 620;
  white-space: nowrap;
}

.stats-table tr:last-child td {
  border-bottom: 0;
}

.stats-table a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 650;
}

.pawn-table td:nth-child(n + 2),
.pawn-table th:nth-child(n + 2) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.quality-pill {
  --quality-color: #6b7280;
  min-width: 36px;
  min-height: 23px;
  padding: 0 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--quality-color);
  border: 1px solid color-mix(in srgb, var(--quality-color) 24%, white);
  border-radius: 999px;
  background: color-mix(in srgb, var(--quality-color) 8%, white);
  font-size: 11px;
  font-weight: 700;
}

.rate-bar {
  width: 68px;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e5e1;
}

.rate-bar span {
  height: 100%;
  display: block;
  border-radius: inherit;
}

.prop-list,
.luck-list {
  display: grid;
}

.prop-row {
  min-width: 0;
  min-height: 40px;
  padding: 6px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.prop-row:last-child {
  border-bottom: 0;
}

.prop-name {
  min-width: 0;
  overflow: hidden;
  color: var(--quality-color);
  font-size: 12px;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seal-row .prop-name {
  color: #b43a74;
}

.prop-meta {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}

.meta-pill,
.meta-rate {
  min-height: 22px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  border-radius: 4px;
  background: var(--surface-muted);
  font-size: 11px;
  white-space: nowrap;
}

.meta-rate {
  min-width: 47px;
  justify-content: flex-end;
  color: var(--ink-2);
  background: color-mix(in srgb, var(--quality-color) 7%, white);
}

.stats-grid .luck-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 24px;
}

.luck-row {
  min-height: 57px;
  padding: 8px 0;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  color: inherit;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  transition: background-color 140ms var(--ease-out);
}

.luck-row:active {
  background: var(--surface-muted);
}

.rank-cell {
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.luck-main {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.luck-main strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.luck-main small,
.luck-score small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.luck-score {
  min-width: 52px;
  display: grid;
  justify-items: end;
  font-variant-numeric: tabular-nums;
}

.luck-score strong {
  font-size: 12px;
}

.luck-up {
  color: var(--success);
  font-weight: 720;
}

.luck-down {
  color: var(--muted);
  font-weight: 680;
}

.coin-score {
  min-width: 68px;
  color: var(--accent);
}

.pawn-rank-row .luck-main small {
  white-space: normal;
}

.empty,
.empty-panel {
  color: var(--muted);
  text-align: center;
  font-size: 11px;
}

.empty {
  padding: 22px 8px;
}

.empty-panel {
  padding: 22px 8px;
  border-bottom: 1px dashed var(--line-strong);
}

.recent-items {
  min-width: 210px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.result-chip {
  min-height: 27px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  color: #6b7280;
  border: 1px solid currentColor;
  border-radius: 5px;
  background: #f9fafb;
  font-size: 11px;
  font-weight: 700;
}

.result-chip.q-limit { color: #c43e7e; background: #fdf2f8; }
.result-chip.q-red { color: #c73434; background: #fef2f2; }
.result-chip.q-gold,
.result-chip.q-yellow { color: #b56c08; background: #fff7ed; }
.result-chip.q-orange { color: #d85718; background: #fff7ed; }
.result-chip.q-purple { color: #7654a0; background: #f5f3ff; }
.result-chip.q-blue { color: #2f6fb0; background: #eff6ff; }
.result-chip.q-green { color: #267a55; background: #f0fdf4; }
.result-chip.q-grey,
.result-chip.q-gray { color: #6b7280; background: #f9fafb; }

@media (hover: hover) and (pointer: fine) {
  .stats-table a:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
  }

  .luck-row:hover {
    background: var(--accent-soft);
  }
}

@media (max-width: 940px) {
  .section-head {
    display: grid;
    align-items: start;
    gap: 15px;
  }

  .section-metrics,
  .wish-metrics {
    width: 100%;
    min-width: 0;
    justify-content: flex-start;
  }

  .metric-item:first-child {
    padding-left: 0;
    border-left: 0;
    text-align: left;
  }

  .stats-grid {
    grid-template-columns: minmax(200px, 0.72fr) minmax(300px, 1.28fr);
    grid-template-areas:
      "quality prop"
      "seal prop"
      "luck luck";
  }

  .stats-grid > .seal-card {
    padding: 18px 0 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 760px) {
  .container {
    padding: 0 12px 48px;
  }

  .topbar {
    top: 0;
    min-height: 56px;
    padding: 4px 2px;
    border-radius: 0;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .brand-copy small,
  .topbar-link:not(.topbar-link-primary) {
    display: none;
  }

  .topbar-link {
    min-height: 44px;
    padding: 0 11px;
  }

  .page-header {
    padding: 22px 0 20px;
  }

  .page-header h1 {
    font-size: 30px;
  }

  .wish-panel,
  .lore-panel,
  .pawn-panel,
  .collection-panel,
  .heritage-panel {
    padding: 22px 0 24px;
  }

  .section-head {
    margin-bottom: 18px;
  }

  .section-metrics {
    overflow-x: auto;
  }

  .metric-item {
    min-width: 86px;
  }

  .lore-grid,
  .pawn-grid,
  .stats-grid,
  .collection-ranking,
  .heritage-grid {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  .stats-grid {
    grid-template-areas:
      "quality"
      "prop"
      "seal"
      "luck";
  }

  .stats-grid > .prop-card,
  .stats-grid > .seal-card,
  .stats-grid > .luck-card,
  .lore-grid > .luck-card,
  .pawn-grid > .luck-card {
    padding: 22px 0 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .stats-grid .luck-list {
    grid-template-columns: 1fr;
  }

  .heritage-grid > .stats-card:nth-child(even) {
    padding-left: 0;
    border-left: 0;
  }

  .heritage-grid > .stats-card + .stats-card {
    padding-top: 22px;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 420px) {
  .metric-item {
    min-width: 80px;
    padding: 0 10px;
  }

  .metric-item strong {
    font-size: 18px;
  }

  .luck-row {
    grid-template-columns: 25px minmax(0, 1fr) auto;
    gap: 7px;
  }
}

@media (prefers-contrast: more) {
  .wish-panel,
  .lore-panel,
  .pawn-panel,
  .collection-panel,
  .heritage-panel,
  .stats-card,
  .luck-row {
    border-color: var(--line-strong);
  }
}
