#version 330

in vec3 fragWorldPos;
in vec3 fragNormal;
in vec4 fragColor;
in float fragPulse;

out vec4 finalColor;

void main() {
    vec3 normal = normalize(fragNormal);
    vec3 lightDir = normalize(vec3(0.4, 0.8, 0.25));
    float diffuse = max(dot(normal, lightDir), 0.0);
    float rim = pow(1.0 - max(normal.z, 0.0), 2.0);

    vec3 baseA = vec3(0.10, 0.85, 1.00);
    vec3 baseB = vec3(1.00, 0.20, 0.55);
    vec3 pulseColor = mix(baseA, baseB, fragPulse);

    float band = 0.5 + 0.5 * sin(fragWorldPos.y * 4.0 + fragWorldPos.x * 2.5);
    vec3 color = pulseColor * (0.30 + diffuse * 0.85);
    color += baseA * rim * 0.45;
    color += band * 0.08;

    finalColor = vec4(color * fragColor.rgb, 1.0);
}
