/* ==========================================================================
   Modex Game Discovery & Preference System
   Whop-style Game Switcher & Onboarding Selection Board
   ========================================================================== */

/* --- Game Filter Shelf (Homepage Feed Bar) --- */
.game-filter-shelf {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 36px 0 24px 0;
  padding: 18px 22px;
  background: rgba(20, 24, 33, 0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(167, 139, 250, 0.16);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.36);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.game-filter-shelf:hover {
  border-color: rgba(167, 139, 250, 0.28);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.44), 0 0 24px rgba(139, 92, 246, 0.1);
}

.game-filter-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.game-filter-indicator {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: #c4b5fd;
  font-family: var(--whop-font-sans, 'Inter', sans-serif);
}

.game-filter-indicator .active-pulse {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #a78bfa;
  box-shadow: 0 0 12px #8b5cf6, 0 0 4px #a78bfa;
  animation: pulseGlow 2.2s infinite ease-in-out;
  flex-shrink: 0;
}

@keyframes pulseGlow {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.35); opacity: 0.5; box-shadow: 0 0 18px #8b5cf6, 0 0 8px #a78bfa; }
}

.game-filter-indicator .filter-prompt {
  color: #94a3b8;
  font-weight: 500;
}

.game-filter-indicator strong {
  color: #ffffff;
  font-weight: 700;
  font-family: var(--whop-font-display, 'Acid Grotesk', sans-serif);
  font-size: 15px;
  letter-spacing: -0.01em;
}

.game-change-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(167, 139, 250, 0.25);
  border-radius: 20px;
  color: #e5d8f9;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--whop-font-sans, 'Inter', sans-serif);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.game-change-button:hover {
  background: rgba(139, 92, 246, 0.22);
  border-color: #a78bfa;
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.25);
}

.game-change-button svg {
  color: #a78bfa;
  transition: transform 0.3s ease;
}

.game-change-button:hover svg {
  transform: rotate(45deg);
}

/* --- Filter Pills --- */
.game-filter-pills {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.game-filter-pills::-webkit-scrollbar {
  display: none;
}

.game-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: rgba(15, 18, 25, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  color: #94a3b8;
  font-size: 13.5px;
  font-weight: 600;
  font-family: var(--whop-font-sans, 'Inter', sans-serif);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.game-pill:hover {
  color: #ffffff;
  background: rgba(30, 36, 49, 0.95);
  border-color: rgba(167, 139, 250, 0.35);
  transform: translateY(-2px);
}

.game-pill.active {
  color: #ffffff !important;
  background: #8b5cf6 !important;
  border-color: #a78bfa !important;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.45), 0 0 10px rgba(167, 139, 250, 0.3);
  transform: translateY(-2px);
}

.game-pill.active .pill-badge {
  background: rgba(0, 0, 0, 0.25);
  color: #ffffff;
}

.game-pill .pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #64748b;
  flex-shrink: 0;
  transition: background 0.2s ease;
}

.game-pill .pill-dot.fivem { background: #10b981; }
.game-pill .pill-dot.mta { background: #3b82f6; }
.game-pill .pill-dot.samp { background: #f59e0b; }
.game-pill .pill-dot.minecraft { background: #22c55e; }
.game-pill .pill-dot.roblox { background: #ec4899; }

.game-pill.active .pill-dot {
  background: #ffffff;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.8);
}

.game-pill .pill-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  transition: all 0.2s ease;
}

/* --- Animated Transition for Resource Grids --- */
.resource-grid.switching {
  opacity: 0;
  transform: translateY(12px) scale(0.99);
  transition: opacity 0.16s ease, transform 0.16s ease;
  pointer-events: none;
}

.resource-grid.switched {
  opacity: 1;
  transform: translateY(0) scale(1);
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- Game Selection Modal (Onboarding Board) --- */
.game-welcome-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(5, 7, 12, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.game-welcome-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.game-welcome-modal {
  position: relative;
  width: 100%;
  max-width: 760px;
  max-height: 90vh;
  overflow-y: auto;
  background: #12151e;
  background: linear-gradient(180deg, #181c28 0%, #11141c 100%);
  border: 1px solid rgba(167, 139, 250, 0.24);
  border-radius: 24px;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.85), 0 0 50px rgba(139, 92, 246, 0.18);
  padding: 36px 32px 32px 32px;
  transform: scale(0.94) translateY(18px);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.game-welcome-backdrop.is-open .game-welcome-modal {
  transform: scale(1) translateY(0);
}

.modal-close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  transform: rotate(90deg);
}

.modal-header {
  text-align: center;
  margin-bottom: 28px;
}

.modal-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 13px;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(167, 139, 250, 0.3);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #c4b5fd;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.modal-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #a78bfa;
  box-shadow: 0 0 8px #a78bfa;
}

.modal-header h2 {
  font-family: var(--whop-font-display, 'Acid Grotesk', sans-serif);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: #ffffff;
  margin: 0 0 8px 0;
  line-height: 1.25;
}

.modal-header p {
  font-family: var(--whop-font-sans, 'Inter', sans-serif);
  font-size: 14px;
  color: #94a3b8;
  margin: 0;
  line-height: 1.5;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}

/* --- Modal Game Grid --- */
.modal-game-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.modal-game-card {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 16px;
  overflow: hidden;
  border: 1.5px solid rgba(255, 255, 255, 0.08);
  background: #0f121a;
  cursor: pointer;
  text-align: left;
  padding: 0;
  transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-game-card:nth-child(4),
.modal-game-card:nth-child(5) {
  grid-column: span 1;
}

.modal-game-card .card-bg {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.modal-game-card .card-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), filter 0.4s ease;
  filter: brightness(0.72) saturate(1.1);
}

.modal-game-card .card-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(11, 13, 18, 0.15) 0%, rgba(11, 13, 18, 0.88) 85%);
  transition: opacity 0.3s ease;
}

.modal-game-card .card-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
  padding: 16px;
}

.modal-game-card .card-tag {
  font-family: var(--whop-font-sans, 'Inter', sans-serif);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #a78bfa;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.modal-game-card h3 {
  font-family: var(--whop-font-display, 'Acid Grotesk', sans-serif);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: #ffffff;
  margin: 0 0 6px 0;
  line-height: 1.2;
}

.modal-game-card .card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-game-card .card-count {
  font-family: var(--whop-font-sans, 'Inter', sans-serif);
  font-size: 12px;
  font-weight: 600;
  color: #cbd5e1;
}

.modal-game-card .card-select-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  opacity: 0.8;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-game-card:hover {
  border-color: #a78bfa;
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.6), 0 0 30px rgba(139, 92, 246, 0.35);
}

.modal-game-card:hover .card-bg img {
  transform: scale(1.08);
  filter: brightness(0.85) saturate(1.2);
}

.modal-game-card:hover .card-select-icon {
  background: #8b5cf6;
  opacity: 1;
  transform: scale(1.1);
  box-shadow: 0 0 14px rgba(139, 92, 246, 0.7);
}

/* Selected state animation */
.modal-game-card.is-selected {
  border-color: #8b5cf6 !important;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.5), 0 0 30px rgba(139, 92, 246, 0.4);
}

.modal-game-card.is-selected .card-select-icon {
  background: #8b5cf6;
  opacity: 1;
  transform: scale(1.15);
}

/* --- Modal Footer --- */
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.modal-all-games-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  color: #94a3b8;
  font-size: 13.5px;
  font-weight: 600;
  font-family: var(--whop-font-sans, 'Inter', sans-serif);
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-all-games-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.25);
  color: #ffffff;
  transform: translateY(-1px);
}

/* --- RTL Support (Arabic) --- */
html[dir="rtl"] .modal-game-card {
  text-align: right;
}

html[dir="rtl"] .modal-close-btn {
  right: auto;
  left: 20px;
}

html[dir="rtl"] .modal-all-games-btn svg {
  transform: scaleX(-1);
}

/* --- Responsive Adjustments --- */
@media (max-width: 768px) {
  .game-filter-shelf {
    margin: 24px 0 16px 0;
    padding: 14px 16px;
  }
  .modal-game-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .modal-game-card:nth-child(5) {
    grid-column: span 2;
    aspect-ratio: 28 / 10;
  }
  .game-welcome-modal {
    padding: 24px 18px 20px 18px;
    border-radius: 20px;
  }
  .modal-header h2 {
    font-size: 22px;
  }
}

@media (max-width: 480px) {
  .modal-game-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .modal-game-card:nth-child(5) {
    grid-column: span 1;
    aspect-ratio: 16 / 10;
  }
}
