My table of content side menu not working properly

I created a sticky table of contents of my guide and related each heading to its section, and there are three problems.

  1. when clicking on the menu item that is before the section I am on, it goes to the end of the section instead of the beginning of the section.
  2. when clicking on the menu item, it goes suddenly to the section without a scrolling effect.
  3. when clicking on the menu item, some of the paragraphs are hidden behind the heading of the section.

I think most of these problems are because my headings are sticky, I want to keep them sticky and solve these problems.

i fixed it with the help of one support staff