"""Auto layer transitions — cross-layer routes, no manual PCells.

When port_a is on one layer and port_b is on another, the router checks
the registered TransitionRegistry. If a transition PCell exists for the
pair (e.g. `PhotonicElevator` for SiLC ↔ SiLN), the router drops it in
automatically and continues on the new layer.

`transition_offset` controls where along the route the transition sits.
"""
import lumicron as lm
import lumicron.pdks.elyon_demo.all as pdk


@lm.pcell
def LayerTransition():
    c = lm.CELL("LayerTransition")

    # Input on silicon, output on nitride.
    c.add(lm.PORT(
        "in", position=(0, 0), direction=0,
        route_profile=pdk.RP.silc_strip,
    ))
    c.add(lm.PORT(
        "out", position=(600, 0), direction=180,
        route_profile=pdk.RP.siln_strip,
    ))

    # The router consults pdk's default transition registry for the
    # SiLC → SiLN pair and inserts the elevator at offset=300 µm.
    c.Route(c.ports["in"], transition_offset=300).to(c.ports["out"])
    return c


if __name__ == "__main__":
    LayerTransition().to_gds("layer_transition.gds")
