// Theme system — editorial, warm, paper-like.
// Multiple palettes + font pairings toggled via Tweaks.

const THEMES = {
  sand: {
    name: 'Sand (Terracotta)',
    paper:   'oklch(0.965 0.012 80)',
    paper2:  'oklch(0.94 0.018 75)',
    ink:     'oklch(0.22 0.025 55)',
    ink2:    'oklch(0.42 0.02 60)',
    muted:   'oklch(0.62 0.018 65)',
    rule:    'oklch(0.82 0.02 70)',
    accent:  'oklch(0.56 0.14 40)',       // terracotta
    accent2: 'oklch(0.68 0.13 55)',
    tint:    'oklch(0.92 0.04 55)',        // soft sand tint for blocks
    good:    'oklch(0.52 0.10 150)',
    warn:    'oklch(0.58 0.14 75)',
  },
  plum: {
    name: 'Plum (Deep)',
    paper:   'oklch(0.965 0.008 320)',
    paper2:  'oklch(0.93 0.014 320)',
    ink:     'oklch(0.22 0.04 325)',
    ink2:    'oklch(0.42 0.04 325)',
    muted:   'oklch(0.60 0.03 325)',
    rule:    'oklch(0.82 0.015 320)',
    accent:  'oklch(0.42 0.14 335)',
    accent2: 'oklch(0.58 0.12 340)',
    tint:    'oklch(0.92 0.03 325)',
    good:    'oklch(0.52 0.10 155)',
    warn:    'oklch(0.58 0.14 55)',
  },
  forest: {
    name: 'Forest (Moss)',
    paper:   'oklch(0.965 0.012 110)',
    paper2:  'oklch(0.93 0.018 115)',
    ink:     'oklch(0.22 0.03 150)',
    ink2:    'oklch(0.40 0.03 150)',
    muted:   'oklch(0.58 0.025 130)',
    rule:    'oklch(0.80 0.02 120)',
    accent:  'oklch(0.42 0.09 150)',
    accent2: 'oklch(0.58 0.10 140)',
    tint:    'oklch(0.92 0.04 130)',
    good:    'oklch(0.50 0.12 150)',
    warn:    'oklch(0.60 0.14 70)',
  },
  ink: {
    name: 'Ink (Mono)',
    paper:   'oklch(0.97 0.004 90)',
    paper2:  'oklch(0.93 0.005 90)',
    ink:     'oklch(0.16 0.005 90)',
    ink2:    'oklch(0.38 0.005 90)',
    muted:   'oklch(0.58 0.005 90)',
    rule:    'oklch(0.82 0.005 90)',
    accent:  'oklch(0.20 0.005 90)',        // black-ink
    accent2: 'oklch(0.45 0.02 60)',
    tint:    'oklch(0.92 0.008 90)',
    good:    'oklch(0.42 0.08 150)',
    warn:    'oklch(0.52 0.12 50)',
  },
};

const FONTS = {
  newsreader: {
    name: 'Newsreader × Instrument Sans',
    display: "'Newsreader', Georgia, serif",
    sans: "'Instrument Sans', system-ui, sans-serif",
    mono: "'JetBrains Mono', ui-monospace, monospace",
    displayWeight: 500,
    displayTracking: '-0.02em',
  },
  instrument: {
    name: 'Instrument Serif × Inter Tight',
    display: "'Instrument Serif', 'Times New Roman', serif",
    sans: "'Inter Tight', system-ui, sans-serif",
    mono: "'JetBrains Mono', ui-monospace, monospace",
    displayWeight: 400,
    displayTracking: '-0.03em',
  },
  fraunces: {
    name: 'Fraunces × Instrument Sans',
    display: "'Fraunces', Georgia, serif",
    sans: "'Instrument Sans', system-ui, sans-serif",
    mono: "'JetBrains Mono', ui-monospace, monospace",
    displayWeight: 500,
    displayTracking: '-0.025em',
  },
};

// React context for theme
const ThemeContext = React.createContext({ t: THEMES.sand, f: FONTS.newsreader, paper: true });

function useTheme() { return React.useContext(ThemeContext); }

Object.assign(window, { THEMES, FONTS, ThemeContext, useTheme });
