/*
 * SPDX-License-Identifier: GPL-3.0-or-later
 */
package com.runicgateway.app.ui.theme

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

/**
 * The M5 type scale, drawn in whichever three families the shard resolved to
 * (THEMING_AND_NAV.md §5.3).
 *
 * Only the family moves. Every size, weight, line height and tracking below is
 * the M5 value from the "Runic Gateway Screens" mockup, so `ShardTypeface.Shipped`
 * — an unthemed instance, a backend that predates the feature, a settings call
 * that failed — reproduces the pre-M12 scale exactly. [androidx.compose.material3.Typography]
 * implements `equals`, so AC-1 asserts that in one comparison.
 *
 * The three groups map onto the three roles verbatim: [ShardTypeface.display]
 * carries the engraved display/headline/title block, [ShardTypeface.serif] the
 * parchment body copy, and [ShardTypeface.sans] the letter-spaced
 * label/meta/button roles.
 */
internal fun shardTypography(faces: ShardTypeface) = Typography(
    // Display / headline / title — the engraved serif role
    displayLarge = TextStyle(
        fontFamily = faces.display, fontWeight = FontWeight.SemiBold,
        fontSize = 40.sp, lineHeight = 46.sp, letterSpacing = 0.4.sp,
    ),
    displayMedium = TextStyle(
        fontFamily = faces.display, fontWeight = FontWeight.SemiBold,
        fontSize = 32.sp, lineHeight = 40.sp, letterSpacing = 0.3.sp,
    ),
    displaySmall = TextStyle(
        fontFamily = faces.display, fontWeight = FontWeight.SemiBold,
        fontSize = 28.sp, lineHeight = 36.sp, letterSpacing = 0.2.sp,
    ),
    headlineLarge = TextStyle(
        fontFamily = faces.display, fontWeight = FontWeight.SemiBold,
        fontSize = 26.sp, lineHeight = 34.sp, letterSpacing = 0.2.sp,
    ),
    headlineMedium = TextStyle(
        fontFamily = faces.display, fontWeight = FontWeight.SemiBold,
        fontSize = 24.sp, lineHeight = 32.sp, letterSpacing = 0.2.sp,
    ),
    headlineSmall = TextStyle(
        fontFamily = faces.display, fontWeight = FontWeight.SemiBold,
        fontSize = 22.sp, lineHeight = 28.sp, letterSpacing = 0.2.sp,
    ),
    titleLarge = TextStyle(
        fontFamily = faces.display, fontWeight = FontWeight.SemiBold,
        fontSize = 20.sp, lineHeight = 26.sp, letterSpacing = 0.2.sp,
    ),
    titleMedium = TextStyle(
        fontFamily = faces.display, fontWeight = FontWeight.SemiBold,
        fontSize = 17.sp, lineHeight = 24.sp, letterSpacing = 0.15.sp,
    ),
    titleSmall = TextStyle(
        fontFamily = faces.display, fontWeight = FontWeight.SemiBold,
        fontSize = 15.sp, lineHeight = 22.sp, letterSpacing = 0.1.sp,
    ),
    // Body — the parchment serif role
    bodyLarge = TextStyle(
        fontFamily = faces.serif, fontWeight = FontWeight.Normal,
        fontSize = 16.sp, lineHeight = 26.sp, letterSpacing = 0.15.sp,
    ),
    bodyMedium = TextStyle(
        fontFamily = faces.serif, fontWeight = FontWeight.Normal,
        fontSize = 15.sp, lineHeight = 24.sp, letterSpacing = 0.15.sp,
    ),
    bodySmall = TextStyle(
        fontFamily = faces.serif, fontWeight = FontWeight.Normal,
        fontSize = 13.sp, lineHeight = 20.sp, letterSpacing = 0.2.sp,
    ),
    // Labels / meta / buttons — the sans role, letter-spaced
    labelLarge = TextStyle(
        fontFamily = faces.sans, fontWeight = FontWeight.Bold,
        fontSize = 14.sp, lineHeight = 18.sp, letterSpacing = 0.45.sp,
    ),
    labelMedium = TextStyle(
        fontFamily = faces.sans, fontWeight = FontWeight.Medium,
        fontSize = 12.sp, lineHeight = 16.sp, letterSpacing = 0.4.sp,
    ),
    labelSmall = TextStyle(
        fontFamily = faces.sans, fontWeight = FontWeight.Medium,
        fontSize = 11.sp, lineHeight = 15.sp, letterSpacing = 0.5.sp,
    ),
)
