/**
 * Browse Topics Widget Styles
 * Dynamic table of contents with sticky positioning and mobile-friendly design
 */

/* Base Browse Topics Widget Styles */
.browse-topics-widget {
  background: #ffffff;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 30px;
  transition: all 0.3s ease;
}

.browse-topics-widget .widget-title {
  font-size: 18px;
  font-weight: 700;
  color: #333333;
  margin-bottom: 15px;
  padding-bottom: 15px;
  border-bottom: 2px solid #6c63ff;
  position: relative;
  cursor: pointer;
}

.browse-topics-widget .arrow-icon {
  display: none;
  float: right;
  width: 20px;
  height: 20px;
  position: relative;
  transition: transform 0.3s ease;
}

.browse-topics-widget .arrow-icon::before,
.browse-topics-widget .arrow-icon::after {
  content: '';
  position: absolute;
  background: #333333;
  height: 2px;
  width: 10px;
  top: 50%;
  transition: all 0.3s ease;
}

.browse-topics-widget .arrow-icon::before {
  right: 5px;
  transform: rotate(45deg);
  transform-origin: right center;
}

.browse-topics-widget .arrow-icon::after {
  left: 5px;
  transform: rotate(-45deg);
  transform-origin: left center;
}

.browse-topics-widget.active .arrow-icon::before {
  transform: rotate(-45deg);
}

.browse-topics-widget.active .arrow-icon::after {
  transform: rotate(45deg);
}

.browse-topics-widget .browse-topics-content {
  max-height: 600px;
  overflow-y: auto;
}

.browse-topics-widget .browse-topics-content::-webkit-scrollbar {
  width: 6px;
}

.browse-topics-widget .browse-topics-content::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.browse-topics-widget .browse-topics-content::-webkit-scrollbar-thumb {
  background: #6c63ff;
  border-radius: 3px;
}

.browse-topics-widget .browse-topics-content::-webkit-scrollbar-thumb:hover {
  background: #5a52e0;
}

.browse-topics-widget .topics-menu {
  list-style: none;
  padding: 0;
  margin: 0;
}

.browse-topics-widget .topics-menu li {
  margin-bottom: 0;
  border-bottom: 1px solid #f0f0f0;
  transition: all 0.2s ease;
}

.browse-topics-widget .topics-menu li:last-child {
  border-bottom: none;
}

.browse-topics-widget .topics-menu li:hover {
  background-color: #f8f8ff;
}

.browse-topics-widget .topics-menu a {
  display: block;
  padding: 12px 15px;
  color: #555555;
  text-decoration: none;
  font-size: 14px;
  line-height: 1.5;
  transition: all 0.3s ease;
  position: relative;
  padding-left: 30px;
}

.browse-topics-widget .topics-menu a::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  background: #6c63ff;
  border-radius: 50%;
  opacity: 0.5;
  transition: all 0.3s ease;
}

.browse-topics-widget .topics-menu a:hover {
  color: #6c63ff;
  padding-left: 35px;
  background: linear-gradient(to right, rgba(108, 99, 255, 0.05) 0%, transparent 100%);
}

.browse-topics-widget .topics-menu a:hover::before {
  opacity: 1;
  transform: translateY(-50%) scale(1.2);
}

.browse-topics-widget .topics-menu a.active {
  color: #6c63ff;
  font-weight: 600;
  background: linear-gradient(to right, rgba(108, 99, 255, 0.1) 0%, transparent 100%);
  border-left: 3px solid #6c63ff;
  padding-left: 32px;
}

.browse-topics-widget .topics-menu a.active::before {
  opacity: 1;
  background: #6c63ff;
  transform: translateY(-50%) scale(1.3);
  box-shadow: 0 0 8px rgba(108, 99, 255, 0.5);
}

/* Desktop Sticky Positioning */
@media (min-width: 992px) {
  .browse-topics-widget {
    /* Sticky positioning is applied via JavaScript for proper width calculation */
    max-height: calc(100vh - 140px);
    overflow: visible;
  }
  
  .browse-topics-widget .browse-topics-content {
    max-height: calc(100vh - 240px);
  }
}

/* Mobile Styles */
@media (max-width: 991px) {
  .browse-topics-widget {
    position: relative;
    z-index: 100;
    margin-bottom: 20px;
  }
  
  .browse-topics-widget .widget-title {
    cursor: pointer;
  }
  
  .browse-topics-widget .arrow-icon {
    display: inline-block;
  }
  
  .browse-topics-widget .browse-topics-content {
    display: none;
    max-height: 400px;
    margin-top: 10px;
  }
  
  .browse-topics-widget.active .browse-topics-content {
    display: block;
  }
}

/* Mobile "Go to Section" Floating Button */
.mobile-go-to-section-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: linear-gradient(135deg, #6c63ff 0%, #5a52e0 100%);
  color: #ffffff;
  border: none;
  border-radius: 50px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(108, 99, 255, 0.4);
  cursor: pointer;
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 8px;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.mobile-go-to-section-btn .icon {
  font-size: 16px;
  display: flex;
  align-items: center;
}

.mobile-go-to-section-btn.visible {
  transform: translateY(0);
  opacity: 1;
}

.mobile-go-to-section-btn:hover,
.mobile-go-to-section-btn.active {
  background: linear-gradient(135deg, #5a52e0 0%, #4a42c0 100%);
  box-shadow: 0 6px 20px rgba(108, 99, 255, 0.6);
  transform: translateY(0) scale(1.05);
}

.mobile-go-to-section-btn:active {
  transform: translateY(0) scale(0.98);
}

/* Hide mobile button on desktop */
@media (min-width: 992px) {
  .mobile-go-to-section-btn {
    display: none !important;
  }
}

/* Mobile only: Show button */
@media (max-width: 991px) {
  .mobile-go-to-section-btn {
    display: flex;
  }
}

/* Animation for topics appearing */
@keyframes slideInFromLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.browse-topics-widget .topics-menu li {
  animation: slideInFromLeft 0.3s ease forwards;
  opacity: 0;
}

.browse-topics-widget .topics-menu li:nth-child(1) { animation-delay: 0.05s; }
.browse-topics-widget .topics-menu li:nth-child(2) { animation-delay: 0.1s; }
.browse-topics-widget .topics-menu li:nth-child(3) { animation-delay: 0.15s; }
.browse-topics-widget .topics-menu li:nth-child(4) { animation-delay: 0.2s; }
.browse-topics-widget .topics-menu li:nth-child(5) { animation-delay: 0.25s; }
.browse-topics-widget .topics-menu li:nth-child(6) { animation-delay: 0.3s; }
.browse-topics-widget .topics-menu li:nth-child(7) { animation-delay: 0.35s; }
.browse-topics-widget .topics-menu li:nth-child(8) { animation-delay: 0.4s; }
.browse-topics-widget .topics-menu li:nth-child(9) { animation-delay: 0.45s; }
.browse-topics-widget .topics-menu li:nth-child(10) { animation-delay: 0.5s; }

/* Smooth scroll behavior */
html {
  scroll-behavior: smooth;
}

/* Styling for H2 tags that are targeted */
.article-content h2 {
  scroll-margin-top: 120px; /* Offset for fixed header */
  position: relative;
  transition: all 0.3s ease;
}

.article-content h2:target {
  animation: highlightSection 1s ease;
}

@keyframes highlightSection {
  0%, 100% {
    background-color: transparent;
  }
  50% {
    background-color: rgba(108, 99, 255, 0.1);
  }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .browse-topics-widget {
    padding: 15px;
  }
  
  .browse-topics-widget .widget-title {
    font-size: 16px;
  }
  
  .browse-topics-widget .topics-menu a {
    font-size: 13px;
    padding: 10px 12px;
    padding-left: 28px;
  }
  
  .mobile-go-to-section-btn {
    bottom: 15px;
    right: 15px;
    padding: 10px 20px;
    font-size: 13px;
  }
}

/* Ensure sidebar positioning */
.node--type-article aside.col-lg-3 {
  position: relative;
}

/* Purple dots separator spacing adjustment */
.browse-topics-widget + .purple-dots-separator,
.browse-topics-widget + .related-blogs-widget {
  margin-top: 30px;
}

