/* Simple Mobile Navigation - Clean implementation */

/* Desktop - hide mobile elements and override Webflow's collapse behavior */
@media screen and (min-width: 768px) {
  .mobile-nav-toggle {
    display: none !important;
  }
  
  .mobile-nav-menu {
    display: none !important;
  }
  
  /* Make the navbar container a flexbox with proper layout */
  .navbar5_container {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    position: relative !important;
  }
  
  /* Logo stays on the left */
  .navbar5_logo-link {
    flex-shrink: 0 !important;
  }
  
  /* Style nav links with proper padding */
  .navbar5_link {
    padding: 0.5rem 1rem !important;
    border-radius: 8px !important;
    transition: all 0.2s ease !important;
  }
  
  /* Hover state */
  .navbar5_link:hover {
    background-color: white !important;
  }
  
  /* Active/current state */
  .navbar5_link.w--current {
    background-color: #f4f4f4 !important;
    color: #353535 !important;
    font-weight: 600 !important;
  }
  
  /* Override Webflow's data-collapse="medium" behavior */
  .w-nav[data-collapse='medium'] .navbar5_menu,
  .w-nav[data-collapse='medium'] .w-nav-menu {
    display: flex !important;
    position: static !important;
    transform: none !important;
    background-color: transparent !important;
    height: auto !important;
    border: none !important;
    padding: 0 !important;
    overflow: visible !important;
    flex: 1 !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin: 0 !important;
  }
  
  /* Center the nav links */
  .navbar5_menu-left {
    position: absolute !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    display: flex !important;
    gap: 2rem !important;
  }
  
  /* Keep search on the right */
  .navbar5_menu-right {
    margin-left: auto !important;
  }
  
  .w-nav[data-collapse='medium'] .navbar5_menu-button,
  .w-nav[data-collapse='medium'] .w-nav-button {
    display: none !important;
  }
}

/* Mobile Navigation */
@media screen and (max-width: 767px) {
  /* Hide desktop menu completely */
  .navbar5_menu {
    display: none !important;
  }
  
  .navbar5_menu-button {
    display: none !important;
  }
  
  /* Mobile nav toggle button */
  .mobile-nav-toggle {
    display: block;
    position: relative;
    width: 30px;
    height: 24px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
  }
  
  .mobile-nav-toggle span {
    display: block;
    position: absolute;
    height: 2px;
    width: 100%;
    background-color: #fff;
    left: 0;
    transition: all 0.3s ease;
  }
  
  .mobile-nav-toggle span:nth-child(1) {
    top: 0;
  }
  
  .mobile-nav-toggle span:nth-child(2) {
    top: 11px;
  }
  
  .mobile-nav-toggle span:nth-child(3) {
    bottom: 0;
  }
  
  /* Toggle animation to X */
  .mobile-nav-toggle.active span:nth-child(1) {
    transform: rotate(45deg);
    top: 11px;
  }
  
  .mobile-nav-toggle.active span:nth-child(2) {
    opacity: 0;
  }
  
  .mobile-nav-toggle.active span:nth-child(3) {
    transform: rotate(-45deg);
    bottom: 11px;
  }
  
  /* Mobile menu */
  .mobile-nav-menu {
    display: none;
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #555b6e;
    padding: 2rem;
    z-index: 999;
    overflow-y: auto;
  }
  
  .mobile-nav-menu.active {
    display: block;
  }
  
  .mobile-nav-links {
    list-style: none;
    padding: 0;
    margin: 0;
  }
  
  .mobile-nav-link {
    display: block;
    padding: 1rem;
    margin-bottom: 0.5rem;
    color: #fff;
    text-decoration: none;
    font-size: 1.125rem;
    font-weight: 600;
    border-radius: 8px;
    transition: background-color 0.2s ease;
  }
  
  .mobile-nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
  }
  
  .mobile-nav-link.active {
    background-color: #f4f4f4;
    color: #353535;
  }
  
  /* Fixed navbar on mobile */
  .navbar5_component {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: #555b6e;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  }
  
  /* Add padding to page content to account for fixed navbar */
  .page-wrapper {
    padding-top: 60px;
  }
  
  /* For series.html which doesn't have page-wrapper - add padding directly to hero */
  body > #navigation-container + .top-section-hero {
    padding-top: 60px;
  }
  
  /* Ensure main-wrapper doesn't add extra spacing */
  .main-wrapper {
    padding-top: 0;
  }
  
  /* Prevent body scroll when menu is open */
  body.mobile-menu-open {
    overflow: hidden;
  }
  
  /* Mobile search container */
  .mobile-search-container {
    padding: 0 0 1.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  .mobile-search-form {
    display: flex;
    gap: 0.5rem;
  }

  .mobile-search-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1rem;
    transition: all 0.3s ease;
  }

  .mobile-search-input::-webkit-input-placeholder {
    color: rgba(255, 255, 255, 0.5);
  }

  .mobile-search-input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.15);
  }

  .mobile-search-button {
    padding: 0.75rem 1.5rem;
    background: #CE6134;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease;
  }

  .mobile-search-button:hover {
    background: #B04F28;
  }

  .mobile-search-results {
    margin-top: 1rem;
    max-height: 300px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    color: #333;
  }

  .mobile-search-results a {
    display: block;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: #333;
    border-bottom: 1px solid #eee;
    transition: background 0.2s ease;
  }

  .mobile-search-results a:hover {
    background: #f5f5f5;
  }

  .mobile-search-results a:last-child {
    border-bottom: none;
  }
  
  /* Logo size on mobile */
  .navbar5_logo-link img {
    max-height: 35px;
    width: auto;
  }
  
  /* Container padding on mobile */
  .navbar5_container {
    padding: 0.75rem 1rem;
  }
}

/* Small mobile adjustments */
@media screen and (max-width: 479px) {
  .mobile-nav-menu {
    padding: 1.5rem;
  }
  
  .mobile-nav-link {
    font-size: 1rem;
    padding: 0.875rem;
  }
}

/* Handle medium screens where nav might collide with search */
@media screen and (min-width: 768px) and (max-width: 1200px) {
  /* Reduce gap between nav items */
  .navbar5_menu-left {
    gap: 1rem !important;
  }
  
  /* Smaller font size for nav links with padding for hover */
  .navbar5_link {
    font-size: 0.95rem !important;
    padding: 0.5rem 1rem !important;
    border-radius: 8px !important;
    transition: all 0.2s ease !important;
  }
  
  /* Hover state with background */
  .navbar5_link:hover {
    background-color: white !important;
  }
  
  /* Active/current state */
  .navbar5_link.w--current {
    background-color: #f4f4f4 !important;
    color: #353535 !important;
  }
  
  /* Make navbar search more compact */
  .navbar5_menu-right .search-input,
  #nav-search {
    /* max-width removed to allow natural sizing */
  }
}

/* Handle screens where nav needs different layout */
@media screen and (min-width: 768px) and (max-width: 1100px) {
  /* Professional two-row layout */
  .navbar5_container {
    flex-wrap: wrap !important;
    padding: 0.5rem 1rem !important;
  }
  
  /* First row: logo and search */
  .navbar5_logo-link {
    order: 1 !important;
  }
  
  /* Keep search functional but more compact */
  .navbar5_menu-right {
    order: 2 !important;
    margin-left: auto !important;
  }
  
  .navbar5_menu-right .search-input,
  #nav-search {
    /* max-width removed to allow natural sizing */
    padding: 0.5rem 0.75rem !important;
    font-size: 0.9rem !important;
  }
  
  .search-button {
    padding: 0.5rem 1rem !important;
    font-size: 0.9rem !important;
  }
  
  /* Second row: centered navigation */
  .navbar5_menu {
    order: 3 !important;
    width: 100% !important;
    justify-content: center !important;
    margin-top: 0.5rem !important;
    padding-top: 0.5rem !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
  }
  
  /* Remove absolute positioning from nav */
  .navbar5_menu-left {
    position: static !important;
    transform: none !important;
    left: auto !important;
    gap: 1.5rem !important;
  }
  
  /* Slightly smaller nav links */
  .navbar5_link {
    font-size: 0.95rem !important;
    padding: 0.4rem 1rem !important;
  }
}

/* Ensure navbar search doesn't get too small at 991px and below */
@media screen and (max-width: 991px) {
  .navbar5_menu-right .search-input,
  #nav-search {
    width: auto !important;
    min-width: 200px !important;
  }
  
  /* Ensure hero/main search input is not constrained */
  #search-input-main {
    width: 100% !important;
    max-width: 100% !important;
    min-width: auto !important;
  }
}

/* Override problematic Webflow styles at 991px breakpoint */
@media screen and (min-width: 768px) and (max-width: 991px) {
  .navbar5_menu.w-nav-menu,
  .w-nav[data-collapse='medium'] .navbar5_menu {
    display: flex !important;
    position: static !important;
    background-color: transparent !important;
    height: auto !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    -webkit-text-fill-color: inherit !important;
    background-clip: border-box !important;
    transition: none !important;
    flex: 1 !important;
    justify-content: space-between !important;
    align-items: center !important;
  }
  
  /* Ensure the menu is visible */
  .w-nav[data-collapse='medium'] .w-nav-menu {
    display: flex !important;
  }
}

/* Smooth transitions */
* {
  -webkit-tap-highlight-color: transparent;
}

.mobile-nav-toggle span,
.mobile-nav-link {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}