<script setup lang="ts">
import type { FeedItem } from '@/feed'
import MediaInfo from './MediaInfo.vue'

const props = defineProps<{
  item: FeedItem
}>()
</script>

<template>
  <div
    class="scroller-item"
    :style="{
      width: `${320}px`,
    }"
  >
    <div class="scroller-item-img">
      <RouterLink :to="`/play/${item.itemId}`">
        <font-awesome-icon icon="fa-solid fa-play" class="play-icon"
      /></RouterLink>
      <RouterLink :to="`/item/${item.itemId}`">
        <img
          :src="props.item.image"
          alt=""
          :style="{
            width: `${320}px`,
          }"
      /></RouterLink>
      <div class="info-box">
        <div class="info-box-content">
          <div class="info-box-header">
            <RouterLink
              class="info-box-title clamp"
              :to="`/item/${props.item.seriesId}`"
              :key="props.item.seriesId"
              >{{ props.item.title }}</RouterLink
            >
            <div class="info-box-subtext">{{ props.item.infoSubtext }}</div>
          </div>
          <div class="info-box-summary clamp-4">{{ props.item.summary }}</div>
          <MediaInfo :item-id="item.itemId" size="sm" />
        </div>
      </div>
    </div>
    <RouterLink
      :to="`/item/${props.item.itemId}`"
      class="scroller-item-description"
      :key="props.item.itemId"
    >
      <div class="scroller-item-title clamp-2" :style="{ maxWidth: `${320 - 5}px` }">
        {{ props.item.title }}
      </div>
      <div class="scroller-item-subtext clamp" :style="{ maxWidth: `${320 - 5}px` }">
        {{ props.item.subtext }}
      </div></RouterLink
    >
  </div>
</template>

<style scoped>
.scroller-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 12px;
}
/* .scroller-item:hover {
  cursor: pointer;
} */

.play-icon {
  position: absolute;
  top: 65px;
  left: 115px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  z-index: 2;
  opacity: 0%;
  padding: 0.75em;
  background: rgba(0, 0, 0, 0.2);
  color: rgba(255, 255, 255, 0.5);
  border-radius: 16px;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  transition: background 10ms linear 0ms;
}
.play-icon:hover {
  background: rgba(122, 122, 122, 0.2);
}
.scroller-item-img:hover .play-icon {
  top: 98px;
  left: 192px;
  opacity: 100%;
  transition:
    all var(--hover-animation-speed) ease var(--hover-animation-delay),
    z-index 1ms,
    background 10ms linear 0ms;
  z-index: 5;
  visibility: visible;
}
.scroller-item-img {
  position: relative;
}
.scroller-item-img img {
  position: relative;
  background-size: cover;
  z-index: 1;
  transition-duration: 0.3s;
}
.scroller-item-img:hover img {
  transform: scale(1.35) translateX(42px) translateY(23px);
  cursor: pointer;
  transition:
    all var(--hover-animation-speed) ease,
    z-index 1ms;
  transition-delay: var(--hover-animation-delay);
  position: relative;
  z-index: 4;
}
.scroller-item-title {
  text-align: center;
}
.scroller-item-subtext {
  color: var(--color-text-faded);
  max-width: 245px;
  text-align: center;
}
.info-box {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 0;
  width: 320px;
  height: 180px;
  visibility: hidden;
  background-color: var(--color-background-grey);
  transition-duration: 0.3s;
}
.scroller-item-img:hover .info-box {
  visibility: visible;
  transform: translateX(432px);
  width: 340px;
  height: 243px;
  z-index: 3;
  transition:
    all var(--hover-animation-speed) ease var(--hover-animation-delay),
    z-index 1ms var(--hover-animation-delay);
}
.info-box-content {
  margin: 0 auto;
  padding: 1.5em;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: baseline;
  justify-content: space-between;
  gap: 1em;
  height: 100%;
  font-size: 13px;
}
.scroller-item-img:hover .info-box-content {
  max-height: 243px;
  transition-delay: 0.05s;
}
.info-box-title {
  font-weight: 600;
  font-size: 18px;
  color: var(--color-text);
  text-decoration: none;
}
.info-box-title:hover {
  text-decoration: underline;
}
.info-box-subtext {
  color: var(--color-text-faded);
}
.info-box-misc-info {
  display: flex;
  justify-content: space-between;
  min-width: 90%;
}
</style>
