/* Scroll Enhancements for Nostalgia Sejarah Islam
 * Version 5.1 - Better scrolling experience
 */

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

/* Better Scrollbar for Modal Content */
.modal-content {
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(102, 126, 234, 0.8) rgba(229, 231, 235, 0.5);
}

.modal-content::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

.modal-content::-webkit-scrollbar-track {
  background: rgba(229, 231, 235, 0.5);
  border-radius: 10px;
  margin: 10px;
}

.modal-content::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.9) 0%, rgba(118, 75, 162, 0.9) 100%);
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.modal-content::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, rgba(118, 75, 162, 1) 0%, rgba(102, 126, 234, 1) 100%);
  border-color: rgba(255, 255, 255, 0.5);
}

/* Scroll to Top Button */
#scrollToTop {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 50%;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  z-index: 999;
  transition: all 0.3s ease;
  animation: fadeInUp 0.3s ease-out;
}

#scrollToTop:hover {
  transform: translateY(-5px) scale(1.1);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

#scrollToTop:active {
  transform: translateY(-3px) scale(1.05);
}

#scrollToTop.show {
  display: flex;
}

/* Scroll Progress Indicator */
#scrollProgress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 4px;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  z-index: 9999;
  transition: width 0.1s ease-out;
  box-shadow: 0 2px 5px rgba(102, 126, 234, 0.5);
}

/* Smooth Scroll Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

/* Material Modal Scroll Enhancements */
#materialModal .modal-content {
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
}

/* Quiz Modal Scroll Enhancements */
#quizModal .modal-content {
  max-height: 90vh;
  overflow-y: auto;
}

/* Opening Screen Scroll */
.opening-screen .speech-bubble {
  max-height: 60vh;
  overflow-y: auto;
  scroll-behavior: smooth;
}

/* Scroll Hint for Long Content */
.scroll-hint {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0.7;
  animation: pulse 2s infinite;
  pointer-events: none;
  z-index: 10;
}

.scroll-hint i {
  font-size: 24px;
  color: #667eea;
}

.scroll-hint span {
  font-size: 12px;
  color: #667eea;
  margin-top: 5px;
}

/* Hide scroll hint when user scrolls */
.scrolled .scroll-hint {
  display: none;
}

/* Better Focus Styles for Keyboard Navigation */
*:focus-visible {
  outline: 3px solid #667eea;
  outline-offset: 2px;
  border-radius: 4px;
}

/* Smooth Transitions for Interactive Elements */
.card,
.btn,
.material-card,
.quiz-option {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Prevent Layout Shift During Scroll */
.modal {
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Better Touch Scrolling on Mobile */
.modal-content,
.opening-screen,
.speech-bubble {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Scroll Snap for Better UX (optional for sections) */
.snap-scroll {
  scroll-snap-type: y proximity;
  scroll-padding: 20px;
}

.snap-scroll > section {
  scroll-snap-align: start;
  scroll-snap-stop: normal;
}

/* Loading State for Scroll */
.scroll-loading {
  pointer-events: none;
  opacity: 0.6;
}

/* Responsive Scroll Button */
@media (max-width: 768px) {
  #scrollToTop {
    width: 45px;
    height: 45px;
    bottom: 20px;
    right: 20px;
    font-size: 18px;
  }
  
  #scrollProgress {
    height: 3px;
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  #scrollToTop {
    border: 2px solid white;
  }
  
  .modal-content::-webkit-scrollbar-thumb {
    background: #000;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  
  #scrollToTop,
  .scroll-hint {
    animation: none;
  }
  
  * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
