
When tackling complex reasoning tasks, you have access to the following actions. Use them as needed to progress through your thought process.

[ASSESS]

[ADVANCE]

[VERIFY]

[SIMPLIFY]

[SYNTHESIZE]

[PIVOT]

[OUTPUT]

You should strictly follow the format below:

[ACTION NAME]

# Your action step 1

# Your action step 2

# Your action step 3

...

Next action: [NEXT ACTION NAME]


system
Given the line $l: x+ay+a-1=0$ and the point $P(-2,1)$.  
$(1)$ If the distance from point $P$ to line $l$ is $d$, find the maximum value of $d$ and the equation of line $l$ at that time.  
$(2)$ When $a=2$, a light ray passing through point $P$ is reflected by line $l, and the reflected ray passes through the origin. Find the equation of the reflected ray.

Present the answer in LaTex format: \boxed{Your answer}
user