/* ==============================================
   CASE STUDY TABLE OF CONTENTS NAVIGATION
   Premium Glassmorphic Apple iOS Design
   with Fluid Scroll-spy Transitions
   ============================================== */

/* ==============================================
   LIGHT MODE - Frosted Glass
   ============================================== */

.cs-jump-nav {
  /* Fixed bottom position - above floating nav */
  position: fixed !important;
  bottom: 1.5rem !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  z-index: 2500 !important; /* Above all content including sections and images */

  display: flex !important;
  flex-wrap: nowrap !important;
  gap: 0.25rem;
  padding: 0.5rem 0.625rem;

  /* Premium Glassmorphism - Enhanced blur */
  background: rgba(255, 255, 255, 0.92) !important;
  backdrop-filter: blur(60px) saturate(200%) brightness(1.05) !important;
  -webkit-backdrop-filter: blur(60px) saturate(200%) brightness(1.05) !important;

  /* Premium border & shadow - more prominent */
  border: 1px solid rgba(255, 255, 255, 0.8) !important;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.04),
    0 2px 4px rgba(0, 0, 0, 0.03),
    0 4px 8px rgba(0, 0, 0, 0.04),
    0 8px 16px rgba(0, 0, 0, 0.05),
    0 16px 32px rgba(0, 0, 0, 0.08),
    0 32px 64px rgba(0, 0, 0, 0.12) !important;

  border-radius: 1rem;
  width: auto;
  max-width: calc(100vw - 2rem);

  /* Smooth entrance */
  animation: slideUpFade 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;

  /* Force new stacking context at top level */
  isolation: isolate !important;
  contain: layout style !important;
  will-change: transform, opacity;
}

@keyframes slideUpFade {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* Hidden state - smooth slide down and fade out */
.cs-jump-nav.toc-hidden {
  opacity: 0 !important;
  transform: translateX(-50%) translateY(20px) !important;
  pointer-events: none !important;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Smooth transition back to visible */
.cs-jump-nav:not(.toc-hidden) {
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.cs-jump-link {
  position: relative;
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: rgba(0, 0, 0, 0.5);
  text-decoration: none !important;
  border-radius: 0.5rem;
  white-space: nowrap;
  outline: none;
  cursor: pointer;
  z-index: 1;

  /* Fluid transitions for scroll spy */
  transition:
    color 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    font-weight 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);

  transform-origin: center center;
}

/* Remove text decoration from all states */
@media (hover: hover) {
  .cs-jump-link:hover,
  .cs-jump-link:focus,
  .cs-jump-link:active,
  .cs-jump-link:visited {
    text-decoration: none !important;
  }
}

/* ==============================================
   HOVER STATE
   ============================================== */

@media (hover: hover) {
  .cs-jump-link:hover:not(.active) {
    color: rgba(0, 0, 0, 0.85);
    background: rgba(0, 0, 0, 0.05);
  }
}

/* Focus visible for keyboard accessibility */
.cs-jump-link:focus-visible {
  color: rgba(0, 0, 0, 0.85);
  background: rgba(0, 0, 0, 0.05);
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.8),
    0 0 0 4px rgba(0, 0, 0, 0.2);
}

/* ==============================================
   CLICK/PRESS ANIMATION
   ============================================== */

.cs-jump-link:active {
  transform: scale(0.96);
  transition: transform 0.1s ease;
}

/* ==============================================
   ACTIVE STATE - Fluid Animated Pill
   ============================================== */

.cs-jump-link.active {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.88);
  border-radius: 0.5rem;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.15),
    0 4px 16px rgba(0, 0, 0, 0.1);

  /* Smooth transitions when scrolling changes active state */
  transition:
    color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    background 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Click animation - bouncy entrance */
.cs-jump-link.active.clicked {
  animation: pillBounce 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes pillBounce {
  0% {
    transform: scale(0.92);
  }
  50% {
    transform: scale(1.04);
  }
  100% {
    transform: scale(1);
  }
}

@media (hover: hover) {
  .cs-jump-link.active:hover {
    background: rgba(0, 0, 0, 0.92);
  }
}

/* Leaving active state - smooth fade */
.cs-jump-link:not(.active) {
  background: transparent;
  box-shadow: none;
  transition:
    color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    background 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Override all theme-specific colors */
.cs-hero--teal .cs-jump-link.active,
.cs-hero--green .cs-jump-link.active,
.cs-hero--pink .cs-jump-link.active,
.cs-hero--orange .cs-jump-link.active,
.cs-hero--blue .cs-jump-link.active,
.cs-hero--purple .cs-jump-link.active,
.cs-hero--red .cs-jump-link.active,
.managed-service-page .cs-jump-link.active,
.pushowl-ai-page .cs-jump-link.active,
.pushowl-page .cs-jump-link.active,
.bhava-page .cs-jump-link.active,
.branch-page .cs-jump-link.active,
.calendar-page .cs-jump-link.active {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  background: rgba(0, 0, 0, 0.88);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.15),
    0 4px 16px rgba(0, 0, 0, 0.1);
}

/* Hover - all themes */
@media (hover: hover) {
  .cs-hero--teal .cs-jump-link:hover:not(.active),
  .cs-hero--green .cs-jump-link:hover:not(.active),
  .cs-hero--pink .cs-jump-link:hover:not(.active),
  .cs-hero--orange .cs-jump-link:hover:not(.active),
  .cs-hero--blue .cs-jump-link:hover:not(.active),
  .cs-hero--purple .cs-jump-link:hover:not(.active),
  .cs-hero--red .cs-jump-link:hover:not(.active),
  .managed-service-page .cs-jump-link:hover:not(.active),
  .pushowl-ai-page .cs-jump-link:hover:not(.active),
  .pushowl-page .cs-jump-link:hover:not(.active),
  .bhava-page .cs-jump-link:hover:not(.active),
  .branch-page .cs-jump-link:hover:not(.active),
  .calendar-page .cs-jump-link:hover:not(.active) {
    color: rgba(0, 0, 0, 0.85);
    background: rgba(0, 0, 0, 0.05);
  }
}

/* ==============================================
   DARK MODE - Premium Glass
   ============================================== */

[data-theme="dark"] .cs-jump-nav {
  background: rgba(20, 20, 22, 0.95) !important;
  backdrop-filter: blur(60px) saturate(200%) brightness(0.95) !important;
  -webkit-backdrop-filter: blur(60px) saturate(200%) brightness(0.95) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06),
    0 2px 4px rgba(0, 0, 0, 0.15),
    0 4px 8px rgba(0, 0, 0, 0.2),
    0 8px 16px rgba(0, 0, 0, 0.25),
    0 16px 32px rgba(0, 0, 0, 0.3),
    0 32px 64px rgba(0, 0, 0, 0.4) !important;
}

[data-theme="dark"] .cs-jump-link {
  color: rgba(255, 255, 255, 0.5);
}

@media (hover: hover) {
  [data-theme="dark"] .cs-jump-link:hover:not(.active) {
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.1);
  }
}

/* Dark focus visible */
[data-theme="dark"] .cs-jump-link:focus-visible {
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.1);
  box-shadow:
    0 0 0 2px rgba(0, 0, 0, 0.5),
    0 0 0 4px rgba(255, 255, 255, 0.3);
}

/* Dark mode active - luminous white */
[data-theme="dark"] .cs-jump-link.active,
[data-theme="dark"] .cs-hero--teal .cs-jump-link.active,
[data-theme="dark"] .cs-hero--green .cs-jump-link.active,
[data-theme="dark"] .cs-hero--pink .cs-jump-link.active,
[data-theme="dark"] .cs-hero--orange .cs-jump-link.active,
[data-theme="dark"] .cs-hero--blue .cs-jump-link.active,
[data-theme="dark"] .cs-hero--purple .cs-jump-link.active,
[data-theme="dark"] .cs-hero--red .cs-jump-link.active,
[data-theme="dark"] .managed-service-page .cs-jump-link.active,
[data-theme="dark"] .pushowl-ai-page .cs-jump-link.active,
[data-theme="dark"] .pushowl-page .cs-jump-link.active,
[data-theme="dark"] .bhava-page .cs-jump-link.active,
[data-theme="dark"] .branch-page .cs-jump-link.active,
[data-theme="dark"] .calendar-page .cs-jump-link.active {
  color: #1a1a1a !important;
  -webkit-text-fill-color: #1a1a1a !important;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.95);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.2),
    0 4px 16px rgba(0, 0, 0, 0.15);
}

@media (hover: hover) {
  [data-theme="dark"] .cs-jump-link.active:hover {
    background: #ffffff;
  }
}

/* Dark hover - all themes */
@media (hover: hover) {
  [data-theme="dark"] .cs-hero--teal .cs-jump-link:hover:not(.active),
  [data-theme="dark"] .cs-hero--green .cs-jump-link:hover:not(.active),
  [data-theme="dark"] .cs-hero--pink .cs-jump-link:hover:not(.active),
  [data-theme="dark"] .cs-hero--orange .cs-jump-link:hover:not(.active),
  [data-theme="dark"] .cs-hero--blue .cs-jump-link:hover:not(.active),
  [data-theme="dark"] .cs-hero--purple .cs-jump-link:hover:not(.active),
  [data-theme="dark"] .cs-hero--red .cs-jump-link:hover:not(.active),
  [data-theme="dark"] .managed-service-page .cs-jump-link:hover:not(.active),
  [data-theme="dark"] .pushowl-ai-page .cs-jump-link:hover:not(.active),
  [data-theme="dark"] .pushowl-page .cs-jump-link:hover:not(.active),
  [data-theme="dark"] .bhava-page .cs-jump-link:hover:not(.active),
  [data-theme="dark"] .branch-page .cs-jump-link:hover:not(.active),
  [data-theme="dark"] .calendar-page .cs-jump-link:hover:not(.active) {
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.1);
  }
}

/* ==============================================
   RESPONSIVE
   ============================================== */

@media (max-width: 768px) {
  .cs-jump-nav {
    /* Hide by default on mobile */
    display: none !important;
    bottom: 1rem;
    padding: 0.375rem;
    gap: 0.125rem;
    overflow-x: auto;
    max-width: calc(100vw - 1.5rem);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  /* Show when explicitly toggled */
  .cs-jump-nav.mobile-visible {
    display: flex !important;
  }

  .cs-jump-nav::-webkit-scrollbar {
    display: none;
  }

  .cs-jump-link {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
  }
}

/* Extra small screens */
@media (max-width: 480px) {
  .cs-jump-nav {
    bottom: 0.75rem;
    padding: 0.3rem;
    border-radius: 0.75rem;
  }

  .cs-jump-link {
    padding: 0.4rem 0.6rem;
    font-size: 0.6875rem;
  }
}

/* ==============================================
   SMOOTH SCROLL
   ============================================== */

html {
  scroll-behavior: smooth;
}

/* ==============================================
   REDUCED MOTION
   ============================================== */

@media (prefers-reduced-motion: reduce) {
  .cs-jump-nav {
    animation: none !important;
    opacity: 1 !important;
    transform: translateX(-50%) translateY(0) !important;
  }

  .cs-jump-link {
    transition: none !important;
  }

  .cs-jump-link.active {
    transition: none !important;
  }

  .cs-jump-link.active.clicked {
    animation: none !important;
  }

  .cs-jump-link:active {
    transform: none !important;
  }
}
