/* 居屋2025 心水排序頁 — 附加樣式（基礎樣式沿用 style.css） */

/* ── top nav ─────────────────────────────────────────────── */
.top-nav { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.top-nav .nav-btn {
  display: inline-flex; align-items: center; text-decoration: none;
  font-size: 0.92rem; padding: 9px 16px;
}
.top-nav .nav-btn:hover { background: #ebf5fb; }

/* ── 屋苑 / 座 嘅心水數量小徽章 ───────────────────────────── */
.estate-fav-count,
.block-fav-count {
  display: inline-block;
  min-width: 20px;
  padding: 1px 6px;
  margin-left: 4px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  background: #f39c12;
  color: white;
  vertical-align: middle;
}
.block-fav-count { background: #2980b9; }
.estate-btn.active .estate-fav-count { background: rgba(255,255,255,0.9); color: #2980b9; }

/* ── 名次 badge ───────────────────────────────────────────── */
.rank-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.5;
  cursor: pointer;
  vertical-align: top;
  border: 1px solid rgba(0,0,0,0.12);
  user-select: none;
}
.rank-badge:hover { filter: brightness(0.94); }

/* 色階：頭 10 金、11–50 深藍、51–150 中藍、151+ 淺灰藍 */
.r-top10  { background: #f9e79f; color: #7d5a00; border-color: #e0b400; }
.r-top50  { background: #2e86c1; color: #ffffff; border-color: #1b4f72; }
.r-top150 { background: #aed6f1; color: #10304a; border-color: #7fb3d5; }
.r-rest   { background: #eaf2f8; color: #5d6d7e; border-color: #cdd9e2; }

/* 心水格：加個邊框同輕微高亮，唔好蓋過原有狀態色 */
td.unit-cell.is-fav { position: relative; box-shadow: inset 0 0 0 2px rgba(243,156,18,0.85); }
td.unit-cell.is-fav .rank-badge { margin-bottom: 2px; }

/* legend 嘅色階方塊 */
.legend-box.rank-box { border-width: 2px; }

/* 跳格閃爍 */
td.unit-cell.flash {
  animation: favFlash 1.2s ease;
  z-index: 5;
}
@keyframes favFlash {
  0%, 100% { box-shadow: inset 0 0 0 2px rgba(243,156,18,0.85); }
  30%      { box-shadow: inset 0 0 0 4px #f39c12, 0 0 14px rgba(243,156,18,0.9); }
}

/* ── layout：matrix + 排名面板 ─────────────────────────────── */
.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}
.content-grid > #matrixBox { min-width: 0; }

/* ── 排名面板 ─────────────────────────────────────────────── */
.rank-panel {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  padding: 16px 14px;
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
  display: flex;
  flex-direction: column;
}
.rank-panel h3 { margin: 0 0 4px; font-size: 1.05rem; color: #1a5276; }
.rank-panel #rankCount { font-size: 0.85rem; color: #7f8c8d; font-weight: 600; }
.rank-hint { font-size: 0.74rem; color: #95a5a6; margin-bottom: 10px; line-height: 1.5; }
#rankList {
  overflow-y: auto;
  flex: 1;
  border-top: 1px solid #eee;
  padding-top: 6px;
}
.rank-item {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 2px 8px;
  align-items: baseline;
  padding: 6px 6px;
  border-radius: 6px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.15s;
}
.rank-item:hover { background: #f7f9fa; }
.rank-item.active { background: #fff3cd; border-left-color: #f39c12; }
.rank-no {
  grid-row: 1 / span 2;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
  padding: 2px 0;
  border-radius: 8px;
}
.rank-unit { font-size: 0.86rem; font-weight: 600; color: #2c3e50; }
.rank-meta { font-size: 0.74rem; color: #7f8c8d; }

/* ── modal：心水排名一行 ──────────────────────────────────── */
.modal-value.v-fav { color: #b9770e; }

/* ── 響應式 ───────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .content-grid { grid-template-columns: minmax(0, 1fr); }
  .rank-panel { position: static; max-height: 420px; }
}
@media (max-width: 700px) {
  .rank-item { grid-template-columns: 40px 1fr; }
  .rank-badge { font-size: 0.62rem; padding: 1px 4px; }
}
