/* ===== 我的钱包 / 银行卡 / 亲属卡 ===== */
/* 设计与理由见 PROMPT/22_我的钱包页.md
 * 页壳借 .ct-page 的变量、底色与滑入，只把层级抬到主页面之上；
 * 顶栏、分组标题、服务列表都是复用件，本文件只写钱包自己的部分。
 * 本文件禁止出现 backdrop-filter 和 will-change，滑入只动 transform。
 *
 * ★ 全站唯一的配色破例：银行卡卡面（.cw-face）用各家银行的主色，
 *   卡面之外的一切 —— 包括亲属卡卡面 —— 仍然严格灰阶、只取 base.css 的变量。
 *   破例只写在下面那组 [data-brand] 里，不要把这些色值扩散到别处。 */
.cw-page,
.cw-deck-page {
  --cw-face-h: 206px;            /* 卡面高，宽度撑满时接近真实卡的 1.6 比例 */
  --cw-face-r: 16px;
  --cw-peek: 64px;               /* 卡堆收起时每张露出的高度，够放下 logo 那一行 */
  --cw-card-bg: var(--c-surface);
}

.cw-page { z-index: 11; }        /* 压在 .ct-page（10）之上，与编辑资料页 / 会话页同级 */
.cw-deck-page { z-index: 12; }   /* 卡堆页从钱包页点进来，还要再高一层 */

/* 两张页面都没有底栏兜着，底部安全区改由滚动区自己加 */
.cw-page .ct-body,
.cw-deck-page .ct-body { padding-bottom: calc(24px + var(--sab)); }

/* 顶栏右上：只排版不响应点击，位置与 .ct-round 一致，但没有圆底也没有按压态 */
.cw-bill {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  margin: auto 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-hint);          /* reicon 内部用 currentColor */
}

/* ===== 零钱：整页唯一一块深底 ===== */
/* 取 --c-text 作底、--c-bg 作字，夜间模式跟着两个变量自动反过来，
 * 与名片上那颗 .ct-me-act.is-solid 是同一个做法 */
.cw-hero {
  margin-top: 20px;
  padding: 20px 22px 18px;
  border-radius: var(--r-lg);
  background: var(--c-text);
  color: var(--c-bg);
}

.cw-hero-label {
  font-size: var(--row-value-size);
  letter-spacing: 0.06em;
  opacity: 0.65;                 /* 深底上的次级字用透明度压，不引新色 */
}

.cw-hero-main {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 10px;
}

.cw-hero-sign {
  font-size: var(--row-name-size);
  font-weight: var(--metric-weight);
  opacity: 0.7;
}

/* 比 --metric-size 再大一档：这是整页的主角，:root 里没有这一档，本页局部定义一次 */
.cw-hero-num {
  font-size: 34px;
  font-weight: var(--metric-weight);
  line-height: 1.1;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}

.cw-hero-sub {
  margin-top: 8px;
  font-size: var(--row-value-size);
  line-height: 1.4;
  opacity: 0.55;
}

/* 两颗都是壳：描边取 currentColor 再压透明度，不响应点击也不给按压态 */
.cw-hero-acts {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.cw-hero-act {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  border: 1px solid currentColor;
  border-radius: var(--r-pill);
  font-size: var(--row-name-size);
  font-weight: var(--row-name-weight);
  opacity: 0.5;
}

/* ===== 银行卡卡面 ===== */
/* 排版照 PROMPT/IMG_8663.heic：左上 logo + 银行中英文名、右上等级、
 * 左中芯片、底部卡号与卡组织标识。三处复用同一份结构：
 * 钱包页入口（.is-mini）、卡堆、展开后的详情 */
.cw-face {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: var(--cw-face-h);
  padding: 16px 18px;
  border-radius: var(--cw-face-r);
  overflow: hidden;
  color: var(--face-fg);
  background: linear-gradient(148deg, var(--face-a) 0%, var(--face-b) 100%);
  box-shadow: var(--shadow-md);
}

/* 卡面上那层斜光：真卡的塑料反光，没有它整张卡是一块死色 */
.cw-face::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 80% at 82% 8%, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0) 55%),
    linear-gradient(118deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0) 46%);
}

/* 卡面内容全部压在斜光之上 */
.cw-face > * {
  position: relative;
  z-index: 1;
}

.cw-face-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 真实 logo 的槽：SVG 直接塞进来，尺寸由这里锁死。
 * 三个 logo 的 viewBox 都是 1325×1024、四周留白也接近，同一个槽下来视觉大小是齐的 */
.cw-face-logo {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 32px;
}
.cw-face-logo svg,
.cw-face-logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* 整体反白：logo 里的 fill 是写死的品牌色，红 logo 压在红卡上等于看不见。
 * brightness(0) 先把所有颜色压成黑（保留 alpha），invert(1) 再翻成白 ——
 * 真卡也是这么印的（品牌色卡面 + 白 logo）。不要改 SVG 文件里的 fill */
.cw-face-logo svg { filter: brightness(0) invert(1); }

/* 兜底方块：没有 SVG 的银行顶着，居中放在槽里，不跟着槽拉成长方形 */
.cw-face-logo-txt {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid currentColor;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  opacity: 0.9;
}

.cw-face-bank {
  flex: 1;
  min-width: 0;
}

.cw-face-cn {
  display: block;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cw-face-en {
  display: block;
  margin-top: 3px;
  font-size: 8px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.1em;
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 卡种等级（一卡通 / 私人银行）：与银行名同排，靠右 */
.cw-face-level {
  flex: none;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  opacity: 0.92;
}

/* 芯片是 CSS 画的：一块金属底 + 三道分割线，别换成图片 */
.cw-face-chip {
  position: relative;
  width: 38px;
  height: 28px;
  border-radius: 5px;
  background: linear-gradient(150deg, var(--face-chip-a) 0%, var(--face-chip-b) 100%);
}
.cw-face-chip::before,
.cw-face-chip::after {
  content: '';
  position: absolute;
  background: var(--face-b);
  opacity: 0.55;
}
.cw-face-chip::before {
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  margin-top: -0.5px;
}
.cw-face-chip::after {
  top: 4px;
  bottom: 4px;
  left: 38%;
  width: 1px;
}

.cw-face-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

/* 卡号只露首四位与末四位，中间统一是点 —— 卡面上不放完整卡号 */
.cw-face-no {
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 0.12em;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.cw-face-no b {
  font-weight: 500;
  letter-spacing: 0.04em;
  opacity: 0.8;
}

/* 卡种压在卡组织标识正上方，两行右对齐 */
.cw-face-marks {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}

/* 储蓄卡 / 信用卡：只有字，不加圈 —— 圈会把它抬得和卡号一样抢眼 */
.cw-face-kind {
  font-size: 10px;
  line-height: 1.3;
  letter-spacing: 0.06em;
  opacity: 0.75;
}

/* 卡组织标识的槽：拿到真实 SVG 后同样直接替换文字 */
.cw-face-net {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  opacity: 0.9;
}

/* 矮版：钱包页入口用。芯片跟着缩但不能删 —— 删了中间空一大块，就不像卡了 */
.cw-face.is-mini {
  height: 150px;
  padding: 14px 16px;
}
.cw-face.is-mini .cw-face-chip {
  width: 32px;
  height: 24px;
}
.cw-face.is-mini .cw-face-cn { font-size: 15px; }
.cw-face.is-mini .cw-face-no { font-size: 15px; }

/* ★ 配色破例只在这一组里。新增银行就在这里加一组，
 *   face-a 浅端 / face-b 深端 / face-fg 卡面字色 / face-chip-* 芯片金属色 */
.cw-face[data-brand="cmb"] {
  --face-a: #a8202a;
  --face-b: #6b1016;
  --face-fg: #ffffff;
  --face-chip-a: #e6d3a3;
  --face-chip-b: #bfa267;
}
.cw-face[data-brand="hsbc"] {
  --face-a: #35353a;
  --face-b: #101013;
  --face-fg: #f2f2f2;
  --face-chip-a: #dcdcdc;
  --face-chip-b: #9a9a9a;
}
.cw-face[data-brand="ccb"] {
  --face-a: #10528f;
  --face-b: #062c53;
  --face-fg: #ffffff;
  --face-chip-a: #e6d3a3;
  --face-chip-b: #bfa267;
}

/* ===== 亲属卡卡面 ===== */
/* 几何与银行卡同一套，配色留在灰阶：它不是银行发的卡，不参与上面那条破例 */
.cw-kface {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: var(--cw-face-h);
  padding: 18px;
  border-radius: var(--cw-face-r);
  overflow: hidden;
  color: var(--c-text);
  background: linear-gradient(148deg, var(--c-surface) 0%, var(--c-surface-3) 100%);
  /* 描边不能省：几张灰卡叠在一起时，全靠这条线分得出哪张压着哪张 ——
   * 银行卡有各自的主色，不需要它 */
  border: 1px solid var(--c-border-m);
  box-shadow: var(--shadow-md);
}

.cw-kface-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cw-kface-ico {
  flex: none;
  display: flex;
  align-items: center;
  color: var(--c-accent-dark);
}

.cw-kface-name {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cw-kface-tag {
  flex: none;
  padding: 2px 9px;
  border-radius: var(--r-pill);
  background: var(--c-bg);
  font-size: var(--label-size);
  font-weight: var(--label-weight);
  line-height: 1.4;
  color: var(--c-sub);
}

.cw-kface-quota {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.cw-kface-quota b {
  font-size: 26px;
  font-weight: var(--metric-weight);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.cw-kface-quota i {
  font-style: normal;
  font-size: var(--row-value-size);
  color: var(--c-sub);
}

.cw-kface-bar {
  display: block;
  height: 4px;
  border-radius: 2px;
  background: var(--c-bg);
  overflow: hidden;
}
.cw-kface-bar i {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--c-accent-dark);
}

.cw-kface-used {
  display: block;
  margin-top: 8px;
  font-size: var(--row-value-size);
  line-height: 1.3;
  color: var(--c-sub);
}

.cw-kface.is-mini {
  height: 150px;
  padding: 16px;
}
.cw-kface.is-mini .cw-kface-quota b { font-size: 22px; }

/* ===== 钱包页上的两个入口 ===== */
/* 一整块卡片就是按钮，不做成 Services 那种一行一行的列表 */
.cw-entry {
  display: block;
  width: 100%;
  padding: 0;
  text-align: left;
  transition: transform 0.15s var(--ease);
}
.cw-entry:active { transform: scale(0.985); }

/* 卡堆预览：两张灰影错开垫在真卡后面，读作「后面还有」 */
.cw-entry-deck {
  position: relative;
  display: block;
  padding-top: 18px;             /* 给灰影让出位置，够露两层 */
}

.cw-ghost {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 9px;
  height: 40px;
  border-radius: var(--cw-face-r);
  background: var(--c-surface-2);
  box-shadow: var(--shadow-sm);
}
/* 第二层再往里收一档、再往上抬一档，两层灰影才分得开 */
.cw-ghost.is-far {
  left: 24px;
  right: 24px;
  top: 0;
  background: var(--c-surface-3);
}

.cw-entry-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 4px 0;
}

.cw-entry-text {
  flex: 1;
  min-width: 0;
  font-size: var(--row-value-size);
  line-height: 1.3;
  color: var(--c-sub);
}

.cw-entry-go {
  flex: none;
  display: flex;
  align-items: center;
  color: var(--c-sub);
}

/* ===== 零钱通：一整行的宽卡 ===== */
.cw-fund {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-radius: var(--r-lg);
  background: var(--cw-card-bg);
}

.cw-fund-ico {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--c-bg);
  color: var(--c-accent-dark);
}

.cw-fund-main {
  flex: 1;
  min-width: 0;
  display: block;
}

.cw-fund-name {
  display: block;
  font-size: var(--row-name-size);
  font-weight: var(--page-title-weight);
  line-height: 1.3;
  color: var(--c-text);
}

.cw-fund-sub {
  display: block;
  margin-top: 4px;
  font-size: var(--row-value-size);
  line-height: 1.3;
  color: var(--c-sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cw-fund-side {
  flex: none;
  display: block;
  text-align: right;
}

.cw-fund-num {
  display: block;
  font-size: 17px;
  font-weight: var(--metric-weight);
  line-height: 1.2;
  color: var(--c-text);
  font-variant-numeric: tabular-nums;
}

.cw-fund-rate {
  display: block;
  margin-top: 4px;
  font-size: var(--row-value-size);
  line-height: 1.3;
  color: var(--c-hint);
  white-space: nowrap;
}

/* ===== 卡堆：银行卡页与亲属卡页共用 ===== */
/* 收起时几张卡竖向叠着只露顶边；展开时选中那张归到 top: 0，其余淡出，
 * 卡堆本身的高度收成一张卡，详情跟着顶上来。位置全靠 --i 算，JS 只打类 */
.cw-deck {
  position: relative;
  margin-top: 20px;
  height: calc(var(--cw-face-h) + (var(--cw-n) - 1) * var(--cw-peek));
  transition: height 0.32s var(--ease);
}
.cw-deck.is-open { height: var(--cw-face-h); }

.cw-deck-card {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--i) * var(--cw-peek));
  z-index: var(--i);             /* 后一张压在前一张上，与真卡堆一致 */
  display: block;
  padding: 0;
  text-align: left;
  transition:
    top 0.32s var(--ease),
    opacity 0.24s var(--ease),
    transform 0.24s var(--ease);
}
.cw-deck-card:active { transform: scale(0.985); }

.cw-deck.is-open .cw-deck-card.is-active {
  top: 0;
  z-index: 9;
}
/* 没被选中的那几张直接淡出：让位给下面的详情，也免得它们在展开态还能点 */
.cw-deck.is-open .cw-deck-card:not(.is-active) {
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
}

/* ===== 展开后的详情 ===== */
/* 折叠一律用 hidden 切换而不是高度动画：行数按卡种变，动画只会抖 */
.cw-detail { margin-top: 18px; }

.cw-fold {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  margin: 0 0 4px auto;
  padding: 0 12px;
  border-radius: var(--r-pill);
  background: var(--c-surface);
  font-size: var(--row-value-size);
  color: var(--c-sub);
  transition: background var(--dur) var(--ease);
}
.cw-fold:active { background: var(--c-surface-3); }

.cw-metric {
  margin-top: 14px;
  padding: 18px;
  border-radius: var(--r-lg);
  background: var(--cw-card-bg);
}

.cw-metric-label {
  font-size: var(--row-value-size);
  line-height: 1.3;
  color: var(--c-sub);
}

.cw-metric-main {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin-top: 8px;
}

.cw-metric-sign {
  font-size: var(--row-name-size);
  font-weight: var(--metric-weight);
  color: var(--c-sub);
}

.cw-metric-num {
  font-size: var(--metric-size);
  font-weight: var(--metric-weight);
  line-height: 1.1;
  color: var(--c-text);
  font-variant-numeric: tabular-nums;
}

.cw-metric-bar {
  height: 4px;
  margin-top: 14px;
  border-radius: 2px;
  background: var(--c-bg);
  overflow: hidden;
}
.cw-metric-bar i {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--c-accent-dark);
}

.cw-metric-sub {
  margin-top: 10px;
  font-size: var(--row-value-size);
  line-height: 1.3;
  color: var(--c-hint);
}

/* ===== 键值列表 ===== */
/* 与列表小节同一套做法：行间留 1px 透出页面底色，首尾收大角 */
.cw-kv-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.cw-kv {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 10px 18px;
  border-radius: var(--card-radius-in);
  background: var(--cw-card-bg);
}
.cw-kv-list .cw-kv:first-child {
  border-top-left-radius: var(--r-lg);
  border-top-right-radius: var(--r-lg);
}
.cw-kv-list .cw-kv:last-child {
  border-bottom-left-radius: var(--r-lg);
  border-bottom-right-radius: var(--r-lg);
}

.cw-kv-k {
  flex: none;
  font-size: var(--row-name-size);
  font-weight: var(--row-name-weight);
  color: var(--c-sub);
}

.cw-kv-v {
  flex: 1;
  min-width: 0;
  text-align: right;
  font-size: var(--row-name-size);
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== 消费明细 ===== */
.cw-bill-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.cw-bill-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 10px 18px;
  border-radius: var(--card-radius-in);
  background: var(--cw-card-bg);
}
.cw-bill-list .cw-bill-row:first-child {
  border-top-left-radius: var(--r-lg);
  border-top-right-radius: var(--r-lg);
}
.cw-bill-list .cw-bill-row:last-child {
  border-bottom-left-radius: var(--r-lg);
  border-bottom-right-radius: var(--r-lg);
}

.cw-bill-main {
  flex: 1;
  min-width: 0;
  display: block;
}

.cw-bill-name {
  display: block;
  font-size: var(--row-name-size);
  font-weight: var(--row-name-weight);
  line-height: 1.3;
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cw-bill-time {
  display: block;
  margin-top: 3px;
  font-size: var(--row-value-size);
  line-height: 1.3;
  color: var(--c-hint);
}

.cw-bill-num {
  flex: none;
  font-size: var(--row-name-size);
  font-weight: var(--metric-weight);
  color: var(--c-text);
  font-variant-numeric: tabular-nums;
}

/* ===== 详情里的三颗操作 ===== */
/* 都是壳：不响应点击也不给按压态 */
.cw-acts {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.cw-act {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 14px 6px;
  border-radius: var(--r-md);
  background: var(--cw-card-bg);
  color: var(--c-hint);
}

.cw-act-ico {
  display: flex;
  align-items: center;
}

.cw-act-name {
  font-size: var(--row-value-size);
  line-height: 1.3;
}

.cw-danger {
  margin-top: 24px;
  text-align: center;
  font-size: var(--row-name-size);
  line-height: 1.3;
  color: var(--c-hint);
}

/* ===== 页脚说明 ===== */
.cw-note {
  margin-top: 22px;
  text-align: center;
  font-size: var(--row-value-size);
  line-height: 1.5;
  color: var(--c-hint);
}

@media (prefers-reduced-motion: reduce) {
  .cw-deck,
  .cw-deck-card {
    transition: opacity 0.24s var(--ease);
  }
  .cw-entry:active,
  .cw-deck-card:active { transform: none; }
  .cw-deck.is-open .cw-deck-card:not(.is-active) { transform: none; }
}
