If you are still working on this, the source of my calibre plugin Kindle Pop-up Footnotes may be useful for the footnote part:
https://github.com/paskal/calibre-kindle-footnotes
It finds recognised footnotes in EPUB and AZW3 books, adds the EPUB 3 footnote markup and reshapes the notes so that they open as pop-ups on a Kindle. It works on notes a book already has: it is a file type plugin that runs when a book is added or converted, not an editor plugin, and it does not create tooltips or margin notes.
Thread:
https://www.mobileread.com/forums/sh...d.php?t=376545
Contributions are very welcome.