class_name EnvironmentConfig
extends Resource

@export_group("Day")
@export var start_time: float = 0.0 #start time of the day
@export var day_duration: float = 300.0 #Duration of a full day cycle in seconds
@export var sunrise: float = 0.25 #day_time 1.0→2.0 (night colors → morning colors)
@export var day: float = 0.45     #day_time 2.0→2.0 (stays morning/afternoon)
@export var sunset: float = 0.80  #day_time 2.0→3.0 (afternoon colors → night colors)
@export var night: float = 1.00   #day_time 3.0→3.0 (stays night)
#At wrap 1.0→0.0:        day_time stays 3.0, then fades back via sunrise

@export_group("Debug")
@export var show_day_time_debug: bool = true #enable/disable debug on screen (time, normalized time and day_time

#Ambient light color tinting for each time of day
@export_group("Directional Lights and Environment")
@export var morning_color: Color = Color(1.0, 0.9, 0.8, 1.0) #Tint for morning
@export var afternoon_color: Color = Color(1.0, 0.663, 0.366, 1.0) #Tint for afternoon (sunset)
@export var night_color: Color = Color(0.1, 0.1, 0.3, 1.0) #Tint for night

#Sun directional light rotation for each time of day
@export_group("Sun Rotation")
@export var sun_rotation_morning: Vector3 = Vector3(-15.0, 45.0, 0.0)
@export var sun_rotation_afternoon: Vector3 = Vector3(-75.0, 10.0, 0.0)
@export var sun_rotation_night: Vector3 = Vector3(-35.0, -120.0, 0.0)
#Sun light energy during night (multiplied onto base energy)
@export var night_light_energy: float = 0.3

#Camera tonemap exposure for each time of day
@export_group("General Exposition")
@export var exposure_morning: float = 1.0
@export var exposure_afternoon: float = 0.95
@export var exposure_night: float = 0.4

#Sky top color for each time of day
@export_group("Sky Colors - Top")
@export var sky_top_morning: Color = Color(0.35, 0.65, 0.9, 1.0)
@export var sky_top_afternoon: Color = Color(0.7, 0.45, 0.2, 1.0)
@export var sky_top_night: Color = Color(0.05, 0.05, 0.15, 1.0)

#Sky horizon color for each time of day
@export_group("Sky Color - Horizon")
@export var sky_horizon_morning: Color = Color(0.75, 0.85, 0.95, 1.0)
@export var sky_horizon_afternoon: Color = Color(0.95, 0.65, 0.35, 1.0)
@export var sky_horizon_night: Color = Color(0.15, 0.1, 0.25, 1.0)

#Top gradient color used by the trunk shader
@export_subgroup("Gradient - Top")
@export var grad_top_morning: Color = Color(0.8, 0.4, 0.2, 1.0)
@export var grad_top_afternoon: Color = Color(0.2, 0.3, 0.5, 1.0)
@export var grad_top_night: Color = Color(0.05, 0.05, 0.1, 1.0)

#Bottom gradient color used by the trunk shader
@export_subgroup("Gradient - Bottom")
@export var grad_bot_morning: Color = Color(0.5, 0.2, 0.1, 1.0)
@export var grad_bot_afternoon: Color = Color(0.1, 0.15, 0.25, 1.0)
@export var grad_bot_night: Color = Color(0.01, 0.01, 0.05, 1.0)

#Gradient blend intensity for the trunk shader
@export_subgroup("Gradient Intensity")
@export var grad_intensity_morning: float = 0.5
@export var grad_intensity_afternoon: float = 0.3
@export var grad_intensity_night: float = 0.8

#Volumetric fog color and density for each time of day
@export_group("Fog")
@export var fog_color_morning: Color = Color(0.75, 0.85, 0.95, 1.0)
@export var fog_color_afternoon: Color = Color(0.95, 0.65, 0.35, 1.0)
@export var fog_color_night: Color = Color(0.15, 0.1, 0.25, 1.0)
@export var fog_density_morning: float = 0.005
@export var fog_density_afternoon: float = 0.002
@export var fog_density_night: float = 0.015

#Glow (bloom) intensity for each time of day
@export_group("Glow")
@export var glow_morning: float = 1.2
@export var glow_afternoon: float = 0.8
@export var glow_night: float = 2.0

#Post-process effect toggles (initial values)
@export_group("Post Process")
@export var enable_dust: bool = false #Floating dust particles overlay
@export var enable_blur: bool = false #Screen blur effect
@export var enable_environment_shadows: bool = true #Cloud shadow projection on terrain
@export var blur_amount: float = 0.6

@export_group("Dust")
@export var dust_color: Color = Color(1.0, 0.456, 0.125, 0.6) #dust color
@export var dust_speed: float = 0.15 #dust speed
@export var dust_density: float = 1.0 #dust density
@export var dust_size_min: float = 0.02; #dust min size
@export var dust_size_max: float = 0.2; #dust max size

#Shader materials used by weather and sky systems
@export_group("Environment Materials")
@export var material_fog: ShaderMaterial #Fog overlay shader material
@export var material_drops: StandardMaterial3D #Rain drops material (albedo tinted by sky)
@export var material_clouds: ShaderMaterial #Cloud layer shader material

#Rain weather settings
@export_group("Rain")
@export var rain_mode_color: Color = Color(0.5, 0.6, 0.7, 1.0) #Sky/light darkening color during rain
@export var rain_fade_time: float = 5.0 #Seconds for rain particles to fade in/out
@export var rain_audio_volume_db: float = -10.0 #Target rain loop volume in decibels
@export var puddle_form_time: float = 15.0 #Seconds for puddles to fully form
@export var puddle_dry_time: float = 20.0 #Seconds for puddles to fully dry after rain stops

#Storm settings (applied on top of rain when storm is active)
@export_group("Storm")
@export var storm_rain_intensity_multiplier: float = 1.5 #Rain intensity target during storm (1.0 = normal rain)
@export var storm_mode_color: Color = Color(0.476, 0.531, 0.639, 1.0) #Additional sky darkening color during storm

#Lightning and thunder configuration
@export_group("Lightning and Thunders")
@export var lightning_min_time: float = 5.0 #Minimum seconds between lightning strikes
@export var lightning_max_time: float = 15.0 #Maximum seconds between lightning strikes
@export var lightning_color: Color = Color(1.0, 1.0, 0.8, 1.0) #Lightning sprite tint color
@export var lightning_min: int = 1 #Minimum number of lightning bolts per strike event
@export var lightning_max: int = 3 #Maximum number of lightning bolts per strike event
@export var lightning_scale_min: float = 1.0 #Minimum random scale of lightning sprite
@export var lightning_scale_max: float = 3.0 #Maximum random scale of lightning sprite
@export var lightning_texture: String = "res://core/daynight/lighting_albedo.png" # Lightning bolt texture path
@export var weather_event_interval: float = 8.0 #Base interval between weather events
@export var thunder_audio_volume_db: float = 0.0 #Target thunder volume in decibels

#God rays spawned after rain or at morning
@export_group("God Rays")
@export var godray_max_rain: int = 8 #Max number of god rays spawned after rain stops
@export var godray_spawn_radius: float = 15.0 #Horizontal spawn radius around the camera
@export var godray_spawn_offset: Vector3 = Vector3(15.0, 5.0, -15.0) #Position offset from camera
@export var godray_rotation_degrees: Vector3 = Vector3(-45.0, 45.0, -30.0) #Rotation of the god ray mesh
@export var godray_spawn_height: float = 5.0 #Y world position where god rays spawn
@export var godray_scale: Vector3 = Vector3(2.0, 6.0, 2.0) #Scale of the god ray mesh

#Snow settings
@export_group("Snow")
@export var snow_amount: float = 0.0 #Initial snow coverage amount (0.0 = none, 1.0 = full)
@export var snow_transaction_time: float = 10.0 #Seconds for snow shader to fully transition in/out
@export var snow_fade_time: float = 5.0 #Seconds for snow particles to fade in/out
@export var snow_threshold: float = 0.4 #Normal Y threshold for snow accumulation on surfaces
@export var snow_accumulation_speed: float = 0.02 #Accumulation speed: 0.1 -> 10s, 0.05 -> 20s, 0.02 -> 50s, 0.2 -> 5s
@export var snow_melt_speed: float = 0.05 #Speed at which accumulated snow melts away
@export var snow_color: Color = Color(0.9, 0.95, 1.0) #Albedo color of snow on surfaces
@export var snow_mode_color: Color = Color(0.556, 0.62, 0.683, 1.0) #Sky/light darkening color during snow

#Wind settings
@export_group("Wind")
@export var wind_amount: int = 100 #Number of wind particles
@export var wind_spawn_ray: float = 25.0 #Horizontal spawn radius (emission box XZ extents)
@export var wind_spawn_height: float = 8.0 #Vertical spawn range (emission box Y extent)
@export var wind_direction: Vector2 = Vector2(0.5, 0.4) #Global wind direction (XZ)
@export var wind_speed: float = 0.2 #Global wind animation speed
@export var wind_scale: float = 0.025 #Global wind noise scale
@export var wind_strength: float = 0.6 #Global wind displacement strength
@export var cloud_scale: float = 0.5 #Cloud noise scale in sky shader
@export var cloud_speed: float = 0.05 #Cloud movement speed in sky shader
@export_range(0.01, 1.0) var cloud_scale_envshadows_rate: float = 0.01 #Cloud scale multiplier for environment shadows
@export_range(0.01, 1.0) var cloud_speed_envshadows_rate: float = 0.5 #Cloud speed multiplier for environment shadows

#Firefly settings (visible only at night)
@export_group("Fireflies")
@export var fireflies_amount: int = 60 #Number of firefly particles
@export var fireflies_spawn_ray: float = 20.0 #Horizontal spawn radius
@export var fireflies_spawn_height: float = 3.0 #Vertical spawn range
