/* ═══════════════════════════════════════════════════════════════════════════
   PACK SHOP + PACK OPENING (v3.2.35)
   Motion lives in js/pack-opening.js (GSAP); this file is layout and look.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Shop cards ─────────────────────────────────────────────────────────── */
#pack-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  max-width: 720px;
  margin: 4px auto 10px;
}
@media (max-width: 420px) {
  #pack-options { grid-template-columns: 1fr; }
}
.pack-option {
  font: inherit;
  color: var(--text);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 14px 10px 12px;
  background: linear-gradient(180deg, #18150e 0%, #0d0c09 100%);
  border: 1px solid var(--border2);
  border-radius: 12px;
  cursor: pointer;
  overflow: hidden;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.pack-option:hover { border-color: var(--gold); transform: translateY(-2px); }
.pack-option:active { transform: scale(.97); }
.pack-option:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.pack-option.featured {
  border-color: rgba(212,175,55,.6);
  box-shadow: inset 0 0 28px rgba(212,175,55,.12), 0 0 18px rgba(212,175,55,.08);
}
.pack-badge {
  position: absolute; top: 0; right: 0; z-index: 6;
  background: var(--gold); color: #000;
  font-family: 'Bebas Neue', sans-serif;
  font-size: .62rem; letter-spacing: 2px;
  padding: 3px 10px; border-bottom-left-radius: 8px;
}

/* Pack art: one pack, or a fan for bundles that opens up on hover. */
.pack-art {
  position: relative;
  width: 100%;
  height: 112px;
  margin-bottom: 8px;
  display: flex;
  justify-content: center;
  align-items: flex-end;
}
.pack-art img {
  height: 100%;
  width: auto;
  filter: drop-shadow(0 8px 12px rgba(0,0,0,.65));
  transition: transform .25s cubic-bezier(.2,.8,.2,1);
  -webkit-user-drag: none;
  user-select: none;
}
.pack-option:hover .pack-art:not(.pack-art-stack) img { transform: translateY(-4px) rotate(-3deg); }
.pack-art-stack img {
  position: absolute;
  bottom: 0;
  left: 50%;
  height: 92%;
  transform-origin: 50% 100%;
  transform: translateX(-50%) translateX(calc(var(--o) * 24%)) rotate(calc(var(--o) * 9deg));
}
.pack-option:hover .pack-art-stack img {
  transform: translateX(-50%) translateX(calc(var(--o) * 34%)) rotate(calc(var(--o) * 13deg));
}
.pack-art-stack img:nth-child(1) { --o: -1; }
.pack-art-stack img:nth-child(2) { --o: 0; z-index: 2; height: 100%; }
.pack-art-stack img:nth-child(3) { --o: 1; }
.pack-art-big img:nth-child(1) { --o: -2; height: 84%; }
.pack-art-big img:nth-child(2) { --o: -1; z-index: 2; height: 92%; }
.pack-art-big img:nth-child(3) { --o: 0; z-index: 3; height: 100%; }
.pack-art-big img:nth-child(4) { --o: 1; z-index: 2; height: 92%; }
.pack-art-big img:nth-child(5) { --o: 2; height: 84%; }
.pack-art-count {
  position: absolute;
  right: 6%;
  bottom: 2px;
  z-index: 5;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.05rem;
  letter-spacing: 1px;
  color: #120e04;
  background: linear-gradient(180deg, #f3d766, #c9a227);
  padding: 1px 7px;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,.5);
}
.pack-name {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.05rem; letter-spacing: 3px; color: var(--text);
}
.pack-contents {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: .72rem; letter-spacing: 2px; color: var(--muted);
}
.pack-price {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.3rem; letter-spacing: 2px; color: var(--gold);
  margin-top: 2px;
}
.pack-original {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: .75rem; letter-spacing: 1px;
  color: var(--muted); text-decoration: line-through;
  margin-left: 4px;
}
.pack-save {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700; font-size: .66rem; letter-spacing: 2px;
  color: #33d97c;
  border: 1px solid rgba(51,217,124,.45);
  background: rgba(51,217,124,.08);
  border-radius: 999px;
  padding: 1px 8px;
}
#pack-odds {
  text-align: center;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: .7rem; letter-spacing: 1.5px;
  color: var(--muted);
  margin: 0 auto 14px;
  max-width: 720px;
}
#pack-odds b { font-weight: 700; }
#pack-odds .odds-legendary { color: #D4AF37; }
#pack-odds .odds-epic { color: #c66bff; }
#pack-odds .odds-rare { color: #3a8fdf; }
#pack-odds .odds-common { color: #9aa3ad; }

/* ── Opening overlay ─────────────────────────────────────────────────────── */
#pack-opening-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  flex-direction: column;
  padding: var(--safe-top, 0px) var(--safe-right, 0px) 0 var(--safe-left, 0px);
  background: #000;
  color: var(--text);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
#pack-opening-overlay.hidden { display: none; }
.po-bg {
  position: absolute; inset: 0;
  pointer-events: none;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 45%, #1d1709 0%, #0b0a07 45%, #000 100%);
}
.po-rays {
  position: absolute;
  left: 50%; top: 46%;
  width: 180vmax; height: 180vmax;
  margin: -90vmax 0 0 -90vmax;
  background: repeating-conic-gradient(from 0deg, rgba(212,175,55,.08) 0deg 5deg, transparent 5deg 15deg);
  -webkit-mask-image: radial-gradient(circle, #000 0%, transparent 42%);
  mask-image: radial-gradient(circle, #000 0%, transparent 42%);
}
.po-top {
  position: relative;
  flex: none;
  text-align: center;
  padding: 12px 16px 0;
}
#pack-opening-status {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.35rem; letter-spacing: 6px;
  color: var(--gold);
  min-height: 1.35em;
  text-shadow: 0 0 18px rgba(212,175,55,.35);
}
#pack-opening-sub {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: .72rem; letter-spacing: 3px;
  color: var(--muted);
  min-height: 1.1em;
}
#pack-opening-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1100px;
}

/* The pack: body and top strip are the same image, clipped along a torn line. */
.po-pack {
  position: relative;
  height: min(64vh, 380px);
  aspect-ratio: 427 / 690;
  container-type: size;
}
.po-pack-el {
  position: absolute; inset: 0;
  cursor: pointer;
  transform-style: preserve-3d;
  -webkit-tap-highlight-color: transparent;
}
.po-pack-el:focus-visible { outline: 2px solid var(--gold); outline-offset: 6px; border-radius: 8px; }
.po-pack-body, .po-pack-top {
  position: absolute; inset: 0;
  filter: drop-shadow(0 18px 28px rgba(0,0,0,.75));
}
.po-pack-body img, .po-pack-top img, .po-pack-ghost {
  width: 100%; height: 100%;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
}
.po-pack-top {
  clip-path: polygon(0 0, 100% 0, 100% 11.4%, 93.75% 12.6%, 87.5% 11.2%, 81.25% 12.7%, 75% 11.3%, 68.75% 12.5%, 62.5% 11.1%, 56.25% 12.6%, 50% 11.4%, 43.75% 12.7%, 37.5% 11.2%, 31.25% 12.5%, 25% 11.3%, 18.75% 12.6%, 12.5% 11.1%, 6.25% 12.5%, 0 11.4%);
}
.po-pack-body {
  clip-path: polygon(0 11.4%, 6.25% 12.5%, 12.5% 11.1%, 18.75% 12.6%, 25% 11.3%, 31.25% 12.5%, 37.5% 11.2%, 43.75% 12.7%, 50% 11.4%, 56.25% 12.6%, 62.5% 11.1%, 68.75% 12.5%, 75% 11.3%, 81.25% 12.7%, 87.5% 11.2%, 93.75% 12.6%, 100% 11.4%, 100% 100%, 0 100%);
}
.po-pack-glow {
  position: absolute; inset: -14%;
  border-radius: 40%;
  background: radial-gradient(closest-side, var(--po-glow, #D4AF37), transparent);
  opacity: .32;
  filter: blur(16px);
  pointer-events: none;
}
/* The art says "10 CARDS" on every pack; cover that line with the real count. */
.po-pack-count {
  position: absolute;
  left: 16%; right: 16%;
  top: 74.6%; height: 5.8%;
  display: flex; align-items: center; justify-content: center;
  background: #0c0e17;
  border-radius: 3px;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  font-size: 9px;
  font-size: 3.1cqh;
  letter-spacing: .05em;
  color: #e3c46c;
  white-space: nowrap;
  pointer-events: none;
}
.po-pack-shine {
  position: absolute; inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 35%, rgba(255,255,255,.22) 48%, rgba(255,255,255,.05) 55%, transparent 65%);
  background-size: 300% 100%;
  mix-blend-mode: screen;
  -webkit-mask: url(../assets/pack_hustle.webp) center / 100% 100% no-repeat;
  mask: url(../assets/pack_hustle.webp) center / 100% 100% no-repeat;
  animation: po-shine 3.4s ease-in-out infinite;
}
@keyframes po-shine {
  0%, 30% { background-position: 120% 0; }
  70%, 100% { background-position: -40% 0; }
}
/* Bundles: more packs stacked behind. */
.po-pack-ghost {
  position: absolute; inset: 0;
  background: url(../assets/pack_hustle.webp) center / 100% 100% no-repeat;
  filter: brightness(.4) drop-shadow(0 10px 18px rgba(0,0,0,.7));
  display: none;
}
.po-pack[data-stack="2"] .po-pack-ghost:nth-child(1),
.po-pack[data-stack="3"] .po-pack-ghost:nth-child(1) { display: block; transform: translate(12%, -2%) rotate(8deg); }
.po-pack[data-stack="3"] .po-pack-ghost:nth-child(2) { display: block; transform: translate(-12%, -2%) rotate(-8deg); }

#pack-opening-flash {
  position: absolute;
  left: 50%; top: 50%;
  width: 70vmin; height: 70vmin;
  margin: -35vmin 0 0 -35vmin;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, rgba(255,236,190,.85) 22%, rgba(212,175,55,.25) 45%, transparent 70%);
  opacity: 0;
  pointer-events: none;
}

/* Card grid: every card fits on screen; JS sets the column count and size. */
#pack-opening-cards {
  position: absolute; inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--po-cols, 3), var(--po-w, 100px));
  grid-auto-rows: var(--po-h, 137px);
  gap: var(--po-gap, 12px);
  justify-content: center;
  align-content: center;
  padding: 8px 12px;
  pointer-events: none;
}
.po-slot {
  position: relative;
  width: var(--po-w, 100px);
  height: var(--po-h, 137px);
  pointer-events: auto;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.po-card {
  position: absolute; left: 0; top: 0; z-index: 1;
  width: 130px; height: 178px;
  transform: scale(var(--po-scale, .77));
  transform-origin: 0 0;
  perspective: 900px;
}
.po-flip {
  position: relative;
  width: 100%; height: 100%;
  transform-style: preserve-3d;
}
.po-slot.is-flipped .po-flip { transform: rotateY(180deg); }
.po-back, .po-front {
  position: absolute; inset: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: 9px;
  overflow: hidden;
}
.po-front { transform: rotateY(180deg); }
.po-front .po-face {
  width: 130px !important;
  height: 178px !important;
  margin: 0 !important;
  transform: none !important;
}

/* Card back. Rare-or-better backs glow in their colour; JS breathes --po-pulse. */
.po-back {
  --po-rc: rgba(212,175,55,.35);
  --po-pulse: 0;
  background:
    repeating-linear-gradient(45deg, rgba(212,175,55,.05) 0 6px, transparent 6px 12px),
    radial-gradient(circle at 50% 42%, #2a2213 0%, #0d0b07 70%);
  border: 2px solid var(--po-rc);
  box-shadow: 0 0 calc(4px + 16px * var(--po-pulse)) var(--po-rc), inset 0 0 18px rgba(0,0,0,.6);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px;
}
.po-back-logo {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 2rem; letter-spacing: 3px;
  color: var(--gold);
  text-shadow: 0 2px 0 #000, 0 0 16px rgba(212,175,55,.35);
}
.po-back-rarity {
  width: 34px; height: 4px; border-radius: 2px;
  background: var(--po-rc);
  opacity: .9;
}
.po-slot.rarity-rare .po-back { --po-rc: #3a8fdf; }
.po-slot.rarity-epic .po-back { --po-rc: #c66bff; }
.po-slot.rarity-legendary .po-back { --po-rc: #D4AF37; border-width: 3px; }
.po-slot.rarity-rare.is-flipped .po-front { box-shadow: 0 0 14px #3a8fdf; }
.po-slot.rarity-epic.is-flipped .po-front { box-shadow: 0 0 18px #c66bff; }
.po-slot.rarity-legendary.is-flipped .po-front { box-shadow: 0 0 22px #D4AF37; }

.po-new {
  position: absolute;
  top: -6px; right: -6px; z-index: 3;
  font-family: 'Bebas Neue', sans-serif;
  font-size: calc(9px + var(--po-w, 100px) * .06);
  letter-spacing: 1.5px;
  color: #fff;
  background: linear-gradient(180deg, #ff4f7b, #d81b4f);
  padding: 1px 7px;
  border-radius: 5px;
  transform: rotate(-8deg);
  box-shadow: 0 3px 8px rgba(0,0,0,.6);
  pointer-events: none;
}
.po-new[hidden] { display: none; }
.po-burst {
  position: absolute;
  inset: -40%;
  z-index: 0;
  border-radius: 50%;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(circle, #000 20%, transparent 65%);
  mask-image: radial-gradient(circle, #000 20%, transparent 65%);
}
.po-burst.rarity-rare { background: repeating-conic-gradient(rgba(58,143,223,.8) 0 7deg, transparent 7deg 20deg); }
.po-burst.rarity-epic { background: repeating-conic-gradient(rgba(198,107,255,.85) 0 7deg, transparent 7deg 18deg); }
.po-burst.rarity-legendary { background: repeating-conic-gradient(rgba(255,215,90,.95) 0 8deg, transparent 8deg 16deg); }

/* Bottom bar: summary chips and the two actions. Fixed height so the grid,
   sized when the cards are dealt, never ends up under the buttons. */
.po-bottom {
  position: relative;
  flex: none;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 4px 16px calc(12px + var(--safe-bottom, 0px));
}
@media (min-aspect-ratio: 4/3) {
  .po-bottom { min-height: 62px; flex-direction: row; gap: 18px; }
}
#pack-opening-summary {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px;
}
#pack-opening-summary[hidden] { display: none; }
.po-chip {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: .72rem; letter-spacing: 2px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid currentColor;
  background: rgba(255,255,255,.04);
}
.po-chip b { font-weight: 800; margin-right: 2px; }
.po-chip.rarity-legendary { color: #D4AF37; }
.po-chip.rarity-epic { color: #c66bff; }
.po-chip.rarity-rare { color: #3a8fdf; }
.po-chip.rarity-common { color: #9aa3ad; }
.po-chip.po-chip-new { color: #ff4f7b; }
.po-actions { display: flex; gap: 10px; }
.po-btn {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.1rem; letter-spacing: 4px;
  min-width: 170px;
  padding: 10px 24px;
  border-radius: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.po-btn[hidden] { display: none; }
.po-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.po-btn-gold {
  color: #141008;
  border: none;
  background: linear-gradient(180deg, #f3d766 0%, #c9a227 100%);
  box-shadow: 0 4px 0 #7a5f12;
}
.po-btn-gold:active { transform: translateY(2px); box-shadow: 0 2px 0 #7a5f12; }
.po-btn-gold:disabled { filter: saturate(.6) brightness(.8); }
.po-btn-ghost {
  color: var(--gold);
  background: rgba(212,175,55,.06);
  border: 1px solid rgba(212,175,55,.55);
}
.po-btn-ghost:active { transform: scale(.97); }

/* Card inspect opens above the pack screen while it is up. */
#inspect-overlay.over-pack { z-index: 5600; }

@media (prefers-reduced-motion: reduce) {
  .po-pack-shine { animation: none; }
}
