<script setup lang="ts">
defineProps({
    name: String,
    photo: String,
    blurb: String,
    slide: String,
    position: {
        type: String,
        default: undefined
    },
    photoSide: {
        type: String as () => 'left' | 'right',
        default: 'left'
    }
});
</script>

<template>
    <article v-hover="{ transform: 'translateY(-8px) rotate(0deg) scale(1.02)'}" class="profile-card" v-show-on-intersect="{type: 'slide-'+slide}">
        <div :class="['profile-flex', photoSide === 'right' ? 'reverse' : '']">
            <div class="profile-image">
                <img class="profile-photo" :src="photo" :alt="'Photo of ' + name" />
            </div>
            <div class="profile-body">
                <h3 class="profile-name">{{ name }}</h3>
                <p v-if="position" class="profile-position">{{ position }}</p>
                <p class="profile-blurb">{{ blurb }}</p>
            </div>
        </div>
    </article>
</template>

<style scoped>
.profile-card {
    cursor: pointer;
    background: var(--card);
    border-radius: 0;
    clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 20px, 100% 100%, 20px 100%, 0 calc(100% - 20px));
    padding: 1.25rem;
}

.profile-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 1.5s ease;
}

.profile-card:hover img {
    transform: scale(1.1);
}

.profile-flex {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-items: center;
}

.profile-flex.reverse {
    flex-direction: column-reverse;
}

@media (min-width: 768px) {
    .profile-flex {
        flex-direction: row;
        align-items: flex-start; /* align top for image and text */
    }

    .profile-flex.reverse {
        flex-direction: row-reverse;
    }
}

@media (max-width: 767px) {
    .profile-card {
        padding: 1rem;
    }

    /* Always photo above text on mobile */
    .profile-flex,
    .profile-flex.reverse {
        flex-direction: column !important;
    }
}

/* Make the text take remaining space */
.profile-body {
    padding: 0.5rem;
    flex: 1 1 0; /* allow body to grow */
}

.profile-image {
    position: relative;
    width: 100%;
    max-width: 320px; /* similar to your old grid column */
    aspect-ratio: 4 / 3;
    background: var(--muted);
    overflow: hidden;
    border: 1px solid var(--border);
    flex-shrink: 0;
    clip-path: polygon(
        50% 0%, 50% 0%,
        100% 25%, 100% 75%,
        50% 100%, 50% 100%,
        0% 75%, 0% 25%
    );
}

.profile-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.profile-name {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
    background: var(--gradient-adventure);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.profile-position {
    color: var(--muted-foreground);
    font-size: 0.95rem;
    letter-spacing: 0.2px;
    margin-bottom: 0.75rem;
    opacity: 0.9;
}

.profile-blurb {
    color: var(--muted-foreground);
    font-size: 1.0625rem;
    line-height: 1.7;
}
</style>
