// LongtailIQ marketing, feature sections (Peec-style: light, minimal)
// Strings route through window.LTQM.t; data arrays are built at RENDER time
// (not module scope) so they resolve after the i18n dictionary has loaded.
(function init(){
if(!window.LongtailIQDesignSystem_ae8f12){return setTimeout(init,30);}
const React = window.React;
const DS = window.LongtailIQDesignSystem_ae8f12;
const { Icon } = DS;

function PillLabel({ icon, children }) {
  return <span className="lt-pill-label lt-reveal"><Icon name={icon} size={14} style={{ color: "var(--text-muted)" }} />{children}</span>;
}
function Wrap({ children, style, id }) { return <section id={id} style={{ maxWidth: 1080, margin: "0 auto", padding: "76px 24px", ...style }}>{children}</section>; }
function Head({ pill, pillIcon, title, gray, sub, gradient }) {
  return (
    <div style={{ textAlign: "center", maxWidth: 640, margin: "0 auto 48px" }}>
      <div style={{ marginBottom: 18 }}><PillLabel icon={pillIcon}>{pill}</PillLabel></div>
      <h2 className="lt-reveal lt-display" style={{ fontSize: "clamp(1.9rem,1.4rem+1.6vw,2.6rem)", fontWeight: 600, letterSpacing: "-0.025em", color: "var(--ink-900)", lineHeight: 1.08 }}>
        {gradient ? <span className="fx-grad-text">{title}</span> : title}{gray && <><br/><span style={{ color: "var(--ink-400)" }}>{gray}</span></>}
      </h2>
      {sub && <p className="lt-reveal" style={{ fontSize: 16, color: "var(--text-muted)", marginTop: 14, lineHeight: 1.55 }}>{sub}</p>}
    </div>
  );
}

function SourceCard({ s }) {
  const [hover, setHover] = React.useState(false);
  const onMove = window.LTQM.useSpotlight();
  return (
    <div className="lt-reveal fx-spotlight" onMouseMove={onMove} onMouseEnter={()=>setHover(true)} onMouseLeave={()=>setHover(false)}
      style={{ position: "relative", border: "1px solid var(--border-subtle)", borderRadius: 14, padding: 18, background: "var(--paper)",
        transition: "border-color var(--dur-base), transform var(--dur-base)",
        borderColor: hover ? "var(--ink-200)" : "var(--border-subtle)", transform: hover ? "translateY(-2px)" : "none" }}>
      <span style={{ position: "relative", zIndex: 2, display: "inline-grid", placeItems: "center", width: 36, height: 36, borderRadius: 9, background: "var(--ink-50)", border: "1px solid var(--border-subtle)", color: "var(--text-strong)", marginBottom: 14 }}><Icon name={s.icon} size={17} strokeWidth={1.8} /></span>
      <div style={{ position: "relative", zIndex: 2, fontSize: 14.5, fontWeight: 600, color: "var(--text-strong)", letterSpacing: "-0.01em" }}>{s.t}</div>
      <div style={{ position: "relative", zIndex: 2, fontSize: 13, color: "var(--text-muted)", lineHeight: 1.5, marginTop: 6 }}>{s.d}</div>
    </div>
  );
}

function Sources() {
  const t = window.LTQM.t;
  const SOURCES = [
    { icon: "globe", t: t("src.google.t"), d: t("src.google.d") },
    { icon: "sparkles", t: t("src.aio.t"), d: t("src.aio.d") },
    { icon: "sparkle", t: t("src.chatgpt.t"), d: t("src.chatgpt.d") },
    { icon: "message-circle", t: t("src.reddit.t"), d: t("src.reddit.d") },
    { icon: "monitor-play", t: t("src.youtube.t"), d: t("src.youtube.d") },
    { icon: "music-2", t: t("src.tiktok.t"), d: t("src.tiktok.d") },
    { icon: "shopping-bag", t: t("src.shopify.t"), d: t("src.shopify.d") },
    { icon: "map-pin", t: t("src.local.t"), d: t("src.local.d") },
  ];
  return (
    <Wrap id="sources">
      <Head pill={t("src.pill")} pillIcon="layers" title={t("src.title")} gray={t("src.title_gray")}
        sub={t("src.sub")} />
      <div style={{ display: "grid", gridTemplateColumns: "repeat(4,1fr)", gap: 14 }} className="lt-src-grid">
        {SOURCES.map((s,i)=><SourceCard key={i} s={s} />)}
      </div>
    </Wrap>
  );
}

function HowSearch() {
  const t = window.LTQM.t;
  const rows = [
    { icon: "message-square-text", t: t("hs.1.t"), d: t("hs.1.d") },
    { icon: "git-compare", t: t("hs.2.t"), d: t("hs.2.d") },
    { icon: "sparkles", t: t("hs.3.t"), d: t("hs.3.d") },
  ];
  return (
    <div id="how" style={{ borderTop: "1px solid var(--border-subtle)", borderBottom: "1px solid var(--border-subtle)", background: "var(--ink-50)" }}>
      <Wrap>
        <Head pill={t("hs.pill")} pillIcon="compass" title={t("hs.title")} />
        <div style={{ display: "grid", gridTemplateColumns: "repeat(3,1fr)", gap: 14 }} className="lt-feat-grid">
          {rows.map((r,i)=>(
            <div key={i} className="lt-reveal" style={{ padding: 22, borderRadius: 14, background: "var(--paper)", border: "1px solid var(--border-subtle)" }}>
              <span style={{ display: "inline-grid", placeItems: "center", width: 36, height: 36, borderRadius: 9, background: "var(--ink-50)", border: "1px solid var(--border-subtle)", color: "var(--text-strong)", marginBottom: 14 }}><Icon name={r.icon} size={17} strokeWidth={1.8} /></span>
              <div style={{ fontSize: 14.5, fontWeight: 600, color: "var(--text-strong)" }}>{r.t}</div>
              <div style={{ fontSize: 13, color: "var(--text-muted)", marginTop: 6, lineHeight: 1.5 }}>{r.d}</div>
            </div>
          ))}
        </div>
      </Wrap>
    </div>
  );
}

// ---- How it works: the product's 3-step workflow (staggered via RevealGroup) ----
function HowItWorks() {
  const M = window.LTQM;
  const t = M.t;
  const STEPS = [
    { n: "01", icon: "search", t: t("hiw.1.t"), d: t("hiw.1.d") },
    { n: "02", icon: "sparkles", t: t("hiw.2.t"), d: t("hiw.2.d") },
    { n: "03", icon: "file-pen-line", t: t("hiw.3.t"), d: t("hiw.3.d") },
  ];
  const RevealGroup = (M && M.RevealGroup) || (({ children, className, style }) => <div className={className} style={style}>{children}</div>);
  return (
    <div style={{ borderTop: "1px solid var(--border-subtle)", background: "var(--paper)" }}>
      <Wrap id="how-it-works">
        <Head pill={t("hiw.pill")} pillIcon="route" title={t("hiw.title")} gray={t("hiw.title_gray")}
          sub={t("hiw.sub")} />
        <RevealGroup stagger={120} className="lt-feat-grid" style={{ display: "grid", gridTemplateColumns: "repeat(3,1fr)", gap: 16 }} childStyle={{ height: "100%" }}>
          {STEPS.map((s, i) => (
            <div key={i} style={{ position: "relative", height: "100%", padding: 24, borderRadius: "var(--r-xl)", border: "1px solid var(--border-subtle)", background: "var(--surface-card)", boxShadow: "var(--shadow-sm)" }}>
              <div style={{ display: "flex", alignItems: "center", justifyContent: "space-between", marginBottom: 16 }}>
                <span style={{ display: "inline-grid", placeItems: "center", width: 42, height: 42, borderRadius: 12, background: "var(--accent-50)", color: "var(--accent-600)" }}><Icon name={s.icon} size={20} strokeWidth={1.8} /></span>
                <span className="lt-num" style={{ fontFamily: "var(--font-mono)", fontSize: 30, fontWeight: 700, color: "var(--ink-150)" }}>{s.n}</span>
              </div>
              <div style={{ fontSize: 17, fontWeight: 700, color: "var(--text-strong)", letterSpacing: "-0.01em", marginBottom: 6 }}>{s.t}</div>
              <p style={{ fontSize: 13.5, color: "var(--text-muted)", lineHeight: 1.6 }}>{s.d}</p>
            </div>
          ))}
        </RevealGroup>
      </Wrap>
    </div>
  );
}

// ---- Platform features: SQSEO's real capabilities (honest; links into the app/docs) ----
function FeatureCard({ f }) {
  const [hover, setHover] = React.useState(false);
  const onMove = window.LTQM.useSpotlight();
  return (
    <a href={f.href} className="fx-spotlight" onMouseMove={onMove} onMouseEnter={()=>setHover(true)} onMouseLeave={()=>setHover(false)}
      style={{ display: "block", height: "100%", position: "relative", border: "1px solid var(--border-subtle)", borderRadius: 14, padding: 18, background: "var(--paper)", textDecoration: "none",
        transition: "border-color var(--dur-base), transform var(--dur-base)", borderColor: hover ? "var(--ink-200)" : "var(--border-subtle)", transform: hover ? "translateY(-2px)" : "none" }}>
      <span style={{ position: "relative", zIndex: 2, display: "inline-grid", placeItems: "center", width: 38, height: 38, borderRadius: 10, background: "var(--accent-50)", color: "var(--accent-600)", marginBottom: 13 }}><Icon name={f.icon} size={18} strokeWidth={1.8} /></span>
      <div style={{ position: "relative", zIndex: 2, fontSize: 14.5, fontWeight: 700, color: "var(--text-strong)", letterSpacing: "-0.01em" }}>{f.t}</div>
      <div style={{ position: "relative", zIndex: 2, fontSize: 13, color: "var(--text-muted)", lineHeight: 1.5, marginTop: 6 }}>{f.d}</div>
    </a>
  );
}
function PlatformFeatures() {
  const M = window.LTQM;
  const t = M.t, h = M.href;
  const PLATFORM = [
    { icon: "radar", t: t("pf.1.t"), d: t("pf.1.d"), href: h("/app/register.html") },
    { icon: "sparkles", t: t("pf.2.t"), d: t("pf.2.d"), href: h("/app/register.html") },
    { icon: "file-pen-line", t: t("pf.3.t"), d: t("pf.3.d"), href: h("/app/register.html") },
    { icon: "git-compare", t: t("pf.4.t"), d: t("pf.4.d"), href: h("/app/register.html") },
    { icon: "gauge", t: t("pf.5.t"), d: t("pf.5.d"), href: h("/app/register.html") },
    { icon: "list-checks", t: t("pf.6.t"), d: t("pf.6.d"), href: h("/app/register.html") },
    { icon: "download", t: t("pf.7.t"), d: t("pf.7.d"), href: h("/app/register.html") },
    { icon: "code", t: t("pf.8.t"), d: t("pf.8.d"), href: h("/api") },
  ];
  const RevealGroup = (M && M.RevealGroup) || (({ children, className, style }) => <div className={className} style={style}>{children}</div>);
  return (
    <Wrap>
      <Head pill={t("pf.pill")} pillIcon="layers" title={t("pf.title")} gray={t("pf.title_gray")} gradient />
      <RevealGroup stagger={70} className="lt-src-grid" style={{ display: "grid", gridTemplateColumns: "repeat(4,1fr)", gap: 14 }} childStyle={{ height: "100%" }}>
        {PLATFORM.map((f, i) => <FeatureCard key={i} f={f} />)}
      </RevealGroup>
    </Wrap>
  );
}

window.LTQM = window.LTQM || {};
Object.assign(window.LTQM, { Sources, HowSearch, HowItWorks, PlatformFeatures });
})();
