Let $N$ be a positive integer; for simplicity I'm happy to assume it's an odd prime but I'm interested in the general case too.

Let $f \colon \mathbb{Z}/N\mathbb{Z} \to \mathbb{C}$ and let $\widehat{f}$ denote its Fourier transform, $\widehat{f}(\xi) = \frac{1}{N} \sum_x f(x) e^{-2 \pi i \xi x / N}$.

I'm interested in functions $f$ with $|f|$ constant and $|\widehat{f}|$ constant; with the above conventions, WLOG taking $|f| = 1$ we have $|\widehat{f}| = 1/\sqrt{N}$.

My question is: is anything known about such functions? Do they have a name? Is there perhaps even a precise classification of them? Any pointers or references would be appreciated.

It's maybe worth saying that, although apparently a question about analysis, it is actually surely strongly algebraic in nature. Indeed, the conditions can be phrased as an algebraic set over $\mathbb{R}$ which I believe has dimension $0$ when $N$ is prime (if we add the condition $f(0) = 1$ to remove the degeneracy), which would mean the collection of such $f$ is finite and the coefficients are algebraic numbers. Furthermore all the examples I've computed are exceedingly structured, e.g.

$$ f(x) = e^{2 \pi i (\alpha x^2 + \beta x + \gamma) / N} $$

where $\alpha \in (\mathbb{Z}/N\mathbb{Z})^\times$, $\beta \in \mathbb{Z}/N\mathbb{Z}$, $\gamma \in \mathbb{R}$, as well as more complicated variants.

EDIT: given Sean Eberhard's partial answer below, I should maybe sketch an example to show that these quadratic examples are not the only ones, i.e. there are such functions $f$ whose values are not $N$th roots of unity.

Very briefly: let $f(x)$ be $1$ when $x$ is a square modulo $N$ and $\alpha$ otherwise for some fixed $\alpha \in \mathbb{C}$. It suffices to show that there is an $\alpha$ that works. Whenever $N \equiv 3 \pmod{4}$ is prime, this is the case, and in fact $$\alpha = \frac{ -(N-1) \pm 2 \sqrt{-N}}{N+1} \ .$$