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

/**
 * Witness lounge — Garvey Kane (civilian-m).
 *
 * Soft chairs, cold coffee, the alibi stage. Accessed from the lobby so the
 * player meets a witness before the squad hall opens the full case board.
 */
export const LOUNGE: RoomDef = {
  id: "precinct-lounge",
  displayName: "Ashgrove Precinct — Witness Lounge",
  fog: { color: 0x0e1014, near: 3, far: 14 },
  ambientLight: { color: 0x404848, intensity: 0.95 },
  lights: [
    {
      kind: "point",
      color: 0xffc090,
      intensity: 22,
      position: { x: 0, y: 2.3, z: 0.5 },
      distance: 12,
    },
    {
      kind: "directional",
      color: 0x304050,
      intensity: 0.35,
      position: { x: -2, y: 5, z: 3 },
    },
  ],
  geometry: [
    floor("floor", { x: 0, y: 0, z: 0 }, 3.8, 3.5),
    wall("wall-n", { x: 0, y: WALL_HALF, z: -3.65 }, { x: 4.0, y: WALL_HALF, z: WALL_THICKNESS }, STONE),
    wall("wall-s", { x: 0, y: WALL_HALF, z: 3.65 }, { x: 4.0, y: WALL_HALF, z: WALL_THICKNESS }),
    wall("wall-e-left", { x: 3.95, y: WALL_HALF, z: -2.0 }, { x: WALL_THICKNESS, y: WALL_HALF, z: 1.5 }),
    wall("wall-e-right", { x: 3.95, y: WALL_HALF, z: 2.0 }, { x: WALL_THICKNESS, y: WALL_HALF, z: 1.5 }),
    wall("wall-w", { x: -3.95, y: WALL_HALF, z: 0 }, { x: WALL_THICKNESS, y: WALL_HALF, z: 3.5 }, STONE),
    prop("sofa", { x: -2.0, y: 0.35, z: 1.6 }, { x: 2.0, y: 0.7, z: 0.8 }, 0x4a3c48),
    prop("coffee-table", { x: -1.6, y: 0.25, z: 0.2 }, { x: 1.2, y: 0.5, z: 0.7 }, TIMBER),
    prop("sideboard", { x: 2.6, y: 0.5, z: -2.2 }, { x: 1.4, y: 1.0, z: 0.5 }, 0x3e3830),
    prop("plant", { x: 2.8, y: 0.5, z: 2.2 }, { x: 0.4, y: 1.0, z: 0.4 }, 0x3a5a38),
  ],
  cameraZones: [
    {
      id: "lounge",
      trigger: { center: { x: 0, y: 1.5, z: 0 }, halfExtents: { x: 3.8, y: 2, z: 3.5 } },
      camera: {
        position: { x: 3.2, y: 2.9, z: 2.8 },
        lookAt: { x: -1.0, y: 1.0, z: 0.2 },
        fov: 56,
        trackPlayer: true,
        trackRadius: 1.5,
      },
      blend: { mode: "blend", duration: 0.4 },
      priority: 0,
    },
  ],
  interactables: [
    {
      id: "cold-coffee",
      label: "Coffee Cup",
      position: { x: -1.6, y: 0.6, z: 0.2 },
      halfExtents: { x: 1.0, y: 1.0, z: 1.0 },
      action: {
        kind: "examine",
        text:
          "Two cups. One lipstick-smudged, empty. One black, half full, cold — and a smear of red clay on the saucer that matches the vault stairs.",
      },
      repeatable: true,
      visual: { kind: "box", size: { x: 0.12, y: 0.14, z: 0.12 }, color: 0xd8d0c4 },
    },
    {
      id: "magazine-stack",
      label: "Magazines",
      position: { x: 2.6, y: 1.1, z: -2.2 },
      halfExtents: { x: 1.1, y: 1.1, z: 1.0 },
      action: {
        kind: "examine",
        text:
          "Last month's city paper. Ashgrove Station renovation delayed. Someone circled the cellar blueprint in ballpoint.",
      },
      repeatable: true,
      visual: { kind: "box", size: { x: 0.35, y: 0.04, z: 0.28 }, color: 0xc0a878 },
    },
    {
      id: "talk-garvey",
      label: "Garvey Kane",
      position: { x: -2.2, y: 0.7, z: 1.4 },
      halfExtents: { x: 1.3, y: 1.2, z: 1.3 },
      action: {
        kind: "examine",
        text:
          'Kane straightens his tie. "I never went downstairs. Nora is scared and inventing stairs. I sat here, I drank cold coffee, I heard the shutter in the corridor grind. Ask Marrow — if he ever comes up from evidence."',
      },
      repeatable: true,
      visual: { kind: "none" },
    },
    door({
      id: "door-lounge-to-foyer",
      label: "Lobby",
      position: { x: 3.8, y: 1.1, z: 0 },
      targetRoomId: "manor-foyer",
      spawnPointId: "from-lounge",
    }),
  ],
  spawnPoints: [
    { id: "from-foyer", position: { x: 2.4, y: 0, z: 0 }, yaw: Math.PI / 2 },
  ],
};
