/* Each collectible supplies its immutable artwork and foil colors on the parent. */
.skin-back,
.card-deal-back,
.portrait-game .portrait-shell #bot-hand > .back {
  background-color: #523341;
  background-image: var(--house-card-art);
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  border-radius: 5%;
  image-rendering: auto;
}
.skin-back,
.card-deal-back,
.skin-face-preview {
  display: block;
  aspect-ratio: 18 / 25;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgb(245 216 166 / 24%), 0 1px 2px #0a1b1b80;
}
.skin-back > .skin-glyph,
.portrait-game .portrait-shell #bot-hand > .back::before,
.portrait-game .portrait-shell #bot-hand > .back::after { display: none; }

.skin-back,
.skin-face-preview { position: relative; isolation: isolate; }
.skin-face-preview {
  background: #f7ebd4;
  color: #253237;
  border: 1px solid var(--finish-hairline, #8a6d55);
  border-radius: 5%;
  container-type: inline-size;
}
.skin-face-preview:is([data-suit="♥"], [data-suit="♦"]) { color: #a1383d; }
.skin-face-preview::before,
.skin-face-preview::after {
  content: attr(data-rank) "\A" attr(data-suit);
  position: absolute;
  font: 800 16cqw/.89 Georgia, serif;
  white-space: pre;
  text-align: center;
}
.skin-face-preview::before { top: 5%; left: 6%; }
.skin-face-preview::after { bottom: 5%; right: 6%; transform: rotate(180deg); }
.skin-face-pip {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font: 600 49cqw/1 Georgia, serif;
}

/* This is the temporary back of a newly dealt, visible card. */
:is(#player-hand, #player-table, #bot-hand, #bot-table) .card > .card-deal-back {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  z-index: 4;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform-origin: center;
  animation: reveal-dealt-card 250ms ease-in-out both;
}
@keyframes reveal-dealt-card {
  0%, 22% { visibility: visible; opacity: 1; transform: scaleX(1); }
  68% { visibility: visible; opacity: 1; transform: scaleX(.13); }
  82%, 100% { visibility: hidden; opacity: 0; transform: scaleX(.03); }
}

.skin-back::after {
  content: "";
  position: absolute;
  inset: 1px;
  z-index: 2;
  display: block;
  pointer-events: none;
  border-radius: inherit;
  background-image: linear-gradient(var(--foil-angle,112deg),
    transparent 35%,
    color-mix(in srgb, var(--foil-a, pink) 24%, transparent) 41%,
    var(--foil-a, pink) 45.5%,
    var(--foil-b, ivory) 47%,
    var(--foil-c, gold) 49%,
    transparent 52%,
    color-mix(in srgb, var(--foil-c, gold) 48%, transparent) 55%,
    transparent 59%);
  background-size: 260% 100%;
  background-position: 43% center;
  background-repeat: no-repeat;
  mix-blend-mode: screen;
  opacity: .12;
}
.collection-card:is([aria-pressed="true"], [data-equipped="true"], :focus-within, :hover) .skin-back::after,
.skin-back.collection-preview-art::after,
.collection-drop > .skin-back::after {
  opacity: .8;
  animation: collection-lacquer 4.8s cubic-bezier(.32, 0, .48, 1) -.48s infinite;
}
.skin-back.collection-preview-art::after,
.collection-drop > .skin-back::after { animation-duration: 3.3s; }
@keyframes collection-lacquer {
  0% { background-position: 100% center; }
  44%, 100% { background-position: 0% center; }
}
@media (prefers-reduced-motion: reduce) {
  :is(#player-hand, #player-table, #bot-hand, #bot-table) .card > .card-deal-back { display: none; animation: none; }
  .collection-card:is([aria-pressed="true"], [data-equipped="true"], :focus-within, :hover) .skin-back::after,
  .skin-back.collection-preview-art::after,
  .collection-drop > .skin-back::after {
    animation: none;
    background-position: 42% center;
    opacity: .31;
  }
}

/* The house design is identical for every hidden rank and has no instance metadata. */
:root { --house-card-art: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2072%20100%27%3E%3Cdefs%3E%3Cpattern%20id%3D%27w%27%20width%3D%2710%27%20height%3D%2714%27%20patternUnits%3D%27userSpaceOnUse%27%3E%3Cpath%20d%3D%27m0%207%205-7%205%207-5%207z%27%20fill%3D%27none%27%20stroke%3D%27%23d18176%27%20stroke-width%3D%271%27%2F%3E%3Cpath%20d%3D%27m3%207%202-3%202%203-2%203z%27%20fill%3D%27%23a3484f%27%2F%3E%3C%2Fpattern%3E%3C%2Fdefs%3E%3Crect%20x%3D%271%27%20y%3D%271%27%20width%3D%2770%27%20height%3D%2798%27%20rx%3D%275%27%20fill%3D%27%23863d49%27%20stroke%3D%27%23dcab86%27%20stroke-width%3D%272%27%2F%3E%3Cpath%20d%3D%27M7%205h58l2%203v84l-2%203H7l-2-3V8z%27%20fill%3D%27url(%23w)%27%20stroke%3D%27%23edc19c%27%20stroke-width%3D%271.3%27%2F%3E%3Cpath%20d%3D%27M36%2034%2049%2050%2036%2066%2023%2050Z%27%20fill%3D%27%23873f4d%27%20stroke%3D%27%23e7b187%27%20stroke-width%3D%271.5%27%2F%3E%3Cpath%20d%3D%27m36%2041%207%209-7%209-7-9z%27%20fill%3D%27%23e1ae8a%27%2F%3E%3Cpath%20d%3D%27m36%2045%204%205-4%205-4-5z%27%20fill%3D%27%23914953%27%2F%3E%3C%2Fsvg%3E"); }
.portrait-game .portrait-shell #bot-hand > .back,
:is(#player-hand, #player-table, #bot-hand, #bot-table) .card > .card-deal-back {
  background-image: var(--house-card-art);
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
.skin-back:not([data-owned-card-back]) {
  background-image: var(--house-card-art);
}
.skin-back[data-pattern-instance]:not([data-owned-card-back]),
:where(:not(body)[data-pattern-instance]) .skin-back:not([data-owned-card-back]),
:is(#player-hand, #player-table) .card[data-pattern-instance] > .card-deal-back {
  background-image: var(--deck-art);
}
#bot-hand > .back::before, #bot-hand > .back::after { content: none; }

/* A collectible finish belongs to one visible card. Ordinary cards keep their normal paper. */
:is(#player-hand, #player-table, #bot-hand, #bot-table) .card > .card-finish,
.skin-face-preview .collection-card-foil { display: none; }
.skin-face-preview[data-pattern-instance]:not(:has(.collection-card-foil)) {
  background: var(--face-foil-art) center / 100% 100% no-repeat, #f7ebd4;
}
:is(#player-hand, #player-table, #bot-hand, #bot-table) .card[data-pattern-instance] > .card-finish,
.skin-face-preview[data-pattern-instance] .collection-card-foil {
  display: block;
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 2;
  border-radius: inherit;
  opacity: 1;
  background-color: transparent;
  background-image: var(--face-foil-art);
  background-position: center;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  box-shadow: none;
  mix-blend-mode: multiply;
}
.skin-face-preview[data-pattern-instance]::before,
.skin-face-preview[data-pattern-instance]::after { z-index: 3; }
:is(#player-hand, #player-table, #bot-hand, #bot-table) .card[data-pattern-instance] > .card-finish::after,
.skin-face-preview[data-pattern-instance] .collection-card-foil::after {
  content: "";
  display: block;
  position: absolute;
  inset: 2px;
  border-radius: inherit;
  pointer-events: none;
  mask-image: none;
  opacity: .77;
  background-image: linear-gradient(var(--foil-angle, 114deg),
    transparent 31%,
    color-mix(in srgb, var(--foil-a, turquoise) 74%, transparent) 40%,
    var(--foil-a, turquoise) 44%,
    var(--foil-b, ivory) 46%,
    white 48%,
    var(--foil-c, violet) 51%,
    transparent 55%,
    color-mix(in srgb, var(--foil-a, turquoise) 64%, transparent) 58%,
    transparent 63%);
  background-size: 255% 100%;
  background-repeat: no-repeat;
  mix-blend-mode: hard-light;
  animation: face-lacquer 4.8s ease-in-out -.85s infinite;
}
.skin-face-preview[data-pattern-instance] .collection-card-foil::after { animation-duration: 4s; }
.skin-face-preview.collection-preview-art[data-pattern-instance] .collection-card-foil::after { animation-duration: 3.3s; }
:is(#player-hand, #player-table, #bot-hand, #bot-table) .card[data-pattern-instance]:nth-child(2n) > .card-finish::after { animation-delay: -1.6s; }
:is(#player-hand, #player-table, #bot-hand, #bot-table) .card[data-pattern-instance]:nth-child(3n) > .card-finish::after { animation-delay: -2.2s; }
@keyframes face-lacquer {
  0% { background-position: 100% 50%; }
  54%, 100% { background-position: 0% 50%; }
}
@media (prefers-reduced-motion: reduce) {
  :is(#player-hand, #player-table, #bot-hand, #bot-table) .card[data-pattern-instance] > .card-finish::after,
  .skin-face-preview[data-pattern-instance] .collection-card-foil::after {
    animation: none;
    opacity: .27;
    background-position: 47% center;
  }
}
