/* ========== Base & Variables ========== */
:root {
  --bg-void: #0a0a0f;
  --bg-mist: #12121a;
  --bg-card: #1a1a24;
  --bg-card-hover: #222230;
  --text-primary: #e8e6e3;
  --text-secondary: #9a9a9a;
  --text-dim: #6a6a6a;
  --accent-gold: #c9a227;
  --accent-gold-dim: #8a7020;
  --accent-purple: #7b5ea7;
  --accent-blue: #4a7c9b;
  --multiplayer-color: #4ade80;
  --streaming-color: #f472b6;
  --ai-color: #a78bfa;
  --border-subtle: rgba(255, 255, 255, 0.06);
  --shadow-glow: 0 0 40px rgba(201, 162, 39, 0.1);
  --font-display: 'Cinzel', serif;
  --font-body: 'Crimson Text', Georgia, serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  background: var(--bg-void);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ========== Background Effects ========== */
.background-effects {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.fog {
  position: absolute;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at center, 
    rgba(123, 94, 167, 0.03) 0%, 
    transparent 50%);
  animation: drift 60s ease-in-out infinite;
}

.fog-1 {
  top: -50%;
  left: -50%;
  animation-delay: 0s;
}

.fog-2 {
  top: -30%;
  left: -30%;
  animation-delay: -30s;
  opacity: 0.5;
}

@keyframes drift {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(5%, 3%) rotate(1deg); }
  50% { transform: translate(3%, 5%) rotate(-1deg); }
  75% { transform: translate(-2%, 2%) rotate(0.5deg); }
}

.particles {
  position: absolute;
  inset: 0;
  background-image: 
    radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 40% 70%, rgba(255,255,255,0.2), transparent),
    radial-gradient(1px 1px at 60% 20%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 80% 60%, rgba(255,255,255,0.2), transparent),
    radial-gradient(1px 1px at 10% 80%, rgba(255,255,255,0.2), transparent),
    radial-gradient(1px 1px at 90% 40%, rgba(255,255,255,0.3), transparent);
  animation: twinkle 8s ease-in-out infinite;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ========== Header ========== */
header {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 4rem 2rem 2rem;
  background: linear-gradient(to bottom, 
    rgba(10, 10, 15, 0.9) 0%, 
    transparent 100%);
}

header h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 3.5rem);
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-primary);
  text-shadow: 0 0 60px rgba(201, 162, 39, 0.3);
  margin-bottom: 0.5rem;
}

.tagline {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--text-secondary);
  letter-spacing: 0.1em;
}

/* ========== Main Content ========== */
main {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

/* ========== Controls ========== */
.controls {
  margin-bottom: 3rem;
}

.search-box {
  max-width: 400px;
  margin: 0 auto 1.5rem;
}

.search-box input {
  width: 100%;
  padding: 1rem 1.5rem;
  font-family: var(--font-body);
  font-size: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 2rem;
  color: var(--text-primary);
  outline: none;
  transition: all 0.3s ease;
}

.search-box input::placeholder {
  color: var(--text-dim);
  font-style: italic;
}

.search-box input:focus {
  border-color: var(--accent-gold-dim);
  box-shadow: 0 0 20px rgba(201, 162, 39, 0.1);
}

.filter-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.filter-tag {
  padding: 0.4rem 1rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: 1rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-tag:hover {
  border-color: var(--accent-gold-dim);
  color: var(--text-primary);
}

.filter-tag.active {
  background: var(--accent-gold-dim);
  border-color: var(--accent-gold);
  color: var(--bg-void);
}

/* ========== Worlds Grid ========== */
.worlds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 2rem;
}

/* ========== World Card ========== */
.world-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 1rem;
  overflow: hidden;
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
}

.world-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-gold-dim);
  transform: translateY(-4px);
  box-shadow: var(--shadow-glow);
}

.world-card-thumbnail {
  width: 100%;
  height: 180px;
  background: linear-gradient(135deg, var(--bg-mist) 0%, var(--bg-void) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.world-card-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.world-card-thumbnail .placeholder-icon {
  font-size: 3rem;
  opacity: 0.3;
}

.world-card-services {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: flex;
  gap: 0.5rem;
}

.service-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  backdrop-filter: blur(8px);
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.service-badge.multiplayer {
  color: var(--multiplayer-color);
  border-color: var(--multiplayer-color);
}

.service-badge.streaming {
  color: var(--streaming-color);
  border-color: var(--streaming-color);
}

.service-badge.ai {
  color: var(--ai-color);
  border-color: var(--ai-color);
}

.world-card-content {
  padding: 1.5rem;
}

.world-card-name {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.world-card-description {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 1rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.world-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.world-tag {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  background: rgba(201, 162, 39, 0.1);
  border-radius: 0.5rem;
  color: var(--accent-gold);
}

.world-card-enter {
  position: absolute;
  bottom: 1.5rem;
  right: 1.5rem;
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-gold);
  opacity: 0;
  transform: translateX(-10px);
  transition: all 0.3s ease;
}

.world-card:hover .world-card-enter {
  opacity: 1;
  transform: translateX(0);
}

/* ========== Loading State ========== */
.loading-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem;
  color: var(--text-secondary);
}

.portal-spinner {
  width: 60px;
  height: 60px;
  margin: 0 auto 1rem;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--accent-gold);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========== Empty State ========== */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-secondary);
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.empty-state h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

/* ========== Footer ========== */
footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-dim);
  font-size: 0.9rem;
  border-top: 1px solid var(--border-subtle);
  margin-top: 4rem;
}

.legend {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 1rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.indicator.multiplayer {
  background: var(--multiplayer-color);
  box-shadow: 0 0 8px var(--multiplayer-color);
}

.indicator.streaming {
  background: var(--streaming-color);
  box-shadow: 0 0 8px var(--streaming-color);
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
  header {
    padding: 3rem 1.5rem 1.5rem;
  }
  
  main {
    padding: 1.5rem;
  }
  
  .worlds-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .legend {
    flex-direction: column;
    gap: 0.5rem;
  }
}

/* ========== Error State ========== */
.error-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem;
  color: #f87171;
}

.error-state h2 {
  font-family: var(--font-display);
  margin-bottom: 0.5rem;
}

.retry-btn {
  margin-top: 1rem;
  padding: 0.75rem 2rem;
  font-family: var(--font-display);
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid var(--accent-gold-dim);
  border-radius: 2rem;
  color: var(--accent-gold);
  cursor: pointer;
  transition: all 0.2s ease;
}

.retry-btn:hover {
  background: var(--accent-gold-dim);
  color: var(--bg-void);
}
