/**
 * Theme engine type definitions.
 *
 * Public types for the CounterMeasure design-system theme engine. The engine
 * resolves a high-level `Theme` object into low-level CSS variables and
 * `data-*` attributes on `:root`.
 *
 * @countermeasure-platform/web-components/services/theme-engine
 */

export type ColorMode = 'dark' | 'light' | 'monokai' | 'glass'
export type AccentId = 'orange' | 'cyan' | 'violet' | 'rose' | 'emerald' | 'amber'
export type FontId = 'inter' | 'sora' | 'roboto' | 'jetbrainsMono' | 'system'
export type IconSetId = 'lucide' | 'heroicons' | 'phosphor' | 'material' | 'countermeasure'
export type Density = 'compact' | 'comfortable' | 'cozy'

/**
 * The full theme state. Persisted to `localStorage` and applied to `:root`
 * by `applyTheme`.
 */
export interface Theme {
  /** Color mode (drives `data-theme` + `--bg-glass*` tints). */
  mode: ColorMode
  /** Accent palette (drives `data-accent` + `--brand*` / `--accent-rgb`). */
  accent: AccentId
  /** Font stack (drives `--font-display` / `--font-mono`). */
  font: FontId
  /** Icon set (drives `data-icon-set` + `--icon-stroke-width` / `--icon-linecap` / `--icon-linejoin`). */
  iconSet: IconSetId
  /** UI density (drives `data-density` + `--density-row`). */
  density: Density
  /** Corner radius in px (0..32). Drives `--radius-sm/md/lg/xl`. */
  radius: number
  /** Surface translucency 0..0.30. Drives `--bg-glass*` rgba alphas. */
  transparency: number
  /** Per-slot icon overrides keyed by `IconUsage.id`. */
  iconOverrides: Record<string, string>
}

export interface ColorModeMeta {
  id: ColorMode
  label: string
  icon: string
  swatch: [string, string, string]
  surfaceTint: string
}

export interface AccentPalette {
  id: AccentId
  label: string
  brand: string
  hot: string
  soft: string
  rgb: string
}

export interface FontStack {
  id: FontId
  label: string
  sample: string
  description: string
  display: string
  mono: string
  google: string | null
}

export interface IconSet {
  id: IconSetId
  label: string
  description: string
  strokeWidth: number
  linecap: 'round' | 'square' | 'butt'
  linejoin: 'round' | 'miter' | 'bevel'
  brand: boolean
}

export interface IconUsage {
  id: string
  label: string
  defaultIcon: string
  alternates: string[]
}

export interface ThemePreset {
  id: string
  label: string
  description: string
  theme: Theme
}
