How does ECDH arrive on a shared secret?
Let's assume that everyone agreed on some elliptic curve and a public base point $g$ somewhere on the curve.
When two parties Alice and Bob want to agree on a shared secret, they proceed as follows:


Alice chooses some random number $a$ and applies the curve operation to $g$, the public base point, $a$ times. She obtains some result $A=g^a=\underbrace{g\cdot g\cdots g}_{\text{$a$ times}}$ and shares this point across the wire with Bob.
Likewise, Bob chooses a random number $b$ and publishes $B=g^b$.
Alice takes Bob's point $B$ and applies the curve operation $a$ times to it to obtain a point $S$. That is, $S=B^a=\underbrace{B\cdot B\cdots B}_{\text{$a$ times}}$.
Bob takes Alice's point $A$ and proceeds accordingly to obtain $S'=A^b$.


At this point, the important thing to notice is that applying some operation $a$ times $b$ times is the same thing as applying some operation $b$ times $a$ times. To keep abusing the billiards metaphor: Hitting a ball $3$ times and repeating this process $5$ times is exactly the same thing as hitting a ball $5$ times and repeating this process $3$ times. In both cases, the ball gets hit $15$ times. Therefore, $S=S'$ is a shared secret!

We have yet to make plausible why $S$ is secret: An attacker only sees $A$ and $B$ and wants to find out what point would result in "mixing" the operations performed by Alice and Bob. Mathematically speaking (this is known as the Diffie-Hellman problem): Given $g^a$ and $g^b$, what is $g^{ab}$? The obvious (but perhaps not the only) way to solve this problem is to compute $a$ and $b$ and simply evaluate the desired expression (remember, hitting the ball is easy!). But computing $a$ or $b$ (solving the discrete logarithm problem) is hopefully — this is in fact an open problem — hard when they are sufficiently large, as described in the text you cited. Therefore, an attacker has (for all we know) a very hard time obtaining the shared secret $S$, and Alice and Bob can live their lives happily ever after.



As to the ephemeral "variants": There are none. The difference lies exclusively in the way the above procedure is used: "ephemeral" simply means that the private keys $a$ and $b$ are generated only for one single session and thrown away afterwards, providing forward secrecy.



Edit. As Stephen pointed out in the comments, it is actually not that easy: If Alice just naïvely applied the curve operation $a$ times, an attacker might obviously also have the computing power to conduct a brute-force search for $a$. In fact, the repeated application of the operation is performed using exponentiation by squaring, effectively obtaining the result in time $\mathcal O(\log a)$ instead of $\mathcal O(a)$. It is based on the observation that, when $a=2a_h+a_\ell$ with $a_\ell\in\{0,1\}$, then
$$g^a = (g^2)^{a_h}\cdot g^{a_\ell}\text.$$
Recursively applying this identity to compute $(g^2)^{a_h}$ until $a_h$ is zero requires a number of steps proportional to the bit length of $a$. When $a=\sum_{i=0}^ra_i2^i$ with all $a_i\in\{0,1\}$ is the binary representation of $a$, this yields the formula
$$g^a=g^{\sum_{i=0}^ra_i2^i}=\prod_{i=0}^rg^{a_i2^i}\text.$$
(Without using formulae, this means: For each $i$ where the $i$th least significant bit of $a$ is set, take $g$ and square it $i$ times. That is, set $t:=g$ and repeat the assignment $t:=t^2$, i.e. apply the curve operation to $t$ and $t$ and call the result $t$ again, $i$ times. Do this for all $i$ and combine the resulting $t$s using the curve operation.)