/*
 * NumbahWan Card Frame System v3.0
 * Premium Fantasy TCG Frames - Unique Designs
 * 
 * FEATURES:
 * - Full-bleed card artwork (image fills the inner area)
 * - Metallic gradient frame borders
 * - Elegant name banners
 * - Gem-style stat displays
 * - Animated glows and effects (NO cheap emoji icons)
 */

/* ============================================
   CSS VARIABLES - Premium Color Palette
   ============================================ */
:root {
  /* Mythic - Divine Fire & Gold */
  --mythic-primary: #ff6b00;
  --mythic-secondary: #fbbf24;
  --mythic-dark: #7f1d1d;
  --mythic-glow: rgba(255, 107, 0, 0.7);
  
  /* Legendary - Royal Gold & Amber */
  --legendary-primary: #fbbf24;
  --legendary-secondary: #d97706;
  --legendary-dark: #78350f;
  --legendary-glow: rgba(251, 191, 36, 0.6);
  
  /* Epic - Arcane Purple & Violet */
  --epic-primary: #a855f7;
  --epic-secondary: #7c3aed;
  --epic-dark: #3b0764;
  --epic-glow: rgba(168, 85, 247, 0.5);
  
  /* Rare - Crystal Blue & Cyan */
  --rare-primary: #3b82f6;
  --rare-secondary: #2563eb;
  --rare-dark: #1e3a5f;
  --rare-glow: rgba(59, 130, 246, 0.5);
  
  /* Uncommon - Forest Green & Emerald */
  --uncommon-primary: #22c55e;
  --uncommon-secondary: #059669;
  --uncommon-dark: #064e3b;
  --uncommon-glow: rgba(34, 197, 94, 0.4);
  
  /* Common - Steel Grey & Silver */
  --common-primary: #71717a;
  --common-secondary: #52525b;
  --common-dark: #27272a;
  --common-glow: rgba(113, 113, 122, 0.3);
  
  /* Card Dimensions */
  --card-width: 260px;
  --card-height: 380px;
  --card-radius: 16px;
  --frame-thickness: 8px;
  --inner-radius: 12px;
}

/* ============================================
   BASE CARD STRUCTURE
   ============================================ */
.nw-card {
  position: relative;
  width: var(--card-width);
  height: var(--card-height);
  border-radius: var(--card-radius);
  overflow: hidden; /* Critical: clip all child elements and pseudo-elements */
  cursor: pointer;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), 
              box-shadow 0.3s ease;
  flex-shrink: 0;
  background: #0a0a12;
  /* Ensure pseudo-elements stay within bounds */
  isolation: isolate;
}

.nw-card:hover {
  transform: translateY(-10px) scale(1.02);
  z-index: 10;
}

/* Inner card container - holds the artwork */
.nw-card-inner {
  position: absolute;
  top: var(--frame-thickness);
  left: var(--frame-thickness);
  right: var(--frame-thickness);
  bottom: var(--frame-thickness);
  border-radius: var(--inner-radius);
  overflow: hidden;
  z-index: 2;
  background: #111;
}

/* Card Art - Full bleed image */
.nw-card-art {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  z-index: 1;
  transition: transform 0.4s ease;
}

.nw-card:hover .nw-card-art {
  transform: scale(1.05);
}

/* Image gradient overlay for text readability */
.nw-card-inner::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.6) 40%, transparent 100%);
  z-index: 2;
  pointer-events: none;
}

/* ============================================
   FRAME BORDER - Metallic Effect
   ============================================ */
.nw-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--card-radius);
  padding: var(--frame-thickness);
  background: linear-gradient(180deg, #3f3f46 0%, #27272a 50%, #3f3f46 100%);
  -webkit-mask: 
    linear-gradient(#fff 0 0) content-box, 
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  z-index: 3;
  pointer-events: none;
}

/* ============================================
   NAME BANNER - Bottom Overlay
   ============================================ */
.nw-card-banner {
  position: absolute;
  bottom: 55px;
  left: 12px;
  right: 12px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.85);
  border-radius: 8px;
  text-align: center;
  z-index: 10;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.1);
}

.nw-card-name {
  font-family: 'Orbitron', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0;
  line-height: 1.2;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nw-card-title {
  font-family: system-ui, sans-serif;
  font-size: 9px;
  font-weight: 500;
  color: rgba(255,255,255,0.6);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-top: 2px;
}

/* ============================================
   STAT GEMS - Bottom Corners
   ============================================ */
.nw-card-stats-container {
  position: absolute;
  bottom: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  z-index: 10;
}

.nw-card-stat {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: 'Orbitron', system-ui, sans-serif;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.nw-card-stat-value {
  font-size: 14px;
  line-height: 1;
  color: #fff;
}

.nw-card-stat-label {
  font-size: 7px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.9;
  color: rgba(255,255,255,0.9);
}

/* ATK Gem - Red */
.nw-card-stat.atk {
  background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
  border: 2px solid #f87171;
}

/* DEF Gem - Blue */
.nw-card-stat.def {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  border: 2px solid #60a5fa;
}

/* Cost Gem - Top Right */
.nw-card-cost {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
  border: 2px solid #a78bfa;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Orbitron', system-ui, sans-serif;
  font-size: 16px;
  font-weight: 800;
  color: white;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  z-index: 10;
}

/* ============================================
   RARITY BADGE - Bottom Center
   ============================================ */
.nw-card-rarity {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 14px;
  font-family: 'Orbitron', system-ui, sans-serif;
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  border-radius: 10px;
  z-index: 15;
  white-space: nowrap;
}

/* ============================================
   CORNER ORNAMENTS - SVG Based (Hidden by default)
   ============================================ */
.nw-card-corner {
  display: none; /* We use CSS borders instead */
}

/* ============================================
   ABILITY TAG
   ============================================ */
.nw-card-ability {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 10px;
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  font-family: system-ui, sans-serif;
  font-size: 9px;
  font-weight: 600;
  color: #e5e5e5;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  z-index: 10;
}

/* ============================================
   CROWN / DIVINE SYMBOLS - Elegant CSS
   ============================================ */
.nw-card-crown,
.nw-card-divine {
  display: none; /* Remove cheap emoji icons */
}

/* ============================================
   COMMON FRAME - Clean Steel
   ============================================ */
.nw-card[data-rarity="common"]::before {
  background: linear-gradient(180deg, 
    #52525b 0%, #3f3f46 30%, #27272a 70%, #3f3f46 100%);
}

.nw-card[data-rarity="common"]:hover {
  box-shadow: 0 15px 40px rgba(0,0,0,0.4), 
              0 0 20px var(--common-glow);
}

.nw-card[data-rarity="common"] .nw-card-banner {
  border-color: rgba(113, 113, 122, 0.3);
}

.nw-card[data-rarity="common"] .nw-card-rarity {
  background: linear-gradient(180deg, #52525b, #3f3f46);
  color: #d4d4d8;
  border: 1px solid #71717a;
}

/* ============================================
   UNCOMMON FRAME - Forest Emerald
   ============================================ */
.nw-card[data-rarity="uncommon"]::before {
  background: linear-gradient(180deg,
    #059669 0%, #047857 30%, #065f46 70%, #047857 100%);
}

.nw-card[data-rarity="uncommon"]:hover {
  box-shadow: 0 15px 40px rgba(0,0,0,0.4), 
              0 0 30px var(--uncommon-glow);
}

.nw-card[data-rarity="uncommon"] .nw-card-banner {
  border-color: rgba(34, 197, 94, 0.4);
}

.nw-card[data-rarity="uncommon"] .nw-card-name {
  color: #a7f3d0;
}

.nw-card[data-rarity="uncommon"] .nw-card-rarity {
  background: linear-gradient(180deg, #22c55e, #059669);
  color: #fff;
  border: 1px solid #4ade80;
}

/* ============================================
   RARE FRAME - Crystal Sapphire
   ============================================ */
.nw-card[data-rarity="rare"]::before {
  background: linear-gradient(180deg,
    #2563eb 0%, #1d4ed8 30%, #1e40af 70%, #1d4ed8 100%);
  box-shadow: inset 0 0 20px rgba(96, 165, 250, 0.3);
}

.nw-card[data-rarity="rare"]:hover {
  box-shadow: 0 15px 50px rgba(0,0,0,0.4), 
              0 0 40px var(--rare-glow);
}

.nw-card[data-rarity="rare"] .nw-card-banner {
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.2);
}

.nw-card[data-rarity="rare"] .nw-card-name {
  color: #bfdbfe;
}

.nw-card[data-rarity="rare"] .nw-card-rarity {
  background: linear-gradient(180deg, #3b82f6, #2563eb);
  color: #fff;
  border: 1px solid #60a5fa;
  box-shadow: 0 0 8px var(--rare-glow);
}

/* Subtle shimmer animation */
.nw-card[data-rarity="rare"]::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, 
    transparent 40%, 
    rgba(147, 197, 253, 0.15) 50%, 
    transparent 60%);
  background-size: 200% 200%;
  animation: rare-shimmer 4s ease-in-out infinite;
  pointer-events: none;
  z-index: 1;
  border-radius: var(--card-radius);
}

@keyframes rare-shimmer {
  0%, 100% { background-position: 200% 200%; }
  50% { background-position: 0% 0%; }
}

/* ============================================
   EPIC FRAME - Arcane Violet
   ============================================ */
.nw-card[data-rarity="epic"]::before {
  background: linear-gradient(180deg,
    #8b5cf6 0%, #7c3aed 30%, #6d28d9 70%, #7c3aed 100%);
  box-shadow: inset 0 0 25px rgba(139, 92, 246, 0.4);
}

.nw-card[data-rarity="epic"]:hover {
  box-shadow: 0 15px 50px rgba(0,0,0,0.4), 
              0 0 50px var(--epic-glow),
              0 0 80px rgba(139, 92, 246, 0.3);
}

.nw-card[data-rarity="epic"] .nw-card-banner {
  border-color: rgba(168, 85, 247, 0.5);
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.3);
}

.nw-card[data-rarity="epic"] .nw-card-name {
  color: #e9d5ff;
}

.nw-card[data-rarity="epic"] .nw-card-rarity {
  background: linear-gradient(180deg, #a855f7, #7c3aed);
  color: #fff;
  border: 1px solid #c084fc;
  box-shadow: 0 0 10px var(--epic-glow);
}

/* Pulsing glow - contained within card bounds */
.nw-card[data-rarity="epic"]::after {
  content: '';
  position: absolute;
  inset: 0;
  background: transparent;
  border: 2px solid rgba(168, 85, 247, 0.6);
  border-radius: var(--card-radius);
  animation: epic-pulse 2s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

@keyframes epic-pulse {
  0%, 100% { 
    opacity: 0.5;
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.3);
  }
  50% { 
    opacity: 1;
    box-shadow: 0 0 25px rgba(168, 85, 247, 0.6);
  }
}

/* ============================================
   LEGENDARY FRAME - Royal Gold
   ============================================ */
.nw-card[data-rarity="legendary"]::before {
  background: linear-gradient(180deg,
    #fbbf24 0%, #d97706 20%, #b45309 50%, #d97706 80%, #fbbf24 100%);
  box-shadow: inset 0 0 30px rgba(251, 191, 36, 0.4);
}

.nw-card[data-rarity="legendary"]:hover {
  box-shadow: 0 20px 60px rgba(0,0,0,0.4), 
              0 0 60px var(--legendary-glow),
              0 0 100px rgba(251, 191, 36, 0.4);
}

.nw-card[data-rarity="legendary"] .nw-card-banner {
  border-color: rgba(251, 191, 36, 0.5);
  box-shadow: 0 0 15px rgba(251, 191, 36, 0.3);
  background: rgba(0, 0, 0, 0.9);
}

.nw-card[data-rarity="legendary"] .nw-card-name {
  background: linear-gradient(90deg, #fef3c7, #fde68a, #fef3c7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nw-card[data-rarity="legendary"] .nw-card-rarity {
  background: linear-gradient(180deg, #fbbf24, #d97706);
  color: #1c1917;
  font-weight: 800;
  border: 1px solid #fde68a;
  box-shadow: 0 0 15px var(--legendary-glow);
}

/* Gold shimmer animation - contained within card bounds */
.nw-card[data-rarity="legendary"]::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, 
    transparent 30%,
    rgba(253, 224, 71, 0.5) 45%,
    rgba(251, 191, 36, 0.7) 50%,
    rgba(253, 224, 71, 0.5) 55%,
    transparent 70%);
  background-size: 300% 300%;
  animation: legendary-shine 3s linear infinite;
  pointer-events: none;
  z-index: 0;
  border-radius: var(--card-radius);
}

@keyframes legendary-shine {
  0% { background-position: 200% 200%; }
  100% { background-position: -100% -100%; }
}

/* ============================================
   MYTHIC FRAME - Divine Flames
   ============================================ */
.nw-card[data-rarity="mythic"] {
  --frame-thickness: 10px;
}

.nw-card[data-rarity="mythic"]::before {
  background: linear-gradient(180deg,
    #ff6b00 0%, #dc2626 20%, #b91c1c 40%,
    #991b1b 60%, #dc2626 80%, #ff6b00 100%);
  box-shadow: inset 0 0 40px rgba(255, 107, 0, 0.5);
}

.nw-card[data-rarity="mythic"]:hover {
  box-shadow: 0 25px 80px rgba(0,0,0,0.4), 
              0 0 80px var(--mythic-glow),
              0 0 120px rgba(255, 107, 0, 0.5),
              0 0 160px rgba(220, 38, 38, 0.3);
  transform: translateY(-12px) scale(1.04);
}

.nw-card[data-rarity="mythic"] .nw-card-banner {
  border: 2px solid rgba(251, 191, 36, 0.6);
  box-shadow: 0 0 20px rgba(255, 107, 0, 0.4);
  background: rgba(0, 0, 0, 0.9);
}

.nw-card[data-rarity="mythic"] .nw-card-name {
  background: linear-gradient(90deg, 
    #fbbf24, #ff6b00, #fbbf24, #fff, #fbbf24);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: mythic-text 3s linear infinite;
}

@keyframes mythic-text {
  0% { background-position: 0% center; }
  100% { background-position: 200% center; }
}

.nw-card[data-rarity="mythic"] .nw-card-rarity {
  background: linear-gradient(180deg, #ff6b00, #dc2626);
  color: #fff;
  font-weight: 800;
  border: 2px solid #fbbf24;
  box-shadow: 0 0 20px var(--mythic-glow);
  animation: mythic-badge 2s ease-in-out infinite;
}

@keyframes mythic-badge {
  0%, 100% { box-shadow: 0 0 15px var(--mythic-glow); }
  50% { box-shadow: 0 0 30px var(--mythic-glow), 0 0 50px rgba(255, 107, 0, 0.4); }
}

/* Rotating gradient border - contained within card bounds */
.nw-card[data-rarity="mythic"]::after {
  content: '';
  position: absolute;
  inset: 0;
  background: conic-gradient(
    from var(--mythic-angle, 0deg),
    #ff6b00, #fbbf24, #ff6b00, #dc2626, #ff6b00, #fbbf24, #ff6b00
  );
  border-radius: var(--card-radius);
  z-index: -1;
  animation: mythic-rotate 4s linear infinite;
  filter: blur(3px);
  opacity: 0.7;
}

@property --mythic-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

@keyframes mythic-rotate {
  to { --mythic-angle: 360deg; }
}

/* Fallback for browsers without @property */
@supports not (background: conic-gradient(from var(--a, 0deg), red, blue)) {
  .nw-card[data-rarity="mythic"]::after {
    background: linear-gradient(135deg, #ff6b00, #fbbf24, #dc2626, #ff6b00);
    background-size: 400% 400%;
    animation: mythic-gradient 4s ease infinite;
  }
  
  @keyframes mythic-gradient {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
  }
}

/* ============================================
   CARD SIZE VARIANTS
   ============================================ */
   
/* Small */
.nw-card.nw-card-sm {
  --card-width: 180px;
  --card-height: 260px;
  --card-radius: 12px;
  --frame-thickness: 6px;
  --inner-radius: 8px;
}

.nw-card.nw-card-sm .nw-card-name { font-size: 10px; letter-spacing: 0.5px; }
.nw-card.nw-card-sm .nw-card-banner { bottom: 42px; padding: 6px 8px; }
.nw-card.nw-card-sm .nw-card-stat { width: 34px; height: 34px; }
.nw-card.nw-card-sm .nw-card-stat-value { font-size: 11px; }
.nw-card.nw-card-sm .nw-card-stat-label { font-size: 6px; }
.nw-card.nw-card-sm .nw-card-rarity { font-size: 7px; padding: 2px 10px; }
.nw-card.nw-card-sm .nw-card-cost { width: 30px; height: 30px; font-size: 13px; top: 8px; right: 8px; }
.nw-card.nw-card-sm .nw-card-stats-container { bottom: 8px; left: 8px; right: 8px; }

/* Large */
.nw-card.nw-card-lg {
  --card-width: 340px;
  --card-height: 500px;
  --card-radius: 20px;
  --frame-thickness: 12px;
  --inner-radius: 14px;
}

.nw-card.nw-card-lg .nw-card-name { font-size: 17px; letter-spacing: 2px; }
.nw-card.nw-card-lg .nw-card-banner { bottom: 75px; padding: 12px 16px; }
.nw-card.nw-card-lg .nw-card-stat { width: 56px; height: 56px; }
.nw-card.nw-card-lg .nw-card-stat-value { font-size: 18px; }
.nw-card.nw-card-lg .nw-card-stat-label { font-size: 8px; }
.nw-card.nw-card-lg .nw-card-rarity { font-size: 10px; padding: 4px 18px; }
.nw-card.nw-card-lg .nw-card-cost { width: 48px; height: 48px; font-size: 20px; top: 16px; right: 16px; }
.nw-card.nw-card-lg .nw-card-stats-container { bottom: 16px; left: 16px; right: 16px; }

/* ============================================
   LOADING STATE
   ============================================ */
.nw-card-art[src=""],
.nw-card-art:not([src]) {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.nw-card-art.loading {
  animation: card-loading 1.5s ease-in-out infinite;
}

@keyframes card-loading {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  .nw-card,
  .nw-card::before,
  .nw-card::after,
  .nw-card * {
    animation: none !important;
    transition: none !important;
  }
}

/* ============================================
   HOVER EFFECTS - Card Tilt (Optional)
   ============================================ */
.nw-card.nw-card-tilt {
  transform-style: preserve-3d;
  perspective: 1000px;
}

.nw-card.nw-card-tilt:hover {
  transform: rotateY(5deg) rotateX(-5deg) translateY(-10px) scale(1.02);
}
