.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background-color: var(--color-menu-bg);
  z-index: 1000;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.top-menu {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0 1.5rem;
  gap: 0.85rem;
}

.home-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  text-decoration: none;
  flex-shrink: 0;
}

.home-logo-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background-color: white;
  color: var(--color-accent);
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  font-size: 1.2rem;
  line-height: 1;
  transition: background-color 0.2s ease, color 0.2s ease;
  border: 2px solid transparent;
}

.home-logo:hover .home-logo-circle {
  background-color: var(--color-accent);
  color: white;
}

.home-logo:focus .home-logo-circle {
  outline: 2px solid white;
  outline-offset: 2px;
}

.top-menu-item {
  position: relative;
  padding: 0;
  cursor: pointer;
  white-space: nowrap;
}

.top-level-label {
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-decoration: none;
  display: block;
  padding: 0.8rem 1.275rem;
  white-space: nowrap;
}

.top-level-label:hover {
  opacity: 0.8;
}

.top-menu-item:hover .top-level-label {
  opacity: 0.8;
}

.top-menu-expand-all-button {
  margin-left: auto;
  margin-right: 0.25rem;
  display: flex;
  align-items: center;
  flex-direction: row-reverse;
  gap: 0;
  white-space: nowrap;
  background: none;
  border: none;
  padding: 0.8rem 0.75rem;
  cursor: pointer;
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  color: #ffffff;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: opacity 0.2s ease;
}

.top-menu-expand-all-button:hover,
.top-menu-expand-all-button:focus {
  opacity: 0.8;
  outline: none;
}

.expand-all-icon {
  font-weight: 900;
  font-size: 1.2rem;
  line-height: 1;
  color: #ffffff;
  flex-shrink: 0;
  display: inline-block;
  transform: translateY(-2px) scale(1.35);
  transform-origin: center;
  text-shadow: 0 0 0.5px #ffffff;
}

.expand-all-icon.expand-all-icon-plus {
  transform: translateY(-1px) scale(1.35);
}

.top-menu-expand-all-button .expand-all-text {
  display: inline-block;
  min-width: 0;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  margin-right: 0;
  transition: opacity 0.2s ease;
  white-space: nowrap;
  color: #ffffff;
}

.top-menu-expand-all-button:hover .expand-all-text,
.top-menu-expand-all-button:focus .expand-all-text,
.top-menu-expand-all-button:focus-visible .expand-all-text {
  max-width: 12rem;
  opacity: 1;
  margin-right: 0.4rem;
}

.mobile-menu-expand-all-button {
  justify-content: flex-start;
  flex-direction: row;
  color: #ffffff;
  background: none;
  border: none;
  padding: 1rem 1.5rem;
  white-space: nowrap;
}

.mobile-menu-expand-all-button .expand-all-text {
  max-width: none;
  opacity: 1;
  overflow: visible;
  transform: none;
}

.mobile-menu-expand-all-button .expand-all-icon {
  margin-right: 0.5rem;
  font-size: 1.2rem;
}

.top-submenu {
  position: absolute;
  top: 100%;
  left: 0;
  background-color: white;
  border: 1px solid var(--color-border);
  border-top: none;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
  min-width: 180px;
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
  z-index: 1001;
  display: none;
}

.top-submenu-item {
  display: block;
  padding: 0.75rem 1.5rem;
  font-family: 'Work Sans', sans-serif;
  font-weight: 300;
  font-size: 0.95rem;
  color: black;
  transition: background-color 0.2s ease;
  text-decoration: none;
}

.top-submenu-item:hover {
  background-color: var(--color-border);
}

/* Hamburger menu button (hidden on desktop) */
.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  margin-left: 1rem;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.hamburger-icon {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  width: 1.5rem;
  height: 1.5rem;
}

.hamburger-icon span {
  width: 100%;
  height: 3px;
  background-color: white;
  border-radius: 2px;
  transition: all 0.3s ease;
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger-icon span:nth-child(1) {
  transform: rotate(45deg) translate(8px, 8px);
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger-icon span:nth-child(2) {
  opacity: 0;
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger-icon span:nth-child(3) {
  transform: rotate(-45deg) translate(8px, -8px);
}

/* Mobile menu overlay */
.mobile-menu {
  position: fixed;
  left: 0;
  width: 100%;
  background-color: white;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
  z-index: 999;
  max-height: calc(100vh - 3.5rem);
  overflow-y: auto;
  transform: translateY(-100%);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s ease;
}

@media (max-width: 768px) {
  .mobile-menu {
    top: 3.5rem;
  }
}

.mobile-menu.active {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
}

.mobile-menu-content {
  padding: 1rem 0;
}

.mobile-menu-item {
  border-bottom: 1px solid var(--color-border);
}

.mobile-menu-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 1rem 1.5rem;
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  color: black;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.2s ease;
}

.mobile-menu-link:hover,
.mobile-menu-link:focus {
  background-color: var(--color-bg-light);
  outline: none;
}

.mobile-submenu {
  max-height: 0;
  overflow: hidden;
  background-color: #f9f9f9;
  transition: max-height 0.3s ease;
}

.mobile-submenu.active {
  max-height: 600px;
}

.mobile-submenu-item {
  display: block;
  padding: 0.75rem 1.5rem 0.75rem 3rem;
  font-family: 'Work Sans', sans-serif;
  font-weight: 300;
  font-size: 0.95rem;
  color: black;
  text-decoration: none;
  text-transform: none;
  letter-spacing: 0;
  transition: background-color 0.2s ease;
}

.mobile-submenu-item:hover,
.mobile-submenu-item:focus {
  background-color: #e8e8e8;
  outline: none;
}

@media (max-width: 768px) {
  /* Hide desktop menu items on mobile */
  .top-menu-item {
    display: none;
  }

  .top-menu-expand-all-button {
    display: none;
  }

  /* Show hamburger button on mobile */
  .mobile-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .top-menu {
    padding: 0.5rem 1.5rem;
    justify-content: space-between;
  }

  .home-logo {
    width: 2.4rem;
    height: 2.4rem;
  }

  .home-logo-circle {
    width: 2.4rem;
    height: 2.4rem;
    font-size: 1.4rem;
  }

  /* Ensure mobile menu appears below the nav bar */
  .top-nav {
    position: fixed;
  }
}

@media (max-width: 1024px) {
  .top-menu-expand-all-button {
    display: none;
  }
}
