Across the Mediterranean region, in fields and on roadsides, thrives a small plant with silvery leaves. It doesn't look like much, and in many cases it's an annoying weed. But in the Middle Ages, Chrozophora tinctoria was highly prized.

There's a clue in the name - tinctoria means to dye, and common names of the plant include dyer's croton and dyer's litmus plant. Medieval artists used its tiny, three-lobed fruit to produce a delicate blue tint called folium or turnsole, for colouring their famous illuminated manuscripts.

These dyes fell out of favour by the 17th century for more vivid mineral-based hues, and the secrets for how to extract the pigment from the fruit were lost.

But Portuguese scientists studying ancient texts didn't just rediscover and recreate the recipe for folium - they've uncovered the chemical structure of the pigment.

And this structure is unlike any other naturally occurring blue pigment; the newly discovered chemical compound has been named chrozophoridin.

The key to the discovery is a medieval Portuguese treatise called The book on how to make all the colour paints for illuminating books. It dates back to the 15th century CE, and describes, in detail, the materials and steps for creating paints - basically a medieval paint recipe book.

The language used is Portuguese, written phonetically using the Hebrew alphabet, and it was used to create Hebrew sacred texts. A few years ago, the research team started using this book to try and recreate the dyes described therein.

It wasn't a purely academic exercise. The illuminated manuscripts that have survived over the centuries are only going to grow more fragile over time. But if we understand the chemistry of the dyes, we can figure out better ways of preserving the colours for future generations.

And in 2018, the team did it. Using the specific instructions laid out in The book on how to make all the colour paints for illuminating books, the researchers successfully recreated folium.

"It describes when to collect the fruits - in July," chemist Paula Nabais of NOVA University Lisbon told Chemical and Engineering News. "You need to squeeze the fruits, being careful not to break the seeds, and then to put them on linen."

The next step - the focus of the team's new paper - was to try to probe the chemical structure of the compound.

The colour is extracted from the shell of the fruit; breaking the seed pollutes the pigment, producing a poor quality ink. And it's laborious work: the team soaked the fruit in a methanol-water solution, stirring carefully for two hours. Then the methanol was evaporated under a vacuum, leaving behind a crude blue extract that the team further purified, and concentrated the blue pigment.

It was this purified, concentrated pigment that the team analysed using a suite of high-tech techniques, including several types of mass spectrometry and magnetic resonance.

The molecular structure the team found was dissimilar from other blue pigments extracted from plants, such as indigo and anthocyanins, the blue pigment found in berries. But it did have a structure in common with a blue chromophore found in another plant - the medicinal herb Mercurialis perennis, or dog's mercury.

With a key difference: the chromophore in C. tinctoria has a stable glycosylated structure, which means it is water soluble - and can therefore be transformed into a dye.

This discovery means that not only can conservators and scientists recreate the dye to probe its properties, such as its structure and how it reacts to environmental stresses over time, but they can better identify it in medieval manuscripts.

"Chrozophoridin was used in ancient times to make a beautiful blue dye for painting, and it is neither an anthocyanin - found in many blue flowers and fruits - nor indigo, the most stable natural blue dye. It turns out to be in a class of its own," the researchers wrote in their paper.

"Thus, we believe that this will be not our final word on this amazing plant and its story and that further discoveries will follow soon."

The research has been published in Science Advances.