/* Navigation System for TestAutism.ro */

/* Scroll margin to prevent sticky header from obscuring anchored sections */
[id] {
  scroll-margin-top: 70px;
}

/* Primary Navigation Bar - FLUID EDGE-TO-EDGE LAYOUT */
.primary-nav {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: var(--color-white);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
  /* Fluid padding: 12px at 320px viewport, 24px at 1400px+ */
  padding: clamp(0.75rem, 0.5rem + 1vw, 1.5rem) clamp(1rem, 0.5rem + 2vw, 2rem);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: clamp(0.5rem, 1vw, 1rem);
}

.primary-nav.scrolled {
  box-shadow: var(--shadow-md);
}

/* Logo Section */
.nav-logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  gap: clamp(0.5rem, 1vw, 0.75rem);
  /* Ensure logo is tappable */
  min-height: 44px;
  padding: 0.25rem 0;
}

.nav-logo-icon {
  /* Fluid icon size: 36px at mobile, 40px at desktop */
  width: clamp(36px, 8vw, 40px);
  height: clamp(36px, 8vw, 40px);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-raads-primary), var(--color-catq-primary));
  color: var(--color-white);
  font-weight: var(--font-weight-bold);
  flex-shrink: 0;
}

.nav-logo-text {
  /* Fluid text size: 1.125rem at mobile, 1.25rem at desktop */
  font-size: clamp(1.125rem, 2vw, 1.25rem);
  font-weight: var(--font-weight-semibold);
  color: var(--heading-color);
  white-space: nowrap;
}

/* Navigation Menu */
.nav-menu {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  /* Fluid gap: 4px at mobile, 8px at desktop */
  gap: clamp(0.25rem, 0.5vw, 0.5rem);
  align-items: center;
}

.nav-item {
  position: relative;
}

.nav-link {
  display: flex;
  align-items: center;
  /* Fluid padding for better scaling */
  padding: clamp(0.5rem, 0.4rem + 0.5vw, 0.75rem) clamp(0.75rem, 0.5rem + 0.8vw, 1rem);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  gap: clamp(0.375rem, 0.5vw, 0.5rem);
  /* Minimum touch target on mobile */
  min-height: 44px;
}

.nav-link:hover {
  background: var(--color-gray-100);
  color: var(--text-primary);
  text-decoration: none;
}

.nav-link i {
  font-size: var(--font-size-lg);
  width: 24px;
  text-align: center;
}

/* SLEEK TEST NAVIGATION BUTTONS */
.nav-test-link {
  position: relative;
  background: var(--color-gray-50);
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  padding: clamp(0.625rem, 0.5rem + 0.5vw, 0.875rem) clamp(0.875rem, 0.6rem + 0.8vw, 1.25rem);
  font-weight: var(--font-weight-semibold);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.nav-test-link::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.6s ease;
}

.nav-test-link:hover::before {
  left: 100%;
}

.nav-test-link:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.nav-test-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

/* RAADS-R Test Button */
.nav-test-link.raads-link,
.nav-link.raads-link {
  background: linear-gradient(135deg, #2196F3, #1976D2) !important;
  color: white !important;
  border-color: #2196F3;
}

.nav-test-link.raads-link:hover,
.nav-link.raads-link:hover {
  background: linear-gradient(135deg, #1976D2, #2196F3) !important;
  color: white !important;
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.3);
}

/* RAADS-R ACTIVE STATE - Enhanced with modern UI/UX */
.nav-test-link.raads-active,
.nav-link.raads-active {
  background: linear-gradient(135deg, #2196F3, #1976D2) !important;
  color: white !important;
  border-color: #2196F3 !important;
  box-shadow: 0 0 0 4px rgba(33, 150, 243, 0.25),
              0 4px 12px rgba(33, 150, 243, 0.4),
              inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
  transform: translateY(-2px) scale(1.02) !important;
  font-weight: 600 !important;
  position: relative;
  animation: pulse-raads 2s ease-in-out infinite;
}

.nav-test-link.raads-active::after,
.nav-link.raads-active::after {
  content: '✓';
  position: absolute;
  top: -8px;
  right: -8px;
  width: 26px;
  height: 26px;
  background: linear-gradient(135deg, #4CAF50, #388E3C);
  border: 3px solid white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 900;
  color: white;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3),
              0 0 0 2px rgba(76, 175, 80, 0.2);
  animation: checkmark-appear 0.3s ease-out;
  z-index: 2;
}

@keyframes pulse-raads {
  0%, 100% {
    box-shadow: 0 0 0 4px rgba(33, 150, 243, 0.25),
                0 4px 12px rgba(33, 150, 243, 0.4),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(33, 150, 243, 0.4),
                0 4px 16px rgba(33, 150, 243, 0.5),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
  }
}

@keyframes checkmark-appear {
  0% {
    transform: scale(0) rotate(-45deg);
    opacity: 0;
  }
  50% {
    transform: scale(1.1) rotate(5deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

/* CAT-Q Test Button */
.nav-test-link.catq-link,
.nav-link.catq-link {
  background: linear-gradient(135deg, #9C27B0, #7B1FA2) !important;
  color: white !important;
  border-color: #9C27B0;
}

.nav-test-link.catq-link:hover,
.nav-link.catq-link:hover {
  background: linear-gradient(135deg, #7B1FA2, #9C27B0) !important;
  color: white !important;
  box-shadow: 0 0 0 3px rgba(156, 39, 176, 0.3);
}

/* CAT-Q ACTIVE STATE - Enhanced with modern UI/UX */
.nav-test-link.catq-active,
.nav-link.catq-active {
  background: linear-gradient(135deg, #9C27B0, #7B1FA2) !important;
  color: white !important;
  border-color: #9C27B0 !important;
  box-shadow: 0 0 0 4px rgba(156, 39, 176, 0.25),
              0 4px 12px rgba(156, 39, 176, 0.4),
              inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
  transform: translateY(-2px) scale(1.02) !important;
  font-weight: 600 !important;
  position: relative;
  animation: pulse-catq 2s ease-in-out infinite;
}

.nav-test-link.catq-active::after,
.nav-link.catq-active::after {
  content: '✓';
  position: absolute;
  top: -8px;
  right: -8px;
  width: 26px;
  height: 26px;
  background: linear-gradient(135deg, #4CAF50, #388E3C);
  border: 3px solid white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 900;
  color: white;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3),
              0 0 0 2px rgba(76, 175, 80, 0.2);
  animation: checkmark-appear 0.3s ease-out;
  z-index: 2;
}

@keyframes pulse-catq {
  0%, 100% {
    box-shadow: 0 0 0 4px rgba(156, 39, 176, 0.25),
                0 4px 12px rgba(156, 39, 176, 0.4),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(156, 39, 176, 0.4),
                0 4px 16px rgba(156, 39, 176, 0.5),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
  }
}

/* Monotropism Test Button */
.nav-test-link.monotropism-link,
.nav-link.monotropism-link {
  background: linear-gradient(135deg, #FF9800, #F57C00) !important;
  color: white !important;
  border-color: #FF9800;
}

.nav-test-link.monotropism-link:hover,
.nav-link.monotropism-link:hover {
  background: linear-gradient(135deg, #F57C00, #FF9800) !important;
  color: white !important;
  box-shadow: 0 0 0 3px rgba(255, 152, 0, 0.3);
}

/* MONOTROPISM ACTIVE STATE - Enhanced with modern UI/UX */
.nav-test-link.monotropism-active,
.nav-link.monotropism-active {
  background: linear-gradient(135deg, #FF9800, #F57C00) !important;
  color: white !important;
  border-color: #FF9800 !important;
  box-shadow: 0 0 0 4px rgba(255, 152, 0, 0.25),
              0 4px 12px rgba(255, 152, 0, 0.4),
              inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
  transform: translateY(-2px) scale(1.02) !important;
  font-weight: 600 !important;
  position: relative;
  animation: pulse-monotropism 2s ease-in-out infinite;
}

.nav-test-link.monotropism-active::after,
.nav-link.monotropism-active::after {
  content: '✓';
  position: absolute;
  top: -8px;
  right: -8px;
  width: 26px;
  height: 26px;
  background: linear-gradient(135deg, #4CAF50, #388E3C);
  border: 3px solid white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 900;
  color: white;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3),
              0 0 0 2px rgba(76, 175, 80, 0.2);
  animation: checkmark-appear 0.3s ease-out;
  z-index: 2;
}

@keyframes pulse-monotropism {
  0%, 100% {
    box-shadow: 0 0 0 4px rgba(255, 152, 0, 0.25),
                0 4px 12px rgba(255, 152, 0, 0.4),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(255, 152, 0, 0.4),
                0 4px 16px rgba(255, 152, 0, 0.5),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
  }
}

/* EDA-QA Test Button */
.nav-test-link.edaqa-link,
.nav-link.edaqa-link {
  background: linear-gradient(135deg, #00897B, #00695C) !important;
  color: white !important;
  border-color: #00897B;
}

.nav-test-link.edaqa-link:hover,
.nav-link.edaqa-link:hover {
  background: linear-gradient(135deg, #00695C, #00897B) !important;
  color: white !important;
  box-shadow: 0 0 0 3px rgba(0, 137, 123, 0.3);
}

/* EDA-QA ACTIVE STATE - Enhanced with modern UI/UX */
.nav-test-link.edaqa-active,
.nav-link.edaqa-active {
  background: linear-gradient(135deg, #00897B, #00695C) !important;
  color: white !important;
  border-color: #00897B !important;
  box-shadow: 0 0 0 4px rgba(0, 137, 123, 0.25),
              0 4px 12px rgba(0, 137, 123, 0.4),
              inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
  transform: translateY(-2px) scale(1.02) !important;
  font-weight: 600 !important;
  position: relative;
  animation: pulse-edaqa 2s ease-in-out infinite;
}

.nav-test-link.edaqa-active::after,
.nav-link.edaqa-active::after {
  content: '✓';
  position: absolute;
  top: -8px;
  right: -8px;
  width: 26px;
  height: 26px;
  background: linear-gradient(135deg, #4CAF50, #388E3C);
  border: 3px solid white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  color: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15),
              0 0 0 2px rgba(76, 175, 80, 0.2);
  animation: checkmark-appear 0.3s ease-out;
  z-index: 2;
}

@keyframes pulse-edaqa {
  0%, 100% {
    box-shadow: 0 0 0 4px rgba(0, 137, 123, 0.25),
                0 4px 12px rgba(0, 137, 123, 0.4),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(0, 137, 123, 0.4),
                0 4px 16px rgba(0, 137, 123, 0.5),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
  }
}

/* Active state override */
.nav-link.active {
  /* Remove generic active styles - handled by specific test classes */
}

/* Removed dropdown menu - tests now in main nav */

/* Mobile Menu Toggle */
.nav-toggle {
  display: none;
  background: transparent;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  /* Ensure 48x48px touch target minimum */
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 1.75rem;
  position: relative;
  transition: all var(--transition-fast);
}

.nav-toggle:hover {
  background: var(--color-gray-100);
  color: var(--color-raads-primary);
}

.nav-toggle:focus-visible {
  outline: 3px solid var(--color-raads-primary);
  outline-offset: 2px;
  background: var(--color-gray-50);
}

.nav-toggle:active {
  transform: scale(0.95);
}

/* Hamburger icon animation */
.nav-toggle i {
  display: block;
  transition: all var(--transition-base);
}

/* Transform to X when menu is open */
.nav-toggle[aria-expanded="true"] i.fa-bars::before {
  content: "\f00d"; /* FontAwesome X icon */
}

/* Section Navigator */
.section-nav {
  position: fixed;
  right: var(--space-lg);
  top: 50%;
  transform: translateY(-50%);
  z-index: var(--z-fixed);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.section-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-sm);
}

.section-nav-label {
  background: var(--color-gray-900);
  color: var(--color-white);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.section-nav-item:hover .section-nav-label,
.section-nav-item:focus-within .section-nav-label {
  opacity: 1;
  visibility: visible;
}

.section-nav-dot {
  width: 14px;
  height: 14px;
  border-radius: var(--radius-full);
  background: var(--color-gray-300);
  border: 2px solid var(--color-white);
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.section-nav-dot:hover {
  transform: scale(1.2);
  background: var(--color-gray-500);
}

.section-nav-item.active .section-nav-dot {
  width: 18px;
  height: 18px;
  background: var(--color-raads-primary);
  border-color: var(--color-raads-primary);
}

.section-nav-item.active.catq-page .section-nav-dot {
  background: var(--color-catq-primary);
  border-color: var(--color-catq-primary);
}

/* Mobile Navigation */
@media (max-width: 991px) {
  .nav-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .nav-menu {
    position: fixed;
    top: 0;
    left: -100%;
    /* Fluid width: 85% on small screens, max 360px */
    width: clamp(280px, 85vw, 360px);
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile browsers */
    background: var(--color-white);
    flex-direction: column;
    align-items: stretch;
    /* Generous padding for touch targets */
    padding: clamp(1.5rem, 4vh, 2.5rem) clamp(1rem, 4vw, 1.5rem);
    padding-top: 0; /* Remove top padding to accommodate header */
    /* Increased spacing between items */
    gap: 0.25rem;
    box-shadow: var(--shadow-2xl);
    transition: left var(--transition-slow);
    overflow-y: auto;
    /* Smooth scrolling on iOS */
    -webkit-overflow-scrolling: touch;
  }

  .nav-menu.open {
    left: 0;
  }

  /* Mobile menu header */
  .nav-menu::before {
    content: '';
    display: block;
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    /* Add safe area for notched devices */
    height: calc(60px + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
    background: linear-gradient(135deg, var(--color-raads-primary), var(--color-catq-primary));
    margin: 0 calc(-1 * clamp(1rem, 4vw, 1.5rem));
    margin-bottom: clamp(1rem, 3vh, 1.5rem);
    z-index: 1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }

  /* Add visual separator between nav items */
  .nav-item {
    border-bottom: 1px solid var(--color-gray-100);
    padding: 0.25rem 0;
  }

  .nav-item:last-child {
    border-bottom: none;
  }

  .nav-link {
    /* Larger text and touch targets on mobile */
    font-size: clamp(1rem, 4vw, 1.125rem);
    padding: clamp(0.875rem, 3vw, 1rem) clamp(0.875rem, 3vw, 1rem);
    /* Ensure proper touch target size */
    min-height: 48px;
    border-radius: var(--radius-lg);
    font-weight: var(--font-weight-semibold);
  }

  .nav-link:active {
    transform: scale(0.98);
    background: var(--color-gray-200);
  }

  .nav-link i {
    font-size: 1.25rem;
    width: 28px;
  }

  /* Mobile test navigation styling */
  .nav-test-link {
    /* Enhanced mobile styling for test buttons */
    border-radius: var(--radius-xl);
    padding: clamp(1rem, 4vw, 1.25rem);
    margin-bottom: 0.5rem;
    min-height: 60px;
    font-weight: var(--font-weight-bold);
    font-size: clamp(1rem, 4vw, 1.125rem);
    box-shadow: var(--shadow-md);
  }

  .nav-test-link:active {
    transform: scale(0.98) translateY(0);
  }

  .nav-test-icon {
    width: 24px;
    height: 24px;
    font-size: 1.25rem;
  }

  /* Section Navigator on Mobile */
  .section-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    transform: none;
    background: var(--color-white);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
    flex-direction: row;
    justify-content: center;
    padding: var(--space-sm) var(--space-md);
    gap: var(--space-lg);
  }

  .section-nav-item {
    flex-direction: column;
    gap: var(--space-xs);
  }

  .section-nav-label {
    position: static;
    opacity: 1;
    visibility: visible;
    background: transparent;
    color: var(--text-muted);
    padding: 0;
    font-size: 0.7rem;
    text-align: center;
    white-space: normal;
  }

  .section-nav-item.active .section-nav-label {
    color: var(--color-raads-primary);
  }
}

/* Overlay for mobile menu */
.nav-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-slow);
  z-index: calc(var(--z-sticky) - 1);
}

.nav-overlay.show {
  opacity: 1;
  visibility: visible;
}

/* Accessibility */
/* Accessibility: Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
  .nav-menu,
  .nav-dropdown-menu,
  .section-nav-label {
    transition: none;
  }

  /* Disable all active state animations for users who prefer reduced motion */
  .nav-test-link.raads-active,
  .nav-link.raads-active,
  .nav-test-link.catq-active,
  .nav-link.catq-active,
  .nav-test-link.monotropism-active,
  .nav-link.monotropism-active,
  .nav-test-link.edaqa-active,
  .nav-link.edaqa-active {
    animation: none !important;
  }

  .nav-test-link.raads-active::after,
  .nav-link.raads-active::after,
  .nav-test-link.catq-active::after,
  .nav-link.catq-active::after,
  .nav-test-link.monotropism-active::after,
  .nav-link.monotropism-active::after,
  .nav-test-link.edaqa-active::after,
  .nav-link.edaqa-active::after {
    animation: none !important;
  }
}

/* Back to Top Button */
.back-to-top {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-lg);
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--color-raads-primary);
  color: var(--color-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xl);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all var(--transition-base);
  border: none;
  z-index: var(--z-fixed);
}

.back-to-top.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  background: var(--color-raads-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-xl);
}

/* Hide on desktop - covered by accessibility widget button */
@media (min-width: 992px) {
  .back-to-top {
    display: none !important;
  }
}

@media (max-width: 991px) {
  .back-to-top {
    bottom: calc(var(--space-4xl) + 60px); /* Account for mobile section nav */
  }
}

/* Progress indicator for test pages */
.nav-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--color-raads-primary), var(--color-catq-primary));
  transition: width var(--transition-slow);
  border-radius: var(--radius-sm);
}

/* High-contrast mode */
@media (prefers-contrast: high) {
  .primary-nav {
    border-bottom: 2px solid #000;
    background: #fff;
  }

  .nav-link {
    color: #000 !important;
    border: 1px solid transparent;
  }

  .nav-link:hover,
  .nav-link:focus-visible {
    border-color: #000;
  }

  .nav-link.active,
  .nav-link[aria-current="page"] {
    border: 2px solid #000;
    font-weight: 700;
  }

  .nav-test-link {
    border: 2px solid #000 !important;
  }

  .section-nav-item a {
    border: 1px solid #000;
  }

  .section-nav-item.active a {
    background: #000;
    color: #fff;
  }

  .back-to-top {
    border: 2px solid #000;
    background: #fff;
    color: #000;
  }

  .nav-toggle {
    border: 2px solid #000;
  }
}

/* Print styles - hide navigation elements */
@media print {
  .primary-nav,
  .section-nav,
  .back-to-top,
  .nav-overlay,
  .nav-progress {
    display: none !important;
  }
}