/**
 * [INPUT]: 依赖 lore-ui.css 的基础令牌、wish.css 的分析组件，以及 wish.ts 输出的 A7 三分段排行语义和 App 素材
 * [OUTPUT]: 提供排行返回栏、收藏家/承徽宗/博阅师分段控件、头像榜单、个人名次摘要与折叠分析区的响应式视觉
 * [POS]: public 的 A7 排行主视觉层；首屏排行由本文件负责，次级概率表格继续由 wish.css 承接
 * [PROTOCOL]: 变更时更新此头部，然后检查 CLAUDE.md
 */

html,
body {
  background: #f0f2ff;
}

body {
  color: #20222b;
}

.container {
  width: min(100%, 1180px);
  padding: 0 24px 72px;
}

.rank-app-header {
  width: min(100%, 920px);
  min-height: 116px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 24px;
}

.rank-app-back {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #20222b;
  transition: background-color 140ms var(--ease-out), transform 120ms var(--ease-out);
}

.rank-app-back img {
  width: 34px;
  height: 34px;
  display: block;
}

.rank-app-back:active {
  transform: scale(0.92);
}

.rank-app-header h1 {
  margin: 0;
  color: #20222b;
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 750;
  line-height: 1.1;
  letter-spacing: 0;
}

.rank-app-shell {
  width: min(100%, 920px);
  margin: 0 auto;
}

.rank-segments {
  min-height: 68px;
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  border-radius: 999px;
  background: #e4e7f7;
}

.rank-segments button {
  min-width: 0;
  min-height: 56px;
  padding: 0 18px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #626778;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background-color 160ms var(--ease-out), color 160ms var(--ease-out), transform 120ms var(--ease-out);
}

.rank-segments button[aria-selected="true"] {
  background: #fbfbff;
  color: #20222b;
  box-shadow: 0 2px 10px rgba(68, 76, 120, 0.08);
}

.rank-segments button:active {
  transform: scale(0.98);
}

.rank-tab-panels {
  min-width: 0;
}

.rank-tab-panel {
  padding: 38px 0 10px;
}

.rank-tab-panel[hidden] {
  display: none;
}

.app-rank-list {
  min-width: 0;
}

.app-rank-row {
  min-width: 0;
  min-height: 102px;
  display: grid;
  grid-template-columns: 52px 64px minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  color: inherit;
  border-bottom: 1px solid #e3e5ef;
  text-decoration: none;
  transition: background-color 140ms var(--ease-out), transform 120ms var(--ease-out);
}

.app-rank-row:active {
  transform: scale(0.99);
}

.app-rank-position {
  color: #6d7280;
  font-family: var(--font-display);
  font-size: 27px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.app-rank-position.is-podium {
  color: #c9992d;
  font-size: 31px;
  font-weight: 750;
}

.app-rank-avatar {
  width: 64px;
  height: 64px;
  display: block;
  overflow: hidden;
  border: 1px solid rgba(64, 70, 91, 0.12);
  border-radius: 50%;
  background: #e9ebf5;
  object-fit: cover;
}

.app-rank-main {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.app-rank-row.is-reading .app-rank-main {
  grid-column: 3 / -1;
}

.app-rank-name {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px 8px;
  flex-wrap: wrap;
  color: #20222b;
  font-family: var(--font-display);
  font-size: 21px;
  line-height: 1.2;
}

.app-rank-name strong,
.app-rank-name > span:not(.app-level-badge) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-rank-name strong {
  font-weight: 750;
}

.app-rank-main > small {
  overflow-wrap: anywhere;
  color: #707583;
  font-family: var(--font-display);
  font-size: 15px;
  line-height: 1.45;
}

.app-level-badge {
  min-width: 60px;
  height: 25px;
  padding: 0 8px 0 4px;
  display: inline-flex;
  align-items: center;
  gap: 1px;
  flex: 0 0 auto;
  border: 1px solid #abd7f4;
  border-radius: 999px;
  color: #4d80a4;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.app-level-badge img {
  width: 21px;
  height: 21px;
  display: block;
  object-fit: contain;
}

.app-rank-value {
  min-width: 82px;
  display: grid;
  gap: 3px;
  color: #727786;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.app-rank-value strong {
  color: #313540;
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1;
}

.app-rank-value small {
  font-size: 12px;
}

.app-rank-summary {
  min-height: 72px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: #272b35;
  border-bottom: 1px solid #e3e5ef;
  font-family: var(--font-display);
  font-size: 18px;
}

.app-rank-summary strong {
  color: #6f7482;
  font-size: 16px;
  font-weight: 500;
  text-align: right;
}

.app-rank-empty {
  min-height: 180px;
  display: grid;
  place-items: center;
  color: #747987;
  font-family: var(--font-display);
  font-size: 17px;
}

.rank-snapshot,
.rank-sync-note {
  margin: 24px 0 0;
  color: #858997;
  font-family: var(--font-display);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.rank-sync-note {
  margin-top: 14px;
  color: #6f7482;
}

.rank-tab-panel .collection-unavailable {
  margin-top: 12px;
  padding: 12px;
  border: 0;
  border-radius: 8px;
  background: rgba(224, 226, 238, 0.6);
}

.heritage-detail-grid {
  margin-top: 34px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0 28px;
  border-top: 1px solid #e3e5ef;
}

.heritage-detail-grid > div {
  min-width: 0;
  padding-top: 20px;
}

.heritage-detail-grid > div + div {
  padding-left: 28px;
  border-left: 1px solid #e3e5ef;
}

.heritage-detail-grid h2 {
  margin: 0 0 10px;
  color: #30343e;
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0;
}

.heritage-detail-grid .luck-row {
  min-height: 58px;
  grid-template-columns: 28px minmax(0, 1fr) auto;
}

.heritage-detail-grid .luck-main small {
  display: none;
}

.rank-analysis {
  width: min(100%, 920px);
  margin: 40px auto 0;
  border-top: 1px solid #dfe2ee;
}

.rank-analysis > summary {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #333743;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  list-style: none;
}

.rank-analysis > summary::-webkit-details-marker {
  display: none;
}

.rank-analysis > summary::after {
  content: "+";
  color: #6e7381;
  font-family: var(--font-sans);
  font-size: 24px;
  font-weight: 400;
}

.rank-analysis[open] > summary::after {
  content: "−";
}

.rank-analysis-content {
  min-width: 0;
}

@media (hover: hover) and (pointer: fine) {
  .rank-app-back:hover,
  .app-rank-row:hover {
    background: rgba(255, 255, 255, 0.62);
  }

  .rank-segments button:hover:not([aria-selected="true"]) {
    color: #3e4350;
  }
}

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

  .rank-app-header {
    min-height: 96px;
    gap: 14px;
  }

  .rank-app-header h1 {
    font-size: 29px;
  }

  .rank-app-back {
    width: 42px;
    height: 42px;
  }

  .rank-app-back img {
    width: 31px;
    height: 31px;
  }

  .rank-segments {
    min-height: 58px;
    padding: 5px;
  }

  .rank-segments button {
    min-height: 48px;
    padding: 0 8px;
    font-size: 18px;
  }

  .rank-tab-panel {
    padding-top: 28px;
  }

  .app-rank-row {
    min-height: 88px;
    grid-template-columns: 34px 50px minmax(0, 1fr);
    gap: 10px;
  }

  .app-rank-position {
    font-size: 22px;
  }

  .app-rank-position.is-podium {
    font-size: 25px;
  }

  .app-rank-avatar {
    width: 50px;
    height: 50px;
  }

  .app-rank-name {
    gap: 4px 6px;
    font-size: 17px;
  }

  .app-rank-main {
    gap: 5px;
  }

  .app-rank-main > small {
    font-size: 13px;
  }

  .app-level-badge {
    min-width: 52px;
    height: 22px;
    padding-right: 6px;
    font-size: 11px;
  }

  .app-level-badge img {
    width: 18px;
    height: 18px;
  }

  .app-rank-value {
    min-width: 0;
    margin-top: -4px;
    grid-column: 3;
    display: flex;
    align-items: baseline;
    gap: 5px;
    text-align: left;
  }

  .app-rank-row.is-reading .app-rank-main {
    grid-column: 3;
  }

  .app-rank-value strong {
    font-size: 15px;
  }

  .app-rank-value small {
    font-size: 11px;
  }

  .app-rank-summary {
    min-height: 64px;
    padding: 0 6px;
    font-size: 16px;
  }

  .app-rank-summary strong {
    font-size: 13px;
  }

  .heritage-detail-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .heritage-detail-grid > div + div {
    margin-top: 18px;
    padding-left: 0;
    padding-top: 18px;
    border-left: 0;
    border-top: 1px solid #e3e5ef;
  }

  .rank-analysis {
    margin-top: 28px;
  }

  .rank-analysis > summary {
    min-height: 64px;
    font-size: 15px;
  }
}

@media (max-width: 390px) {
  .rank-segments button {
    font-size: 17px;
  }

  .app-rank-row {
    grid-template-columns: 30px 46px minmax(0, 1fr);
    gap: 8px;
  }

  .app-rank-avatar {
    width: 46px;
    height: 46px;
  }

  .app-rank-name {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rank-app-back,
  .rank-segments button,
  .app-rank-row {
    transition: none;
  }
}

@media (prefers-contrast: more) {
  .rank-segments,
  .app-rank-row,
  .app-rank-summary,
  .heritage-detail-grid,
  .rank-analysis {
    border-color: #717683;
  }
}
