// OutputShowcase — tabbed left-rail + right-stage showcase.
// Architecture mirrors the template-library layout: clickable rows
// on the left, big preview panel on the right.

const { useState: useSS, useEffect: useSE, useRef: useSR } = React;

const FRAMELESS = "/illustrations-headshots-frameless";

const SHOWCASE_ITEMS = [
  {
    slug: "newsletters",
    name: "Weekly Newsletters",
    cat: "WRITTEN", catAccent: "coral",
    obj: "assets/objects/newsletters.png",
    stageBg: "var(--coral-3)",
    specTitle: "Newsletter Editor",
    specAvatar: `${FRAMELESS}/hedgehog_newsletter-editor.png`,
    specDot: "var(--orange)",
    duration: "~6 min",
    headline: "Weekly Newsletters",
    sub: "In your voice. In your rhythm. Forever.",
    preview: "newsletter",
  },
  {
    slug: "text-posts",
    name: "Text Posts",
    cat: "SOCIAL", catAccent: "pink",
    obj: "assets/objects/twitter-threads.png",
    stageBg: "var(--pink-3)",
    specTitle: "Social Director",
    specAvatar: `${FRAMELESS}/parrot_social-director.png`,
    specDot: "var(--pink-2-soft)",
    duration: "~2 min",
    headline: "Text Posts, Everywhere",
    sub: "One idea. Rewritten for Twitter, LinkedIn, and Threads.",
    preview: "threads",
  },
  {
    slug: "short-form",
    name: "Short-form Video",
    cat: "SOCIAL", catAccent: "pink",
    obj: "assets/objects/instagram-reels.png",
    stageBg: "var(--ice-3)",
    specTitle: "Video Producer",
    specAvatar: `${FRAMELESS}/otter_video-producer.png`,
    specDot: "var(--ice-2)",
    duration: "~4 min",
    headline: "Reels, TikToks, Shorts",
    sub: "Hook, script, captions, platform-native, ready to record.",
    preview: "shortform",
  },
  {
    slug: "carousels",
    name: "Carousels",
    cat: "SOCIAL", catAccent: "pink",
    obj: "assets/objects/carousel.png",
    stageBg: "var(--pink-3)",
    specTitle: "Slide Designer",
    specAvatar: `${FRAMELESS}/magpie_slide-designer.png`,
    specDot: "var(--pink-2)",
    duration: "~5 min",
    headline: "Carousels",
    sub: "Instagram and LinkedIn decks that actually get saved.",
    preview: "carousel",
  },
  {
    slug: "long-form-video",
    name: "Long-form Scripts",
    cat: "VIDEO", catAccent: "ice",
    obj: "assets/objects/video.png",
    stageBg: "var(--ice-3)",
    specTitle: "Video Producer",
    specAvatar: `${FRAMELESS}/otter_video-producer.png`,
    specDot: "var(--ice-2)",
    duration: "~8 min",
    headline: "Long-form Video Scripts",
    sub: "YouTube, webinars, and keynotes. Beat-for-beat.",
    preview: "script",
  },
  {
    slug: "podcast",
    name: "Podcast Outlines",
    cat: "SPOKEN", catAccent: "gold",
    obj: "assets/objects/podcast.png",
    stageBg: "var(--gold-3)",
    specTitle: "Podcast Producer",
    specAvatar: `${FRAMELESS}/bear_podcast-producer.png`,
    specDot: "var(--gold-2-soft)",
    duration: "~5 min",
    headline: "Podcast Outlines & Show Notes",
    sub: "Threads of thought. Timestamps. Pull-quotes. Done.",
    preview: "podcast",
  },
  {
    slug: "sales",
    name: "Sales Pages",
    cat: "MARKETING", catAccent: "iris",
    obj: "assets/objects/sales-pages.png",
    stageBg: "var(--iris-3)",
    specTitle: "Sales Page Builder",
    specAvatar: `${FRAMELESS}/raccoon_sales-page-builder.png`,
    specDot: "var(--iris-2)",
    duration: "~12 min",
    headline: "Sales Pages",
    sub: "Long-form conversion copy that sounds like you, not a funnel.",
    preview: "sales",
  },
  {
    slug: "email",
    name: "Email Sequences",
    cat: "MARKETING", catAccent: "sage",
    obj: "assets/objects/sequences.png",
    stageBg: "var(--sage-3)",
    specTitle: "Email Strategist",
    specAvatar: `${FRAMELESS}/owl_email-strategist.png`,
    specDot: "var(--sage-2)",
    duration: "~7 min",
    headline: "Email Sequences",
    sub: "Welcome flows, nurtures, and launches in your cadence.",
    preview: "email",
  },
  {
    slug: "slides",
    name: "Slide Decks",
    cat: "VISUAL", catAccent: "pink",
    obj: "assets/objects/presentations.png",
    stageBg: "var(--pink-3)",
    specTitle: "Slide Designer",
    specAvatar: `${FRAMELESS}/magpie_slide-designer.png`,
    specDot: "var(--pink-2)",
    duration: "~6 min",
    headline: "Slide Decks",
    sub: "Keynotes and talks drafted in your voice, ready to design.",
    preview: "slides",
  },
  {
    slug: "brand",
    name: "Brand & Design System",
    cat: "STRATEGY", catAccent: "gold",
    obj: "assets/objects/brand-kit.png",
    stageBg: "var(--gold-3)",
    specTitle: "Chief Brand Officer",
    specAvatar: `${FRAMELESS}/badger_brand-officer.png`,
    specDot: "var(--gold-2)",
    duration: "~once",
    headline: "Your Brand, Codified",
    sub: "Voice, tone, guardrails. The foundation every specialist reads from.",
    preview: "brand",
  },
  {
    slug: "repurpose",
    name: "Content Repurposer",
    cat: "REMIX", catAccent: "lime",
    obj: "assets/objects/content-repurposer.png",
    stageBg: "var(--lime-3)",
    specTitle: "Content Repurposer",
    specAvatar: `${FRAMELESS}/octopus_content-repurposer.png`,
    specDot: "var(--lime-2)",
    duration: "~3 min",
    headline: "One Asset → Ten Formats",
    sub: "Drop in a podcast or post. Out comes the whole content week.",
    preview: "repurpose",
  },
];

// ── Preview panels ────────────────────────────────────────
function PhoneFrame({ children, tint = "var(--white)" }) {
  return (
    <div style={{
      width: 300, background: "var(--ink-deep)",
      borderRadius: 36, padding: 10,
      boxShadow: "0 30px 60px -20px hsl(348 52% 15% / 0.35), 0 0 0 1px hsl(348 52% 15% / 0.08)",
    }}>
      <div style={{
        background: tint, borderRadius: 28, overflow: "hidden",
        height: 440, display: "flex", flexDirection: "column",
      }}>{children}</div>
    </div>
  );
}

function PreviewNewsletter() {
  return (
    <div style={{
      width: "100%", maxWidth: 360, background: "var(--white)",
      borderRadius: 16, border: "1px solid var(--border)",
      padding: "22px 22px", boxShadow: "var(--shadow-md)",
    }}>
      <div style={{ fontFamily: "var(--font-mono)", fontSize: 10, color: "var(--muted)", letterSpacing: "0.14em", textTransform: "uppercase", marginBottom: 12 }}>
        Issue No. 47 · Tuesday
      </div>
      <div style={{ fontFamily: "var(--font-display)", fontSize: 24, lineHeight: 1.05, letterSpacing: "-0.015em", color: "var(--ink)", marginBottom: 8 }}>
        The quiet art of <em style={{fontSize: "1.1em"}}>saying less.</em>
      </div>
      <div style={{ fontSize: 13, color: "var(--ink-light)", lineHeight: 1.55, marginBottom: 14 }}>
        I spent six years writing posts that ended with a tidy takeaway. It's the most overrated move in creator content…
      </div>
      <div style={{ height: 1, background: "var(--border)", margin: "14px 0" }} />
      <div style={{ display: "flex", gap: 6, flexWrap: "wrap" }}>
        {["Voice ✓", "Audience ✓", "Pillar: Craft"].map(t => (
          <span key={t} style={{ fontFamily: "var(--font-mono)", fontSize: 10, letterSpacing: "0.08em", textTransform: "uppercase", padding: "4px 10px", borderRadius: 999, background: "var(--coral-3)", color: "var(--coral-1)" }}>{t}</span>
        ))}
      </div>
    </div>
  );
}

function PreviewThreads() {
  const platforms = [
    { name: "Twitter / X", color: "var(--ink)", bg: "var(--white)", body: "the best clients don't want more options. they want one option they can trust. here's how i figured that out after 200 projects →" },
    { name: "LinkedIn",   color: "var(--ice-1)", bg: "var(--white)", body: "After 200 client projects I've come to believe this: the best clients don't want more options. They want one option they can trust." },
    { name: "Threads",    color: "var(--pink-1)", bg: "var(--white)", body: "hot take: 200 client projects in and I'm convinced, the best clients aren't shopping for options. they want one clear bet they can make." },
  ];
  return (
    <div style={{ display: "flex", flexDirection: "column", gap: 10, width: "100%", maxWidth: 360 }}>
      {platforms.map(p => (
        <div key={p.name} style={{
          background: p.bg, border: "1px solid var(--border)",
          borderRadius: 14, padding: "14px 16px",
          boxShadow: "var(--shadow-sm)",
        }}>
          <div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: 8 }}>
            <div style={{ fontFamily: "var(--font-mono)", fontSize: 10, letterSpacing: "0.12em", textTransform: "uppercase", color: p.color, fontWeight: 600 }}>{p.name}</div>
            <div style={{ fontFamily: "var(--font-mono)", fontSize: 10, color: "var(--muted)" }}>✓ ON-BRAND</div>
          </div>
          <div style={{ fontSize: 13, color: "var(--ink)", lineHeight: 1.55 }}>{p.body}</div>
        </div>
      ))}
    </div>
  );
}

function PreviewShortform() {
  // 9:16 video frame (Instagram Reels style). Lightweight chrome:
  // top "Reels" label, right action rail, bottom caption + handle.
  const W = 252;
  const H = Math.round(W * 16 / 9); // 448
  return (
    <div style={{
      width: W, height: H, position: "relative",
      background: "#000", borderRadius: 22, overflow: "hidden",
      boxShadow: "0 30px 60px -20px hsl(348 52% 15% / 0.35), 0 0 0 1px hsl(348 52% 15% / 0.08)",
    }}>
      {/* Scene background */}
      <div style={{
        position: "absolute", inset: 0,
        background: "linear-gradient(165deg, hsl(210 60% 28%), hsl(340 55% 32%) 65%, hsl(12 55% 38%))",
      }} />

      {/* Top: Reels label + IG logo */}
      <div style={{
        position: "absolute", top: 12, left: 14, right: 14,
        display: "flex", justifyContent: "space-between", alignItems: "center",
        color: "#fff", zIndex: 2,
      }}>
        <div style={{ fontFamily: "var(--font-display)", fontSize: 18, letterSpacing: "-0.01em", fontWeight: 600 }}>Reels</div>
        <div style={{
          width: 20, height: 20, borderRadius: 6,
          border: "1.5px solid #fff", position: "relative",
        }}>
          <div style={{ position: "absolute", inset: 3, border: "1.5px solid #fff", borderRadius: "50%" }} />
          <div style={{ position: "absolute", top: 2, right: 2, width: 3, height: 3, borderRadius: "50%", background: "#fff" }} />
        </div>
      </div>

      {/* On-screen text */}
      <div style={{ position: "absolute", left: 14, right: 52, top: "34%", zIndex: 2 }}>
        <div style={{
          fontFamily: "var(--font-display)", fontSize: 26, lineHeight: 1,
          color: "#fff", letterSpacing: "-0.02em", marginBottom: 8,
          textShadow: "0 2px 12px rgba(0,0,0,0.5)",
        }}>
          You're not behind.
        </div>
        <div style={{
          fontFamily: "var(--font-emphasis)", fontStyle: "italic", fontSize: 34,
          lineHeight: 1, color: "var(--orange)", letterSpacing: "-0.01em",
          textShadow: "0 2px 12px rgba(0,0,0,0.5)",
        }}>
          You're outnumbered.
        </div>
      </div>

      {/* Right action rail — unified line icons */}
      <div style={{
        position: "absolute", right: 10, bottom: 86, display: "flex",
        flexDirection: "column", gap: 16, alignItems: "center",
        color: "#fff", fontSize: 9, fontFamily: "var(--font-mono)", zIndex: 2,
      }}>
        {[
          {
            label: "24.1K",
            svg: (
              <path d="M12 20s-6.5-4.3-6.5-9.2A3.8 3.8 0 0 1 12 8.2a3.8 3.8 0 0 1 6.5 2.6C18.5 15.7 12 20 12 20z"
                    fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinejoin="round" />
            ),
          },
          {
            label: "486",
            svg: (
              <path d="M4.5 6.5h15v9h-6.2L8.5 19v-3.5H4.5v-9z"
                    fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinejoin="round" />
            ),
          },
          {
            label: "",
            svg: (
              <path d="M4 12l16-8-5.5 16-2.5-6.5L4 12z"
                    fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinejoin="round" />
            ),
          },
          {
            label: "",
            svg: (
              <path d="M7 4h10v16l-5-3.5L7 20V4z"
                    fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinejoin="round" />
            ),
          },
        ].map((a, i) => (
          <div key={i} style={{
            display: "flex", flexDirection: "column", alignItems: "center",
            lineHeight: 1.1, opacity: 0.95,
          }}>
            <svg viewBox="0 0 24 24" width={18} height={18} style={{ display: "block", marginBottom: 2 }}>
              {a.svg}
            </svg>
            {a.label && <div style={{ letterSpacing: "0.04em" }}>{a.label}</div>}
          </div>
        ))}
        {/* Spinning audio disc */}
        <div style={{
          width: 20, height: 20, borderRadius: "50%",
          background: "radial-gradient(circle, hsl(0 0% 20%) 30%, hsl(0 0% 8%) 31%, hsl(0 0% 8%))",
          border: "1.5px solid #fff",
        }} />
      </div>

      {/* Bottom byline + caption */}
      <div style={{ position: "absolute", left: 14, right: 52, bottom: 14, zIndex: 2, color: "#fff" }}>
        <div style={{ display: "flex", alignItems: "center", gap: 8, marginBottom: 6 }}>
          <div style={{
            width: 22, height: 22, borderRadius: "50%",
            background: "linear-gradient(135deg, hsl(12 70% 65%), hsl(340 60% 70%))",
            border: "1.5px solid #fff",
          }} />
          <div style={{ fontFamily: "var(--font-body)", fontSize: 12, fontWeight: 600 }}>@yourhandle</div>
          <div style={{
            padding: "2px 8px", borderRadius: 6, border: "1px solid #fff",
            fontFamily: "var(--font-body)", fontSize: 10, fontWeight: 600,
          }}>Follow</div>
        </div>
        <div style={{ fontFamily: "var(--font-body)", fontSize: 11, opacity: 0.95, lineHeight: 1.4 }}>
          The fifth option solopreneurs haven't heard about yet.
        </div>
        <div style={{
          fontFamily: "var(--font-mono)", fontSize: 10, opacity: 0.85,
          letterSpacing: "0.04em", marginTop: 4,
          display: "flex", alignItems: "center", gap: 6,
        }}>
          <svg viewBox="0 0 24 24" width={11} height={11}>
            <path d="M9 18V5l11-2v13" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinejoin="round" strokeLinecap="round" />
            <circle cx="6.5" cy="18" r="2.5" fill="currentColor" />
            <circle cx="17.5" cy="16" r="2.5" fill="currentColor" />
          </svg>
          <span>original audio · @yourhandle</span>
        </div>
      </div>
    </div>
  );
}

function PreviewCarousel() {
  // High-contrast slides for the pink stage, each with a small design element.
  const slides = [
    {
      h: "You're not", e: "behind.",
      bg: "var(--white)", fg: "var(--ink)", border: "1px solid var(--border)",
      deco: (
        <div style={{ display: "flex", gap: 4, marginBottom: 10 }}>
          {["var(--coral-2)", "var(--pink-2)", "var(--orange)", "var(--gold-2)"].map((c, i) => (
            <div key={i} style={{ width: 18, height: 18, borderRadius: 4, background: c }} />
          ))}
        </div>
      ),
    },
    {
      h: "You're", e: "outnumbered.",
      bg: "var(--ink-deep)", fg: "#fff", border: "none",
      deco: (
        <div style={{ position: "relative", height: 48, marginBottom: 12 }}>
          <div style={{
            position: "absolute", left: 0, top: 6, width: 30, height: 30,
            borderRadius: "50%", background: "hsl(348 40% 22%)",
            border: "1px solid hsl(348 40% 30%)",
          }} />
          <div style={{
            position: "absolute", left: 20, top: 0, width: 26, height: 26,
            borderRadius: "50%", background: "hsl(348 40% 22%)",
            border: "1px solid hsl(348 40% 30%)",
          }} />
          <div style={{
            position: "absolute", left: 40, top: 12, width: 22, height: 22,
            borderRadius: "50%", background: "hsl(348 40% 22%)",
            border: "1px solid hsl(348 40% 30%)",
          }} />
          <div style={{
            position: "absolute", right: 4, top: 4, width: 32, height: 32,
            borderRadius: "50%", background: "var(--orange)",
            boxShadow: "0 4px 14px hsl(12 72% 50% / 0.4)",
          }} />
        </div>
      ),
    },
    {
      h: "There's a", e: "fifth option.",
      bg: "var(--gold-3)", fg: "var(--ink)", border: "1px solid var(--gold-2)",
      deco: (
        <div style={{ marginBottom: 10 }}>
          <div style={{
            height: 42, borderRadius: 6,
            background: "linear-gradient(135deg, var(--gold-2), var(--orange-light))",
            border: "1px solid var(--gold-2)",
            position: "relative", overflow: "hidden",
          }}>
            <svg viewBox="0 0 100 42" preserveAspectRatio="none" style={{ width: "100%", height: "100%", position: "absolute", inset: 0 }}>
              <path d="M0 34 L20 22 L38 28 L58 12 L78 20 L100 8" fill="none" stroke="var(--orange)" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
              <circle cx="78" cy="20" r="3" fill="var(--orange)" />
            </svg>
          </div>
        </div>
      ),
    },
  ];
  return (
    <div style={{ display: "flex", gap: 12, alignItems: "center", width: "100%", maxWidth: 488, justifyContent: "center" }}>
      {slides.map((s, i) => (
        <div key={i} style={{
          flex: "1 1 0", minWidth: 0, maxWidth: 150,
          aspectRatio: "4/5", background: s.bg, borderRadius: 14,
          padding: 14, display: "flex", flexDirection: "column",
          boxShadow: "0 18px 40px -14px hsl(348 52% 15% / 0.3), var(--shadow-md)",
          color: s.fg, border: s.border,
          transform: `translateY(${i === 1 ? -8 : 0}px)`,
        }}>
          <div style={{ fontFamily: "var(--font-mono)", fontSize: 9, letterSpacing: "0.14em", opacity: 0.6, marginBottom: 8 }}>{i+1} / 3</div>
          {s.deco}
          <div style={{ marginTop: "auto" }}>
            <div style={{ fontFamily: "var(--font-display)", fontSize: 18, lineHeight: 1, letterSpacing: "-0.02em" }}>{s.h}</div>
            <div style={{ fontFamily: "var(--font-emphasis)", fontStyle: "italic", fontSize: 24, lineHeight: 1, color: "var(--orange)", marginTop: 2 }}>{s.e}</div>
          </div>
        </div>
      ))}
    </div>
  );
}

function PreviewScript() {
  const lines = [
    { tag: "COLD OPEN · 0:00",  text: "Show, don't tell. Cut to the metaphor.", tint: "var(--coral-3)", tintFg: "var(--coral-1)" },
    { tag: "HOOK · 0:12",       text: "'I spent six years doing it the wrong way. Here's the shift that changed everything.'", tint: "var(--orange-light)", tintFg: "var(--orange-deep)" },
    { tag: "ACT 1 · 0:45",      text: "The problem: it's not a discipline problem. It's a volume problem.", tint: "var(--ice-3)", tintFg: "var(--ice-1)" },
    { tag: "ACT 2 · 3:10",      text: "The four failed attempts. Specific, painful, paced.", tint: "var(--gold-3)", tintFg: "var(--gold-1)" },
    { tag: "CTA · 8:30",        text: "One sentence. Looking at the camera.", tint: "var(--sage-3)", tintFg: "var(--sage-1)" },
  ];
  return (
    <div style={{
      width: "100%", maxWidth: 420, background: "var(--white)", borderRadius: 16,
      border: "1px solid var(--border)", padding: 18, boxShadow: "var(--shadow-md)",
    }}>
      <div style={{ fontFamily: "var(--font-mono)", fontSize: 10, letterSpacing: "0.14em", color: "var(--muted)", textTransform: "uppercase", marginBottom: 14 }}>
        YouTube · 9-minute essay · Beat sheet
      </div>
      {lines.map((l, i) => (
        <div key={i} style={{ display: "flex", gap: 12, marginBottom: 12, alignItems: "flex-start" }}>
          <div style={{ fontFamily: "var(--font-mono)", fontSize: 9, letterSpacing: "0.08em", background: l.tint, color: l.tintFg, padding: "4px 8px", borderRadius: 6, whiteSpace: "nowrap" }}>{l.tag}</div>
          <div style={{ fontSize: 13, color: "var(--ink)", lineHeight: 1.5 }}>{l.text}</div>
        </div>
      ))}
    </div>
  );
}

function PreviewPodcast() {
  return (
    <div style={{ width: "100%", maxWidth: 400, display: "flex", flexDirection: "column", gap: 10 }}>
      <div style={{ background: "var(--white)", borderRadius: 14, border: "1px solid var(--border)", padding: 16, boxShadow: "var(--shadow-md)" }}>
        <div style={{ fontFamily: "var(--font-mono)", fontSize: 10, color: "var(--gold-1)", letterSpacing: "0.14em", marginBottom: 8 }}>EP. 84 · SHOW NOTES</div>
        <div style={{ fontFamily: "var(--font-display)", fontSize: 20, lineHeight: 1.1, letterSpacing: "-0.015em", marginBottom: 10 }}>
          The case for a <em>studio</em> of one.
        </div>
        {["02:14 · Why hiring freelancers fails", "14:32 · The context problem", "26:40 · Ten specialists, one window", "38:15 · What a Tuesday looks like"].map(l => (
          <div key={l} style={{ fontSize: 12, color: "var(--ink-light)", padding: "4px 0", fontFamily: "var(--font-mono)" }}>{l}</div>
        ))}
      </div>
      <div style={{ background: "var(--ink-deep)", color: "#fff", borderRadius: 14, padding: "12px 16px", fontSize: 12, lineHeight: 1.5, fontStyle: "italic", fontFamily: "var(--font-emphasis)" }}>
        "You're not behind. You're outnumbered. And that's a fixable problem."
      </div>
    </div>
  );
}

function PreviewSales() {
  return (
    <div style={{ width: "100%", maxWidth: 360, background: "var(--white)", borderRadius: 16, border: "1px solid var(--border)", overflow: "hidden", boxShadow: "var(--shadow-md)" }}>
      <div style={{ padding: "28px 24px", background: "radial-gradient(ellipse 80% 70% at 20% 20%, hsla(258, 50%, 85%, 0.5), transparent 60%), var(--white)" }}>
        <div style={{ fontFamily: "var(--font-mono)", fontSize: 10, color: "var(--iris-1)", letterSpacing: "0.14em", marginBottom: 12 }}>INTRODUCING</div>
        <div style={{ fontFamily: "var(--font-display)", fontSize: 30, lineHeight: 1, letterSpacing: "-0.02em", marginBottom: 12 }}>
          Build a one-person studio that ships like <em>ten.</em>
        </div>
        <div style={{ fontSize: 13, color: "var(--ink-light)", lineHeight: 1.55, marginBottom: 16 }}>
          Ten specialists. One brand-context layer. A studio that runs every day after cohort.
        </div>
        <div style={{ display: "inline-flex", padding: "10px 16px", borderRadius: 999, background: "var(--orange)", color: "#fff", fontFamily: "var(--font-body)", fontSize: 13, fontWeight: 600 }}>
          Join the founding cohort →
        </div>
      </div>
      <div style={{ background: "var(--snow)", padding: "14px 24px", fontFamily: "var(--font-mono)", fontSize: 10, letterSpacing: "0.1em", color: "var(--muted)" }}>
        Problem → Options → Fifth way → Proof → Price → FAQ → CTA
      </div>
    </div>
  );
}

function PreviewEmail() {
  const seq = [
    { t: "Day 00 · Welcome",     s: "The thing you came here for." },
    { t: "Day 02 · The reframe", s: "You're not behind." },
    { t: "Day 05 · Story",       s: "Why I stopped hiring freelancers." },
    { t: "Day 07 · Case",        s: "How Kelly ships in 90 minutes." },
    { t: "Day 09 · Invitation",  s: "Here's what the studio unlocks." },
  ];
  return (
    <div style={{ width: "100%", maxWidth: 380, background: "var(--white)", borderRadius: 16, border: "1px solid var(--border)", padding: 16, boxShadow: "var(--shadow-md)" }}>
      <div style={{ fontFamily: "var(--font-mono)", fontSize: 10, color: "var(--sage-1)", letterSpacing: "0.14em", marginBottom: 14 }}>WELCOME SEQUENCE · 5 EMAILS</div>
      {seq.map((e, i) => (
        <div key={i} style={{ display: "flex", gap: 12, alignItems: "center", padding: "10px 0", borderTop: i ? "1px solid var(--border)" : "none" }}>
          <div style={{ width: 26, height: 26, borderRadius: 8, background: "var(--sage-3)", color: "var(--sage-1)", display: "flex", alignItems: "center", justifyContent: "center", fontFamily: "var(--font-mono)", fontSize: 10 }}>{String(i+1).padStart(2, "0")}</div>
          <div style={{ flex: 1 }}>
            <div style={{ fontFamily: "var(--font-mono)", fontSize: 10, color: "var(--muted)", letterSpacing: "0.1em" }}>{e.t}</div>
            <div style={{ fontSize: 14, color: "var(--ink)" }}>{e.s}</div>
          </div>
        </div>
      ))}
    </div>
  );
}

function PreviewSlides() {
  // Three slides stacked vertically, compact so they fit the square-ish
  // preview area instead of stretching into a long rectangle.
  const slides = [
    {
      n: "01",
      t: "Your content dies at volume.",
      render: () => (
        <div style={{ display: "flex", gap: 10, alignItems: "stretch", flex: 1 }}>
          <div style={{
            flex: "0 0 72px", borderRadius: 6,
            background: "linear-gradient(135deg, var(--pink-3), var(--iris-3))",
            border: "1px solid var(--border)",
            position: "relative", overflow: "hidden",
          }}>
            <svg viewBox="0 0 100 60" preserveAspectRatio="none" style={{ width: "100%", height: "100%", position: "absolute", inset: 0 }}>
              <polygon points="0,60 30,28 48,45 72,18 100,40 100,60" fill="hsl(258 25% 60%)" opacity="0.5" />
              <polygon points="0,60 20,40 45,52 70,35 100,50 100,60" fill="hsl(340 30% 55%)" opacity="0.55" />
              <circle cx="78" cy="15" r="5" fill="hsl(38 80% 75%)" opacity="0.7" />
            </svg>
          </div>
          <div style={{ flex: 1, display: "flex", flexDirection: "column", justifyContent: "center", gap: 4 }}>
            <div style={{ height: 5, width: "90%", borderRadius: 3, background: "var(--cloud)" }} />
            <div style={{ height: 5, width: "70%", borderRadius: 3, background: "var(--cloud)" }} />
            <div style={{ height: 5, width: "80%", borderRadius: 3, background: "var(--cloud)" }} />
          </div>
        </div>
      ),
    },
    {
      n: "02",
      t: "The four failing options.",
      render: () => (
        <div style={{ flex: 1, display: "grid", gridTemplateColumns: "1fr 1fr", gap: 5 }}>
          {[
            { bg: "var(--coral-3)", tint: "var(--coral-2)" },
            { bg: "var(--iris-3)",  tint: "var(--iris-2)"  },
            { bg: "var(--gold-3)",  tint: "var(--gold-2)"  },
            { bg: "var(--sage-3)",  tint: "var(--sage-2)"  },
          ].map((c, i) => (
            <div key={i} style={{
              background: c.bg, borderRadius: 4, padding: "3px 6px",
              display: "flex", alignItems: "center", gap: 5,
            }}>
              <div style={{ width: 7, height: 7, borderRadius: "50%", background: c.tint, flexShrink: 0 }} />
              <div style={{ flex: 1, display: "flex", flexDirection: "column", gap: 2 }}>
                <div style={{ height: 3, width: "80%", borderRadius: 2, background: c.tint, opacity: 0.8 }} />
                <div style={{ height: 3, width: "55%", borderRadius: 2, background: c.tint, opacity: 0.5 }} />
              </div>
            </div>
          ))}
        </div>
      ),
    },
    {
      n: "03",
      t: "There's a fifth way.",
      render: () => (
        <div style={{
          flex: 1, display: "flex", alignItems: "center", justifyContent: "center",
          position: "relative",
        }}>
          {[
            { x:  0, y:  14 },
            { x: 18, y:   0 },
            { x:  0, y: -14 },
            { x: -18, y:  0 },
          ].map((p, i) => (
            <div key={i} style={{
              position: "absolute",
              left: `calc(50% + ${p.x}px)`,
              top:  `calc(50% + ${p.y}px)`,
              transform: "translate(-50%, -50%)",
              width: 12, height: 12, borderRadius: "50%",
              background: "var(--cloud)", border: "1px solid var(--border)",
            }} />
          ))}
          <div style={{
            position: "relative", zIndex: 2,
            width: 30, height: 30, borderRadius: "50%",
            background: "var(--orange)",
            boxShadow: "0 6px 14px -4px hsl(12 72% 50% / 0.5)",
            display: "flex", alignItems: "center", justifyContent: "center",
            color: "#fff", fontFamily: "var(--font-emphasis)", fontStyle: "italic", fontSize: 14,
          }}>5</div>
        </div>
      ),
    },
  ];
  return (
    <div style={{ display: "flex", gap: 8, flexDirection: "column", width: "100%", maxWidth: 260 }}>
      {slides.map((s, i) => (
        <div key={s.n} style={{
          background: "var(--white)", border: "1px solid var(--border)",
          borderRadius: 10, padding: "8px 12px",
          boxShadow: "var(--shadow-sm)", aspectRatio: "16 / 7",
          display: "flex", flexDirection: "column", gap: 6,
          transform: `translateX(${i * 6}px)`,
        }}>
          <div style={{ display: "flex", justifyContent: "space-between", alignItems: "baseline", gap: 8 }}>
            <div style={{ fontFamily: "var(--font-mono)", fontSize: 8, letterSpacing: "0.14em", color: "var(--muted)" }}>SLIDE {s.n}</div>
            <div style={{ fontFamily: "var(--font-display)", fontSize: 13, letterSpacing: "-0.015em", lineHeight: 1.05, color: "var(--ink)" }}>{s.t}</div>
          </div>
          {s.render()}
        </div>
      ))}
    </div>
  );
}

function PreviewBrand() {
  const fields = [
    ["VOICE",     "Warm. Direct. Period-for-emphasis."],
    ["AUDIENCE",  "Solopreneur creators, $50k–$500k ARR."],
    ["OFFERS",    "The Studio · The Cohort Pass · The Guide"],
    ["PILLARS",   "Craft · Calm · Solo · Systems"],
    ["NEVER",     "'AI-powered' · 'scale' · 'crush it'"],
  ];
  return (
    <div style={{ width: "100%", maxWidth: 380, background: "var(--white)", border: "1px solid var(--border)", borderRadius: 16, padding: 20, boxShadow: "var(--shadow-md)" }}>
      <div style={{ fontFamily: "var(--font-mono)", fontSize: 10, color: "var(--gold-1)", letterSpacing: "0.14em", marginBottom: 14 }}>BRAND CONTEXT · LIVE</div>
      {fields.map(([k, v]) => (
        <div key={k} style={{ marginBottom: 12 }}>
          <div style={{ fontFamily: "var(--font-mono)", fontSize: 9, letterSpacing: "0.14em", color: "var(--muted)", marginBottom: 3 }}>{k}</div>
          <div style={{ fontSize: 14, color: "var(--ink)", lineHeight: 1.45 }}>{v}</div>
        </div>
      ))}
      <div style={{ marginTop: 14, padding: "8px 12px", background: "var(--gold-3)", borderRadius: 8, fontFamily: "var(--font-mono)", fontSize: 10, color: "var(--gold-1)", letterSpacing: "0.1em", textAlign: "center" }}>
        ALL 10 SPECIALISTS READ FROM THIS
      </div>
    </div>
  );
}

function PreviewRepurpose() {
  return (
    <div style={{ width: "100%", maxWidth: 400 }}>
      <div style={{ background: "var(--white)", border: "1px solid var(--border)", borderRadius: 14, padding: "14px 18px", boxShadow: "var(--shadow-md)", marginBottom: 16, display: "flex", alignItems: "center", gap: 12 }}>
        <div style={{ width: 36, height: 36, borderRadius: 10, background: "var(--lime-3)", display: "flex", alignItems: "center", justifyContent: "center", fontFamily: "var(--font-mono)", fontSize: 14, color: "var(--lime-1)" }}>↑</div>
        <div style={{ flex: 1 }}>
          <div style={{ fontSize: 14, color: "var(--ink)", fontWeight: 600 }}>Episode 84.mp3</div>
          <div style={{ fontFamily: "var(--font-mono)", fontSize: 10, color: "var(--muted)", letterSpacing: "0.1em" }}>42:18 · PODCAST · DROPPED</div>
        </div>
      </div>
      <div style={{ textAlign: "center", fontFamily: "var(--font-emphasis)", fontStyle: "italic", fontSize: 20, color: "var(--orange)", marginBottom: 16 }}>
        becomes
      </div>
      <div style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 8 }}>
        {["Newsletter", "3 Reels", "LinkedIn post", "Tweet thread", "Blog post", "Show notes", "4 Carousels", "Email", "Quote cards"].map(l => (
          <div key={l} style={{ background: "var(--lime-3)", color: "var(--lime-1)", fontFamily: "var(--font-mono)", fontSize: 10, letterSpacing: "0.08em", textTransform: "uppercase", padding: "10px 8px", borderRadius: 10, textAlign: "center", fontWeight: 500 }}>{l}</div>
        ))}
      </div>
    </div>
  );
}

const PREVIEWS = {
  newsletter: PreviewNewsletter,
  threads: PreviewThreads,
  shortform: PreviewShortform,
  carousel: PreviewCarousel,
  script: PreviewScript,
  podcast: PreviewPodcast,
  sales: PreviewSales,
  email: PreviewEmail,
  slides: PreviewSlides,
  brand: PreviewBrand,
  repurpose: PreviewRepurpose,
};

window.OutputShowcase = function OutputShowcase() {
  const [active, setActive] = useSS("text-posts");
  const [paused, setPaused] = useSS(false);
  const stageRef = useSR(null);
  const railRef = useSR(null);
  const item = SHOWCASE_ITEMS.find(i => i.slug === active);
  const Preview = PREVIEWS[item.preview];

  // Keep the active tab visible in the horizontal tab strip (tablet + mobile).
  // Scroll the rail's own scrollLeft instead of scrollIntoView so we never
  // scroll the page vertically (which was yanking readers back to this section).
  useSE(() => {
    if (typeof window === "undefined") return;
    if (window.innerWidth > 1024) return;
    const rail = railRef.current;
    if (!rail) return;
    const btn = rail.querySelector(`[data-slug="${active}"]`);
    if (!btn) return;
    const target = btn.offsetLeft - (rail.clientWidth / 2) + (btn.clientWidth / 2);
    rail.scrollTo({ left: target, behavior: "smooth" });
  }, [active]);

  // Auto-advance — 5s per slide, paused on hover.
  const DURATION_MS = 5000;
  const [progressKey, setProgressKey] = useSS(0);
  useSE(() => {
    if (paused) return;
    const id = setTimeout(() => {
      const idx = SHOWCASE_ITEMS.findIndex(i => i.slug === active);
      const next = SHOWCASE_ITEMS[(idx + 1) % SHOWCASE_ITEMS.length];
      setActive(next.slug);
    }, DURATION_MS);
    return () => clearTimeout(id);
  }, [active, paused]);

  // Bump progress key whenever active slide or pause state changes so the
  // progress bar animation restarts from 0.
  useSE(() => { setProgressKey(k => k + 1); }, [active, paused]);

  const pickSlug = (slug) => {
    setActive(slug);
    if (typeof window !== "undefined" && window.innerWidth <= 900) {
      setTimeout(() => {
        stageRef.current?.scrollIntoView({ behavior: "smooth", block: "start" });
      }, 40);
    }
  };

  return (
    <section className="scs-section-tight" style={{ padding: "120px 32px", background: "var(--snow)", position: "relative", overflow: "hidden" }}
             onMouseEnter={() => setPaused(true)}
             onMouseLeave={() => setPaused(false)}>
      <div style={{ position: "absolute", inset: 0, pointerEvents: "none",
        background: "radial-gradient(ellipse 60% 40% at 50% 0%, hsla(12, 80%, 85%, 0.3), transparent 60%)" }} />

      <div style={{ position: "relative", maxWidth: 1200, margin: "0 auto" }}>
        {/* Header — centered, single unified title */}
        <div style={{ marginBottom: 56, textAlign: "center", maxWidth: 920, marginInline: "auto" }}>
          <window.Eyebrow style={{ marginBottom: 14, color: "var(--orange)" }}>One studio for everything you create</window.Eyebrow>
          <h2 style={{ fontSize: "clamp(40px, 5.2vw, 68px)", lineHeight: 1.05, letterSpacing: "-0.025em", margin: 0 }}>
            Your whole content operation<br />
            in one place. <em>In your voice.</em>
          </h2>
        </div>

        {/* Tabs label */}
        <div style={{
          fontFamily: "var(--font-mono)", fontSize: 10, letterSpacing: "0.16em",
          textTransform: "uppercase", color: "var(--muted)",
          paddingLeft: 4, marginBottom: 12,
        }}>
          Eleven formats · Tailored by platform
        </div>

        {/* Two-column layout: left rail + right stage. Stacks on narrow via .scs-output-layout. */}
        <div className="scs-output-layout" style={{ display: "grid", gridTemplateColumns: "minmax(280px, 380px) 1fr", gap: 16, alignItems: "stretch" }}>
          {/* Left rail — becomes a horizontal scrolling tab strip on narrow via .scs-output-rail-inner */}
          <div ref={railRef} className="scs-output-rail scs-output-rail-inner" style={{ display: "flex", flexDirection: "column", gap: 2 }}>
            {SHOWCASE_ITEMS.map((it, idx) => {
              const isActive = it.slug === active;
              return (
                <button key={it.slug} data-slug={it.slug} onClick={() => pickSlug(it.slug)}
                  style={{
                    all: "unset", cursor: "pointer",
                    display: "flex", alignItems: "center", gap: 14,
                    padding: "14px 14px 12px", borderRadius: 14,
                    background: isActive ? it.stageBg : "transparent",
                    transition: "background 0.2s ease",
                    border: "1px solid transparent",
                    borderColor: isActive ? "var(--border)" : "transparent",
                    position: "relative",
                    overflow: "hidden",
                  }}
                  onMouseEnter={e => !isActive && (e.currentTarget.style.background = "var(--white)")}
                  onMouseLeave={e => !isActive && (e.currentTarget.style.background = "transparent")}
                >
                  {/* Timer bar — only on the active row */}
                  {isActive && (
                    <div key={progressKey} style={{
                      position: "absolute", top: 0, left: 0, height: 3,
                      background: `var(--${it.catAccent}-1)`,
                      borderRadius: "0 3px 3px 0",
                      animation: paused
                        ? "none"
                        : `scsProgress ${DURATION_MS}ms linear forwards`,
                      opacity: 0.85,
                    }} />
                  )}
                  <div aria-hidden="true" style={{
                    width: 36, height: 36, borderRadius: "50%",
                    position: "relative", flexShrink: 0,
                    display: "flex", alignItems: "center", justifyContent: "center",
                    color: "var(--ink)",
                    fontFamily: "var(--font-display)", fontSize: 16, fontWeight: 600,
                    letterSpacing: "-0.01em", lineHeight: 1,
                    boxShadow: isActive ? `0 4px 12px hsl(0 0% 0% / 0.12)` : "none",
                  }}>
                    <span aria-hidden="true" style={{
                      position: "absolute", inset: 0, borderRadius: "50%",
                      background: it.specDot, opacity: 0.5,
                    }} />
                    <span style={{ position: "relative" }}>{idx + 1}</span>
                  </div>
                  <div style={{
                    flex: 1, fontFamily: "var(--font-emphasis)", fontStyle: "italic",
                    fontSize: 19, color: "var(--ink)", lineHeight: 1.15, letterSpacing: "-0.01em",
                  }}>{it.name}</div>
                </button>
              );
            })}
          </div>

          {/* Right stage */}
          <div key={active} ref={stageRef} className="scs-output-stage" style={{
            background: item.stageBg, borderRadius: 24,
            padding: "40px 44px", position: "relative", overflow: "hidden",
            display: "flex", flexDirection: "column", minHeight: 560,
            animation: "scsStageIn 0.5s cubic-bezier(0.22, 1, 0.36, 1)",
            scrollMarginTop: 16,
          }}>
            {/* decorative jar */}
            <img src={item.obj} alt="" className="scs-output-obj" style={{
              position: "absolute", top: 24, right: 28,
              width: 125, height: 125, objectFit: "contain", opacity: 0.95,
            }} />

            {/* headline block (no cat/duration) */}
            <div className="scs-output-head" style={{ maxWidth: 540, marginBottom: 32 }}>
              <h3 className="scs-output-stage-h3" style={{ fontFamily: "var(--font-display)", fontSize: 40, letterSpacing: "-0.025em", lineHeight: 1, margin: "0 0 10px", color: "var(--ink)" }}>
                {item.headline}
              </h3>
              <p style={{ fontSize: 17, color: "var(--ink-light)", lineHeight: 1.5, margin: 0, maxWidth: 460 }}>
                {item.sub}
              </p>
            </div>

            {/* preview artifact */}
            <div className="scs-output-preview-wrap" style={{ flex: 1, display: "flex", alignItems: "center", justifyContent: "center", marginTop: 10 }}>
              <Preview />
            </div>

            {/* footer line: who runs this */}
            <div style={{
              marginTop: 28, padding: "6px 18px 6px 6px",
              background: "hsla(0,0%,100%,0.65)", borderRadius: 999,
              display: "inline-flex", alignItems: "center", gap: 10, alignSelf: "flex-start",
              border: "1px solid hsla(0,0%,100%,0.6)",
            }}>
              <img src={item.specAvatar} alt="" style={{
                width: 32, height: 32, borderRadius: "50%", objectFit: "contain",
                background: "var(--white)", flexShrink: 0,
              }} />
              <span style={{ fontFamily: "var(--font-mono)", fontSize: 11, letterSpacing: "0.12em", textTransform: "uppercase", color: "var(--ink)" }}>
                Built by your {item.specTitle}
              </span>
            </div>
          </div>
        </div>

        {/* Bottom context strip */}
        <div style={{
          marginTop: 36, padding: "22px 28px", background: "var(--white)",
          border: "1px solid var(--border)", borderRadius: 20,
          display: "flex", alignItems: "center", justifyContent: "space-between", gap: 20, flexWrap: "wrap",
          boxShadow: "var(--shadow-sm)",
        }}>
          <div style={{ fontFamily: "var(--font-emphasis)", fontStyle: "italic", fontSize: 22, color: "var(--ink)", lineHeight: 1.2, flex: "1 1 auto" }}>
            Every specialist reads from <span style={{ color: "var(--orange)" }}>one brand-context layer.</span>
          </div>
          <div style={{ display: "flex", gap: 6, flexWrap: "wrap" }}>
            {["Voice profile", "Audience", "Offers", "Content pillars", "Preferences"].map(l => (
              <span key={l} style={{ fontFamily: "var(--font-mono)", fontSize: 10, letterSpacing: "0.1em", textTransform: "uppercase", padding: "6px 12px", borderRadius: 999, background: "var(--snow)", color: "var(--ink-light)", border: "1px solid var(--border)" }}>{l}</span>
            ))}
          </div>
        </div>
      </div>
    </section>
  );
};
