body.custom-mobile-menu-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  transition: filter 0.3s ease-out;
}
body:not(.custom-mobile-menu-open) {
  filter: none;
}

.custom-menu-overlay {
  position: fixed;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease-in-out, visibility 0.4s ease-in-out;
}

#custom-mobile-menu.custom-active + .custom-menu-overlay {
  opacity: 1;
  visibility: visible;
}

#custom-mobile-menu {
  position: fixed;
  left: 0;
  height: 100vh; 
  width: 85%;
  max-width: 350px;
  background: #ffffff;
  transform: translateX(-100%);
  transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55);
  z-index: 9999;
  overflow-y: auto;
  padding: 2rem 1.5rem 5rem 1.5rem; 
  
  border-radius: 0 8px 8px 0;
  display: flex;
  flex-direction: column;
}

#custom-mobile-menu.custom-active {
  transform: translateX(0);
}

#custom-mobile-toggle {
  position: absolute;
  top:0;
  left:0;
  font-size: 2.5rem;
  background: none;
  border: none;
  cursor: pointer;
  z-index: 10000;
  color: #fff;
  padding: 0.75rem;
  transition: color 0.3s ease;
  outline: none; /* Remove default outline on focus */
}

#custom-mobile-toggle:hover,
#custom-mobile-toggle:focus {
  color: #007bff;
}

.custom-menu-list,
.custom-submenu {
  list-style: none;
  margin: 0;
  padding: 0;
}

.custom-menu-list {
  flex-grow: 1;
  /* padding-top: 1rem; */
  padding-bottom: 2rem;
}

.custom-menu-item {
  margin-bottom: 0;
}

.custom-menu-link {
  display: block;
  text-decoration: none;
  color: #333;
  font-weight: 500;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  line-height: 1.5;
  padding: 0;
  transition: background-color 0.25s ease, color 0.25s ease, transform 0.25s ease;
  position: relative;
  overflow: hidden;
  outline: none; /* Ensure no outline on focus for links */
}

.custom-menu-link-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0.9rem 0;
}

.custom-menu-link.custom-menu-parent-toggle {
  cursor: pointer;
  outline: none !important;
}

.custom-menu-link.custom-menu-parent-toggle:hover,
.custom-menu-link.custom-menu-parent-toggle:focus {
  background-color: #f0f0f0; 
  color: #000;
  outline: none !important;
}

.custom-menu-link:not(.custom-menu-parent-toggle):hover,
.custom-menu-link:not(.custom-menu-parent-toggle):focus {
  background-color: #f0f0f0; 
  color: #000; 
  outline: none !important;
}


.custom-submenu-arrow {
  margin-left: 15px;
  transition: transform 0.3s ease, color 0.3s ease;
  display: inline-block;
  font-size: 0.9em;
  color: #999;
  min-width: 1rem;
  text-align: center;
}

.custom-menu-item.is-submenu-open > .custom-menu-link > .custom-menu-link-wrapper > .custom-submenu-arrow {
  transform: rotate(180deg);
  color: black;
}

/* Smaller font size for child items */
.custom-submenu .custom-menu-link {
  font-size: 0.95rem; /* Adjusted font size */
  font-weight: 400; /* Adjusted font weight */
}

.custom-submenu .custom-menu-link-wrapper {
  padding: 0.6rem 0; /* Adjusted padding for child links */
}

.custom-submenu {
  display: block;
  padding-left: 1.5rem;
  background-color: #fbfbfb;
  border-top: 1px solid #f0f0f0;
  border-bottom: 1px solid #f0f0f0;
  max-height: 0;
  opacity: 0;
  overflow: hidden; /* This is for the smooth open/close animation, not for internal scrolling */
  transition: max-height 0.5s ease-in-out, opacity 0.5s ease-in-out;
}

.custom-menu-item.is-submenu-open > .custom-submenu {
  max-height: 500px; /* Adjust this value if your submenus can be taller to ensure content is visible */
  opacity: 1;
  border-bottom: none;
}

@media (min-width: 1200px) {
  #custom-mobile-menu,
  #custom-mobile-toggle,
  .custom-menu-overlay {
    display: none !important;
  }
  body.custom-mobile-menu-open {
    overflow: auto;
    position: static;
    filter: none;
  }
}