"""Section-level chain modifiers — Lumicron's wedge feature.

A single Route can change layer, profile, bend type, and width as it
travels. The chain modifiers `.style()`, `.radius()`, `.bend()`, and
`.width()` apply to the *next* `.go()` and persist until you change
them. Pass `"default"` to revert to the Route()-time global.

Auto layer transitions slot in PCells (e.g. SiLN ↔ SiLC bridges) at
every section boundary that crosses layers — you don't drop them in
manually.
"""
import lumicron as lm
import lumicron.pdks.elyon_demo.all as pdk


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

    c.add(lm.PORT(
        "in", position=(0, 0), direction=0,
        route_profile=pdk.RP.silc_strip,
    ))
    c.add(lm.PORT(
        "out", position=(800, 400), direction=180,
        route_profile=pdk.RP.silc_strip,
    ))

    (c.Route(c.ports["in"]).to(c.ports["out"])
        # Section 1 — silicon strip (default from port_a.route_profile).
        .go("E", by=250)
        # Section 2 — switch to silicon-nitride strip.
        .style(profile=pdk.RP.siln_strip)
        .go("E", by=200)
        .go("N", by=150)
        # Section 3 — back to defaults but with a wider core.
        .style("default")
        .width(3)
        .go("N", to=c.ports["out"].position[1])
        .go("E", to=c.ports["out"].position[0]))
    return c


if __name__ == "__main__":
    SectionTransitions().to_gds("section_transitions.gds")
