import type { CSSProperties } from 'react' /** 카드 색 테마. 만들 때마다 하나를 무작위로 고르고, 화면·명령(--color)에서 직접 고를 수도 있다. * tones: 날씨 타로 1·2·3번 카드 색 (hue = 카드 앞면 틀 그림을 돌릴 각도) */ type Tone = { accent: string; tint: string; hue: number } export type Theme = { id: string; name: string; paper: string; main: string; deep: string; soft: string; stage: string; second: string; tones: [Tone, Tone, Tone] } const ORANGE: Tone = { accent: '#d4552a', tint: '#fff0e5', hue: 0 } const BLUE: Tone = { accent: '#317dc6', tint: '#e6f1ff', hue: 185 } const PURPLE: Tone = { accent: '#6556ac', tint: '#eeeaff', hue: 234 } const GREEN: Tone = { accent: '#1d8a5e', tint: '#e2f6ec', hue: 120 } const PINK: Tone = { accent: '#c43d6d', tint: '#fde6ee', hue: 320 } const MUSTARD: Tone = { accent: '#a87108', tint: '#fff2cc', hue: 25 } export const THEMES: Theme[] = [ { id: 'sunset', name: '노을', paper: '#f7fbff', main: '#ff7a45', deep: '#d4552a', soft: '#ffd7bd', stage: '#e1efff', second: '#4f97e3', tones: [ORANGE, BLUE, PURPLE] }, { id: 'sky', name: '하늘', paper: '#f4f9ff', main: '#4f97e3', deep: '#2b6cb8', soft: '#cfe3fb', stage: '#e3efff', second: '#ff7a45', tones: [BLUE, GREEN, PURPLE] }, { id: 'mint', name: '민트', paper: '#f4fbf8', main: '#2fbf87', deep: '#1d8a5e', soft: '#c8f0de', stage: '#dff5ea', second: '#4f97e3', tones: [GREEN, BLUE, ORANGE] }, { id: 'berry', name: '베리', paper: '#fff7fa', main: '#ef6a96', deep: '#c43d6d', soft: '#fbd0de', stage: '#fde6ee', second: '#8b7be0', tones: [PINK, PURPLE, ORANGE] }, { id: 'lemon', name: '레몬', paper: '#fffbef', main: '#f5b82e', deep: '#a87108', soft: '#ffe7a3', stage: '#fff2cc', second: '#2fbf87', tones: [MUSTARD, GREEN, BLUE] }, { id: 'lavender', name: '라벤더', paper: '#f8f6ff', main: '#8b7be0', deep: '#6556ac', soft: '#ddd6fb', stage: '#eeeaff', second: '#ef6a96', tones: [PURPLE, PINK, BLUE] }, ] export const themeById = (id?: string) => THEMES.find((t) => t.id === id) ?? THEMES[0] export const randomTheme = (except?: string) => { const pool = THEMES.filter((t) => t.id !== except) return pool[Math.floor(Math.random() * pool.length)].id } /** .slide 에 거는 색 변수 */ export function themeVars(id?: string): CSSProperties { const t = themeById(id) return { '--paper': t.paper, '--orange': t.main, '--rust': t.deep, '--soft': t.soft, '--stage': t.stage, '--blue': t.second } as CSSProperties } export function toneVars(id: string | undefined, i: number): CSSProperties { const tone = themeById(id).tones[i] return { '--accent': tone.accent, '--tint': tone.tint, '--hue': `${tone.hue}deg` } as CSSProperties }