package wang.yaojia.webterm.designsystem

import androidx.compose.material3.Typography
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp

/**
 * # Typography — the type ramp (mirrors iOS `DS.Typography`).
 *
 * The proportional ramp is Material 3's default [Typography] (scales with the
 * system font-size setting, the a11y "keep it scalable" point). Numbers /
 * dimensions / cost / `cols×rows` / timestamps use [monoTabular]: a monospace
 * family with **tabular figures** (`tnum`) so columns line up and digits don't
 * jitter as values change — the analogue of iOS `DS.Typography.mono(_:)`.
 */
public object WebTermType {

    /** Material 3 default ramp — proportional, system-scalable. */
    public val ramp: Typography = Typography()

    /**
     * Monospace + tabular-figures style at the given [size]. Use for anything
     * numeric that must align or not jump: `cols×rows`, device/client counts,
     * `$cost`, context %, relative timestamps.
     */
    public fun monoTabular(size: Int = 13): TextStyle = TextStyle(
        fontFamily = FontFamily.Monospace,
        fontFeatureSettings = TABULAR_FIGURES,
        fontSize = size.sp,
    )

    /** The canonical meta-number style: caption-sized mono + tabular. */
    public val metaMono: TextStyle = monoTabular(size = 12)

    /** The terminal-line style: mono at body size (the emulator overrides glyphs). */
    public val terminal: TextStyle = TextStyle(
        fontFamily = FontFamily.Monospace,
        fontFeatureSettings = TABULAR_FIGURES,
        fontSize = 14.sp,
        fontWeight = FontWeight.Normal,
    )

    /** OpenType feature string enabling tabular (fixed-advance) numerals. */
    private const val TABULAR_FIGURES: String = "tnum"
}
