---
const {
    title,
    description,
    date,
    image,
    slug,
    isDevMode = false,
    isHidden = false,
    tags = [],
    type = "personal",
} = Astro.props;

tags.sort();
---

<style>
    .project-item {
        border-color: var(--ayu-gutter-dim);
        transition:
            color 0.2s,
            border-color 0.2s;
    }
    .project-item:hover {
        border-color: var(--ayu-gutter);
    }
    .project-title {
        color: var(--ayu-accent);
    }
    .project-description {
        color: var(--ayu-fg);
    }
    .project-date {
        color: var(--ayu-gutter);
    }
    .project-item:hover .project-date {
        color: var(--ayu-accent);
    }
    .project-item.dev-hidden {
        transition: border 0.2s;
        border: 1px dashed var(--ayu-accent);
    }
    .project-item.dev-hidden:hover {
        border: 1px solid var(--ayu-accent);
    }
</style>

<a
    href={`/projects/${slug}`}
    class={`project-item block border-2 flex flex-col justify-between rounded-md ${isDevMode && isHidden ? "dev-hidden" : ""}`}
    data-tags={tags.join(",")}
>
    <div class="flex gap-4 p-4 pb-0">
        <div class="w-16 h-16 flex-shrink-0">
            {
                image ? (
                    <img
                        src={image}
                        alt={`${title} icon`}
                        class="w-full h-full object-cover rounded"
                    />
                ) : (
                    <div class="w-full h-full border border-ayu-gutter rounded" />
                )
            }
        </div>
        <div class="flex flex-col gap-2">
            <h3 class="project-title text-lg font-500 -mb-2 -mt-1">
                {title}
            </h3>
            <p class="project-description text-sm">
                {description}
            </p>
            {
                tags && tags.length > 0 && (
                    <div class="flex gap-1.5 text-xs flex-wrap leading-3 items-center mb-1 no-select">
                        {tags.map((tag: string, idx: number) => (
                            <span class="project-tag flex items-center text-ayu-fg font-500 rounded-md border border-ayu-gutter px-1.5 py-0.5">
                                {tag}
                            </span>
                        ))}
                    </div>
                )
            }
        </div>
    </div>
    <div class="w-full flex justify-end p-2 pt-1">
        <p class="project-date text-xs">{date}</p>
    </div>
</a>
