Equilateral triangle $ABC$ has side length $840$. Point $D$ lies on the same side of line $BC$ as $A$ such that $\overline{BD} \perp \overline{BC}$. The line $\ell$ through $D$ parallel to line $BC$ intersects sides $\overline{AB}$ and $\overline{AC}$ at points $E$ and $F$, respectively. Point $G$ lies on $\ell$ such that $F$ is between $E$ and $G$, $\triangle AFG$ is isosceles, and the ratio of the area of $\triangle AFG$ to the area of $\triangle BED$ is $8:9$. Find $AF$.
By angle chasing, we conclude that $\triangle AGF$ is a $30^\circ\text{-}30^\circ\text{-}120^\circ$ triangle, and $\triangle BED$ is a $30^\circ\text{-}60^\circ\text{-}90^\circ$ triangle.
Let $AF=x.$ It follows that $FG=x$ and $EB=FC=840-x.$ By the side-length ratios in $\triangle BED,$ we have $DE=\frac{840-x}{2}$ and $DB=\frac{840-x}{2}\cdot\sqrt3.$
Let the brackets denote areas. We have \[[AFG]=\frac12\cdot AF\cdot FG\cdot\sin{\angle AFG}=\frac12\cdot x\cdot x\cdot\sin{120^\circ}=\frac12\cdot x^2\cdot\frac{\sqrt3}{2}\] and \[[BED]=\frac12\cdot DE\cdot DB=\frac12\cdot\frac{840-x}{2}\cdot\left(\frac{840-x}{2}\cdot\sqrt3\right).\]
We set up and solve an equation for $x:$
\begin{align*} \frac{[AFG]}{[BED]}&=\frac89 \\ \frac{\frac12\cdot x^2\cdot\frac{\sqrt3}{2}}{\frac12\cdot\frac{840-x}{2}\cdot\left(\frac{840-x}{2}\cdot\sqrt3\right)}&=\frac89 \\ \frac{2x^2}{(840-x)^2}&=\frac89 \\ \frac{x^2}{(840-x)^2}&=\frac49. \end{align*}
Since $00.$ Therefore, we take the positive square root for both sides:
\begin{align*} \frac{x}{840-x}&=\frac23 \\ 3x&=1680-2x \\ 5x&=1680 \\ x&=\boxed{336}. \end{align*}
~MRENTHUSIASM