/* 1. VARIABLES & RESET */
:root {
  --yt-red: #ff0000;
  --tiktok: #000;
  --insta: #E1306C;
  --fb: #1877F2;
  --reddit: #FF4500;
  --bg: #0b0b0b;
  --card: #1a1a1a;
  --text: #eee;
  --accent: #3b82f6;
  --shop: #10b981;
  --blog: #8b5cf6;
  --forum: #f59e0b;
}

* {
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, sans-serif;
  margin: 0;
  padding: 0;
  line-height: 1.5;
}

/* 2. LAYOUT CONTAINERS */
.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px 20px 20px;
  width: 100%;
}

/* STICKY HEADER */
.sticky-top-nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--bg);
  padding: 20px 0 10px 0;
  border-bottom: 1px solid #222;
}

.header { 
  margin-bottom: 20px; 
}

/* 3. SEARCH BAR */
.search-bar { 
  display: flex; 
  gap: 10px; 
  margin-bottom: 15px;
}

.search-input {
  flex: 1; 
  padding: 14px 24px; 
  border-radius: 30px;
  background: #111; 
  border: 1px solid #333; 
  color: #fff;
  font-size: 16px; 
  transition: border-color 0.2s;
  min-width: 0;
}

.search-input:focus { 
  border-color: var(--accent); 
  outline: none; 
}

.search-go {
  padding: 0 30px; 
  border-radius: 30px;
  background: #fff; 
  border: none; 
  font-weight: 700; 
  cursor: pointer;
  white-space: nowrap;
}

/* 4. TOPIC SECTIONS */
.topic-section {
  position: relative;
  background: #141414;
  border-radius: 16px;
  margin: 10px 0;
  border: 1px solid #222;
}

.topic-container {
  display: flex;
  gap: 12px;
  padding: 14px 60px 14px 14px; 
  overflow-x: auto;
  scrollbar-width: none;
  max-height: 64px; 
  scroll-behavior: smooth;
}

.topic-container::-webkit-scrollbar { display: none; }

.topic-section.unfurled .topic-container {
  flex-wrap: wrap;
  max-height: 400px; 
  overflow-y: auto;
}

.topic-btn {
  background: #222; color: #ccc; border: none; white-space: nowrap;
  padding: 10px 20px; border-radius: 25px; cursor: pointer;
  font-weight: 600; font-size: 14px;
}

.topic-btn.active { background: #fff; color: #000; }

.toggle-topics {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px; height: 40px;
  background: #222; border-radius: 50%;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: #fff; z-index: 5;
}

/* 5. FLEXIBLE GRID BOXES */
.grid {
  display: grid;
  /* 'auto-fit' combined with '1fr' makes boxes stretch to fill the screen width */
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 25px;
  margin-top: 30px;
  margin-bottom: 40px;
}

.card {
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
  text-decoration: none;
  color: #fff;
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
}

.card:hover { transform: translateY(-8px); }

.thumb-wrap {
  aspect-ratio: 16/9;
  background: #111;
  position: relative;
  overflow: hidden;
}

.fractal-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #ff0080, #7928ca, #0070f3, #00dfd8, #ff4d4d, #f9cb28, #ff0080);
  background-size: 500% 500%;
  animation: meshGradient 12s infinite;
}

@keyframes meshGradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.title {
  padding: 16px; 
  font-size: 14px; 
  font-weight: 600; 
  min-height: 60px; 
  display: -webkit-box; 
  -webkit-line-clamp: 2; 
  -webkit-box-orient: vertical; 
  overflow: hidden;
}

/* 6. UTILITY CLASSES */
.semi-transparent-gradient {
  display: flex;
  width: 100%;
  max-width: 300px;
  padding: 20px;
  background: linear-gradient(35deg, rgba(255, 255, 255, 0.1), rgba(0, 123, 255, 0.1), rgba(255, 0, 0, 0.1));
  animation: gradientMove 3s ease infinite;
  justify-content: center; 
  align-items: center;
  color: #ffffff;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  margin: 20px auto; /* Centered horizontally */
}

.controls { 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  margin-top: 20px; 
  width: 100%;
}

.load-more-btn {
  background: #1a1a1a; 
  color: #fff; 
  border: 1px solid #333;
  padding: 12px 48px; 
  border-radius: 30px; 
  font-weight: 700;
  cursor: pointer; 
}

/* 7. MOBILE RESPONSIVE TWEAKS */
@media (max-width: 600px) {
  /* Ensure the container uses all available width */
  .app-container { padding: 0 10px 20px 10px; }

  .search-bar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .search-go { width: 100%; }

  .header { text-align: center; }

  .grid {
    /* On very small mobile, allow the boxes to be slightly smaller to fit better */
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 15px;
  }

  .toggle-topics {
    top: -15px;
    right: 10px;
  }
}