/* ─── Tier List Styles ─────────────────────────── */

.tier-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* ── Controls ── */
.tier-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}
.tier-filter-chips {
  display: flex;
  gap: 8px;
}
.chip-bga {
  margin-left: 8px;
  border-style: dashed;
}
.tier-stats {
  font-size: .8rem;
  color: var(--text3);
  flex: 1;
}
.tier-refresh-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  color: var(--text2);
  font-size: .85rem;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
}
.tier-refresh-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}

/* ── Loading / Empty ── */
.tier-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 80px 20px;
  color: var(--text3);
}
.tier-loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.tier-empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--text2);
  font-size: 1rem;
}

/* ── Tier Sections ── */
.tier-section {
  margin-bottom: 28px;
}

.tier-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  margin-bottom: 2px;
  cursor: pointer;
  user-select: none;
}
.tier-collapse-arrow {
  font-size: .75rem;
  opacity: .65;
  flex-shrink: 0;
  transition: transform .2s ease;
}
.tier-section.collapsed .tier-collapse-arrow {
  transform: rotate(-90deg);
}
.tier-section.collapsed .tier-card-grid {
  display: none;
}
.tier-badge {
  font-family: 'Cinzel', serif;
  font-size: 1.3rem;
  font-weight: 700;
  width: 36px;
  text-align: center;
  flex-shrink: 0;
}
.tier-range {
  font-size: .78rem;
  opacity: .75;
  flex: 1;
}
.tier-count {
  font-size: .8rem;
  font-weight: 600;
  opacity: .85;
}

/* Tier colours */
.tier-s    { background: rgba(255,200,50,.18);  color: #f5c842; border-left: 4px solid #f5c842; }
.tier-a    { background: rgba(74,222,128,.14);  color: #4ade80; border-left: 4px solid #4ade80; }
.tier-b    { background: rgba(96,165,250,.14);  color: #60a5fa; border-left: 4px solid #60a5fa; }
.tier-c    { background: rgba(192,132,252,.14); color: #c084fc; border-left: 4px solid #c084fc; }
.tier-d    { background: rgba(251,146,60,.14);  color: #fb923c; border-left: 4px solid #fb923c; }
.tier-e    { background: rgba(248,113,113,.14); color: #f87171; border-left: 4px solid #f87171; }
.tier-unrated { background: var(--surface); color: var(--text3); border-left: 4px solid var(--border); }

/* ── Card Grid ── */
.tier-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.tier-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
}
.tier-card:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.tier-card-thumb {
  width: 100%;
  aspect-ratio: 6/5;
  overflow: hidden;
  background: var(--bg);
}
.tier-card-thumb canvas {
  width: 100%;
  height: auto;
  display: block;
}
.tier-card-info {
  padding: 6px 8px 8px;
}
.tier-card-name {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}
.tier-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.tier-card-score {
  font-size: .78rem;
  font-weight: 700;
  color: var(--gold);
}
.tier-card-seen {
  font-size: .65rem;
  color: var(--text3);
}
/* 信心標籤：依有效場數分級 */
.tier-card-conf {
  font-size: .58rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 6px;
  line-height: 1.5;
  white-space: nowrap;
}
.tier-conf-warm      { background: rgba(148, 163, 184, .18); color: var(--text3); }
.tier-conf-ref       { background: rgba(245, 158, 11, .18);  color: #f59e0b; }
.tier-conf-converged { background: rgba(34, 197, 94, .18);   color: #22c55e; }
.tier-conf-solid     { background: rgba(16, 185, 129, .24);  color: #10b981; }
/* BGA 牌組禁卡標籤（只在 Tier List 標示，排序卡片刻意不標以避免錨定偏差） */
.tier-card-ban {
  font-size: .58rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 6px;
  line-height: 1.5;
  white-space: nowrap;
  background: rgba(224, 92, 92, .25);
  color: var(--red);
}

/* ── Deck filter ── */
.tier-deck-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 24px;
}
.deck-chip {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 4px 12px;
  font-size: .78rem;
  font-family: inherit;
  color: var(--text3);
  cursor: pointer;
  transition: all var(--transition);
}
.deck-chip.active {
  background: var(--surface);
  border-color: var(--gold);
  color: var(--gold);
}

/* ── Ban section ── */
.tier-ban-section {
  margin-top: 40px;
  border-top: 1px solid var(--border);
  padding-top: 24px;
}
.tier-ban-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.tier-ban-section.collapsed .tier-collapse-arrow {
  transform: rotate(-90deg);
}
.tier-ban-section.collapsed .tier-ban-body {
  display: none;
}
.tier-ban-group {
  margin-bottom: 20px;
}
.tier-ban-label {
  font-size: .8rem;
  color: var(--text3);
  margin-bottom: 10px;
  font-weight: 500;
}
.tier-ban-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
}
.tier-ban-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  opacity: .65;
}
.tier-ban-card:hover {
  border-color: #f87171;
  opacity: 1;
}
.tier-ban-name {
  font-size: .7rem;
  color: var(--text2);
  text-align: center;
  padding: 4px 6px 6px;
  line-height: 1.3;
}

/* ── Search (highlight in place) ── */
.tier-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  margin-bottom: 20px;
}
.tier-search-icon {
  position: absolute;
  left: 14px;
  font-size: .95rem;
  opacity: .6;
  pointer-events: none;
}
.tier-search-input {
  width: 100%;
  padding: 11px 96px 11px 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: .9rem;
  transition: border-color var(--transition);
}
.tier-search-input:focus { outline: none; border-color: var(--gold); }
.tier-search-input::placeholder { color: var(--text3); }
.tier-search-hint {
  position: absolute;
  right: 38px;
  font-size: .72rem;
  color: var(--text3);
  pointer-events: none;
  white-space: nowrap;
}
.tier-search-clear {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: .9rem;
  padding: 4px 6px;
  line-height: 1;
}
.tier-search-clear:hover { color: var(--gold); }

/* 搜尋時：點亮符合的卡、收起不符的 */
.tier-card.search-hit {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
  border-color: var(--gold);
}
.tier-card.search-hide,
.tier-ban-card.search-hide { display: none; }
.tier-ban-card.search-hit { outline: 2px solid var(--gold); outline-offset: 1px; opacity: 1; }

/* ── Responsive ── */
@media (max-width: 600px) {
  .tier-main { padding: 16px 12px 80px; }

  /* Controls — stats on own line */
  .tier-controls { gap: 8px; }
  .tier-filter-chips { flex-wrap: wrap; }
  .tier-stats { width: 100%; order: 10; font-size: .78rem; }
  .tier-refresh-btn { padding: 6px 12px; font-size: .8rem; }

  /* Deck chips */
  .deck-chip { padding: 3px 10px; font-size: .75rem; }

  /* Tier header */
  .tier-header { padding: 8px 12px; }
  .tier-badge { font-size: 1.1rem; width: 28px; }
  .tier-range { font-size: .72rem; }

  /* Card grid */
  .tier-card-grid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 7px; padding: 8px; }
  .tier-card-info { padding: 4px 6px 6px; }
  .tier-card-name { font-size: .7rem; }
  .tier-card-score { font-size: .72rem; }
  .tier-card-seen { font-size: .6rem; }
  .tier-card-conf { font-size: .54rem; padding: 1px 4px; }

  /* Ban section */
  .tier-ban-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 8px; }
}
