/* Main Navigation Container */
.main-nav {
  position: relative;
  z-index: 900; /* Reduced from 1000 for proper hierarchy */
}

.nav-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-6) var(--space-6) var(--space-4);
  max-width: 1200px;
  margin: 0 auto;
}

@media (max-width: 768px) {
  .nav-content {
    display: none; /* Hide main nav content on mobile - only show mobile elements */
  }
}

@media (min-width: 769px) {
  /* CRITICAL: Show desktop navigation */
  .nav-content {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
  }
  
  /* Ensure ALL mobile elements are hidden */
  .nav-toggle,
  .nav-auth-btn,
  .nav-overlay,
  .nav-drawer,
  .mobile-only {
    display: none !important;
  }
}

/* Floating Navigation */
.floating-nav {
  position: fixed;
  top: var(--space-6);
  right: var(--space-6);
  z-index: 500; /* Increased from 100 to avoid modal conflicts */
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

@media (max-width: 768px) {
  .floating-nav {
    top: var(--space-4);
    right: var(--space-4);
    gap: var(--space-2);
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}



.nav-link {
  color: var(--color-gray-warm);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.nav-link:hover {
  color: var(--color-charcoal);
}


/* Dashboard Top Navigation */
.dashboard-top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-6) var(--space-6) var(--space-4);
  max-width: 1200px;
  margin: 0 auto;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: var(--space-8);
}


.nav-right {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.dashboard-top-nav .nav-link {
  color: var(--color-gray-warm);
  text-decoration: none;
  font-weight: 500;
  font-size: var(--text-base);
  transition: color 0.2s ease;
  white-space: nowrap;
}

.dashboard-top-nav .nav-link:hover {
  color: var(--color-charcoal);
}

/* Dashboard link specific styles */
.dashboard-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  margin-right: var(--space-4);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dashboard-link:hover {
  background: rgba(168, 181, 160, 0.08);
  transform: translateY(-1px);
}

/* Left-aligned dashboard button */
.dashboard-link-left {
  margin-right: 0;
  margin-left: 0;
}

.nav-left .dashboard-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.nav-link-icon {
  font-size: var(--text-lg);
}

/* Profile Dropdown */
.profile-dropdown-container {
  position: relative;
}

.profile-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-linen);
  border: 1px solid var(--color-stone);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-charcoal);
  position: relative;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
}

.profile-trigger.loaded {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.profile-trigger::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: radial-gradient(circle, var(--color-sage) 0%, transparent 70%);
  opacity: 0;
  transform: translate(-50%, -50%);
  transition: all 0.4s ease;
}

.profile-trigger:hover {
  background: var(--color-cream);
  border-color: var(--color-sage);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.profile-trigger:hover::after {
  width: 100%;
  height: 100%;
  opacity: 0.1;
}

.profile-trigger:focus {
  outline: 2px solid var(--color-sage);
  outline-offset: 2px;
}

.profile-trigger:focus:not(:focus-visible) {
  outline: none;
}

.profile-name {
  font-weight: 500;
}

.dropdown-arrow {
  font-size: var(--text-xs);
  transition: transform 0.2s ease;
}

.profile-dropdown-container.active .dropdown-arrow {
  transform: rotate(180deg);
}

.profile-dropdown {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  min-width: 220px;
  background: rgba(255, 251, 245, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 251, 245, 0.2);
  border-radius: var(--radius-xl);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  padding: var(--space-2);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 910; /* Increased from 1000 for proper hierarchy */
}

.profile-dropdown-container.active .profile-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  animation: fadeInUp 0.3s ease-out;
}

/* fadeInUp animation removed - now using shared keyframe from animations.css */

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: none;
  border: none;
  border-radius: var(--radius-md);
  color: var(--color-charcoal);
  text-decoration: none;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  position: relative;
  overflow: hidden;
}

.dropdown-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--color-cream);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  z-index: -1;
}

.dropdown-item:hover {
  color: var(--color-charcoal);
  transform: translateX(4px);
}

.dropdown-item:hover::before {
  transform: translateX(0);
}

.dropdown-item:focus {
  outline: 2px solid var(--color-sage);
  outline-offset: -2px;
}

.dropdown-item:focus:not(:focus-visible) {
  outline: none;
}

.dropdown-item.active {
  background: var(--color-cream);
  font-weight: 500;
}

.dropdown-icon {
  font-size: var(--text-base);
  width: 20px;
  text-align: center;
}

.dropdown-divider {
  height: 1px;
  background: var(--color-stone);
  margin: var(--space-2) 0;
}

.dropdown-logout {
  color: var(--color-rose);
}

.dropdown-logout:hover {
  background: rgba(224, 153, 147, 0.1);
}



/* Mobile Hamburger Menu Button */
.nav-toggle {
  display: none;
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 1100;
  background: rgba(253, 251, 247, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(58, 54, 50, 0.15);
  border-radius: var(--radius-full);
  width: 48px;
  height: 48px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  /* Force proper rendering of glassmorphism on Safari/WebKit */
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  will-change: backdrop-filter, transform;
}

.nav-toggle:hover {
  background: rgba(168, 181, 160, 0.15);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.nav-toggle:focus {
  outline: 2px solid var(--color-sage);
  outline-offset: 2px;
}

.nav-toggle:focus:not(:focus-visible) {
  outline: none;
}

.hamburger-line {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--color-charcoal);
  transition: all 0.3s ease;
  border-radius: 2px;
}

.nav-toggle.active .hamburger-line:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.nav-toggle.active .hamburger-line:nth-child(2) {
  opacity: 0;
}

.nav-toggle.active .hamburger-line:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -6px);
}

/* Mobile Navigation Overlay */
.nav-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1050;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

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

/* Mobile Navigation Drawer */
.nav-drawer {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  width: 300px;
  max-width: 80vw;
  height: 100vh;
  background: rgba(255, 251, 245, 0.95);
  backdrop-filter: blur(12px);
  border-left: 1px solid rgba(255, 251, 245, 0.2);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.1);
  z-index: 1060;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
}

.nav-drawer.active {
  transform: translateX(0);
}

/* Mobile Navigation Header */
.nav-drawer-header {
  display: flex;
  justify-content: flex-end;
  padding: var(--space-4);
}

.nav-drawer-close {
  background: none;
  border: none;
  font-size: var(--text-2xl);
  color: var(--color-charcoal);
  cursor: pointer;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.nav-drawer-close:hover {
  background: rgba(168, 181, 160, 0.1);
  transform: scale(1.1);
}

/* Mobile Navigation Content */
.nav-drawer-content {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.nav-drawer-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}


.nav-drawer-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: none;
  border: none;
  border-radius: var(--radius-md);
  color: var(--color-charcoal);
  text-decoration: none;
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  width: 100%;
  text-align: left;
  position: relative;
  overflow: hidden;
  min-height: 48px;
}

.nav-drawer-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--color-cream);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  z-index: -1;
}

.nav-drawer-item:hover {
  color: var(--color-charcoal);
  transform: translateX(4px);
}

.nav-drawer-item:hover::before {
  transform: translateX(0);
}

.nav-drawer-item:focus {
  outline: 2px solid var(--color-sage);
  outline-offset: 2px;
  background: rgba(168, 181, 160, 0.05);
}

.nav-drawer-item:focus:not(:focus-visible) {
  outline: none;
}

.nav-drawer-item.active {
  background: var(--color-cream);
  font-weight: 600;
  border-left: 3px solid var(--color-sage);
}

/* Mobile Primary Navigation */
.mobile-primary-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}


/* Mobile Bottom Navigation */
.mobile-bottom-nav {
  margin-top: var(--space-2);
}

.nav-drawer-divider {
  height: 1px;
  background: var(--color-stone);
  margin: var(--space-2) var(--space-4);
}

.nav-drawer-logout {
  color: var(--color-rose);
}

.nav-drawer-logout:hover {
  background: rgba(224, 153, 147, 0.1);
}

.nav-drawer-logout:hover::before {
  background: rgba(224, 153, 147, 0.1);
}

/* Mobile Sign In Top Button (Replaces burger for non-authenticated) */
.nav-auth-btn {
  display: none;
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 1100;
  background: linear-gradient(135deg, var(--color-sage) 0%, #98a890 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-xl);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(168, 181, 160, 0.3);
  color: white;
  font-weight: 600;
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
}

.nav-auth-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(168, 181, 160, 0.4);
  background: linear-gradient(135deg, #98a890 0%, var(--color-sage) 100%);
}

.nav-auth-btn:active {
  transform: translateY(0);
}

.sign-in-icon {
  font-size: var(--text-base);
}

.sign-in-text {
  font-size: var(--text-sm);
  font-weight: 600;
}

/* Mobile-only elements hidden by default */
.mobile-only {
  display: none;
}

@media (max-width: 768px) {
  /* Show mobile menu elements with correct display values */
  .nav-toggle,
  .nav-auth-btn {
    display: flex !important;
  }
  
  .nav-overlay,
  .nav-drawer {
    display: block !important;
  }
  
  .mobile-only {
    display: flex !important;
  }
  
  /* Hide desktop navigation on mobile */
  .dashboard-top-nav .nav-left,
  .dashboard-top-nav .nav-right {
    display: none;
  }
  
  /* Hide home page specific navigation elements on mobile */
  .floating-nav {
    display: none !important;
  }
  
  .dashboard-top-nav {
    padding: var(--space-4);
    justify-content: flex-end;
    position: relative;
  }
  
  /* Prevent body scroll when mobile menu is open */
  body.mobile-menu-open {
    overflow: hidden;
  }
  
}

.story-floating-nav {
  position: absolute;
  bottom: var(--space-8);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: var(--space-6);
  background: rgba(26, 26, 26, 0.9);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-2xl);
  padding: var(--space-4) var(--space-6);
  z-index: 1001;
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  transition: all 0.4s ease;
}

.story-floating-nav.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(100%);
}

.story-nav-btn {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-full);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
}

.story-nav-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.story-nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.library-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-6) var(--space-8);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(58, 54, 50, 0.08);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-body);
}

.breadcrumb-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-gray-warm);
  text-decoration: none;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.breadcrumb-link:hover {
  background: rgba(168, 181, 160, 0.1);
  color: var(--color-charcoal);
  transform: translateX(-2px);
}

.breadcrumb-icon {
  font-size: var(--text-lg);
}

.breadcrumb-separator {
  color: var(--color-gray-soft);
  font-weight: 300;
}

.breadcrumb-current {
  color: var(--color-charcoal);
  font-weight: 500;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.story-return-nav {
  position: fixed;
  bottom: 100px;
  left: var(--space-6);
  z-index: 920; /* Increased from 1000 for proper hierarchy */
  opacity: 0.9;
  transition: all 0.3s ease;
}

/* Mobile touch target optimization for navigation */
@media (max-width: 768px) {
  .dropdown-item {
    min-height: 44px;
    padding: var(--space-3) var(--space-4);
  }
  
  .nav-drawer-item {
    min-height: 44px;
    padding: var(--space-3) var(--space-4);
  }
  
  .profile-trigger {
    min-height: 44px;
    padding: var(--space-3) var(--space-4);
  }
  
  .breadcrumb-link {
    min-height: 44px;
    padding: var(--space-3) var(--space-4);
  }
  
  .nav-link {
    min-height: 44px;
    padding: var(--space-3) var(--space-4);
    display: inline-flex;
    align-items: center;
  }
}
