/* global React, ReactDOM */
const { useState, useEffect, useMemo } = React;

/* ------------------------------------------------------------------
   Dados: lista de presentes, playlist seed, mural seed
   ------------------------------------------------------------------ */

const GIFTS_SEED = [
// Faixa 1 — Carinhos pequenos
{ id: 'g01', cat: 'Carinhos', name: 'Babadores', price: 45, icon: 'bib', tier: 'carinhos' },
{ id: 'g02', cat: 'Carinhos', name: 'Pacote de fraldas', price: 60, icon: 'diaperPack', tier: 'carinhos' },
{ id: 'g03', cat: 'Carinhos', name: 'Livrinho de pano', price: 75, icon: 'clothBook', tier: 'carinhos' },
{ id: 'g04', cat: 'Carinhos', name: 'Naninha', price: 95, icon: 'cuddle', tier: 'carinhos' },
// Faixa 2 — Dia a dia
{ id: 'g05', cat: 'Dia a dia', name: 'Kit mamadeiras', price: 150, icon: 'bottles', tier: 'diaadia' },
{ id: 'g06', cat: 'Dia a dia', name: 'Almofada de amamentação', price: 190, icon: 'pillow', tier: 'diaadia' },
{ id: 'g07', cat: 'Dia a dia', name: 'Banheira', price: 230, icon: 'tub', tier: 'diaadia' },
{ id: 'g08', cat: 'Dia a dia', name: 'Mochila maternidade', price: 290, icon: 'backpack', tier: 'diaadia' },
// Faixa 3 — Conforto
{ id: 'g09', cat: 'Conforto', name: 'Trocador', price: 390, icon: 'changingMat', tier: 'conforto' },
{ id: 'g10', cat: 'Conforto', name: 'Cadeirinha de descanso', price: 490, icon: 'bouncer', tier: 'conforto' },
{ id: 'g11', cat: 'Conforto', name: 'Babá eletrônica', price: 580, icon: 'monitor', tier: 'conforto' },
{ id: 'g12', cat: 'Conforto', name: 'Cadeirinha de alimentação', price: 680, icon: 'highChair', tier: 'conforto' },
// Faixa 4 — Itens especiais
{ id: 'g13', cat: 'Itens especiais', name: 'Bebê conforto', price: 900, icon: 'carSeat', tier: 'especiais' },
{ id: 'g14', cat: 'Itens especiais', name: 'Berço', price: 1100, icon: 'crib', tier: 'especiais' },
{ id: 'g15', cat: 'Itens especiais', name: 'Carrinho de bebê', price: 1300, icon: 'stroller', tier: 'especiais' },
{ id: 'g16', cat: 'Itens especiais', name: 'Cômoda com trocador', price: 1500, icon: 'dresser', tier: 'especiais' }];


/* ------------------------------------------------------------------
   Pix BR Code (EMV) — gera payload + QR
   ------------------------------------------------------------------ */

const PIX_KEY = '1bd18ee8-6692-4003-9fbf-3c02a3d30298';
const PIX_NAME = 'ANDRE RODRIGUES DA SILVA';
const PIX_CITY = 'FLORIANOPOLIS';

// Pix copia-e-cola (BR Code) — gera QR nativo do Pix, sem intermediário.
const PIX_CODES = {
  45: '00020101021126580014br.gov.bcb.pix01361bd18ee8-6692-4003-9fbf-3c02a3d30298520400005303986540545.005802BR5924ANDRE RODRIGUES DA SILVA6009SAO PAULO622905251KQQEVQ78ESS376BS5QZG9G5763045DEF',
  60: '00020101021126580014br.gov.bcb.pix01361bd18ee8-6692-4003-9fbf-3c02a3d30298520400005303986540560.005802BR5924ANDRE RODRIGUES DA SILVA6009SAO PAULO622905251KQQFE93SEWH0YJQZFQTBCYW263043E78',
  75: '00020101021126580014br.gov.bcb.pix01361bd18ee8-6692-4003-9fbf-3c02a3d30298520400005303986540575.005802BR5924ANDRE RODRIGUES DA SILVA6009SAO PAULO622905251KQQE8WWF08YJRS060BB1BHZX630429DA',
  95: '00020101021126580014br.gov.bcb.pix01361bd18ee8-6692-4003-9fbf-3c02a3d30298520400005303986540595.005802BR5924ANDRE RODRIGUES DA SILVA6009SAO PAULO622905251KQQE9RNPP8C3032ZK4DF0F3D630438FC',
  150: '00020101021126580014br.gov.bcb.pix01361bd18ee8-6692-4003-9fbf-3c02a3d302985204000053039865406150.005802BR5924ANDRE RODRIGUES DA SILVA6009SAO PAULO622905251KQQEB1JDR8QBTGDF4VFS2W6563049348',
  190: '00020101021126580014br.gov.bcb.pix01361bd18ee8-6692-4003-9fbf-3c02a3d302985204000053039865406190.005802BR5924ANDRE RODRIGUES DA SILVA6009SAO PAULO622905251KQQECD6JNWCCFB9GA7HHT0JV63041CD3',
  230: '00020101021126580014br.gov.bcb.pix01361bd18ee8-6692-4003-9fbf-3c02a3d302985204000053039865406230.005802BR5924ANDRE RODRIGUES DA SILVA6009SAO PAULO622905251KQQEEAPTKVH6GGNRWS767WJA6304C9D9',
  290: '00020101021126580014br.gov.bcb.pix01361bd18ee8-6692-4003-9fbf-3c02a3d302985204000053039865406290.005802BR5924ANDRE RODRIGUES DA SILVA6009SAO PAULO622905251KQQEGVN0KGG25PNV55AHKQV863049852',
  390: '00020101021126580014br.gov.bcb.pix01361bd18ee8-6692-4003-9fbf-3c02a3d302985204000053039865406390.005802BR5924ANDRE RODRIGUES DA SILVA6009SAO PAULO622905251KQQEHWH2CVXCP7TEKRBJ8GQ163048D13',
  490: '00020101021126580014br.gov.bcb.pix01361bd18ee8-6692-4003-9fbf-3c02a3d302985204000053039865406490.005802BR5924ANDRE RODRIGUES DA SILVA6009SAO PAULO622905251KQQEK3WAPZWVXDR930PEZ0GR63042FB7',
  580: '00020101021126580014br.gov.bcb.pix01361bd18ee8-6692-4003-9fbf-3c02a3d302985204000053039865406580.005802BR5924ANDRE RODRIGUES DA SILVA6009SAO PAULO622905251KQQEM089AAN8GZ3GRQ8409BJ6304D3C1',
  680: '00020101021126580014br.gov.bcb.pix01361bd18ee8-6692-4003-9fbf-3c02a3d302985204000053039865406680.005802BR5924ANDRE RODRIGUES DA SILVA6009SAO PAULO622905251KQQENJGFKT35P6J7R87A73YB63044D28',
  900: '00020101021126580014br.gov.bcb.pix01361bd18ee8-6692-4003-9fbf-3c02a3d302985204000053039865406900.005802BR5924ANDRE RODRIGUES DA SILVA6009SAO PAULO622905251KQQEQ2S9G1T1RX2ZN3YM1CCV63041D75',
  1100: '00020101021126580014br.gov.bcb.pix01361bd18ee8-6692-4003-9fbf-3c02a3d3029852040000530398654071100.005802BR5924ANDRE RODRIGUES DA SILVA6009SAO PAULO622905251KQQER0HRV3GFV13F55T7E8A16304B704',
  1300: '00020101021126580014br.gov.bcb.pix01361bd18ee8-6692-4003-9fbf-3c02a3d3029852040000530398654071300.005802BR5924ANDRE RODRIGUES DA SILVA6009SAO PAULO622905251KQQES9FPPAHFXAR8EGCNGN9P630431F3',
  1500: '00020101021126580014br.gov.bcb.pix01361bd18ee8-6692-4003-9fbf-3c02a3d3029852040000530398654071500.005802BR5924ANDRE RODRIGUES DA SILVA6009SAO PAULO622905251KQQETG08SZX2HP9JZYCY7GMK6304A668'
};

function pixField(id, value) {
  const v = String(value);
  const len = v.length.toString().padStart(2, '0');
  return id + len + v;
}

function pixCRC16(str) {
  let crc = 0xFFFF;
  for (let i = 0; i < str.length; i++) {
    crc ^= str.charCodeAt(i) << 8;
    for (let j = 0; j < 8; j++) {
      crc = crc & 0x8000 ? (crc << 1 ^ 0x1021) & 0xFFFF : crc << 1 & 0xFFFF;
    }
  }
  return crc.toString(16).toUpperCase().padStart(4, '0');
}

function buildPixPayload(amount) {
  // Merchant Account Information (ID 26) — Pix static
  const mai = pixField('00', 'br.gov.bcb.pix') + pixField('01', PIX_KEY);
  const payload =
  pixField('00', '01') + // Payload Format
  pixField('26', mai) + // Merchant Account Info
  pixField('52', '0000') + // Merchant Category
  pixField('53', '986') + // Currency BRL
  pixField('54', amount.toFixed(2)) + // Transaction amount
  pixField('58', 'BR') + // Country
  pixField('59', PIX_NAME.slice(0, 25)) + // Merchant name
  pixField('60', PIX_CITY.slice(0, 15)) + // City
  pixField('62', pixField('05', '***')); // Additional data
  const toCRC = payload + '6304';
  return toCRC + pixCRC16(toCRC);
}

/* Mural & playlist data lives in Cloudflare KV via /api/mural and /api/playlist */


/* ------------------------------------------------------------------
   Ícones SVG (linha fina, estilo editorial)
   ------------------------------------------------------------------ */

const stroke = { stroke: 'currentColor', strokeWidth: 1.4, fill: 'none', strokeLinecap: 'round', strokeLinejoin: 'round' };

const ICON_STYLE = { color: 'var(--sepia-deep)' };

const Icons = {
  // Babadores — bib com pescoço e laços
  bib:
  <svg viewBox="0 0 64 64" style={ICON_STYLE}>
      <path {...stroke} d="M22 12c-2 4 0 8 4 9M42 12c2 4 0 8-4 9" />
      <path {...stroke} d="M26 21c-10 2-16 12-16 22 0 6 4 9 10 11 4 1 8 1 12 1s8 0 12-1c6-2 10-5 10-11 0-10-6-20-16-22-2 3-10 3-12 0z" />
      <path {...stroke} d="M22 38h20" />
    </svg>,

  // Pacote de fraldas — embalagem retangular
  diaperPack:
  <svg viewBox="0 0 64 64" style={ICON_STYLE}>
      <path {...stroke} d="M12 16h40v36H12z" />
      <path {...stroke} d="M12 26h40" />
      <path {...stroke} d="M22 38c2-3 4-3 4 0M30 38c2-3 4-3 4 0M38 38c2-3 4-3 4 0" />
      <path {...stroke} d="M22 46h20" />
    </svg>,

  // Livrinho de pano — livro aberto com pontos de costura
  clothBook:
  <svg viewBox="0 0 64 64" style={ICON_STYLE}>
      <path {...stroke} d="M8 16c8-2 16-1 24 4v34c-8-5-16-6-24-4z" />
      <path {...stroke} d="M56 16c-8-2-16-1-24 4v34c8-5 16-6 24-4z" />
      <path {...stroke} strokeDasharray="2 2" d="M14 24c4-1 8 0 12 2M14 32c4-1 8 0 12 2M38 26c4-2 8-2 12-2M38 34c4-2 8-2 12-2" />
    </svg>,

  // Naninha — bichinho de pelúcia (orelhas + corpo)
  cuddle:
  <svg viewBox="0 0 64 64" style={ICON_STYLE}>
      <path {...stroke} d="M22 18c-3-6-9-6-10 0-1 4 2 8 6 8" />
      <path {...stroke} d="M42 18c3-6 9-6 10 0 1 4-2 8-6 8" />
      <circle {...stroke} cx="32" cy="32" r="14" />
      <circle {...stroke} cx="27" cy="30" r="1.2" fill="currentColor" />
      <circle {...stroke} cx="37" cy="30" r="1.2" fill="currentColor" />
      <path {...stroke} d="M28 36c1 2 3 3 4 3s3-1 4-3" />
    </svg>,

  // Kit mamadeiras — duas mamadeiras
  bottles:
  <svg viewBox="0 0 64 64" style={ICON_STYLE}>
      <path {...stroke} d="M14 8h12v4h-12z" />
      <path {...stroke} d="M13 12h14l-1 6v28c0 3-3 6-6 6s-6-3-6-6V18z" />
      <path {...stroke} d="M13 24h14" />
      <path {...stroke} d="M38 8h12v4h-12z" />
      <path {...stroke} d="M37 12h14l-1 6v28c0 3-3 6-6 6s-6-3-6-6V18z" />
      <path {...stroke} d="M37 24h14" />
    </svg>,

  // Almofada de amamentação — formato em "C"
  pillow:
  <svg viewBox="0 0 64 64" style={ICON_STYLE}>
      <path {...stroke} d="M44 16c-7-4-15-4-22 0-8 4-12 12-10 20s8 14 16 14c6 0 12-3 14-8 1-3-1-5-4-5h-8c-2 0-4-2-4-4s2-4 4-4h6c4 0 8-1 10-4 2-3 1-7-2-9z" />
    </svg>,

  // Banheira — formato oval com água
  tub:
  <svg viewBox="0 0 64 64" style={ICON_STYLE}>
      <path {...stroke} d="M8 28h48v8c0 8-8 14-24 14S8 44 8 36z" />
      <path {...stroke} d="M16 28v-8a6 6 0 0112 0" />
      <path {...stroke} d="M14 38c3 1 6-1 9 0s6 2 9 1 6-2 9-1 6 1 9 0" />
    </svg>,

  // Mochila maternidade — mochila com alça
  backpack:
  <svg viewBox="0 0 64 64" style={ICON_STYLE}>
      <path {...stroke} d="M16 22h32v32H16z" />
      <path {...stroke} d="M22 22v-4a10 10 0 0120 0v4" />
      <path {...stroke} d="M22 34h20v8H22z" />
      <circle {...stroke} cx="32" cy="38" r="1.4" fill="currentColor" />
    </svg>,

  // Trocador — almofada com bordas levantadas
  changingMat:
  <svg viewBox="0 0 64 64" style={ICON_STYLE}>
      <path {...stroke} d="M8 28c0-3 3-4 6-4h36c3 0 6 1 6 4v8c0 3-3 4-6 4H14c-3 0-6-1-6-4z" />
      <path {...stroke} d="M14 28v-6M50 28v-6" />
      <path {...stroke} d="M16 32h32" strokeDasharray="2 3" />
    </svg>,

  // Cadeirinha de descanso — bouncer
  bouncer:
  <svg viewBox="0 0 64 64" style={ICON_STYLE}>
      <path {...stroke} d="M10 42c8-22 36-22 44 0" />
      <path {...stroke} d="M14 42h36l-4 8H18z" />
      <path {...stroke} d="M22 30h20" />
    </svg>,

  // Babá eletrônica — câmera/monitor com antena
  monitor:
  <svg viewBox="0 0 64 64" style={ICON_STYLE}>
      <path {...stroke} d="M14 22h36v22H14z" />
      <circle {...stroke} cx="32" cy="33" r="6" />
      <circle {...stroke} cx="32" cy="33" r="2" fill="currentColor" />
      <path {...stroke} d="M22 14l4 8M42 14l-4 8" />
      <path {...stroke} d="M20 50h24" />
    </svg>,

  // Cadeirinha de alimentação — high chair
  highChair:
  <svg viewBox="0 0 64 64" style={ICON_STYLE}>
      <path {...stroke} d="M20 10h24v8H20z" />
      <path {...stroke} d="M20 18v14h24V18" />
      <path {...stroke} d="M22 32l-6 22M42 32l6 22" />
      <path {...stroke} d="M16 40h32" />
    </svg>,

  // Bebê conforto — car seat com alça
  carSeat:
  <svg viewBox="0 0 64 64" style={ICON_STYLE}>
      <path {...stroke} d="M12 24c0-12 40-12 40 0v18c0 6-4 8-10 8H22c-6 0-10-2-10-8z" />
      <path {...stroke} d="M16 18c8-14 32-14 32 0" />
      <path {...stroke} d="M22 32h20M32 32v14" />
    </svg>,

  // Berço — crib com grade
  crib:
  <svg viewBox="0 0 64 64" style={ICON_STYLE}>
      <path {...stroke} d="M10 18v34M54 18v34" />
      <path {...stroke} d="M10 22h44" />
      <path {...stroke} d="M10 44h44" />
      <path {...stroke} d="M18 22v22M26 22v22M34 22v22M42 22v22" />
    </svg>,

  // Carrinho de bebê — stroller
  stroller:
  <svg viewBox="0 0 64 64" style={ICON_STYLE}>
      <path {...stroke} d="M14 36c0-12 12-22 24-22l-4 22z" />
      <path {...stroke} d="M14 36h28" />
      <path {...stroke} d="M40 14l8 24" />
      <circle {...stroke} cx="20" cy="48" r="4" />
      <circle {...stroke} cx="44" cy="48" r="4" />
    </svg>,

  // Cômoda com trocador — dresser
  dresser:
  <svg viewBox="0 0 64 64" style={ICON_STYLE}>
      <path {...stroke} d="M10 16h44v36H10z" />
      <path {...stroke} d="M10 26h44M10 38h44" />
      <circle {...stroke} cx="22" cy="21" r="1" fill="currentColor" />
      <circle {...stroke} cx="42" cy="21" r="1" fill="currentColor" />
      <circle {...stroke} cx="22" cy="32" r="1" fill="currentColor" />
      <circle {...stroke} cx="42" cy="32" r="1" fill="currentColor" />
      <circle {...stroke} cx="22" cy="44" r="1" fill="currentColor" />
      <circle {...stroke} cx="42" cy="44" r="1" fill="currentColor" />
    </svg>

};

/* ------------------------------------------------------------------
   Ornamentos SVG — laço, cereja, lagosta, balão
   ------------------------------------------------------------------ */

const Bow = ({ size = 200 }) =>
<svg viewBox="0 0 240 240" width={size} height={size} aria-hidden="true" style={{ display: 'block' }}>
    <defs>
      <linearGradient id="bowMain" x1="0" y1="0" x2="0" y2="1">
        <stop offset="0%" stopColor="#cfe0ee" />
        <stop offset="50%" stopColor="#a8c4dc" />
        <stop offset="100%" stopColor="#7fa3c2" />
      </linearGradient>
      <linearGradient id="bowShade" x1="0" y1="0" x2="0" y2="1">
        <stop offset="0%" stopColor="#8eaec9" />
        <stop offset="100%" stopColor="#5d7e98" />
      </linearGradient>
      <linearGradient id="bowKnot" x1="0" y1="0" x2="0" y2="1">
        <stop offset="0%" stopColor="#7fa3c2" />
        <stop offset="50%" stopColor="#5d7e98" />
        <stop offset="100%" stopColor="#7fa3c2" />
      </linearGradient>
      <linearGradient id="bowHi" x1="0" y1="0" x2="0" y2="1">
        <stop offset="0%" stopColor="#ffffff" stopOpacity="0.55" />
        <stop offset="100%" stopColor="#ffffff" stopOpacity="0" />
      </linearGradient>
    </defs>

    {/* TAILS — long, flowing, behind everything */}
    {/* left tail */}
    <path d="M104 110
             C 96 140, 84 180, 78 220
             L 104 232
             C 110 200, 118 160, 124 122 Z"


  fill="url(#bowMain)" />
    <path d="M104 232 L78 220 L82 218 L 100 226 Z" fill="url(#bowShade)" opacity="0.6" />
    {/* right tail */}
    <path d="M136 110
             C 144 140, 156 180, 162 220
             L 136 232
             C 130 200, 122 160, 116 122 Z"


  fill="url(#bowShade)" opacity="0.92" />
    <path d="M136 232 L162 220 L158 218 L 140 226 Z" fill="#5d7e98" opacity="0.7" />

    {/* LEFT LOOP — taller, fuller */}
    <path d="M120 88
             C 90 32, 24 30, 14 80
             C 6 122, 70 122, 120 100 Z"

  fill="url(#bowMain)" />
    {/* left loop under-fold */}
    <path d="M120 88
             C 96 80, 64 84, 40 96
             C 60 110, 96 112, 120 100 Z"

  fill="url(#bowShade)" opacity="0.55" />
    {/* left loop highlight */}
    <path d="M30 60 C 60 48, 96 56, 116 80" stroke="url(#bowHi)" strokeWidth="2.5" fill="none" />

    {/* RIGHT LOOP — taller, fuller */}
    <path d="M120 88
             C 150 32, 216 30, 226 80
             C 234 122, 170 122, 120 100 Z"

  fill="url(#bowMain)" />
    <path d="M120 88
             C 144 80, 176 84, 200 96
             C 180 110, 144 112, 120 100 Z"

  fill="url(#bowShade)" opacity="0.55" />
    <path d="M210 60 C 180 48, 144 56, 124 80" stroke="url(#bowHi)" strokeWidth="2.5" fill="none" />

    {/* KNOT — wider, more substantial */}
    <path d="M98 78
             C 102 70, 138 70, 142 78
             L 144 116
             C 140 124, 100 124, 96 116 Z"


  fill="url(#bowKnot)" />
    {/* knot horizontal creases */}
    <path d="M100 86 L140 86 M100 108 L140 108" stroke="#3f5e78" strokeWidth="0.9" opacity="0.45" />
    {/* knot top highlight */}
    <path d="M104 76 C 116 73, 124 73, 136 76" stroke="#ffffff" strokeWidth="1.2" opacity="0.4" fill="none" />
    {/* knot side seams */}
    <path d="M98 78 L 96 116 M142 78 L 144 116" stroke="#3f5e78" strokeWidth="0.6" opacity="0.4" fill="none" />
  </svg>;


const Cherry = ({ size = 140 }) =>
<svg viewBox="0 0 140 180" width={size} height={size * 1.28} aria-hidden="true">
    <defs>
      <radialGradient id="chFill1" cx="32%" cy="30%">
        <stop offset="0%" stopColor="#f08294" />
        <stop offset="35%" stopColor="#d63a52" />
        <stop offset="80%" stopColor="#a01e32" />
        <stop offset="100%" stopColor="#6e1220" />
      </radialGradient>
      <radialGradient id="chFill2" cx="32%" cy="30%">
        <stop offset="0%" stopColor="#e8627a" />
        <stop offset="40%" stopColor="#bc2a40" />
        <stop offset="100%" stopColor="#6e1220" />
      </radialGradient>
      <linearGradient id="chBow" x1="0" y1="0" x2="0" y2="1">
        <stop offset="0%" stopColor="#b3c8df" />
        <stop offset="100%" stopColor="#7d9bbb" />
      </linearGradient>
    </defs>
    {/* tiny bow at top */}
    <g transform="translate(70 14)">
      <path d="M0 4 C -10 -4, -18 -2, -16 6 C -18 14, -10 16, 0 8 Z" fill="url(#chBow)" />
      <path d="M0 4 C 10 -4, 18 -2, 16 6 C 18 14, 10 16, 0 8 Z" fill="url(#chBow)" />
      <ellipse cx="0" cy="6" rx="3" ry="3.5" fill="#5e7895" />
      <path d="M-4 9 L -10 22 L -4 18 Z" fill="url(#chBow)" opacity="0.85" />
      <path d="M4 9 L 10 22 L 4 18 Z" fill="url(#chBow)" opacity="0.85" />
    </g>
    {/* stems converging from bow */}
    <path d="M70 22 C 60 40, 48 60, 42 92" stroke="#6b5a3c" strokeWidth="2.4" fill="none" strokeLinecap="round" />
    <path d="M70 22 C 80 40, 92 62, 100 102" stroke="#6b5a3c" strokeWidth="2.4" fill="none" strokeLinecap="round" />
    {/* leaf */}
    <path d="M72 26 C 92 18, 112 24, 116 38 C 104 46, 84 42, 72 26 Z" fill="#8a9d6e" />
    <path d="M74 28 C 90 26, 104 32, 112 38" stroke="#5d6e48" strokeWidth="0.8" fill="none" />
    {/* cherries */}
    <circle cx="42" cy="118" r="26" fill="url(#chFill1)" />
    <ellipse cx="33" cy="110" rx="8" ry="5" fill="#ffb0bd" opacity="0.65" />
    <circle cx="100" cy="128" r="26" fill="url(#chFill2)" />
    <ellipse cx="91" cy="120" rx="8" ry="5" fill="#ff9aac" opacity="0.6" />
    {/* tiny dimple at stem joint */}
    <ellipse cx="42" cy="94" rx="3" ry="2" fill="#6e1220" opacity="0.4" />
    <ellipse cx="100" cy="104" rx="3" ry="2" fill="#6e1220" opacity="0.4" />
  </svg>;


const Lobster = ({ size = 200 }) =>
<svg viewBox="0 0 180 280" width={size} height={size * 1.55} aria-hidden="true">
    <defs>
      <linearGradient id="lobFill" x1="0" y1="0" x2="0" y2="1">
        <stop offset="0%" stopColor="#e25062" />
        <stop offset="50%" stopColor="#c93346" />
        <stop offset="100%" stopColor="#8e1a2c" />
      </linearGradient>
      <linearGradient id="lobShade" x1="0" y1="0" x2="1" y2="0">
        <stop offset="0%" stopColor="#a82236" stopOpacity="0.55" />
        <stop offset="50%" stopColor="#a82236" stopOpacity="0" />
        <stop offset="100%" stopColor="#a82236" stopOpacity="0.55" />
      </linearGradient>
    </defs>

    {/* antennae — long, curving outward */}
    <path d="M80 28 C 50 10, 28 4, 12 8" stroke="#8e1a2c" strokeWidth="1.6" fill="none" strokeLinecap="round" />
    <path d="M85 26 C 65 6, 42 -2, 22 -4" stroke="#8e1a2c" strokeWidth="1.4" fill="none" strokeLinecap="round" />
    <path d="M100 28 C 130 10, 152 4, 168 8" stroke="#8e1a2c" strokeWidth="1.6" fill="none" strokeLinecap="round" />
    <path d="M95 26 C 115 6, 138 -2, 158 -4" stroke="#8e1a2c" strokeWidth="1.4" fill="none" strokeLinecap="round" />

    {/* head/rostrum */}
    <path d="M90 18 L 86 30 L 94 30 Z" fill="url(#lobFill)" />
    <ellipse cx="90" cy="42" rx="20" ry="16" fill="url(#lobFill)" />
    <circle cx="82" cy="38" r="2.4" fill="#2b0a10" />
    <circle cx="98" cy="38" r="2.4" fill="#2b0a10" />
    <circle cx="82.5" cy="37.5" r="0.8" fill="#fff" opacity="0.7" />
    <circle cx="98.5" cy="37.5" r="0.8" fill="#fff" opacity="0.7" />

    {/* claws — large, up by the head */}
    <g>
      {/* left claw arm */}
      <path d="M74 50 C 56 56, 40 66, 28 80" stroke="#a82236" strokeWidth="9" fill="none" strokeLinecap="round" />
      {/* left claw pincer */}
      <path d="M16 78 C 8 70, 6 88, 14 92 C 20 96, 32 92, 36 86 C 30 78, 22 74, 16 78 Z" fill="url(#lobFill)" />
      <path d="M14 84 C 6 88, 8 100, 18 100 C 26 100, 34 94, 34 88" stroke="#8e1a2c" strokeWidth="1" fill="none" opacity="0.5" />
      <path d="M16 78 L 32 86" stroke="#6e1220" strokeWidth="0.8" fill="none" opacity="0.6" />

      {/* right claw arm */}
      <path d="M106 50 C 124 56, 140 66, 152 80" stroke="#a82236" strokeWidth="9" fill="none" strokeLinecap="round" />
      <path d="M164 78 C 172 70, 174 88, 166 92 C 160 96, 148 92, 144 86 C 150 78, 158 74, 164 78 Z" fill="url(#lobFill)" />
      <path d="M166 84 C 174 88, 172 100, 162 100 C 154 100, 146 94, 146 88" stroke="#8e1a2c" strokeWidth="1" fill="none" opacity="0.5" />
      <path d="M164 78 L 148 86" stroke="#6e1220" strokeWidth="0.8" fill="none" opacity="0.6" />
    </g>

    {/* thorax - segmented */}
    <ellipse cx="90" cy="78" rx="22" ry="20" fill="url(#lobFill)" />
    <path d="M70 76 Q 90 70, 110 76" stroke="#6e1220" strokeWidth="0.8" fill="none" opacity="0.6" />

    {/* abdomen segments — vertical, tapering down */}
    <ellipse cx="90" cy="108" rx="24" ry="14" fill="url(#lobFill)" />
    <ellipse cx="90" cy="130" rx="22" ry="12" fill="url(#lobFill)" />
    <ellipse cx="90" cy="150" rx="20" ry="11" fill="url(#lobFill)" />
    <ellipse cx="90" cy="168" rx="18" ry="10" fill="url(#lobFill)" />
    <ellipse cx="90" cy="184" rx="16" ry="9" fill="url(#lobFill)" />
    <ellipse cx="90" cy="198" rx="13" ry="8" fill="url(#lobFill)" />

    {/* segment shading lines */}
    <path d="M70 108 Q 90 102, 110 108" stroke="#6e1220" strokeWidth="0.7" fill="none" opacity="0.5" />
    <path d="M71 130 Q 90 125, 109 130" stroke="#6e1220" strokeWidth="0.7" fill="none" opacity="0.5" />
    <path d="M73 150 Q 90 146, 107 150" stroke="#6e1220" strokeWidth="0.7" fill="none" opacity="0.5" />
    <path d="M74 168 Q 90 165, 106 168" stroke="#6e1220" strokeWidth="0.7" fill="none" opacity="0.5" />
    <path d="M76 184 Q 90 181, 104 184" stroke="#6e1220" strokeWidth="0.7" fill="none" opacity="0.5" />

    {/* legs (small, on sides) */}
    <path d="M74 98 L 60 116 M76 116 L 58 134 M78 132 L 62 150 M80 148 L 66 168" stroke="#8e1a2c" strokeWidth="1.6" fill="none" strokeLinecap="round" />
    <path d="M106 98 L 120 116 M104 116 L 122 134 M102 132 L 118 150 M100 148 L 114 168" stroke="#8e1a2c" strokeWidth="1.6" fill="none" strokeLinecap="round" />

    {/* tail fan — splayed at bottom */}
    <g>
      <path d="M90 206 L 70 248 Q 78 256, 88 252 Z" fill="url(#lobFill)" />
      <path d="M90 206 L 110 248 Q 102 256, 92 252 Z" fill="url(#lobFill)" />
      <path d="M90 208 L 78 254 Q 90 260, 90 256 Z" fill="url(#lobFill)" />
      <path d="M90 208 L 102 254 Q 90 260, 90 256 Z" fill="url(#lobFill)" />
      {/* fan veins */}
      <path d="M82 220 L 76 246 M90 220 L 90 254 M98 220 L 104 246" stroke="#6e1220" strokeWidth="0.7" fill="none" opacity="0.5" />
    </g>

    {/* center highlight on body */}
    <ellipse cx="86" cy="74" rx="6" ry="3" fill="#ff9aa6" opacity="0.45" />
    <ellipse cx="86" cy="106" rx="7" ry="3" fill="#ff9aa6" opacity="0.35" />
  </svg>;


const Balloon = ({ size = 100, color = '#a8c4dc' }) =>
<svg viewBox="0 0 80 140" width={size * 0.57} height={size} aria-hidden="true">
    <defs>
      <radialGradient id={`bal-${color.slice(1)}`} cx="35%" cy="30%">
        <stop offset="0%" stopColor="#ffffff" stopOpacity="0.9" />
        <stop offset="40%" stopColor={color} stopOpacity="0.7" />
        <stop offset="100%" stopColor={color} stopOpacity="0.95" />
      </radialGradient>
    </defs>
    <ellipse cx="40" cy="46" rx="32" ry="40" fill={`url(#bal-${color.slice(1)})`} />
    <path d="M36 86 L40 92 L44 86 Z" fill={color} opacity="0.85" />
    <path d="M40 92 Q 38 110, 42 130" stroke="#2b2017" strokeWidth="1" fill="none" />
    {/* tiny bow */}
    <path d="M36 96 L32 92 L34 100 L30 104 M44 96 L48 92 L46 100 L50 104" stroke="#2b2017" strokeWidth="1" fill="none" />
  </svg>;


/* ------------------------------------------------------------------
   Top bar
   ------------------------------------------------------------------ */

function Topbar() {
  return (
    <header className="topbar">
      <div className="mark">
        <span className="dot" />
        <span>Allegra · 2026</span>
      </div>
      <nav>
        <a href="#local">Local</a>
        <a href="#recado">Recado</a>
        <a href="#presentes">Presentes</a>
        <a href="#playlist">Playlist</a>
        <a href="#mural">Mural</a>
        <a href="https://partiful.com/e/rUR8sgaZmJie5PBXvnJX" target="_blank" rel="noopener noreferrer" className="rsvp">Confirmar →</a>
      </nav>
    </header>);

}

/* ------------------------------------------------------------------
   Hero
   ------------------------------------------------------------------ */

function Hero() {
  const items = ['Chá da Allegra', '◆', '09 de Maio', '◆', 'Sábado, 12h', '◆', 'Rua Almirante Lamego, 910', '◆', 'Thais & André', '◆'];
  const ticker = [...items, ...items, ...items];
  return (
    <section className="hero hero-clean">
      <div className="wrap">
        <div className="eyebrow" style={{ marginBottom: 32, textAlign: 'center' }}>Um convite para celebrar</div>
        <h1 className="hero-title hero-title-center">
          Alle<span className="amp">g</span>ra
        </h1>
        <div className="hero-meta hero-meta-center">
          <div className="hero-meta-row"><span>Chá de bebê</span><b>09 · Maio · 2026</b></div>
          <div className="hero-meta-row"><span>Quando</span><b>Sábado, 12h</b></div>
          <div className="hero-meta-row"><span>Onde</span><b>R. Almirante Lamego, 910</b></div>
          <div className="hero-meta-row"><span>Anfitriões</span><b>Thais &amp; André</b></div>
        </div>
      </div>
      <div className="hero-ticker" style={{ marginTop: 96 }}>
        <div className="hero-ticker-inner">
          {ticker.map((t, i) =>
          <span key={i} className={t === '◆' ? 'diamond' : ''}>{t}</span>
          )}
        </div>
      </div>
    </section>);

}

/* ------------------------------------------------------------------
   HQ + Pull-quote
   ------------------------------------------------------------------ */

function HQSection() {
  return (
    <section className="hq-panel paper-tex" id="historia">
      <div className="wrap">
        <div className="hq-grid">
          <div className="hq-image">
            <img src="photos/hq.jpg" alt="HQ — O melhor presente dos meus 40" />
            <div className="hq-caption">Arquivo pessoal · 2026</div>
          </div>
          <div>
            <div className="eyebrow" style={{ marginBottom: 18 }}>Capítulo 01 · A história</div>
            <p className="hq-pullquote">
              “O <b>melhor presente</b> dos meus <b>40</b>.” — Allegra está chegando pertinho do aniversário do André.
              Um chá de bebê que também é comemoração de vida. Dois motivos, uma festa só.
            </p>
            <div style={{ marginTop: 32, display: 'flex', gap: 24, flexWrap: 'wrap' }}>
              <div>
                <div className="eyebrow">Data</div>
                <div style={{ fontFamily: 'var(--serif)', fontSize: 24, fontStyle: 'italic', marginTop: 4 }}>09 de Maio</div>
              </div>
              <div>
                <div className="eyebrow">Motivo</div>
                <div style={{ fontFamily: 'var(--serif)', fontSize: 24, fontStyle: 'italic', marginTop: 4 }}>Allegra + 40 do André</div>
              </div>
              <div>
                <div className="eyebrow">Dress code</div>
                <div style={{ fontFamily: 'var(--serif)', fontSize: 24, fontStyle: 'italic', marginTop: 4 }}>o que deixar feliz</div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>);

}

/* ------------------------------------------------------------------
   Recado dos pais + galeria
   ------------------------------------------------------------------ */

function Recado() {
  return (
    <section id="recado">
      <div className="wrap">
        <div className="section-head">
          <div>
            <div className="num">02 · Recado</div>
            <h2>Oi,<br />gente querida.</h2>
          </div>
          <p className="lede">


          </p>
        </div>
        <div className="recado">
          <div className="recado-text">
            <p>
              A Allegra começou com um encontro em 2009. Virou ultrassom, virou chute no meio da madrugada, virou enxoval. Hoje é chá de bebê marcado pro <b>dia 09 de maio</b> — que também é aniversário do André.
            </p>
            <p>
              A gente não quer nada demais. Quer que você venha, que coma, que ria, que conte alguma história antiga. Se
              sobrar tempo, deixa um recado pra ela ler quando crescer. E se quiser presentear, tem uma lista aqui em baixo.
            </p>
            <p>
              Se tiver que escolher uma coisa pra trazer, traz você. O resto a gente resolve.
            </p>
            <div className="recado-sign">— Thais &amp; André</div>
          </div>
          <div className="gallery">
            <div className="cell"><img src="photos/11.jpg" alt="" /></div>
            <div className="cell"><img src="photos/10.jpg" alt="" /></div>
            <div className="cell"><img src="photos/05.jpg" alt="" /></div>
            <div className="cell"><img src="photos/09.jpg" alt="" /></div>
          </div>
        </div>
      </div>
    </section>);

}

/* ------------------------------------------------------------------
   Lista de presentes
   ------------------------------------------------------------------ */

function GiftModal({ gift, onClose }) {
  const code = PIX_CODES[gift.price] || '';
  const fallbackPayload = useMemo(() => buildPixPayload(gift.price), [gift.price]);
  const payload = code || fallbackPayload;
  const qrUrl = `https://api.qrserver.com/v1/create-qr-code/?size=320x320&margin=0&data=${encodeURIComponent(payload)}`;
  const [copied, setCopied] = useState(false);
  const copy = () => {
    navigator.clipboard?.writeText(payload);
    setCopied(true);
    setTimeout(() => setCopied(false), 2000);
  };
  return (
    <div className="modal-backdrop" onClick={onClose}>
      <div className="modal" onClick={(e) => e.stopPropagation()}>
        <button className="close" onClick={onClose}>×</button>
        <div className="sub">{gift.cat} · Pix de R$ {gift.price}</div>
        <h3>{gift.name}</h3>
        <p style={{ color: 'var(--ink-soft)', marginBottom: 20, fontSize: 15 }}>
          Aponte a câmera do banco no QR code abaixo — <b>R$ {gift.price}</b> já vai preenchido.
        </p>
        <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 14, padding: 20, background: 'var(--cream)', border: '1px solid var(--rule)' }}>
          <img src={qrUrl} alt={`QR Pix R$ ${gift.price}`} width="220" height="220" style={{ display: 'block', background: 'white', padding: 10 }} />
          <div style={{ fontFamily: 'var(--mono)', fontSize: 11, letterSpacing: '.12em', textTransform: 'uppercase', color: 'var(--sepia-deep)', textAlign: 'center' }}>
            ou copia-e-cola
          </div>
          <div style={{ display: 'flex', gap: 8, width: '100%' }}>
            <code style={{ flex: 1, background: 'var(--paper)', border: '1px solid var(--rule)', padding: '10px 12px', fontFamily: 'var(--mono)', fontSize: 11, color: 'var(--ink)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{payload}</code>
            <button onClick={copy} style={{ background: 'var(--ink)', color: 'var(--paper)', border: 0, padding: '10px 14px', fontFamily: 'var(--mono)', fontSize: 11, letterSpacing: '.12em', textTransform: 'uppercase', cursor: 'pointer' }}>{copied ? 'copiado' : 'copiar'}</button>
          </div>
        </div>
        <p style={{ color: 'var(--ink-soft)', marginTop: 16, fontSize: 13, fontStyle: 'italic' }}>
          Obrigada 💛 — Thais &amp; André
        </p>
      </div>
    </div>);

}

function PixKeyCopy() {
  const [copied, setCopied] = useState(false);
  const copy = () => {
    navigator.clipboard?.writeText(PIX_KEY);
    setCopied(true);
    setTimeout(() => setCopied(false), 2000);
  };
  return (
    <div className="pix-key-row">
      <span className="eyebrow">chave pix · {PIX_KEY}</span>
      <button className="pix-key-copy" onClick={copy}>{copied ? 'copiado' : 'copiar'}</button>
    </div>);

}

function GiftsSection() {
  const [filter, setFilter] = useState('todas');
  const [open, setOpen] = useState(null);

  const filters = [
  { k: 'todas', label: 'Todas' },
  { k: 'carinhos', label: 'Carinhos' },
  { k: 'diaadia', label: 'Dia a dia' },
  { k: 'conforto', label: 'Conforto' },
  { k: 'especiais', label: 'Itens especiais' }];


  const visible = useMemo(() => {
    if (filter === 'todas') return GIFTS_SEED;
    return GIFTS_SEED.filter((g) => g.tier === filter);
  }, [filter]);

  return (
    <section id="presentes">
      <div className="wrap">
        <div className="section-head">
          <div>
            <div className="num">03 · Lista</div>
            <h2>Lista de<br />presentes.</h2>
          </div>
          <p className="lede">
            Separamos uma listinha em quatro faixas, do mais simbólico ao mais estrutural. Pode escolher pelo
            que tem a ver com você — e se não quiser presente, traz só sua presença, que já é muita coisa.
          </p>
        </div>

        <div className="gifts-head">
          <div className="gifts-filter">
            {filters.map((f) =>
            <button key={f.k}
            className={filter === f.k ? 'active' : ''}
            onClick={() => setFilter(f.k)}>{f.label}</button>
            )}
          </div>
          <PixKeyCopy />
        </div>

        <div className="gifts-grid">
          {visible.map((g) =>
          <div key={g.id} className="gift-card">
              <div className="gift-thumb">{Icons[g.icon]}</div>
              <div className="gift-body">
                <div className="gift-cat">{g.cat}</div>
                <div className="gift-name">{g.name}</div>
                <div className="gift-price">
                  <span className="price">R$ {g.price}</span>
                  <button className="btn" onClick={() => setOpen(g)}>presentear</button>
                </div>
              </div>
            </div>
          )}
        </div>
      </div>
      {open && <GiftModal gift={open} onClose={() => setOpen(null)} />}
    </section>);

}

/* ------------------------------------------------------------------
   Playlist
   ------------------------------------------------------------------ */

function Playlist() {
  const [tracks, setTracks] = useState([]);
  const [loading, setLoading] = useState(true);
  const [t, setT] = useState('');
  const [a, setA] = useState('');
  const [by, setBy] = useState('');
  const [submitting, setSubmitting] = useState(false);

  useEffect(() => {
    fetch('/api/playlist')
      .then((r) => r.ok ? r.json() : [])
      .then((data) => setTracks(Array.isArray(data) ? data : []))
      .catch(() => {})
      .finally(() => setLoading(false));
  }, []);

  const add = async () => {
    if (!t.trim() || !a.trim() || submitting) return;
    setSubmitting(true);
    try {
      const res = await fetch('/api/playlist', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ t: t.trim(), a: a.trim(), by: by.trim() })
      });
      if (!res.ok) throw new Error('post failed');
      const created = await res.json();
      setTracks((prev) => [...prev, created]);
      setT(''); setA(''); setBy('');
    } catch {
      alert('Não consegui salvar agora. Tenta de novo daqui a pouco?');
    } finally {
      setSubmitting(false);
    }
  };

  return (
    <section className="playlist-section paper-tex" id="playlist">
      <div className="wrap">
        <div className="section-head">
          <div>
            <div className="num">04 · Playlist</div>
            <h2>A trilha<br />da chegada.</h2>
          </div>
          <p className="lede">
            Uma playlist aberta pra você sugerir uma música pra Allegra ouvir. Pode ser a que embalou sua infância, a
            que ficou marcada, a que você canta no chuveiro. A gente toca no dia.
          </p>
        </div>
        <div className="playlist-wrap">
          <div className="playlist-cover">
            <div className="title">
              <div className="sub">Side A · 2026</div>
              <h3>Pra<br />Allegra<br />ouvir.</h3>
            </div>
          </div>
          <div>
            <div className="track-list">
              {loading && tracks.length === 0 &&
                <div style={{ padding: '14px 0', fontFamily: 'var(--mono)', fontSize: 11, letterSpacing: '0.12em', textTransform: 'uppercase', color: 'var(--sepia-deep)' }}>carregando…</div>
              }
              {!loading && tracks.length === 0 &&
                <div style={{ padding: '14px 0', fontFamily: 'var(--mono)', fontSize: 11, letterSpacing: '0.12em', textTransform: 'uppercase', color: 'var(--sepia-deep)' }}>seja o primeiro a sugerir uma música ↓</div>
              }
              {tracks.map((tr, i) =>
              <div className="track" key={tr.id}>
                  <div className="n">{String(i + 1).padStart(2, '0')}</div>
                  <div className="info">
                    <div className="t">{tr.t}</div>
                    <div className="a">{tr.a}</div>
                  </div>
                  <div className="by">sug. por {tr.by}</div>
                </div>
              )}
            </div>
            <div className="track-add">
              <input placeholder="Nome da música" value={t} onChange={(e) => setT(e.target.value)} />
              <input placeholder="Artista" value={a} onChange={(e) => setA(e.target.value)} />
              <button onClick={add} disabled={submitting}>{submitting ? '...' : 'Sugerir'}</button>
              <div className="track-byline">
                <input placeholder="seu nome (opcional)" value={by} onChange={(e) => setBy(e.target.value)} />
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>);

}

/* ------------------------------------------------------------------
   Mural de recados
   ------------------------------------------------------------------ */

function Mural() {
  const [msgs, setMsgs] = useState([]);
  const [loading, setLoading] = useState(true);
  const [msg, setMsg] = useState('');
  const [by, setBy] = useState('');
  const [submitting, setSubmitting] = useState(false);

  useEffect(() => {
    fetch('/api/mural')
      .then((r) => r.ok ? r.json() : [])
      .then((data) => setMsgs(Array.isArray(data) ? data : []))
      .catch(() => {})
      .finally(() => setLoading(false));
  }, []);

  const add = async () => {
    if (!msg.trim() || !by.trim() || submitting) return;
    setSubmitting(true);
    try {
      const res = await fetch('/api/mural', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ msg: msg.trim(), by: by.trim() })
      });
      if (!res.ok) throw new Error('post failed');
      const created = await res.json();
      setMsgs((prev) => [created, ...prev]);
      setMsg(''); setBy('');
    } catch {
      alert('Não consegui salvar agora. Tenta de novo daqui a pouco?');
    } finally {
      setSubmitting(false);
    }
  };

  return (
    <section id="mural">
      <div className="wrap">
        <div className="section-head">
          <div>
            <div className="num">06 · MURAL</div>
            <h2>Deixe um<br />recado.</h2>
          </div>
          <p className="lede">
            Vamos guardar todos os recados num caderno que a Allegra vai receber no dia que souber ler. Pode ser
            conselho, história, bobagem, qualquer coisa. A gente imprime tudo.
          </p>
        </div>

        <div className="mural">
          <div className="mural-form">
            <div className="label">Seu recado</div>
            <textarea placeholder="Escreva para a Allegra…" value={msg} onChange={(e) => setMsg(e.target.value)} />
            <div className="label" style={{ marginTop: 4 }}>Assinado</div>
            <input placeholder="seu nome" value={by} onChange={(e) => setBy(e.target.value)} />
            <button onClick={add} disabled={submitting}>{submitting ? '...' : 'Deixar recado'}</button>
          </div>
          {loading && msgs.length === 0 &&
            <div style={{ padding: 24, fontFamily: 'var(--mono)', fontSize: 11, letterSpacing: '0.12em', textTransform: 'uppercase', color: 'var(--sepia-deep)' }}>carregando recados…</div>
          }
          {!loading && msgs.length === 0 &&
            <div style={{ padding: 24, fontFamily: 'var(--mono)', fontSize: 11, letterSpacing: '0.12em', textTransform: 'uppercase', color: 'var(--sepia-deep)' }}>nenhum recado ainda — deixe o primeiro ←</div>
          }
          {msgs.map((m) =>
          <div key={m.id} className="mural-card">
              <div className="msg">“{m.msg}”</div>
              <div className="by">
                <span>— {m.by}</span>
                <span>♥</span>
              </div>
            </div>
          )}
        </div>
      </div>
    </section>);

}

/* ------------------------------------------------------------------
   Local — destaque do endereço + dica de Uber
   ------------------------------------------------------------------ */

function Local() {
  const address = 'Rua Almirante Lamego, 910';
  const region = 'Salão de festas · Florianópolis';
  const mapsQuery = encodeURIComponent('Rua Almirante Lamego, 910, Florianópolis');
  const mapsLink = `https://www.google.com/maps/search/?api=1&query=${mapsQuery}`;
  const uberLink = `https://m.uber.com/ul/?action=setPickup&pickup=my_location&dropoff[formatted_address]=${mapsQuery}`;
  const embedSrc = `https://maps.google.com/maps?q=${mapsQuery}&z=16&output=embed`;

  return (
    <section id="local" style={{ borderTop: '1px solid var(--rule)', borderBottom: '1px solid var(--rule)', background: 'var(--cream)' }}>
      <div className="wrap">
        <div className="section-head">
          <div>
            <div className="num">05 · LOCAL</div>
            <h2>Onde a<br />festa rola.</h2>
          </div>
          <p className="lede">
            A festa vai ser num salão de festas no centro. <b>A região é meio sofrida pra estacionar</b> — se puder, vem de Uber/táxi
            que a gente agradece (e você chega de bom humor).
          </p>
        </div>

        <div style={{
          display: 'grid',
          gridTemplateColumns: '1fr 1fr',
          gap: 28,
          alignItems: 'stretch'
        }} className="local-grid">
          {/* Address card */}
          <div style={{
            background: 'var(--paper)',
            border: '1px solid var(--rule)',
            padding: '36px 36px 32px',
            display: 'flex',
            flexDirection: 'column',
            gap: 16,
            position: 'relative'
          }}>
            <div className="eyebrow">Endereço</div>
            <h3 style={{
              fontFamily: 'var(--serif)',
              fontStyle: 'italic',
              fontSize: 'clamp(34px, 4.4vw, 54px)',
              lineHeight: 1.05,
              letterSpacing: '-0.02em',
              color: 'var(--ink)'
            }}>
              {address}
            </h3>
            <div style={{ fontFamily: 'var(--mono)', fontSize: 12, letterSpacing: '0.15em', textTransform: 'uppercase', color: 'var(--sepia-deep)' }}>
              {region}
            </div>

            <div style={{
              marginTop: 8,
              padding: '14px 16px',
              background: 'var(--cream)',
              border: '1px dashed var(--sepia)',
              fontSize: 14,
              color: 'var(--ink-soft)',
              lineHeight: 1.5
            }}>
              <b style={{ color: 'var(--ink)' }}>Dica:</b> estacionar por ali é um perrengue.
              Vem de Uber, 99 ou táxi se rolar — descer na porta é mil vezes mais leve.
            </div>

            <div style={{ display: 'flex', gap: 10, flexWrap: 'wrap', marginTop: 'auto', paddingTop: 12 }}>
              <a href={mapsLink} target="_blank" rel="noopener noreferrer" style={{
                background: 'var(--ink)',
                color: 'var(--paper)',
                textDecoration: 'none',
                padding: '12px 18px',
                fontFamily: 'var(--mono)',
                fontSize: 11,
                letterSpacing: '0.15em',
                textTransform: 'uppercase',
                whiteSpace: 'nowrap'
              }}>Abrir no Google Maps →</a>
              <a href={uberLink} target="_blank" rel="noopener noreferrer" style={{
                background: 'transparent',
                color: 'var(--ink)',
                textDecoration: 'none',
                padding: '12px 18px',
                fontFamily: 'var(--mono)',
                fontSize: 11,
                letterSpacing: '0.15em',
                textTransform: 'uppercase',
                border: '1px solid var(--rule)',
                whiteSpace: 'nowrap'
              }}>Pedir Uber →</a>
            </div>
          </div>

          {/* Map embed */}
          <div style={{
            border: '1px solid var(--rule)',
            background: 'var(--paper)',
            padding: 6,
            position: 'relative',
            minHeight: 320
          }}>
            <iframe
              title="Mapa do local"
              src={embedSrc}
              style={{ width: '100%', height: '100%', minHeight: 320, border: 0, display: 'block', filter: 'sepia(0.15) contrast(0.96) saturate(0.85)' }}
              loading="lazy"
              referrerPolicy="no-referrer-when-downgrade" />
            
            <div style={{
              position: 'absolute',
              left: 14, bottom: 14,
              background: 'var(--paper)',
              border: '1px solid var(--rule)',
              padding: '6px 10px',
              fontFamily: 'var(--mono)',
              fontSize: 10,
              letterSpacing: '0.15em',
              textTransform: 'uppercase',
              color: 'var(--ink-soft)'
            }}>
              ◆ {address}
            </div>
          </div>
        </div>
      </div>
      <style>{`
        @media (max-width: 860px) {
          #local .local-grid { grid-template-columns: 1fr !important; }
        }
      `}</style>
    </section>);

}

/* ------------------------------------------------------------------
   Aviso de saúde — pequeno cartão honesto
   ------------------------------------------------------------------ */

function Cuidado() {
  return (
    <section id="cuidado" style={{ padding: '64px 0' }}>
      <div className="wrap-narrow">
        <div style={{
          background: 'var(--cream)',
          border: '1px solid var(--rule)',
          padding: '40px 44px',
          position: 'relative'
        }}>
          <div className="eyebrow" style={{ marginBottom: 14 }}>P.S. · com carinho</div>
          <h3 style={{
            fontFamily: 'var(--serif)',
            fontStyle: 'italic',
            fontSize: 'clamp(28px, 3.6vw, 40px)',
            lineHeight: 1.1,
            letterSpacing: '-0.01em',
            color: 'var(--ink)',
            marginBottom: 16
          }}>
            Se acordar com qualquer <i style={{ color: 'var(--coral)' }}>tossezinha</i>, espirro<br />ou sentindo ruim — fica em casa, tá?
          </h3>
          <p style={{ color: 'var(--ink-soft)', fontSize: 17, lineHeight: 1.55, maxWidth: '52ch' }}>
            A gente prefere mil vezes ver você bem em outro dia do que correr o risco.
            Manda mensagem, manda foto, manda áudio — guardamos tudo pra contar pra ela.
            Sem cobrança e com muito amor.
          </p>
          <div style={{
            marginTop: 24,
            display: 'flex',
            gap: 10,
            flexWrap: 'wrap',
            fontFamily: 'var(--mono)',
            fontSize: 11,
            letterSpacing: '0.12em',
            textTransform: 'uppercase',
            color: 'var(--sepia-deep)'
          }}>
            <span style={{ border: '1px solid var(--rule)', padding: '6px 10px' }}>tosse</span>
            <span style={{ border: '1px solid var(--rule)', padding: '6px 10px' }}>febre</span>
            <span style={{ border: '1px solid var(--rule)', padding: '6px 10px' }}>nariz escorrendo</span>
            <span style={{ border: '1px solid var(--rule)', padding: '6px 10px' }}>dor de garganta</span>
            <span style={{ border: '1px solid var(--rule)', padding: '6px 10px' }}>mal-estar</span>
          </div>
        </div>
      </div>
    </section>);

}

/* ------------------------------------------------------------------
   Foot
   ------------------------------------------------------------------ */

function Foot() {
  return (
    <footer>
      <div className="wrap">
        <div className="mark"><i>Allegra</i></div>
        <div className="tag">
          09 · Maio · 2026 &nbsp;&nbsp;<span className="heart">◆</span>&nbsp;&nbsp; Thais &amp; André
        </div>
      </div>
    </footer>);

}

/* ------------------------------------------------------------------
   App
   ------------------------------------------------------------------ */

function App() {
  return (
    <>
      <Topbar />
      <Hero />
      <HQSection />
      <Recado />
      <GiftsSection />
      <Cuidado />
      <Playlist />
      <Local />
      <Mural />
      <Foot />
    </>);

}

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