% Overall three-stage framework: offline field prior -> parallel coarse search
% -> joint numerical optimization.  Laid out to fit one IEEE column (252 pt)
% at full size, so no scaling is applied when included.  Section numbers are
% plain text so the standalone figure compiles independently of main.tex.
\documentclass[border=1pt]{standalone}
\input{figstyle}
\begin{document}
\begin{tikzpicture}[
    blk/.style={draw=sitec, line width=0.5pt, rounded corners=1.2pt,
                align=center, inner sep=2.2pt, font=\tiny,
                text width=23mm, minimum height=5.4mm},
    io/.style={blk, fill=fillc, text width=20mm},
    offb/.style={blk, fill=centc!10, draw=centc!70},
    parkb/.style={blk, fill=parkc!10, draw=parkc!70, text width=21mm},
    exitb/.style={blk, fill=exitc!10, draw=exitc!70, text width=21mm},
    optb/.style={blk, fill=corrc!10, draw=corrc!70, text width=52mm},
    stage/.style={draw=sitec!45, line width=0.4pt,
                  dash pattern=on 1.4pt off 1.2pt, rounded corners=2pt},
    lbl/.style={font=\tiny\itshape, sitec},
    ar/.style={->, line width=0.45pt, sitec,
               >={Latex[length=1.3mm,width=1.0mm]}},
    note/.style={font=\tiny, sitec, align=left},
  ]

  % =====================================================================
  % Stage 1 -- offline construction of the guidance-field prior
  % =====================================================================
  \node[io]   (bnd)  at (0,0)      {site boundary point cloud};
  \node[offb] (skel) at (0,-0.98)  {EVG skeleton $+$ QP smoothing
                                    $\rightarrow \varLambda_\text{center}$};
  \node[offb] (guid) at (0,-1.96)  {normal offset $\pm W/2$
                                    $\rightarrow \varLambda_\text{park},
                                     \varLambda_\text{exit}$};
  \node[offb] (fld)  at (0,-3.05)  {kernel superposition
                                    $\rightarrow U_\text{park}, U_\text{exit}$
                                    (mirrored about $\varLambda_\text{center}$)};

  \foreach \a/\b in {bnd/skel, skel/guid, guid/fld}{ \draw[ar] (\a) -- (\b); }

  \node[stage, fit=(bnd)(fld), inner sep=3pt] (s1) {};
  \node[lbl, above=0.8pt of s1.north] {Stage 1: offline (Sec.~III)};

  % =====================================================================
  % Stage 2 -- two coarse paths searched independently and in parallel
  % =====================================================================
  \node[parkb] (hap) at (3.72,-0.82) {field-adaptive Hybrid A*
                                      on $U_\text{park}$};
  \node[exitb] (hax) at (3.72,-2.24) {field-adaptive Hybrid A*
                                      on $U_\text{exit}$};

  \node[stage, fit=(hap)(hax), inner sep=3pt] (s2) {};
  \node[lbl, above=0.8pt of s2.north, align=center]
       {Stage 2: online, parallel (Sec.~IV)};

  \draw[ar] (fld.east) -- ++(0.22,0) |- (hap.west);
  \draw[ar] (fld.east) -- ++(0.22,0) |- (hax.west);

  % =====================================================================
  % Stage 3 -- joint optimization of the two coarse paths
  % =====================================================================
  \node[optb] (corr) at (1.86,-4.35)
       {convex corridors $\mathcal{P}_k$ from the perception snapshot
        (ellipsoid proxy, inset by $\Delta_\text{cut}$)};
  \node[optb] (nlp)  at (1.86,-5.45)
       {joint NLP:
        $\mathbf{z}=[\mathbf{z}_\text{park};\mathbf{z}_\text{exit}]$,
        interaction cost $J_\varPsi$, solved by Ipopt};
  \node[io, text width=28mm] (out) at (1.86,-6.45)
       {$\varGamma_\text{park}^\star,\ \varGamma_\text{exit}^\star$};

  \node[stage, fit=(corr)(out), inner sep=3pt] (s3) {};
  \node[lbl, below=0.8pt of s3.south]
       {Stage 3: joint optimization (Sec.~V)};

  \draw[ar] (hap.east) -- ++(0.20,0) |- ([yshift=1.1mm]corr.east);
  \draw[ar] (hax.south) -- ++(0,-0.30) -| ([xshift=8mm]corr.north);
  \draw[ar] (corr) -- (nlp);
  \draw[ar] (nlp)  -- (out);

  % ---------- what each stage fixes ------------------------------------
  \node[note] at (0.30,-3.72) {\textbf{fixes} topology};
  \node[note] at (3.30,-3.00) {\textbf{fixes} $N,\{\delta_j\}$};
  \node[note] at (-0.62,-5.45) {\textbf{fixes}\\shape,\\$\kappa$ cont.};

  % ---------- rebuild trigger -------------------------------------------
  \draw[ar, densely dotted, centc, >={Latex[length=1.3mm,width=1.0mm]}]
        (out.west) -- ++(-0.42,0) |- (skel.west);
  \node[font=\tiny, centc, align=center] at (-1.32,-2.55)
       {rebuild only\\on boundary\\change};

\end{tikzpicture}
\end{document}
