/* Pack opening ceremony (packs.php, assets/js/pack-opening.js). Scoped to .po- and the reveal section. */

.sb-reveal.is-ceremony {
  --po-gold: #f2c94c;
  --po-glow: #7ab8ff;
}

/* ---- velvet arena and floating booster ------------------------------------ */

.po-stage {
  position: relative;
  min-height: 560px;
  margin: 0 auto 18px;
  border-radius: 22px;
  overflow: hidden;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  padding: 30px 16px 24px;
  perspective: 1100px;
  isolation: isolate;
  border: 1px solid rgba(242, 201, 76, 0.25);
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.7);
}

.po-stage[hidden] {
  display: none;
}

.po-arena {
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(122, 18, 52, 0.55), transparent 62%),
    radial-gradient(ellipse at 50% 120%, rgba(242, 201, 76, 0.12), transparent 55%),
    linear-gradient(180deg, #2a0814, #12040b 70%, #06020a);
}

/* A faint weave on the velvet, so it reads as fabric rather than a flat colour. */
.po-arena::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.18) 0 1px, transparent 1px 4px);
  mix-blend-mode: overlay;
}

.po-arena::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 8%;
  width: 70%;
  height: 16%;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.7), transparent 70%);
  filter: blur(6px);
}

.po-pack {
  position: relative;
  width: min(290px, 72vw);
  aspect-ratio: 3 / 4.6;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  transform-style: preserve-3d;
  transform: rotateX(var(--po-rx, 6deg)) rotateY(var(--po-ry, -8deg));
  transition: transform 0.2s ease-out, opacity 0.6s ease 0.35s;
  animation: po-float 4.2s ease-in-out infinite;
  -webkit-tap-highlight-color: transparent;
}

.po-pack:focus-visible {
  outline: 3px solid #7ab8ff;
  outline-offset: 8px;
  border-radius: 16px;
}

.po-pack-face {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(160deg, #3b0f1c, #1a0710);
  border: 1px solid rgba(242, 201, 76, 0.5);
  box-shadow: 0 34px 60px rgba(0, 0, 0, 0.65), 0 0 46px rgba(242, 201, 76, 0.22);
  transform: translateZ(18px);
}

.po-pack-art {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.po-pack-label {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(7, 9, 19, 0.82);
  border: 1px solid rgba(242, 201, 76, 0.5);
  color: #ffe9a6;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* The foil strip across the top. Its zig-zag bottom edge reads as torn foil. */
.po-strip {
  position: absolute;
  left: -3%;
  right: -3%;
  top: -2%;
  height: 15%;
  z-index: 2;
  display: grid;
  place-items: center;
  background: linear-gradient(100deg, #8f97ac 0%, #f4f6fb 22%, #a7aec4 40%, #ffffff 58%, #7d8498 80%, #e7ebf5 100%);
  clip-path: polygon(0 0, 100% 0, 100% 72%, 96% 100%, 92% 74%, 88% 100%, 84% 72%, 80% 100%, 76% 74%, 72% 100%, 68% 72%, 64% 100%, 60% 74%, 56% 100%, 52% 72%, 48% 100%, 44% 74%, 40% 100%, 36% 72%, 32% 100%, 28% 74%, 24% 100%, 20% 72%, 16% 100%, 12% 74%, 8% 100%, 4% 72%, 0 100%);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.4);
  transform: translateZ(40px);
}

.po-strip span {
  font: 900 0.72rem system-ui, sans-serif;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: #2a2f40;
}

.po-pack.is-torn {
  animation: none;
  transform: rotateX(62deg) translateY(-70px) scale(0.86);
  opacity: 0;
}

.po-pack.is-torn .po-strip {
  transition: transform 0.85s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.85s ease;
  transform: translate(140%, -90%) rotate(24deg) translateZ(60px);
  opacity: 0;
}

.po-hint {
  margin: 0;
  color: #f3e7d0;
  font-size: 0.95rem;
  text-align: center;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8);
}

.po-fallback {
  appearance: none;
  border: 1px solid rgba(242, 201, 76, 0.7);
  background: rgba(242, 201, 76, 0.12);
  color: #ffe9a6;
  border-radius: 10px;
  padding: 10px 18px;
  font-weight: 800;
  cursor: pointer;
}

@keyframes po-float {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -10px; }
}

/* ---- cards -------------------------------------------------------------- */

.po-grid {
  perspective: 1100px;
}

.po-grid.po-emerge .po-card {
  animation: po-emerge 0.85s cubic-bezier(0.2, 0.85, 0.25, 1) both;
  animation-delay: var(--sb-delay, 0ms);
}

@keyframes po-emerge {
  from { opacity: 0; transform: translateY(-120px) scale(0.55) rotateX(40deg); }
  to { opacity: 1; transform: none; }
}

/* Rarity auras, shown on the back while the card is facedown. */
.po-card {
  --po-aura: #ffffff;
}

.po-card.po-common { --po-aura: #f5f7ff; }
.po-card.po-uncommon { --po-aura: #7dffb0; }
.po-card.po-rare { --po-aura: #4fe3ff; }
.po-card.po-epic { --po-aura: #b57bff; }
.po-card.po-legendary { --po-aura: #ffcf4a; }
.po-card.po-mythic { --po-aura: #ff5fd2; }

/* No filter on the card itself: a filter would flatten the 3D flip. The aura lives on the back face. */
.po-card.po-facedown .sb-back {
  box-shadow: inset 0 0 0 2px var(--po-aura), 0 0 26px var(--po-aura);
}

.po-card.po-facedown:hover,
.po-card.po-facedown:focus-visible {
  transform: translateY(-6px);
}

/* Holographic sheen on Rare and above, once the card is face up. Follows the pointer. */
.po-card .sb-holo {
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.po-card.po-rare.is-flipped .sb-holo,
.po-card.po-epic.is-flipped .sb-holo,
.po-card.po-legendary.is-flipped .sb-holo,
.po-card.po-mythic.is-flipped .sb-holo {
  opacity: 1;
  mix-blend-mode: color-dodge;
  background:
    radial-gradient(circle at var(--po-sheen-x, 50%) var(--po-sheen-y, 40%), rgba(255, 255, 255, 0.65), transparent 38%),
    conic-gradient(from 20deg, #ff6ad5, #ffe36b, #5cffb1, #6fd8ff, #b57bff, #ff6ad5);
  opacity: 0.28;
  animation: po-sheen 6s linear infinite;
}

@keyframes po-sheen {
  from { filter: hue-rotate(0deg); }
  to { filter: hue-rotate(360deg); }
}

/* ---- summary dialog ----------------------------------------------------- */

.po-summary {
  width: min(680px, 94vw);
  max-height: 88vh;
  overflow: auto;
  padding: 20px;
  border-radius: 18px;
  border: 1px solid rgba(242, 201, 76, 0.45);
  background: #0d1122;
  color: #e8ecff;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
}

.po-summary::backdrop {
  background: rgba(3, 4, 10, 0.72);
}

.po-summary-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.po-summary-head h2 {
  margin: 0;
  font-size: 1.3rem;
  color: #ffe9a6;
}

.po-summary-close {
  appearance: none;
  border: 1px solid #26305a;
  background: #151b38;
  color: #e8ecff;
  border-radius: 9px;
  padding: 7px 14px;
  cursor: pointer;
  font-weight: 700;
}

.po-summary-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 10px;
}

.po-summary-stats div {
  padding: 10px;
  border-radius: 12px;
  background: #151b38;
  border: 1px solid #26305a;
}

.po-summary-stats dt {
  font-size: 0.75rem;
  color: #97a3cc;
}

.po-summary-stats dd {
  margin: 2px 0 0;
  font-size: 1.15rem;
  font-weight: 800;
}

.po-summary-note {
  margin: 0 0 14px;
  color: #97a3cc;
  font-size: 0.86rem;
}

.po-summary-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}

.po-summary-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 12px;
  background: #151b38;
  border: 1px solid #26305a;
  box-shadow: inset 3px 0 0 var(--po-aura, #26305a);
}

.po-summary-item img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 8px;
  flex: 0 0 auto;
}

.po-summary-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.po-summary-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.po-summary-copy span {
  font-size: 0.76rem;
  color: #97a3cc;
}

.po-tag {
  font-style: normal;
  justify-self: start;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.po-tag.new {
  background: rgba(94, 224, 138, 0.16);
  color: #5ee08a;
}

.po-tag.dup {
  background: rgba(151, 163, 204, 0.16);
  color: #97a3cc;
}

.po-summary-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

@media (max-width: 640px) {
  .po-stage {
    min-height: 480px;
  }

  .po-summary-stats {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .po-pack,
  .po-grid.po-emerge .po-card,
  .po-card .sb-holo {
    animation: none !important;
    transition: none !important;
  }
}
