/* ===========================================================================
 * Politick — design tokens  ·  "Broadcast · Soft red"
 * ---------------------------------------------------------------------------
 * Typed mirror of tokens.css (and DESIGN.md). One source, three encodings —
 * KEEP IN EXACT SYNC: same hexes, same scale values, same names (camelCased).
 * Import in Svelte/JS where a token must be read in script (e.g. canvas, charts,
 * generated SVG). For styling, prefer the CSS custom properties in tokens.css.
 * =========================================================================== */

/** Brand core — FIXED. */
export const color = {
  // core
  ink: "#1C2024", // primary text & strokes · CR 14.8 on paper (AAA)
  paper: "#F6F3EC", // primary surface (warm paper)
  accent: "#B84A38", // THE soft red — used SPARINGLY · CR 4.65 on paper (AA)
  alert: "#D7372A", // brighter red — RESERVED for error/alert states only

  // neutral ramp (warm greys derived from ink↔paper)
  inkStrong: "#3A3B3C", // secondary headings / strong text · CR 10.1 (AAA)
  muted: "#5C564E", // muted & secondary text, captions · CR 6.54 (AA)
  faint: "#8C8A84", // disabled, placeholder, NON-essential UI · CR 3.1
  rule: "#D8D2C4", // hairlines, dividers, table borders
  ruleFaint: "#E6E2D9", // very subtle dividers, zebra rows
  paperRaised: "#FBFAF5", // raised surface (tint, never shadow)

  // accent companions
  accentStrong: "#A23E2D", // pressed/active accent on paper
  accentTint: "#EFD9D2", // faint accent wash (selection / highlight) on paper
} as const;

/** Dark / inverted surface — same roles, ink-surface values (data-theme="ink"). */
export const colorOnInk = {
  paper: "#1C2024",
  paperRaised: "#25292E",
  ink: "#F6F3EC", // text · CR 14.8 (AAA)
  inkStrong: "#E4E0D8",
  muted: "#A6A39C", // CR ~6.4
  faint: "#6E726F",
  rule: "#3C4147",
  ruleFaint: "#2A2E33",
  accent: "#CF6A55", // lifted soft red · CR 4.56 on ink (AA)
  accentStrong: "#B84A38",
  accentTint: "#3A2A26",
} as const;

/**
 * Party-dot palette — PENDING the real party register. These are arbitrary muted
 * placeholders; party colours are DATA, not brand, and appear ONLY as ≤8px dots
 * (never fills). Replace with real party colours before launch.
 */
export const party = {
  maxDotSize: 8, // px — hard cap on party-dot diameter
  placeholders: {
    a: "#8A5A44",
    b: "#4E6E8A",
    c: "#6E8A5A",
    d: "#8A6E4E",
    e: "#6E5A8A",
    f: "#7A7A72",
  },
} as const;

export const font = {
  display:
    '"Playfair Display", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif',
  sans: '"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif',
  mono: '"IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace',
} as const;

export const weight = {
  regular: 400,
  medium: 500,
  semibold: 600,
  bold: 700,
} as const;

/** Type scale — Major Third (1.250), base 16px. 2xs/xs/sm are off-grid UI sizes. */
export const type = {
  scaleRatio: 1.25, // Major Third
  size: {
    "2xs": "0.6875rem", // 11px — kickers / eyebrow labels
    xs: "0.8125rem", // 13px — captions, mono citations
    sm: "0.875rem", // 14px — secondary UI, dense tables
    base: "1rem", // 16px — body
    md: "1.25rem", // 20px — large body / sub-head
    lg: "1.5625rem", // 25px — h3
    xl: "1.953rem", // 31.25px — h2
    "2xl": "2.441rem", // 39px — h1
    "3xl": "3.052rem", // 49px — page hero
    "4xl": "3.815rem", // 61px — wordmark / masthead
  },
  leading: {
    display: 1.08,
    tight: 1.2,
    lead: 1.4,
    body: 1.6,
    ui: 1.5,
  },
  tracking: {
    display: "-0.01em",
    wordmark: "0.005em",
    body: "0",
    caps: "0.14em",
    tagline: "0.18em",
  },
  features: {
    tabular: '"tnum" 1, "lnum" 1', // tabular lining figures (data/mono/tables)
    body: '"kern" 1, "liga" 1',
  },
} as const;

export const layout = {
  measure: "66ch",
  contentMax: "75rem", // 1200px
  contentNarrow: "42rem", // 672px
  gutter: "1.5rem", // 24px
  gridColumns: 12,
} as const;

/** Spacing scale — base unit 4px. */
export const space = {
  0: "0",
  1: "0.25rem", // 4
  2: "0.5rem", // 8
  3: "0.75rem", // 12
  4: "1rem", // 16
  5: "1.5rem", // 24
  6: "2rem", // 32
  7: "3rem", // 48
  8: "4rem", // 64
  9: "6rem", // 96
  10: "8rem", // 128
} as const;

/** Shape — border-radius is 0 everywhere by decree. */
export const shape = {
  radius: 0,
  hairline: "1px",
  ruleW: "1.5px",
  ruleWStrong: "2px",
} as const;

/** Elevation — flat. Separation by rules + surface tint, never shadow. */
export const elevation = "none" as const;

export const motion = {
  fast: "120ms",
  base: "200ms",
  slow: "320ms",
  ease: "cubic-bezier(0.2, 0, 0, 1)",
  easeInOut: "cubic-bezier(0.4, 0, 0.2, 1)",
  pulse: "1200ms", // one-shot broadcast pulse on load
} as const;

export const tokens = {
  color,
  colorOnInk,
  party,
  font,
  weight,
  type,
  layout,
  space,
  shape,
  elevation,
  motion,
} as const;

export default tokens;
