/* --- CARDS BRAINROTS CATALOGUE (RECTANGLE VERTICAL) --- */
#items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 25px;
  padding: 20px;
}

/* Card principale - Rectangle vertical fixe */
.brainrot-card {
  display: flex;
  flex-direction: column;
  height: 380px; /* Hauteur fixe pour uniformité */
  border: 3px solid #ff0000;
  background: linear-gradient(180deg, #1a1a1a 0%, #0d0d0d 100%);
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.3s, box-shadow 0.3s;
  box-shadow: 0 5px 20px rgba(255, 0, 0, 0.3);
  overflow: hidden;
  position: relative;
}

.brainrot-card:hover {
  transform: translateY(-10px) scale(1.02);
  box-shadow: 0 15px 50px rgba(255, 0, 0, 0.7);
}

/* Image en haut de la carte - Optimisée */
.brainrot-image {
  width: 100%;
  height: 280px; /* Hauteur fixe */
  object-fit: cover;
  object-position: center;
  border-bottom: 3px solid #ff0000;
  flex-shrink: 0;
  /* Optimisation du rendu */
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

/* Effet de chargement progressif */
.brainrot-image[loading="lazy"] {
  background: linear-gradient(90deg, #1a1a1a 0%, #2a2a2a 50%, #1a1a1a 100%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Contenu en bas - Hauteur fixe */
.brainrot-content {
  padding: 15px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100px; /* Hauteur fixe */
  flex-shrink: 0;
}

/* Nom du brainrot */
.brainrot-title {
  padding: 10px 15px;
  font-weight: bold;
  font-size: 16px;
  color: #ffffff;
  background: #600000;
  border: 2px solid #ff0000;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1.3;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2; /* Limite à 2 lignes */
  -webkit-box-orient: vertical;
  line-clamp: 2; /* Standard property for compatibility */
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

/* Badge "Nouveau" optionnel */
.brainrot-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #ff0000;
  color: white;
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: bold;
  z-index: 1;
  box-shadow: 0 2px 10px rgba(255, 0, 0, 0.5);
}

/* Responsive pour tablettes */
@media (max-width: 1024px) {
  #items {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
  }
  
  .brainrot-card {
    height: 340px;
  }
  
  .brainrot-image {
    height: 240px;
  }
  
  .brainrot-title {
    font-size: 14px;
    padding: 8px 12px;
  }
}

/* Responsive pour mobiles */
@media (max-width: 768px) {
  #items {
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    padding: 15px;
  }
  
  .brainrot-card {
    height: 300px;
  }
  
  .brainrot-image {
    height: 210px;
  }
  
  .brainrot-content {
    height: 90px;
    padding: 10px;
  }
  
  .brainrot-title {
    font-size: 13px;
    padding: 8px 10px;
  }
}

/* Responsive pour petits mobiles */
@media (max-width: 480px) {
  #items {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 10px;
  }
  
  .brainrot-card {
    height: 260px;
  }
  
  .brainrot-image {
    height: 180px;
  }
  
  .brainrot-content {
    height: 80px;
    padding: 8px;
  }
  
  .brainrot-title {
    font-size: 12px;
    padding: 6px 8px;
  }
}


/* --- POPUP VARIANTES --- */
.modal-content.big {
  width: 90%;
  max-width: 1200px;
  max-height: 85vh;
  overflow-y: auto;
  background: #0d0d0d;
  border: 4px solid #ff0000;
  border-radius: 15px;
  padding: 30px;
  box-shadow: 0 0 50px rgba(255, 0, 0, 0.8);
}

.modal-content.big h2 {
  text-align: center;
  margin-bottom: 30px;
  font-size: 32px;
  color: #ff0000;
  text-shadow: 0 0 20px #ff0000;
  text-transform: uppercase;
}

/* Liste des variantes */
#variantList {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

/* Card de variante */
.variant-card {
  display: flex;
  flex-direction: column;
  background: linear-gradient(135deg, #1a1a1a 0%, #2a0000 100%);
  border: 3px solid #ff0000;
  border-radius: 10px;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  height: 100%; /* Hauteur flexible pour s'adapter au contenu */
}

.variant-card:hover {
  transform: scale(1.03);
  box-shadow: 0 0 30px rgba(255, 0, 0, 0.7);
}

/* Image de la variante (cliquable et optimisée) */
.variant-image {
  width: 100%;
  height: 200px; /* Hauteur fixe */
  object-fit: cover;
  object-position: center;
  cursor: zoom-in;
  border-bottom: 2px solid #ff0000;
  transition: opacity 0.3s, transform 0.3s;
  flex-shrink: 0;
  /* Optimisation du rendu */
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  background: linear-gradient(90deg, #1a1a1a 0%, #2a2a2a 50%, #1a1a1a 100%);
  background-size: 200% 100%;
}

.variant-image[loading="lazy"] {
  animation: loading 1.5s infinite;
}

.variant-image:hover {
  opacity: 0.85;
  transform: scale(1.05);
}

/* Icône de zoom sur l'image */
.variant-image-wrapper {
  position: relative;
  overflow: hidden;
}

.variant-image-wrapper::after {
  content: "🔍";
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  width: 35px;
  height: 35px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.variant-card:hover .variant-image-wrapper::after {
  opacity: 1;
}

/* Contenu de la variante */
.variant-content {
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Section rareté et mutation */
.variant-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.variant-rarity {
  font-size: 16px;
  font-weight: bold;
  padding: 10px 15px;
  border: 3px solid;
  border-radius: 8px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  position: relative;
  overflow: hidden;
}

.variant-rarity::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transform: rotate(45deg);
  animation: shine 3s infinite;
}

@keyframes shine {
  0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
  100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

/* Couleurs selon la rareté - VERSION STYLISÉE */
.rarity-common { 
  background: linear-gradient(135deg, #4a4a4a 0%, #6b6b6b 50%, #4a4a4a 100%);
  color: #fff; 
  border-color: #8b8b8b;
  box-shadow: 0 0 15px rgba(107, 107, 107, 0.5), inset 0 0 10px rgba(255, 255, 255, 0.1);
}

.rarity-uncommon { 
  background: linear-gradient(135deg, #0d9500 0%, #1eff00 50%, #0d9500 100%);
  color: #000; 
  border-color: #3fff2f;
  box-shadow: 0 0 20px rgba(30, 255, 0, 0.7), inset 0 0 15px rgba(255, 255, 255, 0.2);
  animation: glowGreen 2s infinite alternate;
}

@keyframes glowGreen {
  0% { box-shadow: 0 0 20px rgba(30, 255, 0, 0.7), inset 0 0 15px rgba(255, 255, 255, 0.2); }
  100% { box-shadow: 0 0 30px rgba(30, 255, 0, 1), inset 0 0 20px rgba(255, 255, 255, 0.3); }
}

.rarity-rare { 
  background: linear-gradient(135deg, #0050aa 0%, #0070dd 50%, #0050aa 100%);
  color: #fff; 
  border-color: #00aaff;
  box-shadow: 0 0 20px rgba(0, 112, 221, 0.8), inset 0 0 15px rgba(255, 255, 255, 0.2);
  animation: glowBlue 2s infinite alternate;
}

@keyframes glowBlue {
  0% { box-shadow: 0 0 20px rgba(0, 112, 221, 0.8), inset 0 0 15px rgba(255, 255, 255, 0.2); }
  100% { box-shadow: 0 0 35px rgba(0, 170, 255, 1), inset 0 0 20px rgba(255, 255, 255, 0.3); }
}

.rarity-epic { 
  background: linear-gradient(135deg, #6b1a99 0%, #a335ee 50%, #6b1a99 100%);
  color: #fff; 
  border-color: #d896ff;
  box-shadow: 0 0 25px rgba(163, 53, 238, 0.9), inset 0 0 20px rgba(255, 255, 255, 0.2);
  animation: glowPurple 2s infinite alternate;
}

@keyframes glowPurple {
  0% { box-shadow: 0 0 25px rgba(163, 53, 238, 0.9), inset 0 0 20px rgba(255, 255, 255, 0.2); }
  100% { box-shadow: 0 0 40px rgba(216, 150, 255, 1), inset 0 0 25px rgba(255, 255, 255, 0.3); }
}

.rarity-legendary { 
  background: linear-gradient(135deg, #cc6600 0%, #ff8000 50%, #ffaa00 100%);
  color: #000; 
  border-color: #ffcc00;
  box-shadow: 0 0 30px rgba(255, 128, 0, 1), inset 0 0 20px rgba(255, 255, 255, 0.3);
  animation: glowOrange 1.5s infinite alternate;
  font-size: 18px;
}

@keyframes glowOrange {
  0% { 
    box-shadow: 0 0 30px rgba(255, 128, 0, 1), inset 0 0 20px rgba(255, 255, 255, 0.3);
    transform: scale(1);
  }
  100% { 
    box-shadow: 0 0 50px rgba(255, 204, 0, 1), inset 0 0 30px rgba(255, 255, 255, 0.4);
    transform: scale(1.05);
  }
}

.rarity-mythic { 
  background: linear-gradient(135deg, #b8860b 0%, #e6cc80 50%, #ffd700 100%);
  color: #000; 
  border-color: #fff;
  box-shadow: 0 0 40px rgba(255, 215, 0, 1), inset 0 0 25px rgba(255, 255, 255, 0.4);
  animation: glowGold 1s infinite alternate;
  font-size: 19px;
  font-weight: 900;
}

@keyframes glowGold {
  0% { 
    box-shadow: 0 0 40px rgba(255, 215, 0, 1), inset 0 0 25px rgba(255, 255, 255, 0.4);
    transform: scale(1) rotate(-1deg);
  }
  100% { 
    box-shadow: 0 0 60px rgba(255, 255, 0, 1), inset 0 0 35px rgba(255, 255, 255, 0.5);
    transform: scale(1.08) rotate(1deg);
  }
}

.variant-mutation {
  font-size: 15px;
  font-weight: bold;
  color: #ffcc00;
  font-style: normal;
  text-align: center;
  padding: 8px 12px;
  background: linear-gradient(135deg, rgba(255, 204, 0, 0.2) 0%, rgba(255, 153, 0, 0.3) 100%);
  border: 2px solid #ffcc00;
  border-radius: 8px;
  text-shadow: 0 0 10px rgba(255, 204, 0, 0.8), 0 2px 4px rgba(0, 0, 0, 0.5);
  box-shadow: 0 0 15px rgba(255, 204, 0, 0.5), inset 0 0 10px rgba(255, 204, 0, 0.2);
  animation: mutationGlow 2.5s infinite alternate;
  text-transform: uppercase;
  letter-spacing: 1px;
  position: relative;
  overflow: hidden;
}

.variant-mutation::before {
  content: '✨';
  position: absolute;
  left: 5px;
  font-size: 18px;
  animation: sparkle 1.5s infinite;
}

.variant-mutation::after {
  content: '✨';
  position: absolute;
  right: 5px;
  font-size: 18px;
  animation: sparkle 1.5s infinite 0.75s;
}

@keyframes mutationGlow {
  0% { 
    box-shadow: 0 0 15px rgba(255, 204, 0, 0.5), inset 0 0 10px rgba(255, 204, 0, 0.2);
    border-color: #ffcc00;
  }
  100% { 
    box-shadow: 0 0 30px rgba(255, 204, 0, 0.9), inset 0 0 20px rgba(255, 204, 0, 0.4);
    border-color: #ffff00;
  }
}

@keyframes sparkle {
  0%, 100% { 
    opacity: 0.5;
    transform: scale(1) rotate(0deg);
  }
  50% { 
    opacity: 1;
    transform: scale(1.3) rotate(180deg);
  }
}

/* Statistiques */
.variant-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.variant-stat-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(255, 0, 0, 0.1);
  border: 1px solid #ff0000;
  border-radius: 5px;
  color: #fff;
}

.variant-stat-label {
  font-weight: bold;
  color: #ff6666;
}

.variant-stat-value {
  color: #ffffff;
  font-weight: bold;
}

/* Prix et bouton */
.variant-purchase {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: auto;
}

.variant-price {
  font-size: 24px;
  font-weight: bold;
  color: #00ff00;
  text-align: center;
  text-shadow: 0 0 10px #00ff00;
}

.variant-stock {
  font-size: 14px;
  color: #ffcc00;
  text-align: center;
  padding: 5px 10px;
  border: 1px solid #ffcc00;
  border-radius: 5px;
}

.variant-stock.out-of-stock {
  color: #ff0000;
  border-color: #ff0000;
}

.add-to-cart-btn {
  padding: 12px 20px;
  background: #ff0000;
  border: 2px solid #ff0000;
  border-radius: 8px;
  color: #ffffff;
  font-weight: bold;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s;
  text-transform: uppercase;
}

.add-to-cart-btn:hover {
  background: #ffffff;
  color: #ff0000;
  box-shadow: 0 0 15px #ff0000;
}

.add-to-cart-btn:disabled {
  background: #333;
  border-color: #666;
  color: #999;
  cursor: not-allowed;
}

/* Bouton fermer */
#closeModal {
  width: 100%;
  padding: 15px;
  background: #600000;
  border: 2px solid #ff0000;
  color: #ffffff;
  font-size: 18px;
  font-weight: bold;
  border-radius: 8px;
  cursor: pointer;
  transition: 0.3s;
  margin-top: 10px;
}

#closeModal:hover {
  background: #ff0000;
  box-shadow: 0 0 20px #ff0000;
}

/* Message si aucune variante */
.no-variants {
  text-align: center;
  padding: 40px;
  color: #999;
  font-size: 18px;
  grid-column: 1 / -1;
}

/* --- MODAL ZOOM IMAGE --- */
.image-zoom-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  cursor: zoom-out;
  animation: fadeIn 0.2s ease-out;
  backdrop-filter: blur(5px);
}

.image-zoom-modal.hidden {
  display: none;
}

@keyframes fadeIn {
  from { 
    opacity: 0;
    backdrop-filter: blur(0px);
  }
  to { 
    opacity: 1;
    backdrop-filter: blur(5px);
  }
}

.image-zoom-modal img {
  max-width: 90vw;
  max-height: 90vh;
  width: auto;
  height: auto;
  border: 4px solid #ff0000;
  border-radius: 10px;
  box-shadow: 0 0 60px rgba(255, 0, 0, 0.8);
  animation: zoomIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  object-fit: contain;
  /* Optimisation pour grandes images */
  image-rendering: high-quality;
}

@keyframes zoomIn {
  from { 
    transform: scale(0.3);
    opacity: 0;
  }
  to { 
    transform: scale(1);
    opacity: 1;
  }
}

.image-zoom-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: #ff0000;
  color: white;
  border: none;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 0 20px rgba(255, 0, 0, 0.6);
  z-index: 2001;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.image-zoom-close:hover {
  background: #ffffff;
  color: #ff0000;
  transform: rotate(90deg) scale(1.1);
  box-shadow: 0 0 30px rgba(255, 0, 0, 0.9);
}

.image-zoom-close:active {
  transform: rotate(90deg) scale(0.95);
}

/* Info de l'image zoomée */
.image-zoom-info {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  border: 1px solid #ff0000;
  backdrop-filter: blur(10px);
}

/* Mobile responsive */
@media (max-width: 768px) {
  .image-zoom-modal img {
    max-width: 95vw;
    max-height: 85vh;
  }
  
  .image-zoom-close {
    width: 40px;
    height: 40px;
    font-size: 20px;
    top: 10px;
    right: 10px;
  }
}

/* Responsive */
@media (max-width: 768px) {
  #variantList {
    grid-template-columns: 1fr;
  }
  
  .modal-content.big {
    padding: 15px;
  }
  
  .modal-content.big h2 {
    font-size: 24px;
  }
}


/* --- STYLES GLOBAUX POUR RARETÉS ET MUTATIONS --- */

/* Animation de brillance commune */
@keyframes shine {
  0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
  100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

/* Animations de glow par rareté */
@keyframes glowGreen {
  0% { box-shadow: 0 0 20px rgba(30, 255, 0, 0.7), inset 0 0 15px rgba(255, 255, 255, 0.2); }
  100% { box-shadow: 0 0 30px rgba(30, 255, 0, 1), inset 0 0 20px rgba(255, 255, 255, 0.3); }
}

@keyframes glowBlue {
  0% { box-shadow: 0 0 20px rgba(0, 112, 221, 0.8), inset 0 0 15px rgba(255, 255, 255, 0.2); }
  100% { box-shadow: 0 0 35px rgba(0, 170, 255, 1), inset 0 0 20px rgba(255, 255, 255, 0.3); }
}

@keyframes glowPurple {
  0% { box-shadow: 0 0 25px rgba(163, 53, 238, 0.9), inset 0 0 20px rgba(255, 255, 255, 0.2); }
  100% { box-shadow: 0 0 40px rgba(216, 150, 255, 1), inset 0 0 25px rgba(255, 255, 255, 0.3); }
}

@keyframes glowOrange {
  0% { 
    box-shadow: 0 0 30px rgba(255, 128, 0, 1), inset 0 0 20px rgba(255, 255, 255, 0.3);
    transform: scale(1);
  }
  100% { 
    box-shadow: 0 0 50px rgba(255, 204, 0, 1), inset 0 0 30px rgba(255, 255, 255, 0.4);
    transform: scale(1.05);
  }
}

@keyframes glowGold {
  0% { 
    box-shadow: 0 0 40px rgba(255, 215, 0, 1), inset 0 0 25px rgba(255, 255, 255, 0.4);
    transform: scale(1) rotate(-1deg);
  }
  100% { 
    box-shadow: 0 0 60px rgba(255, 255, 0, 1), inset 0 0 35px rgba(255, 255, 255, 0.5);
    transform: scale(1.08) rotate(1deg);
  }
}

/* Animation pour mutations */
@keyframes mutationGlow {
  0% { 
    box-shadow: 0 0 15px rgba(255, 204, 0, 0.5), inset 0 0 10px rgba(255, 204, 0, 0.2);
    border-color: #ffcc00;
  }
  100% { 
    box-shadow: 0 0 30px rgba(255, 204, 0, 0.9), inset 0 0 20px rgba(255, 204, 0, 0.4);
    border-color: #ffff00;
  }
}

@keyframes sparkle {
  0%, 100% { 
    opacity: 0.5;
    transform: scale(1) rotate(0deg);
  }
  50% { 
    opacity: 1;
    transform: scale(1.3) rotate(180deg);
  }
}