<s>[INST] Need help to understand this solution of $2^mp^2 +1=q^5$ The Question-

Find all triples $(m,p,q)$ where $ m $ is a positive integer and $ p ,
> q $ are primes.
****$2^mp^2 +1=q^5$****

After trying my best to solve this problem, and progressing a little bit, I decided to look up the solution and I am unable to quite understand it.
The solution-

clearly $q,p$ are odd
Let:$A=\sum _{i=0}^4q^i$ ,
$\large 2^mp^2=q^5-1=(q-1)\left ( A \right )$
  Let:$d=\gcd(q-1,A)$$\large \Rightarrow d|A=\left (\sum _{i=0}^4(q^i-1)
> \right )+5\Leftrightarrow d|5$
If:$d=5\large \Rightarrow p=5\Rightarrow A=5$ since$ A$ is odd , But
  $A>1+1+1+1+1=5$
then $d = 1$ $\large \Rightarrow q-1=2^m,A=p^2$ , Assume that $
> m\geq3$ $\large \Rightarrow q\equiv1[8]\Rightarrow p^2=A\equiv5[8]$
Which is impossible , so $m<3$
If:$m=1 \Rightarrow q=3,p=11$ $m=2$ $\large \Rightarrow q=5\Rightarrow
> p^2=781$
Therefore the unique solution is $(1,11,3)$

I have understood upto the part where $d$ divides 5, hence $d=1$ or $5$ but I don't understand how the solution progresses after that. 
Could someone give me an explanation behind this proof, and also the thought process of the solution so that I can solve questions like this on my own
 [/INST] I'm going to add some words to the solution.

$$2^mp^2=(q-1)A\tag1$$
where $A=q^4+q^3+q^2+q+1$.

If:$d=5\large \Rightarrow p=5\Rightarrow A=5$ since$ A$ is odd , But
  $A>1+1+1+1+1=5$

If $d=5$, then the right hand of $(1)$ is divisible by $5$, so it follows that $p=5$. Since $A$ is odd, we see that $2^m$ divides $q-1$. Noting that $5$ divides both $q-1$ and $A$, we see that $A=5$. However, this is impossible since $$A=q^4+q^3+q^2+q+1\gt 1+1+1+1+1=5$$

then $d = 1$ $\large \Rightarrow q-1=2^m,A=p^2$ , Assume that $m\geq3$ $\large \Rightarrow q\equiv1[8]\Rightarrow p^2=A\equiv5[8]$ which is impossible , so $m<3$
If:$m=1 \Rightarrow q=3,p=11$ $m=2$ $\large \Rightarrow q=5\Rightarrow p^2=781$

When $d=1$, since $A$ is odd, we see that $q-1=2^m$ and $A=p^2$. 
Assume that $m\ge 3$. Then, $q=2^m+1\equiv 0+1\equiv 1\pmod 8$, so $$p^2=A=q^4+q^3+q^2+q+1\equiv 1^4+1^3+1^2+1+1\equiv 5\pmod 8$$
However, there is no integer $p$ satisfying $p^2\equiv 5\pmod 8$.
So, we get $m\lt 3$.
If $m=1$, then $q=2^1+1=3$ and $2p^2=3^5-1$ implies $p=11$.
If $m=2$, them $q=2^2+1=5$ and $4p^2=5^5-1$ implies $p=\sqrt {781}$ which is not an integer.
</s>