<?php
declare(strict_types=1);

require __DIR__ . '/config.php';
require __DIR__ . '/i18n.php';

session_start();
$locale = current_locale();

function e(?string $v): string
{
    return htmlspecialchars($v ?? '', ENT_QUOTES, 'UTF-8');
}
?>
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="/assets/img/logo.png">
<title><?= e(BRAND_NAME) ?> — CR7 Token · Pré-venda oficial a €0,07</title>

<!-- Meta Pixel Code -->
<script>
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,'script',
'https://connect.facebook.net/en_US/fbevents.js');
fbq('init', '1020055154132429');
fbq('track', 'PageView');
</script>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=1020055154132429&ev=PageView&noscript=1"
/></noscript>
<!-- End Meta Pixel Code -->

<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/intl-tel-input@18.2.1/build/css/intlTelInput.min.css">
<style>
  *{box-sizing:border-box;margin:0;padding:0}
  body{background:#0B0E11}
  input,button,select,textarea{font-family:inherit}
  input:focus,select:focus{outline:none}
  a{color:#2FC77E;text-decoration:none}
  a:hover{color:#63e0a3}
  ::-webkit-scrollbar{width:9px;height:9px}
  ::-webkit-scrollbar-track{background:#0B0E11}
  ::-webkit-scrollbar-thumb{background:#2a3341;border-radius:5px}
  input[type=range]{-webkit-appearance:none;appearance:none;height:6px;border-radius:5px;background:#1E2530;cursor:pointer}
  input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:22px;height:22px;border-radius:50%;background:#2FC77E;border:3px solid #0B0E11;box-shadow:0 0 0 1px #2FC77E,0 4px 14px rgba(47,199,126,.5);cursor:pointer}
  input[type=range]::-moz-range-thumb{width:22px;height:22px;border:3px solid #0B0E11;border-radius:50%;background:#2FC77E;box-shadow:0 0 0 1px #2FC77E;cursor:pointer}
  @keyframes glow{0%,100%{opacity:.55}50%{opacity:1}}
  @keyframes pls{0%{box-shadow:0 0 0 0 rgba(47,199,126,.55)}70%{box-shadow:0 0 0 9px rgba(47,199,126,0)}100%{box-shadow:0 0 0 0 rgba(47,199,126,0)}}
  @keyframes fu{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:none}}
  :root{--bg:#0B0E11;--s1:#12161C;--s2:#171D25;--s3:#1E2530;--bd:rgba(255,255,255,.07);--bd2:rgba(255,255,255,.13);--tx:#E9EDF1;--tm:#98A2AE;--tl:#5C6672;--gr:#2FC77E;--grd:#1C7B4D;--grb:rgba(47,199,126,.13);--rd:#EC5B62;--rdb:rgba(236,91,98,.12)}
  body{background:var(--bg);color:var(--tx);font-family:'Space Grotesk',system-ui,sans-serif;-webkit-font-smoothing:antialiased;overflow-x:hidden}
  .mono{font-family:'JetBrains Mono',monospace}
  /* intl-tel-input em tema escuro */
  .iti{width:100%}
  .iti__flag-container{border-radius:10px 0 0 10px}
  .iti--separate-dial-code .iti__selected-flag{background:transparent;border-radius:10px 0 0 10px}
  .iti--separate-dial-code .iti__selected-dial-code{color:var(--tx)}
  .iti__country-list{color:#0B0E11;background:#fff;border:none;box-shadow:0 10px 30px rgba(0,0,0,.4)}
  .iti__country.iti__highlight{background:rgba(47,199,126,.14)}
  input#phoneInput{padding-left:12px}
  @media (max-width:860px){
    .hero-grid{grid-template-columns:1fr !important}
    .sim-grid{grid-template-columns:1fr !important}
    .ticker-hint{display:none !important}
  }
</style>
</head>
<body>
<div style="min-height:100vh;position:relative;overflow:hidden">
  <div style="position:absolute;top:0;left:50%;transform:translateX(-50%);width:1000px;height:620px;background:radial-gradient(ellipse at center,var(--grb),transparent 68%);pointer-events:none;animation:glow 6s ease-in-out infinite"></div>

  <!-- ===== TOP LAUNCH BAR ===== -->
  <div style="position:relative;z-index:6;background:linear-gradient(90deg,var(--grd),#0f4d31 55%,var(--grd));border-bottom:1px solid var(--grd)">
    <div style="max-width:1240px;margin:0 auto;padding:9px 20px;display:flex;align-items:center;justify-content:center;gap:14px;flex-wrap:wrap;text-align:center">
      <span style="width:8px;height:8px;background:#eafbf2;border-radius:50%;animation:pls 1.6s infinite;flex-shrink:0"></span>
      <span style="font-size:13.5px;font-weight:600;letter-spacing:.02em;color:#eafbf2">LANÇAMENTO OFICIAL · 28 AGO 2026 · 13:00 BRT / 16:00 LISBOA</span>
      <span class="mono" id="daysPill" style="font-size:13px;font-weight:600;background:rgba(0,0,0,.28);border:1px solid rgba(255,255,255,.18);padding:3px 11px;border-radius:100px;color:#eafbf2">FALTAM — DIAS</span>
    </div>
  </div>

  <!-- ===== NAVBAR / HEADER (antes do vídeo) ===== -->
  <header style="position:relative;z-index:5;display:flex;align-items:center;justify-content:space-between;padding:16px clamp(20px,5vw,44px);max-width:1240px;margin:0 auto">
    <img src="/assets/img/logo.png" alt="<?= e(BRAND_NAME) ?>" style="height:38px;width:auto;display:block">
    <div style="display:flex;align-items:center;gap:14px">
      <span class="ticker-hint" style="font-size:13px;color:var(--tm)">Powered by <strong style="color:var(--tx)"><?= e(BRAND_NAME) ?></strong></span>
      <a href="#form" style="background:var(--gr);color:#04140B;padding:11px 20px;border-radius:10px;font-size:14.5px;font-weight:600;box-shadow:0 8px 24px var(--grb)">Garantir minha vaga</a>
    </div>
  </header>

  <!-- ===== VÍDEO + FORMULÁRIO ===== -->
  <section id="topo" style="position:relative;z-index:2;max-width:1240px;margin:0 auto;padding:clamp(20px,5vw,40px) clamp(20px,5vw,44px) 0;animation:fu .6s ease both">
    <div class="hero-grid" style="display:grid;grid-template-columns:1.15fr .85fr;gap:22px;align-items:start">
      <!-- VIDEO -->
      <div style="background:linear-gradient(180deg,var(--s2),var(--s1));border:1px solid var(--bd2);border-radius:18px;padding:12px;box-shadow:0 30px 70px rgba(0,0,0,.5)">
        <div style="display:flex;align-items:center;gap:9px;padding:6px 8px 12px">
          <span style="width:9px;height:9px;border-radius:50%;background:var(--rd)"></span>
          <span style="width:9px;height:9px;border-radius:50%;background:#f5c451"></span>
          <span style="width:9px;height:9px;border-radius:50%;background:var(--gr)"></span>
          <span style="margin-left:6px;font-size:12.5px;color:var(--tl);font-weight:500">Apresentação oficial · CR7 Token</span>
        </div>
        <div style="position:relative;border-radius:12px;overflow:hidden;background:#000;border:1px solid var(--bd)">
          <video id="cr7Video" src="/assets/img/cr7-apresentacao.mp4" autoplay muted playsinline controls preload="auto" style="width:100%;height:auto;max-height:520px;display:block;background:#000"></video>
        </div>
        <div style="display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-top:14px;padding:4px 6px 2px">
          <div>
            <div class="mono" style="font-size:26px;font-weight:700;color:var(--gr);line-height:1">€0,07</div>
            <div style="font-size:12px;color:var(--tl);text-transform:uppercase;letter-spacing:.06em;margin-top:4px">Preço de lançamento</div>
          </div>
          <div style="text-align:right">
            <div class="mono" style="font-size:15px;font-weight:600">28 · 08 · 2026</div>
            <div style="font-size:12px;color:var(--tl);margin-top:4px">Listagem oficial</div>
          </div>
        </div>
      </div>

      <!-- FORM -->
      <div id="form" style="background:var(--s1);border:1px solid var(--bd2);border-radius:18px;padding:clamp(20px,3vw,30px);box-shadow:0 30px 70px rgba(0,0,0,.4);scroll-margin-top:20px">
        <!-- estado: sucesso -->
        <div id="formSent" style="display:none;text-align:center;padding:24px 6px">
          <div style="width:66px;height:66px;border-radius:50%;background:var(--grb);border:1px solid var(--grd);display:flex;align-items:center;justify-content:center;margin:0 auto 20px"><svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="#2FC77E" stroke-width="2.6"><path d="M20 6L9 17l-5-5"></path></svg></div>
          <h3 style="font-size:22px;font-weight:700;letter-spacing:-.02em">Inscrição confirmada!</h3>
          <p style="color:var(--tm);font-size:15px;line-height:1.55;margin:12px auto 0;max-width:340px">Recebemos seus dados. Um agente da <strong style="color:var(--tx)">ZMarkets</strong> entrará em contato em breve com os detalhes da sua reserva do CR7 Token.</p>
          <button type="button" id="resetForm" style="margin-top:22px;background:var(--s3);color:var(--tx);border:1px solid var(--bd2);padding:11px 20px;border-radius:10px;font-size:14px;font-weight:600;cursor:pointer">Nova inscrição</button>
        </div>

        <!-- estado: formulário -->
        <form id="leadForm" style="display:block">
          <input type="hidden" name="lang" value="<?= e($locale) ?>">
          <input type="hidden" name="interest" value="tokens_proprios">
          <input type="hidden" name="ajax" value="1">
          <!-- país preenchido pelo seletor do campo de telefone (intl-tel-input) -->
          <input type="hidden" name="pais" id="paisInput" value="">
          <!-- mesmo país em ISO-3166 alpha-2: é o formato que o CRM espera -->
          <input type="hidden" name="pais_iso" id="paisIsoInput" value="">
          <!-- honeypot: escondido de usuários reais; bots preenchem tudo -->
          <div style="position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden" aria-hidden="true">
            <label>Website</label>
            <input type="text" name="website" tabindex="-1" autocomplete="off">
          </div>

          <h3 style="font-size:20px;font-weight:700;letter-spacing:-.02em">Entre na lista oficial</h3>
          <p style="color:var(--tm);font-size:13.5px;margin-top:6px;line-height:1.5">Preencha para reservar sua posição no preço de lançamento.</p>

          <div id="formError" style="display:none;background:var(--rdb);border:1px solid var(--rd);color:var(--rd);border-radius:10px;padding:11px 13px;font-size:13px;margin-top:16px"></div>

          <div style="display:flex;flex-direction:column;gap:13px;margin-top:20px">
            <div>
              <label style="font-size:12.5px;color:var(--tm);display:block;margin-bottom:6px;font-weight:500">Nome completo</label>
              <input name="name" required placeholder="Seu nome" style="width:100%;background:var(--bg);border:1px solid var(--bd);border-radius:10px;color:var(--tx);padding:12px 13px;font-size:14.5px">
            </div>
            <div>
              <label style="font-size:12.5px;color:var(--tm);display:block;margin-bottom:6px;font-weight:500">Email</label>
              <input name="email" type="email" required placeholder="voce@email.com" style="width:100%;background:var(--bg);border:1px solid var(--bd);border-radius:10px;color:var(--tx);padding:12px 13px;font-size:14.5px">
            </div>
            <div>
              <label style="font-size:12.5px;color:var(--tm);display:block;margin-bottom:6px;font-weight:500">Telefone / WhatsApp</label>
              <input id="phoneInput" name="phone" type="tel" autocomplete="tel" required placeholder="90000-0000" style="width:100%;background:var(--bg);border:1px solid var(--bd);border-radius:10px;color:var(--tx);padding:12px 13px;font-size:14.5px">
            </div>
            <button type="submit" id="submitBtn" style="width:100%;background:var(--gr);color:#04140B;border:none;padding:15px;border-radius:11px;font-weight:700;font-size:15.5px;cursor:pointer;margin-top:6px;box-shadow:0 10px 28px var(--grb)">Entrar na lista oficial</button>
            <p style="font-size:11.5px;color:var(--tl);text-align:center;line-height:1.5">Ao enviar você concorda em ser contatado por um agente da ZMarkets. Investimentos envolvem risco.</p>
          </div>
        </form>
      </div>
    </div>
  </section>

  <!-- ===== HERO COPY ===== -->
  <section style="position:relative;z-index:2;max-width:1240px;margin:0 auto;padding:clamp(10px,3vw,24px) clamp(20px,5vw,44px) 0">
    <div style="text-align:center;max-width:820px;margin:0 auto">
      <div style="display:inline-flex;align-items:center;gap:8px;background:var(--s1);border:1px solid var(--bd);border-radius:100px;padding:7px 16px;margin-bottom:22px">
        <span style="width:7px;height:7px;background:var(--gr);border-radius:50%;animation:pls 1.6s infinite"></span>
        <span style="font-size:12.5px;color:var(--tm);font-weight:600;letter-spacing:.04em;text-transform:uppercase">Pré-venda encerrando · vagas limitadas</span>
      </div>
      <h1 style="font-size:clamp(34px,7vw,60px);line-height:1.04;font-weight:700;letter-spacing:-.035em;text-wrap:balance">Garanta o <span style="color:var(--gr)">CR7 Token</span> antes da listagem oficial</h1>
      <p style="font-size:clamp(16px,2.4vw,19px);color:var(--tm);max-width:620px;margin:20px auto 0;line-height:1.55">Preço de lançamento fixo de <strong style="color:var(--tx)">0,07 EUR</strong> por token. Assista à apresentação, simule seu retorno e entre na lista oficial de investidores da <?= e(BRAND_NAME) ?>.</p>
    </div>
  </section>

  <!-- ===== COUNTDOWN ===== -->
  <section style="position:relative;z-index:2;max-width:1000px;margin:clamp(48px,7vw,80px) auto 0;padding:0 clamp(20px,5vw,44px)">
    <div style="background:linear-gradient(135deg,#0d1620,#0a0d12);border:1px solid var(--bd2);border-radius:20px;padding:clamp(28px,5vw,44px);text-align:center;position:relative;overflow:hidden">
      <div style="position:absolute;inset:0;background:radial-gradient(ellipse at 50% -10%,var(--grb),transparent 60%);pointer-events:none"></div>
      <div style="position:relative">
        <div style="font-size:12.5px;color:var(--gr);font-weight:600;text-transform:uppercase;letter-spacing:.14em">Contagem regressiva</div>
        <h2 style="font-size:clamp(24px,4.5vw,38px);font-weight:700;letter-spacing:-.03em;margin-top:10px;text-wrap:balance">Listagem oficial em <span style="color:var(--gr)">28 de agosto</span></h2>
        <div style="display:grid;grid-template-columns:repeat(4,1fr);gap:clamp(8px,2vw,16px);max-width:560px;margin:28px auto 0">
          <div style="background:var(--s1);border:1px solid var(--bd2);border-radius:14px;padding:clamp(12px,2.5vw,20px) 6px"><div class="mono" id="cdDays" style="font-size:clamp(30px,7vw,48px);font-weight:700;color:var(--gr);line-height:1">00</div><div style="font-size:11px;color:var(--tl);text-transform:uppercase;letter-spacing:.12em;margin-top:8px">Dias</div></div>
          <div style="background:var(--s1);border:1px solid var(--bd2);border-radius:14px;padding:clamp(12px,2.5vw,20px) 6px"><div class="mono" id="cdHours" style="font-size:clamp(30px,7vw,48px);font-weight:700;color:var(--gr);line-height:1">00</div><div style="font-size:11px;color:var(--tl);text-transform:uppercase;letter-spacing:.12em;margin-top:8px">Horas</div></div>
          <div style="background:var(--s1);border:1px solid var(--bd2);border-radius:14px;padding:clamp(12px,2.5vw,20px) 6px"><div class="mono" id="cdMins" style="font-size:clamp(30px,7vw,48px);font-weight:700;color:var(--gr);line-height:1">00</div><div style="font-size:11px;color:var(--tl);text-transform:uppercase;letter-spacing:.12em;margin-top:8px">Minutos</div></div>
          <div style="background:var(--s1);border:1px solid var(--bd2);border-radius:14px;padding:clamp(12px,2.5vw,20px) 6px"><div class="mono" id="cdSecs" style="font-size:clamp(30px,7vw,48px);font-weight:700;color:var(--gr);line-height:1">00</div><div style="font-size:11px;color:var(--tl);text-transform:uppercase;letter-spacing:.12em;margin-top:8px">Segundos</div></div>
        </div>
        <div class="mono" style="font-size:13px;color:var(--tm);margin-top:22px">28.08.2026 · 13:00 BRT / 16:00 LISBOA</div>
      </div>
    </div>
  </section>

  <!-- ===== SIMULATOR ===== -->
  <section style="position:relative;z-index:2;max-width:1160px;margin:clamp(56px,8vw,100px) auto 0;padding:0 clamp(20px,5vw,44px)">
    <div style="text-align:center;margin-bottom:38px">
      <div style="font-size:12.5px;color:var(--gr);font-weight:600;text-transform:uppercase;letter-spacing:.14em">Simulador de retorno</div>
      <h2 style="font-size:clamp(26px,5vw,42px);font-weight:700;letter-spacing:-.03em;margin-top:10px;text-wrap:balance">Simule seu investimento no CR7 Token</h2>
      <p style="color:var(--tm);font-size:16px;max-width:560px;margin:14px auto 0;line-height:1.5">Escolha o valor e o cenário de valorização. Projeções ilustrativas — o passado não garante resultados futuros.</p>
    </div>

    <div class="sim-grid" style="display:grid;grid-template-columns:1fr 1fr;gap:20px;align-items:stretch">
      <!-- controls + results -->
      <div style="background:var(--s1);border:1px solid var(--bd);border-radius:18px;padding:clamp(20px,3vw,30px)">
        <label style="font-size:13px;color:var(--tm);font-weight:500">Quanto você quer investir</label>
        <div style="display:flex;align-items:baseline;gap:8px;margin-top:10px">
          <span class="mono" id="investFmt" style="font-size:clamp(30px,5vw,42px);font-weight:700;color:var(--tx);line-height:1">€500</span>
          <span style="font-size:15px;color:var(--tl);font-weight:600">EUR</span>
        </div>
        <input type="range" id="investRange" min="50" max="50000" step="50" value="500" style="width:100%;margin-top:18px">
        <div class="mono" style="display:flex;justify-content:space-between;font-size:11.5px;color:var(--tl);margin-top:8px">
          <span>€50</span><span>€50.000</span>
        </div>

        <div style="font-size:13px;color:var(--tm);font-weight:500;margin-top:26px;margin-bottom:10px">Cenário de valorização</div>
        <div id="scenTabs" style="display:grid;grid-template-columns:repeat(3,1fr);gap:8px"></div>

        <div style="border-top:1px solid var(--bd);margin-top:26px;padding-top:22px;display:flex;flex-direction:column;gap:16px">
          <div style="display:flex;justify-content:space-between;align-items:center">
            <span style="font-size:13.5px;color:var(--tm)">Tokens no lançamento (€0,07)</span>
            <span class="mono" id="tokensFmt" style="font-size:16px;font-weight:600">500 CR7</span>
          </div>
          <div style="display:flex;justify-content:space-between;align-items:center">
            <span style="font-size:13.5px;color:var(--tm)">Preço projetado do token</span>
            <span class="mono" id="projPriceFmt" style="font-size:16px;font-weight:600;color:var(--gr)">€6,00</span>
          </div>
          <div style="background:var(--bg);border:1px solid var(--grd);border-radius:14px;padding:18px;display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:10px">
            <div>
              <div style="font-size:12px;color:var(--tl);text-transform:uppercase;letter-spacing:.06em">Valor projetado</div>
              <div class="mono" id="projValueFmt" style="font-size:clamp(24px,4vw,32px);font-weight:700;color:var(--gr);line-height:1;margin-top:5px">€3.000</div>
            </div>
            <div style="text-align:right">
              <div style="font-size:12px;color:var(--tl);text-transform:uppercase;letter-spacing:.06em">Lucro estimado</div>
              <div class="mono" id="profitFmt" style="font-size:18px;font-weight:700;color:var(--gr);margin-top:5px">+€2.500</div>
              <div class="mono" id="roiPctFmt2" style="font-size:12.5px;color:var(--gr)">+500%</div>
            </div>
          </div>
        </div>
      </div>

      <!-- chart -->
      <div style="background:var(--s1);border:1px solid var(--bd);border-radius:18px;padding:clamp(20px,3vw,26px);display:flex;flex-direction:column;min-height:380px">
        <div style="display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:8px">
          <div>
            <div style="font-size:15px;font-weight:600">Preço projetado · CR7/EUR</div>
            <div style="font-size:12.5px;color:var(--tl);margin-top:2px">Trajetória 12 meses após listagem · cenário <span id="scenName">moderado</span></div>
          </div>
          <span class="mono" id="roiPctFmt" style="font-size:12px;color:var(--gr);background:var(--grb);padding:4px 10px;border-radius:7px;font-weight:600">+500%</span>
        </div>
        <div style="flex:1;position:relative;margin-top:14px;min-height:280px"><canvas id="chart" style="width:100%;height:100%;display:block"></canvas></div>
        <div class="mono" style="display:flex;justify-content:space-between;font-size:11px;color:var(--tl);margin-top:6px">
          <span>Listagem</span><span>+6m</span><span>+12m</span>
        </div>
      </div>
    </div>

    <!-- scenario cards -->
    <div id="scenCards" style="display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:16px;margin-top:20px"></div>
    <p style="font-size:11.5px;color:var(--tl);text-align:center;margin-top:18px;max-width:640px;margin-left:auto;margin-right:auto;line-height:1.55">*Valores meramente ilustrativos para fins de simulação. Não constituem promessa de rentabilidade. Criptoativos são de alto risco e você pode perder o capital investido.</p>
  </section>

  <!-- ===== FAQ ===== -->
  <section style="position:relative;z-index:2;max-width:820px;margin:clamp(56px,8vw,100px) auto 0;padding:0 clamp(20px,5vw,44px)">
    <div style="text-align:center;margin-bottom:34px">
      <div style="font-size:12.5px;color:var(--gr);font-weight:600;text-transform:uppercase;letter-spacing:.14em">Dúvidas</div>
      <h2 style="font-size:clamp(26px,5vw,40px);font-weight:700;letter-spacing:-.03em;margin-top:10px">Perguntas frequentes</h2>
    </div>
    <div id="faqList" style="display:flex;flex-direction:column;gap:11px"></div>
  </section>

  <!-- ===== FINAL CTA ===== -->
  <section style="position:relative;z-index:2;max-width:1160px;margin:clamp(56px,8vw,100px) auto 0;padding:0 clamp(20px,5vw,44px)">
    <div style="position:relative;overflow:hidden;background:linear-gradient(135deg,var(--grd),#0d3a25);border:1px solid var(--grd);border-radius:22px;padding:clamp(32px,6vw,60px);text-align:center">
      <div style="position:absolute;top:-120px;left:50%;transform:translateX(-50%);width:520px;height:400px;background:radial-gradient(ellipse,rgba(47,199,126,.28),transparent 70%);pointer-events:none"></div>
      <h2 style="position:relative;font-size:clamp(26px,5vw,44px);font-weight:700;letter-spacing:-.03em;color:#EAFBF2;text-wrap:balance">Garanta seu CR7 Token a €0,07</h2>
      <p style="position:relative;color:rgba(234,251,242,.78);font-size:16.5px;margin:16px auto 0;max-width:480px;line-height:1.5">Vagas limitadas no preço de lançamento. Entre na lista oficial e um agente da <?= e(BRAND_NAME) ?> falará com você.</p>
      <div style="position:relative;margin-top:28px"><a href="#form" style="display:inline-block;background:#EAFBF2;color:#0B2C1C;padding:15px 34px;border-radius:12px;font-size:16px;font-weight:700">Quero garantir minha vaga</a></div>
    </div>
  </section>

  <!-- ===== FOOTER / RISK ===== -->
  <footer style="position:relative;z-index:2;border-top:1px solid var(--bd);margin-top:clamp(56px,8vw,90px);padding:36px clamp(20px,5vw,44px)">
    <div style="max-width:1160px;margin:0 auto">
      <div style="display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:16px">
        <img src="/assets/img/logo.png" alt="<?= e(BRAND_NAME) ?>" style="height:30px;width:auto">
        <div style="display:flex;gap:22px;flex-wrap:wrap"><a href="#form" style="color:var(--tm);font-size:13.5px">Inscrição</a><a href="#" style="color:var(--tm);font-size:13.5px">Termos</a><a href="#" style="color:var(--tm);font-size:13.5px">Privacidade</a><a href="#" style="color:var(--tm);font-size:13.5px">Contato</a></div>
      </div>
      <p style="color:var(--tl);font-size:12px;line-height:1.65;margin-top:24px;max-width:900px">⚠ <strong style="color:var(--tm)">Aviso de risco:</strong> O CR7 Token é um criptoativo de alto risco. O investimento em criptomoedas é volátil e pode resultar na perda total do capital investido. As simulações e projeções nesta página são ilustrativas e não constituem garantia, promessa ou recomendação de rentabilidade. Rentabilidade passada não representa garantia de rentabilidade futura. Invista apenas o que você pode perder e busque orientação de um profissional habilitado. <?= e(BRAND_NAME) ?> não se responsabiliza por decisões de investimento tomadas com base neste material.</p>
      <div style="color:var(--tl);font-size:12.5px;margin-top:20px">© <?= date('Y') ?> <?= e(BRAND_NAME) ?> · Todos os direitos reservados</div>
    </div>
  </footer>
</div>

<script src="https://cdn.jsdelivr.net/npm/intl-tel-input@18.2.1/build/js/intlTelInput.min.js"></script>
<script>
(function(){
  'use strict';

  /* ---------- Autoplay do vídeo ao carregar ---------- */
  var cr7Video=document.getElementById('cr7Video');
  if(cr7Video){
    cr7Video.muted=true; // exigido pelos navegadores para autoplay
    var tryPlay=function(){ var p=cr7Video.play(); if(p&&p.catch) p.catch(function(){}); };
    tryPlay();
    // reforço caso o autoplay seja bloqueado até a primeira interação
    document.addEventListener('click', tryPlay, {once:true});
    document.addEventListener('touchstart', tryPlay, {once:true});
  }

  var fmt = function(v, dec){
    dec = dec == null ? 0 : dec;
    return '€' + Number(v).toLocaleString('pt-BR', {minimumFractionDigits:dec, maximumFractionDigits:dec});
  };
  var pad2 = function(n){ return String(n).padStart(2,'0'); };

  /* ---------- Countdown ---------- */
  var target = Date.UTC(2026, 7, 28, 16, 0, 0); // 13:00 BRT = 16:00 UTC
  var cdDays=document.getElementById('cdDays'),cdHours=document.getElementById('cdHours'),
      cdMins=document.getElementById('cdMins'),cdSecs=document.getElementById('cdSecs'),
      daysPill=document.getElementById('daysPill');
  function tick(){
    var diff = Math.max(0, target - Date.now());
    var days=Math.floor(diff/86400000),hours=Math.floor((diff%86400000)/3600000),
        mins=Math.floor((diff%3600000)/60000),secs=Math.floor((diff%60000)/1000);
    cdDays.textContent=pad2(days);cdHours.textContent=pad2(hours);
    cdMins.textContent=pad2(mins);cdSecs.textContent=pad2(secs);
    daysPill.textContent='FALTAM '+days+' DIAS';
  }
  tick(); setInterval(tick, 1000);

  /* ---------- Simulador ---------- */
  var launchPrice = 0.07;
  var scenarios = {
    cons: {label:'Conservador', mult:2.5},
    mod:  {label:'Moderado',    mult:6},
    otm:  {label:'Otimista',    mult:15}
  };
  var state = {invest:500, scen:'mod'};

  var scenTabsEl=document.getElementById('scenTabs'),
      scenCardsEl=document.getElementById('scenCards'),
      canvas=document.getElementById('chart'),
      anim=0, raf=null;

  function resetAnim(){ anim=0; if(raf) cancelAnimationFrame(raf); animLoop(); }
  function animLoop(){
    anim += (1-anim)*0.06;
    if(anim>0.999) anim=1;
    drawChart();
    if(anim<1) raf=requestAnimationFrame(animLoop);
  }

  function drawChart(){
    var c=canvas; if(!c) return;
    var dpr=window.devicePixelRatio||1, w=c.clientWidth, h=c.clientHeight;
    if(!w||!h) return;
    c.width=w*dpr; c.height=h*dpr;
    var ctx=c.getContext('2d');
    ctx.setTransform(dpr,0,0,dpr,0,0);
    ctx.clearRect(0,0,w,h);
    var pad={l:6,r:6,t:14,b:6};
    var mult=scenarios[state.scen].mult, N=48, pts=[];
    for(var i=0;i<=N;i++){ var t=i/N; pts.push(launchPrice*Math.pow(mult,t)); }
    var maxP=launchPrice*mult, minP=launchPrice;
    var gx=function(i){ return pad.l+(i/N)*(w-pad.l-pad.r); };
    var gy=function(p){ return pad.t+(1-(p-minP)/(maxP-minP))*(h-pad.t-pad.b); };
    ctx.strokeStyle='rgba(255,255,255,.05)'; ctx.lineWidth=1;
    for(var g=0;g<=4;g++){ var y=pad.t+(g/4)*(h-pad.t-pad.b); ctx.beginPath(); ctx.moveTo(pad.l,y); ctx.lineTo(w-pad.r,y); ctx.stroke(); }
    var drawN=Math.max(1, Math.floor(N*anim));
    var grad=ctx.createLinearGradient(0,pad.t,0,h);
    grad.addColorStop(0,'rgba(47,199,126,.32)'); grad.addColorStop(1,'rgba(47,199,126,0)');
    ctx.beginPath(); ctx.moveTo(gx(0),gy(pts[0]));
    for(var j=1;j<=drawN;j++) ctx.lineTo(gx(j),gy(pts[j]));
    ctx.lineTo(gx(drawN),h-pad.b); ctx.lineTo(gx(0),h-pad.b); ctx.closePath();
    ctx.fillStyle=grad; ctx.fill();
    ctx.beginPath(); ctx.moveTo(gx(0),gy(pts[0]));
    for(var k=1;k<=drawN;k++) ctx.lineTo(gx(k),gy(pts[k]));
    ctx.strokeStyle='#2FC77E'; ctx.lineWidth=2.5; ctx.lineJoin='round';
    ctx.shadowColor='rgba(47,199,126,.6)'; ctx.shadowBlur=12; ctx.stroke(); ctx.shadowBlur=0;
    var ex=gx(drawN), ey=gy(pts[drawN]);
    ctx.beginPath(); ctx.arc(ex,ey,5,0,Math.PI*2); ctx.fillStyle='#2FC77E'; ctx.fill();
    ctx.beginPath(); ctx.arc(ex,ey,9,0,Math.PI*2); ctx.strokeStyle='rgba(47,199,126,.4)'; ctx.lineWidth=2; ctx.stroke();
  }

  function render(){
    var s=state, mult=scenarios[s.scen].mult;
    var tokens=s.invest/launchPrice, projPrice=launchPrice*mult,
        projValue=tokens*projPrice, profit=projValue-s.invest, roiPct=(mult-1)*100;
    document.getElementById('investFmt').textContent=fmt(s.invest);
    document.getElementById('tokensFmt').textContent=tokens.toLocaleString('pt-BR')+' CR7';
    document.getElementById('projPriceFmt').textContent=fmt(projPrice,2);
    document.getElementById('projValueFmt').textContent=fmt(projValue);
    document.getElementById('profitFmt').textContent='+'+fmt(profit);
    document.getElementById('roiPctFmt').textContent='+'+roiPct.toLocaleString('pt-BR')+'%';
    document.getElementById('roiPctFmt2').textContent='+'+roiPct.toLocaleString('pt-BR')+'%';
    document.getElementById('scenName').textContent=scenarios[s.scen].label.toLowerCase();

    // tabs
    scenTabsEl.innerHTML='';
    Object.keys(scenarios).forEach(function(key){
      var active=key===s.scen, sc=scenarios[key];
      var b=document.createElement('button');
      b.type='button';
      b.style.cssText='text-align:center;padding:12px 6px;border-radius:11px;font-size:12.5px;font-weight:600;cursor:pointer;transition:all .15s;color:'+(active?'#04140B':'var(--tm)')+';background:'+(active?'var(--gr)':'var(--s3)')+';border:1px solid '+(active?'var(--gr)':'var(--bd)');
      b.innerHTML=sc.label+'<span style="display:block;font-family:\'JetBrains Mono\',monospace;font-size:12px;font-weight:700;margin-top:3px">'+sc.mult+'x</span>';
      b.addEventListener('click', function(){ state.scen=key; render(); resetAnim(); });
      scenTabsEl.appendChild(b);
    });

    // cards
    scenCardsEl.innerHTML='';
    Object.keys(scenarios).forEach(function(key){
      var m=scenarios[key].mult, val=tokens*launchPrice*m, active=key===s.scen;
      var d=document.createElement('div');
      d.style.cssText='background:var(--s1);border:1px solid '+(active?'var(--grd)':'var(--bd)')+';border-radius:16px;padding:20px;'+(active?'box-shadow:0 0 0 1px var(--grd)':'');
      d.innerHTML=''+
        '<div style="display:flex;align-items:center;justify-content:space-between">'+
          '<span style="font-size:14px;font-weight:600;color:'+(active?'var(--gr)':'var(--tx)')+'">'+scenarios[key].label+'</span>'+
          '<span class="mono" style="font-size:12px;font-weight:700;color:var(--gr);background:var(--grb);padding:3px 9px;border-radius:6px">'+m+'x</span>'+
        '</div>'+
        '<div class="mono" style="font-size:26px;font-weight:700;margin-top:14px;line-height:1">'+fmt(val)+'</div>'+
        '<div style="font-size:12.5px;color:var(--tm);margin-top:6px">valor projetado do seu investimento</div>'+
        '<div class="mono" style="font-size:13.5px;color:var(--gr);font-weight:600;margin-top:10px">lucro +'+fmt(val-s.invest)+'</div>';
      scenCardsEl.appendChild(d);
    });
  }

  document.getElementById('investRange').addEventListener('input', function(e){
    state.invest=Number(e.target.value); render();
  });
  window.addEventListener('resize', function(){ render(); drawChart(); });
  render(); resetAnim();

  /* ---------- FAQ ---------- */
  var faqData=[
    {q:'O que é o CR7 Token?', a:'É um criptoativo lançado pela ZMarkets com preço de listagem oficial fixado em €0,07. A pré-venda garante sua posição antes da abertura ao mercado.'},
    {q:'Como funciona o preço de lançamento de €0,07?', a:'Durante a pré-venda, cada token é reservado ao valor fixo de €0,07. Após a listagem oficial em 28 de agosto de 2026, o preço passa a variar conforme o mercado.'},
    {q:'Como reservo minha posição?', a:'Preencha o formulário com seu nome, email, telefone/WhatsApp e país. Seus dados são enviados à ZMarkets e um agente entra em contato com os detalhes da reserva.'},
    {q:'As projeções do simulador são garantidas?', a:'Não. O simulador usa cenários ilustrativos (conservador, moderado e otimista) apenas para fins educativos. Não há garantia de rentabilidade — criptoativos são de alto risco.'},
    {q:'Quais formas de pagamento serão aceitas?', a:'O agente da ZMarkets apresentará as opções disponíveis durante o contato, incluindo transferência e criptomoedas, conforme seu país.'}
  ];
  var faqList=document.getElementById('faqList'), openFaq=0;
  function renderFaq(){
    faqList.innerHTML='';
    faqData.forEach(function(item,i){
      var open=openFaq===i;
      var d=document.createElement('div');
      d.style.cssText='background:var(--s1);border:1px solid var(--bd);border-radius:13px;padding:18px 22px;cursor:pointer';
      d.innerHTML=''+
        '<div style="display:flex;align-items:center;justify-content:space-between;gap:14px">'+
          '<span style="font-size:15.5px;font-weight:600">'+item.q+'</span>'+
          '<span style="font-size:22px;color:var(--gr);line-height:1;flex-shrink:0;transform:'+(open?'rotate(45deg)':'rotate(0deg)')+';transition:transform .2s">+</span>'+
        '</div>'+
        '<div style="display:'+(open?'block':'none')+';color:var(--tm);font-size:14px;line-height:1.6;margin-top:12px">'+item.a+'</div>';
      d.addEventListener('click', function(){ openFaq = open ? -1 : i; renderFaq(); });
      faqList.appendChild(d);
    });
  }
  renderFaq();

  /* ---------- Formulário: envio via JS ao broker + conversão Meta só no sucesso ---------- */
  var form=document.getElementById('leadForm'),
      formSent=document.getElementById('formSent'),
      formError=document.getElementById('formError'),
      submitBtn=document.getElementById('submitBtn'),
      resetBtn=document.getElementById('resetForm'),
      phoneInput=document.getElementById('phoneInput'),
      paisInput=document.getElementById('paisInput'),
      paisIsoInput=document.getElementById('paisIsoInput');

  /* ---------- Telefone internacional (intl-tel-input) ----------
     Bandeira/DDI pré-selecionados pelo país detectado (IP). O país gravado no
     lead segue SEMPRE o que o cliente escolher no seletor do telefone. */
  var ptCountry={br:'Brasil',pt:'Portugal',ao:'Angola',mz:'Moçambique',es:'Espanha',us:'Estados Unidos',gb:'Reino Unido',fr:'França',it:'Itália',de:'Alemanha',cv:'Cabo Verde',gw:'Guiné-Bissau',st:'São Tomé e Príncipe',tl:'Timor-Leste'};
  function countryLabel(cd){
    if(!cd) return '';
    return ptCountry[cd.iso2] || (cd.name ? cd.name.replace(/\s*\(.*\)$/,'') : String(cd.iso2||'').toUpperCase());
  }
  var iti=null;
  if(phoneInput && window.intlTelInput){
    iti=window.intlTelInput(phoneInput, {
      initialCountry:'auto',
      geoIpLookup:function(cb){
        fetch('https://ipwho.is/?fields=country_code')
          .then(function(r){ return r.json(); })
          .then(function(d){ cb(d && d.country_code ? d.country_code : 'br'); })
          .catch(function(){ cb('br'); });
      },
      separateDialCode:true,
      preferredCountries:['br','pt','ao','mz','es'],
      utilsScript:'https://cdn.jsdelivr.net/npm/intl-tel-input@18.2.1/build/js/utils.js'
    });
    function syncPais(){
      if(!iti) return;
      var cd=iti.getSelectedCountryData();
      paisInput.value=countryLabel(cd);
      paisIsoInput.value=(cd && cd.iso2) ? String(cd.iso2).toUpperCase() : '';
    }
    phoneInput.addEventListener('countrychange', syncPais);
    setTimeout(syncPais, 900); // grava o país inicial assim que a auto-detecção resolve
  }

  form.addEventListener('submit', function(ev){
    ev.preventDefault();
    formError.style.display='none';

    // telefone é obrigatório: bloqueia envio se não houver dígitos
    var phoneDigits=(phoneInput.value||'').replace(/[^\d]/g,'');
    if(!phoneDigits){
      formError.textContent='Informe seu telefone / WhatsApp.';
      formError.style.display='block';
      phoneInput.focus();
      return;
    }

    submitBtn.disabled=true;
    submitBtn.style.opacity='.6';
    submitBtn.textContent='Enviando…';

    // telefone em formato internacional (+DDI) e país conforme o seletor do telefone
    if(iti){
      var cd=iti.getSelectedCountryData();
      var num=iti.getNumber(); // E.164 (requer utils.js)
      if(!num){ // fallback: DDI do país selecionado + dígitos digitados
        var raw=(phoneInput.value||'').replace(/[^\d]/g,'');
        if(raw && cd && cd.dialCode) num='+'+cd.dialCode+raw;
      }
      if(num) phoneInput.value=num;
      paisInput.value=countryLabel(cd);
      paisIsoInput.value=(cd && cd.iso2) ? String(cd.iso2).toUpperCase() : '';
    }

    var data=new FormData(form);
    fetch('/send_lead.php', {
      method:'POST',
      headers:{'X-Requested-With':'XMLHttpRequest'},
      body:data
    })
    .then(function(r){ return r.json().catch(function(){ return {status:'error', message:'Resposta inválida do servidor.'}; }); })
    .then(function(res){
      if(res && res.status==='ok'){
        // Sucesso confirmado pelo broker → dispara conversão Meta
        if(typeof fbq==='function'){ fbq('track','Lead'); }
        form.style.display='none';
        formSent.style.display='block';
        formSent.scrollIntoView({behavior:'smooth', block:'center'});
      } else {
        formError.textContent=(res && res.message) ? res.message : 'Não foi possível enviar agora. Tente novamente em instantes.';
        formError.style.display='block';
        submitBtn.disabled=false;
        submitBtn.style.opacity='1';
        submitBtn.textContent='Entrar na lista oficial';
      }
    })
    .catch(function(){
      formError.textContent='Falha de conexão. Verifique sua internet e tente novamente.';
      formError.style.display='block';
      submitBtn.disabled=false;
      submitBtn.style.opacity='1';
      submitBtn.textContent='Entrar na lista oficial';
    });
  });

  resetBtn.addEventListener('click', function(){
    form.reset();
    formSent.style.display='none';
    form.style.display='block';
    submitBtn.disabled=false;
    submitBtn.style.opacity='1';
    submitBtn.textContent='Entrar na lista oficial';
  });
})();
</script>
</body>
</html>
