// Main app — routing, language, tweaks
const { useState: useState_, useEffect: useEffect_ } = React;
const TWEAK_DEFAULTS = /*EDITMODE-BEGIN*/{
"palette": "champagne",
"displayFont": "Cormorant Garamond",
"bodyFont": "Inter",
"language": "en"
}/*EDITMODE-END*/;
const PALETTES = {
champagne: {
name: 'Champagne',
vars: { '--paper': '#F6F1EA', '--cream': '#EFE7DB', '--blush': '#EBD7CF', '--ink': '#1F1B17', '--noir': '#161311', '--muted': '#7A6E62', '--line': '#D9CFC1', '--hairline': '#E5DCCE', '--champagne': '#B58552', '--champagne-deep': '#8E6638' },
},
rose: {
name: 'Dusty Rose',
vars: { '--paper': '#F7F0EC', '--cream': '#EFE0DA', '--blush': '#E8C7BE', '--ink': '#2A1F1C', '--noir': '#1A1311', '--muted': '#7E665E', '--line': '#DEC8BE', '--hairline': '#E9D7CD', '--champagne': '#B47C6C', '--champagne-deep': '#8A574A' },
},
sage: {
name: 'Olive & Cream',
vars: { '--paper': '#F4F2EA', '--cream': '#E7E5D5', '--blush': '#D8DAC2', '--ink': '#1F2018', '--noir': '#13140E', '--muted': '#6E7060', '--line': '#CDCFBA', '--hairline': '#DEE0CB', '--champagne': '#7E8A5C', '--champagne-deep': '#5A663D' },
},
noir: {
name: 'Noir & Gold',
vars: { '--paper': '#EFEAE0', '--cream': '#E2D8C5', '--blush': '#D9C9AE', '--ink': '#161311', '--noir': '#0D0B0A', '--muted': '#6E6253', '--line': '#C9BBA0', '--hairline': '#DAC9AB', '--champagne': '#C09553', '--champagne-deep': '#8A6730' },
},
};
const DISPLAY_FONTS = ['Cormorant Garamond', 'Playfair Display', 'DM Serif Display', 'EB Garamond'];
const BODY_FONTS = ['Inter', 'Work Sans', 'Outfit'];
function App() {
const [tweaks, setTweak] = useTweaks(TWEAK_DEFAULTS);
const [route, setRoute] = useState_('home');
const [routeParams, setRouteParams] = useState_({});
const [lang, setLang] = useState_(tweaks.language || 'en');
const t = I18N[lang];
// Apply palette
useEffect_(() => {
const p = PALETTES[tweaks.palette] || PALETTES.champagne;
Object.entries(p.vars).forEach(([k, v]) => document.documentElement.style.setProperty(k, v));
}, [tweaks.palette]);
// Apply fonts via inline style
useEffect_(() => {
let id = document.getElementById('__dyn_fonts');
if (!id) { id = document.createElement('link'); id.id = '__dyn_fonts'; id.rel = 'stylesheet'; document.head.appendChild(id); }
const d = encodeURIComponent(tweaks.displayFont).replace(/%20/g, '+');
const b = encodeURIComponent(tweaks.bodyFont).replace(/%20/g, '+');
id.href = `https://fonts.googleapis.com/css2?family=${d}:ital,wght@0,300;0,400;0,500;1,300;1,400&family=${b}:wght@300;400;500&display=swap`;
let s = document.getElementById('__dyn_font_style');
if (!s) { s = document.createElement('style'); s.id = '__dyn_font_style'; document.head.appendChild(s); }
s.textContent = `
body { font-family: '${tweaks.bodyFont}', system-ui, sans-serif; }
.serif { font-family: '${tweaks.displayFont}', 'Times New Roman', serif; }
[dir="rtl"] body { font-family: 'Noto Kufi Arabic', '${tweaks.bodyFont}', sans-serif; }
[dir="rtl"] .serif { font-family: 'Noto Kufi Arabic', '${tweaks.displayFont}', serif !important; font-weight: 500 !important; }
`;
}, [tweaks.displayFont, tweaks.bodyFont]);
// Apply lang/dir
useEffect_(() => {
document.documentElement.lang = lang;
document.documentElement.dir = lang === 'ar' ? 'rtl' : 'ltr';
}, [lang]);
// Reset scroll on route change
useEffect_(() => { window.scrollTo({ top: 0, behavior: 'instant' }); }, [route, routeParams.id]);
const navigate = (r, params = {}) => { setRoute(r); setRouteParams(params); };
const onEnquire = () => navigate('contact');
// Decide if hero is dark (homepage and detail page have transparent dark hero)
const heroDark = route === 'home' || route === 'detail';
let page;
if (route === 'home') page =