/* =========================================================================
   PACK OPENER — layout & components
   ========================================================================= */
.pack-opener {
  width: 100%;
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 16px;
  position: relative;
}

.error-wrapper {
  display: flex;
  width: 100%;
  min-height: 60vh;
  justify-content: center;
  align-items: center;
}

/* ---- Top bar ---- */
.pack-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 4px;
}

.skip-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  padding: 6px 12px;
  border: 1px solid rgba(128, 128, 128, 0.35);
  border-radius: 20px;
  font-size: 0.85rem;
}

.skip-toggle input {
  cursor: pointer;
}

.pack-counter {
  font-size: 0.9rem;
  opacity: 0.85;
}

/* ---- Stage (loader + pack) ---- */
.pack-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
}

/* Light burst behind the pack when it opens */
.pack-flash {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95) 0%, rgba(255, 246, 209, 0.6) 35%, rgba(124, 114, 72, 0) 70%);
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}

.pack-flash.active {
  animation: pack-flash 0.6s ease-out forwards;
}

@keyframes pack-flash {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
  35% { opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(22); opacity: 0; }
}

.pack-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 18px;
}

#pack-standard {
  position: relative;
  z-index: 10;
  display: inline-block;
}

#pack-standard img {
  max-width: 280px;
  width: 60vw;
  box-shadow: 0 0 90px 0 rgba(124, 114, 72, 0.4);
  outline: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 6px;
  cursor: pointer;
}

#pack-standard img:hover {
  animation: pulsate 2s ease-out infinite;
}

.pack-hint {
  font-size: 0.85rem;
  opacity: 0.7;
  letter-spacing: 0.02em;
}

.skip-btn {
  position: absolute;
  bottom: 18px;
  z-index: 20;
}

@keyframes pulsate {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.96); opacity: 0.92; box-shadow: 0 0 90px 0 rgba(0, 0, 0, 0.29); }
  100% { transform: scale(1); opacity: 1; }
}

/* Opening sequence: shake, then burst away */
#pack-standard.shake img {
  animation: pack-shake 0.3s ease-in-out both;
}

@keyframes pack-shake {
  0%, 100% { transform: translateX(0) rotate(0); }
  20% { transform: translateX(-6px) rotate(-2deg); }
  40% { transform: translateX(6px) rotate(2deg); }
  60% { transform: translateX(-4px) rotate(-1.5deg); }
  80% { transform: translateX(4px) rotate(1.5deg); }
}

#pack-standard.burst img {
  animation: pack-burst 0.45s cubic-bezier(0.34, 1.4, 0.6, 1) forwards;
}

@keyframes pack-burst {
  0% { transform: scale(1); opacity: 1; }
  45% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* ---- Revealed cards ---- */
.pack-wrapper {
  margin-top: 4vh;
  width: 100%;
  position: relative;
  display: none;
  justify-content: center;
  overflow: auto;
}

.card-holder {
  display: flex;
  flex-wrap: wrap;
  max-width: 1100px;
  min-width: 204px;
  justify-content: center;
  gap: 20px;
  width: 100%;
  margin-bottom: 30px;
}

.card {
  width: 203px;
  height: 287px;
  cursor: pointer;
  position: relative;
  transform-style: preserve-3d;
  transform-origin: center right;
  transition: transform 1s;
  margin-bottom: 16px;
}

.card.is-flipped {
  transform: translateX(-100%) rotateY(-180deg);
}

/* Staggered entrance when the pack opens (face-down). animation-delay is set per
   card in JS; the helper classes are removed on animationend so the flip
   transition can take over the transform afterwards. */
.card.enter {
  opacity: 0;
}

.card.enter.in {
  animation: card-in 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(28px) scale(0.92); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.card__face {
  position: absolute;
  width: 100%;
  height: 100%;
  color: white;
  text-align: center;
  font-weight: bold;
  font-size: 40px;
  backface-visibility: hidden;
  border-radius: 11px;
}

.card__face--back {
  transform: rotateY(180deg);
  border: 1px solid black;
}

/* Card hover actions (only meaningful once flipped face-up) */
.card-actions {
  position: absolute;
  bottom: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transform: rotateY(180deg); /* sit on the back face */
  backface-visibility: hidden;
  transition: opacity 0.15s ease;
  z-index: 5;
}

.card.is-flipped:hover .card-actions {
  opacity: 1;
}

.card-action {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(20, 22, 26, 0.85);
  color: #fff;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: background 0.15s ease, transform 0.15s ease;
}

.card-action:hover {
  transform: scale(1.1);
}

.card-action-add:hover {
  background: #28a745;
}

.card-action-view:hover {
  background: #007bff;
}

@media (hover: none) {
  .card.is-flipped .card-actions {
    opacity: 1;
  }
}

/* ---- Actions ---- */
.actions-wrapper {
  display: none;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px auto 60px auto;
}

.action-btn {
  white-space: nowrap;
}

/* ---- Card highlight overlay ---- */
.card-highlight {
  display: none;
  z-index: 100;
  width: 100%;
  height: 100%;
  padding: 0;
  position: fixed;
  max-width: 100%;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, 0.8);
  justify-content: center;
  align-items: center;
}

.card-highlight > img {
  width: 480px;
  border-radius: 26px;
  border: 1px solid black;
  max-width: 90vw;
}

.view-in-another-tab {
  border: 1px solid #dc0800;
  top: calc(50% + 345px);
  height: 24px;
  line-height: 24px;
  width: 100px;
  left: calc(50% - 50px);
  position: absolute;
  background-color: white;
  border-radius: 20px;
  text-align: center;
}

.view-in-another-tab a {
  color: #dc0800;
}

/* =========================================================================
   MODALS (self-contained, no Bootstrap JS dependency)
   ========================================================================= */
.pack-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1050;
  background: rgba(0, 0, 0, 0.55);
  justify-content: center;
  align-items: flex-start;
  padding: 8vh 16px 16px;
}

.pack-modal-dialog {
  background: var(--white, #fff);
  color: inherit;
  width: 100%;
  max-width: 460px;
  border-radius: 10px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.pack-modal-header,
.pack-modal-footer {
  display: flex;
  align-items: center;
  padding: 14px 18px;
}

.pack-modal-header {
  justify-content: space-between;
  border-bottom: 1px solid rgba(128, 128, 128, 0.25);
}

.pack-modal-footer {
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid rgba(128, 128, 128, 0.25);
}

.pack-modal-body {
  padding: 18px;
}

.pack-modal-body textarea {
  width: 100%;
}

.pack-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
}

.pack-modal-close:hover {
  opacity: 1;
}

/* ---- Toast ---- */
.pack-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #28a745;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 1100;
}

.pack-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#header {
  margin-bottom: 0;
}

/* ---- Foil overlay ---- */
.foil {
  opacity: 1;
  width: 100%;
  height: 100%;
  z-index: 10;
  border: 1px solid black;
  border-radius: 11px;
  background: linear-gradient(48deg,
      rgba(227, 193, 244, 0.35),
      rgba(217, 215, 237, 0.35),
      rgba(223, 247, 241, 0.35),
      rgba(172, 240, 255, 0.35),
      rgba(227, 193, 244, 0.35),
      rgba(217, 215, 237, 0.35),
      rgba(223, 247, 241, 0.35),
      rgba(172, 240, 255, 0.35),
      rgba(227, 193, 244, 0.35));
  animation: foil 8s ease infinite;
  background-size: 200% 200%;
}

@keyframes foil {
  0% { background-position: 84% 0; }
  50% { background-position: 17% 100%; }
  100% { background-position: 84% 0; }
}
