<template>
  <div class="absolute inset-0 pointer-events-none overflow-hidden">
    <div
      class="absolute inset-0 transition-transform duration-100 xParallax"
      data-parallax-speed="0.4"
      :style="{
        opacity: opacity,
        backgroundImage: patternSvg
      }"
    />
    <div class="absolute top-0 left-0 right-0 h-32 bg-gradient-to-b from-[#0a0a0a] to-transparent z-10" />
    <div class="absolute bottom-0 left-0 right-0 h-32 bg-gradient-to-t from-[#0a0a0a] to-transparent z-10" />
  </div>
</template>

<script setup>
const props = defineProps({
  /** Pattern opacity (0-1) */
  opacity: {
    type: Number,
    default: 0.35,
  },
  /** Primary pattern color */
  color: {
    type: String,
    default: '#164e63',
  },
  /** Secondary pattern color */
  colorSecondary: {
    type: String,
    default: '#1e3a8a',
  },
})

const patternSvg = computed(() => {
  const encodedColor = encodeURIComponent(props.color)
  const encodedColorSecondary = encodeURIComponent(props.colorSecondary)
  return `url('data:image/svg+xml,%3Csvg width="100" height="100" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"%3E%3Cpattern id="circuit" x="0" y="0" width="100" height="100" patternUnits="userSpaceOnUse"%3E%3Cpath d="M0 50 H30 V20 H50" fill="none" stroke="${encodedColor}" stroke-width="1"/%3E%3Cpath d="M50 80 V50 H80 V30" fill="none" stroke="${encodedColorSecondary}" stroke-width="1"/%3E%3Ccircle cx="30" cy="50" r="3" fill="${encodedColor}"/%3E%3Ccircle cx="50" cy="20" r="3" fill="${encodedColor}"/%3E%3Ccircle cx="50" cy="80" r="3" fill="${encodedColorSecondary}"/%3E%3Ccircle cx="80" cy="30" r="3" fill="${encodedColorSecondary}"/%3E%3C/pattern%3E%3Crect width="100" height="100" fill="url(%23circuit)"/%3E%3C/svg%3E')`
})
</script>

