"""Lower the exposed circular light 3 mm; retain the original rear collector and LED.
Run in the Version 28 native Fusion document after the cosmetic build and pilot restoration.
"""
import pathlib, json, traceback
OUT=pathlib.Path(C28_ROOT)
exec(compile((OUT/'source/03_build_28.py').read_text().split('try:\n    shell_o=')[0], '28_native_helpers', 'exec'),globals())
try:
    o=occurrence('C28_R1_01_');shell=worldcopy(o)
    # Restore only the forward skin of the former round aperture. The existing
    # rear collector seat, optical coupler and LED mount remain unmodified.
    shell=join(shell,cyl(0,5,2.46,-2.15,0))
    shell=cut(shell,cyl(0,2,2.45,-2.151,1))
    replace(o,shell,'C28_R1_01_Front_Shell_Chalk_Mesh_Round_Controls')
    o=occurrence('C28_R1_04_');old=worldcopy(o)
    collector=common(old,box(-5,5,-1,11,-3.6,-2.15))
    lens=join(collector,cyl(0,2,2.35,-2.151,.32))
    lens=join(lens,cyl(0,2,2.35,.32,.42,2.25))
    replace(o,lens,'C28_R1_04_Circular_Status_Lens_Original_Collector')
    assert o.component.bRepBodies.count==1 and o.component.bRepBodies.item(0).isSolid
    (OUT/'audit/light_position_review.json').write_text(json.dumps({
        'visible_center_mm':[0,2], 'previous_visible_center_mm':[0,5],
        'downward_change_mm':3, 'visible_diameter_mm':4.7, 'shell_aperture_mm':4.9,
        'original_rear_collector_retained':True,'internal_led_and_coupler_moved':False,
        'status':'Single connected lens solid. Offset optical output requires physical brightness/uniformity qualification.'
    },indent=2))
    d.timeline.moveToEnd();app.activeViewport.fit()
    print('Circular status light lowered 3 mm to Y=2; original rear collector and LED retained.')
except:
    (OUT/'audit/light_adjustment_error.txt').write_text(traceback.format_exc());print(traceback.format_exc())
