package com.fabledsword.minstrel.theme

import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp

/**
 * Raw color values for the dark surface cohort. Source of truth:
 * `flutter_client/shared/fabledsword.tokens.json` (dark block).
 *
 * Token names are **semantic roles**, not literal colors. In dark
 * mode, `parchment` is light text on dark surfaces (#E8E4D8); in
 * [FabledSwordLightTokens], `parchment` is dark text on light
 * surfaces (#14171A). Consume tokens through [LocalFabledSwordTheme],
 * never reference these raw objects from UI code — the mode-switch
 * stops working otherwise.
 */
object FabledSwordDarkTokens {
    val obsidian = Color(0xFF14171A)
    val iron = Color(0xFF1E2228)
    val slate = Color(0xFF2C313A)
    val pewter = Color(0xFF3F4651)
    val parchment = Color(0xFFE8E4D8)
    val vellum = Color(0xFFC2BFB4)
    val ash = Color(0xFF9C9A92)
}

/**
 * Raw color values for the light surface cohort. Mirrors
 * `fabledsword.tokens.json`'s light block.
 *
 * Same names as [FabledSwordDarkTokens] but inverted semantics — see
 * that doc-comment.
 */
object FabledSwordLightTokens {
    val obsidian = Color(0xFFF8F5EE)
    val iron = Color(0xFFECE6D5)
    val slate = Color(0xFFDCD3BD)
    val pewter = Color(0xFFB8AE94)
    val parchment = Color(0xFF14171A)
    val vellum = Color(0xFF2C313A)
    val ash = Color(0xFF5C6068)
}

/**
 * Mode-independent (flat) tokens. Action colors live here; they're
 * the same in light + dark. Per the design system: Moss / Bronze /
 * Oxblood are action colors; the forest-teal accent is for
 * highlights / non-action emphasis and must NEVER be used as a
 * button color.
 */
object FabledSwordFlatTokens {
    val moss = Color(0xFF4A5D3F)
    val bronze = Color(0xFF8B7355)
    val oxblood = Color(0xFF6B2118)
    val warning = Color(0xFF8B6F1E)
    val error = Color(0xFFC04A1F)
    val info = Color(0xFF3D5A6E)
    val accent = Color(0xFF4A6B5C)
    val onAction = Color(0xFFE8E4D8)

    val radiusSm = 4.dp
    val radiusMd = 8.dp
    val radiusLg = 12.dp
    val radiusXl = 16.dp
}

/**
 * Back-compat alias mirroring the Flutter `FabledSwordTokens` class
 * (dark surfaces + flat). Existing call sites that read
 * `FabledSwordTokens.iron` continue to work but bind to dark-mode
 * values regardless of system mode. New code should read from
 * `LocalFabledSwordTheme.current` instead. Removed in a follow-up
 * once all widgets are migrated.
 */
@Deprecated(
    "Use LocalFabledSwordTheme.current — see FabledSwordTheme.kt",
    level = DeprecationLevel.WARNING,
)
object FabledSwordTokens {
    val obsidian = FabledSwordDarkTokens.obsidian
    val iron = FabledSwordDarkTokens.iron
    val slate = FabledSwordDarkTokens.slate
    val pewter = FabledSwordDarkTokens.pewter
    val parchment = FabledSwordDarkTokens.parchment
    val vellum = FabledSwordDarkTokens.vellum
    val ash = FabledSwordDarkTokens.ash
    val moss = FabledSwordFlatTokens.moss
    val bronze = FabledSwordFlatTokens.bronze
    val oxblood = FabledSwordFlatTokens.oxblood
    val warning = FabledSwordFlatTokens.warning
    val error = FabledSwordFlatTokens.error
    val info = FabledSwordFlatTokens.info
    val accent = FabledSwordFlatTokens.accent
    val onAction = FabledSwordFlatTokens.onAction
    val radiusSm = FabledSwordFlatTokens.radiusSm
    val radiusMd = FabledSwordFlatTokens.radiusMd
    val radiusLg = FabledSwordFlatTokens.radiusLg
    val radiusXl = FabledSwordFlatTokens.radiusXl
}
