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

/**
 * Precinct lobby — campaign start.
 *
 * Reception desk, Ellis the night custodian, and doors into the squad hall
 * and witness lounge. Atmosphere first; the case opens one door at a time.
 */
export const FOYER: RoomDef = {
  id: "manor-foyer",
  displayName: "Ashgrove Precinct — Lobby",
  fog: { color: 0x0c0e12, near: 3, far: 18 },
  ambientLight: { color: 0x3a4050, intensity: 0.95 },
  lights: [
    {
      kind: "point",
      color: 0xffd9a0,
      intensity: 28,
      position: { x: 0, y: 2.5, z: 0 },
      distance: 14,
    },
    {
      kind: "directional",
      color: 0x304050,
      intensity: 0.4,
      position: { x: 2, y: 6, z: 4 },
    },
  ],
  geometry: [
    floor("floor", { x: 0, y: 0, z: 0 }, 4.5, 4),
    wall("wall-s", { x: 0, y: WALL_HALF, z: 4.15 }, { x: 4.7, y: WALL_HALF, z: WALL_THICKNESS }),
    wall("wall-n-left", { x: -2.7, y: WALL_HALF, z: -4.15 }, { x: 1.6, y: WALL_HALF, z: WALL_THICKNESS }),
    wall("wall-n-right", { x: 2.7, y: WALL_HALF, z: -4.15 }, { x: 1.6, y: WALL_HALF, z: WALL_THICKNESS }),
    // East wall split for lounge door at z≈0
    wall("wall-e-north", { x: 4.65, y: WALL_HALF, z: -2.3 }, { x: WALL_THICKNESS, y: WALL_HALF, z: 1.7 }, STONE),
    wall("wall-e-south", { x: 4.65, y: WALL_HALF, z: 2.3 }, { x: WALL_THICKNESS, y: WALL_HALF, z: 1.7 }, STONE),
    wall("wall-w", { x: -4.65, y: WALL_HALF, z: 0 }, { x: WALL_THICKNESS, y: WALL_HALF, z: 4 }, STONE),
    prop("console", { x: -2.8, y: 0.45, z: 1.5 }, { x: 1.2, y: 0.9, z: 0.5 }, TIMBER),
    prop("bench", { x: 2.8, y: 0.3, z: 2.4 }, { x: 1.4, y: 0.6, z: 0.5 }, 0x3a3530),
    prop("umbrella-stand", { x: -3.4, y: 0.4, z: -2.6 }, { x: 0.35, y: 0.8, z: 0.35 }, 0x3a3530),
  ],
  cameraZones: [
    {
      id: "foyer",
      trigger: { center: { x: 0, y: 1.5, z: 0 }, halfExtents: { x: 4.5, y: 2, z: 4 } },
      camera: {
        position: { x: 3.6, y: 3.2, z: 3.6 },
        lookAt: { x: -0.5, y: 1, z: -1 },
        fov: 55,
        trackPlayer: true,
        trackRadius: 1.8,
      },
      blend: { mode: "cut" },
      priority: 0,
    },
  ],
  interactables: [
    {
      id: "foyer-plaque",
      label: "Brass Plaque",
      position: { x: -2.8, y: 1.2, z: 1.5 },
      halfExtents: { x: 1.1, y: 1.1, z: 1 },
      action: {
        kind: "examine",
        text:
          '"Ashgrove Precinct — Est. 1891. Those who enter leave something of themselves behind." Someone scratched last night\'s date into the brass under the motto.',
      },
      repeatable: true,
      visual: { kind: "box", size: { x: 0.4, y: 0.25, z: 0.04 }, color: 0xb0a060 },
    },
    {
      id: "duty-log",
      label: "Duty Log",
      position: { x: -2.8, y: 1.0, z: 1.1 },
      halfExtents: { x: 1.0, y: 1.0, z: 0.9 },
      action: {
        kind: "examine",
        text:
          "Night board: REYES — office. MARROW — evidence vault. HALE — records (sealed). CIVILIANS: Voss / Kane — hold for interview. ELLIS — on grounds.",
      },
      repeatable: true,
      visual: { kind: "box", size: { x: 0.35, y: 0.03, z: 0.28 }, color: 0xd8d0c0 },
    },
    {
      id: "talk-ellis",
      label: "Ellis",
      position: { x: 3.2, y: 0.7, z: -1.8 },
      halfExtents: { x: 1.2, y: 1.1, z: 1.2 },
      action: {
        kind: "examine",
        text:
          'Ellis wipes grease off a ring of keys. "Night shift only. I mopped the lobby, then the upstairs hall went quiet. No shouting — just the lights flickering once. If you want the cellar, that key left the board years ago."',
      },
      repeatable: true,
      visual: { kind: "none" },
    },
    door({
      id: "door-foyer-to-gallery",
      label: "Squad Hall",
      position: { x: 0, y: 1.1, z: -4 },
      targetRoomId: "manor-gallery",
      spawnPointId: "from-foyer",
    }),
    door({
      id: "door-foyer-to-lounge",
      label: "Witness Lounge",
      position: { x: 4.5, y: 1.1, z: 0 },
      targetRoomId: "precinct-lounge",
      spawnPointId: "from-foyer",
    }),
  ],
  spawnPoints: [
    { id: "start", position: { x: 0, y: 0, z: 2.5 }, yaw: Math.PI },
    { id: "from-gallery", position: { x: 0, y: 0, z: -2.5 }, yaw: 0 },
    { id: "from-lounge", position: { x: 2.8, y: 0, z: 0 }, yaw: Math.PI / 2 },
  ],
};
