"""
Mailbox mail-presence sensor - all dimensions. Millimetres. ASA.

ORIENTATION (confirmed 2026-09-22)
    Standing at the mail slot:
    X = ACROSS the slot, 153 mm wide, X=0 at centre (+X = right)
    Y = DEPTH from the slot wall, 255 mm, Y=0 at the slot wall
    Z = height, 85 mm, Z=0 at the steel floor
    The slot is at the top of the Y=0 wall. The lid hinges there and flips
    forward. The hardware bay sits against that wall, spanning the width.
    The insert is shortened at the BACK (far from the slot) to fit the printer.
"""

# ---- letterbox interior (measured) ----
BOX_W = 153.0          # X across the slot
BOX_D = 255.0          # Y depth from the slot wall
BOX_H = 85.0
BOLT_PROUD = 3.0       # 4 post bolts; file reliefs if any land on one

# ---- printer / fit ----
BUILD_VOL = 256.0
PRINT_MARGIN = 4.0
FIT_CLR = 1.5          # print to steel, each side
WALL = 2.0

# ---- components (nominal - VERIFY on the real parts) ----
LED_DIA = 5.0
LED_BODY_H = 8.6
LED_FLANGE_DIA = 5.8
LEAD_PITCH = 2.54
PT_DIA = 5.0
PT_BODY_H = 8.6
PT_FLANGE_DIA = 5.8
PART_CLR = 0.25
CELL_DIA, CELL_LEN, CELL_CLR = 21.8, 71.0, 1.2     # LG M58T maximums

# ---- tray (false floor) ----
TRAY_HX = BOX_W / 2 - FIT_CLR                      # 75
TRAY_Y0 = FIT_CLR                                  # 1.5
TRAY_Y1 = min(BOX_D - FIT_CLR, TRAY_Y0 + BUILD_VOL - PRINT_MARGIN - 2.0)  # 251.5
FLOOR_TOTAL_H = 13.0                               # deck top (10-13)
FLOOR_T = 2.4
RIB_W = 3.0
RIB_X = (25.0, 50.0)                               # ribs running front-to-back, +/-
RIB_Y = (110.0, 200.0)                             # ribs running across
CORRIDOR_HALF_W = 7.0                              # centre wire corridor

# ---- bay (fixed part) ----
BAY_D = 28.0           # slot wall to cover outer face. 21700 lies across X:
                       # needs CELL_DIA+CLR (23.0) clear of wall+cover, so 27.4
                       # minimum; 28 gives 23.6 mm clear.
COVER_T = 2.4
COVER_CLR = 0.4
# Side clearance per end between the cover and the insert.
# ⚠️ The cover is guided by the END WALLS (inner faces at X +/-73.0, i.e. a
# 146 mm opening), NOT by the ledges at X +/-71.0. The cover's rear wall sits
# at Y 27.1..29.5, which is entirely behind the ledges - they stop at Y 27.1
# and never touch it. Sizing the cover to 142 left 2 mm of slop per side on
# the first print. Width is now (146 - 2*COVER_SIDE_CLR).
COVER_SIDE_CLR = 0.2
COVER_BEND_Z = 56.0    # rear wall / slope bend, outer
# single STEP built into the slot wall for the cover's top edge to sit on:
# the wall thickens over a 45 deg gusset, steps back to a thin lip. No rail,
# no rear lip, no overhang.
STEP_Z = 77.0          # step face height (cover top edge sits 0.5 above)
STEP_Y1 = 7.5          # step reaches this far back from the slot face
LIP_Y1 = 4.3           # thin lip above the step, inner face
HOOK_BOT_Z = 77.5
TOP_Z = 84.0           # 1 mm under the lid
# cover foot: flange lying on the deck, screwed DOWN into bosses under it
FOOT_LEN = 12.0
FOOT_SCREW_X = 50.0
FOOT_SCREW_Y_OFF = 6.0
SCREW_CLR_D = 2.4
SCREW_PILOT_D = 1.8
BOSS_DIA = 8.0
# vertical wire tube on the inside of the RIGHT end wall, near the back of
# the bay; wire comes out its top through a notch in the cover's slope
TUBE_OUT = 7.0
TUBE_BORE = 4.0
TUBE_Y0 = 16.5
TUBE_TOP_PROUD = 1.0   # tube top above the cover's outer surface
DRAIN_DIA = 4.0
DRAIN_COUNT = 3
CABLE_NOTCH_W = 7.0    # sensor cables into the bay through the rim, at X=0
CABLE_NOTCH_H = 5.0

# --- controller PCB ---------------------------------------------------------
# 104 x 46 x 1.6 board, ORDERED 2026-09-23. How it mounts inside the bay is
# still OPEN - see pcb/MOUNTING-TODO.md. No card guides are modelled: the
# earlier ones assumed the board mounted to the COVER, which is removable.
PCB_W, PCB_H, PCB_T = 104.0, 46.0, 1.6

# ---- sensors ----
BEAM_X = 0.0
SENSOR_Y = (70.0, 150.0)          # front, rear - on the centreline
PT_BORE_DIA = 6.0
PT_RECESS = 0.4                   # film cover sits this far below the deck
PT_RIDGE_W = 2.0                  # glue ring for the film
PT_SLAB_L, PT_SLAB_W = 24.0, 20.0
LEG_CH_W, LEG_CH_D = 1.6, 2.0
PT_FLANGE_SEAT_D = 1.2

# ---- ceiling LED carrier ----
CARRIER_SLAB_H = LED_BODY_H + 1.4 # 10 - dome fully recessed
H1_LX, H1_LY = 30.0, 26.0         # front housing (junction well)
H2_LX, H2_LY = 22.0, 18.0         # rear housing
BR_W, BR_H, BR_WALL = 10.0, 6.0, 1.6
BR_MOUTH = 4.2
CARRIER_SIDE_X = 68.0             # the run to the hinge goes down this X
CARRIER_EXIT_END_GAP = 10.0       # channel ends this far behind the bay
