/* ============================================================
   集體洗碼任務模組 — washcode3.css  Version A
   黑銀金屬 80% + 橘紅 20%  ·  iOS Dark 質感
============================================================ */
:root {
  --color-w65: rgba(255, 255, 255, 0.65);
  --color-w100: rgba(255, 255, 255, 1);
}

/* ── Section ── */
.washcode-section {
  margin: 10px 0 14px;
  background: #13141a;
  border: 1px solid rgba(180, 180, 195, 0.15);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ── Header ── */
.washcode-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(180, 180, 195, 0.08);
  background: linear-gradient(180deg, rgba(15, 17, 26, 0.98) 0%, rgba(10, 12, 20, 0.98) 100%);
}

.washcode-header i {
  color: #c8cdd8;
  font-size: 1.1rem;
}

.washcode-header-title {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #e8eaf0;
  margin: 0;
}

.washcode-count-badge {
  display: inline-block;
  background: rgba(180, 180, 195, 0.1);
  border: 1px solid rgba(180, 180, 195, 0.25);
  color: #a0a8b8;
  font-size: 9.5px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 99px;
}

.washcode-header-right {
  margin-left: auto;
  color: #3d4455;
  font-size: 11px;
}

/* ── List wrap ── */
.washcode-list-wrap {
  display: flex;
  align-items: stretch;
}

.washcode-rows-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.washcode-list .washcode-row.wc-hidden {
  display: none;
}

/* ── Row ── */
.washcode-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 13px 12px 13px 16px;
  position: relative;
  background: linear-gradient(180deg, #0e0f15 0%, #0b0c12 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background 0.18s;
  animation: wc-fade-up 0.35s ease both;
  gap: 10px;
}

.washcode-row:last-child {
  border-bottom: none;
}

.washcode-row.wc-row-expired {
  opacity: 0.55;
  filter: grayscale(40%);
}

.wc-expired-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #444;
  color: #bbb;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 20px;
  margin-right: 4px;
}

.wc-completed {
  color: #52c41a;
  font-size: 13px;
  font-weight: bold;
  margin-bottom: 4px;
}

.wc-completed i {
  margin-right: 4px;
}

.washcode-fill.wc-fill-done {
  background: linear-gradient(90deg, #52c41a, #95de64);
}

.washcode-row::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, #9ca3af, #6b7280);
  border-radius: 0 2px 2px 0;
  box-shadow: 0 0 6px rgba(156, 163, 175, 0.25);
}

/* ── 左區 ── */
.wc-left {
  flex: 0 0 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 200px;
}

.wc-title-row {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.wc-badge {
  display: inline-block;
  background: linear-gradient(135deg, rgb(0 0 0 / 41%), rgb(104 0 0 / 32%));
  color: #f1f5f9;
  font-size: 11px;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgb(163 71 71 / 45%);
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

.wc-brand {
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
  background: linear-gradient(135deg, #fef08a 0%, #eab308 50%, #d97706 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: #eab308;
}

.wc-name {
  color: #f1f5f9;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.wc-date {
  color: var(--color-w65);
  font-size: 9.5px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.wc-date i {
  font-size: 9.5px;
}

/* ── 中區：進度條 ── */
.wc-mid {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: rgba(0, 0, 0, 0.3);
  padding: 8px;
  border-radius: 6px;
  border: 0.5px solid rgba(156, 163, 175, 0.12);
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.6);
}

.wc-prog-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.washcode-pct {
  font-size: 12px;
  font-weight: 800;
  color: #e2e8f0;
}

.wc-vol {
  color: var(--color-w65);
  font-size: 9.5px;
  font-family: monospace;
}

.wc-vol-total {
  color: #e7e7e7;
  font-weight: bold;
}

.wc-vol.completed {
  color: #34d399;
}

.wc-vol.failed {
  color: #9ca3af;
}

.washcode-track {
  width: 100%;
  height: 7px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  overflow: hidden;
}

.washcode-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #ac2200, #c31800, #ff2d00);
  position: relative;
  box-shadow: 0 0 6px rgba(156, 163, 175, 0.2);
}

.washcode-fill.completed {
  background: linear-gradient(90deg, #064e3b, #059669, #10b981);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.washcode-fill.failed {
  background: linear-gradient(90deg, #374151, #4b5563, #9ca3af);
  box-shadow: 0 0 6px rgba(156, 163, 175, 0.1);
}

.washcode-fill::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 10px;
  background: rgba(255, 255, 255, 0.45);
  filter: blur(3px);
  border-radius: 99px;
}

/* ── 任務失敗狀態整列優化 ── */
.washcode-row.is-failed {
  opacity: 0.7;
}

.washcode-row.is-failed::before {
  background: #374151;
  box-shadow: none;
}

.washcode-row.is-failed .wc-name {
  color: #9ca3af;
}

.washcode-row.is-failed .wc-badge {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #6b7280;
}

.washcode-row.is-failed .wc-brand {
  background: none;
  -webkit-text-fill-color: #6b7280;
  color: #6b7280;
}

.washcode-row.is-failed .washcode-play-btn {
  background: transparent;
  color: #4b5563;
  box-shadow: none;
  cursor: not-allowed;
}

.washcode-row.is-failed .washcode-play-btn i {
  filter: none;
}

.washcode-row.is-failed .washcode-devote span i {
  color: #6b7280;
  filter: none;
}

.washcode-row.is-failed .washcode-tag {
  color: #6b7280;
}

/* ── 右區 ── */
.wc-right {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-shrink: 0;
}

.alignment-right {
  width: 300px;
}

.wc-payout {
  color: var(--color-w65);
  font-size: 9.5px;
}

/* --- 🌟 泡泡框功能 CSS START 🌟 --- */
.washcode-tag {
  font-size: 9.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
}

/* 標籤文字漸層色 */
.washcode-tag>span {
  color: #eab308;
}

/* 1. 泡泡框最外層觸發容器 */
.rank-tooltip-container {
  position: relative;
  display: inline-block;
  cursor: pointer;
}

/* 2. 旁邊的提示小圖示 ( i ) */
.rank-tooltip-container i.fa-circle-info {
  margin-left: 3px;
  font-size: 9.5px;
  opacity: 0.8;
  transition: opacity 0.2s;
  color: #eab308;
}

/* 3. 泡泡框本體 (毛玻璃 IOS 質感) */
.rank-tooltip {
  position: absolute;
  background: rgba(30, 35, 45, 0);
  -webkit-backdrop-filter: blur(16px) saturate(120%);
  backdrop-filter: blur(16px) saturate(120%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  
  /* ★ 移除 max-height 和 overflow-y，因為移到 inner 去了 */
  /* padding 移到 inner 確保滾動時邊緣不突兀 */
  width: 130px;
  
  opacity: 0;
  visibility: hidden;
  transform: translateY(5px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
  z-index: 99999;
  color: #e5e7eb;
  font-size: 10px;
  font-weight: normal;
  text-align: left;
  cursor: default;
}

/* ★ 4. 新增：氣泡窗內部的滾動層 */
.rank-tooltip-inner {
  max-height: 140px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 12px;
  border-radius: 8px; /* 確保滾動條不破壞四角圓邊 */
}

/* 滾動條美化 (現在對齊 inner) */
.rank-tooltip-inner::-webkit-scrollbar {
  width: 4px;
}

.rank-tooltip-inner::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

/* 5. 泡泡框下方的箭頭指標 (這會黏在外殼的底部，完美固定) */
.rank-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 15px;
  border-width: 5px;
  border-style: solid;
  border-color: rgb(76 76 76) transparent transparent transparent;
}

.rank-tooltip.show-tooltip-active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* 7. 泡泡框內部的每一行排名資料 */
.tooltip-rank-item {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.tooltip-rank-item:last-child {
  border-bottom: none;
}

.tooltip-rank-item .rank-num {
  color: #fbbf24;
  font-weight: bold;
  width: 20px;
}

.tooltip-rank-item .rank-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
  color: #9ca3af;
}

/* --- 🌟 泡泡框功能 CSS END 🌟 --- */

/* 貢獻者 */
.wc-devote {
  display: flex;
  justify-content: space-between;
  padding-right: 4px;
}

.washcode-devote {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 9.5px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--color-w100);
  min-width: 170px;
  justify-content: flex-start;
}

.washcode-devote span i {
  color: #ffdf00;
  filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.7));
}

.washcode-devote .idname {
  font-size: 12.5px;
  max-width: 8em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
  vertical-align: bottom;
  background: linear-gradient(135deg, #fef08a 0%, #eab308 50%, #d97706 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-decoration: underline;
}

/* ── 遊玩按鈕 ── */
.washcode-play-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #dc2626;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.18s;
  padding: 0;
}

.washcode-play-btn i {
  font-size: 26px;
  margin: 0;
  filter: drop-shadow(0 2px 4px rgba(220, 38, 38, 0.4));
}

.washcode-play-btn:active {
  transform: scale(0.96);
}

/* 手機按鈕桌機隱藏 */
.wc-play-mobile {
  display: none;
}

/* ── 右側垂直展開按鈕 ── */
.washcode-expand-btn {
  width: 28px;
  flex-shrink: 0;
  border: none;
  border-left: 1px solid rgba(180, 180, 195, 0.08);
  background: rgba(180, 180, 195, 0.03);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: rgba(160, 168, 184, 0.4);
  transition: background 0.2s, color 0.2s;
  gap: 4px;
  padding: 0;
}

.washcode-expand-btn .wc-exp-label {
  writing-mode: vertical-rl;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  white-space: nowrap;
  color: inherit;
}

.washcode-expand-btn i {
  font-size: 11px;
  transition: transform 0.25s;
  color: inherit;
}

.washcode-expand-btn.expanded i {
  transform: rotate(180deg);
}

/* ── Animations ── */
@keyframes wc-fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ★★★ 重點：隔離 Hover 特效，避免手機版滑動時卡住觸發 ★★★ */
@media (hover: hover) and (pointer: fine) {
  .washcode-row:hover {
    background: #13141a;
  }

  .washcode-row.is-failed .washcode-play-btn:hover {
    transform: none;
    background: transparent;
    color: #4b5563;
  }

  .rank-tooltip-container:hover i.fa-circle-info {
    opacity: 1;
  }

  .washcode-play-btn:hover {
    background: transparent;
    color: #ef4444;
    box-shadow: none;
    transform: scale(1.15);
  }

  .washcode-expand-btn:hover {
    background: rgba(180, 180, 195, 0.07);
    color: #a0a8b8;
  }
}

/* ── RWD Mobile ── */
@media (max-width: 576px) {
  .washcode-section {
    margin: 8px 0 10px;
    border-radius: 10px;
  }

  .washcode-row {
    flex-direction: column;
    align-items: stretch;
    padding: 10px 12px 10px 14px;
    gap: 6px;
  }

  .wc-left {
    width: 100%;
    box-sizing: border-box;
  }

  .wc-play-mobile {
    display: inline-flex;
    margin-left: auto;
    width: 26px;
    height: 26px;
  }

  .wc-play-mobile i {
    font-size: 24px;
  }

  .wc-play-pc {
    display: none;
  }

  .wc-mid {
    width: 100%;
    box-sizing: border-box;
  }

  .washcode-track {
    height: 6px;
  }

  .alignment-right {
    width: 100%;
    box-sizing: border-box;
  }

  .wc-devote {
    width: 100%;
    box-sizing: border-box;
    justify-content: space-between;
    padding-right: 0;
  }

  .wc-right {
    gap: 4px;
  }

  .wc-payout {
    font-size: 9.5px;
  }

  .washcode-expand-btn {
    width: 24px;
  }
}