//! # Mawida
//!
//! A small, code-first game framework in Rust. The programming model is XNA's
//! (a `Game` you implement with `update`/`draw` callbacks, a `Context` carrying
//! the hardware handles), running on a modern `wgpu` backend.
//!
//! Mawida is **2D today**, but every foundational layer is built so that the
//! move to 3D is *additive* and the move to VR is *reachable*:
//!
//! - math is always 3D (`glam` `Vec3`/`Mat4`/`Quat`), never restricted to `Vec2`
//! - drawing goes through a [`Camera`] (2D is just the orthographic case)
//! - drawables are `mesh + material + transform` (a sprite is the trivial
//!   textured-unlit quad), never a privileged `draw_sprite(x, y)` primitive
//! - "present" sits behind the [`RenderBackend`] trait, so it can later become
//!   "submit to the XR compositor" instead of "present to the surface"
//! - the renderer takes a camera per draw, so N cameras / per-eye view-projection
//!   is natural rather than a refactor
//!
//! See `handoff.md` for the full design rationale and the wgpu/Vulkan/OpenXR
//! strategy. See `CLAUDE.md` for build commands and working conventions.
//!
//! ## Module map
//!
//! Pure-logic core (no GPU, no window, unit-testable):
//! - [`math`]      re-exported `glam` types
//! - [`time`]      [`GameTime`] and a frame [`Clock`]
//! - [`color`]     [`Color`]
//! - [`transform`] [`Transform`] (TRS -> `Mat4`)
//! - [`input`]     [`InputState`] snapshot (own key/button enums, winit-free)
//! - [`camera`]    [`Camera`] trait, [`OrthographicCamera`], [`PerspectiveCamera`]
//! - [`drawable`]  [`Vertex`], [`Mesh`], [`Material`], [`Drawable`]
//! - [`content`]   [`ContentManager`] and asset handles
//! - [`error`]     [`MawidaError`] / [`Result`]
//!
//! Runtime layer (behind the `runtime` feature: winit + wgpu):
//! - [`app`]       the `Game` trait, [`Context`], and `run`
//! - `gfx`         the [`RenderBackend`] seam and its wgpu implementation

pub mod color;
pub mod camera;
pub mod content;
pub mod drawable;
pub mod error;
pub mod input;
pub mod math;
pub mod animation;

#[cfg(feature = "physics")]
pub mod physics;

#[cfg(feature = "gamepad")]
pub mod gamepad;
pub mod collide;
pub mod script;
pub mod text;
pub mod time;
pub mod transform;
pub mod world;

pub mod gfx;

#[cfg(feature = "runtime")]
pub mod app;

#[cfg(feature = "runtime")]
pub mod module;

#[cfg(feature = "audio")]
pub mod audio;

// --- flat re-exports for ergonomics ---
pub use camera::{Camera, FollowCamera2d, OrbitCamera, OrthographicCamera, PerspectiveCamera};
pub use color::Color;
pub use content::{ContentManager, TextureId};
pub use drawable::{Drawable, Material, Mesh, Sprite, Vertex};
pub use error::{MawidaError, Result};
pub use input::{InputState, Key, MouseButton};
pub use animation::{Animation, AnimationMode};
pub use collide::{Aabb, Circle, Obb, SpatialGrid};
pub use content::SpriteSheet;
pub use drawable::flip_x;
pub use script::{Bundle, Command, Component, NullHost, ScriptHost, WorldView};
pub use text::{Font, Glyph, MonoFont, Text};
pub use time::{Clock, GameTime};
pub use transform::Transform;
pub use world::{Entity, World};

#[cfg(feature = "runtime")]
pub use text::{draw_text, draw_text_variable, render_text};

pub use gfx::RenderBackend;

#[cfg(feature = "runtime")]
pub use app::{run, App, AppConfig, Assets, Context, DirectionalLight, Game, RenderQueue, System};

#[cfg(feature = "runtime")]
pub use module::Module;

#[cfg(feature = "runtime")]
pub use script::ScriptModule;

#[cfg(all(feature = "runtime", feature = "audio"))]
pub use module::{AudioModule, PlaySound, PlaySoundFile};

pub use math::{Mat4, Quat, Vec2, Vec3, Vec4};

/// The clear color XNA used by default. A small homage; also a sanity check
/// that your render loop is actually running.
pub const CORNFLOWER_BLUE: Color = Color::rgb(0.392, 0.584, 0.929);
