/* table.css - the card table: playing cards, the opponent seats and the hand.
   Paired with table.js and shared by every card game. Every class is pc-. */

:root {
  --pc-w: clamp(48px, 13.5vw, 66px);   /* hand card width */
  --pc-felt: #1f6f3a;
  --pc-felt-dark: #17562d;
  --pc-felt-edge: #0f3d1f;
  --pc-red: #c62828;
  --pc-black: #1f1d1b;
  --pc-blue: #1f5fbf;   /* diamonds, four-color option */
  --pc-green: #1c7a3a;  /* clubs, four-color option */
  --pc-back: #157623;
  --pc-highlight: #ffb920;
}

/* ===== A card ===== */
.pc-card {
  --w: var(--pc-w);
  position: relative;
  flex: 0 0 auto;
  width: var(--w);
  height: calc(var(--w) * 1.4);
  padding: 0;
  border: 1px solid #c9cdd4;
  border-radius: calc(var(--w) * 0.12);
  background: #fff;
  color: var(--pc-black);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  font-family: 'Arimo', sans-serif;
  line-height: 1;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
button.pc-card { cursor: pointer; font: inherit; }
/* Suit symbols as text, never color emoji (iOS). table.js also adds U+FE0E. */
.pc-card, .suit-btn, .turn-text, .move-log, .suit-badge { font-variant-emoji: text; }
.pc-card.pc-red { color: var(--pc-red); }

/* The card's only marking: big rank, big suit under it, in the left ~45%
   of the card (the strip that shows when cards overlap). */
.pc-corner {
  position: absolute;
  top: calc(var(--w) * 0.08);
  left: calc(var(--w) * 0.09);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--w) * 0.04);
  font-weight: 700;
  line-height: 1;
}
.pc-rank { font-size: calc(var(--w) * 0.38); letter-spacing: -0.05em; }
.pc-suit { font-size: calc(var(--w) * 0.44); }

/* In an overlapped hand only a strip of each card shows (--pc-strip, set
   by fitHand). Rank and suit shrink to fit it, so "10" never gets cut off. */
.pc-hand .pc-corner {
  left: min(calc(var(--w) * 0.09), calc(var(--pc-strip, 999px) * 0.1));
}
.pc-hand .pc-rank { font-size: min(calc(var(--w) * 0.38), calc(var(--pc-strip, 999px) * 0.74)); }
.pc-hand .pc-suit { font-size: min(calc(var(--w) * 0.44), calc(var(--pc-strip, 999px) * 0.82)); }

.pc-card.pc-sm { --w: clamp(34px, 9vw, 44px); }
.pc-card.pc-xs { --w: 14px; border-radius: 2px; box-shadow: none; }

/* Four-color suits (setting): helps kids and small screens tell suits apart. */
.pc-four-color .pc-card.pc-diamonds { color: var(--pc-blue); }
.pc-four-color .pc-card.pc-clubs { color: var(--pc-green); }

/* ===== Card back ===== */
.pc-card.pc-back {
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.14) 0 3px, transparent 3px 7px),
    var(--pc-back);
  border: 2px solid #fff;
  outline: 1px solid #c9cdd4;
}
.pc-card.pc-xs.pc-back { border-width: 1px; outline: none; }

/* ===== Opponent seats (placed by compassSeats in table.js) ===== */
.pc-seat {
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
  padding: 6px 2px 5px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid transparent;
  border-radius: 10px;
  color: #fff;
  text-align: center;
}
.pc-seat.is-up { border-color: var(--pc-highlight); background: rgba(255, 255, 255, 0.2); }
.pc-seat.is-winner { border-color: var(--pc-highlight); background: rgba(255, 185, 32, 0.3); }

.pc-seat-hand { position: relative; display: flex; justify-content: center; height: 30px; }
.pc-seat-count {
  position: absolute;
  right: -10px;
  top: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: #fff;
  color: var(--pc-black);
  font-family: 'League Spartan', sans-serif;
  font-weight: 800;
  font-size: 0.8rem;
  line-height: 20px;
}
.pc-seat-name {
  max-width: 100%;
  font-weight: 700;
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pc-seat-meta { font-size: 0.7rem; opacity: 0.85; }

/* Tricks taken: a small face-down pile, landscape, a little taller per trick.
   Its height is reserved even when empty so nothing moves. */
.pc-pile {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 22px;
}
.pc-pile .pc-card {
  position: absolute;
  width: 24px;
  height: 17px;
  border-radius: 3px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
}

/* One back per card; table.js sets each overlap so the fan fits its seat. */
.pc-fan { display: flex; align-items: center; min-height: 28px; }
.pc-fan .pc-card { --w: 20px; border-radius: 3px; }

/* West and East: the hand runs down the side of the table, cards turned
   sideways, like a real player sitting on your left or right. */
.pc-seat--west, .pc-seat--east { flex: none; width: 54px; padding: 6px 1px 5px; }
.pc-seat--west .pc-seat-hand, .pc-seat--east .pc-seat-hand { height: auto; padding: 2px 0; }
.pc-seat--west .pc-fan, .pc-seat--east .pc-fan { flex-direction: column; }
.pc-seat--west .pc-fan .pc-card, .pc-seat--east .pc-fan .pc-card {
  width: 30px;
  height: 21px;
}
.pc-seat--west .pc-seat-count, .pc-seat--east .pc-seat-count { right: -12px; top: -6px; }

/* ===== Your hand ===== */
.pc-hand {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  flex-wrap: nowrap;
  width: 100%;
  padding-top: 12px; /* room for a lifted card */
}

.pc-hand .pc-card { transition: transform 0.12s; }
.pc-hand .pc-card.is-playable {
  transform: translateY(-8px);
  box-shadow: 0 0 0 3px var(--pc-highlight), 0 3px 8px rgba(0, 0, 0, 0.3);
}
.pc-hand .pc-card.is-dim { filter: brightness(0.82); }
.pc-hand .pc-card.is-selected {
  transform: translateY(-14px);
  box-shadow: 0 0 0 3px #157623, 0 4px 10px rgba(0, 0, 0, 0.35);
}
.pc-hand .pc-card.is-new { animation: pc-arrive 0.28s ease-out; }
.pc-hand .pc-card.is-nope { animation: pc-nope 0.35s ease-in-out; }

@keyframes pc-arrive {
  from { transform: translateY(-30px) scale(0.85); opacity: 0.3; }
}
@keyframes pc-nope {
  0%, 100% { translate: 0 0; }
  25% { translate: -4px 0; }
  75% { translate: 4px 0; }
}
@keyframes pc-land {
  from { transform: scale(0.75) rotate(-6deg); opacity: 0.4; }
  to { transform: scale(1) rotate(0); opacity: 1; }
}
.pc-card.is-landed { animation: pc-land 0.24s ease-out; }
