/* The table opener's layers: objects on the felt, then the dim, the big card, particles and words. */

.to-root {
  position: absolute;
  inset: 0;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  font-family: var(--font, "Pipwick", Consolas, "Courier New", monospace);
  font-weight: bold;
}
.to-shake,
.to-layer,
.to-top,
.to-fx,
.to-ui {
  position: absolute;
  inset: 0;
}
.to-fx,
.to-ui,
.to-dim {
  pointer-events: none;
}
.to-shake {
  z-index: 1;
}
.to-top {
  z-index: 30;
  pointer-events: none;
}
.to-fx {
  z-index: 40;
}
.to-ui {
  z-index: 50;
}

.to-pack,
.to-card,
.to-shadow {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform;
}
.to-pack {
  width: var(--pw);
  height: var(--ph);
  cursor: pointer;
}
.to-card {
  width: var(--cw);
  height: var(--ch);
  cursor: pointer;
  perspective: 600px;
}
.to-shadow {
  width: var(--cw);
  height: var(--ch);
  border-radius: 4px;
  background: rgb(0 0 0 / 0.9);
  /* a soft edge painted once; a blur filter on a moving layer is run again every frame */
  box-shadow: 0 0 4px rgb(0 0 0 / 0.9);
  pointer-events: none;
}
.to-shadow-pack {
  width: var(--pw);
  height: var(--ph);
  border-radius: 6px;
  transform-origin: 50% 50%;
}

/* a pack is the same wrapper image cut in two at the tear line, on the top crimp (STRIP_H / PACK_H in pixel-pack.js):
   the strip pivots on its right end */
.to-pack-body,
.to-pack-strip,
.to-pack-flash {
  position: absolute;
  inset: 0;
}
.to-pack-body {
  clip-path: inset(5% 0 0 0);
}
/* their own layers, so a tap's tear and flash move them without repainting the pack */
.to-pack-strip {
  transform-origin: 96% 5%;
  will-change: transform;
}
.to-pack-flash {
  will-change: opacity;
}
.to-pack-stripface {
  position: absolute;
  inset: 0;
  clip-path: inset(0 0 95% 0);
}
.to-pack img,
.to-wrap {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: auto;
  pointer-events: none;
}
.to-pack img.to-pixel {
  image-rendering: pixelated;
  object-fit: fill;
}
.to-pack-flash {
  opacity: 0;
  filter: brightness(0) invert(1);
  mix-blend-mode: screen;
  pointer-events: none;
}
.to-wrap {
  border-radius: 3px;
  background:
    linear-gradient(160deg, rgb(255 255 255 / 0.3), transparent 40%),
    linear-gradient(var(--pack), color-mix(in srgb, var(--pack) 55%, #120c1c));
  overflow: hidden;
}
.to-wrap img {
  position: absolute;
  inset: auto 8% 22% 8%;
  width: 84%;
  height: 52%;
  object-fit: cover;
  object-position: 50% 18%;
  box-shadow: 0 0 0 2px #fff8;
}
.to-wrap b {
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: 6%;
  text-align: center;
  font-size: calc(var(--pw) * 0.11);
  color: #fff;
  text-shadow: 1px 1px #0008;
}

/* cards: face down until they turn */
.to-card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform: rotateY(180deg);
  transition: transform 0.26s cubic-bezier(0.65, 0, 0.35, 1);
}
.to-up .to-card-inner {
  transform: rotateY(0deg);
}
.to-moment-card .to-card-inner {
  transition: none;
}
.to-front,
.to-back {
  position: absolute;
  inset: 0;
  border-radius: calc(var(--cw) * 0.05);
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.to-front {
  background: #e9dfc4;
}
.to-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}
.to-front span {
  position: absolute;
  inset: 8%;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: calc(var(--cw) * 0.12);
  color: #4a3a22;
}
.to-back {
  transform: rotateY(180deg);
  /* the real Pokémon TCG card back (art/card-back.webp, credited in docs/pack-art-credits.md), the same on every card */
  background: url("../art/card-back.webp") center / 100% 100% no-repeat;
}

/* foil on holo and up, and on reverse holos, once they're face up. The band is three times the card's size and
   slides across it: a moving transform runs on the compositor, where sliding a background repainted every holo on
   the table every frame. */
.to-foil {
  position: absolute;
  left: 0;
  top: 0;
  width: 300%;
  height: 300%;
  display: none;
  pointer-events: none;
  mix-blend-mode: color-dodge;
  background: linear-gradient(
    115deg,
    transparent 25%,
    #ff6f6f 35%,
    #ffe96f 42%,
    #6fff9d 50%,
    #6fc8ff 58%,
    #d86fff 65%,
    transparent 75%
  );
  animation: to-foil 3s linear infinite;
}
:is(.to-up, .to-moment-card):is(.to-tier-holo, .to-reverse) .to-foil {
  display: block;
  opacity: 0.28;
}
:is(.to-up, .to-moment-card).to-tier-ultra .to-foil {
  display: block;
  opacity: 0.38;
}
:is(.to-up, .to-moment-card):is(.to-tier-illustration, .to-tier-grail) .to-foil {
  display: block;
  opacity: 0.5;
}
@keyframes to-foil {
  from {
    transform: translate(-66.667%, -66.667%);
  }
  to {
    transform: none;
  }
}

.to-heartbeat .to-layer {
  filter: brightness(0.82);
}

/* the moment */
.to-dim {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgb(4 3 6);
  opacity: 0;
  transition: opacity 0.2s;
}

.to-banner {
  position: absolute;
  left: 50%;
  bottom: 4%;
  translate: -50% 0;
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 6px 18px 8px;
  color: #342716;
  background: linear-gradient(#ffe77a, #e0a92a);
  border: 3px solid #6f4b13;
  box-shadow: 0 4px #302018;
  white-space: nowrap;
  animation: to-banner 0.5s cubic-bezier(0.3, 1.6, 0.5, 1) both;
}
.to-banner b {
  font-size: 3.4cqh;
  letter-spacing: 0.06em;
}
.to-banner span {
  font-size: 1.9cqh;
}
.to-banner small {
  font-size: 1.3cqh;
  opacity: 0.75;
}
.to-banner-secret {
  background: linear-gradient(#ffc6d0, #ff7e98);
  border-color: #6b2232;
}
.to-banner-grail {
  background: linear-gradient(90deg, #ff9c9c, #ffe59c, #9cffc4, #9cd6ff, #e19cff);
  border-color: #3b2b4a;
}
.to-root {
  container-type: size;
}
@keyframes to-banner {
  from {
    scale: 0.2;
    opacity: 0;
  }
}

/* particles: square, like the rest of the desk, all on one canvas (table-opener.js updateParticles) */
.to-fxc {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.to-ring {
  position: absolute;
  width: 50px;
  height: 50px;
  border: 3px solid;
  border-radius: 50%;
}

.to-float {
  position: absolute;
  white-space: nowrap;
  color: #fff;
  font-size: calc(var(--cw) * 0.13);
  text-shadow:
    2px 2px #231b22,
    -1px -1px #231b22;
}
.to-dmg {
  color: #fff6d8;
}
.to-crit {
  color: #ffd66b;
  font-size: calc(var(--cw) * 0.16);
}
.to-callout {
  font-size: calc(var(--cw) * 0.14);
}
.to-callout.to-big {
  font-size: calc(var(--cw) * 0.18);
}
.to-new {
  color: #ffe066;
  font-size: calc(var(--cw) * 0.1);
}

@media (prefers-reduced-motion: reduce) {
  .to-foil {
    animation: none !important;
  }
}

/* ---------- the row (layout: "row"): one pack at a time ---------- */
.to-pack.to-torn .to-pack-body {
  transform: translate(-12%, 6%) rotate(-14deg);
  clip-path: inset(11% 0 0 0);
  filter: drop-shadow(3px 4px 0 rgb(0 0 0 / 0.3));
  transition: transform 0.25s ease-out;
}
/* glows painted on the card's faces, which follow their rounded corners like a drop-shadow filter would without
   running a filter on a moving layer every frame */
.to-card.to-hov {
  cursor: pointer;
}
.to-card.to-hov :is(.to-front, .to-back) {
  box-shadow: 0 0 calc(var(--cw) * 0.1) rgb(255 230 150 / 0.9);
}
.to-card.to-hit :is(.to-front, .to-back) {
  box-shadow: 0 0 calc(var(--cw) * 0.12) rgb(255 200 90 / 0.8);
}
.to-sold {
  position: absolute;
  left: 50%;
  top: 100%;
  translate: -50% 18%;
  white-space: nowrap;
  font-family: "Silkscreen", monospace;
  font-size: calc(var(--cw) * 0.09);
  line-height: 1;
  color: #1f5a2c;
  background: #d9f2c8;
  border: calc(var(--cw) * 0.02) solid #1a1018;
  border-radius: calc(var(--cw) * 0.025);
  padding: calc(var(--cw) * 0.025) calc(var(--cw) * 0.03) calc(var(--cw) * 0.01);
  animation: to-banner 0.3s cubic-bezier(0.3, 1.6, 0.5, 1) both;
}
.to-sold.to-wanted {
  color: #1a1018;
  background: #ffd24a;
}
