// ── Content sections ────────────────────────────────────────

function Section({ children, glow, noTopBorder, style, className = "" }) {
  // glow: subtle warm radial wash from the top (gold, very faint) — keeps
  // section heads feeling premium without competing with CTA color.
  return (
    <section className={`pf-section ${className}`} style={{ padding: "100px 0", borderTop: noTopBorder ? "none" : "1px solid var(--border)", position: "relative", background: glow ? "radial-gradient(ellipse at 50% 0%, rgba(var(--go-rgb),0.05), transparent 55%), var(--abyss)" : "var(--abyss)", ...style }}>
      <Wrap style={{ position: "relative", zIndex: 1 }}>{children}</Wrap>
    </section>
  );
}

// Editorial section head: oversized ghosted serif numeral behind a
// premium eyebrow tag, headline and optional sub-paragraph.
function SectionHead({ tag, n, title, sub, titleStyle, align = "left" }) {
  return (
    <Reveal>
      <div style={{ position: "relative", paddingTop: n ? "32px" : 0, textAlign: align }}>
        {n && (
          <span aria-hidden="true" style={{ position: "absolute", top: "-22px", left: align === "center" ? "50%" : "-12px", transform: align === "center" ? "translateX(-50%)" : "none", fontFamily: "var(--f-display)", fontStyle: "italic", fontWeight: 400, fontSize: "clamp(7rem, 14vw, 11rem)", lineHeight: 0.85, letterSpacing: "-0.05em", backgroundImage: "linear-gradient(180deg, rgba(var(--bronze-rgb),0.18) 0%, rgba(var(--bronze-rgb),0.02) 100%)", WebkitBackgroundClip: "text", backgroundClip: "text", color: "transparent", pointerEvents: "none", userSelect: "none", whiteSpace: "nowrap" }}>
            {n}
          </span>
        )}
        <div style={{ position: "relative", display: align === "center" ? "inline-block" : "block" }}>
          <SectionTag n={n}>{tag}</SectionTag>
        </div>
        <h2 className="pf-section-head" style={{ position: "relative", fontFamily: "var(--f-display)", fontWeight: 400, fontSize: "clamp(1.9rem,3.6vw,3rem)", lineHeight: 1.12, letterSpacing: "-0.015em", color: "var(--cream)", margin: "0 0 18px", ...titleStyle }} dangerouslySetInnerHTML={{ __html: title }} />
        {sub && <p style={{ position: "relative", fontFamily: "var(--f-body)", fontSize: "1.1rem", lineHeight: 1.65, color: "var(--txt-body)", maxWidth: "620px", margin: align === "center" ? "0 auto" : 0 }}>{sub}</p>}
      </div>
    </Reveal>
  );
}

// ── TICKER ──
function Ticker() {
  const items = ["Imersão Mundo China · 24 e 25 de Junho de 2026 · Alphaville", "Com Soong · direto da China", "+100 milhões importados", "Negocie mais perto da fonte", "Preparação para a feira de outubro"];
  const loop = [...items, ...items];
  return (
    <div className="pf-ticker-rail" style={{ background: "var(--deep)", borderTop: "1px solid rgba(var(--bronze-rgb),0.18)", borderBottom: "1px solid rgba(var(--bronze-rgb),0.18)", padding: "20px 0", overflow: "hidden", whiteSpace: "nowrap" }}>
      <div style={{ display: "inline-block", animation: "pfScroll 30s linear infinite" }}>
        {loop.map((t, i) => (
          <span key={i} style={{ fontFamily: "var(--f-body)", fontWeight: 500, fontSize: ".74rem", letterSpacing: ".24em", textTransform: "uppercase", color: "var(--champagne)" }}>
            <span style={{ color: "var(--go-4)", margin: "0 22px", fontSize: ".6rem" }}>❖</span>{t}
          </span>
        ))}
      </div>
    </div>
  );
}

// Accent presets for icon-led cards. Reds re-tuned to imperial crimson
// (Cinnabar) for the high-ticket Asia/luxury palette; cool cyan kept
// only as a soft accent option, not used for primary tagging.
const ACC = {
  red:  { fg: "#B83232", line: "#8C1F1F", soft: "rgba(140,31,31,0.10)" },
  gold: { fg: "var(--go-4)", line: "var(--go)", soft: "rgba(var(--go-rgb),0.08)" },
  green:{ fg: "#34D399", line: "#10B981", soft: "rgba(16,185,129,0.07)" },
  cyan: { fg: "#67E8F9", line: "#06B6D4", soft: "rgba(6,182,212,0.07)" },
};

// Premium editorial card for a high-end event: gold metallic hairline
// (the VIP "ticket" thread), ghosted gold index numeral, dot + line-icon +
// tracked kicker + fading rule, confident Syne title. No chunky chips.
function IconCard({ icon, kicker, tone = "red", num, title, children }) {
  const a = ACC[tone];
  const [h, setH] = React.useState(false);
  return (
    <div onMouseEnter={() => setH(true)} onMouseLeave={() => setH(false)} className="pf-iconcard"
      style={{ position: "relative", overflow: "hidden", height: "100%", boxSizing: "border-box",
        background: "linear-gradient(165deg,#151A2C 0%,#0A0E1A 100%)", borderRadius: "6px", padding: "26px 24px 24px",
        border: `1px solid ${h ? "var(--border-2)" : "rgba(255,255,255,0.08)"}`,
        boxShadow: h ? "0 34px 64px -26px rgba(0,0,0,0.95)" : "inset 0 1px 0 rgba(255,255,255,0.06), 0 30px 60px -34px rgba(0,0,0,0.95)",
        transform: h ? "translateY(-5px)" : "none", transition: "transform .45s var(--ease-out), box-shadow .45s var(--ease-out), border-color .45s var(--ease-out)" }}>
      <span style={{ position: "absolute", top: 0, left: 0, right: 0, height: "1px", background: "linear-gradient(90deg,transparent 0%,#9C6B1E 20%,var(--go-4) 50%,#9C6B1E 80%,transparent 100%)", opacity: 0.7 }} />
      <span style={{ position: "absolute", top: "-30px", left: "-30px", width: "160px", height: "160px", background: `radial-gradient(circle, ${a.soft}, transparent 70%)`, pointerEvents: "none" }} />
      {num && <span style={{ position: "absolute", top: "8px", right: "16px", fontFamily: "var(--f-display)", fontWeight: 800, fontSize: "4.4rem", lineHeight: 1, letterSpacing: "-0.04em", backgroundImage: "linear-gradient(180deg,var(--go-4),var(--bronze))", WebkitBackgroundClip: "text", backgroundClip: "text", color: "transparent", opacity: 0.12 }}>{num}</span>}
      <div style={{ position: "relative", display: "flex", alignItems: "center", gap: "9px", marginBottom: "20px" }}>
        <span style={{ width: "6px", height: "6px", borderRadius: "50%", background: a.fg, boxShadow: `0 0 8px ${a.fg}`, flexShrink: 0 }} />
        <span style={{ display: "flex", color: a.fg }}><i data-lucide={icon}></i></span>
        <span style={{ fontFamily: "var(--f-body)", fontWeight: 600, fontSize: ".6rem", letterSpacing: ".3em", textTransform: "uppercase", color: a.fg, whiteSpace: "nowrap" }}>{kicker}</span>
        <span style={{ flex: 1, height: "1px", background: `linear-gradient(90deg, ${a.line}, transparent)`, opacity: 0.35 }} />
      </div>
      <div style={{ position: "relative", fontFamily: "var(--f-display)", fontWeight: 700, fontSize: "1.16rem", lineHeight: 1.12, letterSpacing: "-0.015em", color: "var(--txt-white)", marginBottom: "11px" }}>{title}</div>
      <div style={{ position: "relative", fontFamily: "var(--f-body)", fontSize: ".92rem", lineHeight: 1.58, color: "var(--txt-soft)", textWrap: "pretty" }}>{children}</div>
    </div>
  );
}

// ── PAIN ──
const PAINS = [
  { ic: "layers", t: "O intermediário invisível", d: "Distribuidores e fornecedores brasileiros já compraram antes de você. Cada elo no caminho cobra a sua parte, e ela sai direto da sua margem." },
  { ic: "trending-down", t: "A margem comprimida", d: "Você vende bem, mas compra mal. O lucro que deveria ser seu fica espalhado entre os atravessadores até a mercadoria chegar nas suas mãos." },
  { ic: "eye-off", t: "Pouca clareza sobre fornecedores", d: "Você não sabe quem está por trás do produto: fábrica, trading ou revendedor? Sem essa leitura, não dá pra comprar com estratégia." },
  { ic: "handshake", t: "Falta de negociação direta", d: "Sem acesso à fonte, você aceita o preço que te dão. Negociar direto muda o jogo, mas exige entender como a China funciona." },
  { ic: "calendar-x", t: "Despreparo para as oportunidades", d: "A maior feira de fornecedores do mundo acontece em outubro. Chegar lá sem preparação é desperdiçar a melhor janela do ano." },
];
function Pain() {
  return (
    <Section noTopBorder style={{ background: "linear-gradient(180deg, var(--void) 0%, var(--abyss) 18%, var(--abyss) 100%)", paddingTop: "120px" }}>
      <SectionHead n="01" tag="O problema" title='Você pode estar pagando <span style="color:var(--crimson-4); font-style: italic;">até 3x mais caro</span> sem perceber.' sub="Muitos negócios vendem bem, mas compram mal. Quando você depende de distribuidores e fornecedores brasileiros que já compraram antes de você, parte da sua margem fica no caminho." />
      <div className="pf-pain-grid" style={{ display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(280px, 1fr))", gap: "16px", marginTop: "44px" }}>
        {PAINS.map((p, i) => (
          <Reveal key={i} delay={i * 0.06}>
            <IconCard icon={p.ic} tone="red" kicker="Dor" num={String(i + 1).padStart(2, "0")} title={p.t}>{p.d}</IconCard>
          </Reveal>
        ))}
      </div>
    </Section>
  );
}

// ── TURN (a virada) — editorial interlude band, no chapter number ──
function Turn() {
  return (
    <Section style={{ background: "radial-gradient(ellipse at 50% 0%, rgba(var(--go-rgb),0.06), transparent 60%), var(--abyss)", padding: "104px 0" }}>
      <Reveal>
        <div style={{ maxWidth: "840px", margin: "0 auto", textAlign: "center" }}>
          <div style={{ display: "inline-flex", alignItems: "center", gap: "14px", marginBottom: "28px" }}>
            <span style={{ width: "54px", height: "1px", background: "linear-gradient(90deg, transparent, var(--bronze) 60%, var(--go-4))" }} />
            <span style={{ width: "9px", height: "9px", border: "1px solid var(--go-4)", background: "var(--abyss)", transform: "rotate(45deg)", boxShadow: "0 0 12px rgba(var(--go-rgb),0.35)" }} />
            <span style={{ width: "54px", height: "1px", background: "linear-gradient(90deg, var(--go-4), var(--bronze) 40%, transparent)" }} />
          </div>
          <h2 className="pf-section-head" style={{ fontFamily: "var(--f-display)", fontWeight: 400, fontSize: "clamp(1.9rem,4.2vw,3.2rem)", lineHeight: 1.12, letterSpacing: "-0.015em", color: "var(--cream)", margin: "0 0 22px" }}>
            A oportunidade não está só em vender mais.<br /><span style={{ color: "var(--go-4)", fontStyle: "italic" }}>Está em comprar melhor.</span>
          </h2>
          <p style={{ fontFamily: "var(--f-body)", fontSize: "1.12rem", lineHeight: 1.7, color: "var(--txt-soft)", maxWidth: "640px", margin: "0 auto" }}>
            Para quem já tem demanda, produto, loja ou operação, entender a China muda a forma de comprar, negociar e planejar crescimento. É aí que a margem volta para o seu lado.
          </p>
        </div>
      </Reveal>
    </Section>
  );
}

// reusable card with hover lift + soft accent wash (no flat left-border)
function HoverCard({ accent, children, surface = "var(--surface)", pad = "24px" }) {
  const [h, setH] = React.useState(false);
  return (
    <div onMouseEnter={() => setH(true)} onMouseLeave={() => setH(false)}
      style={{ position: "relative", overflow: "hidden", background: surface, borderRadius: "16px", padding: pad, height: "100%", boxSizing: "border-box",
        border: `1px solid ${h ? "var(--border-2)" : "rgba(255,255,255,0.07)"}`,
        boxShadow: h ? "0 22px 46px -18px rgba(0,0,0,0.85)" : "0 1px 0 rgba(255,255,255,0.04) inset",
        transform: h ? "translateY(-4px)" : "none", transition: "transform .4s var(--ease-out), box-shadow .4s var(--ease-out), border-color .4s var(--ease-out)" }}>
      {accent && <span style={{ position: "absolute", top: 0, left: 0, width: "150px", height: "150px", background: `radial-gradient(circle at top left, color-mix(in srgb, ${accent} 15%, transparent), transparent 70%)`, pointerEvents: "none" }} />}
      <div style={{ position: "relative" }}>{children}</div>
    </div>
  );
}

// ── EXPERIENCE ("O que você vai viver") ──
const STEPS = [
  { t: "Enxergar oportunidades de compra", d: "Onde estão as oportunidades reais de compra, e o que separa um bom negócio de uma armadilha cara." },
  { t: "Pensar fornecedores e fábricas", d: "Como enxergar fábricas e fornecedores por trás dos produtos que você já vende, em vez de aceitar o primeiro intermediário." },
  { t: "Fugir dos intermediários", d: "O caminho para chegar mais perto da fonte e parar de pagar a margem de quem comprou antes de você." },
  { t: "Se preparar para negociar", d: "Como chegar à negociação com clareza: o que perguntar, o que exigir e o que nunca aceitar." },
  { t: "Pedidos, amostras e volume", d: "Como funcionam pedidos, amostras e compras em volume, e o que avaliar antes de fechar." },
  { t: "Logística e chegada no Brasil", d: "Como pensar logística, importação e a chegada da mercadoria ao Brasil sem travar no caminho." },
  { t: "Preparação para a feira de outubro", d: "Como se preparar para a maior feira de fornecedores do mundo, em outubro, chegando lá sabendo o que procurar." },
  { t: "Networking entre empresários", d: "Troca direta com empresários, compradores e participantes que vivem o mesmo desafio que você." },
];
function Experience({ onCta }) {
  // Very subtle calligraphy backdrop that gently warms up on hover.
  const [hovers, setHovers] = React.useState(0);
  const bump = () => setHovers((h) => Math.min(h + 1, 6));
  const opacity = Math.min(0.04 + hovers * 0.014, 0.13);
  return (
    <Section glow style={{ position: "relative", overflow: "hidden" }}>
      <div aria-hidden="true" style={{ position: "absolute", inset: 0, zIndex: 0, pointerEvents: "none" }}>
        <img src="assets/calligraphy-strokes.png" alt="" loading="lazy"
          style={{ position: "absolute", top: "50%", left: "50%", transform: "translate(-50%, -50%)", width: "min(110%, 1450px)", height: "auto", opacity, transition: "opacity 1.2s var(--ease-out)" }} />
      </div>
      <div onMouseEnter={bump} style={{ position: "relative", zIndex: 2 }}>
        <SectionHead n="02" tag="O que você vai viver" title='Dois dias para enxergar a <span style="color:var(--go-4); font-style: italic;">China dos negócios</span> por dentro.' sub="Não é teoria de quem olha de longe. É a leitura de quem vive a China e traduz os bastidores para o empresário brasileiro." />
        <div style={{ marginTop: "48px", position: "relative" }}>
          <div style={{ position: "absolute", left: "23px", top: "12px", bottom: "12px", width: "1px", background: "linear-gradient(180deg, var(--bronze) 0%, var(--go-4) 40%, var(--bronze) 70%, transparent 100%)" }} />
          {STEPS.map((s, i) => (
            <Reveal key={i} delay={i * 0.05}>
              <div onMouseEnter={bump} style={{ display: "flex", gap: "22px", padding: "16px 0", alignItems: "flex-start" }}>
                <div style={{ flexShrink: 0, width: "48px", height: "48px", borderRadius: "50%", background: "linear-gradient(165deg, #1B1810 0%, #0A0907 100%)", border: "1px solid var(--bronze)", display: "flex", alignItems: "center", justifyContent: "center", fontFamily: "var(--f-display)", fontStyle: "italic", fontWeight: 400, fontSize: "1.05rem", color: "var(--go-4)", position: "relative", zIndex: 1, boxShadow: "0 0 0 4px var(--abyss), 0 6px 18px rgba(0,0,0,0.6)" }}>{String(i + 1).padStart(2, "0")}</div>
                <div style={{ paddingTop: "4px" }}>
                  <div style={{ fontFamily: "var(--f-display)", fontWeight: 400, fontSize: "1.25rem", color: "var(--cream)", marginBottom: "6px", letterSpacing: "-0.005em" }}>{s.t}</div>
                  <div style={{ fontFamily: "var(--f-body)", fontSize: ".98rem", lineHeight: 1.6, color: "var(--txt-body)", maxWidth: "640px" }}>{s.d}</div>
                </div>
              </div>
            </Reveal>
          ))}
        </div>
        <Reveal delay={0.2}>
          <div className="pf-btn-container-experience" style={{ marginTop: "40px", paddingLeft: "70px" }}>
            <Button variant="primary" size="md" onClick={onCta} shimmer>Quero viver essa imersão →</Button>
          </div>
        </Reveal>
      </div>
    </Section>
  );
}

// ── AUDIENCE (for / not for) ──
function Audience() {
  const yes = ["Já vende produtos físicos ou tem operação rodando", "Já compra de fornecedores ou distribuidores brasileiros", "Sente que a sua margem poderia ser bem maior", "Quer negociar mais perto da fonte, sem intermediário", "Quer se preparar para a feira de fornecedores de outubro", "Busca networking e quer aprender com quem mora na China"];
  const no = ["Procura promessa de dinheiro fácil", "Quer fórmula mágica, sem estratégia", "Não está disposto a estudar compra e negociação", "Ainda não tem interesse real em produtos ou fornecedores"];
  // Left (yes) column: brighter cream text, full saturation. Right
  // (no) column: legible soft cream-grey — the brief specifically asked
  // we lift contrast there but keep visual hierarchy lower than yes.
  const Col = ({ head, items, color, mark, accent, strike, textColor, bg }) => (
    <HoverCard accent={accent} surface={bg} pad="30px">
      <div style={{ fontFamily: "var(--f-display)", fontWeight: 700, fontSize: "1.2rem", color, marginBottom: "20px", letterSpacing: "-0.005em" }}>{head}</div>
      <div style={{ display: "flex", flexDirection: "column", gap: "14px" }}>
        {items.map((t, i) => (
          <div key={i} style={{ display: "flex", gap: "14px", alignItems: "flex-start", fontFamily: "var(--f-body)", fontSize: "1rem", lineHeight: 1.5, color: textColor }}>
            <span style={{ color, flexShrink: 0, fontWeight: 700, fontSize: "1.05rem", lineHeight: 1.4 }}>{mark}</span>
            <span style={{ textDecoration: strike ? "line-through" : "none", textDecorationColor: "rgba(140,31,31,0.55)", textDecorationThickness: "1px" }}>{t}</span>
          </div>
        ))}
      </div>
    </HoverCard>
  );
  return (
    <Section>
      <SectionHead n="03" tag="Para quem é" title="Direto ao ponto: isso é pra você?" />
      <div className="pf-audience-grid" style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: "16px", marginTop: "44px" }}>
        <Reveal>
          <Col head="É pra você se…" items={yes} color="var(--go-4)" mark="✓" accent="var(--go)" textColor="var(--cream)" bg="linear-gradient(165deg, #1B1810 0%, #0F0D08 100%)" />
        </Reveal>
        <Reveal delay={0.08}>
          <Col head="Não é pra você se…" items={no} color="var(--crimson-4)" mark="✗" accent="var(--crimson)" strike textColor="#C8BFAE" bg="var(--surface)" />
        </Reveal>
      </div>
    </Section>
  );
}

window.Section = Section; window.SectionHead = SectionHead; window.Ticker = Ticker;
window.Pain = Pain; window.Turn = Turn; window.Experience = Experience; window.Audience = Audience; window.HoverCard = HoverCard;
window.IconCard = IconCard; window.ACC = ACC;
