<script setup lang="ts">
/** iPhone-Mockup mit Auto-Platzhalter, wenn die PNG fehlt. */
const props = defineProps<{
  file: string
  title: string
  icon: string
  width?: string
}>()
const failed = ref(false)
</script>

<template>
  <div
    class="relative shrink-0 rounded-[2.4rem] bg-gray-900 border border-white/10 p-2 shadow-2xl shadow-primary-950/40"
    :style="{ width: props.width || '240px' }"
  >
    <div
      class="absolute top-3.5 left-1/2 -translate-x-1/2 w-16 h-4 bg-black rounded-full z-10"
    />
    <div class="rounded-[1.9rem] overflow-hidden bg-black aspect-[9/19.5]">
      <img
        v-if="!failed"
        :src="`/preview/${props.file}`"
        :alt="props.title"
        class="w-full h-full object-cover"
        loading="lazy"
        @error="failed = true"
      />
      <div
        v-else
        class="w-full h-full flex flex-col items-center justify-center gap-2.5 bg-linear-to-b from-gray-900 to-gray-950 px-4 text-center"
      >
        <div
          class="w-11 h-11 rounded-2xl bg-primary-500/15 flex items-center justify-center"
        >
          <UIcon :name="props.icon" class="text-primary-400 text-xl" />
        </div>
        <p class="text-[13px] font-bold text-highlighted leading-tight">{{ props.title }}</p>
        <p class="text-[10px] text-muted leading-snug">
          Screenshot folgt<br />
          <span class="font-mono">preview/{{ props.file }}</span>
        </p>
      </div>
    </div>
  </div>
</template>
