import type { RoomDef } from "@psx/shared";
import { door, floor, prop, STONE, TIMBER, wall, WALL_HALF, WALL_THICKNESS } from "./helpers.js";

/**
 * Detective office — Det. Reyes (Olivia).
 *
 * Case board and partner briefing. Open from the squad hall; sets the
 * investigation tone before the player fans out to witnesses.
 */
export const OFFICE: RoomDef = {
  id: "precinct-office",
  displayName: "Ashgrove Precinct — Detective Office",
  fog: { color: 0x0c1016, near: 3, far: 16 },
  ambientLight: { color: 0x3a4250, intensity: 1 },
  lights: [
    {
      kind: "point",
      color: 0xffd0a0,
      intensity: 28,
      position: { x: -1.2, y: 2.4, z: -0.5 },
      distance: 12,
    },
    {
      kind: "point",
      color: 0x7080a0,
      intensity: 10,
      position: { x: 2, y: 2.2, z: 2 },
      distance: 9,
    },
  ],
  geometry: [
    floor("floor", { x: 0, y: 0, z: 0 }, 4, 3.5),
    wall("wall-n", { x: 0, y: WALL_HALF, z: -3.65 }, { x: 4.2, y: WALL_HALF, z: WALL_THICKNESS }, STONE),
    wall("wall-s-left", { x: -2.4, y: WALL_HALF, z: 3.65 }, { x: 1.4, y: WALL_HALF, z: WALL_THICKNESS }),
    wall("wall-s-right", { x: 2.4, y: WALL_HALF, z: 3.65 }, { x: 1.4, y: WALL_HALF, z: WALL_THICKNESS }),
    wall("wall-e", { x: 4.15, y: WALL_HALF, z: 0 }, { x: WALL_THICKNESS, y: WALL_HALF, z: 3.5 }, STONE),
    wall("wall-w", { x: -4.15, y: WALL_HALF, z: 0 }, { x: WALL_THICKNESS, y: WALL_HALF, z: 3.5 }, STONE),
    prop("desk", { x: -2.2, y: 0.4, z: -1.2 }, { x: 1.8, y: 0.8, z: 1.0 }, TIMBER),
    prop("case-board", { x: 3.4, y: 1.2, z: -1.5 }, { x: 0.12, y: 1.8, z: 2.4 }, 0x2a2824),
    prop("filing", { x: 3.2, y: 0.7, z: 2 }, { x: 0.7, y: 1.4, z: 0.9 }, 0x4a4e54),
    prop("chair", { x: -2.2, y: 0.35, z: 0.2 }, { x: 0.5, y: 0.7, z: 0.5 }, 0x3a3530),
  ],
  cameraZones: [
    {
      id: "office",
      trigger: { center: { x: 0, y: 1.5, z: 0 }, halfExtents: { x: 4, y: 2, z: 3.5 } },
      camera: {
        position: { x: 3.0, y: 3.0, z: 3.0 },
        lookAt: { x: -1.2, y: 1.1, z: -1 },
        fov: 56,
        trackPlayer: true,
        trackRadius: 1.6,
      },
      blend: { mode: "cut" },
      priority: 0,
    },
  ],
  interactables: [
    {
      id: "case-board",
      label: "Case Board",
      position: { x: 3.2, y: 1.3, z: -1.5 },
      halfExtents: { x: 1.2, y: 1.4, z: 1.4 },
      action: {
        kind: "examine",
        text:
          "ASHGROVE — NIGHT SHIFT. Red string pins Lobby → Records → Vault. Three living witnesses. One body in evidence. Kane's timeline is marked with a question; Voss's with a star.",
      },
      repeatable: true,
      visual: { kind: "none" },
    },
    {
      id: "partner-notes",
      label: "Partner Notes",
      position: { x: -2.2, y: 0.95, z: -1.2 },
      halfExtents: { x: 1.2, y: 1.1, z: 1.1 },
      action: {
        kind: "examine",
        text:
          "Reyes' handwriting: \"Question everyone. Touch nothing in the vault until Marrow's journal is read. The crank pieces still open the records shutter — old building, old puzzles.\"",
      },
      repeatable: true,
      visual: { kind: "box", size: { x: 0.32, y: 0.02, z: 0.26 }, color: 0xe8dcc8 },
    },
    {
      id: "talk-olivia",
      label: "Det. Reyes",
      position: { x: -2.4, y: 0.7, z: -1.6 },
      halfExtents: { x: 1.3, y: 1.2, z: 1.3 },
      action: {
        kind: "examine",
        text:
          'Reyes doesn\'t look up from the case board. "Victim was last seen leaving the records wing. Interview Voss and Kane first — their stories don\'t line up. Hale\'s notes are sealed until you turn the corridor valve. I\'ll hold the line here."',
      },
      repeatable: true,
      visual: { kind: "none" },
    },
    door({
      id: "door-office-to-gallery",
      label: "Squad Hall",
      position: { x: 0, y: 1.1, z: 3.5 },
      targetRoomId: "manor-gallery",
      spawnPointId: "from-office",
    }),
  ],
  spawnPoints: [
    { id: "from-gallery", position: { x: 0, y: 0, z: 2.2 }, yaw: Math.PI },
  ],
};
