<script lang="ts">
    import { BlogPostTag, type BlogPostLink } from "../../routes/blog/posts";

    let {
        posts,
    }: {
        posts: BlogPostLink[];
    } = $props();
</script>

<div class="entry-container">
    {#each posts as post}
        <a class="entry" href="{post.key}">
            <div class="entry-banner-container">
                <img class="entry-banner" src="{post.key}/{post.post.banner}" alt="{post.post.bannerAlt}">
            </div>
            <div class="entry-text-container">
                <p class="entry-title">{post.post.title}</p>
                <p class="entry-date">
                    ::&nbsp;{post.post.date}
                    {#if post.post.dateUpdated}
                        // {post.post.dateUpdated}
                    {/if}
                </p>
                <p class="entry-description">{post.post.description}</p>
                <div class="entry-tag-container">
                    {#each post.post.tags as tag}
                        <span class="post-tag">{tag}</span>
                    {/each}
                </div>
            </div>
        </a>
    {/each}
</div>

<style>
    .entry-container {
        display: grid;
        /* gap: 8px; */
        grid-template-columns: 1fr 1fr 1fr;
    }

    .entry {
        margin: 0;
        padding: 8px;
        transition: background-color var(--duration-animation) var(--anim-curve),
                    border-color var(--duration-animation) var(--anim-curve),
                    backdrop-filter var(--duration-blur) var(--anim-curve),
                    border-radius var(--duration-animation) var(--anim-curve);
        border: var(--border-dash-size) var(--border-style) transparent;
        text-decoration: none;
        border-radius: var(--border-radius);
    }

    .entry:hover {
        background-color: var(--color-background-highlight-alt);
        border-color: var(--color-highlight-alt);
        backdrop-filter: blur(var(--blur-radius-background));
    }

    .entry:hover .entry-banner {
        scale: 1.2;
    }

    .entry:hover .entry-banner-container {
        /* border-radius: 24px 24px 0 0; */
        border-top-left-radius: calc(var(--border-radius) - 8px);
        border-top-right-radius: calc(var(--border-radius) - 8px);
        border-bottom-left-radius: 4px;
        border-bottom-right-radius: 4px;
    }

    .entry-banner-container {
        width: 100%;
        height: 160px;
        overflow: hidden;
        display: flex;
        justify-content: center;
        transition: border-radius var(--duration-animation) var(--anim-curve);
    }

    .entry-banner {
        width: 100%;
        object-fit: cover;
        transition: scale var(--duration-animation) var(--anim-curve);
    }

    .entry-text-container {
        display: flex;
        flex-direction: column;
        margin: 16px 2px 2px;
        /* gap: 8px; */
    }

    .entry-title {
        font-family: var(--font-mono);
        font-weight: 700;
        font-size: 1.2rem;
        line-height: 1.4rem;
        margin: 0;
    }

    .entry-date {
        font-size: 0.8rem;
        line-height: 0.8rem;
        font-weight: 600;
        margin: 4px 0 0 0;
        font-family: var(--font-mono);
        color: var(--color-text-highlight-alt);
    }

    .entry-description {
        font-size: 1.0rem;
        line-height: 1.3rem;
        margin: 4px 0 8px;
    }

    .entry-tag-container {
        display: flex;
        gap: 4px;
        flex-direction: row;
        flex-wrap: wrap;
    }

    @media screen and (max-width: 900px) {
        .entry-container {
            grid-template-columns: 1fr 1fr;
        }
    }

    @media screen and (max-width: 600px) {
        .entry-container {
            grid-template-columns: 1fr;
        }
    }
</style>