// palettes.jsx — Palette catalog + live applier.
//
// Each palette supplies the same shape as the original P1686 object. When the
// user picks one, applyPalette() mutates window.P1686 in place and the App
// re-renders, so every `P1686.xxx` lookup picks up the new value.

const PALETTES = [
  {
    key: 'plum',
    name: 'Plum',
    note: 'Nilar Campus — the default. Deep plum-black with violet and electric blue.',
    swatches: ['#08050f', '#130b22', '#8b5cf6', '#6a8aff', '#f4f1ff'],
    values: {
      bg:        '#08050f',
      bg2:       '#0d0817',
      surface:   '#130b22',
      surfaceHi: '#1a1230',
      line:      'rgba(244,241,255,0.08)',
      lineHi:    'rgba(244,241,255,0.14)',
      text:      '#f4f1ff',
      muted:     'rgba(244,241,255,0.55)',
      mute2:     'rgba(244,241,255,0.35)',
      violet:    '#8b5cf6',
      violetHi:  '#a98aff',
      blue:      '#6a8aff',
      blueHi:    '#9bb1ff',
      moss:      '#6bbe9c',
    },
  },
  {
    key: 'slate',
    name: 'Slate',
    note: 'Cool, technical. Deep navy with electric blue and cyan.',
    swatches: ['#04060c', '#0e1828', '#5b8dff', '#3bd4e8', '#eef4ff'],
    values: {
      bg:        '#04060c',
      bg2:       '#08101e',
      surface:   '#0e1828',
      surfaceHi: '#152237',
      line:      'rgba(238,244,255,0.08)',
      lineHi:    'rgba(238,244,255,0.14)',
      text:      '#eef4ff',
      muted:     'rgba(238,244,255,0.55)',
      mute2:     'rgba(238,244,255,0.35)',
      violet:    '#5b8dff',
      violetHi:  '#8eb1ff',
      blue:      '#3bd4e8',
      blueHi:    '#7be7f3',
      moss:      '#7bd5a4',
    },
  },
  {
    key: 'forest',
    name: 'Forest',
    note: 'Warm dark with green undertone. Moss primary, warm gold accent.',
    swatches: ['#070f0a', '#0f1e18', '#7dd4a3', '#d4b67d', '#f1f4ee'],
    values: {
      bg:        '#070f0a',
      bg2:       '#0a1612',
      surface:   '#0f1e18',
      surfaceHi: '#152821',
      line:      'rgba(241,244,238,0.08)',
      lineHi:    'rgba(241,244,238,0.14)',
      text:      '#f1f4ee',
      muted:     'rgba(241,244,238,0.55)',
      mute2:     'rgba(241,244,238,0.35)',
      violet:    '#7dd4a3',
      violetHi:  '#a4e6c0',
      blue:      '#d4b67d',
      blueHi:    '#e8ccac',
      moss:      '#7dd4a3',
    },
  },
  {
    key: 'burgundy',
    name: 'Burgundy',
    note: 'Wine and terracotta. The most editorial / financial.',
    swatches: ['#0d0608', '#23131a', '#d4905b', '#b06e85', '#f9f0ec'],
    values: {
      bg:        '#0d0608',
      bg2:       '#180a0d',
      surface:   '#23131a',
      surfaceHi: '#2c1a22',
      line:      'rgba(249,240,236,0.08)',
      lineHi:    'rgba(249,240,236,0.14)',
      text:      '#f9f0ec',
      muted:     'rgba(249,240,236,0.55)',
      mute2:     'rgba(249,240,236,0.35)',
      violet:    '#d4905b',
      violetHi:  '#e8af80',
      blue:      '#b06e85',
      blueHi:    '#c894a8',
      moss:      '#9caf83',
    },
  },
  {
    key: 'carbon',
    name: 'Carbon',
    note: 'Near-monochrome. Neutral charcoal with a single signal accent.',
    swatches: ['#070707', '#161616', '#ff6a3d', '#e0e0e0', '#fafafa'],
    values: {
      bg:        '#070707',
      bg2:       '#0e0e0e',
      surface:   '#161616',
      surfaceHi: '#1f1f1f',
      line:      'rgba(255,255,255,0.07)',
      lineHi:    'rgba(255,255,255,0.13)',
      text:      '#fafafa',
      muted:     'rgba(255,255,255,0.55)',
      mute2:     'rgba(255,255,255,0.32)',
      violet:    '#ff6a3d',
      violetHi:  '#ff8d6a',
      blue:      '#e0e0e0',
      blueHi:    '#ffffff',
      moss:      '#a8a8a8',
    },
  },
  {
    key: 'bone',
    name: 'Bone (light)',
    note: 'Warm cream with ink. Hg-direct light direction.',
    swatches: ['#f4efe6', '#fbf7ef', '#7c2eff', '#3055d0', '#19140e'],
    values: {
      bg:        '#f4efe6',
      bg2:       '#ebe5d8',
      surface:   '#fbf7ef',
      surfaceHi: '#ffffff',
      line:      'rgba(25,20,14,0.08)',
      lineHi:    'rgba(25,20,14,0.16)',
      text:      '#19140e',
      muted:     'rgba(25,20,14,0.58)',
      mute2:     'rgba(25,20,14,0.38)',
      violet:    '#7c2eff',
      violetHi:  '#9b4dff',
      blue:      '#3055d0',
      blueHi:    '#4669e0',
      moss:      '#2f7a55',
    },
  },
];

// Mutate window.P1686 in place so every render after this point picks up
// the new values. Caller is expected to bump a React key to force the tree
// to re-render.
function applyPalette(key) {
  const p = PALETTES.find((x) => x.key === key) || PALETTES[0];
  Object.assign(window.P1686, p.values);
}

Object.assign(window, { PALETTES, applyPalette });
