---
// Cena ilustrada usada enquanto o destino não tem foto. Tipos: mar, recife, rio, dunas, vila, resort.
// Paletas: dia, tarde, por (pôr do sol), noite.
interface Props { tipo?: string; paleta?: 'dia' | 'tarde' | 'por' | 'noite'; titulo?: string }
const { tipo = 'mar', paleta = 'dia', titulo = '' } = Astro.props;
const u = Math.random().toString(36).slice(2, 8);
const P = {
  dia:   { c1: '#7cc6ea', c2: '#cdeaf4', sol: '#fff6dc', brilho: '#ffffff', mar1: '#1d8fbf', mar2: '#0e5a7e', raso: '#5fd0d6', areia1: '#f3e3c7', areia2: '#e2c79c', verde: '#2f6b4f', sombra: '#163f33', rio: '#7a5a2a' },
  tarde: { c1: '#f2b880', c2: '#fbe3c2', sol: '#fff1cf', brilho: '#ffe7c4', mar1: '#2a86a8', mar2: '#124f6b', raso: '#7ccfc6', areia1: '#f4dcb6', areia2: '#deb984', verde: '#3b5f40', sombra: '#22382a', rio: '#6e4a22' },
  por:   { c1: '#e86a3a', c2: '#f9b47a', sol: '#ffe3b0', brilho: '#ffd3a1', mar1: '#3b5f85', mar2: '#1c3552', raso: '#c98f78', areia1: '#e9b98f', areia2: '#c98d63', verde: '#2b2e3a', sombra: '#1c1e28', rio: '#4f3020' },
  noite: { c1: '#0b2536', c2: '#1d4a63', sol: '#f3f0e2', brilho: '#9fc3d6', mar1: '#123a52', mar2: '#071c29', raso: '#2c6a7b', areia1: '#8b8a86', areia2: '#5e5c58', verde: '#0d1f1a', sombra: '#060f0c', rio: '#1d2a2a' },
}[paleta];
const sol = { dia: [1180, 260, 70], tarde: [1050, 330, 80], por: [800, 470, 110], noite: [1250, 220, 46] }[paleta];
// coqueiro: tronco curvo + palhas
const coqueiro = (x: number, y: number, s = 1, flip = false) => {
  const f = flip ? -1 : 1;
  return `<g transform="translate(${x} ${y}) scale(${s * f} ${s})" fill="${P.sombra}">
    <path d="M0 0 C 8 -90, 30 -190, 70 -300 L 80 -296 C 44 -190, 22 -90, 14 0 Z"/>
    <g transform="translate(74 -300)">
      <path d="M0 0 C -60 -40 -130 -30 -180 20 C -120 -10 -60 -10 0 6Z"/>
      <path d="M0 0 C -40 -70 -110 -90 -160 -70 C -100 -60 -50 -40 0 4Z"/>
      <path d="M0 0 C 20 -80 80 -110 140 -100 C 80 -80 40 -50 4 4Z"/>
      <path d="M0 0 C 70 -30 140 -10 190 40 C 130 10 70 0 2 6Z"/>
      <path d="M0 0 C 50 10 100 50 120 110 C 80 60 40 30 0 8Z"/>
      <path d="M0 0 C -30 20 -70 60 -80 120 C -50 70 -20 40 0 8Z"/>
      <circle cx="0" cy="8" r="10"/>
    </g></g>`;
};
let frente = '';
if (tipo === 'recife') frente = `
  <path d="M0 640 L1600 610 L1600 1000 L0 1000Z" fill="url(#mar${u})"/>
  <g fill="${P.raso}" opacity=".9"><ellipse cx="420" cy="700" rx="260" ry="38"/><ellipse cx="900" cy="690" rx="220" ry="30"/><ellipse cx="1320" cy="720" rx="200" ry="34"/></g>
  <g fill="${P.sombra}" opacity=".55"><path d="M150 700 q60 -28 120 -6 q40 -20 90 2 q-60 18 -210 4z"/><path d="M640 690 q70 -24 140 -4 q50 -16 110 6 q-90 16 -250 -2z"/><path d="M1120 716 q60 -22 130 -2 q40 -14 90 6 q-70 16 -220 -4z"/></g>
  <path d="M0 790 C 300 760 600 800 900 780 S 1400 760 1600 790 L1600 1000 L0 1000Z" fill="${P.raso}" opacity=".55"/>
  <path d="M0 840 C 320 820 640 860 960 840 S 1420 820 1600 846 L1600 1000 L0 1000Z" fill="url(#areia${u})"/>
  ${coqueiro(1420, 900, 1.15, true)}`;
else if (tipo === 'rio') frente = `
  <path d="M0 620 L1600 600 L1600 1000 L0 1000Z" fill="url(#mar${u})"/>
  <path d="M0 700 C 400 680 800 720 1600 690 L1600 1000 L0 1000Z" fill="url(#areia${u})"/>
  <path d="M-20 1000 C 200 900 420 860 620 820 C 820 780 980 760 1160 700 L 1240 705 C 1060 780 900 820 700 870 C 500 920 320 960 160 1000Z" fill="${P.rio}" opacity=".92"/>
  <path d="M520 850 C 700 805 880 780 1060 735" stroke="${P.brilho}" stroke-width="3" fill="none" opacity=".5"/>
  <path d="M1000 720 C 1200 660 1400 650 1600 640 L1600 700 C 1400 700 1250 720 1140 740Z" fill="${P.areia2}" opacity=".8"/>
  <g fill="${P.verde}"><path d="M0 760 C 120 720 220 740 300 770 L300 820 L0 860Z"/></g>
  ${coqueiro(130, 820, .95)}${coqueiro(1430, 880, 1.1, true)}`;
else if (tipo === 'dunas') frente = `
  <path d="M0 620 L1600 600 L1600 1000 L0 1000Z" fill="url(#mar${u})"/>
  <path d="M0 720 C 260 600 520 640 760 700 C 980 600 1260 590 1600 690 L1600 1000 L0 1000Z" fill="${P.areia2}"/>
  <path d="M0 820 C 300 700 600 720 860 800 C 1100 720 1350 730 1600 800 L1600 1000 L0 1000Z" fill="url(#areia${u})"/>
  <path d="M760 700 C 900 650 1050 640 1200 660" stroke="${P.brilho}" stroke-width="2" fill="none" opacity=".45"/>
  <path d="M0 930 C 400 860 800 900 1600 880 L1600 1000 L0 1000Z" fill="${P.areia1}"/>
  <g fill="${P.verde}" opacity=".8"><path d="M200 900 q10 -40 20 0z M230 905 q8 -30 16 0z M1260 880 q10 -40 20 0z"/></g>`;
else if (tipo === 'vila') frente = `
  <path d="M0 640 L1600 620 L1600 1000 L0 1000Z" fill="url(#mar${u})"/>
  <path d="M0 760 C 400 740 800 770 1600 740 L1600 1000 L0 1000Z" fill="url(#areia${u})"/>
  <g fill="${P.sombra}">
    <path d="M1080 760 L1080 700 L1110 680 L1140 700 L1140 760Z"/><rect x="1150" y="715" width="70" height="45"/><path d="M1145 718 L1185 690 L1225 718Z"/>
    <path d="M1240 760 L1240 660 L1262 630 L1284 660 L1284 760Z"/><rect x="1258" y="600" width="8" height="30"/><rect x="1252" y="612" width="20" height="4"/>
    <rect x="1290" y="718" width="90" height="42"/><path d="M1286 720 L1335 692 L1384 720Z"/>
    <path d="M940 760 L948 560 L968 560 L976 760Z"/><path d="M936 560 L980 560 L972 540 L944 540Z"/>
  </g>
  <path d="M955 548 L700 430 L700 470 Z" fill="${P.brilho}" opacity=".18"/>
  <path d="M0 860 C 400 840 800 880 1600 850 L1600 1000 L0 1000Z" fill="${P.areia1}"/>
  ${coqueiro(1460, 860, 1.05, true)}${coqueiro(860, 780, .7)}${coqueiro(160, 900, 1.2)}`;
else if (tipo === 'resort') frente = `
  <path d="M0 640 L1600 620 L1600 1000 L0 1000Z" fill="url(#mar${u})"/>
  <path d="M0 740 C 400 720 800 750 1600 720 L1600 1000 L0 1000Z" fill="url(#areia${u})"/>
  <g fill="${P.sombra}" opacity=".85">${[260, 520, 780, 1040, 1300].map((x) => `<path d="M${x - 70} 820 Q${x} 770 ${x + 70} 820Z"/><rect x="${x - 3}" y="818" width="6" height="70"/>`).join('')}</g>
  <path d="M0 900 C 400 880 800 920 1600 890 L1600 1000 L0 1000Z" fill="${P.areia1}"/>
  ${coqueiro(80, 900, 1.15)}${coqueiro(1500, 880, 1.1, true)}${coqueiro(1380, 820, .8, true)}`;
else frente = `
  <path d="M0 640 L1600 620 L1600 1000 L0 1000Z" fill="url(#mar${u})"/>
  <path d="M0 760 C 300 740 640 790 980 760 S 1420 740 1600 760 L1600 1000 L0 1000Z" fill="${P.raso}" opacity=".5"/>
  <path d="M0 820 C 320 800 680 850 1000 820 S 1420 800 1600 826 L1600 1000 L0 1000Z" fill="url(#areia${u})"/>
  ${coqueiro(1400, 900, 1.2, true)}${coqueiro(1520, 860, .9, true)}`;
const svg = `
<defs>
  <linearGradient id="ceu${u}" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="${P.c1}"/><stop offset="1" stop-color="${P.c2}"/></linearGradient>
  <radialGradient id="sol${u}" cx="${sol[0]}" cy="${sol[1]}" r="${sol[2] * 5}" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="${P.brilho}" stop-opacity=".75"/><stop offset="1" stop-color="${P.brilho}" stop-opacity="0"/></radialGradient>
  <linearGradient id="mar${u}" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="${P.mar1}"/><stop offset="1" stop-color="${P.mar2}"/></linearGradient>
  <linearGradient id="areia${u}" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="${P.areia1}"/><stop offset="1" stop-color="${P.areia2}"/></linearGradient>
  <filter id="grao${u}"><feTurbulence type="fractalNoise" baseFrequency=".9" numOctaves="2" stitchTiles="stitch"/><feColorMatrix values="0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .07 0"/></filter>
</defs>
<rect width="1600" height="1000" fill="url(#ceu${u})"/>
<rect width="1600" height="1000" fill="url(#sol${u})"/>
<circle cx="${sol[0]}" cy="${sol[1]}" r="${sol[2]}" fill="${P.sol}"/>
<g fill="#fff" opacity="${paleta === 'noite' ? 0 : .5}"><ellipse cx="300" cy="200" rx="160" ry="22"/><ellipse cx="380" cy="186" rx="90" ry="20"/><ellipse cx="760" cy="140" rx="120" ry="16"/></g>
<path d="M0 600 L1600 590 L1600 640 L0 650Z" fill="${P.mar1}" opacity=".6"/>
<path d="M${sol[0] - 120} 600 L${sol[0] + 120} 600 L${sol[0] + 60} 700 L${sol[0] - 60} 700Z" fill="${P.brilho}" opacity=".18"/>
${frente}
<rect width="1600" height="1000" filter="url(#grao${u})"/>`;
---
<svg viewBox="0 0 1600 1000" preserveAspectRatio="xMidYMid slice" role="img" aria-label={titulo || 'Ilustração da paisagem'} set:html={svg} />
