package dev.kaizen.app

import androidx.compose.ui.graphics.colorspace.ColorSpaces
import dev.kaizen.app.ui.theme.Amber
import dev.kaizen.app.ui.theme.AmberDeep
import dev.kaizen.app.ui.theme.BlobAmber
import dev.kaizen.app.ui.theme.BlobCoral
import dev.kaizen.app.ui.theme.BlobHoney
import dev.kaizen.app.ui.theme.BlobTeal
import dev.kaizen.app.ui.theme.DarkMuted
import dev.kaizen.app.ui.theme.DarkStroke
import dev.kaizen.app.ui.theme.DarkText
import dev.kaizen.app.ui.theme.LightBackground
import dev.kaizen.app.ui.theme.LightMuted
import dev.kaizen.app.ui.theme.LightStroke
import dev.kaizen.app.ui.theme.LightSurface
import dev.kaizen.app.ui.theme.LightSurfaceVariant
import dev.kaizen.app.ui.theme.LightText
import dev.kaizen.app.ui.theme.Obsidian
import dev.kaizen.app.ui.theme.ObsidianElevated
import dev.kaizen.app.ui.theme.ObsidianInput
import dev.kaizen.app.ui.theme.OnAmber
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test

class ColorPipelineTest {

    @Test
    fun `brand amber is in DisplayP3 color space`() {
        assertEquals(ColorSpaces.DisplayP3, Amber.colorSpace)
        assertEquals(ColorSpaces.DisplayP3, AmberDeep.colorSpace)
        assertEquals(ColorSpaces.DisplayP3, OnAmber.colorSpace)
    }

    @Test
    fun `dark scheme colors are in DisplayP3`() {
        listOf(Obsidian, ObsidianElevated, ObsidianInput, DarkText, DarkMuted, DarkStroke)
            .forEach { color ->
                assertEquals(
                    "Color $color should be DisplayP3",
                    ColorSpaces.DisplayP3,
                    color.colorSpace,
                )
            }
    }

    @Test
    fun `light scheme colors are in DisplayP3`() {
        listOf(LightBackground, LightSurface, LightSurfaceVariant, LightText, LightMuted, LightStroke)
            .forEach { color ->
                assertEquals(
                    "Color $color should be DisplayP3",
                    ColorSpaces.DisplayP3,
                    color.colorSpace,
                )
            }
    }

    @Test
    fun `blob colors are in DisplayP3`() {
        listOf(BlobAmber, BlobCoral, BlobHoney, BlobTeal).forEach { color ->
            assertEquals(ColorSpaces.DisplayP3, color.colorSpace)
        }
    }

    @Test
    fun `amber has expected approximate values`() {
        assertTrue("Red should be around 0.878", Amber.red in 0.87f..0.89f)
        assertTrue("Green should be around 0.635", Amber.green in 0.62f..0.65f)
        assertTrue("Blue should be around 0.243", Amber.blue in 0.23f..0.26f)
        assertEquals(1f, Amber.alpha, 0.001f)
    }

    @Test
    fun `stroke colors have transparency`() {
        assertTrue("DarkStroke should be transparent", DarkStroke.alpha < 1f)
        assertTrue("LightStroke should be transparent", LightStroke.alpha < 1f)
    }

    @Test
    fun `no pure black or pure white in neutrals`() {
        assertTrue("Obsidian should not be pure black", Obsidian.red > 0f || Obsidian.green > 0f || Obsidian.blue > 0f)
        assertTrue("LightBackground should not be pure white", LightBackground.red < 1f || LightBackground.green < 1f)
    }
}
