/* global React, FramerMotion */
/* Cena 3D do hero (three.js), partilhada por todas as páginas. As cores vêm do tema
   da página (--orange, --orange-soft, --orange-deep, --accent-rgb, --bg…) e os ícones
   em órbita mudam por produto: icons = "websites" | "assistant" | "social" | "home". */

function CaptixyHero3D({ icons = "websites", colors = null }) {
  const canvasRef = React.useRef(null);
  const wrapRef = React.useRef(null);
  const [ready, setReady] = React.useState(Boolean(window.THREE));

  React.useEffect(() => {
    setReady(Boolean(window.THREE));
  }, []);

  React.useEffect(() => {
    const THREE = window.THREE;
    const canvas = canvasRef.current;
    const wrap = wrapRef.current;
    if (!THREE || !canvas || !wrap) return undefined;

    const theme = getComputedStyle(document.documentElement);
    const cssVar = (name, fallback) =>
      theme.getPropertyValue(name).trim() || fallback;
    let accent = cssVar("--orange", "#6366F1");
    const accentSoft = cssVar("--orange-soft", "#818CF8");
    const accentDeep = cssVar("--orange-deep", "#4F46E5");
    const bg = cssVar("--bg", "#0F172A");
    const bgSoft = cssVar("--bg-soft", "#1E293B");
    const primary = cssVar("--primary", "#F1F5F9");
    const accentRgb = cssVar("--accent-rgb", "99,102,241");
    const accentRgba = (alpha) => `rgba(${accentRgb},${alpha})`;
    const threeColor = (value) => new THREE.Color(value);
    // Paleta opcional com várias cores (home): nebulosas, luzes, reflexos e ícones.
    const palette = Array.isArray(colors) && colors.length ? colors : null;
    const pick = (i, fallback) => (palette ? palette[i % palette.length] : fallback);
    const hexRgba = (hex, a) => {
      const h = hex.replace("#", "");
      const n = parseInt(h.length === 3 ? h.split("").map((c) => c + c).join("") : h, 16);
      return `rgba(${(n >> 16) & 255},${(n >> 8) & 255},${n & 255},${a})`;
    };

    const scene = new THREE.Scene();
    const camera = new THREE.PerspectiveCamera(40, 1, 0.1, 100);
    camera.position.set(0, 0, 8.6);

    const renderer = new THREE.WebGLRenderer({
      canvas,
      alpha: true,
      antialias: true,
      powerPreference: "high-performance",
    });
    renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2.6));
    renderer.outputColorSpace = THREE.SRGBColorSpace;
    renderer.toneMapping = THREE.ACESFilmicToneMapping;
    renderer.toneMappingExposure = 1.08;

    scene.add(new THREE.AmbientLight(0xffffff, 0.42));
    const keyLight = new THREE.DirectionalLight(0xffffff, 0.5);
    keyLight.position.set(4, 5, 7);
    scene.add(keyLight);
    const accentLight = new THREE.PointLight(threeColor(pick(0, accent)), palette ? 1.6 : 1.2, 60);
    accentLight.position.set(-5, 3, 4);
    scene.add(accentLight);
    const softLight = new THREE.PointLight(threeColor(pick(1, accentSoft)), palette ? 1.2 : 0.82, 60);
    softLight.position.set(5, -3, 3);
    scene.add(softLight);
    const glint = new THREE.PointLight(0xffffff, 1.1, 45);
    scene.add(glint);

    const world = new THREE.Group();
    const root = new THREE.Group();
    const logoGroup = new THREE.Group();
    scene.add(world);
    world.add(root);
    root.add(logoGroup);

    const textureDisposables = [];

    const environmentCanvas = document.createElement("canvas");
    environmentCanvas.width = 1024;
    environmentCanvas.height = 512;
    const environmentCtx = environmentCanvas.getContext("2d");
    const environmentBg = environmentCtx.createLinearGradient(0, 0, 0, 512);
    environmentBg.addColorStop(0, "#1b2c49");
    environmentBg.addColorStop(0.5, bg);
    environmentBg.addColorStop(1, "#05070e");
    environmentCtx.fillStyle = environmentBg;
    environmentCtx.fillRect(0, 0, 1024, 512);
    const environmentBlob = (x, y, radius, color) => {
      const gradient = environmentCtx.createRadialGradient(
        x,
        y,
        0,
        x,
        y,
        radius,
      );
      gradient.addColorStop(0, color);
      gradient.addColorStop(1, "rgba(0,0,0,0)");
      environmentCtx.fillStyle = gradient;
      environmentCtx.fillRect(0, 0, 1024, 512);
    };
    environmentBlob(300, 150, 280, "rgba(255,255,255,0.55)");
    environmentBlob(770, 165, 240, palette ? hexRgba(pick(0), 0.6) : accentRgba(0.55));
    environmentBlob(540, 370, 280, palette ? hexRgba(pick(1), 0.5) : accentRgba(0.42));
    if (palette) environmentBlob(900, 380, 220, hexRgba(pick(2), 0.5));
    environmentBlob(120, 370, 220, "rgba(120,150,255,0.22)");
    const environmentStripe = environmentCtx.createLinearGradient(
      0,
      118,
      0,
      205,
    );
    environmentStripe.addColorStop(0, "rgba(255,255,255,0)");
    environmentStripe.addColorStop(0.5, "rgba(255,255,255,0.9)");
    environmentStripe.addColorStop(1, "rgba(255,255,255,0)");
    environmentCtx.fillStyle = environmentStripe;
    environmentCtx.fillRect(0, 118, 1024, 87);
    const environmentTexture = new THREE.CanvasTexture(environmentCanvas);
    environmentTexture.mapping = THREE.EquirectangularReflectionMapping;
    environmentTexture.colorSpace = THREE.SRGBColorSpace;
    const pmrem = new THREE.PMREMGenerator(renderer);
    pmrem.compileEquirectangularShader();
    const environment = pmrem.fromEquirectangular(environmentTexture).texture;
    scene.environment = environment;
    textureDisposables.push(environmentTexture, environment);
    pmrem.dispose();

    function roundRect(ctx, x, y, width, height, radius) {
      ctx.beginPath();
      ctx.moveTo(x + radius, y);
      ctx.lineTo(x + width - radius, y);
      ctx.quadraticCurveTo(x + width, y, x + width, y + radius);
      ctx.lineTo(x + width, y + height - radius);
      ctx.quadraticCurveTo(
        x + width,
        y + height,
        x + width - radius,
        y + height,
      );
      ctx.lineTo(x + radius, y + height);
      ctx.quadraticCurveTo(x, y + height, x, y + height - radius);
      ctx.lineTo(x, y + radius);
      ctx.quadraticCurveTo(x, y, x + radius, y);
      ctx.closePath();
    }

    const makeTexture = (width, height, draw) => {
      const textureCanvas = document.createElement("canvas");
      textureCanvas.width = width;
      textureCanvas.height = height;
      const ctx = textureCanvas.getContext("2d");
      draw(ctx, width, height);
      const texture = new THREE.CanvasTexture(textureCanvas);
      texture.colorSpace = THREE.SRGBColorSpace;
      texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
      texture.minFilter = THREE.LinearMipmapLinearFilter;
      texture.needsUpdate = true;
      textureDisposables.push(texture);
      return texture;
    };

    let disposed = false;
    let logoBorn = null;
    const logoDepth = 0.36;
    const colorStops = palette
      ? palette.map((c) => threeColor(c))
      : [threeColor(accentSoft), threeColor(accent), threeColor(accentDeep)];
    const logoMaterial = new THREE.MeshPhysicalMaterial({
      vertexColors: true,
      color: 0xffffff,
      metalness: 0,
      roughness: 0.06,
      transmission: 0.82,
      ior: 1.46,
      clearcoat: 1,
      clearcoatRoughness: 0.07,
      reflectivity: 0.6,
      emissive: threeColor(accentDeep),
      emissiveIntensity: 0.18,
      envMapIntensity: 1.4,
      transparent: true,
      opacity: 0,
    });
    const lerpLogoColor = (value) => {
      const segment = value < 0.5 ? 0 : 1;
      const localValue = value < 0.5 ? value / 0.5 : (value - 0.5) / 0.5;
      const from = colorStops[segment];
      const to = colorStops[segment + 1];
      return new THREE.Color(
        from.r + (to.r - from.r) * localValue,
        from.g + (to.g - from.g) * localValue,
        from.b + (to.b - from.b) * localValue,
      );
    };
    const simplifyLogoPoints = (points, epsilon) => {
      if (points.length < 5) return points;
      const squareDistance = (a, b) => {
        const dx = a[0] - b[0];
        const dy = a[1] - b[1];
        return dx * dx + dy * dy;
      };
      const segmentDistance = (point, start, end) => {
        let x = start[0];
        let y = start[1];
        const dx = end[0] - x;
        const dy = end[1] - y;
        if (dx || dy) {
          const t =
            ((point[0] - x) * dx + (point[1] - y) * dy) / (dx * dx + dy * dy);
          if (t > 1) {
            x = end[0];
            y = end[1];
          } else if (t > 0) {
            x += dx * t;
            y += dy * t;
          }
        }
        return squareDistance(point, [x, y]);
      };
      const keep = new Array(points.length).fill(false);
      keep[0] = true;
      keep[points.length - 1] = true;
      const stack = [[0, points.length - 1]];
      while (stack.length) {
        const [start, end] = stack.pop();
        let maxDistance = 0;
        let index = -1;
        for (let i = start + 1; i < end; i += 1) {
          const distance = segmentDistance(
            points[i],
            points[start],
            points[end],
          );
          if (distance > maxDistance) {
            maxDistance = distance;
            index = i;
          }
        }
        if (maxDistance > epsilon * epsilon && index > 0) {
          keep[index] = true;
          stack.push([start, index], [index, end]);
        }
      }
      return points.filter((_, index) => keep[index]);
    };
    const smoothLogoPoints = (points, iterations) => {
      let output = points;
      for (let iteration = 0; iteration < iterations; iteration += 1) {
        const smoothed = [];
        for (let i = 0; i < output.length; i += 1) {
          const current = output[i];
          const next = output[(i + 1) % output.length];
          smoothed.push([
            current[0] * 0.75 + next[0] * 0.25,
            current[1] * 0.75 + next[1] * 0.25,
          ]);
          smoothed.push([
            current[0] * 0.25 + next[0] * 0.75,
            current[1] * 0.25 + next[1] * 0.75,
          ]);
        }
        output = smoothed;
      }
      return output;
    };
    const traceLogoComponent = (componentMask, size) => {
      const get = (x, y) =>
        x >= 0 && y >= 0 && x < size && y < size
          ? componentMask[y * size + x]
          : 0;
      let startIndex = -1;
      for (let i = 0; i < size * size; i += 1) {
        if (componentMask[i]) {
          startIndex = i;
          break;
        }
      }
      if (startIndex < 0) return null;
      const directions = [
        [1, 0],
        [1, 1],
        [0, 1],
        [-1, 1],
        [-1, 0],
        [-1, -1],
        [0, -1],
        [1, -1],
      ];
      const startX = startIndex % size;
      const startY = (startIndex / size) | 0;
      let currentX = startX;
      let currentY = startY;
      let backtrackX = startX - 1;
      let backtrackY = startY;
      const contour = [[startX, startY]];
      let guard = 0;
      while (guard < size * size * 8) {
        guard += 1;
        let backtrackDirection = 0;
        for (let i = 0; i < 8; i += 1) {
          if (
            currentX + directions[i][0] === backtrackX &&
            currentY + directions[i][1] === backtrackY
          ) {
            backtrackDirection = i;
            break;
          }
        }
        let moved = false;
        for (let i = 1; i <= 8; i += 1) {
          const directionIndex = (backtrackDirection + i) % 8;
          const nextX = currentX + directions[directionIndex][0];
          const nextY = currentY + directions[directionIndex][1];
          if (get(nextX, nextY)) {
            backtrackX = currentX + directions[(directionIndex + 7) % 8][0];
            backtrackY = currentY + directions[(directionIndex + 7) % 8][1];
            currentX = nextX;
            currentY = nextY;
            contour.push([currentX, currentY]);
            moved = true;
            break;
          }
        }
        if (!moved || (currentX === startX && currentY === startY)) break;
      }
      return contour;
    };
    const buildLogoMonogram = (image) => {
      const size = 480;
      const logoCanvas = document.createElement("canvas");
      logoCanvas.width = size;
      logoCanvas.height = size;
      const logoCtx = logoCanvas.getContext("2d");
      logoCtx.drawImage(image, 0, 0, size, size);
      const data = logoCtx.getImageData(0, 0, size, size).data;
      const mask = new Uint8Array(size * size);
      for (let i = 0; i < size * size; i += 1) {
        const r = data[i * 4];
        const g = data[i * 4 + 1];
        const b = data[i * 4 + 2];
        const a = data[i * 4 + 3];
        mask[i] = a > 60 && Math.min(r, g, b) > 165 ? 1 : 0;
      }
      const labels = new Int32Array(size * size);
      const componentSizes = [0];
      const stack = [];
      let component = 0;
      for (let i = 0; i < size * size; i += 1) {
        if (mask[i] && !labels[i]) {
          component += 1;
          let count = 0;
          stack.length = 0;
          stack.push(i);
          labels[i] = component;
          while (stack.length) {
            const point = stack.pop();
            count += 1;
            const x = point % size;
            const y = (point / size) | 0;
            for (let dy = -1; dy <= 1; dy += 1) {
              for (let dx = -1; dx <= 1; dx += 1) {
                if (!dx && !dy) continue;
                const nextX = x + dx;
                const nextY = y + dy;
                if (nextX < 0 || nextY < 0 || nextX >= size || nextY >= size) {
                  continue;
                }
                const nextPoint = nextY * size + nextX;
                if (mask[nextPoint] && !labels[nextPoint]) {
                  labels[nextPoint] = component;
                  stack.push(nextPoint);
                }
              }
            }
          }
          componentSizes[component] = count;
        }
      }
      const geometries = [];
      const worldSize = 2.4;
      for (let current = 1; current <= component; current += 1) {
        if (componentSizes[current] < size * size * 0.004) continue;
        const componentMask = new Uint8Array(size * size);
        for (let i = 0; i < size * size; i += 1) {
          componentMask[i] = labels[i] === current ? 1 : 0;
        }
        let contour = traceLogoComponent(componentMask, size);
        if (!contour || contour.length < 12) continue;
        if (
          contour.length > 2 &&
          contour[0][0] === contour[contour.length - 1][0] &&
          contour[0][1] === contour[contour.length - 1][1]
        ) {
          contour.pop();
        }
        contour = smoothLogoPoints(simplifyLogoPoints(contour, 1.6), 3);
        if (contour.length < 8) continue;
        const shape = new THREE.Shape();
        contour.forEach((point, index) => {
          const x = (point[0] / size - 0.5) * worldSize;
          const y = (0.5 - point[1] / size) * worldSize;
          if (index === 0) shape.moveTo(x, y);
          else shape.lineTo(x, y);
        });
        const geometry = new THREE.ExtrudeGeometry(shape, {
          depth: logoDepth,
          bevelEnabled: true,
          bevelThickness: 0.045,
          bevelSize: 0.04,
          bevelSegments: 6,
          curveSegments: 1,
        });
        geometry.translate(0, 0, -logoDepth / 2);
        geometry.computeBoundingBox();
        geometries.push(geometry);
      }
      if (!geometries.length) return;
      let minX = Infinity;
      let maxX = -Infinity;
      geometries.forEach((geometry) => {
        minX = Math.min(minX, geometry.boundingBox.min.x);
        maxX = Math.max(maxX, geometry.boundingBox.max.x);
      });
      const box = new THREE.Box3();
      geometries.forEach((geometry) => {
        const positions = geometry.attributes.position;
        const colors = new Float32Array(positions.count * 3);
        for (let i = 0; i < positions.count; i += 1) {
          const value = Math.max(
            0,
            Math.min(1, (positions.getX(i) - minX) / (maxX - minX)),
          );
          const color = lerpLogoColor(value);
          colors[i * 3] = color.r;
          colors[i * 3 + 1] = color.g;
          colors[i * 3 + 2] = color.b;
        }
        geometry.setAttribute("color", new THREE.BufferAttribute(colors, 3));
        logoGroup.add(new THREE.Mesh(geometry, logoMaterial));
        box.union(geometry.boundingBox);
      });
      const center = box.getCenter(new THREE.Vector3());
      logoGroup.children.forEach((mesh) => mesh.position.sub(center));
      const logoSize = box.getSize(new THREE.Vector3());
      logoGroup.scale.setScalar(2.15 / Math.max(logoSize.x, logoSize.y));
      logoBorn = frame;
    };
    const logoImage = new Image();
    logoImage.crossOrigin = "anonymous";
    logoImage.onload = () => {
      if (disposed) return;
      try {
        buildLogoMonogram(logoImage);
      } catch (error) {
        console.warn("hero logo build failed", error);
      }
    };
    logoImage.src = "assets/captixy-logo.png";

    const glowTexture = makeTexture(256, 256, (ctx, width, height) => {
      const glow = ctx.createRadialGradient(
        width / 2,
        height / 2,
        0,
        width / 2,
        height / 2,
        width / 2,
      );
      glow.addColorStop(0, accentRgba(0.88));
      glow.addColorStop(0.42, accentRgba(0.32));
      glow.addColorStop(1, accentRgba(0));
      ctx.fillStyle = glow;
      ctx.fillRect(0, 0, width, height);
    });
    const glow = new THREE.Mesh(
      new THREE.PlaneGeometry(7.4, 7.4),
      new THREE.MeshBasicMaterial({
        map: glowTexture,
        transparent: true,
        blending: THREE.AdditiveBlending,
        depthWrite: false,
      }),
    );
    glow.position.z = -0.9;
    root.add(glow);

    const dotTexture = makeTexture(64, 64, (ctx, width, height) => {
      const dot = ctx.createRadialGradient(
        width / 2,
        height / 2,
        0,
        width / 2,
        height / 2,
        width / 2,
      );
      dot.addColorStop(0, "rgba(255,255,255,1)");
      dot.addColorStop(1, "rgba(255,255,255,0)");
      ctx.fillStyle = dot;
      ctx.fillRect(0, 0, width, height);
    });

    const isMobile = window.innerWidth < 760;
    const makeStars = (count, minRadius, radiusSpan) => {
      const positions = new Float32Array(count * 3);
      for (let i = 0; i < count; i += 1) {
        const radius = minRadius + Math.random() * radiusSpan;
        const theta = Math.random() * Math.PI * 2;
        const phi = Math.acos(2 * Math.random() - 1);
        positions[i * 3] = radius * Math.sin(phi) * Math.cos(theta);
        positions[i * 3 + 1] = radius * Math.cos(phi);
        positions[i * 3 + 2] = radius * Math.sin(phi) * Math.sin(theta);
      }
      const geometry = new THREE.BufferGeometry();
      geometry.setAttribute(
        "position",
        new THREE.BufferAttribute(positions, 3),
      );
      return geometry;
    };
    const stars = new THREE.Points(
      makeStars(isMobile ? 440 : 920, 8, 13),
      new THREE.PointsMaterial({
        size: 0.07,
        map: dotTexture,
        transparent: true,
        blending: THREE.AdditiveBlending,
        depthWrite: false,
        color: threeColor(primary),
        opacity: 0.5,
      }),
    );
    const starsAccent = new THREE.Points(
      makeStars(isMobile ? 70 : 140, 6, 8),
      new THREE.PointsMaterial({
        size: 0.15,
        map: dotTexture,
        transparent: true,
        blending: THREE.AdditiveBlending,
        depthWrite: false,
        color: threeColor(accentSoft),
        opacity: 0.68,
      }),
    );
    scene.add(stars);
    scene.add(starsAccent);

    const nebulaTexture = makeTexture(256, 256, (ctx, width, height) => {
      const nebula = ctx.createRadialGradient(
        width / 2,
        height / 2,
        0,
        width / 2,
        height / 2,
        width / 2,
      );
      nebula.addColorStop(0, "rgba(255,255,255,0.55)");
      nebula.addColorStop(0.5, "rgba(255,255,255,0.12)");
      nebula.addColorStop(1, "rgba(255,255,255,0)");
      ctx.fillStyle = nebula;
      ctx.fillRect(0, 0, width, height);
    });
    const nebulas = [
      { x: -6.5, y: 3, z: -8, size: 11, color: pick(0, accent), opacity: palette ? 0.32 : 0.2 },
      { x: 7, y: -3.4, z: -9, size: 13, color: pick(2, accentDeep), opacity: palette ? 0.3 : 0.18 },
      { x: 2, y: 5, z: -10.5, size: 12, color: pick(1, accentSoft), opacity: palette ? 0.24 : 0.12 },
    ].map((item, index) => {
      const nebula = new THREE.Mesh(
        new THREE.PlaneGeometry(item.size, item.size),
        new THREE.MeshBasicMaterial({
          map: nebulaTexture,
          transparent: true,
          blending: THREE.AdditiveBlending,
          depthWrite: false,
          color: threeColor(item.color),
          opacity: 0,
        }),
      );
      nebula.position.set(item.x, item.y, item.z);
      nebula.userData = { baseOpacity: item.opacity, phase: index * 2.1 };
      scene.add(nebula);
      return nebula;
    });

    const ringPivot = new THREE.Group();
    ringPivot.rotation.x = 1.16;
    ringPivot.rotation.z = 0.18;
    root.add(ringPivot);
    const ringCount = isMobile ? 560 : 1050;
    const ringPositions = new Float32Array(ringCount * 3);
    for (let i = 0; i < ringCount; i += 1) {
      const angle = Math.random() * Math.PI * 2;
      const radius = 1.95 + Math.random() * 0.95;
      ringPositions[i * 3] = Math.cos(angle) * radius;
      ringPositions[i * 3 + 1] = (Math.random() * 2 - 1) * 0.06;
      ringPositions[i * 3 + 2] = Math.sin(angle) * radius;
    }
    const ringGeometry = new THREE.BufferGeometry();
    ringGeometry.setAttribute(
      "position",
      new THREE.BufferAttribute(ringPositions, 3),
    );
    const ringPoints = new THREE.Points(
      ringGeometry,
      new THREE.PointsMaterial({
        size: 0.05,
        map: dotTexture,
        transparent: true,
        blending: THREE.AdditiveBlending,
        depthWrite: false,
        color: threeColor(accentSoft),
        opacity: 0.5,
      }),
    );
    ringPivot.add(ringPoints);

    const chip = (ctx, width, height) => {
      ctx.clearRect(0, 0, width, height);
      ctx.save();
      ctx.shadowColor = "rgba(0,0,0,.5)";
      ctx.shadowBlur = 18;
      ctx.shadowOffsetY = 8;
      roundRect(ctx, 16, 16, width - 32, height - 32, 26);
      ctx.fillStyle = bgSoft;
      ctx.fill();
      ctx.restore();
      roundRect(ctx, 16, 16, width - 32, height - 32, 26);
      ctx.lineWidth = 3;
      ctx.strokeStyle = accentRgba(0.5);
      ctx.stroke();
    };
    const iconCode = (ctx, width, height) => {
      chip(ctx, width, height);
      ctx.fillStyle = accentSoft;
      ctx.font = '700 50px "Almarai", sans-serif';
      ctx.textAlign = "center";
      ctx.textBaseline = "middle";
      ctx.fillText("</>", width / 2, height / 2 + 2);
    };
    const iconBraces = (ctx, width, height) => {
      chip(ctx, width, height);
      ctx.fillStyle = primary;
      ctx.font = '700 56px "Almarai", sans-serif';
      ctx.textAlign = "center";
      ctx.textBaseline = "middle";
      ctx.fillText("{ }", width / 2, height / 2 + 2);
    };
    const iconCursor = (ctx, width, height) => {
      chip(ctx, width, height);
      ctx.save();
      ctx.translate(width / 2 - 14, height / 2 - 22);
      ctx.beginPath();
      ctx.moveTo(0, 0);
      ctx.lineTo(0, 46);
      ctx.lineTo(12, 35);
      ctx.lineTo(21, 53);
      ctx.lineTo(29, 49);
      ctx.lineTo(20, 32);
      ctx.lineTo(36, 32);
      ctx.closePath();
      ctx.fillStyle = primary;
      ctx.strokeStyle = bg;
      ctx.lineWidth = 4;
      ctx.lineJoin = "round";
      ctx.stroke();
      ctx.fill();
      ctx.restore();
    };
    const iconSwatch = (ctx, width, height) => {
      chip(ctx, width, height);
      [accentSoft, accent, accentDeep].forEach((color, index) => {
        ctx.beginPath();
        ctx.arc(width / 2 - 30 + index * 30, height / 2, 13, 0, Math.PI * 2);
        ctx.fillStyle = color;
        ctx.fill();
      });
    };
    const iconLayout = (ctx, width, height) => {
      chip(ctx, width, height);
      ctx.strokeStyle = "rgba(255,255,255,.85)";
      ctx.lineWidth = 4;
      ctx.strokeRect(34, 34, width - 68, height - 68);
      ctx.fillStyle = accent;
      ctx.fillRect(34, 34, width - 68, 14);
      ctx.fillStyle = "rgba(255,255,255,.5)";
      ctx.fillRect(40, 62, 26, height - 88);
      ctx.fillRect(74, 62, width - 114, height - 88);
    };
    const iconPen = (ctx, width, height) => {
      chip(ctx, width, height);
      const centerX = width / 2;
      const centerY = height / 2;
      ctx.strokeStyle = "rgba(255,255,255,.5)";
      ctx.lineWidth = 3;
      ctx.beginPath();
      ctx.moveTo(centerX - 32, centerY + 16);
      ctx.lineTo(centerX + 32, centerY - 16);
      ctx.stroke();
      ctx.fillStyle = accent;
      ctx.beginPath();
      ctx.moveTo(centerX, centerY - 15);
      ctx.lineTo(centerX + 13, centerY);
      ctx.lineTo(centerX, centerY + 15);
      ctx.lineTo(centerX - 13, centerY);
      ctx.closePath();
      ctx.fill();
    };

    /* Ícones por produto (Assistant, Social, Home); os do Websites estão acima. */
    const strokeIcon = (draw) => (ctx, width, height) => {
      chip(ctx, width, height);
      ctx.save();
      ctx.strokeStyle = primary;
      ctx.fillStyle = primary;
      ctx.lineWidth = 6;
      ctx.lineCap = "round";
      ctx.lineJoin = "round";
      draw(ctx, width / 2, height / 2);
      ctx.restore();
    };
    const iconChat = strokeIcon((ctx, cx, cy) => {
      ctx.beginPath();
      roundRect(ctx, cx - 32, cy - 24, 64, 42, 12);
      ctx.stroke();
      ctx.beginPath();
      ctx.moveTo(cx - 14, cy + 18);
      ctx.lineTo(cx - 22, cy + 32);
      ctx.lineTo(cx, cy + 18);
      ctx.stroke();
      ctx.fillStyle = accent;
      [-14, 0, 14].forEach((dx) => { ctx.beginPath(); ctx.arc(cx + dx, cy - 3, 4.5, 0, Math.PI * 2); ctx.fill(); });
    });
    const iconCheck = strokeIcon((ctx, cx, cy) => {
      ctx.fillStyle = accent;
      ctx.beginPath(); ctx.arc(cx, cy, 30, 0, Math.PI * 2); ctx.fill();
      ctx.strokeStyle = "#ffffff"; ctx.lineWidth = 8;
      ctx.beginPath(); ctx.moveTo(cx - 14, cy + 1); ctx.lineTo(cx - 3, cy + 12); ctx.lineTo(cx + 16, cy - 11); ctx.stroke();
    });
    const iconBell = strokeIcon((ctx, cx, cy) => {
      ctx.beginPath();
      ctx.moveTo(cx - 24, cy + 16);
      ctx.quadraticCurveTo(cx - 20, cy + 6, cx - 20, cy - 6);
      ctx.quadraticCurveTo(cx - 20, cy - 28, cx, cy - 28);
      ctx.quadraticCurveTo(cx + 20, cy - 28, cx + 20, cy - 6);
      ctx.quadraticCurveTo(cx + 20, cy + 6, cx + 24, cy + 16);
      ctx.closePath(); ctx.stroke();
      ctx.beginPath(); ctx.arc(cx, cy + 22, 6, 0, Math.PI); ctx.stroke();
      ctx.fillStyle = accent; ctx.beginPath(); ctx.arc(cx + 20, cy - 24, 9, 0, Math.PI * 2); ctx.fill();
    });
    const iconCalendar = strokeIcon((ctx, cx, cy) => {
      ctx.beginPath(); roundRect(ctx, cx - 30, cy - 24, 60, 52, 9); ctx.stroke();
      ctx.beginPath(); ctx.moveTo(cx - 30, cy - 8); ctx.lineTo(cx + 30, cy - 8); ctx.stroke();
      ctx.beginPath(); ctx.moveTo(cx - 14, cy - 32); ctx.lineTo(cx - 14, cy - 18); ctx.moveTo(cx + 14, cy - 32); ctx.lineTo(cx + 14, cy - 18); ctx.stroke();
      ctx.fillStyle = accent; ctx.fillRect(cx + 4, cy + 2, 16, 14);
    });
    const iconPhone = strokeIcon((ctx, cx, cy) => {
      ctx.beginPath(); roundRect(ctx, cx - 20, cy - 34, 40, 68, 9); ctx.stroke();
      ctx.fillStyle = accent; ctx.fillRect(cx - 11, cy - 18, 22, 6); ctx.fillRect(cx - 11, cy - 6, 22, 6);
      ctx.fillStyle = "rgba(255,255,255,.55)"; ctx.fillRect(cx - 11, cy + 6, 14, 6);
    });
    const iconForm = strokeIcon((ctx, cx, cy) => {
      [-18, 0, 18].forEach((dy, i) => {
        ctx.beginPath(); roundRect(ctx, cx - 30, cy + dy - 7, 60, 14, 7);
        if (i === 1) { ctx.fillStyle = accent; ctx.fill(); } else { ctx.stroke(); }
      });
    });
    const iconPlay = strokeIcon((ctx, cx, cy) => {
      ctx.fillStyle = accent;
      ctx.beginPath(); ctx.moveTo(cx - 13, cy - 22); ctx.lineTo(cx + 24, cy); ctx.lineTo(cx - 13, cy + 22); ctx.closePath(); ctx.fill();
    });
    const iconHeart = strokeIcon((ctx, cx, cy) => {
      ctx.fillStyle = accent;
      ctx.beginPath();
      ctx.moveTo(cx, cy + 24);
      ctx.bezierCurveTo(cx - 40, cy - 2, cx - 22, cy - 34, cx, cy - 14);
      ctx.bezierCurveTo(cx + 22, cy - 34, cx + 40, cy - 2, cx, cy + 24);
      ctx.fill();
    });
    const iconRecord = strokeIcon((ctx, cx, cy) => {
      ctx.beginPath(); ctx.arc(cx, cy, 28, 0, Math.PI * 2); ctx.stroke();
      ctx.fillStyle = accent; ctx.beginPath(); ctx.arc(cx, cy, 15, 0, Math.PI * 2); ctx.fill();
    });
    const iconCaption = (ctx, width, height) => {
      chip(ctx, width, height);
      ctx.fillStyle = primary; ctx.font = '800 34px "Almarai", sans-serif'; ctx.textAlign = "center"; ctx.textBaseline = "middle";
      ctx.fillText("Aa", width / 2, height / 2 - 8);
      ctx.fillStyle = accent; ctx.fillRect(width / 2 - 28, height / 2 + 18, 56, 7);
    };
    const iconMusic = strokeIcon((ctx, cx, cy) => {
      ctx.beginPath(); ctx.moveTo(cx - 10, cy + 18); ctx.lineTo(cx - 10, cy - 24); ctx.lineTo(cx + 22, cy - 30); ctx.lineTo(cx + 22, cy + 12); ctx.stroke();
      ctx.fillStyle = accent;
      ctx.beginPath(); ctx.arc(cx - 18, cy + 18, 9, 0, Math.PI * 2); ctx.fill();
      ctx.beginPath(); ctx.arc(cx + 14, cy + 12, 9, 0, Math.PI * 2); ctx.fill();
    });
    const iconFilm = strokeIcon((ctx, cx, cy) => {
      ctx.beginPath(); roundRect(ctx, cx - 22, cy - 32, 44, 64, 7); ctx.stroke();
      ctx.fillStyle = accent;
      [-22, -8, 6, 20].forEach((dy) => { ctx.fillRect(cx - 18, cy + dy - 2, 6, 6); ctx.fillRect(cx + 12, cy + dy - 2, 6, 6); });
    });
    const iconStar = strokeIcon((ctx, cx, cy) => {
      ctx.fillStyle = accent;
      ctx.beginPath();
      for (let i = 0; i < 10; i += 1) {
        const r = i % 2 === 0 ? 28 : 12;
        const a = -Math.PI / 2 + (i * Math.PI) / 5;
        ctx.lineTo(cx + Math.cos(a) * r, cy + Math.sin(a) * r);
      }
      ctx.closePath(); ctx.fill();
    });
    const ICON_SETS = {
      websites: [iconCode, iconSwatch, iconCursor, iconLayout, iconBraces, iconPen],
      assistant: [iconChat, iconCheck, iconBell, iconCalendar, iconPhone, iconForm],
      social: [iconPlay, iconHeart, iconRecord, iconCaption, iconMusic, iconFilm],
      home: [iconLayout, iconPlay, iconForm, iconCursor, iconHeart, iconStar],
    };
    const iconSet = ICON_SETS[icons] || ICON_SETS.websites;

    const satellites = [];
    const addSatellite = (draw, options) => {
      const baseAccent = accent;
      if (palette) accent = pick(options.index);
      const texture = makeTexture(128, 128, draw);
      accent = baseAccent;
      const satellite = new THREE.Mesh(
        new THREE.PlaneGeometry(options.size, options.size),
        new THREE.MeshBasicMaterial({
          map: texture,
          transparent: true,
          depthWrite: false,
          opacity: 0,
        }),
      );
      options.euler = new THREE.Euler(options.tiltX, 0, options.tiltZ);
      satellite.userData = options;
      root.add(satellite);
      satellites.push(satellite);

      const orbitPoints = [];
      for (let i = 0; i <= 120; i += 1) {
        const angle = (i / 120) * Math.PI * 2;
        orbitPoints.push(
          new THREE.Vector3(
            Math.cos(angle) * options.radius,
            0,
            Math.sin(angle) * options.radius,
          ).applyEuler(options.euler),
        );
      }
      const line = new THREE.Line(
        new THREE.BufferGeometry().setFromPoints(orbitPoints),
        new THREE.LineBasicMaterial({
          color: threeColor(accent),
          transparent: true,
          opacity: 0,
        }),
      );
      line.userData = { baseOpacity: options.lineOpacity };
      root.add(line);
      options.line = line;
    };
    [
      [iconSet[0], 3.0, 1.2, 0.15, 0, 0.34, 0.5, 0.06, 0, 0.18],
      [iconSet[1], 3.55, 0.5, -0.5, 2.0, 0.27, 0.46, 0.05, 1, 0.13],
      [iconSet[2], 2.55, 1.45, 0.5, 4.1, 0.42, 0.42, 0.07, 2, 0.16],
      [iconSet[3], 4.0, 0.9, 0.3, 3.0, 0.22, 0.52, 0.05, 3, 0.11],
      [iconSet[4], 3.25, 1.0, -0.25, 5.2, 0.3, 0.46, 0.06, 4, 0.14],
      [iconSet[5], 4.45, 0.35, 0.45, 1.0, 0.19, 0.48, 0.05, 5, 0.1],
    ].forEach(
      ([
        draw,
        radius,
        tiltX,
        tiltZ,
        angle,
        speed,
        size,
        bob,
        index,
        lineOpacity,
      ]) =>
        addSatellite(draw, {
          radius,
          tiltX,
          tiltZ,
          angle,
          speed,
          size,
          bob,
          phase: index,
          index,
          maxOpacity: index === 5 ? 0.82 : 0.92,
          lineOpacity,
        }),
    );

    function resize() {
      const rect = wrap.getBoundingClientRect();
      const width = Math.max(1, Math.floor(rect.width));
      const height = Math.max(1, Math.floor(rect.height));
      renderer.setSize(width, height, false);
      camera.aspect = width / height;
      camera.updateProjectionMatrix();
      root.position.x = width < 760 ? 0 : width / height > 1.25 ? 0.28 : 0.18;
    }

    let frame = 0;
    let raf = 0;
    const pointer = { x: 0, y: 0 };
    const easedPointer = { x: 0, y: 0 };
    const cameraWorld = new THREE.Vector3();
    const satellitePosition = new THREE.Vector3();
    const clamp = (value) => Math.max(0, Math.min(1, value));
    const easeOut = (value) => 1 - Math.pow(1 - value, 3);
    const easeBack = (value) => {
      const c1 = 1.70158;
      const c3 = c1 + 1;
      return 1 + c3 * Math.pow(value - 1, 3) + c1 * Math.pow(value - 1, 2);
    };
    const onPointerMove = (event) => {
      pointer.x = (event.clientX / window.innerWidth) * 2 - 1;
      pointer.y = -((event.clientY / window.innerHeight) * 2 - 1);
    };
    window.addEventListener("pointermove", onPointerMove, { passive: true });

    function animate(time) {
      frame = time * 0.001;
      const intro = clamp(frame / 1.4);
      world.scale.setScalar(
        (0.2 + 0.8 * easeBack(intro)) * (isMobile ? 0.66 : 0.92),
      );
      root.rotation.y = Math.sin(frame * 0.28) * 0.1 - 0.06;
      root.rotation.x = Math.sin(frame * 0.22) * 0.05;
      logoGroup.rotation.y = frame * 0.34 + (1 - easeOut(intro)) * Math.PI;
      logoGroup.rotation.x = Math.sin(frame * 0.4) * 0.08;
      logoGroup.position.y = Math.sin(frame * 0.55) * 0.07;
      logoMaterial.opacity =
        logoBorn == null ? 0 : clamp((frame - logoBorn) / 0.8);
      glow.scale.setScalar(1 + Math.sin(frame * 1.3) * 0.06);
      glow.material.opacity = 0.42 + Math.sin(frame * 1.3) * 0.1;
      glow.lookAt(camera.position);
      ringPoints.rotation.y = frame * 0.06;
      stars.rotation.y = frame * 0.012;
      starsAccent.rotation.y = -frame * 0.008;

      camera.getWorldPosition(cameraWorld);
      satellites.forEach((satellite) => {
        const options = satellite.userData;
        const reveal = clamp((frame - 0.45 - options.index * 0.1) / 0.7);
        const angle = options.angle + frame * options.speed;
        satellitePosition
          .set(
            Math.cos(angle) * options.radius,
            0,
            Math.sin(angle) * options.radius,
          )
          .applyEuler(options.euler);
        satellitePosition.y +=
          Math.sin(frame * 0.8 + options.phase) * options.bob;
        satellite.position.copy(satellitePosition);
        satellite.lookAt(cameraWorld);
        satellite.scale.setScalar(0.0001 + easeOut(reveal));
        satellite.material.opacity = reveal * options.maxOpacity;
        if (options.line) {
          options.line.material.opacity =
            easeOut(reveal) * options.line.userData.baseOpacity;
        }
      });

      nebulas.forEach((nebula) => {
        nebula.material.opacity =
          nebula.userData.baseOpacity *
          (0.7 + 0.3 * Math.sin(frame * 0.4 + nebula.userData.phase));
      });
      easedPointer.x += (pointer.x - easedPointer.x) * 0.05;
      easedPointer.y += (pointer.y - easedPointer.y) * 0.05;
      camera.position.x = easedPointer.x * 0.7;
      camera.position.y = easedPointer.y * 0.48;
      camera.position.z = 8.6 + (1 - easeOut(intro)) * 1.4;
      camera.lookAt(camera.position.x, 0, 0);
      glint.position.set(
        Math.cos(frame * 0.45) * 4.8,
        Math.sin(frame * 0.45) * 3.2 + 0.6,
        5.6,
      );
      renderer.render(scene, camera);
      raf = window.requestAnimationFrame(animate);
    }

    resize();
    window.addEventListener("resize", resize);
    raf = window.requestAnimationFrame(animate);

    return () => {
      disposed = true;
      window.removeEventListener("resize", resize);
      window.removeEventListener("pointermove", onPointerMove);
      window.cancelAnimationFrame(raf);
      scene.traverse((object) => {
        if (object.geometry) object.geometry.dispose();
        if (object.material) {
          if (Array.isArray(object.material)) {
            object.material.forEach((material) => material.dispose());
          } else {
            object.material.dispose();
          }
        }
      });
      textureDisposables.forEach((texture) => texture.dispose());
      renderer.dispose();
    };
  }, [ready, icons, colors ? colors.join() : ""]);

  if (!ready) {
    return (
      <div
        className="pointer-events-none absolute right-[9%] top-1/2 z-[1] aspect-square w-[clamp(180px,22vw,300px)] -translate-y-1/2 rounded-3xl bg-cover bg-center"
        style={{
          backgroundImage: "url('assets/captixy-logo.png')",
          boxShadow: `0 40px 130px -20px rgba(var(--accent-rgb),0.65)`,
          animation: "captixyFloat 8s ease-in-out infinite",
        }}
        aria-hidden="true"
      />
    );
  }

  return (
    <div
      ref={wrapRef}
      className="pointer-events-none absolute inset-0 z-[1] overflow-hidden"
      aria-hidden="true"
    >
      <canvas ref={canvasRef} className="absolute inset-0 h-full w-full" />
    </div>
  );
}

/* Estilos partilhados do hero (grelha a deslizar, indicador de scroll). */
function CaptixyHeroStyles() {
  return (
    <style>{`
      .cx3d-grid {
        background-image: linear-gradient(rgba(255,255,255,.022) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.022) 1px, transparent 1px);
        background-size: 60px 60px;
        animation: captixyGridDrift 16s linear infinite;
      }
      @keyframes captixyGridDrift { to { background-position: 60px 60px; } }
      @keyframes captixyFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-20px); } }
      @keyframes captixyScrollDot { 0% { transform: translateY(0); opacity: 0; } 30%, 80% { opacity: 1; } 100% { transform: translateY(44px); opacity: 0; } }
      .cx3d-scroll-dot { animation: captixyScrollDot 2s ease-in-out infinite; }
      @media (prefers-reduced-motion: reduce) { .cx3d-grid, .cx3d-scroll-dot { animation: none; } }
    `}</style>
  );
}

/* Palavra que roda por cima do título (igual ao hero do Websites). */
function CaptixyRotatingWord({ words, interval = 2200, colors = null }) {
  const { motion: rm, AnimatePresence: RAP } = FramerMotion;
  const [index, setIndex] = React.useState(0);
  React.useEffect(() => {
    if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return undefined;
    const timer = setInterval(() => setIndex((v) => (v + 1) % words.length), interval);
    return () => clearInterval(timer);
  }, [words.length, interval]);
  return (
    <div className="relative h-5 w-[min(360px,72vw)] overflow-hidden">
      <RAP mode="wait">
        <rm.span
          key={words[index]}
          initial={{ y: "105%", opacity: 0 }}
          animate={{ y: 0, opacity: 1 }}
          exit={{ y: "-105%", opacity: 0 }}
          transition={{ duration: 0.45, ease: [0.16, 1, 0.3, 1] }}
          className="absolute left-0 top-0 whitespace-nowrap text-xs font-bold uppercase tracking-[0.34em]"
          style={{ color: colors ? colors[index % colors.length] : "var(--orange)" }}
        >
          {words[index]}
        </rm.span>
      </RAP>
    </div>
  );
}

/* Indicador "Deslizar" no fundo do hero. */
function CaptixyScrollHint() {
  return (
    <div className="pointer-events-none absolute bottom-[clamp(20px,3.5vh,40px)] left-1/2 z-[3] hidden -translate-x-1/2 flex-col items-center gap-2.5 md:flex" aria-hidden="true">
      <span className="text-[10px] uppercase tracking-[0.3em] text-white/35">Deslizar</span>
      <div className="relative h-[42px] w-px overflow-hidden bg-white/10">
        <div className="cx3d-scroll-dot absolute left-0 top-0 h-3.5 w-px" style={{ background: "var(--orange)" }} />
      </div>
    </div>
  );
}

Object.assign(window, { CaptixyHero3D, CaptixyHeroStyles, CaptixyRotatingWord, CaptixyScrollHint });

/* Hero completo ao estilo do Websites: cena 3D, grelha a deslizar, título editorial,
   palavra que roda, três ações e indicador de scroll. As cores seguem o tema da página. */
function CaptixyProductHero({
  icons,
  words,
  title,
  titleEm,
  lead,
  primary,
  secondary = [],
  note,
  bg = "#070B1F",
  bgSoft = "#141A3A",
  ink = "#F7F8FF",
  primaryText = "#070B1F",
  id = "topo",
  colors = null,
  aurora = null,
  wordColors = null,
  emStyle = null,
  primaryBg = null,
}) {
  const { motion: hm } = FramerMotion;
  const ease = [0.16, 1, 0.3, 1];
  const rise = (delay, y = 28) => ({
    initial: { opacity: 0, y },
    animate: { opacity: 1, y: 0 },
    transition: { duration: 0.85, delay, ease },
  });
  return (
    <section
      id={id}
      className="relative flex min-h-[100svh] flex-col justify-center overflow-hidden px-[clamp(24px,4vw,56px)] pb-[clamp(110px,15vh,160px)] pt-[clamp(110px,14vh,150px)]"
      style={{ background: `radial-gradient(120% 90% at 80% 10%, ${bgSoft} 0%, ${bg} 55%)`, color: ink }}
    >
      <CaptixyHeroStyles />
      <div className="cx3d-grid pointer-events-none absolute inset-0" aria-hidden="true" />
      <div
        className="pointer-events-none absolute right-[-5%] top-[-10%] h-[46vw] max-h-[680px] w-[46vw] max-w-[680px] rounded-full"
        style={{ background: "radial-gradient(circle, rgba(var(--accent-rgb),0.18) 0%, transparent 68%)" }}
        aria-hidden="true"
      />
      {aurora && (
        <div className="pointer-events-none absolute inset-0" aria-hidden="true">
          {aurora.map(([c, pos], i) => (
            <div key={i} className="absolute h-[520px] w-[520px] rounded-full blur-[130px]" style={{ background: c, opacity: 0.22, ...pos }} />
          ))}
        </div>
      )}
      <CaptixyHero3D icons={icons} colors={colors} />
      <div
        className="pointer-events-none absolute inset-0 z-[2]"
        style={{ background: `linear-gradient(90deg, ${bg} 0%, ${bg}EB 24%, ${bg}8C 46%, ${bg}00 66%)` }}
        aria-hidden="true"
      />

      <div className="relative z-[3] ml-0 max-w-[1080px] md:ml-[clamp(24px,5vw,76px)]">
        <hm.div {...rise(0)} className="mb-[30px] flex items-center gap-4">
          <span className="inline-block h-px w-8" style={{ background: primaryBg || "var(--orange)" }} />
          <CaptixyRotatingWord words={words} colors={wordColors} />
        </hm.div>
        <hm.h1
          {...rise(0.08, 30)}
          className="serif m-0 max-w-[14ch] text-[clamp(50px,8.2vw,128px)] font-normal leading-[0.96] tracking-[-0.025em]"
          style={{ color: ink }}
        >
          {title}{" "}
          <em className="serif italic" style={emStyle || { color: "var(--orange-soft)" }}>{titleEm}</em>
        </hm.h1>
        <hm.p
          {...rise(0.18, 26)}
          className="mt-[34px] max-w-[560px] text-[clamp(16px,1.4vw,21px)] leading-[1.6]"
          style={{ color: `${ink}A6` }}
        >
          {lead}
        </hm.p>
        <hm.div {...rise(0.28, 24)} className="mt-10 flex flex-wrap gap-4">
          <a
            href={primary.href}
            className="inline-flex items-center gap-3 rounded-full px-7 py-[17px] text-sm font-semibold tracking-[0.03em] transition-all hover:-translate-y-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/80 focus-visible:ring-offset-2"
            style={{ background: primaryBg || "var(--orange)", color: primaryText, boxShadow: "0 20px 44px -14px rgba(var(--accent-rgb),0.65)" }}
          >
            {primary.label}
            <svg viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" className="h-4 w-4" aria-hidden="true"><path d="M3 8h10M9 4l4 4-4 4" /></svg>
          </a>
          {secondary.map((b, i) => (
            <a
              key={b.href}
              href={b.href}
              className={`inline-flex items-center gap-3 rounded-full border border-white/20 px-7 py-[17px] text-sm font-medium tracking-[0.03em] transition-all hover:-translate-y-1 hover:bg-white/[0.1] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/70 ${i === 0 ? "bg-white/[0.07]" : "bg-transparent"}`}
              style={{ color: ink }}
            >
              {b.label}
            </a>
          ))}
        </hm.div>
        {note && (
          <hm.div {...rise(0.38, 18)} className="mt-8 flex flex-wrap gap-x-6 gap-y-2 text-sm" style={{ color: `${ink}80` }}>
            {note}
          </hm.div>
        )}
      </div>
      <CaptixyScrollHint />
    </section>
  );
}

Object.assign(window, { CaptixyProductHero });
