use crate::image::MeasurementReport;
use crate::types::{AgentBrief, EvidenceCard};

pub fn evidence_cards(report: &MeasurementReport) -> Vec<EvidenceCard> {
    let confidence = report
        .rankings
        .first()
        .map_or(0.0, |ranking| ranking.confidence);
    vec![
        EvidenceCard {
            kind: "facial_contrast_v1".to_string(),
            summary: "Measured directional feature contrast informs goal fit.".to_string(),
            confidence,
        },
        EvidenceCard {
            kind: "skin_uniformity_v1".to_string(),
            summary: "Skin-region measurements inform penalty and uncertainty only.".to_string(),
            confidence,
        },
        EvidenceCard {
            kind: "calibration_uncertainty_v1".to_string(),
            summary: format!(
                "Capture mode and quality produce confidence {:.2}.",
                confidence
            ),
            confidence,
        },
    ]
}

pub fn agent_brief(report: &MeasurementReport) -> AgentBrief {
    let uncertainty = report.rankings.first().map_or(
        "No ranking because required measurements are missing.".to_string(),
        |ranking| {
            format!(
                "Confidence {:.2}; interpret as goal-specific uncertainty, not personal worth.",
                ranking.confidence
            )
        },
    );
    AgentBrief { summary: "Ranking is based on measured color contrast, candidate color, and requested goal vector.".to_string(), uncertainty }
}

pub fn contains_prohibited_claim(text: &str) -> bool {
    let lower = text.to_ascii_lowercase();
    [
        "beauty score",
        "attractiveness",
        "race",
        "medical diagnosis",
        "identity recognition",
        "skin-tone-to-palette",
    ]
    .iter()
    .any(|phrase| lower.contains(phrase))
}
