/* Navigation buttons */
.fixed-nav-buttons {
  position: fixed;
  width: 100%;
  z-index: 60;
  pointer-events: none;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  justify-content: space-between;
  padding: 0 1rem;
}

.nav-btn-floating {
  background-color: rgba(255, 255, 255, 0.8);
  color: #6a5acd;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer !important;
  box-shadow: 0 4px 12px rgba(106, 90, 205, 0.4);
  pointer-events: auto !important;
  transition: all 0.3s ease;
  animation: floatButtons 3s ease-in-out infinite, fadeIn 0.5s ease-out;
  position: relative !important;
  overflow: hidden;
  z-index: 200 !important;
}

/* Add glitter effect to nav buttons */
.nav-btn-floating::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    to bottom right, 
    rgba(255, 255, 255, 0) 0%, 
    rgba(255, 255, 255, 0.3) 50%, 
    rgba(255, 255, 255, 0) 100%
  );
  transform: rotate(45deg);
  transition: transform 0.5s ease-in-out;
  z-index: 1;
}

.nav-btn-floating:hover::before {
  animation: buttonGlitter 1.5s ease-in-out;
}

.nav-btn-floating:hover {
  background-color: rgba(255, 255, 255, 0.95);
  transform: scale(1.15);
  box-shadow: 0 0 18px rgba(106, 90, 205, 0.8);
}

.nav-btn-floating svg {
  position: relative;
  z-index: 2;
}

.nav-btn-left {
  margin-right: auto;
  left: calc(50% - 280px);
}

.nav-btn-right {
  margin-left: auto;
  right: calc(50% - 280px);
}

/* Music controls styling */
.music-controls-container {
  pointer-events: none !important;
  position: fixed !important;
  z-index: 150 !important;
  bottom: 1rem !important;
  display: flex !important;
  justify-content: center !important;
  width: 100% !important;
}

.music-control-btn, 
.music-control-slider, 
.music-control-counter,
.page-navigation-container,
#page-select {
  pointer-events: auto !important;
  z-index: 200 !important;
  position: relative !important;
}

.music-control-btn:hover {
  transform: scale(1.15);
  box-shadow: 0 0 15px rgba(106, 90, 205, 0.7);
}

#toggle-music, #volume-control, #page-select {
  transition: transform 0.3s ease;
}

#toggle-music:hover, #volume-control:hover, #page-select:hover {
  transform: scale(1.1);
}

/* Page jumper styling */
.page-select {
  background-color: rgba(255, 255, 255, 0.9);
  color: #6a5acd;
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(106, 90, 205, 0.2);
  cursor: pointer !important;
  position: relative !important;
  z-index: 100 !important;
  pointer-events: auto !important;
  border: 1px solid rgba(106, 90, 205, 0.3);
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236a5acd' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  background-size: 1em;
  padding-right: 2.5rem;
}

.page-select:hover {
  box-shadow: 0 4px 12px rgba(106, 90, 205, 0.3);
  background-color: rgba(224, 216, 240, 1);
}

/* Volume control styling */
input[type=range] {
  height: 6px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  margin: 10px 0;
  border-radius: 5px;
  background: #e0d8f0;
}

input[type=range]::-webkit-slider-runnable-track {
  height: 6px;
  background: #e0d8f0;
  border-radius: 5px;
}

input[type=range]::-webkit-slider-thumb {
  height: 16px;
  width: 16px;
  border-radius: 50%;
  background: #6a5acd;
  -webkit-appearance: none;
  margin-top: -5px;
}

input[type=range]:focus {
  outline: none;
}

/* Text-only memory specific styles */
.text-only-memory {
  background: linear-gradient(to bottom, #f9f7ff, #ffffff);
  padding: 2rem;
  border-radius: 8px;
  box-shadow: inset 0 0 20px rgba(106, 90, 205, 0.15);
  height: 100%;
  overflow-y: auto;
  white-space: pre-line;
  -webkit-overflow-scrolling: touch;
}

/* Mobile optimizations */
@media (max-width: 768px) {
  .book {
    height: 80vh !important;
    max-height: 80vh !important;
    transform-style: preserve-3d !important;
    perspective: 1000px !important;
    will-change: transform !important;
    touch-action: manipulation !important;
  }
  
  .page {
    height: 100% !important;
    backface-visibility: hidden !important;
    will-change: transform !important;
    transform-style: preserve-3d !important;
    transition: transform 0.5s cubic-bezier(0.645, 0.045, 0.355, 1) !important;
  }
  
  .page-content {
    -webkit-overflow-scrolling: touch !important;
    overflow-y: auto !important;
    height: 100% !important;
    padding: 1rem !important;
  }
  
  .memory-media {
    height: 45% !important;
    min-height: 45% !important;
  }
  
  .memory-text-container {
    height: 55% !important;
    min-height: 55% !important;
  }
  
  /* Fix for page jumper */
  .page-select {
    padding: 0.35rem 0.75rem !important;
    font-size: 0.85rem !important;
  }
  
  /* Hide nav buttons on mobile and use swipe */
  .nav-btn-floating {
    display: none !important;
  }
  
  /* Fix open book button */
  #open-book {
    position: relative !important;
    z-index: 9999 !important;
    pointer-events: auto !important;
    cursor: pointer !important;
  }
  
  /* Reduce animations for better performance */
  .animate-float,
  .animate-pulse-slow,
  .floating-particles::before,
  .sparkles,
  .floating-with-music,
  .magic-shine::after,
  .shimmer-text {
    animation-duration: 0.5s !important;
    animation-delay: 0s !important;
  }
  
  /* Higher contrast for readability */
  h1, h2, p {
    text-shadow: 0 1px 2px rgba(0,0,0,0.1) !important;
  }
  
  /* Optimize music controls */
  .music-controls-container {
    background-color: rgba(255, 255, 255, 0.6) !important;
    backdrop-filter: blur(5px) !important;
    border-radius: 30px !important;
    padding: 0.35rem 0.5rem !important;
  }
}

/* Emergency fix for Open Book button */
#open-book {
  cursor: pointer !important;
  z-index: 9999 !important;
  position: relative !important;
  pointer-events: auto !important;
  -webkit-tap-highlight-color: transparent !important;
  touch-action: manipulation !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  transform: translateZ(0) !important;
  -webkit-transform: translateZ(0) !important;
  will-change: transform !important;
}

/* Enhanced button styling - MORE AGGRESSIVE to ensure they work */
button, 
a, 
.nav-btn-floating, 
.music-control-btn, 
input[type="range"],
#open-book,
#submit-password,
#toggle-music,
#page-select,
.page-number,
.page-select {
  cursor: pointer !important;
  position: relative !important;
  z-index: 50 !important;
  pointer-events: auto !important;
  -webkit-tap-highlight-color: transparent !important;
  touch-action: manipulation !important;
  transform: translateZ(0) !important;
}

/* Make input fields properly clickable */
input, textarea, select {
  cursor: text !important;
  position: relative !important;
  z-index: 1000 !important;
  pointer-events: auto !important;
  transform: translateZ(0) !important;
}

/* Force clickable style */
*[onclick],
*[id="open-book"],
*[id="submit-password"],
*[id="toggle-music"],
*[id="prev-btn"],
*[id="next-btn"],
*[id="password"],
*[id="page-select"],
button,
a,
input,
select,
textarea {
  pointer-events: auto !important;
  position: relative !important;
  z-index: 50 !important;
  transform: translateZ(0) !important;
}

/* Fix for Firefox and Safari */
button, a, [role="button"], select {
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Whitespace management for text content */
.whitespace-pre-line {
  white-space: pre-line !important;
}

/* Reduce animations on devices with reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
