// brand.jsx — Steaks N Buns shared atoms, i18n, brand visuals
// Exports to window for use across other Babel script files.

// ─── i18n dictionary ──────────────────────────────────────────────────────
const SNB_STRINGS = {
  // brand
  brand_tag:         { en: 'BURGERS · FRIES · STRIPS',  ar: 'برجر · بطاطس · شرائح' },
  since:             { en: "MADINAH'S FAVOURITE",      ar: 'الأكثر تفضيلاً في المدينة' },

  // nav
  nav_home:          { en: 'Home',     ar: 'الرئيسية' },
  nav_menu:          { en: 'Menu',     ar: 'المنيو' },
  nav_order:         { en: 'Order Now', ar: 'اطلب الآن' },
  nav_gallery:       { en: 'Gallery',  ar: 'المعرض' },
  nav_contact:       { en: 'Contact',  ar: 'تواصل' },
  nav_about:         { en: 'About',    ar: 'من نحن' },
  nav_location:      { en: 'Location', ar: 'الموقع' },

  // hero
  hero_kicker:       { en: 'OPEN TILL 2AM · MADINAH',    ar: 'مفتوح حتى ٢ صباحاً · المدينة المنورة' },
  hero_h1_food:      { en: 'Everything you crave. And more.', ar: 'كل اللي تشتهيه عندنا وأكثر' },
  hero_sub_food:     { en: 'Burgers, fries & maple strips. Done right.', ar: 'برجر، فرايز وميبل ستربس. بإتقان.' },
  hero_h1_combo:     { en: 'Everything you crave. And more.', ar: 'كل اللي تشتهيه عندنا وأكثر' },
  hero_sub_combo:    { en: 'Maple crispy fixes your mood.', ar: 'الميبل كرسبي يظبط مودك.' },
  hero_h1_late:      { en: "Taste your way. Till 2 AM.", ar: 'طعم على كيفك. حتى ٢ صباحاً.' },
  hero_sub_late:     { en: "Open every night. Bring friends.", ar: 'مفتوحون كل ليلة. تعال مع أصحابك.' },
  hero_h1_family:    { en: 'Your favourite spot in Madinah', ar: 'مكانك المفضل في المدينة' },
  hero_sub_family:   { en: "Family room, kids meals, calm vibes.", ar: 'قسم عائلي، وجبات أطفال، أجواء هادئة.' },
  cta_order:         { en: 'Order Now',    ar: 'اطلب الآن' },
  cta_menu:          { en: 'View Menu',    ar: 'تصفح المنيو' },
  cta_call:          { en: 'Call',         ar: 'اتصل' },
  cta_directions:    { en: 'Directions',   ar: 'الاتجاهات' },
  cta_book:          { en: 'Book a Table', ar: 'احجز طاولة' },

  // trust bar
  trust_rating:      { en: '4.3 Google',         ar: '٤٫٣ على قوقل' },
  trust_reviews:     { en: '586 reviews',     ar: '٥٨٦ تقييم' },
  trust_late:        { en: 'Open till 2AM',      ar: 'حتى ٢ صباحاً' },
  trust_delivery:    { en: 'Delivery available', ar: 'توصيل متاح' },
  trust_price:       { en: 'From 17 SAR',          ar: 'من ١٧ ريال' },

  // order modes
  order_mode_h:      { en: 'How do you want it?', ar: 'كيف تبيها؟' },
  mode_delivery:     { en: 'Delivery',     ar: 'توصيل' },
  mode_takeaway:     { en: 'Collection',   ar: 'استلام' },
  mode_dinein:       { en: 'Dine-in',      ar: 'جلوس' },
  mode_nocontact:    { en: 'No-contact',   ar: 'بدون تلامس' },
  mode_delivery_sub: { en: '25–35 min · 5+ km radius',  ar: '٢٥–٣٥ دقيقة · ٥+ كم' },
  mode_takeaway_sub: { en: 'Ready in 10 min',           ar: 'جاهز خلال ١٠ دقائق' },
  mode_dinein_sub:   { en: 'Family room available',     ar: 'قسم عائلي متوفر' },
  mode_nocontact_sub:{ en: 'Left at the door',          ar: 'يُترك عند الباب' },

  // sections
  bestsellers_h:     { en: "What everyone's ordering", ar: 'الأكثر طلباً' },
  bestsellers_sub:   { en: "The ones we're known for.", ar: 'الأطباق اللي نُعرف فيها.' },
  usage_h:           { en: 'A burger for every hour', ar: 'برجر لكل وقت' },
  usage_day_h:       { en: 'Lunch sorted', ar: 'الغداء جاهز' },
  usage_day_sub:     { en: 'In and out in 15.', ar: 'تدخل وتطلع خلال ١٥ دقيقة.' },
  usage_night_h:     { en: 'Late-night cravings', ar: 'وجبات سهرة' },
  usage_night_sub:   { en: "We're still grilling.", ar: 'لسه نشوي.' },
  family_h:          { en: 'Family approved', ar: 'مناسب للعائلة' },
  family_sub:        { en: 'Separate room. Kids meals. Calm vibes.', ar: 'قسم منفصل. وجبات أطفال. أجواء هادئة.' },
  reviews_h:         { en: "What Madinah's saying", ar: 'وش يقول أهل المدينة' },
  reviews_sub:       { en: "Don't take our word for it.", ar: 'لا تأخذ كلامنا. شف بنفسك.' },
  location_h:        { en: 'Come by. Or we come to you.', ar: 'تعالوا، أو نوصلكم' },
  parking_h:         { en: 'Parking', ar: 'مواقف' },
  parking_street:    { en: 'Free street parking', ar: 'مواقف شارع مجانية' },
  parking_lot:       { en: 'Free private lot',    ar: 'موقف خاص مجاني' },
  parking_space:     { en: 'Plenty of space',     ar: 'مساحة وفيرة' },
  hours_h:           { en: 'Opening hours', ar: 'أوقات العمل' },
  hours_weekday:     { en: 'Sat — Wed', ar: 'السبت — الأربعاء' },
  hours_weekend:     { en: 'Thu — Fri', ar: 'الخميس — الجمعة' },
  hours_weekday_t:   { en: '12:00 — 2:00 AM', ar: '١٢٫٠٠ — ٢٫٠٠ ص' },
  hours_weekend_t:   { en: '12:00 — 3:00 AM', ar: '١٢٫٠٠ — ٣٫٠٠ ص' },
  final_cta_h:       { en: 'Hungry? Order in minutes.', ar: 'جائع؟ اطلب الآن.' },
  final_cta_sub:     { en: 'Delivery, collection or dine-in.', ar: 'توصيل، استلام، أو جلوس.' },

  // menu
  menu_h:            { en: 'The full menu', ar: 'المنيو كامل' },
  menu_sub:          { en: 'Prices in SAR · calories shown', ar: 'الأسعار بالريال · السعرات مذكورة' },
  cat_all:           { en: 'All',         ar: 'الكل' },
  cat_burgers:       { en: 'Burgers',     ar: 'برجر' },
  cat_sandwiches:    { en: 'Sandwiches',  ar: 'ساندوتشات' },
  cat_appetizers:    { en: 'Appetizers',  ar: 'المقبلات' },
  cat_drinks:        { en: 'Drinks',      ar: 'المشروبات' },
  cat_kids:          { en: "Kids' Meals", ar: 'وجبات الأطفال' },
  cat_sauces:        { en: 'Sauces',      ar: 'صوص' },
  add:               { en: 'Add',         ar: 'أضف' },
  cal:               { en: 'Cal',         ar: 'سعرة' },
  sar:               { en: 'SAR',         ar: 'ر.س' },

  // about
  about_kicker:      { en: 'OUR STORY', ar: 'قصتنا' },
  about_h:           { en: 'Burgers worth the bun.', ar: 'برجر يستحق الخبزة.' },
  about_p1:          { en: 'Started in a small Madinah corner with one griddle, three sauces, and a loud opinion about buns. Sixteen years later — same opinion, more griddles, much more sauce.', ar: 'بدأنا من ركن صغير في المدينة بمشواة واحدة، ثلاث صوصات، ورأي قوي بالخبز. مرت ١٦ سنة — نفس الرأي، مشوايات أكثر، صوصات أكثر بكثير.' },
  values_h:          { en: 'What we won\'t skip', ar: 'الأشياء اللي ما نقصرفيها' },
  value_1_h:         { en: 'Fresh',  ar: 'طازج' },
  value_1_p:         { en: 'Patties pressed every morning, not pre-frozen.', ar: 'لحم يضغط كل صباح، مو مجمد.' },
  value_2_h:         { en: 'Fast',   ar: 'سريع' },
  value_2_p:         { en: '10 minutes from order to bag, no shortcuts on flavour.', ar: '١٠ دقائق من الطلب للكيس، بدون تنازل عن الطعم.' },
  value_3_h:         { en: 'Consistent', ar: 'ثابت' },
  value_3_p:         { en: 'Tuesday burger should match Saturday burger. Always.', ar: 'برجر الثلاثاء يشبه برجر السبت. دائماً.' },
  stats_reviews:     { en: 'Google reviews', ar: 'تقييم قوقل' },
  stats_rating:      { en: 'Google rating', ar: 'تقييم قوقل' },
  stats_late:        { en: 'Open till', ar: 'مفتوح حتى' },
  stats_location:    { en: 'Madinah, KSA', ar: 'المدينة المنورة' },

  // gallery
  gallery_h:         { en: 'The good stuff', ar: 'الأشياء الحلوة' },
  gallery_sub:       { en: 'Customers, plates, late-night runs.', ar: 'زبائن، أطباق، سهرات.' },
  follow_us:         { en: 'Follow @steaksnbuns', ar: 'تابعنا @steaksnbuns' },

  // contact
  contact_h:         { en: 'Find us. Call us. Order.', ar: 'تواصل، اتصل، اطلب.' },
  contact_phone_l:   { en: 'Phone', ar: 'الهاتف' },
  contact_addr_l:    { en: 'Address', ar: 'العنوان' },
  contact_addr:      { en: 'Quba Road, Al Aziziyah · Madinah, Saudi Arabia', ar: 'طريق قباء، العزيزية · المدينة المنورة' },
  contact_form_h:    { en: 'Got a question?', ar: 'عندك سؤال؟' },
  form_name:         { en: 'Your name', ar: 'الاسم' },
  form_phone:        { en: 'Phone number', ar: 'رقم الجوال' },
  form_msg:          { en: 'How can we help?', ar: 'كيف نقدر نخدمك؟' },
  form_send:         { en: 'Send message', ar: 'إرسال' },
  pay_h:             { en: 'Payment methods', ar: 'وسائل الدفع' },
  pay_card:          { en: 'Card', ar: 'بطاقة' },
  pay_nfc:           { en: 'NFC tap', ar: 'NFC' },
  pay_cash:          { en: 'Cash', ar: 'كاش' },
  pay_apple:         { en: 'Apple Pay', ar: 'Apple Pay' },
  pay_stc:           { en: 'STC Pay', ar: 'STC Pay' },
  delivery_apps_h:   { en: 'Or order via', ar: 'أو اطلب عبر' },
  faq_h:             { en: 'Quick questions', ar: 'أسئلة سريعة' },
  faq_q1: { en: 'How late are you open?',  ar: 'متى تسكرون؟' },
  faq_a1: { en: 'Every night till 2 AM. Thursdays and Fridays till 3.', ar: 'كل ليلة حتى ٢ صباحاً. الخميس والجمعة حتى ٣.' },
  faq_q2: { en: 'Do you deliver?',         ar: 'هل عندكم توصيل؟' },
  faq_a2: { en: 'Yes — via HungerStation and Keeta.', ar: 'نعم — عبر هنقرستيشن وكيتا.' },
  faq_q3: { en: 'Family room?',            ar: 'في قسم عائلي؟' },
  faq_a3: { en: "Yes — separate, kids-welcome, no booking needed.", ar: 'نعم — منفصل، مرحب بالأطفال، بدون حجز.' },
  faq_q4: { en: 'Is there parking?',       ar: 'في موقف؟' },
  faq_a4: { en: 'Free private lot + street parking. Usually space, even late.', ar: 'موقف خاص مجاني + مواقف شارع. غالباً متوفر، حتى متأخراً.' },

  // sticky bottom
  sticky_order: { en: 'Order',  ar: 'اطلب' },
  sticky_call:  { en: 'Call',   ar: 'اتصل' },
  sticky_menu:  { en: 'Menu',   ar: 'منيو' },
};

function snbT(key, lang) {
  const e = SNB_STRINGS[key];
  if (!e) return key;
  return e[lang] || e.en;
}

// ─── i18n hook ────────────────────────────────────────────────────────────
const SnbCtx = React.createContext({ lang: 'en', dir: 'ltr', t: (k) => snbT(k, 'en'), tweaks: {} });
function useSnb() { return React.useContext(SnbCtx); }

// ─── SVG Logo (from real Steaks N Buns logo) ──────────────────────────────
function SnbLogo({ size = 80, color = 'currentColor', yellow = '#E0CD2F', src }) {
  // If a raster logo asset is passed (for the high-fidelity hero), use it.
  if (src) {
    return <img src={src} alt="Steaks N Buns" style={{ width: size, height: 'auto', display: 'block' }} />;
  }
  // Fallback type-set lockup
  return (
    <div style={{ display: 'inline-flex', flexDirection: 'column', alignItems: 'center', lineHeight: 1, gap: 4 }}>
      <div style={{ fontFamily: 'var(--snb-display)', fontSize: size * 0.42, color, letterSpacing: '-0.02em', whiteSpace: 'nowrap' }}>
        STEAKS<span style={{ color: yellow, margin: '0 2px' }}>N</span>BUNS
      </div>
    </div>
  );
}

// Compact lockup with arched brand tagline + sub-tagline
function SnbWordmark({ width = 200, color = 'var(--snb-green)', yellow = 'var(--snb-yellow)' }) {
  return (
    <svg viewBox="0 0 200 110" width={width} height={(width * 110) / 200} aria-label="Steaks N Buns" role="img">
      <defs>
        <path id="snb-arc-top" d="M 12 38 A 90 56 0 0 1 188 38" fill="none" />
      </defs>
      <text fontFamily="serif" fontWeight="700" fontSize="9" letterSpacing="2" fill={color} textAnchor="middle">
        <textPath href="#snb-arc-top" startOffset="50%">MADINAH</textPath>
      </text>
      <text x="100" y="62" fontFamily="var(--snb-display)" fontWeight="400" fontSize="32" fill={color} textAnchor="middle" letterSpacing="-0.5">
        STEAKS<tspan fill={yellow} dx="2" dy="-2" fontSize="36">N</tspan><tspan fill={color} dx="2" dy="2">BUNS</tspan>
      </text>
      <text x="100" y="92" fontFamily="serif" fontWeight="700" fontSize="9" letterSpacing="2" fill={color} textAnchor="middle">
        BURGERS · FRIES · STRIPS
      </text>
    </svg>
  );
}

// Brand checker stripe — the iconic parallelogram pattern
function SnbCheckerStripe({ height = 36, flip = false }) {
  return (
    <div className="snb-checker-row" style={{
      height,
      transform: flip ? 'scaleY(-1)' : undefined,
    }} />
  );
}

// Star rating row
function SnbStars({ value = 5, size = 14, color = 'var(--snb-yellow)' }) {
  return (
    <span style={{ display: 'inline-flex', gap: 2, color }}>
      {[1,2,3,4,5].map(i => (
        <svg key={i} width={size} height={size} viewBox="0 0 24 24" fill={i <= value ? color : 'rgba(0,0,0,.1)'}>
          <path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/>
        </svg>
      ))}
    </span>
  );
}

// Tiny icon system (inline SVG, currentColor)
const SnbIcon = ({ name, size = 20, stroke = 2 }) => {
  const props = { width: size, height: size, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: stroke, strokeLinecap: 'round', strokeLinejoin: 'round' };
  const map = {
    phone: <svg {...props}><path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"/></svg>,
    pin:   <svg {...props}><path d="M20 10c0 7-8 13-8 13s-8-6-8-13a8 8 0 0 1 16 0z"/><circle cx="12" cy="10" r="3"/></svg>,
    clock: <svg {...props}><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>,
    bag:   <svg {...props}><path d="M6 2L3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4z"/><line x1="3" y1="6" x2="21" y2="6"/><path d="M16 10a4 4 0 0 1-8 0"/></svg>,
    bike:  <svg {...props}><circle cx="5.5" cy="17.5" r="3.5"/><circle cx="18.5" cy="17.5" r="3.5"/><path d="M15 6h5l-4 7H8L5 9h7l3-3z"/></svg>,
    store: <svg {...props}><path d="M3 9l1-5h16l1 5"/><path d="M4 9v10a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1V9"/><path d="M9 22V12h6v10"/></svg>,
    chair: <svg {...props}><path d="M6 11V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v6"/><path d="M4 11h16l-1 4H5z"/><line x1="7" y1="22" x2="7" y2="15"/><line x1="17" y1="22" x2="17" y2="15"/></svg>,
    box:   <svg {...props}><path d="M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/><polyline points="3.27 6.96 12 12.01 20.73 6.96"/><line x1="12" y1="22.08" x2="12" y2="12"/></svg>,
    star:  <svg {...props} fill="currentColor"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg>,
    fire:  <svg {...props}><path d="M12 2s4 5 4 9a4 4 0 0 1-8 0c0-1.5 1-3 2-4 0 2 1 3 2 3-1-3 0-6 0-8z"/></svg>,
    moon:  <svg {...props}><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/></svg>,
    sun:   <svg {...props}><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"/></svg>,
    car:   <svg {...props}><path d="M5 17h14l-1.5-5h-11z"/><circle cx="7.5" cy="17.5" r="1.5"/><circle cx="16.5" cy="17.5" r="1.5"/><path d="M7 12V8h10v4"/></svg>,
    family:<svg {...props}><circle cx="9" cy="7" r="3"/><circle cx="17" cy="9" r="2"/><path d="M3 21v-2a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v2"/><path d="M21 21v-1a3 3 0 0 0-3-3"/></svg>,
    check: <svg {...props}><polyline points="20 6 9 17 4 12"/></svg>,
    plus:  <svg {...props}><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>,
    chevR: <svg {...props}><polyline points="9 18 15 12 9 6"/></svg>,
    chevL: <svg {...props}><polyline points="15 18 9 12 15 6"/></svg>,
    chevD: <svg {...props}><polyline points="6 9 12 15 18 9"/></svg>,
    menu:  <svg {...props}><line x1="3" y1="12" x2="21" y2="12"/><line x1="3" y1="6" x2="21" y2="6"/><line x1="3" y1="18" x2="21" y2="18"/></svg>,
    close: <svg {...props}><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>,
    instagram: <svg {...props}><rect x="3" y="3" width="18" height="18" rx="5" ry="5"/><circle cx="12" cy="12" r="4"/><circle cx="17.5" cy="6.5" r="0.5" fill="currentColor"/></svg>,
    snap:  <svg {...props}><path d="M12 3c4 0 5 3 5 6v3l2 2-2 1c-1 2-2 3-5 3s-4-1-5-3l-2-1 2-2V9c0-3 1-6 5-6z"/></svg>,
    tiktok:<svg {...props} fill="currentColor" stroke="none"><path d="M19 8.5a5 5 0 0 1-5-5h-3v11a2 2 0 1 1-2-2v-3a5 5 0 1 0 5 5V10a8 8 0 0 0 5 1.5z"/></svg>,
    wa:    <svg {...props} fill="currentColor" stroke="none"><path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"/></svg>,
  };
  return map[name] || null;
}

Object.assign(window, { SNB_STRINGS, snbT, SnbCtx, useSnb, SnbLogo, SnbWordmark, SnbCheckerStripe, SnbStars, SnbIcon });
