# Call, Video Frame, Camera, Speaker, Screen Share, and In-Call Chat Fixes

This patch updates the Spaceship call experience for desktop and mobile browsers.

## What changed

### 1. Video call frame fit
- Rebuilt the video area into a WhatsApp-style call frame.
- The remote video now uses the full call stage.
- The local camera preview is shown as a picture-in-picture overlay.
- Both local and remote videos use `object-fit: contain` so the camera feed is not cropped.
- Mobile uses a portrait-friendly frame and the whole call modal remains scrollable.

### 2. Camera priority / switch camera
- Added a **Camera priority** selector:
  - Front / selfie camera first
  - Back / rear camera first
  - Browser default camera
  - Detected physical camera devices after permission is granted
- Added **Switch Cam** for live video calls.
- The selected camera preference is saved in `localStorage`.

### 3. Loudspeaker / earpiece option
- The speaker control now remains visible as **Loudspeaker / Earpiece**.
- If the browser supports audio-output routing, the app tries to switch the output.
- If the browser blocks routing, the app shows a clear fallback telling the user to use phone/device audio controls.

### 4. Screen sharing
- Desktop/laptop screen sharing uses `navigator.mediaDevices.getDisplayMedia()`.
- The code retries with basic constraints if advanced display constraints fail.
- Unsupported mobile browsers now show a clearer status instead of failing silently.
- Important: iOS Safari and many mobile browsers do not expose true screen capture to normal websites. That limitation cannot be fully fixed with PHP/JavaScript alone; a native app/WebView plugin is required for full mobile screen capture.

### 5. In-call chat emojis and GIFs
- Added emoji button inside the in-call chatbox.
- Added GIF button inside the in-call chatbox.
- GIF sending reuses the existing encrypted message/GIF backend.
- GIFs/images now render inside the in-call chat instead of appearing only as `[image]`.

## Files changed

- `index.php`
- `css/app.css`
- `js/app.js`

## Validation performed

- `php -l` passed for all PHP files.
- `node --check js/app.js` passed.
- ZIP integrity was checked after packaging.
