/* Pack opener. Everything is sized from the mount element (container units), so it
   fits the ~700x420 table centre as well as a full screen. */

.po-stage {
  position: absolute;
  inset: 0;
  z-index: 40;
  container-type: size;
  overflow: hidden;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  cursor: pointer;
  font-family: var(--font, Consolas, "Courier New", monospace);
  font-weight: bold;
  color: #fbf1d3;
  --mx: 0.5;
  --my: 0.5;
  --cw: min(calc(72cqh / 1.95), 30cqw);
  --ch: calc(var(--cw) * 1.396);
}
.po-dim {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 42%, rgb(20 14 10 / 0.15), rgb(15 10 8 / 0.55));
  transition:
    opacity 0.5s,
    background 0.5s;
  pointer-events: none;
}
.po-hush .po-dim {
  background: radial-gradient(ellipse at 50% 42%, rgb(12 8 18 / 0.35), rgb(5 3 8 / 0.85));
}
.po-auto .po-dim {
  opacity: 0.5;
}

/* light rays behind special art pulls */
.po-rays {
  position: absolute;
  left: 50%;
  top: 40%;
  width: 160cqmax;
  height: 160cqmax;
  translate: -50% -50%;
  background: repeating-conic-gradient(
    from 0deg,
    rgb(255 236 170 / 0.22) 0 6deg,
    transparent 6deg 18deg
  );
  mask: radial-gradient(circle, #000 8%, transparent 45%);
  opacity: 0;
  transition: opacity 0.6s;
  pointer-events: none;
  animation: po-spin 14s linear infinite;
}
.po-rays-on .po-rays {
  opacity: 1;
}
@keyframes po-spin {
  to {
    rotate: 360deg;
  }
}

.po-hud {
  position: absolute;
  top: 2.5cqh;
  left: 3cqw;
  right: 3cqw;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: clamp(10px, 3.2cqh, 14px);
  text-shadow: 2px 2px #231b22;
  pointer-events: none;
  z-index: 5;
}
.po-count {
  min-width: 4em;
  color: #ffe69a;
}
.po-hint {
  flex: 1;
  text-align: center;
  animation: po-bob 1.6s ease-in-out infinite;
}
.po-hud .po-btn {
  pointer-events: auto;
}
@keyframes po-bob {
  50% {
    translate: 0 -3px;
  }
}

.po-btn {
  font: inherit;
  font-size: clamp(10px, 3cqh, 13px);
  cursor: pointer;
  background: #344d60;
  border: 2px solid #6191a1;
  color: #f4f5e6;
  box-shadow: 0 2px #172330;
  padding: 6px 12px;
  border-radius: 2px;
}
.po-btn.po-primary {
  background: linear-gradient(#ffda51, #dca522);
  color: #342716;
  border: 3px solid #6f4b13;
  border-top-color: #ffe792;
  box-shadow: 0 3px #302018;
  text-shadow: 1px 1px #ffe597;
}
.po-btn:hover {
  filter: brightness(1.15);
}
.po-btn:active {
  translate: 0 2px;
}

.po-table {
  position: absolute;
  left: 0;
  right: 0;
  top: 7cqh;
  bottom: 22cqh;
  display: grid;
  place-items: center;
  perspective: 900px;
}
.po-stack,
.po-pack {
  grid-area: 1 / 1;
  position: relative;
}
.po-stack {
  width: var(--cw);
  height: var(--ch);
}
.po-pack {
  width: calc(var(--cw) * 1.12);
  aspect-ratio: 0.58;
  z-index: 2;
  filter: drop-shadow(0 10px 8px rgb(20 10 5 / 0.45));
}
.po-pack.po-tearable {
  cursor: ew-resize;
}
.po-pack-top,
.po-pack-body {
  position: absolute;
  inset: 0;
}

/* ---------- wrapper ---------- */
.po-pack-face {
  position: absolute;
  inset: 0;
  border-radius: 3px;
  overflow: hidden;
  background:
    linear-gradient(160deg, rgb(255 255 255 / 0.28), transparent 40%),
    linear-gradient(var(--pack), color-mix(in srgb, var(--pack) 55%, #120c1c));
  box-shadow: inset 0 0 0 2px rgb(0 0 0 / 0.25);
}
.po-pack-face::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    115deg,
    transparent calc(var(--mx) * 100% - 30%),
    rgb(255 255 255 / 0.4) calc(var(--mx) * 100%),
    transparent calc(var(--mx) * 100% + 30%)
  );
  mix-blend-mode: soft-light;
  pointer-events: none;
}
.po-pack-face.po-real {
  background: none;
  box-shadow: none;
}
.po-wrapper-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.po-crimp {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 7%;
  background:
    repeating-linear-gradient(90deg, rgb(255 255 255 / 0.3) 0 2px, rgb(0 0 0 / 0.18) 2px 4px),
    color-mix(in srgb, var(--pack) 70%, #fff);
  z-index: 3;
}
.po-crimp-bottom {
  top: auto;
  bottom: 0;
}
.po-wrapper-art {
  position: absolute;
  left: 7%;
  right: 7%;
  top: 27%;
  height: 44%;
  overflow: hidden;
  border-radius: 2px;
  box-shadow:
    0 0 0 3px rgb(255 255 255 / 0.65),
    0 6px 14px rgb(0 0 0 / 0.4);
  background: #0003;
}
.po-wrapper-art img {
  position: absolute;
  width: 128%;
  left: -14%;
  top: -16%;
}
.po-wrapper-foil {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    125deg,
    #ff8a8a33,
    #ffe08a44 calc(var(--mx) * 60%),
    #8affc144,
    #8ad0ff44 calc(40% + var(--mx) * 60%),
    #d58aff33
  );
  mix-blend-mode: color-dodge;
  pointer-events: none;
}
.po-wrapper-logo {
  position: absolute;
  left: 10%;
  width: 80%;
  top: 9%;
  height: 16%;
  object-fit: contain;
  filter: drop-shadow(0 2px 2px rgb(0 0 0 / 0.5));
  z-index: 2;
}
.po-wrapper-name {
  position: absolute;
  left: 4%;
  right: 4%;
  top: 74%;
  text-align: center;
  font-size: calc(var(--cw) * 0.085);
  line-height: 1.1;
  text-shadow: 2px 2px #0009;
  text-transform: uppercase;
}
.po-wrapper-band {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12%;
  padding: 2% 0;
  text-align: center;
  font-size: calc(var(--cw) * 0.05);
  letter-spacing: 0.08em;
  background: rgb(0 0 0 / 0.35);
}
.po-wrapper-count {
  position: absolute;
  right: 6%;
  bottom: 8.5%;
  font-size: calc(var(--cw) * 0.045);
  opacity: 0.85;
}

.po-tear-guide {
  position: absolute;
  left: 4%;
  right: 4%;
  top: 4.2%;
  height: 3px;
  display: flex;
  background: repeating-linear-gradient(90deg, rgb(255 246 216 / 0.9) 0 6px, transparent 6px 11px);
  z-index: 4;
  animation: po-blink 1.2s ease-in-out infinite;
  pointer-events: none;
}
.po-tear-guide i {
  display: block;
  width: 0;
  height: 100%;
  background: #fff6d8;
  box-shadow: 0 0 8px #ffd77a;
}
.po-fast .po-tear-guide,
.po-quick .po-tear-guide,
.po-auto .po-tear-guide {
  display: none;
}
@keyframes po-blink {
  50% {
    opacity: 0.45;
  }
}

/* ---------- cards ---------- */
.po-card {
  position: absolute;
  inset: 0;
  translate: calc(var(--i) * -0.7px) calc(var(--i) * 0.9px);
  perspective: 800px;
}
.po-card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.po-down .po-card-inner {
  transform: rotateY(180deg);
}
.po-card-front,
.po-card-back {
  position: absolute;
  inset: 0;
  border-radius: calc(var(--cw) * 0.045);
  overflow: hidden;
  backface-visibility: hidden;
  box-shadow: 0 6px 12px rgb(20 10 5 / 0.45);
}
.po-card-front {
  background: #e9dfc4;
}
.po-card-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.po-card-missing {
  position: absolute;
  inset: 6%;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: calc(var(--cw) * 0.08);
  color: #4a3a22;
  border: 3px solid #c7b48a;
  border-radius: 4px;
  background: linear-gradient(#f5ecd4, #dccca2);
}
.po-card-back {
  transform: rotateY(180deg);
  /* the real Pokémon TCG card back, the same on every card */
  background: url("../art/card-back.webp") center / 100% 100% no-repeat;
}

.po-anticipate {
  animation: po-wiggle 0.5s ease-in-out infinite;
}
.po-anticipate.po-tier-illustration,
.po-anticipate.po-tier-grail {
  animation-duration: 0.28s;
}
@keyframes po-wiggle {
  25% {
    rotate: -1.6deg;
  }
  75% {
    rotate: 1.6deg;
  }
}
.po-revealed {
  z-index: 50 !important;
  animation: po-pop 0.6s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.po-tier-illustration.po-revealed,
.po-tier-grail.po-revealed {
  animation: po-pop-big 0.9s cubic-bezier(0.3, 1.6, 0.5, 1) forwards;
}
@keyframes po-pop {
  40% {
    scale: 1.12;
  }
}
@keyframes po-pop-big {
  45% {
    scale: 1.28;
  }
  100% {
    scale: 1.12;
  }
}

/* holo foil follows the pointer */
.po-foil {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  mix-blend-mode: color-dodge;
  background: linear-gradient(
    calc(100deg + var(--mx) * 40deg),
    transparent 20%,
    #ff6f6f 32%,
    #ffe96f 40%,
    #6fff9d 48%,
    #6fc8ff 56%,
    #d86fff 64%,
    transparent 78%
  );
  background-size: 250% 250%;
  background-position: calc(var(--mx) * 100%) calc(var(--my) * 100%);
}
.po-tier-holo .po-foil,
.po-reverse .po-foil {
  opacity: 0.3;
}
.po-tier-ultra .po-foil {
  opacity: 0.42;
}
.po-tier-illustration .po-foil,
.po-tier-grail .po-foil {
  opacity: 0.55;
}

.po-banner {
  position: absolute;
  left: 50%;
  bottom: -9%;
  translate: -50% 0;
  white-space: nowrap;
  padding: 4px 10px;
  font-size: clamp(10px, 3.4cqh, 15px);
  letter-spacing: 0.08em;
  color: #342716;
  background: linear-gradient(#ffe77a, #e0a92a);
  border: 2px solid #6f4b13;
  box-shadow: 0 3px #302018;
  animation: po-banner 0.5s cubic-bezier(0.3, 1.6, 0.5, 1) both;
  z-index: 3;
}
.po-tier-illustration .po-banner {
  background: linear-gradient(#ffc2ec, #d978c8);
  border-color: #6b2862;
}
.po-tier-grail .po-banner {
  background: linear-gradient(90deg, #ff9c9c, #ffe59c, #9cffc4, #9cd6ff, #e19cff);
  border-color: #3b2b4a;
}
@keyframes po-banner {
  from {
    scale: 0.2;
    opacity: 0;
  }
}

.po-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 60;
}
.po-spark {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 1px;
  rotate: 45deg;
  box-shadow: 0 0 6px currentColor;
}

/* ---------- tray / summary ---------- */
.po-tray {
  position: absolute;
  left: 3cqw;
  right: 3cqw;
  bottom: 3cqh;
  height: 16cqh;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 1.2cqw;
  z-index: 4;
  transition:
    bottom 0.45s,
    height 0.45s;
}
.po-mini {
  position: relative;
  height: 100%;
  aspect-ratio: 0.716;
  border-radius: 3px;
  background: #e9dfc4;
  box-shadow: 0 3px 6px rgb(20 10 5 / 0.5);
  transition:
    opacity 0.15s,
    height 0.45s;
}
.po-auto .po-mini {
  animation: po-deal 0.35s cubic-bezier(0.3, 1.5, 0.5, 1) both;
}
@keyframes po-deal {
  from {
    translate: 0 -22cqh;
    scale: 0.6;
    opacity: 0;
  }
}
.po-mini img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 3px;
  display: block;
}
.po-mini.po-tier-holo,
.po-mini.po-tier-ultra {
  box-shadow:
    0 0 0 2px #ffe08a,
    0 3px 6px rgb(20 10 5 / 0.5);
}
.po-mini.po-tier-illustration,
.po-mini.po-tier-grail {
  box-shadow:
    0 0 0 2px #ff9ce0,
    0 0 12px #ff9ce0;
}
.po-mini.po-new::after {
  content: "NEW";
  position: absolute;
  top: -6px;
  right: -6px;
  font-size: 9px;
  padding: 1px 4px;
  color: #342716;
  background: #ffe066;
  border: 2px solid #6f4b13;
}
.po-mini .po-val {
  position: absolute;
  left: 50%;
  bottom: -1.9em;
  translate: -50% 0;
  font-size: clamp(9px, 2.6cqh, 12px);
  color: #ffe69a;
  text-shadow: 1px 1px #231b22;
  white-space: nowrap;
}
.po-tray.po-summary {
  top: 8cqh;
  bottom: 19cqh;
  height: auto;
  display: grid;
  grid-template-columns: repeat(5, auto);
  grid-template-rows: repeat(2, minmax(0, 1fr));
  justify-content: center;
  align-content: center;
  row-gap: 6cqh;
}
.po-summary .po-mini {
  height: 100%;
  animation: po-deal-in 0.4s cubic-bezier(0.3, 1.5, 0.5, 1) both;
}
.po-summary .po-mini:nth-child(n) {
  animation-delay: calc(var(--d, 0) * 1ms);
}
.po-auto .po-tray.po-summary {
  top: auto;
  bottom: 3cqh;
  height: 16cqh;
  display: flex;
}
.po-auto .po-summary .po-mini {
  height: 100%;
  animation: po-deal 0.35s cubic-bezier(0.3, 1.5, 0.5, 1) both;
}
.po-mini.po-best {
  z-index: 2;
  animation: po-best 1.4s ease-in-out infinite !important;
}
@keyframes po-best {
  50% {
    translate: 0 -6px;
    filter: brightness(1.15);
  }
}
@keyframes po-deal-in {
  from {
    scale: 0.7;
    opacity: 0;
  }
}

.po-done-bar {
  position: absolute;
  left: 3cqw;
  right: 3cqw;
  bottom: 3cqh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: clamp(10px, 3.2cqh, 14px);
  text-shadow: 2px 2px #231b22;
  z-index: 6;
  animation: po-deal-in 0.4s both;
}
.po-done-bar b {
  color: #ffe69a;
}
.po-auto .po-done-bar {
  top: 3cqh;
  bottom: auto;
}

@media (prefers-reduced-motion: reduce) {
  .po-anticipate,
  .po-rays,
  .po-hint,
  .po-mini.po-best,
  .po-tear-guide {
    animation: none !important;
  }
}

/* the pixel pouch (pixel-pack.js): its own outline and shading, so no frame or sheen */
.po-pack-face.po-pixel {
  background: none;
  box-shadow: none;
  border-radius: 0;
  overflow: visible;
}
.po-pack-face.po-pixel::after {
  display: none;
}
.po-pack-face.po-pixel img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  display: block;
}
