/* Shared floating card view - one DOM tree, one CSS cascade.
   Used by:
     - TMA binder inspect       (frontend/js/app.js)
     - TMA pack reveal          (frontend/js/app.js)
     - Creator admin overlay    (creator/admin.js)

   The cardview is a singleton: at most one is open at a time and the
   backdrop element is reused across invocations. Click outside the stack
   or the close button => onClose() then the cardview is removed.
*/

.cardview-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  overflow-y: auto;
}
.cardview-backdrop.open { display: flex; }

.cardview-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: min(78vw, 320px);
  pointer-events: auto;
  margin: auto;
}

.cardview-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.78em;
  color: var(--muted, #8b9199);
  text-transform: uppercase;
  letter-spacing: 0.10em;
}

/* Non-card chrome (title, controls, actions) starts hidden and fades in
   AFTER the card lands so the user doesn't see the buttons before the
   FLIP completes. card-view.js adds .cardview-chrome-hidden on mount
   and removes it on FLIP finish (or next frame when there's no FLIP). */
.cardview-title,
.cardview-controls,
.cardview-actions {
  opacity: 1;
  transition: opacity 200ms ease-out;
}
.cardview-chrome-hidden { opacity: 0; }

/* Direct perspective wrapper so the card tilts via its own transforms
   (matches the previous .inspect-card-wrap pattern). */
.cardview-card {
  width: 100%;
  display: flex;
  justify-content: center;
  perspective: 1200px;
}
.cardview-card > .card { width: 100%; }

/* 3D flipper for pack-reveal. preserve-3d so both faces can sit in the
   same 3D space; backface-visibility hides whichever face is away from
   the viewer. Pokemon-cards-css technique - no DOM swap mid-animation,
   so the card never disappears between front and back. */
.cardview-flipper {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 7;
  transform-style: preserve-3d;
  will-change: transform;
}
.cardview-flipper-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.cardview-flipper-face--back  { transform: rotateY(0deg); }
.cardview-flipper-face--front { transform: rotateY(180deg); }

.cardview-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.cardview-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}
/* Actions need to read clearly against the blurred backdrop. Solid panel
   background + larger tap target + bolder font. The .btn rule in the
   game stylesheet sets a default look; this layer makes them stand out
   above the blur layer. */
.cardview-actions .btn {
  width: 100%;
  background: rgba(22, 26, 32, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--fg, #e5e7eb);
  font-size: 0.95em;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 13px 16px;
  min-height: 48px;
}
.cardview-actions .btn:hover:not(:disabled) {
  background: rgba(30, 36, 46, 0.95);
  border-color: var(--accent, #19c37d);
  color: var(--accent, #19c37d);
}
.cardview-actions .btn-primary {
  background: rgba(25, 195, 125, 0.18);
  border-color: rgba(25, 195, 125, 0.55);
  color: var(--accent, #19c37d);
}
.cardview-actions .btn-primary:hover:not(:disabled) {
  background: rgba(25, 195, 125, 0.30);
}
.cardview-actions .btn-danger {
  background: rgba(255, 107, 107, 0.15);
  border-color: rgba(255, 107, 107, 0.50);
  color: #ff8c8c;
}

.cardview-close {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(20, 20, 28, 0.85);
  border: 1px solid var(--border, #2a2f36);
  color: var(--fg, #e5e7eb);
  font-size: 1.5em;
  line-height: 1;
  cursor: pointer;
  z-index: 101;
  padding: 0;
  min-height: unset;
}
.cardview-close:hover { background: rgba(40, 40, 52, 0.95); }

@media (max-width: 480px) {
  .cardview-backdrop { padding: 16px; }
}
