// Tomohunt landing — interactive layer (waitlist form, FAQ accordion, screenshot carousel, tweaks)
// Loads after tweaks-panel.jsx + shader.js.

const TWEAK_DEFAULTS = /*EDITMODE-BEGIN*/{
  "parallaxStrength": 1.0,
  "sceneIntensity": 1.0,
  "forceReducedMotion": false
} /*EDITMODE-END*/;

// ─── Icons (Lucide-style, stroke 1.5) ─────────────────────────────────────
const Icon = ({ d, size = 22, stroke = 1.5, fill = "none", style }) =>
<svg width={size} height={size} viewBox="0 0 24 24" fill={fill}
stroke="currentColor" strokeWidth={stroke} strokeLinecap="round" strokeLinejoin="round"
style={style} aria-hidden="true">
    {d}
  </svg>;

const IconSearch = (p) => <Icon {...p} d={<><circle cx="11" cy="11" r="7" /><path d="m20 20-3.5-3.5" /></>} />;
const IconStar = (p) => <Icon {...p} d={<polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" />} />;
const IconBell = (p) => <Icon {...p} d={<><path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9" /><path d="M10.3 21a1.94 1.94 0 0 0 3.4 0" /></>} />;
const IconPlay = (p) => <Icon {...p} d={<polygon points="6 4 20 12 6 20 6 4" />} />;
const IconArrow = (p) => <Icon {...p} d={<><path d="M5 12h14" /><path d="m12 5 7 7-7 7" /></>} />;
const IconChev = (p) => <Icon {...p} d={<polyline points="6 9 12 15 18 9" />} />;
const IconCheck = (p) => <Icon {...p} d={<polyline points="20 6 9 17 4 12" />} />;
const IconBook = (p) => <Icon {...p} d={<><path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20" /><path d="M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z" /></>} />;
const IconLink = (p) => <Icon {...p} d={<><path d="M9 17H7A5 5 0 0 1 7 7h2" /><path d="M15 7h2a5 5 0 1 1 0 10h-2" /><line x1="8" y1="12" x2="16" y2="12" /></>} />;
const IconX = (p) => <Icon {...p} d={<path d="M18.901 1.153h3.68l-8.04 9.19L24 22.846h-7.406l-5.8-7.584-6.638 7.584H.474l8.6-9.83L0 1.154h7.594l5.243 6.932ZM17.61 20.644h2.039L6.486 3.24H4.298Z" />} fill="currentColor" stroke={0} />;
const IconInstagram = (p) => <Icon {...p} d={<path d="M12 0C8.74 0 8.333.015 7.053.072 5.775.132 4.905.333 4.14.63c-.789.306-1.459.717-2.126 1.384S.935 3.35.63 4.14C.333 4.905.131 5.775.072 7.053.012 8.333 0 8.74 0 12s.015 3.667.072 4.947c.06 1.277.261 2.148.558 2.913.306.788.717 1.459 1.384 2.126.667.666 1.336 1.079 2.126 1.384.766.296 1.636.499 2.913.558C8.333 23.988 8.74 24 12 24s3.667-.015 4.947-.072c1.277-.06 2.148-.262 2.913-.558.788-.306 1.459-.718 2.126-1.384.666-.667 1.079-1.335 1.384-2.126.296-.765.499-1.636.558-2.913.06-1.28.072-1.687.072-4.947s-.015-3.667-.072-4.947c-.06-1.277-.262-2.149-.558-2.913-.306-.789-.718-1.459-1.384-2.126C21.319 1.347 20.651.935 19.86.63c-.765-.297-1.636-.499-2.913-.558C15.667.012 15.26 0 12 0zm0 2.16c3.203 0 3.585.016 4.85.071 1.17.055 1.805.249 2.227.415.562.217.96.477 1.382.896.419.42.679.819.896 1.381.164.422.36 1.057.413 2.227.057 1.266.07 1.646.07 4.85s-.015 3.585-.074 4.85c-.061 1.17-.256 1.805-.421 2.227-.224.562-.479.96-.899 1.382-.419.419-.824.679-1.38.896-.42.164-1.065.36-2.235.413-1.274.057-1.649.07-4.859.07-3.211 0-3.586-.015-4.859-.074-1.171-.061-1.816-.256-2.236-.421-.569-.224-.96-.479-1.379-.899-.421-.419-.69-.824-.9-1.38-.165-.42-.359-1.065-.42-2.235-.045-1.26-.061-1.649-.061-4.844 0-3.196.016-3.586.061-4.861.061-1.17.255-1.814.42-2.234.21-.57.479-.96.9-1.381.419-.419.81-.689 1.379-.898.42-.166 1.051-.361 2.221-.421 1.275-.045 1.65-.06 4.859-.06zm0 3.678c-3.405 0-6.162 2.76-6.162 6.162 0 3.405 2.76 6.162 6.162 6.162 3.405 0 6.162-2.76 6.162-6.162 0-3.405-2.76-6.162-6.162-6.162zM12 16c-2.21 0-4-1.79-4-4s1.79-4 4-4 4 1.79 4 4-1.79 4-4 4zm7.846-10.405c0 .795-.646 1.44-1.44 1.44-.795 0-1.44-.646-1.44-1.44 0-.794.646-1.439 1.44-1.439.793-.001 1.44.645 1.44 1.439z" />} fill="currentColor" stroke={0} />;
const IconBluesky = (p) => <Icon {...p} d={<path d="M12 10.8c-1.087-2.114-4.046-6.053-6.798-7.995C2.566.944 1.561 1.266.902 1.565.139 1.908 0 3.08 0 3.768c0 .69.378 5.65.624 6.479.815 2.736 3.713 3.66 6.383 3.364.136-.02.275-.039.415-.056-.138.021-.276.04-.415.056-3.912.58-7.387 2.005-2.83 7.078 5.013 5.19 6.87-1.113 7.823-4.308.953 3.195 2.05 9.271 7.733 4.308 4.267-4.308 1.172-6.498-2.74-7.078-.136-.02-.275-.039-.415-.056.14.017.279.036.415.056 2.67.296 5.568-.628 6.383-3.364.246-.828.624-5.79.624-6.478 0-.69-.139-1.861-.902-2.206-.659-.298-1.664-.62-4.3 1.24C16.046 4.748 13.087 8.687 12 10.8z" />} fill="currentColor" stroke={0} />;

// ─── Brand mark (matches Tomohunt Identity.html) ──────────────────────────
const LogoMark = ({ size = 30 }) => (
  <svg width={size} height={size} viewBox="0 0 200 200" aria-hidden="true" className="brand-mark">
    <defs>
      <linearGradient id="logo-mark-grad" x1="0" y1="0" x2="1" y2="1">
        <stop offset="0%" stopColor="#4338CA"/>
        <stop offset="100%" stopColor="#818CF8"/>
      </linearGradient>
    </defs>
    <rect width="200" height="200" rx="46" fill="url(#logo-mark-grad)"/>
    <text x="100" y="148" textAnchor="middle"
          fontFamily="Space Grotesk, Inter, sans-serif"
          fontWeight="800" fontSize="180" letterSpacing="-8"
          fill="#F4F2FA">t</text>
    <g transform="translate(154, 48) rotate(15)">
      <path d="M 0,-12 L 3,-3 L 12,0 L 3,3 L 0,12 L -3,3 L -12,0 L -3,-3 Z" fill="#FBBF24"/>
      <circle r="2.4" fill="#FFFFFF" opacity="0.9"/>
    </g>
  </svg>
);

// ─── Trust bar editoras ───────────────────────────────────────────────────
const EDITORAS = ["JBC", "NewPOP", "Pipoca e Nanquim", "Devir", "Panini", "Baú Editora", "Universo dos Livros", "Taverna do Rei", "MPEG"];

// ─── Phone screen mockups (placeholder, indigo gradient) ──────────────────
function PhoneScreen({ kind }) {
  // Three flavors of in-app screen, drawn in CSS — placeholder until real prints exist.
  if (kind === "home") {
    return (
      <div className="screen-home">
        <div className="screen-statusbar">
          <span>9:41</span>
          <span className="screen-statusicons">
            <i className="dot"></i><i className="dot"></i><i className="dot"></i>
          </span>
        </div>
        <div className="screen-h1">Maio 2026</div>
        <div className="screen-h2">12 volumes esperando você</div>
        <div className="screen-grid">
          {[
          { t: "Chainsaw Man", v: "Vol. 17", s: "12 mai", tag: "Pré-venda" },
          { t: "Berserk Deluxe", v: "Vol. 9", s: "18 mai", tag: "Pré-venda" },
          { t: "Dandadan", v: "Vol. 11", s: "Lançado", tag: "Comprar" },
          { t: "Vagabond", v: "Vol. 22", s: "25 mai", tag: "Esperando" }].
          map((b, i) =>
          <div key={i} className="screen-card">
              <div className="screen-cover" style={{
              background: `linear-gradient(${135 + i * 30}deg, #4338CA, #6366F1 60%, #818CF8)`
            }}>
                <span className="screen-cover-vol">{b.v.replace('Vol. ', '#')}</span>
              </div>
              <div className="screen-card-meta">
                <div className="screen-card-t">{b.t}</div>
                <div className="screen-card-s">{b.s}</div>
              </div>
              <div className={"screen-card-tag tag-" + b.tag.toLowerCase().replace(/\s|ç/g, '')}>{b.tag}</div>
            </div>
          )}
        </div>
      </div>);

  }
  if (kind === "watchlist") {
    return (
      <div className="screen-home">
        <div className="screen-statusbar"><span>9:41</span><span className="screen-statusicons"><i className="dot"></i><i className="dot"></i><i className="dot"></i></span></div>
        <div className="screen-h1">Minha lista</div>
        <div className="screen-segment">
          <button className="seg-on">Pré-venda</button>
          <button>Aguardando</button>
          <button>Lançados</button>
        </div>
        <div className="screen-list">
          {[
          { t: "Chainsaw Man", v: "Vol. 17 · JBC", d: "12 mai" },
          { t: "Berserk Deluxe", v: "Vol. 9 · Panini", d: "18 mai" },
          { t: "Spy x Family", v: "Vol. 14 · Panini", d: "23 mai" },
          { t: "Frieren", v: "Vol. 8 · NewPOP", d: "30 mai" },
          { t: "Blame!", v: "Vol. 4 · Pipoca e Nanquim", d: "5 jun" }].
          map((r, i) =>
          <div key={i} className="screen-row">
              <div className="screen-row-cover" style={{ background: `linear-gradient(${100 + i * 40}deg, #4338CA, #818CF8)` }} />
              <div className="screen-row-body">
                <div className="screen-row-t">{r.t}</div>
                <div className="screen-row-s">{r.v}</div>
              </div>
              <div className="screen-row-date">
                <div className="screen-row-d">{r.d}</div>
                <IconStar size={14} fill="#FBBF24" stroke={0} style={{ color: '#FBBF24' }} />
              </div>
            </div>
          )}
        </div>
      </div>);

  }
  // detail
  return (
    <div className="screen-home">
      <div className="screen-statusbar"><span>9:41</span><span className="screen-statusicons"><i className="dot"></i><i className="dot"></i><i className="dot"></i></span></div>
      <div className="screen-hero" style={{ background: "linear-gradient(160deg, #4338CA, #6366F1 50%, #818CF8)" }}>
        <div className="screen-hero-vol">#17</div>
      </div>
      <div className="screen-detail-body">
        <div className="screen-detail-t">Chainsaw Man</div>
        <div className="screen-detail-s">Volume 17 · JBC · 200 págs</div>
        <div className="screen-detail-chips">
          <span className="chip">Pré-venda</span>
          <span className="chip chip-muted">Lança 12 mai</span>
        </div>
        <div className="screen-detail-row"><span>Autor</span><b>Tatsuki Fujimoto</b></div>
        <div className="screen-detail-row"><span>Editora BR</span><b>JBC</b></div>
        <div className="screen-detail-row"><span>Preço sugerido</span><b>R$ 32,90</b></div>
        <button className="screen-buy">
          <span>Comprar na JBC</span>
          <IconArrow size={14} />
        </button>
        <div className="screen-affiliate">
          <IconLink size={11} /> Link de afiliado — você não paga a mais
        </div>
      </div>
    </div>);

}

function PhoneFrame({ kind, label }) {
  return (
    <div className="phone-wrap">
      <div className="phone-frame">
        <div className="phone-notch"></div>
        <div className="phone-screen">
          <PhoneScreen kind={kind} />
        </div>
      </div>
      {label && <div className="phone-label">{label}</div>}
    </div>);

}

// ─── Sections ─────────────────────────────────────────────────────────────
function Header() {
  return (
    <header className="site-header" style={{ opacity: "1", borderRadius: "0px" }}>
      <a href="#" className="brand" aria-label="tomohunt">
        <LogoMark size={30}/>
        <span className="brand-wordmark"><span className="brand-accent">tomo</span><span>hunt</span></span>
      </a>
      <nav className="site-nav">
        <a href="#como">Como funciona</a>
        <a href="#screens">Telas</a>
        <a href="#faq">FAQ</a>
      </nav>
      <a href="#top" className="nav-cta nav-cta-filled">
        <span>Baixar grátis</span>
      </a>
    </header>);

}

// ─── Store icons + bento feature card icons ──────────────────────────────
const IconApple = (p) => <Icon {...p} d={<><path d="M16.5 12.5c0-2.5 2-3.6 2.1-3.7-1.1-1.7-3-1.9-3.6-1.9-1.5-.2-3 .9-3.8.9s-2-.9-3.3-.9c-1.7 0-3.3 1-4.2 2.5-1.8 3.1-.5 7.7 1.3 10.2.9 1.2 1.9 2.6 3.2 2.5 1.3-.1 1.8-.8 3.3-.8s2 .8 3.3.8 2.2-1.2 3-2.4c.9-1.4 1.3-2.7 1.3-2.8-.1-.1-2.6-1-2.6-3.4z" /><path d="M14 4.5c.7-.8 1.1-1.9 1-3-1 0-2.1.7-2.8 1.5-.6.7-1.2 1.8-1 2.9 1.1.1 2.1-.6 2.8-1.4z" /></>} stroke={0} fill="currentColor" />;
const IconGooglePlay = (p) => <Icon {...p} d={<><path d="M3 20.5V3.5a1 1 0 0 1 1.5-.87L21 12 4.5 21.37A1 1 0 0 1 3 20.5z" /><path d="m13.5 9 7.5 3-7.5 3" /></>} />;
const IconStar2 = (p) => <Icon {...p} d={<polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" />} fill="currentColor" stroke={0} />;
const IconClock = (p) => <Icon {...p} d={<><circle cx="12" cy="12" r="10" /><polyline points="12 6 12 12 16 14" /></>} />;
const IconShoppingBag = (p) => <Icon {...p} d={<><path d="M6 2 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4z" /><line x1="3" y1="6" x2="21" y2="6" /><path d="M16 10a4 4 0 0 1-8 0" /></>} />;
const IconTrendingUp = (p) => <Icon {...p} d={<><polyline points="22 7 13.5 15.5 8.5 10.5 2 17" /><polyline points="16 7 22 7 22 13" /></>} />;

// ─── Bento sub-cards ──────────────────────────────────────────────────────
// BENTO-DATA-START (auto-refreshed by scripts/refresh-bento.py — do not edit by hand)
const BENTO_NOTIF = {"title": "AS VIAJANTES DO FIM Vol. 3 chegou às livrarias", "cta": "Toque pra comprar na Baú"};
const BENTO_STATS = {"count": 11, "pubs": ["Baú", "JBC", "+2"]};
const BENTO_WATCHLIST = [
  {"t": "Astro Boy BIG", "v": "Vol. 04 · JBC", "d": "1/4", "ring": true, "cover": "https://tomohunt-cdn.inovatehk.com/covers/799987f23beaa9d0d5bcb34f.jpg"},
  {"t": "Yomi no Tsugai - Daemons do Reino das Sombras", "v": "Vol. 03 · JBC", "d": "1/4", "ring": true, "cover": "https://tomohunt-cdn.inovatehk.com/covers/b69d26d13f84414bf1ab9d29.jpg"},
  {"t": "Bencao", "v": "Vol. 2 · NewPOP", "d": "1/4", "ring": true, "cover": "https://tomohunt-cdn.inovatehk.com/covers/4c2518347ae7e455230635f3.jpg"},
  {"t": "AS VIAJANTES DO FIM", "v": "Vol. 1 · Baú", "d": "1/5", "ring": true, "cover": "https://tomohunt-cdn.inovatehk.com/covers/fa23570e0c0b844dae6096a9.png"},
];
// BENTO-DATA-END

function NotificationCard() {
  return (
    <div className="bento-card bento-notif">
      <div className="bento-card-head">
        <div className="bento-eyebrow"><IconBell size={13} /> NOTIFICAÇÃO</div>
        <div className="bento-time">agora</div>
      </div>
      <div className="notif-toast">
        <div className="notif-icon"><IconBell size={18} /></div>
        <div className="notif-body">
          <div className="notif-source">TOMOHUNT · agora</div>
          <div className="notif-title">{BENTO_NOTIF.title}</div>
          <div className="notif-action">
            <span>{BENTO_NOTIF.cta}</span>
            <IconArrow size={12} />
          </div>
        </div>
      </div>
    </div>);

}

function TodayStatsCard() {
  return (
    <div className="bento-card bento-stats">
      <div className="bento-card-head">
        <div className="bento-eyebrow"><IconClock size={13} /> CATÁLOGO</div>
      </div>
      <div className="stats-big">{BENTO_STATS.count}</div>
      <div className="stats-label">volumes recém<br />publicados</div>
      <div className="stats-publishers">
        {BENTO_STATS.pubs.map((p, i) => <span className="stats-pub" key={i}>{p}</span>)}
      </div>
    </div>);

}

function WatchlistCard() {
  const items = BENTO_WATCHLIST;

  return (
    <div className="bento-card bento-watchlist">
      <div className="bento-card-head">
        <div className="bento-eyebrow"><IconStar size={13} /> LISTA</div>
        <div className="bento-time">{items.length} itens</div>
      </div>
      <div className="watchlist-rows">
        {items.map((it, i) =>
        <div className="watchlist-row" key={i}>
            <img className="watchlist-cover" src={it.cover} alt="" loading="lazy" />
            <div className="watchlist-meta">
              <div className="watchlist-t">{it.t}</div>
              <div className="watchlist-s">{it.v}</div>
            </div>
            <div className="watchlist-date">
              {it.ring && <IconBell size={11} style={{ color: 'var(--accent-hi)' }} />}
              <span>{it.d}</span>
            </div>
          </div>
        )}
      </div>
    </div>);

}

function AffiliateCard() {
  return (
    <div className="bento-card bento-affiliate">
      <div className="bento-card-head">
        <div className="bento-eyebrow"><IconShoppingBag size={13} /> COMPRAR</div>
      </div>
      <div className="affiliate-pill" style={{ backgroundColor: "rgba(141, 104, 240, 0.255)", color: "rgb(255, 255, 255)", borderColor: "rgba(90, 31, 237, 0.56)" }}>
        <IconLink size={11} />
        Link de afiliado
      </div>
      <div className="affiliate-copy">
        <strong>Você nunca paga a mais.</strong> A gente avisa antes de você clicar e fica com uma fração — é o que mantém o app grátis.
      </div>
    </div>);

}

// ─── Hero ─────────────────────────────────────────────────────────────────
function Hero() {
  const stageRef = React.useRef(null);

  React.useEffect(() => {
    const stage = stageRef.current;
    if (!stage) return;
    const layers = () => stage.querySelectorAll('.iso-layer');
    const state = { mx: 0, my: 0, tmx: 0, tmy: 0, scroll: 0 };
    let raf = 0;

    function onMove(e) {
      const r = stage.getBoundingClientRect();
      const cx = r.left + r.width / 2;
      const cy = r.top + r.height / 2;
      state.tmx = Math.max(-1.4, Math.min(1.4, (e.clientX - cx) / (r.width / 2)));
      state.tmy = Math.max(-1.4, Math.min(1.4, (e.clientY - cy) / (r.height / 2)));
    }
    function onLeave() {state.tmx = 0;state.tmy = 0;}
    function onScroll() {
      const r = stage.getBoundingClientRect();
      const p = Math.max(0, Math.min(1, -r.top / Math.max(r.height, 1)));
      state.scroll = p;
    }

    function loop() {
      state.mx += (state.tmx - state.mx) * 0.10;
      state.my += (state.tmy - state.my) * 0.10;
      const rootStyle = getComputedStyle(document.documentElement);
      const strength = parseFloat(rootStyle.getPropertyValue('--parallax-strength')) || 1.0;
      const reduced = parseFloat(rootStyle.getPropertyValue('--reduced-motion')) === 1;
      const sm = reduced ? 0 : strength;
      for (const l of layers()) {
        const d = parseFloat(l.dataset.depth || '0.1');
        const px = state.mx * d * 200 * sm; // mouse-driven X, bumped for visibility
        const py = state.my * d * 130 * sm; // mouse-driven Y
        const sy = state.scroll * (1 - d * 1.2) * 220;
        const op = 1 - state.scroll * (0.55 + d * 0.6);
        l.style.transform = `translate3d(${px.toFixed(2)}px, ${(py + sy).toFixed(2)}px, 0)`;
        l.style.opacity = Math.max(0, op).toFixed(2);
      }
      raf = requestAnimationFrame(loop);
    }

    document.addEventListener('mousemove', onMove, { passive: true });
    document.addEventListener('pointermove', onMove, { passive: true });
    window.addEventListener('mouseout', (e) => {if (!e.relatedTarget) onLeave();});
    window.addEventListener('blur', onLeave);
    window.addEventListener('scroll', onScroll, { passive: true });
    onScroll();
    raf = requestAnimationFrame(loop);
    return () => {
      cancelAnimationFrame(raf);
      document.removeEventListener('mousemove', onMove);
      document.removeEventListener('pointermove', onMove);
      window.removeEventListener('blur', onLeave);
      window.removeEventListener('scroll', onScroll);
    };
  }, []);

  const IsoScene = window.IsoScene;

  return (
    <section className="hero" id="top">
      <div className="hero-stage" ref={stageRef} aria-hidden="true">
        <div className="hero-stage-inner">
          {IsoScene && <IsoScene />}
        </div>
      </div>
      <div className="hero-vignette" aria-hidden="true"></div>

      <div className="hero-grid">
        <div className="hero-text">
          <h1 className="display">
            Nunca perca um lançamento de mangá no Brasil <span className="display-em">de novo.</span>
          </h1>
          <p className="hero-sub">
            Tomohunt acompanha as listas de toda editora e te avisa no dia que o seu volume chega às livrarias.
          </p>

          <div className="hero-cta">
            <a href="#" className="store-btn">
              <IconApple size={26} />
              <span className="store-label">
                <small>Baixe na</small>
                <strong>App Store</strong>
              </span>
            </a>
            <a href="#" className="store-btn">
              <IconGooglePlay size={22} />
              <span className="store-label">
                <small>Disponível no</small>
                <strong>Google Play</strong>
              </span>
            </a>
          </div>

          <div className="trustbar" aria-label="Editoras acompanhadas">
            <span className="trustbar-label">Acompanhamos</span>
            {EDITORAS.map((e, i) =>
            <React.Fragment key={e}>
                <span>{e}</span>
                {i < EDITORAS.length - 1 && <span className="trust-sep">·</span>}
              </React.Fragment>
            )}
          </div>
        </div>

        <div className="hero-bento" aria-hidden="true">
          <NotificationCard />
          <TodayStatsCard />
          <WatchlistCard />
          <AffiliateCard />
        </div>
      </div>
    </section>);

}

function ComoFunciona() {
  const steps = [
  { icon: <IconSearch />, t: "A gente vasculha", b: "Todo dia conferimos os lançamentos das principais editoras do Brasil." },
  { icon: <IconStar />, t: "Você marca o que importa", b: "Toca na estrelinha do volume ou da série inteira." },
  { icon: <IconBell />, t: "A gente avisa", b: "Push no dia provável de chegada. Link de compra com aviso de afiliado, sempre." }];

  return (
    <section className="section" id="como">
      <div className="section-eyebrow">Como funciona</div>
      <h2 className="h1">Três passos. Sem fricção.</h2>
      <div className="steps">
        {steps.map((s, i) =>
        <div className="step" key={i} data-reveal data-reveal-delay={String(i + 1)}>
            <div className="step-icon">{s.icon}</div>
            <div className="step-num">0{i + 1}</div>
            <div className="step-t">{s.t}</div>
            <div className="step-b">{s.b}</div>
          </div>
        )}
      </div>
    </section>);

}

function Screenshots() {
  const phones = [
  { k: "home", label: "Checklist do mês" },
  { k: "watchlist", label: "Minha lista" },
  { k: "detail", label: "Detalhe do volume" }];

  return (
    <section className="section" id="screens">
      <div className="section-eyebrow">Por dentro</div>
      <h2 className="h1">Construído pra quem realmente coleciona.</h2>
      <p className="section-sub">Três telas, uma única ideia: você sabe exatamente o que vem por aí.</p>
      <div className="phones">
        {phones.map((p, i) => <div data-reveal data-reveal-delay={String(i + 1)} key={p.k}><PhoneFrame kind={p.k} label={p.label} /></div>)}
      </div>
    </section>);

}

function DemoVideo() {
  return (
    <section className="section" id="demo">
      <div className="demo-card">
        <div className="demo-aspect">
          <div className="demo-overlay">
            <button className="demo-play" aria-label="Reproduzir demo">
              <IconPlay size={28} fill="currentColor" />
            </button>
            <div className="demo-tooltip">Demo de 30s — em breve</div>
          </div>
        </div>
      </div>
    </section>);

}

function FAQ() {
  const items = [
  { q: "Quanto custa?", a: "Grátis pra sempre. O Premium adiciona notificações ilimitadas e cobertura estendida — o core de avisos não tem paywall." },
  { q: "Funciona com quais editoras?", a: "JBC, NewPOP, Pipoca e Nanquim, Devir, Panini, Baú Editora, Universo dos Livros, Taverna do Rei e MPEG. Lista atualizada à medida que entram." },
  { q: "Os links de compra dão alguma comissão?", a: "Sim, alguns têm tag de afiliado da editora ou Amazon. Quando tem, a gente avisa antes de você clicar. Você nunca paga a mais por isso." },
  { q: "iOS e Android?", a: "Sim, ambos. Lançamento simultâneo no iOS e Android." },
  { q: "Cadê meus dados?", a: "A gente guarda só seu e-mail + token de sessão + token de push do aparelho. Sem rastreamento de comportamento fora do app. Política completa: link no rodapé." },
  { q: "Com que frequência acompanha?", a: "Diariamente — uma vez por dia, respeitando os sites das editoras." }];

  const [open, setOpen] = React.useState(0);
  return (
    <section className="section" id="faq">
      <div className="section-eyebrow">Perguntas frequentes</div>
      <h2 className="h1">O básico, sem rodeio.</h2>
      <div className="faq">
        {items.map((it, i) => {
          const isOpen = open === i;
          return (
            <div key={i} className={"faq-item " + (isOpen ? "open" : "")}>
              <button className="faq-q" onClick={() => setOpen(isOpen ? -1 : i)} aria-expanded={isOpen}>
                <span>{it.q}</span>
                <IconChev size={18} style={{ transform: isOpen ? "rotate(180deg)" : "none", transition: "transform 220ms ease" }} />
              </button>
              <div className="faq-a" style={{ maxHeight: isOpen ? 240 : 0 }}>
                <p>{it.a}</p>
              </div>
            </div>);

        })}
      </div>
    </section>);

}

function Footer() {
  return (
    <footer className="site-footer">
      <div className="footer-cta">
        <div>
          <h3 className="footer-cta-h">Comece a acompanhar seus lançamentos.</h3>
          <p className="footer-cta-p">Grátis no iOS e Android. Sem cadastro.</p>
        </div>
        <div className="footer-cta-buttons">
          <a href="#" className="store-btn">
            <IconApple size={22}/>
            <span className="store-label"><small>Baixe na</small><strong>App Store</strong></span>
          </a>
          <a href="#" className="store-btn">
            <IconGooglePlay size={20}/>
            <span className="store-label"><small>Disponível no</small><strong>Google Play</strong></span>
          </a>
        </div>
      </div>

      <div className="footer-cols">
        <div>
          <div className="footer-brand"><LogoMark size={28}/> <span><span className="brand-accent">tomo</span>hunt</span></div>
          <div className="footer-tag">Avisos de lançamento de mangá no Brasil.</div>
          <div className="footer-social">
            <a href="#" aria-label="Twitter / X"><IconX size={28}/></a>
            <a href="#" aria-label="Instagram"><IconInstagram size={28}/></a>
            <a href="#" aria-label="Bluesky"><IconBluesky size={28}/></a>
          </div>
        </div>
        <div>
          <div className="footer-h">Sobre</div>
          <a href="/quem-faz.html">Quem faz</a>
          <a href="#faq">FAQ</a>
        </div>
        <div>
          <div className="footer-h">Legal</div>
          <a href="/privacidade.html">Política de privacidade</a>
          <a href="/afiliados.html">Aviso de afiliados</a>
          <a href="/termos.html">Termos</a>
        </div>
        <div>
          <div className="footer-h">Newsletter</div>
          <p className="footer-news-tag">Resumo semanal dos lançamentos.</p>
          <form className="footer-news" onSubmit={(e) => e.preventDefault()}>
            <input type="email" placeholder="seu@email.com" aria-label="Email"/>
            <button type="submit" aria-label="Assinar"><IconArrow size={14}/></button>
          </form>
          <a href="mailto:suporte@tomohunt.com.br" className="footer-contact">suporte@tomohunt.com.br</a>
        </div>
      </div>
      <div className="footer-foot">
        Feito por fãs, pra fãs. tomohunt não é afiliado às editoras listadas.
      </div>
    </footer>);

}

// ─── Cookie consent banner ───────────────────────────────────────────────
// LGPD/GDPR-style opt-in. No cookies / analytics / external scripts must
// init before the user explicitly accepts. The consent flag itself lives in
// localStorage (treated as "strictly necessary" for the consent mechanism).
const CONSENT_KEY = 'tomohunt-consent';
function readConsent() {
  try { return localStorage.getItem(CONSENT_KEY); } catch { return null; }
}
function writeConsent(value) {
  try { localStorage.setItem(CONSENT_KEY, value); } catch {}
  window.dispatchEvent(new CustomEvent('tomohunt-consent-change', { detail: value }));
}
function CookieBanner() {
  const [state, setState] = React.useState('hidden');
  React.useEffect(() => {
    setState(readConsent() ? 'hidden' : 'visible');
  }, []);
  const decide = (value) => {
    writeConsent(value);
    setState('hidden');
  };
  if (state !== 'visible') return null;
  return (
    <div className="cookie-banner" role="dialog" aria-live="polite" aria-label="Aviso de cookies">
      <div className="cookie-copy">
        <strong>Sobre cookies.</strong> Tomohunt só usa o estritamente necessário pra esta página funcionar. Nada de analytics ou rastreio sem o seu aceite. Detalhes na <a href="/privacidade.html">Política de privacidade</a>.
      </div>
      <div className="cookie-actions">
        <button type="button" className="cookie-btn cookie-btn-ghost" onClick={() => decide('denied')}>Só essenciais</button>
        <button type="button" className="cookie-btn cookie-btn-primary" onClick={() => decide('accepted')}>Aceitar tudo</button>
      </div>
    </div>);
}

// ─── App ──────────────────────────────────────────────────────────────────
function App() {
  // Production: use TWEAK_DEFAULTS directly (tweaks-panel.jsx is design-tool only).
  const t = TWEAK_DEFAULTS;

  const systemReducedMotion = React.useMemo(() =>
  window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches, []);
  const reducedMotion = t.forceReducedMotion || systemReducedMotion;

  // Apply tweaks to CSS custom properties so the scene + parallax pick them up.
  React.useEffect(() => {
    const r = document.documentElement;
    r.style.setProperty('--parallax-strength', String(t.parallaxStrength));
    r.style.setProperty('--scene-intensity', String(t.sceneIntensity));
    r.style.setProperty('--reduced-motion', reducedMotion ? '1' : '0');
  }, [t.parallaxStrength, t.sceneIntensity, reducedMotion]);

  // Scroll-in reveal: add .in-view to [data-reveal] elements when they enter the viewport.
  React.useEffect(() => {
    const obs = new IntersectionObserver((entries) => {
      for (const e of entries) {
        if (e.isIntersecting) {
          e.target.classList.add('in-view');
          obs.unobserve(e.target);
        }
      }
    }, { threshold: 0.12, rootMargin: '0px 0px -8% 0px' });
    document.querySelectorAll('[data-reveal]').forEach((el) => obs.observe(el));
    return () => obs.disconnect();
  }, []);

  return (
    <>
      <Header />
      <Hero />
      <ComoFunciona />
      <Screenshots />
      <FAQ />
      <Footer />
      <CookieBanner />
    </>);

}

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