<script lang="ts">
    export interface GalleryEntry {
        title: string;
        subtitle: string;
        img: string;
        imgAlt: string;
        link: string;
        description: string;
    }

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

<div class="post-list">
    {#each entries as entry}
        {@render galleryEntry({entry})}
    {/each}
</div>

{#snippet galleryEntry({entry}: {entry: GalleryEntry})}
    <a class="gallery-container" href="{entry.link}">
        {#if entry.img && entry.img !== ""}
            <img class="gallery-img" src="{entry.img}" alt="{entry.imgAlt}">
        {:else}
            <div class="gallery-img-placeholder"></div>
        {/if}
        <div class="gallery-text-container">
            <p class="gallery-subtitle">{@html entry.subtitle}</p>
            <p class="gallery-title">{entry.title}</p>
            <p class="gallery-description">{entry.description}</p>
        </div>
    </a>
{/snippet}

<style>
    :root {
        --color-laura: #C76668CC;
        --color-laura-darker: #A55051CC;
    }

    .post-list {
        max-width: 1600px;
        margin-left: auto;
        margin-right: auto;
    }

    .gallery-container {
        box-sizing: content-box;
        height: 120px;
        display: flex;
        flex-direction: row;
        text-decoration: none;
        align-items: center;
        margin: 0;
        justify-content: center;
        border: var(--border-style) transparent var(--border-dash-size);
        transition: border-color var(--duration-animation) var(--anim-curve);
    }

    .gallery-img, .gallery-img-placeholder {
        width: 180px;
        min-width: 180px;
        height: 100%;
        margin: 0;
        object-fit: cover;
        transition: width var(--duration-animation) var(--anim-curve);
    }

    .gallery-img-placeholder {
        background-color: var(--color-highlight-dark);
    }

    .gallery-text-container {
        display: grid;
        grid-auto-columns: 1fr;
        grid-template-rows: 1fr 1fr 0fr;
        align-items: center;
        flex-grow: 1;
        padding: 0 16px;
        transition: background-color var(--duration-animation) var(--anim-curve),
                    backdrop-filter var(--duration-blur) var(--anim-curve),
                    grid-template-rows var(--duration-blur) var(--anim-curve);
    }

    .gallery-title, .gallery-subtitle, .gallery-description {
        margin: 0;
        transition: color var(--duration-animation) var(--anim-curve),
                    opacity var(--duration-animation) var(--anim-curve);
    }

    .gallery-title {
        font-family: var(--font-mono);
        font-weight: 700;
    }

    .gallery-subtitle, .gallery-description {
        font-size: 1.0rem;
        line-height: 1.2rem;
        overflow: hidden;
    }

    .gallery-description {
        font-weight: 500;
        opacity: 0;
    }

    .gallery-container:hover {
        border-color: var(--color-highlight);
        background-color: var(--color-background-highlight);
        backdrop-filter: blur(var(--blur-radius-background));
    }
    .gallery-container:hover p {
        color: var(--color-highlight);
    }

    @media screen and (min-width: 800px) {
        .gallery-title {
            font-size: 1.4rem;
            line-height: 2.0rem;
        }

        .gallery-container:hover .gallery-img, .gallery-container:hover .gallery-img-placeholder {
            width: 260px;
        }

        .gallery-container:hover .gallery-text-container {
            grid-template-rows: 0fr 1fr 1fr;
        }

        .gallery-container:hover .gallery-subtitle {
            opacity: 0;
            
        }

        .gallery-container:hover .gallery-description {
            opacity: 1;
        }
    }
    @media screen and (max-width: 800px) {
        .gallery-title {
            font-size: 1.0rem;
            line-height: 1.1rem;
        }

        .gallery-description {
            display: none;
        }

        .gallery-subtitle {
            font-size: 0.8rem;
            line-height: 1rem;
            /* display: none; */
        }
        
        .gallery-container {
            height: 72px;
        }

        .gallery-text-container {
            padding-left: 8px;
        }
        
        .gallery-img, .gallery-img-placeholder {
            width: 110px;
            min-width: 110px;
        }
    }
</style>