/* global React, ReactDOM, TweaksPanel, useTweaks, TweakSection, TweakRadio, TweakToggle, TweakSelect */

const { useState, useEffect, useRef } = React;

const TWEAK_DEFAULTS = /*EDITMODE-BEGIN*/{
  "palette": "acid",
  "showLiveDemo": "screenshot",
  "marqueeOn": true,
  "stickerOn": true,
  "stepsLayout": "grid",
  "heroFont": "archivo"
} /*EDITMODE-END*/;

// ── Reveal on scroll ────────────────────────────────────────────────────────
function useReveal() {
  useEffect(() => {
    const els = document.querySelectorAll('.reveal');
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => {if (e.isIntersecting) e.target.classList.add('in');});
    }, { threshold: 0.1 });
    els.forEach((el) => io.observe(el));
    return () => io.disconnect();
  }, []);
}

// ── Animated bar ───────────────────────────────────────────────────────────
function Bar({ pct, klass, label }) {
  const [w, setW] = useState(0);
  useEffect(() => {
    const t = setTimeout(() => setW(pct), 200);
    return () => clearTimeout(t);
  }, [pct]);
  // Below ~14% the bar is too narrow to fit a word; show just the % so it stays legible.
  // Below ~5% don't even try the % — the bar is a sliver.
  let inner = '';
  if (w >= 14 && label) inner = `${label} ${pct}%`;
  else if (w >= 5) inner = `${pct}%`;
  return (
    <div className={`bar ${klass}`} style={{ width: `${w}%` }}>
      {inner}
    </div>);

}

// ── Scenarios with animated bars ───────────────────────────────────────────
function Scenarios() {
  return (
    <div style={{ display: 'flex', flexDirection: 'column', gap: 22 }}>
      <div className="scenario reveal">
        <div className="scenario-tag">Submitter = creator · post pays 10 HBD</div>
        <div className="who">your share<br /><b>3%</b> creator</div>
        <div className="bar-wrap">
          <Bar pct={3} klass="creator" label="you" />
          <Bar pct={1} klass="frontend" label="frontend" />
          <Bar pct={96} klass="author" label="poster" />
        </div>
        <div className="totals"><b>0.30</b> HBD<br />to you, forever</div>
      </div>

      <div className="scenario reveal">
        <div className="scenario-tag">Submitter = creator · comment pays 2 HBD</div>
        <div className="who">your share<br /><b>15%</b> stacked</div>
        <div className="bar-wrap">
          <Bar pct={15} klass="creator" label="you" />
          <Bar pct={1} klass="frontend" label="fe" />
          <Bar pct={84} klass="author" label="commenter" />
        </div>
        <div className="totals"><b>0.30</b> HBD<br />per top reply</div>
      </div>

      <div className="scenario reveal">
        <div className="scenario-tag unclaimed">Submitter ≠ creator · comment pays 2 HBD</div>
        <div className="who">split share<br /><b>10% / 5%</b></div>
        <div className="bar-wrap">
          <Bar pct={10} klass="creator" label="submitter" />
          <Bar pct={5} klass="holding" label="hold" />
          <Bar pct={1} klass="frontend" label="fe" />
          <Bar pct={84} klass="author" label="commenter" />
        </div>
        <div className="totals"><b>0.20</b> to submitter<br /><b>0.10</b> held for creator</div>
      </div>
    </div>);

}

// ── Sample template stamps ─────────────────────────────────────────────────
const STAMPS = [
{ top: "when the", bot: "rewards hit", color: 'var(--acid)', rot: -8, x: 0, y: 0, w: 52, label: "drake-react", pct: "4 / 16%" },
{ top: "submit once", bot: "earn forever", color: 'var(--hot)', rot: 7, x: 46, y: 26, w: 52, label: "spongebob", pct: "4 / 16%" },
{ top: "i don't always", bot: "post memes", color: 'var(--sun)', rot: -4, x: 8, y: 56, w: 52, label: "most-int-man", pct: "4 / 16%" }];


function HeroIllust() {
  return (
    <div className="hero-illust">
      {STAMPS.map((s, i) =>
      <div key={i} className="stamp"
      style={{
        left: `${s.x}%`, top: `${s.y}%`, width: `${s.w}%`,
        transform: `rotate(${s.rot}deg)`,
        zIndex: i + 1
      }}>
          <div className="tape" />
          <div className="img" style={{ color: s.color }}>
            <div className="top">{s.top}</div>
            <div className="bot">{s.bot}</div>
          </div>
          <div className="label">
            <span>{s.label}.png</span>
            <span className="pct">{s.pct}</span>
          </div>
        </div>
      )}
      <div className="star spin" style={{ right: -8, top: -8 }}>4% post · 16% comment</div>
    </div>);

}

// ── Step icons (mini illustrations) ─────────────────────────────────────────
function StepVis({ n }) {
  if (n === 1) return (
    <svg viewBox="0 0 200 80" width="100%" height="100%" preserveAspectRatio="xMidYMid meet">
      <rect x="20" y="14" width="80" height="52" fill="var(--card)" stroke="var(--fg)" strokeWidth="2" strokeDasharray="4 4" />
      <text x="60" y="48" textAnchor="middle" fontFamily="JetBrains Mono" fontSize="10" fill="var(--muted)">+ DROP</text>
      <path d="M 110 40 L 145 40 M 138 33 L 145 40 L 138 47" stroke="var(--acid)" strokeWidth="2.5" fill="none" />
      <rect x="150" y="14" width="40" height="52" fill="var(--acid)" stroke="var(--fg)" strokeWidth="2" />
      <circle cx="170" cy="34" r="4" fill="var(--ink)" />
      <path d="M 158 50 L 168 42 L 175 48 L 182 38 L 182 58 L 158 58 Z" fill="var(--ink)" />
    </svg>);

  if (n === 2) return (
    <svg viewBox="0 0 200 80" width="100%" height="100%">
      <rect x="14" y="14" width="172" height="52" fill="var(--card)" stroke="var(--fg)" strokeWidth="2" />
      <rect x="22" y="22" width="44" height="14" fill="var(--hot)" rx="7" />
      <text x="44" y="32" textAnchor="middle" fontFamily="JetBrains Mono" fontSize="9" fontWeight="700" fill="white">REACTION</text>
      <rect x="72" y="22" width="36" height="14" fill="var(--acid)" rx="7" />
      <text x="90" y="32" textAnchor="middle" fontFamily="JetBrains Mono" fontSize="9" fontWeight="700" fill="var(--ink)">WOJAK</text>
      <rect x="114" y="22" width="42" height="14" fill="var(--sun)" rx="7" />
      <text x="135" y="32" textAnchor="middle" fontFamily="JetBrains Mono" fontSize="9" fontWeight="700" fill="var(--ink)">CLASSIC</text>
      <rect x="22" y="44" width="32" height="14" fill="none" stroke="var(--fg)" strokeWidth="1.2" rx="7" />
      <rect x="60" y="44" width="40" height="14" fill="none" stroke="var(--fg)" strokeWidth="1.2" rx="7" />
      <rect x="106" y="44" width="34" height="14" fill="none" stroke="var(--fg)" strokeWidth="1.2" rx="7" />
    </svg>);

  if (n === 3) return (
    <svg viewBox="0 0 200 80" width="100%" height="100%">
      <rect x="14" y="14" width="172" height="52" fill="var(--card)" stroke="var(--fg)" strokeWidth="2" />
      <rect x="22" y="24" width="14" height="14" fill="var(--acid)" stroke="var(--fg)" strokeWidth="1.5" />
      <path d="M 25 31 L 28 34 L 33 28" stroke="var(--ink)" strokeWidth="2" fill="none" />
      <text x="44" y="34" fontFamily="Bricolage Grotesque" fontSize="13" fontWeight="700" fill="var(--fg)">I created this</text>
      <text x="22" y="55" fontFamily="JetBrains Mono" fontSize="10" fill="var(--muted)">@your-hive-account</text>
      <rect x="120" y="46" width="60" height="14" fill="var(--fg)" stroke="var(--fg)" strokeWidth="1.5" />
      <text x="150" y="56" textAnchor="middle" fontFamily="JetBrains Mono" fontSize="9" fontWeight="700" fill="var(--bg)">LINK ACCT</text>
    </svg>);

  if (n === 4) return (
    <svg viewBox="0 0 200 80" width="100%" height="100%">
      <rect x="14" y="14" width="172" height="52" fill="var(--card)" stroke="var(--fg)" strokeWidth="2" />
      <text x="22" y="32" fontFamily="JetBrains Mono" fontSize="9" fill="var(--muted)">USES</text>
      <text x="22" y="54" fontFamily="Bricolage Grotesque" fontSize="20" fontWeight="800" fill="var(--acid)">1,247</text>
      <text x="86" y="32" fontFamily="JetBrains Mono" fontSize="9" fill="var(--muted)">EARNED</text>
      <text x="86" y="54" fontFamily="Bricolage Grotesque" fontSize="20" fontWeight="800" fill="var(--hot)">42.6 HBD</text>
      <path d="M 162 56 L 168 50 L 174 53 L 180 42" stroke="var(--sun)" strokeWidth="2.5" fill="none" />
      <circle cx="180" cy="42" r="3" fill="var(--sun)" />
    </svg>);

  return null;
}

// ── FAQ ─────────────────────────────────────────────────────────────────────
const FAQS = [
{ q: "Do I need to keep doing anything to keep earning?",
  a: "Nope. Once your template is approved and your Hive account is linked, every post and comment that uses it routes a beneficiary share to you on-chain. No ongoing maintenance, no claims to file." },
{ q: "What if I didn't make the template, I just found a great one?",
  a: "Submit it as 'not the original creator'. You become the submitter — you earn the 10% submitter share on every comment, forever. The 5% creator share routes to the holding account decentmemeshold and stacks there until the original creator claims it. Both shares are independent: you keep submitter rewards even after a creator claims theirs." },
{ q: "How are the percentages decided?",
  a: "Posts: 3% creator + 1% frontend = 4% total. Comments: 10% submitter + 5% creator + 1% frontend = 16% total. Set in basis points on the beneficiary slot — applied automatically by the embedding frontend at broadcast. Comments are weighted heavier because comment payouts are an order of magnitude smaller; lighter weights get eaten by Hive's dust threshold." },
{ q: "Can I edit or take down a template I submitted?",
  a: "Submissions are subject to admin review before going live. After approval, request takedown via admin — but expect that already-attributed rewards from past posts stay where they were sent." },
{ q: "Where does the template image actually live?",
  a: "Uploaded directly to images.hive.blog signed by the submitter's Keychain. No central server holds the meme files — only the metadata (name, tags, beneficiary, use count) lives in the index." }];


function FAQ() {
  const [open, setOpen] = useState(0);
  return (
    <div className="faq">
      {FAQS.map((f, i) =>
      <div key={i} className={`faq-item${open === i ? ' open' : ''}`} onClick={() => setOpen(open === i ? -1 : i)}>
          <div className="faq-q">
            <h4>{f.q}</h4>
            <span className="icon">+</span>
          </div>
          <div className="faq-a">{f.a}</div>
        </div>
      )}
    </div>);

}

// ── Main App ────────────────────────────────────────────────────────────────
function App() {
  const [tw, setTweak] = useTweaks(TWEAK_DEFAULTS);
  useReveal();

  // Apply palette to body
  useEffect(() => {
    document.body.setAttribute('data-palette', tw.palette);
  }, [tw.palette]);

  // Apply hero font to body
  useEffect(() => {
    document.body.setAttribute('data-hero-font', tw.heroFont || 'archivo');
  }, [tw.heroFont]);

  return (
    <>
      <nav className="top">
        <div className="brand">
          <span className="pill">v1</span>
          decentmemes
          <span style={{ color: 'var(--muted)', fontWeight: 400 }}>/template-creators</span>
        </div>
        <div className="links">
          <a href="#how">how it works</a>
          <a href="#rewards">rewards</a>
          <a href="#submit">submit</a>
          <a href="#faq">faq</a>
        </div>
        <a href="/widget/" className="cta">submit a template ↗</a>
      </nav>

      {tw.marqueeOn &&
      <div className="marquee">
          <div className="marquee-track">
            <span>SUBMIT ONCE <span className="dot" /> EARN FOREVER <span className="dot" /> 4% POSTS <span className="dot" /> 16% COMMENTS <span className="dot" /> 10% SUBMITTER <span className="dot" /> 5% CREATOR <span className="dot" /> 1% FRONTEND <span className="dot" /></span>
            <span>SUBMIT ONCE <span className="dot" /> EARN FOREVER <span className="dot" /> 4% POSTS <span className="dot" /> 16% COMMENTS <span className="dot" /> 10% SUBMITTER <span className="dot" /> 5% CREATOR <span className="dot" /> 1% FRONTEND <span className="dot" /></span>
          </div>
        </div>
      }

      {/* HERO */}
      <section className="hero">
        <div className="hero-grid">
          <div>
            <h1 style={{ color: "rgb(255, 255, 255)" }}>
              your <span className="hot">meme</span>.<br />
              your <span className="underline">template</span>.<br />
              your <span className="acid">cut</span><em>forever</em>.
            </h1>
            <p className="hero-sub">
              <b>decentmemes</b> is the first meme generator that pays the people who made the templates — and the people who surfaced them.
              Submit a template once, link your Hive account, and every post or comment built on top of it
              routes a beneficiary share back to you. <b style={{ color: 'var(--fg)' }}>10% submitter</b> + <b style={{ color: 'var(--fg)' }}>5% creator</b> + <b style={{ color: 'var(--fg)' }}>1% frontend</b> on every comment. Automatic, on-chain, zero ongoing work.
            </p>
            <dl className="hero-meta">
              <div><dt>per post</dt><dd><span className="accent">4%</span> total</dd></div>
              <div><dt>per top-level comment</dt><dd><span className="accent">16%</span> total</dd></div>
              <div><dt>frontend cut</dt><dd>1%</dd></div>
              <div><dt>review time</dt><dd>~24h</dd></div>
            </dl>
          </div>
          <HeroIllust />
        </div>
      </section>

      {/* HOW IT WORKS */}
      <section className="section" id="how">
        <div className="section-inner">
          <span className="eyebrow">How to submit a template</span>
          <h2 className="section-title">Four steps. <span className="acid">Five minutes.</span> Then never touch it again.</h2>
          <p className="section-lede">
            The submit flow lives in the widget itself — open the meme widget on any Hive frontend that's wired
            us up, hit "+ Submit a template" in the strip header, and you're here.
          </p>

          <div className="steps reveal">
            <div className="step">
              <div className="num">01<span className="slash">/04</span></div>
              <div className="step-vis"><StepVis n={1} /></div>
              <h3>Drop the image</h3>
              <p>JPEG / PNG / GIF / WebP up to 8MB. The image gets signed by your Keychain and pushed to images.hive.blog — we never hold the file.</p>
              <div className="tip"><b>Tip:</b> high-res, no watermarks, clean negative space for top/bottom text.</div>
              <div className="tip" style={{ background: 'transparent', borderColor: 'var(--sun)', color: 'var(--muted)' }}><b style={{ color: 'var(--sun)' }}>Soon:</b> early on, submitting is <b style={{ color: 'var(--fg)' }}>free</b>. Once we're past the seeding phase a small <b style={{ color: 'var(--fg)' }}>1 HIVE</b> burn (sent to <code style={{ fontFamily: 'JetBrains Mono', fontSize: 11 }}>@null</code>) will gate each submission as anti-spam.</div>
            </div>
            <div className="step">
              <div className="num">02<span className="slash">/04</span></div>
              <div className="step-vis"><StepVis n={2} /></div>
              <h3>Name + tag it</h3>
              <p>Pick a clear, searchable name. Hit at least 2 tags from the predefined taxonomy — that's how meme-makers will actually find your template in the strip browser.</p>
              <div className="tip"><b>Tip:</b> tag for vibe (reaction / classic / wojak) and topic (crypto / drama / wholesome).</div>
            </div>
            <div className="step">
              <div className="num">03<span className="slash">/04</span></div>
              <div className="step-vis"><StepVis n={3} /></div>
              <h3>Claim ownership</h3>
              <p>Tick "I created this template" and drop in your Hive account — you collect both submitter (10% comment) and creator (3% post / 5% comment) shares. Skip the tick if you didn't make it: you keep submitter, the creator slot stacks in escrow until the original claims.</p>
              <div className="tip"><b>Either way, you earn.</b> Submitter rewards are unconditional. Frontend gets a flat 1% on top.</div>
            </div>
            <div className="step">
              <div className="num">04<span className="slash">/04</span></div>
              <div className="step-vis"><StepVis n={4} /></div>
              <h3>Earn on autopilot</h3>
              <p>After a quick admin review, your template appears in every embedded widget. Each use logs to your reward ledger; HBD/HIVE flows to your account at payout.</p>
              <div className="tip"><b>Track it:</b> see use count + earnings on your <b>creator dashboard</b>.</div>
            </div>
          </div>
        </div>
      </section>

      {/* REWARDS SPLIT */}
      <section className="section" id="rewards" style={{ background: 'var(--card)' }}>
        <div className="section-inner">
          <span className="eyebrow">How beneficiary rewards split</span>
          <h2 className="section-title">
            Posters keep <span className="hot">most</span>. Submitters, creators &amp; frontends each get <span className="acid">a slice</span>. <span className="sun">Forever.</span>
          </h2>
          <p className="section-lede">
            Hive's <code style={{ fontFamily: 'JetBrains Mono', background: 'var(--bg)', padding: '2px 6px', fontSize: 14 }}>comment_options</code> beneficiary slot is the magic. The embedding frontend appends up to three entries per use — <b style={{ color: 'var(--fg)' }}>submitter</b> (10% on comments), <b style={{ color: 'var(--fg)' }}>creator</b> (3% post / 5% comment), and the embedding <b style={{ color: 'var(--fg)' }}>frontend itself</b> (1% post and comment). Comments stack to <b style={{ color: 'var(--fg)' }}>16%</b> total because comment payouts are smaller — anything thinner falls below Hive's dust threshold and gets silently dropped.
          </p>

          <div className="split-box reveal">
            <div className="split-grid">
              <div className="split-left">
                <div>
                  <h3>Three scenarios.</h3>
                  <p>
                    The split depends on whether you submitted your own template, and whether the post is a top-level
                    post or a comment. Hover any bar for exact basis points.
                  </p>
                </div>
                <div className="legend">
                  <div className="legend-row"><span className="swatch" style={{ background: 'var(--fg)' }} /><b>poster / commenter</b> <span>— published the post</span></div>
                  <div className="legend-row"><span className="swatch" style={{ background: 'var(--acid)' }} /><b>you</b> <span>— submitter &amp;/or creator</span></div>
                  <div className="legend-row"><span className="swatch" style={{ background: 'var(--hot)' }} /><b>holding</b> <span>— escrow until creator claims</span></div>
                  <div className="legend-row"><span className="swatch" style={{ background: 'var(--sun)' }} /><b>frontend</b> <span>— 1% to embedding app (PeakD, Ecency, …)</span></div>
                </div>
              </div>
              <div className="split-right">
                <Scenarios />
              </div>
            </div>
          </div>

          {/* Claim */}
          <div className="claim reveal" id="claim">
            <div className="claim-side">
              <h3>What happens to <span style={{ color: 'var(--hot)' }}>unclaimed</span> templates?</h3>
              <p>
                When a template is submitted by someone other than its original creator, only the
                <b style={{ color: 'var(--fg)' }}> 5% creator slot</b> on comments (and 3% on posts) routes to
                <code style={{ fontFamily: 'JetBrains Mono', background: 'var(--card)', padding: '2px 6px' }}>@decentmemeshold</code> instead of vanishing into a platform pool.
                When the real creator surfaces, they prove ownership and the accumulated balance — plus the
                creator slot from that point forward — flows to them. The submitter keeps their 10% comment
                share regardless.
              </p>
              <ul>
                <li>No platform takes a cut. The hold account is custodial-pending, not custodial-final.</li>
                <li>Submitters earn their 10% comment share immediately — no waiting on the creator to surface.</li>
                <li>Original creators can claim retroactively at any time — held rewards don't expire.</li>
              </ul>
            </div>
            <div className="claim-side">
              <h3>Are <span className="acid">you</span> the original creator of a template that's already up?</h3>
              <p style={{ marginBottom: 18 }}>
                Tell us. Bring proof — original file, post history, source thread, anything that ties the
                meme back to you. Once verified, the template's beneficiary flips to your Hive account and
                any held rewards are released.
              </p>
              <a href="mailto:claim@decentmemes.example" className="fp-btn" style={{ display: 'inline-block', textDecoration: 'none' }}>
                claim a template →
              </a>
            </div>
          </div>
        </div>
      </section>

      {/* FORM PREVIEW + DEMO */}
      <section className="section" id="submit">
        <div className="section-inner">
          <span className="eyebrow">What the submit form looks like</span>
          <h2 className="section-title">It's <span className="acid">one form</span>. That's it.</h2>
          <p className="section-lede">
            Every embedded decentmemes widget has the same submit affordance. Open the widget, hit "+ Submit a
            template" in the top-right of the template strip, fill these five fields, done.
          </p>

          <div className="form-preview reveal">
            <div className="fp-head">
              <div className="dots"><span /><span /><span /></div>
              <div className="url">decentmemes://widget/submit-modal</div>
              <div style={{ color: 'var(--muted)' }}>v1</div>
            </div>
            <div className="fp-body">
              <div className="fp-img-side">
                <div className="fp-drop">
                  <div className="icon">+</div>
                  <div>drop image or click to upload<br />JPEG · PNG · GIF · WEBP · max 8MB</div>
                </div>
                <div style={{ fontFamily: 'JetBrains Mono', fontSize: 11, color: 'var(--muted)', lineHeight: 1.5 }}>
                  → signed via your Keychain<br />
                  → uploaded to images.hive.blog<br />
                  → only the URL hits our index
                </div>
              </div>
              <div className="fp-form">
                <div className="fp-field">
                  <label>Template name</label>
                  <input className="fp-input" defaultValue="Distracted Boyfriend" />
                </div>
                <div className="fp-field">
                  <label>Tags (pick at least 2)</label>
                  <div className="fp-chips">
                    <span className="fp-chip on">reaction</span>
                    <span className="fp-chip on">classic</span>
                    <span className="fp-chip">wholesome</span>
                    <span className="fp-chip">wojak</span>
                    <span className="fp-chip">crypto</span>
                    <span className="fp-chip">drama</span>
                    <span className="fp-chip">animal</span>
                  </div>
                </div>
                <div className="fp-toggle">
                  <div className="check">✓</div>
                  <div>
                    <b>I created this template</b>
                    <span>Creator share (3% post / 5% comment) routes to your Hive account. Skip this if you found the meme elsewhere — that slot holds for the real creator. The 10% submitter share comes to you either way.</span>
                  </div>
                </div>
                <div className="fp-field">
                  <label>Your Hive account</label>
                  <input className="fp-input" defaultValue="@your-account" />
                </div>
                <div className="fp-actions">
                  <button className="fp-btn ghost">cancel</button>
                  <a href="/widget/" className="fp-btn" style={{ textDecoration: 'none', display: 'inline-flex', alignItems: 'center' }}>open the widget →</a>
                </div>
              </div>
            </div>
          </div>

          {/* Demo */}
          {tw.showLiveDemo !== 'off' &&
          <div style={{ marginTop: 80 }}>
              <span className="eyebrow">See it in motion</span>
              <h2 className="section-title" style={{ fontSize: 'clamp(32px, 4vw, 56px)' }}>
                The widget itself.
              </h2>
              <p className="section-lede">
                What every Hive frontend embeds. Same submit button you'll use lives top-right of that strip.
              </p>
              <div className="demo-frame">
                {tw.showLiveDemo === 'live' &&
              <iframe src="/widget/" title="decentmemes widget" />
              }
                {tw.showLiveDemo === 'screenshot' &&
              <div style={{ background: '#0f0f13', padding: 24 }}>
                    <div style={{
                  background: '#18181f', padding: 14, borderRadius: 8,
                  display: 'flex', alignItems: 'center', gap: 10,
                  borderBottom: '1px solid #2a2a38', fontFamily: 'system-ui',
                  color: '#a78bfa', fontSize: 14, fontWeight: 600
                }}>
                      DecentMemes
                      <span style={{ marginLeft: 'auto', fontSize: 12, color: '#888' }}>+ Submit a template ↗</span>
                    </div>
                    <div style={{ display: 'flex', gap: 8, padding: 12, background: '#13131a', overflow: 'hidden' }}>
                      {[0, 1, 2, 3, 4, 5, 6].map((i) =>
                  <div key={i} style={{
                    flexShrink: 0, width: 90, height: 70,
                    background: `linear-gradient(135deg, hsl(${i * 47},40%,20%), hsl(${i * 47 + 20},40%,12%))`,
                    border: i === 1 ? '2px solid #a78bfa' : '2px solid transparent',
                    borderRadius: 5
                  }} />
                  )}
                    </div>
                    <div style={{
                  padding: 60, textAlign: 'center', color: '#444',
                  fontFamily: 'system-ui', fontSize: 14
                }}>
                      [ canvas editor — top/bottom text, color, font-size auto-fit ]
                    </div>
                    <div style={{
                  padding: 12, borderTop: '1px solid #2a2a38', display: 'flex', gap: 8,
                  background: '#13131a', fontFamily: 'system-ui', fontSize: 13
                }}>
                      <button style={{ padding: '7px 16px', background: '#1e1e2a', color: '#ccc', border: '1px solid #2e2e40', borderRadius: 7 }}>Download</button>
                      <button style={{ padding: '7px 16px', background: '#7c3aed', color: '#fff', border: 0, borderRadius: 7 }}>Add to post</button>
                    </div>
                  </div>
              }
                {tw.showLiveDemo === 'placeholder' &&
              <div className="demo-fallback">
                    <div className="big">[ widget embed slot ]</div>
                    <div>iframe drops in here at deploy time → decentmemes.com/widget/</div>
                  </div>
              }
              </div>
            </div>
          }
        </div>
      </section>

      {/* FAQ */}
      <section className="section" id="faq">
        <div className="section-inner">
          <span className="eyebrow">Quick questions</span>
          <h2 className="section-title">FAQ.</h2>
          <FAQ />
        </div>
      </section>

      {/* FOOTER */}
      <footer>
        <div className="footer-inner">
          <div className="footer-cta">
            ready to <span className="acid">ship</span> a<br />
            template?<br />
            <a href="/widget/">submit yours →</a>
          </div>
          <div className="footer-meta">
            <div>decentmemes / v1 / 2026</div>
            <div style={{ display: 'flex', gap: 24 }}>
              <a href="#how">how it works</a>
              <a href="#rewards">rewards</a>
              <a href="#faq">faq</a>
              <a href="#submit">submit</a>
            </div>
            <div>built on hive · no platform cut</div>
          </div>
        </div>
      </footer>

      {/* TWEAKS */}
      <TweaksPanel title="Tweaks">
        <TweakSection title="Palette">
          <TweakSelect
            label="Color world"
            value={tw.palette}
            onChange={(v) => setTweak('palette', v)}
            options={[
            { value: 'acid', label: 'Acid (green / pink / yellow on black)' },
            { value: 'cream', label: 'Cream (paper + ink + orange)' },
            { value: 'cyber', label: 'Cyber (purple / cyan / magenta)' },
            { value: 'lava', label: 'Lava (black / orange / red)' }]
            } />
          
        </TweakSection>
        <TweakSection title="Hero font">
          <TweakSelect
            label="Display typeface"
            value={tw.heroFont || 'archivo'}
            onChange={(v) => setTweak('heroFont', v)}
            options={[
            { value: 'bricolage', label: 'Bricolage Grotesque (default)' },
            { value: 'archivo', label: 'Archivo Black (chunky sans)' },
            { value: 'anton', label: 'Anton (tall condensed)' },
            { value: 'bigshoulders', label: 'Big Shoulders (industrial)' },
            { value: 'instrument', label: 'Instrument Serif (elegant)' },
            { value: 'boldonse', label: 'Boldonse (retro display)' },
            { value: 'honk', label: 'Honk (chromatic / playful)' }]
            } />
          
        </TweakSection>
        <TweakSection title="Layout">
          <TweakRadio
            label="Live widget demo"
            value={tw.showLiveDemo}
            onChange={(v) => setTweak('showLiveDemo', v)}
            options={[
            { value: 'screenshot', label: 'Static mock' },
            { value: 'placeholder', label: 'Placeholder' },
            { value: 'live', label: 'Real iframe' },
            { value: 'off', label: 'Off' }]
            } />
          
          <TweakToggle
            label="Marquee banner"
            value={tw.marqueeOn}
            onChange={(v) => setTweak('marqueeOn', v)} />
          
          <TweakToggle
            label="Spinning sticker"
            value={tw.stickerOn}
            onChange={(v) => setTweak('stickerOn', v)} />
          
        </TweakSection>
      </TweaksPanel>
    </>);

}

ReactDOM.createRoot(document.getElementById('root')).render(<App />);