<script lang="ts">
    export interface LinkRowEntry {
        title: string;
        description: string;
        img: string;
        latestUpdate?: string;
        altText: string;
        link: string;
    }

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

<div class="row-container">
    {#each entries as entry}
        <a class="row-entry blurred-background-hover" href="{entry.link}">
            <div class="row-img-container">
                <img class="row-img" src="{entry.img}" alt="{entry.altText}">
            </div>
            <div class="row-text-container">
                <p class="row-title">&gt; {entry.title}</p>
                <p class="row-description">{@html entry.description}</p>
                {#if entry.latestUpdate}
                    <p class="row-updated">updated: <span class="row-updated-date">{entry.latestUpdate}</span></p>
                {/if}
            </div>
        </a>
    {/each}
</div>

<style>
    .row-container {
        display: flex;
        flex-direction: row;
    }

    .row-entry {
        flex: 1 1 0px;
        box-sizing: border-box;
        margin: 0;
        padding: 8px;
        text-decoration: none;
        border-radius: var(--border-radius);
        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: var(--border-dash-size) var(--border-style) transparent;
    }

    .row-entry:hover {
        background-color: var(--color-background-highlight);
        border-color: var(--color-highlight);
    }

    .row-entry:hover .row-img {
        scale: 1.2;
    }

    .row-entry:hover .row-img-container {
        border-top-left-radius: calc(var(--border-radius) - 8px);
        border-top-right-radius: calc(var(--border-radius) - 8px);
    }

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

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

    .row-text-container {
        margin-top: 8px;
        margin-bottom: 4px;
    }

    .row-title {
        font-family: var(--font-mono);
        font-weight: 700;
        color: var(--color-highlight);
        margin: 0;
    }

    .row-description {
        font-size: 1.0rem;
        line-height: 1.3rem;
        margin: 0;
    }

    .row-updated, .row-updated-date {
        font-size: 0.9rem;
        line-height: 1.2rem;
        margin: 0;
        font-style: italic;
        width: fit-content;
        transition: color var(--duration-animation) var(--anim-curve),
                    background-color var(--duration-animation) var(--anim-curve);
    }

    .row-updated {
        margin-top: 2px;
        padding: 4px 8px;
        font-weight: 500;
        background-color: var(--color-background-highlight);
        border-radius: var(--border-radius);
    }

    .row-entry:hover .row-updated {
        color: var(--color-text-dark);
        background-color: var(--color-highlight);
    }

    .row-updated-date {
        font-weight: 600;
    }

    .row-entry:hover .row-updated-date {
        color: var(--color-text-dark);
    }

    @media screen and (max-width: 600px) {
        .row-container {
            flex-direction: column;
        }
    }
</style>