// mobile-landing.jsx — Pain-led, bilingual mobile-first landing page
// Sections: Hero → Pain Hook → Core Edu → 5 Stories → +Accordion →
// Solution → Mechanism → Before/After → Diagnostic → Who-this-is-for → Final CTA

const { useState: useStateMFL, useEffect: useEffectMFL, useRef: useRefMFL } = React;

/* ─────────────────── COPY (AR / EN) ─────────────────── */

const COPY = {
  ar: {
    dir: "rtl",
    nav: { brand: "Clinic Growth Ops", cta: "احجز تشخيصًا", ctaShort: "احجز تشخيصًا مجانيًا" },
    hero: {
      eyebrow: "لعيادات زراعة الشعر",
      h1Pre: "عيادتك لا تحتاج",
      h1Bold: "استفسارات أكثر",
      h1Post: "فقط — تحتاج نظامًا يحوّل الاهتمام إلى",
      h1Accent: "حجوزات جدية",
      lede: "نساعد عيادات زراعة الشعر على بناء رحلة واضحة من الإعلان إلى الحجز: استهداف أدق، صفحة هبوط مقنعة، Lead Magnet ذكي، تأهيل، متابعة، مراجعات، وتتبع للنتائج.",
      cta: "احجز تشخيصًا مجانيًا لعيادتك",
      micro: "في المكالمة نراجع أين تضيع الفرص اليوم: الاستهداف، الصفحة، التأهيل، المتابعة، الحجز، أو الإغلاق.",
    },
    pain: {
      sid: "01 · PAIN HOOK",
      h2Pre: "هل هذا يحدث",
      h2Accent: "داخل عيادتك؟",
      items: [
        ["تصرف على الإعلانات، لكن أغلب الرسائل تسأل:", "“بقداش؟”"],
        ["تحصل على أرقام، لكن", "لا تعرف من الجاد ومن الفضولي"],
        ["أشخاص يحجزون", "ثم لا يحضرون"],
        ["فرص ساخنة تضيع لأن", "المتابعة تأخرت"],
        ["الفريق يدخل المحادثة", "بدون معرفة كافية"],
        ["لا توجد رحلة واضحة", "من الإعلان إلى الحجز"],
        ["لا تعرف أين تخسر المال:", "الإعلان؟ التأهيل؟ المتابعة؟ الإغلاق؟"],
      ],
      transitionEyebrow: "الخلاصة",
      transition: "زيادة الميزانية ليست الحل دائمًا. الحل هو بناء نظام تحويل.",
    },
    edu: {
      sid: "02 · CORE EDUCATION",
      h2Pre: "إعلان جيد بدون نظام تحويل =",
      h2Accent: "مال يُحرق بهدوء",
      body: "الإعلان يستطيع جذب الانتباه. لكن الانتباه وحده لا يعني حجزًا. راغب زراعة الشعر يحتاج رحلة منطقية:",
      journey: ["يرى الإعلان", "يفهم الخدمة", "يثق", "يحصل على قيمة", "يُؤهَّل", "يحجز", "تتم متابعته", "يصل للفريق بمعلومات واضحة", "تُتتبع النتيجة"],
      key: "إذا انكسرت أي مرحلة من هذه الرحلة، تبدأ الخسارة.",
    },
    storiesTitle: { sid: "03 · WHERE MONEY LEAKS", h2: "خمس قصص ألم تختبئ في كل عيادة" },
    stories: [
      {
        n: "STORY 01 · TARGETING",
        h: "حين تستهدف \u201Cكل من يعاني من تساقط الشعر\u201D… تحصل على فضول أكثر من الجدية.",
        viz: "broad-targeting",
        body: <>عيادة تطلق حملة عامة: <strong>“زراعة الشعر بأحدث التقنيات.”</strong> رسائل كثيرة، أسئلة كثيرة عن السعر — لكن القليل فقط مناسب فعلًا للحجز. المشكلة ليست أن الإعلان لم يجذب اهتمامًا، بل أنه جذب اهتمامًا واسعًا وغير مصفّى.</>,
        lesson: "الاستهداف لا يبحث عن “من يهتم”، بل عن الشخص الأقرب للقرار: مشكلة واضحة، دافع قوي، توقع منطقي، وقدرة على الخطوة التالية.",
      },
      {
        n: "STORY 02 · LEAD MAGNET",
        h: "\u201Cاترك رقمك وسنتصل بك\u201D لم يعد كافيًا.",
        viz: "weak-form",
        body: <>شخص مهتم يضغط على الإعلان، يجد فورمًا: اسم، هاتف، مدينة. لا يشعر أنه حصل على شيء. لا يعرف هل حالته مناسبة، ولا نطاق التكلفة، ولا الخطوة التالية — وقد ينسى أصلًا لماذا ترك رقمه.</>,
        lesson: "Lead Magnet قوي لا يأخذ المعلومات فقط — يعطي قيمة أولًا. تقدير مبدئي للتكلفة أو تقييم أولي للحالة يجعل الشخص أكثر استعدادًا لإكمال الرحلة.",
      },
      {
        n: "STORY 03 · EDUCATION",
        h: "الشخص غير المتعلّم يقارن بالسعر فقط.",
        viz: "price-cloud",
        body: <>حين لا تشرح العيادة الفرق بين التقنية، عدد البصيلات، جودة التشخيص، الخبرة، والنتائج الواقعية، يبقى سؤال واحد فقط في ذهن المهتم: <strong>“كم السعر؟”</strong> وهنا تدخل العيادة في مقارنة خطيرة مع أي عرض أرخص.</>,
        lesson: "التثقيف ليس محتوى جميلًا فقط — هو أداة تحويل. كلما فهم الشخص أكثر، أصبح قراره أقل سطحية وأكثر ارتباطًا بالقيمة والثقة.",
      },
      {
        n: "STORY 04 · FOLLOW-UP",
        h: "ليس كل من لم يحجز غير مهتم.",
        viz: "followup",
        body: <>أحيانًا هو مهتم لكنه مشغول، أحيانًا يحتاج تذكيرًا، أحيانًا يريد رؤية تجربة شخص آخر، وأحيانًا ينتظر أن يشعر بالثقة. إذا توقفت المتابعة بعد أول رسالة، فأنت تترك المال على الطاولة.</>,
        lesson: "المتابعة ليست إزعاجًا إذا كانت مبنية على قيمة. المتابعة الصحيحة تعلّم، تطمئن، وتدفع للخطوة التالية.",
      },
      {
        n: "STORY 05 · REVIEWS",
        h: "إذا كان عملاؤك السعداء لا يتركون مراجعات… منافسوك يبدون أقوى.",
        viz: "reviews",
        body: <>راغب زراعة الشعر سيبحث عنك قبل الحجز. سيرى Google، سيرى Facebook، سيقارن، وسيسأل نفسه: <strong>“هل أثق بهذه العيادة؟”</strong> إذا لم تتحول التجارب الجيدة إلى Reviews، تبقى الثقة ناقصة على الإنترنت — حتى لو كانت الخدمة جيدة في الواقع.</>,
        lesson: "Google Reviews وFacebook Reviews ليست رفاهية — هي جزء من قرار الحجز.",
      },
    ],
    accordion: {
      title: "مشاكل أخرى نراجعها في التشخيص",
      items: [
        "ضعف كشف الاعتراضات الحقيقية قبل الاستشارة",
        "غياب التأهيل بين الفضولي والجاد والجاهز",
        "غياب رحلة عميل واضحة من الإعلان إلى النتيجة",
        "عدم تتبع ما يحدث بعد الحجز والحضور والإغلاق",
        "عدم تحويل التجارب الناجحة إلى قصص ثقة",
        "ضعف المتابعة بعد العملية",
        "صرف إعلاني بدون نظام إغلاق مستدام",
      ],
    },
    solution: {
      sid: "04 · WHAT WE BUILD",
      h2: "نبني نظام تحويل، لا حملة عابرة.",
      lede: "نظام يساعد عيادتك على:",
      items: [
        "جذب المهتمين المناسبين، لا الجمهور العام",
        "صفحة هبوط تقود لخطوة واحدة واضحة",
        "Lead Magnet ذكي يعطي قيمة أولية",
        "تأهيل الفرص حسب الجدية والاستعداد",
        "كشف الاعتراضات الحقيقية مبكرًا",
        "متابعة منظمة حسب مرحلة كل فرصة",
        "تسهيل الحجز وتسليم الفريق سياقًا أوضح",
        "تتبع ما يحدث بعد الحجز حتى الإغلاق",
        "تقوية الثقة عبر Google + Facebook Reviews",
        "رؤية واضحة لأين تضيع الفرص بالأرقام",
      ],
    },
    mechanism: {
      sid: "05 · HOW IT WORKS",
      h2: "كيف يعمل النظام",
      steps: [
        ["جذب موجّه", "نستهدف الأشخاص الأقرب للاهتمام الجاد بزراعة الشعر، لا جمهورًا عشوائيًا."],
        ["صفحة هبوط للتحويل", "صفحة لا تشرح فقط — بل تقود الزائر إلى خطوة واحدة واضحة."],
        ["Lead Magnet ذكي", "تجربة تفاعلية تساعد المهتم على فهم نطاق التكلفة أو ملاءمة حالته."],
        ["تأهيل وتقييم", "نفرّق بين الفضولي، المتردد، الجاد، والجاهز للحجز فورًا."],
        ["متابعة منظمة", "رسائل تذكير وتثقيف وتحفيز حسب مرحلة كل فرصة."],
        ["حجز وتتبع", "كل فرصة في مسار واضح: حجزت؟ حضرت؟ ماذا بعد الاستشارة؟"],
        ["مراجعات وثقة", "نظام منظّم لجمع Google + Facebook Reviews وتقوية السمعة."],
      ],
    },
    beforeAfter: {
      sid: "06 · BEFORE / AFTER",
      h2: "الفرق ليس في الإعلان — في النظام كله.",
      before: ["حملات بدون وضوح كافٍ", "استفسارات كثيرة بجودة غير معروفة", "متابعة عشوائية", "لا يوجد Lead Magnet قوي", "ضعف في كشف الاعتراضات", "فرص تضيع بسبب التأخير", "لا توجد رحلة واضحة", "مراجعات غير مستغلة", "ميزانية تضيع بدون رؤية"],
      after: ["استهداف أدق وأنضج", "صفحة تقود للقرار", "تجربة ذكية تعطي قيمة أولًا", "تأهيل للفرص", "متابعة مبنية على المرحلة", "حجز أكثر تنظيمًا", "معلومات أوضح قبل الاستشارة", "تتبع من الإعلان إلى النتيجة", "قرارات مبنية على أرقام"],
    },
    diagnostic: {
      sid: "07 · DIAGNOSIS CALL",
      h2: "مكالمة التشخيص المجانية",
      sub: "لا نبيع لك \u201Cباقة إعلانات\u201D. نراجع معك:",
      qs: [
        "هل الاستهداف الحالي يجذب الجادين؟",
        "هل الصفحة الحالية تقنع؟",
        "هل يوجد Lead Magnet فعلي؟",
        "هل يتم تأهيل الفرص؟",
        "هل توجد متابعة كافية؟",
        "هل يعرف الفريق الاعتراضات قبل الاستشارة؟",
        "هل يتم تتبع الحجز والحضور والإغلاق؟",
        "هل تستفيد العيادة من Google + Facebook Reviews؟",
        "أين أكبر خسارة مخفية اليوم؟",
      ],
      micro: "مناسب لعيادات زراعة الشعر التي تريد نموًا أوضح، جودة فرص أعلى، وتتبعًا أفضل للعائد.",
    },
    fit: {
      sid: "08 · IS THIS FOR YOU?",
      h2: "هل هذا مناسب لعيادتك؟",
      yes: { tag: "نعم", title: "هذا مناسب لك إذا…", items: [
        "عندك عيادة تقدم خدمة زراعة الشعر",
        "تصرف على الإعلانات بدون رؤية واضحة للعائد",
        "تحصل على استفسارات بجودة متفاوتة",
        "تريد حجوزات أكثر جدية",
        "تريد تقليل الفرص الضائعة",
        "تريد متابعة منظمة",
        "تريد تقوية الثقة عبر المراجعات",
        "تريد نظامًا يمكن تحسينه بالأرقام",
      ]},
      no: { tag: "لا", title: "هذا ليس لك إذا…", items: [
        "تبحث فقط عن أرخص إعلانات",
        "تريد أكبر عدد رسائل بغض النظر عن الجودة",
        "لا تريد تتبع ما يحدث بعد الحجز",
        "لا تريد تنظيم رحلة العميل المحتمل",
        "لا تريد مشاركة بيانات النتائج لتحسين النظام",
      ]},
    },
    final: {
      sid: "09 · BOOK NOW",
      h2Pre: "هل تعرف أين",
      h2Accent: "تضيع فرص زراعة الشعر",
      h2Post: "داخل عيادتك؟",
      sub: "في مكالمة التشخيص، نحدد أين يبدأ التسريب.",
      leaks: ["الاستهداف", "الصفحة", "التثقيف", "التأهيل", "المتابعة", "الاعتراضات", "المراجعات", "الرحلة"],
      cta: "احجز مكالمة تشخيص مجانية",
      micro: "لا تحتاج إلى المزيد من التخمين. ابدأ بفهم أين تضيع الفرص.",
    },
    foot: "CLINIC GROWTH OPS · HAIR-TX SYSTEMS",
  },
  en: {
    dir: "ltr",
    nav: { brand: "Clinic Growth Ops", cta: "Book diagnosis", ctaShort: "Book free diagnosis" },
    hero: {
      eyebrow: "FOR HAIR TRANSPLANT CLINICS",
      h1Pre: "Your clinic may not need",
      h1Bold: "more inquiries.",
      h1Post: " It needs a system that turns interest into",
      h1Accent: "serious bookings",
      lede: "We help hair transplant clinics build a clear journey from ad click to booking: sharper targeting, conversion-focused landing page, smart lead magnet, qualification, follow-up, reviews, and outcome tracking.",
      cta: "Book a Free Clinic Growth Diagnosis",
      micro: "In this call, we review where opportunities may be leaking today: targeting, landing page, qualification, follow-up, booking, reviews, or closing process.",
    },
    pain: {
      sid: "01 · PAIN HOOK",
      h2Pre: "Does this happen",
      h2Accent: "inside your clinic?",
      items: [
        ["You spend money on ads — but most messages just ask:", "“How much does it cost?”"],
        ["You get contact details, but", "you don’t know who is serious"],
        ["People book consultations", "and never show up"],
        ["Hot opportunities disappear because", "follow-up is late or inconsistent"],
        ["Your team enters conversations", "without enough context"],
        ["There is no clear journey", "from ad click to booking"],
        ["You can’t clearly see where money is lost:", "the ad? qualification? follow-up? close?"],
      ],
      transitionEyebrow: "Bottom line",
      transition: "Increasing ad budget is not always the answer. The answer is usually a better conversion system.",
    },
    edu: {
      sid: "02 · CORE EDUCATION",
      h2Pre: "A good ad without a conversion system =",
      h2Accent: "money quietly burning.",
      body: "Ads create attention. Attention alone does not create bookings. A person considering a hair transplant needs a logical journey:",
      journey: ["Sees the ad", "Understands the offer", "Trusts the clinic", "Receives initial value", "Gets qualified", "Books", "Is followed up with", "Team gets context", "Result is tracked"],
      key: "If one part of this journey breaks, money starts leaking.",
    },
    storiesTitle: { sid: "03 · WHERE MONEY LEAKS", h2: "Five pain stories hiding inside every clinic" },
    stories: [
      {
        n: "STORY 01 · TARGETING",
        h: "When you target “everyone with hair loss”, you attract curiosity, not commitment.",
        viz: "broad-targeting",
        body: <>A clinic launches a general campaign: <strong>“Advanced hair transplant techniques available now.”</strong> Messages flow in. People ask about price. But only a small slice are actually close to booking. The ad didn’t fail to create interest — it attracted interest that was too broad and unfiltered.</>,
        lesson: "Targeting should not only ask “who is interested” — it should ask who is closest to action: a clear problem, strong motivation, realistic expectations, and readiness to take the next step.",
      },
      {
        n: "STORY 02 · LEAD MAGNET",
        h: "“Leave your phone number and we will contact you” is no longer enough.",
        viz: "weak-form",
        body: <>Someone clicks the ad and lands on a simple form: name, phone, city. They don’t feel they received anything. They don’t know if their case is suitable, the cost range, or what comes next — and minutes later they may forget why they submitted at all.</>,
        lesson: "A strong lead magnet doesn’t only collect information — it gives value first. An initial cost range or a suitability pre-check makes the prospect more likely to continue the journey.",
      },
      {
        n: "STORY 03 · EDUCATION",
        h: "An uneducated prospect compares only by price.",
        viz: "price-cloud",
        body: <>When you don’t explain technique, graft count, diagnosis quality, doctor experience, and realistic outcomes, the prospect is left with one question: <strong>“How much?”</strong> And once the decision becomes price-only, your clinic is compared against the cheapest offer in the market.</>,
        lesson: "Education is not just content — it’s a conversion asset. The more a person understands, the more their decision shifts from price to value and trust.",
      },
      {
        n: "STORY 04 · FOLLOW-UP",
        h: "Not everyone who doesn’t book is uninterested.",
        viz: "followup",
        body: <>Sometimes they’re interested but busy. Sometimes they need a reminder. Sometimes they want to see another person’s journey. Sometimes they’re waiting to feel more trust. If follow-up stops after the first message, you leave money on the table.</>,
        lesson: "Follow-up is not annoying when it’s valuable. Good follow-up educates, reassures, reminds, and moves the person to the next logical step.",
      },
      {
        n: "STORY 05 · REVIEWS",
        h: "If happy clients don’t leave reviews, your competitors look stronger online.",
        viz: "reviews",
        body: <>A person considering a hair transplant will search you up before booking. They check Google. They check Facebook. They compare. They ask themselves: <strong>“Can I trust this clinic?”</strong> If good experiences don’t turn into reviews, online trust stays weaker than your real service.</>,
        lesson: "Google + Facebook reviews are not decoration — they’re part of the booking decision.",
      },
    ],
    accordion: {
      title: "Other leaks we check in the diagnosis",
      items: [
        "Weak discovery of real objections before consultation",
        "No qualification between curious, serious, and ready",
        "No clear customer journey from ad to outcome",
        "No tracking of booking, attendance, or close",
        "Successful journeys never turned into trust assets",
        "Weak post-operation follow-up",
        "Ad spend without sustainable closing process",
      ],
    },
    solution: {
      sid: "04 · WHAT WE BUILD",
      h2: "We build a conversion system, not a temporary campaign.",
      lede: "A system that helps your clinic:",
      items: [
        "Attract better-fit prospects, not a broad audience",
        "Send them to a conversion-focused landing page",
        "Give them initial value via a smart lead magnet",
        "Qualify opportunities by seriousness and readiness",
        "Reveal real objections earlier",
        "Follow up consistently, by stage",
        "Make booking easier and hand the team better context",
        "Track what happens after the booking",
        "Strengthen trust via Google + Facebook reviews",
        "See clearly where opportunities are leaking",
      ],
    },
    mechanism: {
      sid: "05 · HOW IT WORKS",
      h2: "How the system works",
      steps: [
        ["Focused attraction", "We target people more likely to be serious about hair transplant — not a broad, generally-curious audience."],
        ["Conversion landing page", "A page that doesn’t only explain — it guides the visitor toward one clear next step."],
        ["Smart lead magnet", "An interactive experience that gives initial value: cost range or suitability pre-check."],
        ["Qualification", "We separate the curious, the hesitant, the serious, and the booking-ready."],
        ["Structured follow-up", "Educational and reminder-based follow-up tuned to the prospect’s stage."],
        ["Booking & tracking", "Every opportunity enters a visible journey: booked, attended, closed, lost, or nurturing."],
        ["Reviews & trust", "We help collect and grow Google + Facebook reviews in a structured way."],
      ],
    },
    beforeAfter: {
      sid: "06 · BEFORE / AFTER",
      h2: "The difference isn’t the ad — it’s the whole system.",
      before: ["Campaigns run without enough clarity", "Inquiries arrive, quality is uncertain", "Random, ad-hoc follow-up", "No real lead magnet", "Hidden objections", "Hot opportunities disappear", "No clear customer journey", "Reviews underused", "Budget lost without visibility"],
      after: ["Sharper, more mature targeting", "Landing page supports the decision", "Lead magnet gives value first", "Prospects are qualified", "Stage-based follow-up", "Booking becomes manageable", "Better context before consultation", "Full journey is trackable", "Decisions based on numbers"],
    },
    diagnostic: {
      sid: "07 · DIAGNOSIS CALL",
      h2: "The free diagnosis call",
      sub: "This is not a call to sell you “more ads.” We review:",
      qs: [
        "Is your targeting attracting serious prospects?",
        "Does your landing page convert or lose visitors?",
        "Do you have a real lead magnet?",
        "Are prospects being qualified?",
        "Is follow-up strong enough?",
        "Does the team know objections before the consultation?",
        "Are booking, attendance, and close being tracked?",
        "Are you collecting enough Google + Facebook reviews?",
        "Where is the biggest hidden leak today?",
      ],
      micro: "For hair transplant clinics that want clearer growth, better-quality opportunities, and better visibility on return on ad spend.",
    },
    fit: {
      sid: "08 · IS THIS FOR YOU?",
      h2: "Is this for your clinic?",
      yes: { tag: "YES", title: "This is for you if…", items: [
        "You run or manage a hair transplant clinic",
        "You spend on ads without clearly seeing the return",
        "You receive inquiries of inconsistent quality",
        "You want more serious bookings",
        "You want fewer lost opportunities",
        "You want better, structured follow-up",
        "You want stronger trust through reviews",
        "You want a system that improves with data",
      ]},
      no: { tag: "NO", title: "This is not for you if…", items: [
        "You only want the cheapest possible ads",
        "You only care about message volume, not quality",
        "You don’t want to track what happens after booking",
        "You don’t want to organize the customer journey",
        "You don’t want to share outcome data",
      ]},
    },
    final: {
      sid: "09 · BOOK NOW",
      h2Pre: "Do you know where",
      h2Accent: "hair transplant opportunities leak",
      h2Post: "inside your clinic?",
      sub: "In the diagnosis call, we identify where the leak starts.",
      leaks: ["Targeting", "Landing page", "Education", "Qualification", "Follow-up", "Objections", "Reviews", "Journey"],
      cta: "Book a Free Clinic Growth Diagnosis",
      micro: "You don’t need more guessing. Start by finding where opportunities are being lost.",
    },
    foot: "CLINIC GROWTH OPS · HAIR-TX SYSTEMS",
  },
};

/* ─────────────────── SHARED PRIMITIVES ─────────────────── */

function ArrowGlyph({ dir }) {
  // Always visually points to the start of the call (toward CTA destination)
  return (
    <svg width="14" height="14" viewBox="0 0 14 14" fill="none" aria-hidden="true"
         style={{ transform: dir === "rtl" ? "scaleX(-1)" : "none" }}>
      <path d="M2 7h10M8 3l4 4-4 4" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
    </svg>
  );
}

function SectionId({ children }) {
  return <div className="mfl-sid">{children}</div>;
}

/* ─────────────────── TOP BAR ─────────────────── */

function TopBar({ lang, setLang, theme, setTheme, copy }) {
  return (
    <div className="mfl-topbar">
      <div className="mfl-topbar-inner">
        <a href="#top" className="mfl-brand">
          <svg width="22" height="22" viewBox="0 0 28 28" fill="none" aria-hidden="true">
            <circle cx="14" cy="14" r="13.5" stroke="var(--accent)" strokeOpacity="0.5" />
            <path d="M7 21 L14 14 L21 7" stroke="var(--accent)" strokeWidth="1.5" />
            <path d="M14 14 L20 18" stroke="var(--accent)" strokeWidth="1.5" strokeOpacity="0.7" />
            <circle cx="14" cy="14" r="2" fill="var(--accent)" />
          </svg>
          <span className="mfl-brand-name">{copy.nav.brand}</span>
        </a>
        <div style={{ display: "flex", alignItems: "center" }}>
          <div className="mfl-lang" role="tablist" aria-label="Language">
            <button className={`mfl-lang-btn ${lang === "ar" ? "is-active" : ""}`}
                    onClick={() => setLang("ar")} aria-pressed={lang === "ar"}>AR</button>
            <button className={`mfl-lang-btn ${lang === "en" ? "is-active" : ""}`}
                    onClick={() => setLang("en")} aria-pressed={lang === "en"}>EN</button>
          </div>
          <button
            className="mfl-theme-btn"
            onClick={() => setTheme(theme === "dark" ? "light" : "dark")}
            aria-label={theme === "dark" ? "Switch to light mode" : "Switch to dark mode"}
            title={theme === "dark" ? "Light mode" : "Dark mode"}
          >
            {theme === "dark" ? (
              /* Sun */
              <svg width="15" height="15" viewBox="0 0 15 15" fill="none" aria-hidden="true">
                <circle cx="7.5" cy="7.5" r="3" stroke="currentColor" strokeWidth="1.3" />
                <g stroke="currentColor" strokeWidth="1.3" strokeLinecap="round">
                  <path d="M7.5 1.5 V3" /><path d="M7.5 12 V13.5" />
                  <path d="M1.5 7.5 H3" /><path d="M12 7.5 H13.5" />
                  <path d="M3.3 3.3 L4.4 4.4" /><path d="M10.6 10.6 L11.7 11.7" />
                  <path d="M3.3 11.7 L4.4 10.6" /><path d="M10.6 4.4 L11.7 3.3" />
                </g>
              </svg>
            ) : (
              /* Moon */
              <svg width="15" height="15" viewBox="0 0 15 15" fill="none" aria-hidden="true">
                <path d="M12.5 9.2 A5.5 5.5 0 1 1 5.8 2.5 A4.2 4.2 0 0 0 12.5 9.2 Z"
                      fill="currentColor" stroke="currentColor" strokeWidth="0.8" strokeLinejoin="round" />
              </svg>
            )}
          </button>
        </div>
      </div>
    </div>
  );
}

/* ─────────────────── HERO ─────────────────── */

function Hero({ copy, lang }) {
  const h = copy.hero;
  return (
    <section className="mfl-hero" id="top">
      <div className="mfl-hero-mark">
        <span className="dot" />
        <span className="label">{h.eyebrow}</span>
      </div>
      <h1 className="mfl-h1">
        {h.h1Pre}{" "}
        <span style={{ color: "var(--text)" }}>{h.h1Bold}</span>
        {" "}{h.h1Post}{" "}
        <span className="mfl-accent">{h.h1Accent}</span>
        {lang === "ar" ? "." : "."}
      </h1>
      <p className="mfl-lede">{h.lede}</p>
      <div className="mfl-hero-cta">
        <a href="#book" className="mfl-btn mfl-btn-primary mfl-btn-block">
          {h.cta} <ArrowGlyph dir={copy.dir} />
        </a>
      </div>
      <p className="mfl-hero-micro">{h.micro}</p>
    </section>
  );
}

/* ─────────────────── PAIN HOOK ─────────────────── */

function PainHook({ copy }) {
  const p = copy.pain;
  return (
    <section className="mfl-section">
      <SectionId>{p.sid}</SectionId>
      <h2 className="mfl-h2">
        {p.h2Pre} <span className="mfl-accent">{p.h2Accent}</span>
      </h2>
      <ul className="mfl-painlist">
        {p.items.map((it, i) => (
          <li key={i}>
            <span className="x" aria-hidden="true">✕</span>
            <span>{it[0]} <em>{it[1]}</em></span>
          </li>
        ))}
      </ul>
      <div className="mfl-pull">
        <div className="mfl-eyebrow">— {p.transitionEyebrow}</div>
        <p>{p.transition}</p>
      </div>
    </section>
  );
}

/* ─────────────────── CORE EDUCATION ─────────────────── */

function CoreEducation({ copy }) {
  const e = copy.edu;
  return (
    <section className="mfl-section">
      <SectionId>{e.sid}</SectionId>
      <h2 className="mfl-h2">
        {e.h2Pre} <span className="mfl-warn">{e.h2Accent}</span>
      </h2>
      <p className="mfl-body" style={{ marginTop: 18 }}>{e.body}</p>

      {/* Journey diagram — number + label on the same row, never collapse */}
      <div style={{
        marginTop: 22, padding: "14px 16px",
        border: "1px solid var(--hairline)", borderRadius: 10,
        background: "rgba(255,255,255,0.018)",
      }}>
        {e.journey.map((s, i) => (
          <div key={i} className="mfl-row">
            <div className="num">{String(i + 1).padStart(2, "0")}</div>
            <div className="label">{s}</div>
          </div>
        ))}
      </div>

      <div className="mfl-pull" style={{ borderColor: "rgba(224,123,95,0.25)", background: "linear-gradient(180deg, rgba(224,123,95,0.06), transparent)" }}>
        <div className="mfl-eyebrow" style={{ color: "var(--warn)" }}>— KEY</div>
        <p>{e.key}</p>
      </div>
    </section>
  );
}

/* ─────────────────── STORIES ─────────────────── */

function StoriesTitle({ copy }) {
  const s = copy.storiesTitle;
  return (
    <section className="mfl-section" style={{ paddingBlockEnd: 12 }}>
      <SectionId>{s.sid}</SectionId>
      <h2 className="mfl-h2">{s.h2}</h2>
    </section>
  );
}

function StoryViz({ kind, lang }) {
  if (kind === "broad-targeting") return <ViewBroadTargeting lang={lang} />;
  if (kind === "weak-form") return <ViewWeakForm lang={lang} />;
  if (kind === "price-cloud") return <ViewPriceCloud lang={lang} />;
  if (kind === "followup") return <ViewFollowup lang={lang} />;
  if (kind === "reviews") return <ViewReviews lang={lang} />;
  return null;
}

function ViewBroadTargeting({ lang }) {
  // 5x6 dot field with serious-vs-curious ratio
  const ar = lang === "ar";
  const dots = [];
  const serious = new Set([7, 13, 22, 4]); // sparse "serious" dots
  for (let i = 0; i < 30; i++) {
    const isSerious = serious.has(i);
    dots.push(
      <div key={i} style={{
        width: 12, height: 12, borderRadius: "50%",
        background: isSerious ? "var(--accent)" : "var(--hairline-strong)",
        boxShadow: isSerious ? "0 0 0 3px var(--accent-glow)" : "none",
      }} />
    );
  }
  return (
    <div className="mfl-story-mock" style={{ padding: 16 }}>
      <div style={{ display: "flex", justifyContent: "space-between", marginBottom: 12, color: "var(--text-dim)", fontSize: ar ? 12 : 10.5, letterSpacing: ar ? 0 : "0.14em", fontFamily: ar ? "var(--f-body)" : "var(--f-mono)" }}>
        <span>{ar ? "كل من يهتم" : "EVERYONE INTERESTED"}</span>
        <span style={{ color: "var(--accent)" }}>{ar ? "الجادون فقط" : "ONLY SERIOUS"}</span>
      </div>
      <div className="mfl-dotgrid">
        {dots}
      </div>
      <div style={{ marginTop: 14, fontSize: ar ? 12.5 : 11.5, fontFamily: ar ? "var(--f-body)" : "var(--f-mono)", color: "var(--text-dim)", letterSpacing: ar ? 0 : "0.08em" }}>
        {ar ? "13% فقط مؤهّلون فعلاً" : "ONLY ~13% ACTUALLY QUALIFIED"}
      </div>
    </div>
  );
}

function ViewWeakForm({ lang }) {
  const ar = lang === "ar";
  return (
    <div className="mfl-formmock">
      <div className="row">{ar ? "الاسم" : "Name"}</div>
      <div className="row">{ar ? "رقم الهاتف" : "Phone number"}</div>
      <div className="row">{ar ? "المدينة" : "City"}</div>
      <div className="submit">{ar ? "إرسال" : "Submit"}</div>
      <div style={{ fontFamily: ar ? "var(--f-body)" : "var(--f-mono)", fontSize: ar ? 12.5 : 10.5, color: "var(--warn)", marginTop: 6, letterSpacing: ar ? 0 : "0.08em" }}>
        ⚠ {ar ? "لا قيمة فورية · لا سياق" : "NO IMMEDIATE VALUE · NO CONTEXT"}
      </div>
    </div>
  );
}

function ViewPriceCloud({ lang }) {
  const ar = lang === "ar";
  return (
    <div className="mfl-pricecloud">
      <span className="chip loud">{ar ? "كم السعر؟" : "How much?"}</span>
      <span className="chip">{ar ? "تقنية" : "Technique"}</span>
      <span className="chip">{ar ? "بصيلات" : "Grafts"}</span>
      <span className="chip loud">{ar ? "أرخص خيار؟" : "Cheapest?"}</span>
      <span className="chip">{ar ? "خبرة" : "Experience"}</span>
      <span className="chip">{ar ? "تشخيص" : "Diagnosis"}</span>
      <span className="chip loud">{ar ? "خصم؟" : "Discount?"}</span>
      <span className="chip">{ar ? "نتائج" : "Results"}</span>
      <span className="chip">{ar ? "تعافي" : "Recovery"}</span>
    </div>
  );
}

function ViewFollowup({ lang }) {
  const ar = lang === "ar";
  return (
    <div className="mfl-chat">
      <div className="mfl-chat-bubble user">{ar ? "مرحبًا، أريد سعر زراعة الشعر" : "Hi, I want a price for hair transplant"}</div>
      <div className="mfl-chat-bubble">{ar ? "بصيلتك: قرابة 3000 · السعر التقريبي…" : "Around 3000 grafts · approx price…"}</div>
      <div style={{
        textAlign: "center", fontFamily: ar ? "var(--f-body)" : "var(--f-mono)", fontSize: ar ? 12.5 : 10.5, color: "var(--text-dim)",
        letterSpacing: ar ? 0 : "0.14em", padding: "8px 0",
      }}>— {ar ? "صمت · 12 يومًا" : "SILENCE · 12 DAYS"} —</div>
      <div className="mfl-chat-bubble" style={{ borderStyle: "dashed", borderWidth: 1, borderColor: "var(--warn)", background: "rgba(224,123,95,0.05)", color: "var(--warn)" }}>
        {ar ? "فرصة ضائعة" : "Lost opportunity"}
      </div>
    </div>
  );
}

function ViewReviews({ lang }) {
  const ar = lang === "ar";
  return (
    <div className="mfl-cmpgrid">
      {[
        ["YOU", "3.8", "12 reviews", "var(--warn)"],
        ["COMPETITOR", "4.9", "428 reviews", "var(--accent)"],
      ].map((row, i) => (
        <div key={i} style={{
          padding: 12, borderRadius: 6,
          border: `1px solid ${row[3] === "var(--warn)" ? "rgba(224,123,95,0.30)" : "rgba(0,194,184,0.30)"}`,
          background: row[3] === "var(--warn)" ? "rgba(224,123,95,0.04)" : "rgba(0,194,184,0.04)",
        }}>
          <div style={{ fontFamily: "var(--f-mono)", fontSize: 10, letterSpacing: "0.16em", color: "var(--text-dim)" }}>{row[0]}</div>
          <div style={{ display: "flex", alignItems: "baseline", gap: 6, marginTop: 4 }}>
            <span style={{ fontFamily: "var(--f-display)", fontSize: 22, fontWeight: 600, color: row[3], direction: "ltr" }}>{row[1]}</span>
            <span style={{ fontSize: 13, color: row[3] }}>★</span>
          </div>
          <div style={{ fontFamily: "var(--f-mono)", fontSize: 10.5, color: "var(--text-dim)", marginTop: 4, direction: "ltr" }}>{row[2]}</div>
        </div>
      ))}
    </div>
  );
}

function Story({ s, idx, lang }) {
  return (
    <article className="mfl-story">
      <div className="mfl-story-num">{s.n}</div>
      <h3 className="mfl-h3">{s.h}</h3>
      <StoryViz kind={s.viz} lang={lang} />
      <p className="mfl-story-body">{s.body}</p>
      <div className="mfl-story-lesson">
        <span className="badge">{lang === "ar" ? "الدرس" : "LESSON"}</span>
        <p>{s.lesson}</p>
      </div>
    </article>
  );
}

function Stories({ copy, lang }) {
  return (
    <section className="mfl-section" style={{ paddingBlockStart: 12 }}>
      {copy.stories.map((s, i) => <Story key={i} s={s} idx={i} lang={lang} />)}
    </section>
  );
}

function MoreLeaksAccordion({ copy, lang }) {
  const [open, setOpen] = useStateMFL(false);
  const a = copy.accordion;
  return (
    <section className="mfl-section" style={{ paddingBlockStart: 12 }}>
      <div className="mfl-accordion">
        <button className={`mfl-acc-head ${open ? "is-open" : ""}`} onClick={() => setOpen(!open)} aria-expanded={open}>
          <span>{a.title}</span>
          <span className="caret">{lang === "ar" ? "‹" : "›"}</span>
        </button>
        {open && (
          <div className="mfl-acc-body">
            <ul>
              {a.items.map((it, i) => (
                <li key={i}>
                  <span className="n">{String(i + 6).padStart(2, "0")}</span>
                  <span>{it}</span>
                </li>
              ))}
            </ul>
          </div>
        )}
      </div>
    </section>
  );
}

/* ─────────────────── SOLUTION ─────────────────── */

function Solution({ copy }) {
  const s = copy.solution;
  return (
    <section className="mfl-section">
      <SectionId>{s.sid}</SectionId>
      <h2 className="mfl-h2">{s.h2}</h2>
      <p className="mfl-lede" style={{ marginTop: 16 }}>{s.lede}</p>
      <div className="mfl-buildlist">
        {s.items.map((it, i) => (
          <div key={i} className="item">
            <span className="check" aria-hidden="true">
              <svg width="12" height="12" viewBox="0 0 12 12" fill="none">
                <path d="M2 6.5 L5 9 L10 3" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" />
              </svg>
            </span>
            <p>{it}</p>
          </div>
        ))}
      </div>
    </section>
  );
}

/* ─────────────────── MECHANISM ─────────────────── */

function Mechanism({ copy }) {
  const m = copy.mechanism;
  return (
    <section className="mfl-section">
      <SectionId>{m.sid}</SectionId>
      <h2 className="mfl-h2">{m.h2}</h2>
      <div className="mfl-mech">
        {m.steps.map((st, i) => (
          <div key={i} className="step">
            <div className="step-head">
              <span className="step-num">{String(i + 1).padStart(2, "0")}</span>
              <h4>{st[0]}</h4>
            </div>
            <p>{st[1]}</p>
          </div>
        ))}
      </div>
    </section>
  );
}

/* ─────────────────── BEFORE / AFTER ─────────────────── */

function BeforeAfter({ copy, lang }) {
  const b = copy.beforeAfter;
  return (
    <section className="mfl-section">
      <SectionId>{b.sid}</SectionId>
      <h2 className="mfl-h2">{b.h2}</h2>
      <div className="mfl-ba">
        <div className="mfl-ba-col before">
          <span className="mfl-ba-tag">{lang === "ar" ? "قبل النظام" : "BEFORE THE SYSTEM"}</span>
          <ul className="mfl-ba-list">
            {b.before.map((it, i) => <li key={i}><span>{it}</span></li>)}
          </ul>
        </div>
        <div className="mfl-ba-col after">
          <span className="mfl-ba-tag">{lang === "ar" ? "بعد النظام" : "AFTER THE SYSTEM"}</span>
          <ul className="mfl-ba-list">
            {b.after.map((it, i) => <li key={i}><span>{it}</span></li>)}
          </ul>
        </div>
      </div>
    </section>
  );
}

/* ─────────────────── DIAGNOSTIC ─────────────────── */

function Diagnostic({ copy, lang }) {
  const d = copy.diagnostic;
  return (
    <section className="mfl-section" id="book">
      <SectionId>{d.sid}</SectionId>
      <h2 className="mfl-h2">{d.h2}</h2>
      <p className="mfl-lede" style={{ marginTop: 16 }}>{d.sub}</p>
      <div className="mfl-checklist">
        {d.qs.map((q, i) => (
          <div key={i} className="qrow">
            <span className="qmark" />
            <p>{q}</p>
          </div>
        ))}
      </div>
      <div style={{ marginTop: 22, display: "flex", flexDirection: "column", gap: 10 }}>
        <a href="#contact" className="mfl-btn mfl-btn-primary mfl-btn-block">
          {copy.hero.cta} <ArrowGlyph dir={copy.dir} />
        </a>
        <p style={{ fontSize: 13, color: "var(--text-dim)", lineHeight: 1.55, marginTop: 4, textAlign: lang === "ar" ? "right" : "left" }}>
          {d.micro}
        </p>
      </div>
    </section>
  );
}

/* ─────────────────── FIT ─────────────────── */

function Fit({ copy }) {
  const f = copy.fit;
  return (
    <section className="mfl-section">
      <SectionId>{f.sid}</SectionId>
      <h2 className="mfl-h2">{f.h2}</h2>
      <div className="mfl-fit">
        <div className="mfl-fit-block yes">
          <h3 className="mfl-h3">
            <span className="icon">✓</span>
            <span>{f.yes.title}</span>
          </h3>
          <ul>
            {f.yes.items.map((it, i) => <li key={i}>{it}</li>)}
          </ul>
        </div>
        <div className="mfl-fit-block no">
          <h3 className="mfl-h3">
            <span className="icon">✕</span>
            <span>{f.no.title}</span>
          </h3>
          <ul>
            {f.no.items.map((it, i) => <li key={i}>{it}</li>)}
          </ul>
        </div>
      </div>
    </section>
  );
}

/* ─────────────────── FINAL CTA ─────────────────── */

function FinalCTA({ copy }) {
  const f = copy.final;
  return (
    <section className="mfl-section mfl-final" id="contact">
      <SectionId>{f.sid}</SectionId>
      <h2 className="mfl-h2" style={{ textAlign: copy.dir === "rtl" ? "right" : "left" }}>
        {f.h2Pre} <span className="mfl-accent">{f.h2Accent}</span> {f.h2Post}
      </h2>
      <p className="mfl-lede" style={{ marginTop: 16, textAlign: copy.dir === "rtl" ? "right" : "left" }}>{f.sub}</p>
      <div className="mfl-final-leak">
        {f.leaks.map((l, i) => <span key={i} className="chip">{l}</span>)}
      </div>
      <div style={{ marginTop: 28 }}>
        <a href="mailto:hello@clinicgrowthops.com?subject=Diagnosis%20call" className="mfl-btn mfl-btn-primary mfl-btn-block">
          {f.cta} <ArrowGlyph dir={copy.dir} />
        </a>
        <p style={{ fontSize: 13, color: "var(--text-dim)", marginTop: 16, lineHeight: 1.55 }}>{f.micro}</p>
      </div>
    </section>
  );
}

/* ─────────────────── STICKY CTA ─────────────────── */

function StickyCTA({ copy }) {
  const [show, setShow] = useStateMFL(false);
  useEffectMFL(() => {
    const onScroll = () => {
      const top = window.scrollY;
      const docH = document.documentElement.scrollHeight - window.innerHeight;
      // Show after passing the hero, hide near final CTA
      setShow(top > 480 && top < docH - 400);
    };
    window.addEventListener("scroll", onScroll, { passive: true });
    onScroll();
    return () => window.removeEventListener("scroll", onScroll);
  }, []);
  return (
    <div className={`mfl-stickycta ${show ? "" : "is-hidden"}`} aria-hidden={!show}>
      <div className="mfl-stickycta-inner">
        <a href="#book" className="mfl-btn mfl-btn-primary mfl-btn-block">
          {copy.nav.ctaShort} <ArrowGlyph dir={copy.dir} />
        </a>
      </div>
    </div>
  );
}

/* ─────────────────── SCROLL PROGRESS ─────────────────── */

function ScrollProgress() {
  const [w, setW] = useStateMFL(0);
  useEffectMFL(() => {
    const onScroll = () => {
      const docH = document.documentElement.scrollHeight - window.innerHeight;
      setW(docH > 0 ? (window.scrollY / docH) * 100 : 0);
    };
    window.addEventListener("scroll", onScroll, { passive: true });
    onScroll();
    return () => window.removeEventListener("scroll", onScroll);
  }, []);
  return <div className="mfl-progress" style={{ width: `${w}%` }} />;
}

/* ─────────────────── APP ─────────────────── */

function MobileLandingApp() {
  const [lang, setLang] = useStateMFL("ar");
  const [theme, setTheme] = useStateMFL("dark");
  const copy = COPY[lang];

  useEffectMFL(() => {
    document.documentElement.setAttribute("lang", lang);
    document.documentElement.setAttribute("dir", copy.dir);
    document.documentElement.setAttribute("data-lang", lang);
    document.body.setAttribute("data-lang", lang);
  }, [lang, copy.dir]);

  useEffectMFL(() => {
    document.documentElement.setAttribute("data-theme", theme);
    document.body.setAttribute("data-theme", theme);
    document.body.style.backgroundColor = theme === "light" ? "#F4F1EC" : "#0B1420";
  }, [theme]);

  return (
    <div className="mfl-page" data-lang={lang} data-theme={theme}>
      <ScrollProgress />
      <TopBar lang={lang} setLang={setLang} theme={theme} setTheme={setTheme} copy={copy} />
      <div className="mfl-shell">
        <Hero copy={copy} lang={lang} />
        <PainHook copy={copy} />
        <CoreEducation copy={copy} />
        <StoriesTitle copy={copy} />
        <Stories copy={copy} lang={lang} />
        <MoreLeaksAccordion copy={copy} lang={lang} />
        <Solution copy={copy} />
        <Mechanism copy={copy} />
        <BeforeAfter copy={copy} lang={lang} />
        <Diagnostic copy={copy} lang={lang} />
        <Fit copy={copy} />
        <FinalCTA copy={copy} />
        <div className="mfl-foot">{copy.foot}</div>
      </div>
      <StickyCTA copy={copy} />
    </div>
  );
}

ReactDOM.createRoot(document.getElementById("root")).render(<MobileLandingApp />);
