/* Morpara Digital Wallet — case study (route: case/morpara).
   Same editorial structure & component patterns as the Stablex V2 page,
   re-themed to the single dark surface #2B1243. Imagery uses the supplied
   device-gallery montages (onboarding / explore / home-wallets).
   Site fonts (Clash Display / Cabinet Grotesk). Green accent kept for tags. */

const MP_DARK = "#2B1243";
const MP_HL = "#C9A6F2";           /* hero highlight (light purple) */
const MP_TINT = "rgba(43,18,67,.05)";
const MP_TINT2 = "rgba(43,18,67,.07)";

const MP_GALERI1 = (typeof window !== "undefined" && window.__resources && window.__resources.morparaGaleri1) || "assets/morpara-galeri-1.png";
const MP_GALERI2 = (typeof window !== "undefined" && window.__resources && window.__resources.morparaGaleri2) || "assets/morpara-galeri-2.png";
const MP_EXPLORE_1 = (typeof window !== "undefined" && window.__resources && window.__resources.morparaExplore1) || "assets/morpara-explore-1.png";
const MP_EXPLORE_2 = (typeof window !== "undefined" && window.__resources && window.__resources.morparaExplore2) || "assets/morpara-explore-2.png";
const MP_EXPLORE_3 = (typeof window !== "undefined" && window.__resources && window.__resources.morparaExplore3) || "assets/morpara-explore-3.png";
const MP_EXPLORE_1B = (typeof window !== "undefined" && window.__resources && window.__resources.morparaExplore1b) || "assets/morpara-explore-1new.png";
const MP_LOGIN_VIDEO = (typeof window !== "undefined" && window.__resources && window.__resources.morparaLoginVideo) || "assets/morpara-login-2.mp4";
const MP_VERIFIED_VIDEO = (typeof window !== "undefined" && window.__resources && window.__resources.morparaVerifiedVideo) || "assets/morpara-verified.mp4";
const MP_CONTRACTED_VIDEO = (typeof window !== "undefined" && window.__resources && window.__resources.morparaContractedVideo) || "assets/morpara-contracted-3.mp4";
const MP_VERIFIED2_VIDEO = (typeof window !== "undefined" && window.__resources && window.__resources.morparaVerified2Video) || "assets/morpara-verified-4.mp4";
const MP_KAPAK = (typeof window !== "undefined" && window.__resources && window.__resources.morparaKapak) || "assets/morpara-kapak.png";
const MP_LOGO = (typeof window !== "undefined" && window.__resources && window.__resources.morparaLogo) || "assets/morpara-logo.png";
const MP_BEFORE = (typeof window !== "undefined" && window.__resources && window.__resources.morparaBefore) || "assets/morpara-before.png";
const MP_PROBLEM_AFTER = (typeof window !== "undefined" && window.__resources && window.__resources.morparaProblemAfter) || "assets/morpara-problem-after.png";
const MP_FINAL_VIDEO = (typeof window !== "undefined" && window.__resources && window.__resources.morparaFinalVideo) || "assets/morpara-final-video.mp4";
const MP_DS_GALLERY = [
  (typeof window !== "undefined" && window.__resources && window.__resources.morparaDs3) || "assets/morpara-ds-3.png",
  (typeof window !== "undefined" && window.__resources && window.__resources.morparaDs4) || "assets/morpara-ds-4.png",
  (typeof window !== "undefined" && window.__resources && window.__resources.morparaDs5) || "assets/morpara-ds-5.png",
  (typeof window !== "undefined" && window.__resources && window.__resources.morparaDs6) || "assets/morpara-ds-6.png",
];

/* ---------- local building blocks ---------- */

function MPPill({ children, dark = false }) {
  return (
    <span className="inline-flex items-center whitespace-nowrap rounded-full border px-3.5 py-1.5 text-[14px] uppercase tracking-[0.18em]"
          style={dark ? { borderColor: "rgba(255,255,255,.3)", color: "rgba(255,255,255,.7)" } : { borderColor: "rgba(15,26,22,.25)", color: "rgba(15,26,22,.6)" }}>
      {children}
    </span>
  );
}

function MPCol({ children, className = "" }) {
  return <div className={`mx-auto px-6 max-w-[680px] ${className}`}>{children}</div>;
}

/* wide tinted panel that breaks out of the text column */
function MPPanel({ children, caption, tint = "#F4F4F5", className = "", maxW = "1080px", pad = "p-0", dark = false }) {
  return (
    <figure className={`mx-auto px-6 ${className}`} style={{ maxWidth: maxW }}>
      <div className={`rounded-2xl overflow-hidden ${pad}`} style={{ background: tint }}>
        {children}
      </div>
      {caption && <figcaption className="mt-3 text-[14px]" style={{ color: dark ? "rgba(255,255,255,.55)" : "rgba(15,26,22,.5)" }}>{caption}</figcaption>}
    </figure>
  );
}

/* single device frame with a screenshot (or a labelled placeholder) */
function MPPhone({ src, label, frame = "#1A0E26", className = "" }) {
  return (
    <div className={`relative w-full ${className}`}>
      <div className="relative" style={{ background: frame, borderRadius: "1.5rem", padding: 5, aspectRatio: "9 / 19", boxShadow: "0 40px 90px -45px rgba(0,0,0,.6)" }}>
        <div className="relative w-full h-full overflow-hidden grid place-items-center" style={{ borderRadius: "1.2rem", background: src ? "#2B1243" : undefined }}>
          {src ? (
            <img src={src} alt={label} draggable="false" className="absolute inset-0 w-full h-full object-cover object-top select-none" />
          ) : (
            <div className="absolute inset-0 grid place-items-center" style={{ background: "rgba(255,255,255,.05)", border: "1px dashed rgba(255,255,255,.18)", borderRadius: "1.2rem" }}>
              <span className="text-[11px] uppercase tracking-[0.16em] px-3 text-center leading-relaxed" style={{ color: "rgba(255,255,255,.4)" }}>{label}</span>
            </div>
          )}
        </div>
      </div>
    </div>
  );
}

/* bare video (already contains its own device mockup) + tap-to-play button.
   No extra frame — object-contain on the matching light panel so there is no
   black strip above/below the baked-in mockup. */
function MPVideoBare({ src, className = "" }) {
  const ref = React.useRef(null);
  const [playing, setPlaying] = React.useState(false);
  const toggle = () => {
    const v = ref.current; if (!v) return;
    if (v.paused) { v.play(); setPlaying(true); } else { v.pause(); setPlaying(false); }
  };
  return (
    <div className={`relative w-full overflow-hidden ${className}`} style={{ aspectRatio: "9 / 19.5", borderRadius: 14 }}>
      <video
        ref={ref}
        src={src}
        playsInline
        loop
        preload="metadata"
        onEnded={() => setPlaying(false)}
        onClick={toggle}
        className="absolute object-cover cursor-pointer"
        style={{ top: -2, left: -10, width: "calc(100% + 20px)", height: "calc(100% + 4px)" }}
      />
      {!playing && (
        <button
          onClick={toggle}
          aria-label="Play video"
          className="absolute inset-0 grid place-items-center"
        >
          <span className="grid place-items-center rounded-full" style={{ width: 64, height: 64, background: "rgba(255,255,255,.8)", boxShadow: "0 10px 30px -8px rgba(0,0,0,.4)" }}>
            <svg width="26" height="26" viewBox="0 0 24 24" fill="#1A0E26"><path d="M8 5v14l11-7z" /></svg>
          </span>
        </button>
      )}
    </div>
  );
}

/* device frame holding a video, with a tap-to-play button */
function MPVideoPhone({ src, frame = "#1A0E26", className = "" }) {
  const ref = React.useRef(null);
  const [playing, setPlaying] = React.useState(false);
  const toggle = () => {
    const v = ref.current; if (!v) return;
    if (v.paused) { v.play(); setPlaying(true); } else { v.pause(); setPlaying(false); }
  };
  return (
    <div className={`relative w-full ${className}`}>
      <div className="relative" style={{ background: frame, borderRadius: "1.5rem", padding: 5, aspectRatio: "9 / 19", boxShadow: "0 40px 90px -45px rgba(0,0,0,.6)" }}>
        <div className="relative w-full h-full overflow-hidden grid place-items-center" style={{ borderRadius: "1.2rem", background: "#2B1243" }}>
          <video
            ref={ref}
            src={src}
            playsInline
            loop
            preload="metadata"
            onEnded={() => setPlaying(false)}
            onClick={toggle}
            className="absolute inset-0 w-full h-full object-cover object-top cursor-pointer"
          />
          {!playing && (
            <button
              onClick={toggle}
              aria-label="Play video"
              className="absolute inset-0 grid place-items-center"
              style={{ background: "rgba(43,18,67,.18)" }}
            >
              <span className="grid place-items-center rounded-full" style={{ width: 76, height: 76, background: "rgba(255,255,255,.8)", boxShadow: "0 10px 30px -8px rgba(0,0,0,.4)" }}>
                <svg width="30" height="30" viewBox="0 0 24 24" fill="#1A0E26"><path d="M8 5v14l11-7z" /></svg>
              </span>
            </button>
          )}
        </div>
      </div>
    </div>
  );
}

/* full montage image, sits on a tinted panel */
function MPShot({ src, alt, tint = "#F6F1F9", className = "" }) {
  return (
    <div className={`rounded-2xl overflow-hidden ${className}`} style={{ background: tint }}>
      <img src={src} alt={alt} draggable="false" className="w-full h-auto block select-none" />
    </div>
  );
}

/* horizontal image gallery with prev/next arrows + dots */
function MPGallery({ images, alt = "Design system" }) {
  const [i, setI] = React.useState(0);
  const [stuck, setStuck] = React.useState(false);
  const barRef = React.useRef(null);
  React.useEffect(() => {
    const onScroll = () => { const el = barRef.current; if (!el) return; setStuck(el.getBoundingClientRect().top <= 0.5); };
    onScroll();
    window.addEventListener("scroll", onScroll, { passive: true });
    window.addEventListener("resize", onScroll);
    return () => { window.removeEventListener("scroll", onScroll); window.removeEventListener("resize", onScroll); };
  }, []);
  const n = images.length;
  const go = (d) => setI((p) => (p + d + n) % n);
  return (
    <div className="rounded-2xl" style={{ background: "#EDE7F2" }}>
      {/* top control bar — part of the window card at first; full-bleed once it sticks */}
      <div ref={barRef} className="flex items-center justify-between py-3.5"
           style={{ background: "#E7DEF0", position: "sticky", top: 0, zIndex: 60,
             ...(stuck
               ? { width: "100vw", marginLeft: "calc(50% - 50vw)", paddingLeft: 40, paddingRight: 40, borderBottom: "1px solid rgba(43,18,67,.1)" }
               : { width: "100%", marginLeft: 0, paddingLeft: 24, paddingRight: 24, borderTopLeftRadius: 16, borderTopRightRadius: 16 }) }}>
        <div className="flex items-center gap-1.5">
          {images.map((_, k) => (
            <button key={k} onClick={() => setI(k)} aria-label={`Go to ${k + 1}`}
              className="h-[3px] rounded-full overflow-hidden transition-all duration-300"
              style={{ width: k === i ? 32 : 16, background: "rgba(43,18,67,.18)" }}>
              <span className="block h-full rounded-full transition-all duration-500"
                style={{ width: k === i ? "100%" : "0%", background: MP_DARK }} />
            </button>
          ))}
        </div>
        <div className="flex items-center gap-2">
          <button onClick={() => go(-1)} aria-label="Previous"
            className="grid place-items-center rounded-full transition-colors"
            style={{ width: 34, height: 34, background: "rgba(255,255,255,.7)", border: "1px solid rgba(43,18,67,.12)" }}>
            <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke={MP_DARK} strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M15 18l-6-6 6-6" /></svg>
          </button>
          <button onClick={() => go(1)} aria-label="Next"
            className="grid place-items-center rounded-full transition-colors"
            style={{ width: 34, height: 34, background: "rgba(255,255,255,.7)", border: "1px solid rgba(43,18,67,.12)" }}>
            <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke={MP_DARK} strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M9 6l6 6-6 6" /></svg>
          </button>
        </div>
      </div>
      <div className="overflow-hidden rounded-b-2xl">
        <div className="flex transition-transform duration-500 ease-out" style={{ transform: `translateX(-${i * 100}%)` }}>
          {images.map((src, k) => (
            <img key={k} src={src} alt={`${alt} ${k + 1}`} draggable="false" className="w-full flex-shrink-0 h-auto block select-none" />
          ))}
        </div>
      </div>
    </div>
  );
}

/* light striped placeholder for missing visuals */
function MPPlaceholder({ label, height = 300 }) {
  return (
    <div className="grid place-items-center rounded-2xl overflow-hidden"
         style={{ height, backgroundImage: "repeating-linear-gradient(45deg, rgba(43,18,67,.06) 0 10px, transparent 10px 20px)", background: "rgba(43,18,67,.04)" }}>
      <span className="text-[12px] uppercase tracking-[0.2em] px-4 text-center" style={{ color: "rgba(43,18,67,.45)" }}>{label}</span>
    </div>
  );
}

/* bottom floating section navigator (same dock pattern as Stablex) */
function MPSectionNav() {
  const items = [
    ["mp-problem", "Problem"], ["mp-discovery", "Discovery"], ["mp-decisions", "Decisions"],
    ["mp-final", "Final design"], ["mp-impact", "Impact"],
  ];
  const [active, setActive] = React.useState("mp-problem");
  const [shown, setShown] = React.useState(false);
  const [navUp, setNavUp] = React.useState(false);
  const lastYRef = React.useRef(0);
  React.useEffect(() => {
    const pick = () => {
      const mid = window.scrollY + window.innerHeight * 0.5;
      let current = items[0][0];
      for (const [id] of items) {
        const el = document.getElementById(id);
        if (el && el.getBoundingClientRect().top + window.scrollY <= mid) current = id;
      }
      setActive(current);
      const y = window.scrollY;
      setShown(y > 40);
      if (y < lastYRef.current - 2) setNavUp(true);
      else if (y > lastYRef.current + 2 || y <= 2) setNavUp(false);
      lastYRef.current = y;
    };
    pick();
    window.addEventListener("scroll", pick, { passive: true });
    window.addEventListener("resize", pick);
    return () => { window.removeEventListener("scroll", pick); window.removeEventListener("resize", pick); };
  }, []);
  const go = (e, id) => {
    e.preventDefault();
    const el = document.getElementById(id);
    if (el) window.scrollTo({ top: el.getBoundingClientRect().top + window.scrollY - 80, behavior: "smooth" });
  };
  return (
    <React.Fragment>
    <nav className="md:hidden fixed left-0 right-0 z-40" style={{ top: navUp ? 64 : 0, opacity: shown ? 1 : 0, transition: "opacity .4s ease, top .3s ease", pointerEvents: shown ? "auto" : "none" }}>
      <div className="flex items-center gap-1 overflow-x-auto px-3 py-2" style={{ background: MP_DARK, borderBottom: "1px solid rgba(255,255,255,0.12)", WebkitOverflowScrolling: "touch" }}>
        {items.map(([id, label]) => {
          const on = active === id;
          return (
            <a key={id} href={`#${id}`} onClick={(e) => go(e, id)}
               className="shrink-0 text-[11px] uppercase tracking-[0.12em] rounded-full px-3.5 py-1.5 whitespace-nowrap"
               style={on ? { background: "#4A2A6B", color: "#ffffff", fontWeight: 600 } : { color: "rgba(255,255,255,0.55)" }}>
              {label}
            </a>
          );
        })}
      </div>
    </nav>
    <nav className="hidden md:block fixed left-1/2 z-40"
         style={{
           bottom: 24,
           transform: `translateX(-50%) translateY(${shown ? 0 : 28}px)`,
           opacity: shown ? 1 : 0,
           pointerEvents: shown ? "auto" : "none",
           transition: "opacity .5s cubic-bezier(0.16,1,0.3,1), transform .5s cubic-bezier(0.16,1,0.3,1)",
         }}>
      <div className="flex items-center gap-1 rounded-full px-2 py-2"
           style={{ background: MP_DARK, border: "1px solid rgba(255,255,255,0.1)", boxShadow: "0 16px 50px -18px rgba(0,0,0,0.9)" }}>
        {items.map(([id, label]) => {
          const on = active === id;
          return (
            <a key={id} href={`#${id}`} onClick={(e) => go(e, id)}
               className="text-[12px] uppercase tracking-[0.14em] rounded-full px-3.5 py-2 transition-all duration-300 whitespace-nowrap"
               style={on ? { background: "#4A2A6B", color: "#ffffff", fontWeight: 600 } : { color: "rgba(255,255,255,0.5)" }}>
              {label}
            </a>
          );
        })}
      </div>
    </nav>
    </React.Fragment>
  );
}

/* numbered decision block */
function MPDecision({ n, title, body, influence, panel, caption, tint, panelMaxW, dark = false }) {
  const titleColor = dark ? "#fff" : MP_DARK;
  return (
    <div className="mt-24 first:mt-16">
      <MPCol>
        <Reveal>
          <h3 className="font-display font-medium text-[24px] md:text-[30px] leading-[1.15] tracking-tight">
            <span style={{ color: titleColor }}>{n}.</span> <span style={{ color: titleColor }}>{title}</span>
          </h3>
        </Reveal>
        <Reveal delay={70}>
          <p className="mt-4 text-[20px] leading-[1.7]" style={{ color: dark ? "rgba(255,255,255,.8)" : "rgba(15,26,22,.78)" }}>{body}</p>
        </Reveal>
        {influence && (
          <Reveal delay={160}>
            <p className="mt-4 text-[16px] leading-[1.6] rounded-lg px-4 py-3 inline-block" style={dark ? { background: "rgba(21,217,151,.16)", color: "rgba(255,255,255,.8)" } : { background: "rgba(21,217,151,.1)", color: "rgba(15,26,22,.7)" }}>
              <span className="uppercase tracking-[0.14em] text-[12px]" style={{ color: dark ? MP_HL : MP_DARK }}>My influence · </span>
              {influence}
            </p>
          </Reveal>
        )}
      </MPCol>
      <Reveal delay={120}>
        <MPPanel caption={caption} tint={tint} maxW={panelMaxW || "1080px"} className="mt-10" dark={dark}>
          {panel}
        </MPPanel>
      </Reveal>
    </div>
  );
}

/* ---------- the page ---------- */

/* Scroll-linked "SPOILER ALERT" card below the Summary — same behaviour as the
   Stablex page, themed to Morpara's #2B1243. Opens (pushing content down) as
   the summary scrolls to the top, closes again on scroll up. */
function MPSpoilerCard() {
  const [open, setOpen] = React.useState(false);
  React.useEffect(() => {
    const tick = () => {
      const sum = document.getElementById("mp-summary");
      if (!sum) return;
      const vh = window.innerHeight;
      const sT = sum.getBoundingClientRect().top;
      setOpen((o) => (o ? sT < vh * 0.05 : sT < -vh * 0.05));
    };
    tick();
    window.addEventListener("scroll", tick, { passive: true });
    window.addEventListener("resize", tick);
    return () => { window.removeEventListener("scroll", tick); window.removeEventListener("resize", tick); };
  }, []);
  const metrics = [
    ["3.2% → 14.1%", "Account-upgrade rate"],
    ["1.1% → 3.8%", "Campaign redemption rate"],
  ];
  return (
    <div
      style={{
        overflow: "hidden",
        maxHeight: open ? "360px" : "0px",
        opacity: open ? 1 : 0,
        marginTop: open ? "20px" : "0px",
        transition: "max-height .8s cubic-bezier(0.16,1,0.3,1), opacity .6s ease, margin-top .8s cubic-bezier(0.16,1,0.3,1)",
      }}>
      <div className="rounded-2xl px-7 py-7 md:px-9 md:py-8" style={{ background: MP_DARK, color: "#fff", transform: open ? "translateY(0) scale(1)" : "translateY(14px) scale(.93)", transformOrigin: "top center", transition: "transform .72s cubic-bezier(0.34,1.56,0.64,1) .05s" }}>
        <div className="text-[12px] uppercase tracking-[0.24em]" style={{ color: MP_HL }}>Spoiler alert</div>
        <div className="mt-5 grid grid-cols-1 sm:grid-cols-2 gap-7 sm:gap-10">
          {metrics.map(([num, label], i) => (
            <div key={i}>
              <div className="font-display font-normal text-[34px] md:text-[40px] leading-none tracking-tight" style={{ color: MP_HL }}>{num}</div>
              <div className="mt-3 text-[15px] text-white/85 leading-snug">{label}</div>
            </div>
          ))}
        </div>
      </div>
    </div>
  );
}

function MorparaCase({ navigate }) {
  return (
    <div className="relative" style={{ background: "#FCFCFC", color: "#0f1a16" }}>
      <MPSectionNav />

      {/* 1 — HERO */}
      <header className="relative overflow-hidden" style={{ background: MP_DARK, color: "#fff" }}>
        <div className="mx-auto max-w-[1080px] px-6 pt-36 pb-36">
          <Reveal delay={40}>
            <a href="https://apps.apple.com/tr/app/morpara/id1672014463" target="_blank" rel="noopener noreferrer" aria-label="View Morpara on the App Store" className="md:hidden inline-block mb-5">
              <img src={MP_LOGO} alt="Morpara" draggable="false" className="block rounded-2xl select-none" style={{ width: 72, height: 72 }} />
            </a>
          </Reveal>
          <Reveal>
            <div className="text-[14px] uppercase tracking-[0.22em] text-white/45">Morpara Digital Wallet · 2024</div>
          </Reveal>
          <div className="mt-6 flex items-center justify-between gap-10">
            <Reveal delay={80}>
              <h1 className="font-display font-medium text-[40px] md:text-[58px] leading-[1.06] tracking-[-0.02em] max-w-[18ch]" style={{ color: "#ffffff" }}>
                A flawless verification flow. But upgrades stayed flat. <span style={{ color: MP_HL }}>Why?</span>
              </h1>
            </Reveal>
            <Reveal delay={120}>
              <a href="https://apps.apple.com/tr/app/morpara/id1672014463" target="_blank" rel="noopener noreferrer" aria-label="View Morpara on the App Store" className="hidden md:block shrink-0 transition-transform hover:-translate-y-1">
                <img src={MP_LOGO} alt="Morpara" draggable="false"
                     className="block rounded-2xl select-none"
                     style={{ width: 160, height: 160, boxShadow: "0 30px 70px -30px rgba(43,18,67,.8)" }} />
              </a>
            </Reveal>
          </div>
        </div>
      </header>

      {/* 2 — SUMMARY CARD */}
      {/* 2 — SUMMARY CARD */}
      <section id="mp-summary" className="pt-20 pb-24">
        <MPCol>
          <Reveal>
            <div className="rounded-2xl px-7 py-7 md:px-9 md:py-8" style={{ background: "#F6F1F9" }}>
              <div className="text-[14px] uppercase tracking-[0.2em]" style={{ color: "rgba(15,26,22,.5)" }}>Summary</div>
              <p className="mt-4 text-[20px] leading-[1.7]" style={{ color: "rgba(15,26,22,.85)" }}>
                Morpara is a digital wallet app with multi-currency accounts, a card, and a campaigns hub, operating in the Netherlands, Turkey, and Russia. As the design lead at their agency, I owned the <strong className="font-bold" style={{ color: "#0f1a16" }}>UX design</strong> end-to-end and led the <strong className="font-bold" style={{ color: "#0f1a16" }}>Researcher</strong> and <strong className="font-bold" style={{ color: "#0f1a16" }}>UI Designer</strong> on the team, directing the process and signing off on every final decision.
              </p>
            </div>
          </Reveal>
          <MPSpoilerCard />
        </MPCol>
      </section>

      {/* 3 — THE PROBLEM */}
      <section id="mp-problem" className="pb-28">
        <MPCol>
          <Reveal><MPPill>The problem</MPPill></Reveal>
          <Reveal delay={70}>
            <h2 className="mt-6 font-display font-medium text-[28px] md:text-[36px] leading-[1.12] tracking-tight" style={{ color: MP_DARK }}>
              One metric healed. Another stayed sick.
            </h2>
          </Reveal>
          <Reveal delay={130}>
            <p className="mt-6 text-[20px] leading-[1.7]" style={{ color: "rgba(15,26,22,.78)" }}>
              We&apos;d redesigned Morpara and shipped it six months earlier: especially the ID verification flow, which had an unusually high abandonment rate. That rate dropped from ~75% to 42%, a clear win.
              <br /><br />
              But one number refused to move: <strong className="font-bold" style={{ color: MP_DARK }}>the ratio of ID-verified users to total users</strong> stayed flat. We thought the barrier was gone. <strong className="font-bold" style={{ color: MP_DARK }}>The upgrade rate</strong> said no.
            </p>
          </Reveal>
        </MPCol>
        <div className="mx-auto px-6 max-w-[1080px] mt-12 space-y-6">
          <Reveal delay={120}>
            <figure>
              <MPShot src={MP_BEFORE} alt="Morpara — original KYC flow" tint="#F6F1F9" />
              <figcaption className="mt-3 text-[14px]" style={{ color: "rgba(15,26,22,.5)" }}>Before: the old KYC flow. Abandonment was the problem here.</figcaption>
            </figure>
          </Reveal>
          <Reveal delay={160}>
            <figure>
              <MPShot src={MP_PROBLEM_AFTER} alt="Morpara redesigned onboarding & upgrade flow" tint="#F6F1F9" />
              <figcaption className="mt-3 text-[14px]" style={{ color: "rgba(15,26,22,.5)" }}>After: our redesign, shipped six months ago. Abandonment dropped. Upgrade rate didn&apos;t follow. <span style={{ color: "rgba(15,26,22,.38)" }}>(This is the redesign we shipped six months prior: the one that solved abandonment but not upgrade rate.)</span></figcaption>
            </figure>
          </Reveal>
        </div>
      </section>

      {/* 4 — DISCOVERY */}
      <section id="mp-discovery" className="py-24" style={{ background: "#F4F4F5" }}>
        <MPCol>
          <Reveal><MPPill>Discovery</MPPill></Reveal>
          <Reveal delay={70}>
            <h2 className="mt-6 font-display font-medium text-[28px] md:text-[36px] leading-[1.12] tracking-tight" style={{ color: MP_DARK }}>
              Time to look at the upgrade rate from a different angle.
            </h2>
          </Reveal>
          <Reveal delay={130}>
            <p className="mt-6 text-[20px] leading-[1.7]" style={{ color: "rgba(15,26,22,.78)" }}>
              This section breaks into three parts: what we suspected, how we tested it, and what we found.
            </p>
          </Reveal>

          {/* What we suspected */}
          <Reveal delay={120}>
            <div className="mt-14">
              <div className="text-[14px] uppercase tracking-[0.2em] font-medium" style={{ color: MP_DARK }}>What we suspected</div>
              <p className="mt-4 text-[16px] leading-[1.6] rounded-lg px-4 py-3" style={{ background: "rgba(21,217,151,.1)", color: "rgba(15,26,22,.7)" }}>
                <span className="uppercase tracking-[0.14em] text-[12px]" style={{ color: MP_DARK }}>My influence · </span>
                I drew up this list of suspected causes myself heuristically, before the research started — and one of them turned out to be exactly right.
              </p>
              <div className="mt-5 space-y-3">
                {[
                  { t: "The prompts nudging users to upgrade weren't strong enough.", tag: "Navigation Problem" },
                  { t: "Users might be misreading “Upgrade” as a paid action, not a free identity step.", tag: "Wording Problem" },
                  { t: "The campaign eligibility requirement (being ID-verified) might not be communicated clearly enough.", tag: "Visibility Problem" },
                ].map((h, i) => (
                  <div key={i} className="rounded-2xl px-6 py-5 flex flex-col gap-3 md:flex-row md:items-center md:justify-between md:gap-6" style={{ background: "#FFFFFF" }}>
                    <p className="text-[17px] leading-[1.5]" style={{ color: "rgba(15,26,22,.82)" }}>{h.t}</p>
                    {h.tag && (
                      <span className="inline-flex shrink-0 items-center rounded-full px-3.5 py-1.5 text-[13px] font-medium uppercase tracking-[0.08em]" style={{ background: MP_TINT, color: "#0f1a16" }}>{h.tag}</span>
                    )}
                  </div>
                ))}
              </div>
            </div>
          </Reveal>

          {/* What we asked */}
          <Reveal delay={120}>
            <div className="mt-14">
              <div className="text-[14px] uppercase tracking-[0.2em] font-medium" style={{ color: MP_DARK }}>What we asked</div>
              <p className="mt-4 text-[16px] leading-[1.6] rounded-lg px-4 py-3" style={{ background: "rgba(21,217,151,.1)", color: "rgba(15,26,22,.7)" }}>
                <span className="uppercase tracking-[0.14em] text-[12px]" style={{ color: MP_DARK }}>My influence · </span>
                I defined the four research angles and moderated the sessions myself.
              </p>
              <p className="mt-5 text-[19px] leading-[1.65]" style={{ color: "rgba(15,26,22,.82)" }}>
                We ran a think-aloud <strong className="font-bold" style={{ color: MP_DARK }}>usability study with 7 participants</strong>, structured around four angles:
                {" "}<strong className="font-bold" style={{ color: MP_DARK }}>Awareness</strong>,
                {" "}<strong className="font-bold" style={{ color: MP_DARK }}>Value perception</strong>,
                {" "}<strong className="font-bold" style={{ color: MP_DARK }}>Motivation</strong>,
                {" "}<strong className="font-bold" style={{ color: MP_DARK }}>Usability &amp; copy test</strong>.
              </p>
              <details className="mt-5 group rounded-2xl overflow-hidden" style={{ background: "#FFFFFF" }}>
                <summary className="cursor-pointer list-none select-none px-6 py-4 flex items-center justify-between text-[15px] font-medium" style={{ color: MP_DARK }}>
                  <span>See the four research angles</span>
                  <span className="transition-transform duration-200 group-open:rotate-45 text-[22px] leading-none" style={{ color: "rgba(15,26,22,.5)" }}>+</span>
                </summary>
                <div className="px-6 pb-6 space-y-6 border-t" style={{ borderColor: "rgba(15,26,22,.08)" }}>
                  {[
                    { label: "Awareness", q: "Do you know if there's an account type beyond Beginner? Can you describe, in your own words, what's different between the two?", d: "Users could see the “Upgrade” button, but didn't tap it — they didn't know what was behind it." },
                    { label: "Value perception", q: "What advantages or campaigns do you think a verified user gets that an unverified one doesn't?", d: "Users hadn't realized campaigns were exclusive to ID-verified accounts, or hadn't noticed the campaigns section at all." },
                    { label: "Motivation", q: "Have you ever looked at the campaigns on the home screen or your profile? Did anything catch your interest? If so, did you understand what you'd need to do to claim it?", d: "The campaign visuals were appealing, but the call to action — “Verify now and earn” — wasn't clear." },
                    { label: "Usability & copy test", q: "Shown the current campaign/upgrade screen: what's the first thing you notice here? What does this screen promise you? What does the word “Upgrade” mean to you?", d: null },
                  ].map((a, i) => (
                    <div key={i} className="pt-6 first:pt-6">
                      <div className="text-[13px] uppercase tracking-[0.12em] font-medium" style={{ color: MP_DARK }}>{a.label}</div>
                      <p className="mt-2 text-[16px] leading-[1.6] italic" style={{ color: "rgba(15,26,22,.7)" }}>“{a.q}”</p>
                      {a.d && (
                        <p className="mt-3 text-[15px] leading-[1.6] rounded-xl px-4 py-3" style={{ background: MP_TINT, color: "rgba(15,26,22,.82)" }}>
                          <strong className="font-bold" style={{ color: MP_DARK }}>Discovery:</strong> {a.d}
                        </p>
                      )}
                    </div>
                  ))}
                </div>
              </details>
            </div>
          </Reveal>

          {/* What we found */}
          <Reveal delay={120}>
            <div className="mt-14">
              <div className="text-[14px] uppercase tracking-[0.2em] font-medium" style={{ color: MP_DARK }}>What we found</div>
              <p className="mt-5 text-[20px] leading-[1.7]" style={{ color: "rgba(15,26,22,.82)" }}>
                The problem wasn't navigation, it was the absence of a reason. It's called the
                {" "}<strong className="font-bold" style={{ color: MP_DARK }}>Friction Reduction Illusion</strong>:
                teams polish the technical steps of a funnel but miss the core motivation a user needs to start it.
                What gets someone moving isn't a better design. It's a clear answer to one question:
                {" "}<strong className="font-bold" style={{ color: MP_DARK }}>what's in it for me?</strong>
              </p>
            </div>
          </Reveal>
        </MPCol>
      </section>

      {/* 5 — DECISIONS */}
      <section id="mp-decisions" className="py-28" style={{ background: MP_DARK }}>
        <MPCol>
          <Reveal><MPPill dark>Key decisions</MPPill></Reveal>
          <Reveal delay={70}>
            <h2 className="mt-6 font-display font-medium text-[28px] md:text-[36px] leading-[1.12] tracking-tight" style={{ color: "#fff" }}>
              Two decisions changed how people saw what was on the other side of verification.
            </h2>
          </Reveal>
        </MPCol>

        <MPDecision
          dark
          n="1" title="Unify incentives under “Explore”"
          body="The brand's potential incentives (campaigns, free transfers, multi-currency accounts, the card) were scattered across the app with no single home. We consolidated all of it under one Explore surface, so the value of having an ID Verified account became visible and findable."
          influence="I defined the Explore taxonomy and which benefits qualified for inclusion — the order users meet value in, before they're ever asked to verify."
          caption="Explore brings campaigns, accounts and the card under one findable surface."
          tint="#F6F1F9"
          panel={<div className="p-5 md:p-8"><div className="grid grid-cols-2 md:grid-cols-4 gap-4 md:gap-6"><MPPhone src={MP_EXPLORE_1B} label="Welcome" /><MPPhone src={MP_EXPLORE_2} label="Home" /><MPPhone src={MP_EXPLORE_3} label="Welcome" /><MPVideoPhone src={MP_LOGIN_VIDEO} /></div></div>}
        />
        <MPDecision
          dark
          n="2" title="Story-format campaign browsing"
          body="We replaced static campaign cards with a story-style format, matching consumption patterns from prior research: stories get tapped through at far higher rates than cards. After ID verification, the “Explore” feature no longer appears on the home page."
          caption="Story-style campaign format — Basic vs. ID verified user states."
          tint="#F6F1F9"
          panelMaxW="680px"
          panel={<div className="p-5 md:p-8"><div className="grid grid-cols-1 md:grid-cols-2 gap-8 md:gap-6 mx-auto max-w-[94%] md:max-w-[86%]"><MPVideoPhone src={MP_VERIFIED2_VIDEO} /><MPVideoPhone src={MP_CONTRACTED_VIDEO} /></div></div>}
        />
      </section>

      {/* 6 — FINAL DESIGN (+ design system) */}
      <section id="mp-final" className="py-28" style={{ background: "#FFFFFF" }}>
        <MPCol className="text-center">
          <Reveal><MPPill>Final design</MPPill></Reveal>
        </MPCol>

        <Reveal delay={90}>
          <MPPanel className="mt-12" tint="#F6F1F9" pad="p-5 md:p-8" caption="Home & wallets — the everyday surface, balances and quick send.">
            <div style={{ overflow: "hidden", borderRadius: "12px", lineHeight: 0 }}>
              <video src={MP_FINAL_VIDEO} autoPlay loop muted playsInline preload="auto" className="w-full h-auto block select-none" />
            </div>
          </MPPanel>
        </Reveal>
        <Reveal delay={90}>
          <MPPanel className="mt-8" tint="transparent" pad="p-0" caption="Explore & cards — campaigns, multi-currency accounts, card and transactions.">
            <img src={MP_GALERI2} alt="Morpara explore & cards" draggable="false" className="w-full h-auto block rounded-xl select-none" />
          </MPPanel>
        </Reveal>

        {/* Design system — compact sub-section */}
        <MPCol className="mt-20">
          <Reveal>
            <h3 className="font-display font-medium text-[22px] md:text-[26px] leading-[1.15] tracking-tight" style={{ color: "#0f1a16" }}>Design system</h3>
          </Reveal>
          <Reveal delay={70}>
            <p className="mt-3 text-[19px] md:text-[20px] leading-[1.55]" style={{ color: "rgba(15,26,22,.5)" }}>
              One token-based source of truth, built on Figma Variables.
            </p>
          </Reveal>
          <Reveal delay={100}>
            <div className="mt-6 flex flex-wrap gap-2">
              {["Colors", "Grid", "Text Styles", "Icons", "Shadows", "Components", "Organisms", "Animation Assets"].map((m) => (
                <span key={m} className="inline-flex items-center whitespace-nowrap rounded-full px-3.5 py-1.5 text-[13px]"
                      style={{ background: "#F6F1F9", color: "rgba(15,26,22,.65)" }}>{m}</span>
              ))}
            </div>
          </Reveal>
        </MPCol>
        <Reveal delay={110}>
          <div className="mx-auto px-6 max-w-[1080px] mt-10">
            <MPGallery images={MP_DS_GALLERY} alt="Morpara design system" />
          </div>
        </Reveal>
        <MPCol className="mt-7">
          <Reveal delay={140}>
            <p className="text-[16px] leading-[1.6] rounded-lg px-4 py-3 inline-block" style={{ background: "rgba(21,217,151,.1)", color: "rgba(15,26,22,.7)" }}>
              <span className="uppercase tracking-[0.14em] text-[12px]" style={{ color: MP_DARK }}>My influence · </span>
              My role here was direction, not execution. I guided the UI designer and approved every screen.
            </p>
          </Reveal>
          <Reveal delay={180}>
            <div className="mt-6 flex flex-wrap gap-x-8 gap-y-3 text-[16px]">
              <a href="https://apps.apple.com/tr/app/morpara/id1672014463" target="_blank" rel="noopener noreferrer"
                 className="inline-block"
                 style={{ color: "#0E8C63", textDecoration: "underline", textUnderlineOffset: "3px", textDecorationColor: "rgba(14,140,99,.4)" }}>
                View in App Store →
              </a>
              <a href="https://play.google.com/store/apps/details?id=com.morpara.wallet.tr&hl=en" target="_blank" rel="noopener noreferrer"
                 className="inline-block"
                 style={{ color: "#0E8C63", textDecoration: "underline", textUnderlineOffset: "3px", textDecorationColor: "rgba(14,140,99,.4)" }}>
                View in Play Store →
              </a>
            </div>
          </Reveal>
        </MPCol>
      </section>

      {/* 7 — IMPACT (dummy numbers) */}
      <section id="mp-impact" className="py-28" style={{ background: MP_DARK, color: "#fff" }}>
        <MPCol>
          <Reveal><span className="inline-flex items-center rounded-full border border-white/25 px-3.5 py-1.5 text-[14px] uppercase tracking-[0.18em] text-white/60">Impact</span></Reveal>
          <Reveal delay={60}>
            <div className="mt-5"></div>
          </Reveal>
          <div className="mt-8 grid grid-cols-1 sm:grid-cols-2 gap-10">
            {[
              ["3.2% → 14.1%", "Account-upgrade rate", "in first 4 months"],
              ["1.1% → 3.8%", "Campaign redemption rate", "in first 3 months"],
            ].map(([num, label, micro]) => (
              <Reveal key={label}>
                <div>
                  <div className="font-display font-normal text-[36px] md:text-[44px] leading-none tracking-tight" style={{ color: "#15D997" }}>{num}</div>
                  <div className="mt-3 text-[16px] text-white/85">{label}</div>
                  <div className="mt-1.5 text-[14px] leading-[1.6] text-white/45">{micro}</div>
                </div>
              </Reveal>
            ))}
          </div>
        </MPCol>
      </section>

      {/* 8 — BEHIND THE WORK */}
      <section className="py-24">
        <MPCol>
          <Reveal>
            <div className="rounded-2xl px-7 py-8 md:px-9" style={{ background: MP_TINT }}>
              <div className="text-[14px] uppercase tracking-[0.2em]" style={{ color: "rgba(15,26,22,.5)" }}>Behind the work</div>
              <div className="mt-6 grid grid-cols-2 md:grid-cols-3 gap-y-6 gap-x-6 text-[16px]">
                <div>
                  <div className="text-[14px] uppercase tracking-[0.14em]" style={{ color: MP_DARK }}>Role</div>
                  <div className="mt-1.5" style={{ color: "rgba(15,26,22,.85)" }}>Design Lead (process &amp; final calls) &amp; UX Designer</div>
                </div>
                <div>
                  <div className="text-[14px] uppercase tracking-[0.14em]" style={{ color: MP_DARK }}>Team</div>
                  <div className="mt-1.5" style={{ color: "rgba(15,26,22,.85)" }}>Researcher · UI Designer · Project Manager · Design Lead (me)</div>
                </div>
                <div>
                  <div className="text-[14px] uppercase tracking-[0.14em]" style={{ color: MP_DARK }}>Date</div>
                  <div className="mt-1.5" style={{ color: "rgba(15,26,22,.85)" }}>2024</div>
                </div>
              </div>
              <div className="mt-7 pt-6" style={{ borderTop: "1px solid rgba(43,18,67,.12)" }}>
                <div className="text-[14px] uppercase tracking-[0.14em]" style={{ color: MP_DARK }}>What I learned</div>
                <p className="mt-2 text-[16px] leading-[1.7]" style={{ color: "rgba(15,26,22,.75)" }}>
                  As product designers, we sometimes get so focused on crafting the perfect flow or the
                  perfect screen that it stops being entirely healthy. We have to care about the user — but
                  not at the cost of losing sight of the product owner&apos;s perspective. The two have to be held
                  together, and this project was a clear reminder of that.
                </p>
              </div>
            </div>
          </Reveal>
        </MPCol>
      </section>

      {/* 9 — FOOTER */}
      <section className="py-12" style={{ background: MP_DARK, color: "#fff" }}>
        <Reveal>
          <div className="w-full px-6 md:px-10">
            <div className="grid grid-cols-2 gap-8 md:flex md:items-center md:justify-between md:gap-6">
              <button onClick={() => { navigate("case/stablex"); window.scrollTo({ top: 0 }); }} className="text-left shrink-0 order-2 md:order-none">
                <div className="text-[12px] uppercase tracking-[0.18em] text-white/45">Previous project</div>
                <div className="mt-1.5 font-display text-[20px] md:text-[22px] text-white">Stablex</div>
              </button>
              <div className="flex flex-col items-center text-center gap-2 col-span-2 order-1 md:order-none flex-1">
                <h2 className="font-display font-normal text-[28px] md:text-[48px] leading-[1] tracking-tight">
                  Let's work <span style={{ color: MP_HL }}>together</span><span style={{ color: "rgba(255,255,255,.25)" }}>.</span>
                </h2>
                <a href="mailto:tunaaldemir@gmail.com" className="mt-3 inline-block font-display text-[15px] md:text-[18px] text-white/80 hover:text-white link-underline">
                  tunaaldemir@gmail.com
                </a>
                <a href={/iPhone|iPad|iPod|Android/i.test(navigator.userAgent) ? "tel:+31634483433" : "facetime:+31634483433"}
                   className="inline-block font-display text-[13px] md:text-[15px] text-white/45 hover:text-white/75">
                  +31 06 34 48 34 33
                </a>
                <div className="mt-3 flex items-center gap-3">
                  <a href="https://wa.me/905353130311" target="_blank" rel="noopener noreferrer" aria-label="WhatsApp" className="transition-transform hover:-translate-y-0.5">
                    <svg width="34" height="34" viewBox="0 0 34 34" fill="none" xmlns="http://www.w3.org/2000/svg">
                      <circle cx="17" cy="17" r="17" fill="#fff"/>
                      <g transform="translate(7 7) scale(0.833)">
                        <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-.149-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.885-9.885 9.885M20.52 3.449C18.24 1.245 15.24 0 12.045 0 5.463 0 .104 5.334.101 11.892c0 2.096.549 4.142 1.595 5.945L0 24l6.335-1.652a12.062 12.062 0 005.71 1.447h.005c6.585 0 11.946-5.335 11.949-11.893a11.821 11.821 0 00-3.484-8.45" fill={MP_DARK}/>
                      </g>
                    </svg>
                  </a>
                  <a href="https://www.linkedin.com/in/tuna-aldemir/" target="_blank" rel="noopener noreferrer" aria-label="LinkedIn" className="transition-transform hover:-translate-y-0.5">
                    <svg width="34" height="34" viewBox="0 0 34 34" fill="none" xmlns="http://www.w3.org/2000/svg">
                      <circle cx="17" cy="17" r="17" fill="#fff"/>
                      <path d="M12.6 13.2a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Zm-1.27 1.15h2.53v8.15h-2.53v-8.15Zm4.12 0h2.42v1.11h.04c.34-.62 1.16-1.28 2.39-1.28 2.56 0 3.03 1.64 3.03 3.78v4.54h-2.53v-4.03c0-.96-.02-2.2-1.36-2.2-1.36 0-1.57 1.04-1.57 2.13v4.1h-2.53v-8.15Z" fill={MP_DARK}/>
                    </svg>
                  </a>
                  <a href="assets/Tuna_Aldemir_CV.pdf" target="_blank" rel="noopener noreferrer" aria-label="View CV" className="transition-transform hover:-translate-y-0.5">
                    <span className="grid place-items-center size-[34px] rounded-full" style={{ background: "#fff", color: MP_DARK }}>
                      <span className="font-display font-semibold text-[13px] tracking-tight">CV</span>
                    </span>
                  </a>
                </div>
              </div>
              <button onClick={() => { navigate("case/algora"); window.scrollTo({ top: 0 }); }} className="text-right shrink-0 order-3 md:order-none justify-self-end">
                <div className="text-[12px] uppercase tracking-[0.18em] text-white/45">Next project</div>
                <div className="mt-1.5 font-display text-[20px] md:text-[22px] text-white">Algora</div>
              </button>
            </div>
          </div>
        </Reveal>
      </section>
    </div>
  );
}

window.MorparaCase = MorparaCase;
