#ifndef JNR_CAMERA_H
#define JNR_CAMERA_H

#include "util/vec2.h"
#include "config.h"

typedef struct Camera {
    Vec2  pos;           /* world position of top-left corner  */
    Vec2  viewport;      /* screen dimensions in game pixels   */
    Vec2  bounds_min;    /* level bounds (top-left)            */
    Vec2  bounds_max;    /* level bounds (bottom-right)        */
    float smoothing;     /* higher = slower follow (0=instant) */
    Vec2  deadzone;      /* half-size of deadzone rect         */
    Vec2  look_ahead;    /* pixels to lead in move direction   */
    /* Zoom (used by editor; gameplay keeps 1.0) */
    float zoom;          /* 1.0 = normal, <1 = zoomed out      */
    /* Screen shake */
    float shake_timer;   /* remaining shake time               */
    float shake_intensity; /* current max pixel offset          */
    Vec2  shake_offset;  /* current frame shake displacement   */
} Camera;

void camera_init(Camera *c, float vp_w, float vp_h);
void camera_set_bounds(Camera *c, float world_w, float world_h);
void camera_follow(Camera *c, Vec2 target, Vec2 velocity, float dt);

/* Convert world position to screen position */
Vec2 camera_world_to_screen(const Camera *c, Vec2 world_pos);

/* Convert screen position to world position */
Vec2 camera_screen_to_world(const Camera *c, Vec2 screen_pos);

/* Trigger screen shake (intensity in pixels, duration in seconds) */
void camera_shake(Camera *c, float intensity, float duration);

/* Update shake (call once per frame, after camera_follow) */
void camera_update_shake(Camera *c, float dt);

#endif /* JNR_CAMERA_H */
