/* ------------------------------------------------------------- blackjack */

/*
 * A felt in the game frame, the dealer at the top and the hands along the
 * bottom. The cards are drawn here rather than fetched: a rank in two corners,
 * a suit in the middle, and the house mark on the back.
 */

.bj-frame {
  margin-bottom: 14px;
}

.bj-stage {
  padding: 0;
}

.bj-felt {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: center;
  justify-items: center;
  gap: 10px;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: min(64vh, 620px);
  padding: 22px;
  background:
    radial-gradient(70% 90% at 50% 0%, rgba(204, 255, 0, 0.1), transparent 62%),
    radial-gradient(90% 70% at 50% 120%, rgba(0, 0, 0, 0.5), transparent 70%),
    linear-gradient(180deg, #0d1a12, #060d09);
}

/* The arc of the table, drawn faintly behind the hands. */
.bj-felt::after {
  content: '';
  position: absolute;
  left: 8%;
  right: 8%;
  top: 44%;
  height: 58%;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 50% 50% 0 0 / 70% 70% 0 0;
  pointer-events: none;
}

.bj-dealer,
.bj-seat {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 1;
}

.bj-who {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.bj-cards {
  display: flex;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  min-height: 92px;
}

.bj-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 64px;
  height: 92px;
  padding: 6px;
  border-radius: 8px;
  background: linear-gradient(180deg, #fdfdfb, #e8ebe6);
  color: #16202c;
  font-weight: 700;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.45);
}

.bj-card.is-red {
  color: #c62828;
}

.bj-card-corner {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 13px;
  line-height: 1;
}

.bj-card-corner i {
  font-style: normal;
  font-size: 11px;
}

.bj-card-corner.is-foot {
  align-self: flex-end;
  transform: rotate(180deg);
}

.bj-card-pip {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 30px;
}

/* The back: the house mark on a dark card, so a hole card reads as ours. */
.bj-card.is-back {
  background:
    repeating-linear-gradient(45deg, rgba(204, 255, 0, 0.12) 0 6px, transparent 6px 12px),
    linear-gradient(180deg, #16210c, #0b1206);
  box-shadow:
    inset 0 0 0 2px rgba(204, 255, 0, 0.35),
    0 10px 18px rgba(0, 0, 0, 0.45);
}

.bj-card-mark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 30px;
  height: 30px;
  transform: translate(-50%, -50%);
  border-radius: 8px;
  background: linear-gradient(140deg, var(--lime), var(--lime-dark));
  box-shadow: 0 0 0 3px rgba(11, 18, 6, 0.9);
}

/* ------------------------------------------------------------- the shoe */

/*
 * The shoe: a stack of backs on the right of the felt with the house mark on
 * the top one. It is the place every card is thrown from, so it has to sit
 * still and be measurable, which is why it is positioned rather than laid out.
 */
.bj-shoe {
  position: absolute;
  right: 26px;
  top: 30px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.bj-shoe-stack {
  position: relative;
  display: block;
  width: 64px;
  height: 92px;
  transform: rotate(-6deg);
  transition: transform 160ms ease;
}

/* The edges of the cards underneath, each one a little further back. */
.bj-shoe-stack i,
.bj-shoe-top {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background: linear-gradient(160deg, #101a24, #0a121a);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
}

.bj-shoe-stack i:nth-child(1) { transform: translate(-6px, -6px); }
.bj-shoe-stack i:nth-child(2) { transform: translate(-5px, -5px); }
.bj-shoe-stack i:nth-child(3) { transform: translate(-4px, -4px); }
.bj-shoe-stack i:nth-child(4) { transform: translate(-3px, -3px); }
.bj-shoe-stack i:nth-child(5) { transform: translate(-2px, -2px); }
.bj-shoe-stack i:nth-child(6) { transform: translate(-1px, -1px); }

.bj-shoe-top {
  border: 1px solid rgba(204, 255, 0, 0.16);
  background:
    repeating-linear-gradient(
      45deg,
      rgba(204, 255, 0, 0.06) 0 6px,
      transparent 6px 12px
    ),
    linear-gradient(160deg, #12202c, #0a121a);
}

.bj-shoe-label {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  white-space: nowrap;
}

/* The stack gives a little as a card leaves it. */
.bj-shoe.is-giving .bj-shoe-stack {
  animation: bj-shoe-give 220ms ease;
}

@keyframes bj-shoe-give {
  40% {
    transform: rotate(-6deg) translate(-4px, 2px) scale(0.985);
  }
}

/* A card that has just been dealt comes out of the shoe rather than appearing. */
.bj-card.is-fresh {
  animation: bj-deal 380ms cubic-bezier(0.22, 0.72, 0.24, 1);
}

/* The card that was face down turns over where it lies. */
.bj-card.is-flip {
  animation: bj-flip 420ms ease;
}

@keyframes bj-flip {
  from {
    transform: rotateY(88deg);
    background: linear-gradient(160deg, #12202c, #0a121a);
  }

  49.9% {
    background: linear-gradient(160deg, #12202c, #0a121a);
  }

  50% {
    transform: rotateY(44deg);
  }
}

@keyframes bj-deal {
  from {
    transform: translate(var(--dx, 40px), var(--dy, -60px)) rotate(var(--dr, 8deg)) scale(0.94);
    opacity: 0.35;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bj-card.is-fresh,
  .bj-card.is-flip,
  .bj-shoe.is-giving .bj-shoe-stack {
    animation: none;
  }
}

.bj-score {
  min-width: 34px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(8, 12, 6, 0.8);
  font-size: 13px;
  font-weight: 700;
  color: var(--lime);
}

.bj-middle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 1;
}

.bj-rule {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.bj-insurance {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid rgba(204, 255, 0, 0.35);
  border-radius: 12px;
  background: rgba(8, 12, 6, 0.85);
  font-size: 13px;
}

.bj-insurance-buttons {
  display: flex;
  gap: 8px;
}

.bj-seats {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 26px;
  z-index: 1;
}

.bj-seat.is-active .bj-score {
  box-shadow: 0 0 0 2px var(--lime);
}

.bj-seat.is-bust,
.bj-seat.is-lost {
  opacity: 0.6;
}

.bj-seat-bet {
  font-size: 11px;
  color: var(--text-faint);
}

.bj-seat-paid {
  font-size: 13px;
  font-weight: 700;
  color: var(--lime);
}

.bj-tag {
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(204, 255, 0, 0.16);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--lime);
}

.bj-seat.is-lost .bj-tag,
.bj-seat.is-bust .bj-tag {
  background: rgba(248, 113, 113, 0.16);
  color: var(--down);
}

/* ------------------------------------------------------------- controls */

.bj-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.bj-bet-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.bj-bet-row .amount-field {
  flex: 1;
  min-width: 220px;
}

.bj-moves {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.bj-moves .button {
  min-width: 104px;
}

.bj-note {
  margin: 0;
  min-height: 18px;
  font-size: 12px;
  color: var(--text-dim);
}

.bj-empty {
  padding: 40px 0;
  text-align: center;
  color: var(--text-faint);
}

@media (max-width: 760px) {
  .bj-felt {
    aspect-ratio: auto;
    min-height: 420px;
  }

  .bj-card {
    width: 52px;
    height: 76px;
  }

  .bj-shoe {
    right: 12px;
    top: 14px;
  }

  .bj-shoe-stack {
    width: 44px;
    height: 64px;
  }

  .bj-cards {
    min-height: 76px;
  }
}
