Where is the documentation for writing an Arduino core?
There are two major parts to writing an Arduino core: the hardware independent portions and the hardware dependent.
The hardware independent portions are pretty much done for you in the ArduinoCore-API. However I wouldn't just use that verbatim but use it as a starting point and adapt it to your needs. This is because it actually has a couple of unresolved issues and not everything may 100% fit your needs. We don't use it for the chipKIT core because:

It has an unresolved issue around the naming of the String.h file which conflicts with the libc's string.h on case insensitive filesystems
Our USB stack is vastly different to how the Arduino &quot;Pluggable USB&quot; works
We have extra facilities in a number of standard objects to make use of more efficient use of more advanced hardware

Once you have the hardware independent portion sorted you need to write, from scratch, the hardware dependent portion.  The basic list of functions you need to implement are listed in the Arduino reference. How you write them cannot be documented, since that depends on the hardware. And you may well need to (or want to) write considerably more functions that just those. For example on chipKIT as well as the standard analogWrite() function we also have functions to change the PWM frequency and resolution - things that aren't part of the &quot;standard&quot;, but are incredibly useful.
A good starting point is to examine the Arduino.h file of an existing core (the AVR core is a good baseline) which will list most of the functions and their parameter/return types. That gives you what the functions expect to receive and what they should emit, but how those functions are written is completely down to you.
And then of course you have to implement the boards variants etc to make the whole things work...
Also, be warned that writing (and maintaining) a core is a long and involved process and will consume the rest of your life.