/* ============================================================
   集體洗碼任務模組 — washcode3.css  Version A
   黑銀金屬 80% + 橘紅 20%  ·  iOS Dark 質感
============================================================ */
:root {
  --wc-text: var(--ref-text, #363636);
  --wc-text-muted: var(--ref-text-muted, #666666);
  --wc-surface: var(--ref-surface, #ffffff);
  --wc-surface-2: #fafcfe;
  --wc-primary: var(--ref-primary, #003d79);
  --wc-secondary: var(--ref-secondary, #89c4f4);
  --wc-border: var(--ref-border, #dddddd);
  --wc-gold-hi: var(--ref-gold-hi, #f7e08f);
  --wc-gold: var(--ref-gold, #d4a150);
  --wc-gold-deep: var(--ref-gold-deep, #7e5b23);
  --wc-gold-bar: linear-gradient(
    90deg,
    #4a453c 0%,
    #7a6a4e 28%,
    #c5a059 58%,
    #e8d5a3 78%,
    #b8954a 100%
  );
}

/* ── Section：白卡片浮在淡藍灰頁底（參考站區塊法） ── */
.washcode-section {
  margin: 0;
  background: var(--wc-surface);
  border: 1px solid rgba(0, 61, 121, 0.1);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 61, 121, 0.06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--wc-text);
}

/* ── Header ── */
.washcode-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(0, 61, 121, 0.08);
  background: #ffffff;
}

.washcode-header i {
  color: var(--wc-gold, #d4a150);
  font-size: 1.1rem;
  filter: drop-shadow(0 0 8px rgba(212, 161, 80, 0.35));
}

.washcode-header-title {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--wc-primary);
  margin: 0;
}

.washcode-count-badge {
  display: inline-block;
  background: rgba(234, 136, 36, 0.12);
  border: 1px solid rgba(234, 136, 36, 0.35);
  color: #9a4f08;
  font-size: 9.5px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 99px;
}

.washcode-header-right {
  margin-left: auto;
  color: #7f89a1;
  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: #ffffff;
  border: 1px solid rgba(0, 61, 121, 0.08);
  border-radius: 10px;
  margin: 6px 8px;
  transition: background 0.18s, border-color 0.18s, box-shadow 0.18s;
  animation: wc-fade-up 0.35s ease both;
  gap: 10px;
  box-sizing: border-box;
}

.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: var(--wc-gold-bar);
  box-shadow: 0 0 8px rgba(184, 149, 74, 0.35);
}

.washcode-row::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: linear-gradient(180deg, #f7e08f 0%, #d4a150 55%, #7e5b23 100%);
  border-radius: 999px;
  box-shadow: 0 0 8px rgba(212, 161, 80, 0.28);
}

/* ── 左區 ── */
.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, rgba(0, 61, 121, 0.3), rgba(137, 196, 244, 0.26));
  color: #f1f5f9;
  font-size: 11px;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(0, 61, 121, 0.46);
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

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

.wc-name {
  color: #363636;
  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: #f5f8fc;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(0, 61, 121, 0.1);
  box-shadow: none;
}

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

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

.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: var(--wc-gold-deep);
  min-width: 0;
  white-space: normal;
  text-align: right;
  line-height: 1.35;
}

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

.washcode-track {
  width: 100%;
  height: 8px;
  background: rgba(74, 69, 60, 0.1);
  border-radius: 99px;
  overflow: hidden;
}

.washcode-fill {
  height: 100%;
  border-radius: 99px;
  /* 灰金金屬條：炭灰 → 古銅 → 香檳金，避免藍跳金 */
  background: var(--wc-gold-bar);
  position: relative;
  box-shadow: 0 0 8px rgba(126, 106, 78, 0.28);
}

.washcode-fill.completed {
  background: linear-gradient(
    90deg,
    #5c5346 0%,
    #8a7350 24%,
    #d4a150 55%,
    #f0e2b8 78%,
    #c5a059 100%
  );
  box-shadow: 0 0 10px rgba(212, 161, 80, 0.38);
}

.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(240, 226, 184, 0.45);
  filter: blur(3px);
  border-radius: 99px;
}

/* 進度條跑光：一道亮帶沿著已完成區段掃 */
.washcode-fill::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 99px;
  pointer-events: none;
  background-image: linear-gradient(100deg,
      rgba(255, 255, 255, 0) 0%,
      rgba(255, 253, 244, 0.1) 38%,
      rgba(255, 253, 244, 0.62) 50%,
      rgba(255, 253, 244, 0.1) 62%,
      rgba(255, 255, 255, 0) 100%);
  background-repeat: no-repeat;
  background-size: 56px 100%;
  animation: wc-fill-sweep 2.2s linear infinite;
}

/* 亮帶固定寬度：用 % 會跟著已填滿段縮放，進度少時被壓成一小點 */
@keyframes wc-fill-sweep {
  from { background-position: -56px 0; }
  to   { background-position: calc(100% + 56px) 0; }
}

.washcode-fill.failed::before {
  animation: none;
  background-image: none;
}

@media (prefers-reduced-motion: reduce) {
  .washcode-fill::before {
    animation: none;
    background-image: none;
  }
}

/* ── 首頁手點領：獎勵列＋領取鈕 ── */
.wc-claim-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 28px;
}

.wc-claim-rewards {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.wc-claim-reward {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 800;
  color: var(--wc-text, #363636);
}

.wc-claim-reward i {
  font-size: 14px;
  color: var(--wc-gold-deep, #7e5b23);
}

.wc-claim-wash {
  font-size: 10px;
  font-weight: 700;
  color: var(--wc-gold-deep, #7e5b23);
  background: rgba(212, 161, 80, 0.18);
  border-radius: 3px;
  padding: 1px 4px;
}

.wc-claim-btn {
  flex-shrink: 0;
  min-width: 66px;
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid var(--wc-primary, #003d79);
  background: var(--wc-primary, #003d79);
  color: #ffffff;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
}

.wc-claim-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.wc-vol.ineligible {
  color: #b45309;
}

.wc-vol.settling {
  color: var(--wc-primary, #003d79);
}

/* ── 任務失敗狀態整列優化 ── */
.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: #ffffff;
  border: 1px solid rgba(0, 61, 121, 0.12);
  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 {
  background: #f3f4f6;
  border-color: rgba(107, 114, 128, 0.28);
  color: #6b7280;
}

.washcode-row.is-failed .washcode-tag > span {
  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: 12.5px;
}

/* --- 🌟 泡泡框功能 CSS START 🌟 --- */
.washcode-tag {
  font-size: 9.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 99px;
  background: rgba(0, 61, 121, 0.08);
  border: 1px solid rgba(0, 61, 121, 0.18);
}

/* 標籤文字：加深對比，避免淺藍難讀 */
.washcode-tag > span {
  color: var(--ref-primary, #003d79);
}

.washcode-tag.restricted {
  background: rgba(0, 61, 121, 0.08);
  border-color: rgba(0, 61, 121, 0.2);
}

.washcode-tag.restricted > span {
  color: var(--ref-primary, #003d79);
}

.washcode-tag.winner {
  background: rgba(212, 161, 80, 0.14);
  border-color: rgba(212, 161, 80, 0.35);
}

.washcode-tag.winner > span {
  color: var(--ref-gold-deep, #7e5b23);
}

.washcode-tag.open {
  background: rgba(0, 86, 163, 0.08);
  border-color: rgba(0, 86, 163, 0.22);
}

.washcode-tag.open > span {
  color: var(--ref-primary-hover, #0056a3);
}

/* 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: #003d79;
}

/* 3. 泡泡框本體（XHE 淺底：半透明白＋模糊，暱稱才讀得到） */
.rank-tooltip {
  position: absolute;
  /* 預設釘在左上，避免未觸發時停在 body 尾端（靜態位置）撐出頁面可捲動高度；
     hover 時 JS 會覆寫成正確座標 */
  top: 0;
  left: 0;
  background: rgba(255, 255, 255, 0.94);
  -webkit-backdrop-filter: blur(16px) saturate(120%);
  backdrop-filter: blur(16px) saturate(120%);
  border: 1px solid rgba(0, 61, 121, 0.14);
  box-shadow: 0 8px 24px rgba(0, 61, 121, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  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: var(--ref-text, #363636);
  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(0, 61, 121, 0.22);
  border-radius: 4px;
}

/* 5. 泡泡框下方的箭頭指標 (這會黏在外殼的底部，完美固定) */
.rank-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 58px;
  border-width: 5px;
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.94) 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(0, 61, 121, 0.08);
}

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

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

.tooltip-rank-item .rank-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
  color: var(--ref-text, #363636);
  font-weight: 600;
}

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

/* 貢獻者 */
.wc-devote {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding-right: 4px;
}

/* 上下兩列（貢獻英雄／獎勵對象）：標籤等寬，值左邊界對齊 */
.wc-info-row {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.wc-info-row .wc-lbl {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  white-space: nowrap;
}

/* 貢獻英雄那行原本 gap 3px，補成 4px 讓兩行的值起點完全一致 */
.wc-info-row.washcode-devote {
  gap: 4px;
}

.wc-target-val {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--wc-text, #363636);
  white-space: nowrap;
}

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

.washcode-devote span i {
  color: #0056a3;
  filter: drop-shadow(0 0 6px rgba(137, 196, 244, 0.5));
}

.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, #0056a3 0%, #003d79 58%, #0056a3 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-decoration: underline;
}

/* ── 遊玩按鈕：參考站深藍圓鈕（fa-circle-play 自帶圓形） ── */
.washcode-play-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--wc-primary, #003d79);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.18s;
  padding: 0;
  position: relative;
  left: -10px;
}

.washcode-play-btn i,
.washcode-play-btn .svg-inline--fa {
  font-size: 26px;
  width: auto;
  height: 26px;
  margin: 0;
  filter: drop-shadow(0 2px 6px rgba(0, 61, 121, 0.28));
  transform-origin: center;
  animation: wc-play-breath 2.4s ease-in-out infinite;
}

/* 呼吸：只動圖示本體，按鈕的 hover/active 縮放不受影響 */
@keyframes wc-play-breath {
  0%, 100% {
    transform: scale(1);
    filter: drop-shadow(0 2px 5px rgba(0, 61, 121, 0.24));
  }
  50% {
    transform: scale(1.12);
    filter: drop-shadow(0 2px 10px rgba(0, 61, 121, 0.55));
  }
}

.washcode-row.is-failed .washcode-play-btn i,
.washcode-row.is-failed .washcode-play-btn .svg-inline--fa {
  animation: none;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .washcode-play-btn i,
  .washcode-play-btn .svg-inline--fa {
    animation: none;
  }
}

.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(0, 61, 121, 0.16);
  background: rgba(0, 61, 121, 0.06);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: rgba(169, 180, 203, 0.55);
  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:
      radial-gradient(130% 160% at 8% 0%, rgba(247, 224, 143, 0.28) 0%, rgba(212, 161, 80, 0) 55%),
      #fffaf0;
    border: 1px solid var(--ref-gold-line, rgba(212, 161, 80, 0.42));
    box-shadow: 0 4px 14px rgba(212, 161, 80, 0.12);
  }

  .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: var(--ref-primary-hover, #0056a3);
    box-shadow: none;
    transform: scale(1.12);
  }

  .washcode-expand-btn:hover {
    background: rgba(0, 61, 121, 0.12);
    color: #89c4f4;
  }
}

/* ── RWD Mobile ── */
@media (max-width: 576px) {
  .washcode-section {
    margin: 0;
    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: auto;
    min-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;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding-right: 0;
  }

  /* 手機版左右一列，兩塊各自貼齊邊 */
  .wc-devote>.washcode-devote {
    min-width: 0;
  }

  .wc-right {
    gap: 4px;
  }

  .wc-payout,
  .wc-target-val,
  .washcode-tag {
    font-size: 9.5px;
  }

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