// Copyright (C) 2026 Jason M. Schwefel. All Rights Reserved.
package com.coldboreballisticsllc.scopedope.ui.theme

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.text.googlefonts.Font
import androidx.compose.ui.text.googlefonts.GoogleFont
import androidx.compose.ui.unit.em
import androidx.compose.ui.unit.sp
import com.coldboreballisticsllc.scopedope.R

// ── Google Fonts provider ─────────────────────────────────────────────────────
private val fontProvider = GoogleFont.Provider(
    providerAuthority = "com.google.android.gms.fonts",
    providerPackage   = "com.google.android.gms",
    certificates      = R.array.com_google_android_gms_fonts_certs,
)

private val ibmPlexMono = GoogleFont("IBM Plex Mono")
private val inter       = GoogleFont("Inter")

val PlexMono: FontFamily = FontFamily(
    Font(googleFont = ibmPlexMono, fontProvider = fontProvider, weight = FontWeight.Normal),
    Font(googleFont = ibmPlexMono, fontProvider = fontProvider, weight = FontWeight.Bold),
)

val InterSans: FontFamily = FontFamily(
    Font(googleFont = inter, fontProvider = fontProvider, weight = FontWeight.Normal),
    Font(googleFont = inter, fontProvider = fontProvider, weight = FontWeight.Medium),
    Font(googleFont = inter, fontProvider = fontProvider, weight = FontWeight.SemiBold),
    Font(googleFont = inter, fontProvider = fontProvider, weight = FontWeight.Bold),
)

// ── Named TextStyle constants (used directly in composables) ──────────────────

val HeroElevationStyle = TextStyle(
    fontFamily  = PlexMono,
    fontWeight  = FontWeight.Bold,
    fontSize    = 74.sp,
    lineHeight  = 74.sp,
    letterSpacing = (-0.02).em,
)

val HeroWindStyle = TextStyle(
    fontFamily  = PlexMono,
    fontWeight  = FontWeight.Bold,
    fontSize    = 38.sp,
    lineHeight  = 38.sp,
    letterSpacing = 0.02.em,
)

// Unified data font: table cells, DOPE display values, field inputs
val DataValueStyle = TextStyle(
    fontFamily  = PlexMono,
    fontWeight  = FontWeight.Bold,
    fontSize    = 20.sp,
    lineHeight  = 20.sp,
)

val TableHeaderStyle = TextStyle(
    fontFamily    = PlexMono,
    fontWeight    = FontWeight.Bold,
    fontSize      = 18.sp,
    letterSpacing = 0.10.em,
)

val PanelLabelStyle = TextStyle(
    fontFamily    = PlexMono,
    fontWeight    = FontWeight.Bold,
    fontSize      = 15.sp,
    letterSpacing = 0.14.em,
    lineHeight    = 15.sp,
)

val ContextStripStyle = TextStyle(
    fontFamily    = PlexMono,
    fontWeight    = FontWeight.Bold,
    fontSize      = 14.sp,
    letterSpacing = 0.08.em,
)

val FieldLabelStyle = TextStyle(
    fontFamily    = PlexMono,
    fontWeight    = FontWeight.Normal,
    fontSize      = 12.sp,
    letterSpacing = 0.10.em,
)

val NavLabelStyle = TextStyle(
    fontFamily    = PlexMono,
    fontWeight    = FontWeight.Normal,
    fontSize      = 12.sp,
    letterSpacing = 0.10.em,
)

val ActionButtonStyle = TextStyle(
    fontFamily    = PlexMono,
    fontWeight    = FontWeight.Bold,
    fontSize      = 30.sp,
    letterSpacing = 0.07.em,
)

val BodyStyle = TextStyle(
    fontFamily = InterSans,
    fontWeight = FontWeight.Normal,
    fontSize   = 17.sp,
    lineHeight = 24.sp,
)

val BodySubStyle = TextStyle(
    fontFamily = InterSans,
    fontWeight = FontWeight.Normal,
    fontSize   = 14.sp,
    lineHeight = 20.sp,
)

val HeroSubStyle = TextStyle(
    fontFamily    = PlexMono,
    fontWeight    = FontWeight.Normal,
    fontSize      = 13.sp,
    letterSpacing = 0.06.em,
)

// Settings: +25% body scale
val SettingsBodyStyle = TextStyle(
    fontFamily = InterSans,
    fontWeight = FontWeight.Medium,
    fontSize   = 21.sp,
    lineHeight = 26.sp,
)

val SettingsBodySubStyle = TextStyle(
    fontFamily = InterSans,
    fontWeight = FontWeight.Normal,
    fontSize   = 18.sp,
    lineHeight = 24.sp,
)

val BadgeStyle = TextStyle(
    fontFamily    = PlexMono,
    fontWeight    = FontWeight.Bold,
    fontSize      = 11.sp,
    letterSpacing = 0.08.em,
)

// ── M3 Typography (for Scaffold, Dialog, etc.) ────────────────────────────────

val AppTypography = Typography(
    // TopAppBar title
    titleLarge = TextStyle(
        fontFamily  = InterSans,
        fontWeight  = FontWeight.SemiBold,
        fontSize    = 30.sp,
        lineHeight  = 36.sp,
        color       = ColorTextPrimary,
    ),
    titleMedium = TextStyle(
        fontFamily  = InterSans,
        fontWeight  = FontWeight.SemiBold,
        fontSize    = 17.sp,
        lineHeight  = 22.sp,
        color       = ColorTextPrimary,
    ),
    bodyLarge = TextStyle(
        fontFamily = InterSans,
        fontWeight = FontWeight.Normal,
        fontSize   = 17.sp,
        lineHeight = 24.sp,
        color      = ColorTextPrimary,
    ),
    bodyMedium = TextStyle(
        fontFamily = InterSans,
        fontWeight = FontWeight.Normal,
        fontSize   = 14.sp,
        lineHeight = 20.sp,
        color      = ColorTextPrimary,
    ),
    bodySmall = TextStyle(
        fontFamily = InterSans,
        fontWeight = FontWeight.Normal,
        fontSize   = 14.sp,
        lineHeight = 20.sp,
        color      = ColorTextPrimary,
    ),
    labelLarge = TextStyle(
        fontFamily  = InterSans,
        fontWeight  = FontWeight.Medium,
        fontSize    = 15.sp,
        lineHeight  = 20.sp,
        color       = ColorTextMuted,
    ),
    labelMedium = TextStyle(
        fontFamily  = PlexMono,
        fontWeight  = FontWeight.Normal,
        fontSize    = 12.sp,
        lineHeight  = 16.sp,
        color       = ColorTextMuted,
    ),
    labelSmall = TextStyle(
        fontFamily  = PlexMono,
        fontWeight  = FontWeight.Normal,
        fontSize    = 11.sp,
        lineHeight  = 14.sp,
        color       = ColorTextMuted,
    ),
)
