/* ============================================================================
 * cards.css —— 实体收藏卡装裱工艺 (Card Frame & Foil Sheen) / 物理手牌 / 暴击特效
 * 说明：本文件在 style.css 之后加载，卡牌与特效样式以本文件为准
 * ========================================================================== */

/* ---------------------------------------------------------------------------
 * 1. 实体铜版纸收藏卡装裱（2:3 裁切 + 1.5px 金属倒角内边框 + 深邃浮动投影 + 斜向流光扫光）
 * ------------------------------------------------------------------------- */
.card {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: 9.5px;
  overflow: hidden;
  flex: 0 0 auto;
  background: #14100b;
  box-shadow:
    0 1.5px 0 rgba(255, 248, 225, .36) inset,
    0 -2px 5px rgba(0, 0, 0, .55) inset,
    0 3px 5px rgba(0, 0, 0, .65),
    0 10px 22px rgba(0, 0, 0, .58),
    0 0 0 1.5px rgba(212, 175, 55, .42);
  transition: transform .17s var(--ease-out-soft),
              box-shadow .2s ease, opacity .2s ease, filter .3s ease;
  will-change: transform;
}

/* 1.5px 金属倒角内边框与出血装裱线 */
.card::before {
  content: '';
  position: absolute;
  inset: 2.5px;
  border-radius: 7.5px;
  border: 1.5px solid rgba(255, 243, 196, .34);
  box-shadow: inset 0 0 0 0.8px rgba(0, 0, 0, .5);
  z-index: 3;
  pointer-events: none;
}

/* 铜版纸烫金光泽斜向流光扫光（Foil Sheen） */
.card::after {
  content: '';
  position: absolute;
  inset: -45%;
  z-index: 3;
  pointer-events: none;
  background: linear-gradient(
    115deg,
    transparent 35%,
    rgba(255, 246, 210, .32) 48%,
    rgba(255, 255, 255, .14) 53%,
    transparent 65%
  );
  transform: translate3d(-125%, -20%, 0);
  transition: transform .55s cubic-bezier(.22, .9, .3, 1);
}
.hand .card.playable:hover::after,
.hand .card.wave-0::after,
.hand .card.wave-l1::after,
.hand .card.wave-r1::after,
.hand .card.drawn-hot::after {
  transform: translate3d(125%, 20%, 0);
}

/* 版权保护 Canvas 图层（取代 <img> 直出，含隐形盲水印） */
.card canvas.card-canvas,
.card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: inherit;
  z-index: 2;
  pointer-events: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  user-select: none;
}

/* 顶层透明交互代理层（Event Proxy）：任何长按或拖拽只能触发游戏交互，无法触达画布底层 */
.card .card-proxy {
  position: absolute;
  inset: 0;
  z-index: 4;
  border-radius: inherit;
  background: transparent;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  user-select: none;
}

.card.no-img canvas.card-canvas,
.card.no-img img { display: none; }

/* ---------------------------------------------------------------------------
 * 2. 无图典藏级纯 CSS 兜底牌面：经典倾斜椭圆徽标 + Fredoka / Titan One 硬边立体大字
 * ------------------------------------------------------------------------- */
.fb {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: inherit;
  overflow: hidden;
  background: #231b12;
}
.fb::before {
  content: '';
  position: absolute;
  inset: 5px;
  border-radius: 6px;
  border: 1.5px solid rgba(255, 243, 196, .35);
  pointer-events: none;
}
.fb::after {
  content: '';
  position: absolute;
  left: 9%; right: 9%; top: 12%; bottom: 12%;
  border-radius: 50% / 42%;
  background: rgba(255, 248, 225, .15);
  border: 1px solid rgba(255, 243, 196, .24);
  transform: rotate(-24deg);
  pointer-events: none;
}
.fb-corner {
  position: absolute;
  z-index: 2;
  font-family: var(--font-display);
  font-size: clamp(8px, 1.45vh, 12px);
  font-weight: 900;
  line-height: 1;
  color: #fff9e6;
  text-shadow: 0 2px 0 #000, 0 2px 4px rgba(0, 0, 0, .65);
  pointer-events: none;
}
.fb-corner.tl { top: 7px; left: 8px; }
.fb-corner.br { bottom: 7px; right: 8px; transform: rotate(180deg); }

.fb-glyph {
  position: relative;
  z-index: 2;
  font-family: var(--font-display);
  font-size: clamp(20px, 4.5vh, 38px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -.5px;
  color: #fff9e6;
  -webkit-text-stroke: 1.2px #1c0e02;
  text-shadow:
    0 3px 0 #000,
    0 5px 10px rgba(0, 0, 0, .65);
}
.fb-lbl {
  position: relative;
  z-index: 2;
  font-size: clamp(7px, 1.35vh, 10px);
  font-weight: 900;
  letter-spacing: .5px;
  color: rgba(255, 248, 225, .94);
  text-shadow: 0 2px 0 #000;
}
.fb-red    { background: linear-gradient(155deg, #e04238 0%, #a81910 54%, #5e0a05 100%); }
.fb-yellow { background: linear-gradient(155deg, #f2c43d 0%, #c48808 52%, #6e4600 100%); }
.fb-green  { background: linear-gradient(155deg, #42b568 0%, #167a38 52%, #083d19 100%); }
.fb-blue   { background: linear-gradient(155deg, #4b86e3 0%, #19489e 52%, #091f4f 100%); }
.fb-wild   { background: conic-gradient(from 210deg, #a81910 0 25%, #c48808 0 50%, #167a38 0 75%, #19489e 0); }
.fb-back   { background: radial-gradient(circle at 50% 45%, #302214 0%, #171009 65%, #0a0704 100%); }

.hand .fb-glyph { font-size: clamp(13px, calc(var(--hand-w) * .44), 34px); }
.hand .fb-lbl { font-size: clamp(5px, calc(var(--hand-w) * .13), 9px); letter-spacing: 0; }
.hand .fb-corner { font-size: clamp(7px, calc(var(--hand-w) * .15), 11px); }
.opp-cards .fb-glyph,
.opp-cards .fb-lbl,
.opp-cards .fb-corner { display: none; }

.card.deal-in { animation: dealIn .34s var(--ease-out-soft) both; }
.card.drop-in { animation: dropIn .4s var(--ease-pop) both; }

/* ---------------------------------------------------------------------------
 * 3. 对手区扇形迷你手牌叠
 * ------------------------------------------------------------------------- */
.opp-cards .card {
  width: calc(var(--pile-w) * .42);
  margin-left: -13px;
  box-shadow:
    0 2px 6px rgba(0, 0, 0, .68),
    0 0 0 1px rgba(212, 175, 55, .36);
}
.opp-cards .card:first-child { margin-left: 0; }

/* ---------------------------------------------------------------------------
 * 4. 弃牌堆：最近 5 张微倾叠放残影 + 拖拽磁吸高亮
 * ------------------------------------------------------------------------- */
#discard .card {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform-origin: 50% 88%;
}
#discard.magnet-hot {
  transform: scale3d(1.07, 1.07, 1);
  box-shadow:
    0 0 0 3px var(--gold-bright),
    0 0 36px rgba(212, 175, 55, .92) !important;
}

/* ---------------------------------------------------------------------------
 * 5. 手牌区（含 >10 张密集手牌《炉石传说》式波浪推开预览 + 物理拖拽）
 * ------------------------------------------------------------------------- */
.hand-area {
  position: relative;
  z-index: 30;
  flex: 0 0 auto;
  padding: 0 10px;
  min-height: calc(var(--hand-w) * 1.5 + 64px);
  overflow: visible;
}

.hand {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-end;
  justify-content: center;
  gap: 5px;
  height: auto;
  min-height: calc(var(--hand-w) * 1.5 + 32px);
  margin-top: 4px;
  padding: 36px 40px 10px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
  -webkit-touch-callout: none;
  scrollbar-width: thin;
  scrollbar-color: rgba(212, 175, 55, .3) transparent;
}
.hand.is-scrollable {
  justify-content: flex-start;
}
.hand.dense:not(.grid-rows) {
  margin-top: 4px;
  padding: 36px 40px 10px;
  overflow-x: auto;
  overflow-y: hidden;
}
.hand.dense { gap: 0; }
.hand.dense .card + .card { margin-left: clamp(-22px, -2.4vw, -10px); }

.hand::-webkit-scrollbar { height: 4px; }
.hand::-webkit-scrollbar-thumb { background: rgba(212, 175, 55, .3); border-radius: 4px; }
.hand::-webkit-scrollbar-track { background: transparent; }

.hand .card {
  width: var(--hand-w);
  cursor: default;
  transform: translate3d(0, 0, 0);
  touch-action: none;
}

/* 可出牌：平滑上浮 12px + 哑光香槟金呼吸外轮廓描边（绝不遮挡自定义卡面插画） */
.hand .card.playable {
  transform: translate3d(0, -12px, 0);
  box-shadow:
    0 0 0 2px var(--gold-light),
    0 0 18px rgba(212, 175, 55, .55),
    0 12px 24px rgba(0, 0, 0, .65);
  animation: playableGlow 2.2s ease-in-out infinite;
  cursor: grab;
}
.hand .card.playable:hover {
  transform: translate3d(0, -22px, 0) scale3d(1.09, 1.09, 1);
  z-index: 18;
  box-shadow:
    0 0 0 2.5px var(--gold-bright),
    0 0 28px rgba(212, 175, 55, .82),
    0 18px 32px rgba(0, 0, 0, .72);
}
.hand .card.playable:active { transform: translate3d(0, -16px, 0) scale3d(.99, .99, 1); }

/* 摸牌即出高亮目标牌 */
.hand .card.drawn-hot {
  transform: translate3d(0, -24px, 0) scale3d(1.08, 1.08, 1) !important;
  z-index: 22 !important;
  box-shadow:
    0 0 0 2.5px #fff3c4,
    0 0 30px rgba(242, 184, 26, .92),
    0 16px 30px rgba(0, 0, 0, .7) !important;
}

/* 不可出牌：轻微压暗 */
.hand .card.dim { opacity: .48; filter: saturate(.72) brightness(.88); }
.hand .card:hover:not(.playable) { transform: translate3d(0, -4px, 0); }

/* 《炉石传说》式波浪式依次抬起放大并推开相邻卡牌（纯 translate3d 零重排） */
.hand .card.wave-0 {
  transform: translate3d(0, -28px, 0) scale3d(1.16, 1.16, 1) !important;
  z-index: 25 !important;
}
.hand .card.wave-l1 {
  transform: translate3d(-14px, -16px, 0) scale3d(1.06, 1.06, 1) !important;
  z-index: 20 !important;
}
.hand .card.wave-r1 {
  transform: translate3d(14px, -16px, 0) scale3d(1.06, 1.06, 1) !important;
  z-index: 20 !important;
}
.hand .card.wave-l2 {
  transform: translate3d(-7px, -7px, 0) scale3d(1.02, 1.02, 1) !important;
  z-index: 15 !important;
}
.hand .card.wave-r2 {
  transform: translate3d(7px, -7px, 0) scale3d(1.02, 1.02, 1) !important;
  z-index: 15 !important;
}

/* 物理跟手拖拽中 */
.card.dragging {
  transition: none !important;
  animation: none !important;
  z-index: 95 !important;
  cursor: grabbing !important;
  pointer-events: none;
  box-shadow:
    0 0 0 2px var(--gold-bright),
    0 26px 48px rgba(0, 0, 0, .78),
    0 0 28px rgba(212, 175, 55, .58) !important;
}
.card.dragging.release-ready {
  box-shadow:
    0 0 0 3px #fff5cc,
    0 28px 54px rgba(0, 0, 0, .82),
    0 0 40px rgba(212, 175, 55, .95) !important;
}

/* 等待房主确认中 */
.hand .card.pending {
  transform: translate3d(0, -18px, 0) scale3d(.97, .97, 1);
  opacity: .78;
  box-shadow: 0 0 0 2px var(--gold-light), 0 12px 24px rgba(0, 0, 0, .6);
}
.hand .card.pending::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  z-index: 3;
  pointer-events: none;
  box-shadow: inset 0 0 0 2px var(--gold-light);
  animation: pendingPulse 1s ease-in-out infinite;
}

/* 误触抖动 */
.card.shake { animation: cardShake .46s cubic-bezier(.36, .07, .19, .97); }

/* ---------------------------------------------------------------------------
 * 6. 图鉴里的迷你收藏牌面
 * ------------------------------------------------------------------------- */
.mini {
  position: relative;
  width: 42px;
  aspect-ratio: 2 / 3;
  flex: 0 0 auto;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 16px;
  color: #fff9e6;
  text-shadow: 0 2px 0 #000, 0 3px 6px rgba(0, 0, 0, .6);
  box-shadow:
    0 4px 10px rgba(0, 0, 0, .6),
    inset 0 0 0 1.5px rgba(255, 243, 196, .35);
  transform: rotate(-3deg);
  overflow: hidden;
}
.mini::after {
  content: '';
  position: absolute;
  left: 12%; right: 12%; top: 14%; bottom: 14%;
  border-radius: 50% / 42%;
  background: rgba(255, 255, 255, .16);
  transform: rotate(-24deg);
}
.mini span { position: relative; z-index: 1; }
.mini.red    { background: linear-gradient(155deg, #e04238, #99140c); }
.mini.yellow { background: linear-gradient(155deg, #f2c43d, #a87003); }
.mini.green  { background: linear-gradient(155deg, #42b568, #0f692d); }
.mini.blue   { background: linear-gradient(155deg, #4b86e3, #113c8a); }
.mini.wild   { background: conic-gradient(from 200deg, #99140c 0 25%, #a87003 0 50%, #0f692d 0 75%, #113c8a 0); }
.mini.dark   { background: linear-gradient(155deg, #3b3228, #14100b); border: 1px solid var(--gold); }

/* ---------------------------------------------------------------------------
 * 7. 街机级立体冲击特效：+2! / +4! / 跳过! / UNO!（Fredoka / Titan One + 硬边深色投影）
 * ------------------------------------------------------------------------- */
.impact {
  position: relative;
  font-family: var(--font-display);
  font-size: clamp(62px, 17vmin, 154px);
  font-weight: 900;
  letter-spacing: 1px;
  line-height: 1;
  -webkit-text-stroke: 3px #1c0d02;
  text-shadow:
    0 6px 0 #000,
    0 10px 0 rgba(0, 0, 0, .55),
    0 0 42px currentColor,
    0 18px 44px rgba(0, 0, 0, .78);
  animation: impactPop .95s cubic-bezier(.2, 1.2, .3, 1) forwards;
  will-change: transform, opacity;
}

.uno-wave {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46vmin;
  height: 46vmin;
  margin: -23vmin 0 0 -23vmin;
  border-radius: 50%;
  border: 3.5px solid var(--gold-bright);
  box-shadow:
    0 0 48px rgba(212, 175, 55, .9),
    inset 0 0 60px rgba(212, 175, 55, .5);
  animation: unoWave 1.05s cubic-bezier(.15, .8, .3, 1) forwards;
  pointer-events: none;
  will-change: transform, opacity;
}

.fx-p {
  position: absolute;
  left: var(--ox, 50%);
  top: var(--oy, 50%);
  width: var(--sz, 9px);
  height: calc(var(--sz, 9px) * 1.45);
  border-radius: 2px;
  background: var(--c, #d4af37);
  border: 0.5px solid rgba(255, 248, 220, .45);
  box-shadow: 0 0 10px var(--c, #d4af37);
  pointer-events: none;
  animation: fxBurst var(--dur, .92s) cubic-bezier(.16, .88, .3, 1) forwards;
  will-change: transform, opacity;
}

.vfx-shockwave {
  position: absolute;
  left: var(--ox, 50%);
  top: var(--oy, 50%);
  width: 24vmin;
  height: 24vmin;
  margin: -12vmin 0 0 -12vmin;
  border-radius: 50%;
  border: 3.5px solid var(--c, #d4af37);
  box-shadow:
    0 0 42px var(--c, #d4af37),
    inset 0 0 42px var(--c, #d4af37);
  pointer-events: none;
  animation: wildShockwave .88s cubic-bezier(.16, .84, .32, 1) forwards;
  will-change: transform, opacity;
}

.vfx-proj {
  position: absolute;
  left: 0;
  top: 0;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff9e6 0%, var(--c, #e5342b) 55%, transparent 100%);
  box-shadow:
    0 0 24px var(--c, #e5342b),
    0 0 46px var(--c, #e5342b);
  pointer-events: none;
  will-change: transform, opacity;
}

.vfx-crit-float {
  position: absolute;
  left: var(--ox, 50%);
  top: var(--oy, 50%);
  font-family: var(--font-display);
  font-size: clamp(28px, 6vmin, 46px);
  font-weight: 900;
  letter-spacing: 0;
  color: var(--c, #ff5f5f);
  -webkit-text-stroke: 1.8px #1c0d02;
  text-shadow:
    0 4px 0 #000,
    0 0 24px var(--c, #ff5f5f);
  pointer-events: none;
  animation: critFloatPop .95s cubic-bezier(.2, 1.35, .36, 1) forwards;
  will-change: transform, opacity;
}

/* ---------------------------------------------------------------------------
 * 8. 关键帧
 * ------------------------------------------------------------------------- */
@keyframes dealIn {
  from { opacity: 0; transform: translate3d(0, -28px, 0) scale3d(.85, .85, 1); }
  to { opacity: 1; transform: translate3d(0, 0, 0) scale3d(1, 1, 1); }
}
@keyframes dropIn {
  0% { opacity: 0; transform: scale3d(1.35, 1.35, 1) rotate(-6deg); }
  60% { opacity: 1; }
  100% { opacity: 1; transform: scale3d(1, 1, 1) rotate(0deg); }
}
@keyframes pendingPulse {
  0%, 100% { opacity: .25; }
  50% { opacity: .9; }
}
@keyframes playableGlow {
  0%, 100% {
    box-shadow:
      0 0 0 2px var(--gold),
      0 0 14px rgba(212, 175, 55, .42),
      0 9px 18px rgba(0, 0, 0, .58);
  }
  50% {
    box-shadow:
      0 0 0 2.5px var(--gold-bright),
      0 0 26px rgba(212, 175, 55, .78),
      0 11px 22px rgba(0, 0, 0, .64);
  }
}
@keyframes cardShake {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
  14% { transform: translate3d(-7px, 0, 0) rotate(-2deg); }
  30% { transform: translate3d(7px, 0, 0) rotate(2deg); }
  46% { transform: translate3d(-5px, 0, 0) rotate(-1.4deg); }
  62% { transform: translate3d(5px, 0, 0) rotate(1.4deg); }
  80% { transform: translate3d(-2px, 0, 0) rotate(-.6deg); }
}
@keyframes impactPop {
  0% { opacity: 0; transform: translate3d(0, 0, 0) scale3d(.4, .4, 1) rotate(-8deg); }
  22% { opacity: 1; transform: translate3d(0, 0, 0) scale3d(1.14, 1.14, 1) rotate(2deg); }
  40% { transform: translate3d(0, 0, 0) scale3d(1, 1, 1) rotate(0deg); }
  72% { opacity: 1; transform: translate3d(0, 0, 0) scale3d(1, 1, 1); }
  100% { opacity: 0; transform: translate3d(0, -26px, 0) scale3d(1.1, 1.1, 1); }
}
@keyframes unoWave {
  0% { opacity: .95; transform: scale3d(.25, .25, 1); }
  70% { opacity: .5; }
  100% { opacity: 0; transform: scale3d(1.9, 1.9, 1); }
}
@keyframes wildShockwave {
  0% { opacity: .95; transform: scale3d(.18, .18, 1); }
  65% { opacity: .55; }
  100% { opacity: 0; transform: scale3d(3.4, 3.4, 1); }
}
@keyframes critFloatPop {
  0% { opacity: 0; transform: translate3d(-50%, 6px, 0) scale3d(.35, .35, 1) rotate(-10deg); }
  28% { opacity: 1; transform: translate3d(-50%, -14px, 0) scale3d(1.24, 1.24, 1) rotate(4deg); }
  52% { opacity: 1; transform: translate3d(-50%, -10px, 0) scale3d(1, 1, 1) rotate(0deg); }
  100% { opacity: 0; transform: translate3d(-50%, -34px, 0) scale3d(.92, .92, 1) rotate(0deg); }
}
@keyframes fxBurst {
  0% { opacity: 1; transform: translate3d(-50%, -50%, 0) scale3d(.5, .5, 1) rotate(0deg); }
  70% { opacity: .92; }
  100% { opacity: 0; transform: translate3d(calc(-50% + var(--tx, 0px)), calc(-50% + var(--ty, 0px)), 0) scale3d(1, 1, 1) rotate(var(--rot, 220deg)); }
}

/* ---------------------------------------------------------------------------
 * 9. 响应式
 * ------------------------------------------------------------------------- */
@media (max-width: 430px) {
  .hand { margin-top: 4px; padding: 32px 34px 8px; gap: 3px; }
  .hand.dense:not(.grid-rows) { margin-top: 4px; padding: 32px 34px 8px; }
  .hand .fb-lbl { display: none; }
  .opp-cards .card { width: calc(var(--pile-w) * .34); margin-left: -13px; }
  .hand-area { min-height: calc(var(--hand-w) * 1.5 + 64px); }
  .impact { font-size: clamp(50px, 20vmin, 114px); }
  .uno-wave { width: 70vmin; height: 70vmin; }
}

@media (max-height: 560px) {
  .hand { margin-top: 2px; padding: 26px 34px 6px; height: auto; }
  .hand.dense:not(.grid-rows) { margin-top: 2px; padding: 26px 34px 6px; }
  .hand-area { min-height: calc(var(--hand-w) * 1.5 + 50px); }
  .opp-cards .card { width: calc(var(--pile-w) * .34); margin-left: -10px; }
}
