// ============================================
// Shared color palettes — calm vintage
//   PAPER_COLORS : telegram paper tints (per-member, distinguishes sender)
//   TYPE_COLORS  : typewriter body tints (per-member-per-box, distinguishes box)
// The typewriter photo is a saturated seafoam-green Olivetti on a near-white
// ground, so hue-rotate/saturate recolors the body while leaving the ground
// and gray keys neutral. `filter` is applied to the <img>; `tint` is the
// accent hex used for dots / glows in the UI.
// ============================================

window.PAPER_COLORS = [
  { id: 'ivory',  label: '아이보리', bg: '#f2e9d3', edge: '#e1d3b0', ink: '#3a3428' },
  { id: 'blush',  label: '블러시',   bg: '#efdcd5', edge: '#e0c2b7', ink: '#4a3630' },
  { id: 'sage',   label: '세이지',   bg: '#dde4d3', edge: '#c6d2b7', ink: '#33402f' },
  { id: 'powder', label: '파우더',   bg: '#d8e1e7', edge: '#bfced7', ink: '#2c3a42' },
  { id: 'lilac',  label: '라일락',   bg: '#e1dae7', edge: '#ccc1d8', ink: '#3a3244' },
  { id: 'wheat',  label: '밀짚',     bg: '#ebdfbe', edge: '#d9cb9f', ink: '#403721' },
  { id: 'clay',   label: '클레이',   bg: '#ecdbc9', edge: '#dbc4ab', ink: '#463726' },
  { id: 'mist',   label: '미스트',   bg: '#d6e4dc', edge: '#bdd4c8', ink: '#2c3f37' },
];

window.TYPE_COLORS = [
  { id: 'green',    label: '세이지그린', tint: '#7f9c86', filter: 'none' },
  { id: 'teal',     label: '틸',        tint: '#5f8f93', filter: 'hue-rotate(22deg) saturate(1.05)' },
  { id: 'blue',     label: '스틸블루',   tint: '#5f7699', filter: 'hue-rotate(58deg) saturate(1.05)' },
  { id: 'violet',   label: '바이올렛',   tint: '#7d6f9c', filter: 'hue-rotate(108deg) saturate(1)' },
  { id: 'burgundy', label: '버건디',     tint: '#9c5b57', filter: 'hue-rotate(202deg) saturate(1.12)' },
  { id: 'rust',     label: '러스트',     tint: '#a5714c', filter: 'hue-rotate(232deg) saturate(1.05)' },
  { id: 'mustard',  label: '머스터드',   tint: '#ab9048', filter: 'hue-rotate(262deg) saturate(1.12) brightness(1.03)' },
  { id: 'charcoal', label: '차콜',       tint: '#63636a', filter: 'saturate(0.16) brightness(0.98)' },
];

window.getPaper = (id) => window.PAPER_COLORS.find((p) => p.id === id) || window.PAPER_COLORS[0];
window.getType  = (id) => window.TYPE_COLORS.find((t) => t.id === id) || window.TYPE_COLORS[0];

// Auto-pick the next unused paper color for a new member (falls back to cycling)
window.pickPaper = (usedIds = []) => {
  const free = window.PAPER_COLORS.find((p) => !usedIds.includes(p.id));
  return (free || window.PAPER_COLORS[usedIds.length % window.PAPER_COLORS.length]).id;
};
window.pickType = (usedIds = []) => {
  const free = window.TYPE_COLORS.find((t) => !usedIds.includes(t.id));
  return (free || window.TYPE_COLORS[usedIds.length % window.TYPE_COLORS.length]).id;
};
