meta:
  engine: 4.1.0

# U is a predefined unit of measure that means 19.05mm (MX spacing)
points:
  zones:
    # ==================== LEFT HAND ====================
    matrix_left:
      anchor.shift: [50, -100]
      columns:
        pinky:
        ring.key.stagger: 0.66U
        middle.key.stagger: 0.25U
        index.key.stagger: -0.25U
        inner.key.stagger: -0.15U
      rows:
        bottom.padding: U
        home.padding: U
        top.padding: U
    thumb_left:
      anchor:
        ref: matrix_left_index_bottom
        shift: [0.66U, -1.25U]
        rotate: -10
      columns:
        tucky:
          key.name: thumb_left_tucky
        reachy:
          key.spread: U
          key.splay: -15
          key.origin: [-0.5U, -0.5U]
          key.name: thumb_left_reachy

    # ==================== RIGHT HAND ====================
    matrix_right:
      # Anchors the right hand 220mm to the right of the left hand
      anchor:
        ref: matrix_left_pinky_bottom
        shift: [220, 0]
      key.spread: -U # Builds columns to the left
      columns:
        pinky:
        ring.key.stagger: 0.66U
        middle.key.stagger: 0.25U
        index.key.stagger: -0.25U
        inner.key.stagger: -0.15U
      rows:
        bottom.padding: U
        home.padding: U
        top.padding: U
    thumb_right:
      anchor:
        ref: matrix_right_index_bottom
        shift: [-0.66U, -1.25U]
        rotate: 10
      columns:
        tucky:
          key.name: thumb_right_tucky
        reachy:
          key.spread: -U
          key.splay: 15
          key.origin: [0.5U, -0.5U]
          key.name: thumb_right_reachy

outlines:
  # 1. Base outer shell profile
  panel:
    - what: rectangle
      where: true
      size: [U + 4, U + 4] # 2mm bezel around keys
      fillet: 3            
  
  # 2. Hollow inner core for the tray layout
  cavity_profile:
    - what: rectangle
      where: true
      size: [U - 1, U - 1] 
      fillet: 2

  # 3. Standard 14x14mm MX switch cutouts
  switches:
    - what: rectangle
      where: true
      size: [14, 14]

  # 4. Standard M2 screw holes (2.2mm diameter) for corner standoffs
  screw_holes:
    - what: circle
      where:
        # Left Hand Screws
        - ref: matrix_left_pinky_top
          shift: [-0.6U, 0.6U]
        - ref: matrix_left_inner_top
          shift: [0.6U, 0.6U]
        - ref: matrix_left_pinky_bottom
          shift: [-0.6U, -0.6U]
        - ref: matrix_left_inner_bottom
          shift: [0.6U, -0.6U]
        # Right Hand Screws
        - ref: matrix_right_pinky_top
          shift: [0.6U, 0.6U]
        - ref: matrix_right_inner_top
          shift: [-0.6U, 0.6U]
        - ref: matrix_right_pinky_bottom
          shift: [0.6U, -0.6U]
        - ref: matrix_right_inner_bottom
          shift: [-0.6U, -0.6U]
      radius: 1.1

  # 5. U-shaped cable channel cutout on the back wall
  jack_cutout:
    - what: rectangle
      where:
        - ref: matrix_left_inner_top 
          shift: [0.5U, 0.7U] 
        - ref: matrix_right_inner_top 
          shift: [-0.5U, 0.7U] 
      size: [6.5, 12]       

  # 6. Pinhole window to let the RP2040-Zero's onboard RGB LED shine through the top plate
  led_window:
    - what: circle
      where:
        - ref: matrix_left_inner_home
          shift: [0.9U, 0.5U]
        - ref: matrix_right_inner_home
          shift: [-0.9U, 0.5U]
      radius: 1.5           

  # Combine elements to create the final top plate layout
  plate_holes:
    - panel
    - -switches
    - -screw_holes
    - -led_window

cases:
  # The 1.5mm Top Switch Plate
  switch_plate:
    - what: outline
      name: plate_holes
      extrude: 1.5

  # The 9mm Bottom Enclosure Tray
  bottom_case:
    - what: outline
      name: panel
      extrude: 9.0
    - what: outline
      name: cavity_profile
      extrude: 7.5
      operation: subtract
    - what: outline
      name: jack_cutout
      extrude: 10
      operation: subtract
    - what: outline
      name: screw_holes
      extrude: 10
      operation: subtract