/**
 * Discovery Bar Component
 * Reusable topic filter/discovery bar component
 * Used on: explore page, profile pages, topic pages, leaderboard
 */

/* ============================================================================
   Discovery Bar Section
   ============================================================================ */

.discovery-bar-section {
  position: relative;
  padding: 0.5rem 0 1rem;
  margin-bottom: 0.25rem;
  z-index: 1000;
}

/* On explore page, add margin-top since search is now in nav bar */
.page-explore .discovery-bar-section {
  margin-top: 1.5rem;
}

/* On explore page, constrain discovery bar width and center it */
.page-explore .discovery-bar-section .section-container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 2rem;
}

/* ============================================================================
   Discovery Bar Container
   ============================================================================ */

.discovery-bar-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ============================================================================
   Discovery Help Button
   ============================================================================ */

.discovery-help-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.discovery-help-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: rgba(0, 168, 255, 0.1);
  z-index: 99999;
}

.discovery-help-icon {
  line-height: 1;
}

/* ============================================================================
   Panel Help Labels (shown when hovering discovery help button)
   ============================================================================ */

.panel-help-label {
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.4rem 0.85rem;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm, 4px);
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1.3;
  text-align: center;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 1000;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}

/* Arrow pointing down from label */
.panel-help-label::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid rgba(255, 255, 255, 0.15);
}

/* Ensure panels have relative positioning for label placement */
.explore-panel,
.explore-author-preview {
  position: relative;
}

/* Outline effect on panels when help is active */
.explore-panel.help-highlight,
.explore-author-preview.help-highlight,
.discovery-bar-wrapper.help-highlight {
  outline: 2px solid rgba(0, 168, 255, 0.8);
  outline-offset: 4px;
  border-radius: var(--radius-md, 8px);
  transition: outline 0.3s ease;
  overflow: visible !important; /* Allow help labels to show above panels */
}

/* Parent containers need overflow visible when help is active */
.help-overflow {
  overflow: visible !important;
}

/* Show labels when parent has help-highlight class */
.explore-panel.help-highlight .panel-help-label,
.explore-author-preview.help-highlight .panel-help-label,
.discovery-bar-wrapper.help-highlight .panel-help-label {
  opacity: 1;
  visibility: visible;
}

/* Discovery bar wrapper needs relative positioning for label */
.discovery-bar-wrapper {
  position: relative;
}

/* Specific positioning for author preview label (inside pages panel) */
#exploreAuthorPreview .panel-help-label {
  top: -24px;
}

/* Trending panel label - position from right to prevent clipping off viewport */
#explorePanelTrending .panel-help-label {
  left: auto;
  right: 0;
  transform: none;
}

#explorePanelTrending .panel-help-label::after {
  left: auto;
  right: 20px;
  transform: none;
}

/* Help button active state (when clicked to toggle on) */
.discovery-help-btn.active {
  background: rgba(0, 168, 255, 0.2);
  border-color: rgba(0, 168, 255, 0.5);
  color: var(--color-primary, #00a8ff);
}

.discovery-bar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.5rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md, 8px);
  min-width: 0;
  overflow: hidden;
}

/* ============================================================================
   Discovery Links
   ============================================================================ */

.discovery-links-wrapper {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.discovery-links {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0.05rem 0;
}

.discovery-links::-webkit-scrollbar {
  display: none;
}

/* ============================================================================
   Discovery Link Pills
   ============================================================================ */

.discovery-link {
  font-size: clamp(0.5rem, 0.8vw, 0.55rem);
  font-weight: 500;
  color: var(--color-text-secondary, #888);
  text-decoration: none;
  white-space: nowrap;
  padding: 0.08rem 0.3rem;
  border-radius: var(--radius-sm, 4px);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.15rem;
  cursor: pointer;
}

.discovery-link:hover {
  color: white;
  background: rgba(0, 168, 255, 0.2);
  border-color: rgba(0, 168, 255, 0.4);
}

.discovery-link.active {
  color: white;
  background: rgba(0, 168, 255, 0.25);
  border-color: rgba(0, 168, 255, 0.5);
}

/* ============================================================================
   Discovery Search Pill
   ============================================================================ */

.discovery-search-pill {
  position: relative;
  overflow: hidden;
  flex-shrink: 0; /* Never shrink - always stay visible */
  /* Active blue style by default */
  color: white;
  background: rgba(0, 168, 255, 0.25);
  border-color: rgba(0, 168, 255, 0.5);
}

.discovery-search-pill svg {
  flex-shrink: 0;
  margin-left: 0.3rem;
  transition: opacity 0.2s ease;
}

.discovery-search-pill .discovery-search-input {
  width: 0;
  height: auto;
  min-height: 0;
  padding: 0;
  margin: 0;
  border: none;
  outline: none;
  box-shadow: none;
  background: transparent;
  color: white;
  font-size: inherit;
  font-weight: inherit;
  font-family: inherit;
  line-height: inherit;
  opacity: 0;
  transition: width 0.2s ease, opacity 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
}

.discovery-search-pill .discovery-search-input:focus {
  outline: none;
  box-shadow: none;
}

.discovery-search-pill .discovery-search-input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

/* Expanded state */
.discovery-search-pill.expanded {
  background: rgba(0, 168, 255, 0.3);
  border-color: rgba(0, 168, 255, 0.6);
}

.discovery-search-pill.expanded .discovery-search-input {
  width: 80px;
  opacity: 1;
  margin-left: 0.25rem;
}

/* ============================================================================
   No Results Message
   ============================================================================ */

.discovery-no-results {
  font-size: 0.75rem;
  color: var(--color-text-muted, #666);
  font-style: italic;
  padding: 0.25rem 0.5rem;
  white-space: nowrap;
}

/* ============================================================================
   Active Filters Row
   ============================================================================ */

.active-filters-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  margin-top: 0.5rem;
}

.active-filters-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-muted, #666);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.active-filters-pills {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex: 1;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.5rem;
  background: rgba(0, 168, 255, 0.15);
  border: 1px solid rgba(0, 168, 255, 0.3);
  border-radius: var(--radius-sm, 4px);
  font-size: 0.75rem;
  color: white;
}

.filter-pill-text {
  font-weight: 500;
}

.filter-pill-remove {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: color 0.2s ease;
}

.filter-pill-remove:hover {
  color: white;
}

.clear-all-filters-btn {
  font-size: 0.7rem;
  color: var(--color-text-muted, #666);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  transition: color 0.2s ease;
}

.clear-all-filters-btn:hover {
  color: white;
}

/* ============================================================================
   Profile Page Variant
   Minimal adjustments for profile pages
   ============================================================================ */

.profile-topic-filter-section {
  margin-bottom: 1rem;
}

.profile-discovery-bar-wrapper {
  padding: 0;
}

.profile-discovery-bar {
  background: transparent;
  border: none;
  padding: 0.5rem 0;
}

/* ============================================================================
   Topic Filter Bar Variant (Centered)
   For topic pages and other centered layouts
   ============================================================================ */

.topic-filter-bar-wrapper {
  margin-bottom: 1rem;
}

/* Inline variant - reduced spacing when placed between header and grid */
.topic-filter-bar-inline {
  padding: 0 0 0.25rem;
  margin-bottom: 0;
}

.topic-filter-bar-wrapper .discovery-bar {
  justify-content: center;
}

.topic-filter-bar-wrapper .discovery-links-wrapper {
  flex: 0 1 auto;
  max-width: 100%;
}

.topic-filter-bar-wrapper .discovery-links {
  justify-content: center;
}

/* ============================================================================
   Tablet Responsive - Hide discovery links to prevent overlap with search
   ============================================================================ */

@media (max-width: 900px) {
  /* Hide discovery links on tablet - they move to hamburger menu */
  .discovery-links-wrapper {
    display: none;
  }

  /* When links are hidden, let search pill take more space */
  .discovery-search-pill.expanded .discovery-search-input {
    width: 140px;
  }
}

/* ============================================================================
   Mobile Responsive
   ============================================================================ */

@media (max-width: 768px) {
  .discovery-bar-section {
    padding: 0.25rem 0 0.5rem;
  }

  .discovery-bar {
    padding: 0.35rem 0.5rem;
  }

  .discovery-links {
    gap: 0.25rem;
  }

  /* Font size and padding now handled by clamp() in base styles */

  .active-filters-row {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem 0;
  }

  .active-filters-pills {
    width: 100%;
    order: 2;
  }
}

/* ============================================================================
   Group Tags (user-scoped organizational tags)
   ============================================================================ */

.discovery-link-group {
  font-style: italic;
  border-style: dashed;
}

.discovery-link-group.active {
  border-style: dashed;
}
