package wang.yaojia.webterm.designsystem

import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test

/**
 * Regression guard for the FROZEN design-system spec (plan §"Design system",
 * mirrors iOS `DS`). The expected values are transcribed INDEPENDENTLY from the
 * spec, so any accidental drift in [DesignSpec] fails here. Pure JVM — no device.
 */
class DesignSpecTest {

    @Test
    fun `amber-gold accent hex matches the frozen desktop palette`() {
        // #E3A64A dark (web --accent) / #C9892F light (web --accent-2); gold needs
        // dark ink #1A1305 on top (web --on-accent).
        assertEquals(0xFFE3A64AL, DesignSpec.ACCENT_DARK)
        assertEquals(0xFFC9892FL, DesignSpec.ACCENT_LIGHT)
        assertEquals(0xFF1A1305L, DesignSpec.ON_ACCENT)
    }

    @Test
    fun `semantic status colors match the frozen web status set`() {
        assertEquals(0xFF46D07FL, DesignSpec.STATUS_WORKING) // web --green
        assertEquals(0xFFF5B14CL, DesignSpec.STATUS_WAITING) // web --amber
        assertEquals(0xFFFF6B6BL, DesignSpec.STATUS_STUCK) // web --red
    }

    @Test
    fun `terminal canvas colors are the fixed desktop values`() {
        assertEquals(0xFF100F0DL, DesignSpec.TERMINAL_BACKGROUND) // web --bg
        assertEquals(0xFFECE9E3L, DesignSpec.TERMINAL_FOREGROUND) // web --text
        assertEquals(0xFFE3A64AL, DesignSpec.TERMINAL_CARET) // gold caret == accent
    }

    @Test
    fun `spacing scale is exactly 2-4-8-12-16-20-24`() {
        val scale = listOf(
            DesignSpec.SPACE_XS2,
            DesignSpec.SPACE_XS4,
            DesignSpec.SPACE_SM8,
            DesignSpec.SPACE_MD12,
            DesignSpec.SPACE_LG16,
            DesignSpec.SPACE_XL20,
            DesignSpec.SPACE_XXL24,
        )
        assertEquals(listOf(2f, 4f, 8f, 12f, 16f, 20f, 24f), scale)
    }

    @Test
    fun `radius, stroke, opacity and hit-target tokens match the spec`() {
        assertEquals(8f, DesignSpec.RADIUS_SM8)
        assertEquals(12f, DesignSpec.RADIUS_MD12)
        assertEquals(16f, DesignSpec.RADIUS_LG16)
        assertEquals(999f, DesignSpec.RADIUS_PILL)
        assertEquals(1f, DesignSpec.STROKE_HAIRLINE)
        assertEquals(0.45f, DesignSpec.OPACITY_STALE)
        assertEquals(0.55f, DesignSpec.OPACITY_EXITED)
        assertEquals(0.72f, DesignSpec.OPACITY_PRESSED)
        assertEquals(44f, DesignSpec.MIN_HIT_TARGET)
    }
}
