@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
  :root {
    --color-indigo-700: #4B5EAA;
    --color-purple-700: #8A4AF3;
    --color-wood: #D4A373;
    --color-dark-bg: #1F2937;
    --color-light-text: #F9FAFB;
    --color-dark-text: #111827;
  }

  [data-theme="dark"] {
    --color-wood: #4A4035;
    --color-dark-bg: #111827;
    --color-light-text: #D1D5DB;
    --color-dark-text: #F9FAFB;
  }
}

/* Custom Font Classes */
.font-elite {
  font-family: 'Special Elite', cursive;
}

.font-architects {
  font-family: 'Architects Daughter', cursive;
}

/* Enhanced Character Card Styles - 3:4 Aspect Ratio (1080x1440) */
.character-card {
  @apply relative bg-gradient-to-b from-slate-800 to-slate-900 border-2 border-slate-700 rounded-2xl shadow-2xl hover:shadow-3xl transition-all duration-300 hover:scale-105 hover:-translate-y-2 cursor-pointer;
  width: 100%;
  max-width: 320px;
  aspect-ratio: 3/4;
  background: linear-gradient(135deg, #1e293b 0%, #334155 30%, #1e293b 100%);
  border: 2px solid #475569;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);
  position: relative;
  overflow: hidden;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.character-card:hover {
  @apply border-purple-400;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(147, 51, 234, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);
  transform: translateY(-12px) scale(1.08);
}

.character-card-image-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #334155 0%, #1e293b 100%);
  overflow: hidden;
}

.character-card-image {
  @apply transition-all duration-300;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
  transform: scale(1.02);
}

.character-card-image.loaded {
  opacity: 1;
  transform: scale(1);
}

/* Remove loading spinner - keep smooth image transitions */

.character-card:hover .character-card-image {
  @apply scale-105;
}

.character-card-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 140px;
  padding: 16px;
  text-align: center;
  background: linear-gradient(180deg, rgba(0,0,0,0.6) 0%, rgba(0,0,0,0.9) 100%);
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

.character-card-name {
  color: white !important;
  font-family: 'Special Elite', cursive;
  font-size: 20px;
  line-height: 1.2;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.character-card-tag {
  display: inline-block;
  color: white !important;
  background: rgba(255, 255, 255, 0.2);
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: bold;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.3);
  margin-bottom: 0.5rem;
  font-size: 14px;
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.character-card-description {
  color: rgba(255, 255, 255, 0.9) !important;
  font-size: 15px;
  line-height: 1.4;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  margin-bottom: 0.5rem;
  max-height: 3.2em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.character-card-stats {
  color: rgba(255, 255, 255, 0.7) !important;
  font-size: 13px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* Rarity-specific card borders and effects */
.character-card.common {
  border-color: #9ca3af;
  box-shadow: 0 10px 25px rgba(156, 163, 175, 0.2);
}

.character-card.uncommon {
  border-color: #10b981;
  box-shadow: 0 10px 25px rgba(16, 185, 129, 0.2);
}

.character-card.rare {
  border-color: #3b82f6;
  box-shadow: 0 10px 25px rgba(59, 130, 246, 0.2);
}

.character-card.epic {
  border-color: #8b5cf6;
  box-shadow: 0 10px 25px rgba(139, 92, 246, 0.2);
}

.character-card.legendary {
  border-color: #f59e0b;
  box-shadow: 0 10px 25px rgba(245, 158, 11, 0.2);
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 30%, #0f3460 70%, #1a1a2e 100%);
}

.character-card.legendary::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(45deg, #f59e0b, #fbbf24, #f59e0b, #fbbf24);
  border-radius: 8px;
  z-index: -1;
  animation: legendary-glow 2s ease-in-out infinite alternate;
}

@keyframes legendary-glow {
  from { opacity: 0.5; }
  to { opacity: 0.8; }
}

/* Coming Soon Overlay for Character Cards */
.coming-soon-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.95));
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  z-index: 15;
}

/* Coming Soon Overlay for Modal/List View - preserves original behavior */
.coming-soon-overlay-modal {
  @apply absolute inset-0 flex items-center justify-center;
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.95));
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  z-index: 10;
}

.coming-soon-text {
  @apply text-white font-bold text-center;
  font-size: 24px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
  letter-spacing: 1px;
  color: #fbbf24;
}


/* Legacy coming soon badge for list view */
.coming-soon-badge {
  @apply bg-yellow-500 text-black text-xs px-2 py-1 rounded-full font-bold;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  z-index: 10;
}

/* Placeholder for characters without images */
.character-placeholder {
  @apply w-full h-full;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 100%;
}

.coming-soon-content {
  @apply flex flex-col items-center justify-center text-center;
  gap: 0.5rem;
  height: 100%;
  width: 100%;
}

.character-placeholder-emoji {
  @apply text-white;
  font-size: 5rem;
  line-height: 1;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.7));
}

.character-placeholder-text {
  @apply text-white/80 text-sm font-medium;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  z-index: 1;
}

/* Grid Layouts */
.grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  justify-items: center;
  padding: 20px;
}

@media (max-width: 640px) {
  .grid-view {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 16px;
  }
}

@media (min-width: 641px) and (max-width: 1024px) {
  .grid-view {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    max-width: 1200px;
    margin: 0 auto;
  }
}

@media (min-width: 1025px) {
  .grid-view {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    max-width: 1400px;
    margin: 0 auto;
  }
}

.list-view {
  @apply flex flex-col space-y-4;
}

.list-view .character-card {
  @apply flex flex-row items-center p-4 hover:scale-100 hover:translate-y-0;
}

.list-view .character-card-image {
  @apply w-24 h-24 rounded-lg mr-4 flex-shrink-0;
}

.list-view .character-card-content {
  @apply text-left p-0 flex-1;
}

.list-view .character-card-name {
  @apply text-xl mb-1;
}

/* Search and Filter Styles */
.search-input {
  @apply w-full pl-10 pr-4 py-3 bg-white/10 border border-white/20 rounded-lg text-white placeholder-white/60 focus:outline-none focus:ring-2 focus:ring-purple-500 focus:border-transparent transition-all duration-200;
}

.filter-select {
  @apply px-4 py-3 bg-white/10 border border-white/20 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-purple-500 transition-all duration-200;
}

.view-toggle {
  @apply flex bg-white/10 rounded-lg p-1;
}

.view-toggle button {
  @apply p-2 text-white/50 hover:bg-white/20 rounded transition-colors duration-200;
}

.view-toggle button.active {
  @apply text-white bg-white/20;
}

/* Modal Styles */
.modal-overlay {
  @apply fixed inset-0 bg-black bg-opacity-75 flex items-center justify-center z-50 backdrop-blur-sm;
}

.modal-content {
  @apply bg-gradient-to-b from-gray-800 to-gray-900 rounded-2xl max-w-2xl w-full mx-4 relative transform scale-0 opacity-0 transition-all duration-500 shadow-2xl;
  border: 3px solid #4a5568;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.modal-content.show {
  @apply scale-100 opacity-100;
}

/* Optimized modal image styles */
#modalImage {
  transition: opacity 0.3s ease;
}

#modalImage:not([src]), #modalImage[src=""] {
  display: none !important;
}

/* Modal text styling improvements */
#modalName {
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

#modalDescription {
  line-height: 1.5;
}

/* Responsive modal improvements */
@media (max-width: 768px) {
  #modalContent {
    margin: 8px;
    border-radius: 16px;
    max-width: calc(100vw - 16px);
  }
  
  /* Stack vertically on mobile */
  #modalContent .flex {
    flex-direction: column !important;
  }
  
  #modalImage {
    border-radius: 0;
  }
}

/* Modal animation improvements */
#modal:not(.hidden) #modalContent {
  animation: modalSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes modalSlideIn {
  from {
    transform: scale(0.8) translateY(20px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

/* Loading and Empty States */
.loading-spinner {
  @apply inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-purple-500;
}

.empty-state {
  @apply text-center py-12;
}

.empty-state-icon {
  @apply text-6xl mb-4;
}

.empty-state-title {
  @apply text-xl font-semibold text-white mb-2;
}

.empty-state-description {
  @apply text-white/70;
}

/* Hero Background */
.hero-background {
  background-image: url('../images/backgrounds/wild-reactions-hero-bg.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

/* Fallback for when image is loading or unavailable */
.hero-background::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 30%, #ec4899 100%);
  z-index: -1;
}

/* Animation Utilities */
.animation-delay-1 {
  animation-delay: 1s;
}

/* Animations */
@keyframes floatUp {
  from {
    transform: translateY(100%) scale(0);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Card Hover Effects */
.character-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transform: translateX(-100%);
  transition: transform 0.6s;
}

.character-card:hover::before {
  transform: translateX(100%);
}

/* Responsive Design */
@media (max-width: 640px) {
  .character-card {
    @apply hover:scale-100 hover:-translate-y-0;
    max-width: 280px;
    height: 373px; /* 280 * 4/3 = 373.33 for 3:4 aspect ratio */
  }
  
  .list-view .character-card {
    @apply flex-col text-center;
  }
  
  .list-view .character-card-image {
    @apply w-full h-48 mr-0 mb-4;
  }
  
  /* Larger touch targets for mobile */
  button {
    @apply min-h-12;
  }
  
  input, select {
    @apply min-h-12 text-base;
  }
}

@media (max-width: 768px) {
  /* Improved modal sizing on mobile */
  #modalContent {
    max-height: 95vh;
    max-width: calc(100vw - 16px);
  }
  
  /* Better navigation spacing */
  .nav-brand {
    @apply text-lg;
  }
  
  /* Disable fixed attachment on mobile for better performance */
  .hero-background {
    background-attachment: scroll;
  }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

/* Focus States for Accessibility */
.character-card:focus {
  @apply outline-none ring-2 ring-purple-500 ring-offset-2 ring-offset-transparent;
}

button:focus {
  @apply outline-none ring-2 ring-purple-500 ring-offset-2 ring-offset-transparent;
}

input:focus {
  @apply outline-none ring-2 ring-purple-500 ring-offset-2 ring-offset-transparent;
}

select:focus {
  @apply outline-none ring-2 ring-purple-500 ring-offset-2 ring-offset-transparent;
}