/* One face for a standard suit card, and the Nain Jaune back for every face-down card. */

.playing-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 0;
  background: var(--card-paper);
  color: var(--card-ink);
  box-shadow: inset 0 0 0 5px rgb(34 34 34 / 12%);
  touch-action: manipulation;
}

.playing-card[data-red="true"] {
  color: var(--card-red);
  box-shadow: inset 0 0 0 5px rgb(199 68 68 / 28%);
}

.playing-rank {
  font: 700 28px/1 ui-sans-serif, system-ui, sans-serif;
}

.playing-suit {
  font: 700 24px/1 ui-sans-serif, system-ui, sans-serif;
}

button.playing-card {
  cursor: pointer;
}

button.playing-card:disabled:not(.belote-card) {
  cursor: default;
  opacity: 0.45;
}

.card-back {
  display: block;
  box-sizing: border-box;
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 42%, #f0d15a 0 12%, transparent 13%),
    repeating-linear-gradient(135deg, #8e1824 0 8px, #c4303c 8px 16px);
  box-shadow: inset 0 0 0 4px #e8c14a;
}

.uno-card.card-back {
  padding: 0;
  background:
    radial-gradient(circle at 50% 42%, #f0d15a 0 12%, transparent 13%),
    repeating-linear-gradient(135deg, #8e1824 0 8px, #c4303c 8px 16px);
  box-shadow: inset 0 0 0 4px #e8c14a;
}

/* South plays from the bottom. The other three hands sit North, West and East. */
.card-table {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 76px;
  grid-template-areas:
    "north north north"
    "west center east"
    "south south south";
  align-items: center;
  justify-items: center;
  gap: 8px 6px;
  width: min(980px, 100%);
  margin: auto;
}

.card-seat.is-north { grid-area: north; }
.card-seat.is-west { grid-area: west; }
.card-seat.is-east { grid-area: east; }
.card-center { grid-area: center; width: 100%; min-width: 0; }
.card-south { grid-area: south; width: 100%; min-width: 0; }

.card-seat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}

.card-seat-name {
  position: relative;
  z-index: 2;
  margin: 0;
  max-width: 9.5rem;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--bg);
  font: var(--type-body);
  text-align: center;
}

.card-seat.is-turn .card-seat-name {
  font-weight: 750;
}

.card-fan {
  display: flex;
  justify-content: center;
}

.card-seat.is-north .card-fan .card-back {
  width: 42px;
  height: 60px;
  min-width: 0;
  min-height: 0;
  margin: 0 -12px;
  padding: 0;
}

.card-seat.is-west .card-fan,
.card-seat.is-east .card-fan {
  flex-direction: column;
}

.card-seat.is-west .card-fan .card-back,
.card-seat.is-east .card-fan .card-back {
  width: 36px;
  height: 50px;
  min-width: 0;
  min-height: 0;
  margin: -22px 0 0;
  padding: 0;
}

.card-seat.is-west .card-fan .card-back:first-child,
.card-seat.is-east .card-fan .card-back:first-child {
  margin-top: 0;
}

.card-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* The deal sits on a round. Arrows run counter-clockwise until play reverses. */
.play-round {
  position: relative;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(100%, 300px);
  min-height: 220px;
  margin: 4px auto;
  padding: 36px 20px;
  border-radius: 50%;
  background: var(--idle);
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--ink) 22%, transparent);
}

.tarot-scene .play-round,
.uno-scene .play-round,
.belote-scene .play-round {
  background: #f4f3f6;
  box-shadow: none;
}

.uno-scene .play-round,
.belote-scene .play-round,
.tarot-scene .play-round {
  width: min(100%, 300px);
  height: auto;
  aspect-ratio: 1;
  min-height: 0;
  flex: none;
}

[data-theme="dark"] .tarot-scene .play-round,
[data-theme="dark"] .uno-scene .play-round,
[data-theme="dark"] .belote-scene .play-round {
  background: #8d8b94;
  box-shadow: none;
}

.play-round-cards {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: auto;
  max-width: 100%;
  min-width: 0;
}

.play-arrow {
  position: absolute;
  z-index: 1;
  display: grid;
  width: 28px;
  height: 28px;
  color: #ffffff;
  filter: drop-shadow(0 0 1px rgb(24 24 28 / 50%));
  pointer-events: none;
}

.play-arrow svg {
  width: 28px;
  height: 28px;
}

.play-arrow.is-n { top: 8px; left: 50%; transform: translateX(-50%) rotate(-90deg); }
.play-arrow.is-e { top: 50%; right: 6px; transform: translateY(-50%) rotate(0deg); }
.play-arrow.is-s { bottom: 8px; left: 50%; transform: translateX(-50%) rotate(90deg); }
.play-arrow.is-w { top: 50%; left: 6px; transform: translateY(-50%) rotate(180deg); }

.play-round.is-reversed .play-arrow.is-n { transform: translateX(-50%) rotate(90deg); }
.play-round.is-reversed .play-arrow.is-e { transform: translateY(-50%) rotate(180deg); }
.play-round.is-reversed .play-arrow.is-s { transform: translateX(-50%) rotate(-90deg); }
.play-round.is-reversed .play-arrow.is-w { transform: translateY(-50%) rotate(0deg); }

.play-round .uno-card,
.play-round .belote-card {
  width: 76px;
  height: 110px;
  min-width: 0;
  min-height: 0;
  padding: 4px;
  border-radius: 10px;
}

.play-round .tarot-card {
  width: 78px;
  height: auto;
  aspect-ratio: 267 / 495;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border-radius: 8px;
  background: #f4efe4;
}

.play-round .playing-rank { font-size: 16px; }
.play-round .playing-suit { font-size: 14px; }
.play-round .belote-card::before { inset: 3px; border-radius: 4px; }
.play-round .belote-card .playing-rank { font-size: 14px; }
.play-round .belote-card .playing-suit { width: 10px; height: 10px; }
.play-round .belote-card .playing-pip { width: 34%; }
.play-round .belote-card .playing-corner.is-tl { top: 7px; left: 6px; }
.play-round .belote-card .playing-corner.is-br { right: 6px; bottom: 7px; }
.play-round .atout-numeral { font-size: 22px; }
.play-round .atout-caption { font-size: 8px; letter-spacing: 0.08em; }

.uno-stock {
  position: relative;
  width: 74px;
  height: 102px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
}

button.uno-stock {
  cursor: pointer;
}

button.uno-stock:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
  border-radius: 12px;
}

.uno-stock .card-back {
  position: absolute;
  top: 0;
  left: 0;
  width: 64px;
  height: 92px;
  min-height: 0;
}

.uno-stock .card-back:nth-child(1) { transform: translate(8px, 8px); }
.uno-stock .card-back:nth-child(2) { transform: translate(4px, 4px); }
.uno-stock .card-back:nth-child(3) { z-index: 1; }

.is-thrown {
  animation: card-throw 420ms cubic-bezier(0.16, 0.84, 0.32, 1);
}

.is-thrown[data-from="north"] { --throw-x: 0px; --throw-y: -88px; }
.is-thrown[data-from="south"] { --throw-x: 0px; --throw-y: 110px; }
.is-thrown[data-from="west"] { --throw-x: -110px; --throw-y: 0px; }
.is-thrown[data-from="east"] { --throw-x: 110px; --throw-y: 0px; }

@keyframes card-throw {
  from { transform: translate(var(--throw-x, 0), var(--throw-y, 48px)) scale(0.78); }
  to { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .is-thrown { animation: none; }
}

@media (max-width: 680px) {
  .card-table {
    grid-template-columns: 52px minmax(0, 1fr) 52px;
  }

  .card-seat.is-north .card-fan .card-back {
    width: 32px;
    height: 46px;
    margin: 0 -10px;
  }
}

.belote-scene .play-round,
[data-theme="dark"] .belote-scene .play-round {
  background: transparent;
  box-shadow: none;
}

.belote-scene.is-bidding .play-round {
  padding: 0;
  border: 0;
  background: transparent;
}

@media (orientation: landscape) and (max-height: 520px) {
  .card-seat.is-north .card-fan .card-back,
  .card-seat.is-west .card-fan .card-back,
  .card-seat.is-east .card-fan .card-back {
    width: 26px;
    height: 38px;
    margin: -16px 0 0;
  }

  .card-seat.is-north .card-fan .card-back {
    margin: 0 -8px;
  }
}
