/* public/styles/cards.css
 *
 * 纸牌类游戏（Briscola / Scopa / Belote / Skat / Mau-Mau / Cribbage …）共用的
 * 牌面与牌桌样式。
 *
 * 为什么放 public/styles/ 而不是各组件里的 <style is:global>：
 *   本站 1400+ 页，Astro 会把小于 4KB 的组件 scoped style 内联进**每一个**
 *   引用它的页面。十来款牌戏逐份复制同一套牌面 CSS，等于把这些字节乘十几遍
 *   写进产物，而且改一次要改十几处。放这里只有一份，还能被浏览器缓存。
 *   （同款理由见 public/styles/tool-shells.css 与 AGENTS.md 的说明。）
 *
 * 由 src/layouts/DocLayout.astro 在 pageType === 'game' 时 link 进来。
 * 新增牌戏直接复用 .cg-* 类，不要在自己组件里重写牌面。
 *
 * 配色约束（见 AGENTS.md 壁纸章节）：7 套壁纸里 sunset 是深色底，
 * 所以牌桌面板一律半透明深色 + 浅色描边，牌面一律不透明浅色 ——
 * 两者叠在任何壁纸上都成立。
 */

/* ------------------------------------------------------------------ */
/* 牌面                                                                */
/* ------------------------------------------------------------------ */

.cg-card {
  --cg-w: 46px;
  position: relative;
  width: var(--cg-w);
  height: calc(var(--cg-w) * 1.45);
  flex: 0 0 auto;
  border-radius: calc(var(--cg-w) * 0.14);
  background: #FBFAF7;
  border: 1px solid rgba(0, 0, 0, 0.16);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16);
  color: #2C3230;
  font-family: inherit;
  font-weight: 700;
  line-height: 1;
  user-select: none;
  box-sizing: border-box;
  overflow: hidden;
  transition: transform 0.14s, box-shadow 0.14s, border-color 0.14s;
}

.cg-card.red { color: #C0432E; }
.cg-card.black { color: #2C3230; }

/* 牌角：左上角点数 + 花色，右下角镜像 */
.cg-card .cg-corner {
  position: absolute;
  top: 5%;
  left: 8%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  font-size: calc(var(--cg-w) * 0.3);
}
.cg-card .cg-corner.br {
  top: auto;
  left: auto;
  bottom: 5%;
  right: 8%;
  transform: rotate(180deg);
}
.cg-card .cg-pip {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cg-w) * 0.52);
  opacity: 0.9;
}

/* 已打出的牌 / 手牌里更小的展示位 */
.cg-card.mini { --cg-w: 34px; }
.cg-card.small { --cg-w: 40px; }
.cg-card.big { --cg-w: 62px; }

/* 牌背：用于对手手牌、牌堆 */
.cg-card.back {
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.14) 0 4px, transparent 4px 8px),
    var(--cg-back, #5B7B9A);
  border-color: rgba(0, 0, 0, 0.24);
  color: transparent;
}
.cg-card.back > * { visibility: hidden; }

/* 可选：可点击的手牌 */
.cg-card.pick { cursor: pointer; }
.cg-card.pick:hover { transform: translateY(-8px); box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24); }
.cg-card.pick:focus-visible { outline: 2px solid var(--cg-accent, #5B7B9A); outline-offset: 2px; }

/* 合法 / 不合法（当前不能出） */
.cg-card.playable { box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2), 0 0 0 2px var(--cg-accent, #5B7B9A); }
.cg-card.dead { opacity: 0.5; filter: grayscale(0.55); }
/* 刚打出的牌 / 赢下的墩 */
.cg-card.won { box-shadow: 0 0 0 2px #E0A94A, 0 3px 10px rgba(0, 0, 0, 0.2); }

/* ------------------------------------------------------------------ */
/* 牌桌                                                                */
/* ------------------------------------------------------------------ */

.cg-wrap { width: 100%; max-width: 640px; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.cg-wrap [hidden] { display: none !important; }

.cg-table {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(34, 42, 38, 0.34);
  border: 1px solid rgba(255, 255, 255, 0.26);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  box-sizing: border-box;
}

/* 一位玩家：名字 + 手牌数 + 打出的牌 */
.cg-seat { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cg-seat-name {
  font-size: 0.74rem;
  font-weight: 700;
  color: #F2F4F2;
  background: rgba(0, 0, 0, 0.32);
  border-radius: 99px;
  padding: 3px 11px;
  white-space: nowrap;
}
.cg-seat-name.turn { background: var(--cg-accent, #5B7B9A); color: #fff; }
.cg-seat-cards { display: flex; gap: 4px; flex-wrap: wrap; }

/* 中央出牌区 */
.cg-trick {
  min-height: calc(46px * 1.45 + 8px);
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  padding: 6px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.16);
}
.cg-trick-empty { font-size: 0.74rem; color: rgba(255, 255, 255, 0.62); }

/* 手牌区 */
.cg-hand { display: flex; gap: 7px; justify-content: center; flex-wrap: wrap; min-height: calc(46px * 1.45); }

/* 牌堆 / 王牌位 */
.cg-stock { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; }
.cg-stock-label { font-size: 0.72rem; color: rgba(255, 255, 255, 0.78); }

/* ------------------------------------------------------------------ */
/* 状态条 / 按钮 / 结算浮层（牌戏共用的最小外壳）                        */
/* ------------------------------------------------------------------ */

.cg-topbar { display: flex; gap: 7px; justify-content: center; flex-wrap: wrap; align-items: center; }
.cg-badge {
  font-size: 0.72rem;
  color: #5C6A62;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: 99px;
  padding: 4px 12px;
}

.cg-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 7px 18px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  font-size: 0.86rem;
  font-weight: 700;
  color: #333B36;
  min-height: 22px;
  text-align: center;
}
.cg-status .sub { font-size: 0.72rem; font-weight: 500; color: #8B968F; }

.cg-score {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  font-size: 0.76rem;
  color: #4A5560;
  background: rgba(255, 255, 255, 0.88);
  border-radius: 99px;
  padding: 5px 16px;
}
.cg-score b { font-weight: 700; }
.cg-score .lead { color: #C0432E; }

.cg-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.cg-btn {
  background: var(--cg-accent, #5B7B9A);
  color: #fff;
  border: none;
  padding: 7px 17px;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: filter 0.18s;
}
.cg-btn:hover { filter: brightness(1.08); }
.cg-btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }
.cg-btn.sub { background: rgba(255, 255, 255, 0.9); color: #4A5560; border: 1px solid rgba(0, 0, 0, 0.1); }

/* 选项组（叫牌 / 花色选择等） */
.cg-choice { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.cg-choice button {
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.92);
  color: #37423B;
  border-radius: 9px;
  padding: 6px 13px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.cg-choice button.active { background: var(--cg-accent, #5B7B9A); color: #fff; border-color: transparent; }

.cg-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(24, 28, 26, 0.45);
  backdrop-filter: blur(3px);
}
.cg-overlay .ov-card {
  background: #FBFBF9;
  border-radius: 18px;
  padding: 26px 24px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.cg-overlay .ov-icon { font-size: 2.4rem; }
.cg-overlay .ov-title { margin: 0; font-size: 1.24rem; font-weight: 700; color: #333B36; }
.cg-overlay .ov-lines { font-size: 0.84rem; line-height: 1.75; color: #7D8A82; white-space: pre-line; }

/* 对局战报 */
.cg-log {
  width: 100%;
  max-height: 132px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
  font-size: 0.72rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.86);
  box-sizing: border-box;
}
.cg-log .cg-log-line:last-child { color: #fff; font-weight: 600; }

@media (max-width: 460px) {
  .cg-card { --cg-w: 38px; }
  .cg-card.big { --cg-w: 52px; }
  .cg-table { padding: 10px; gap: 8px; }
}
