<script setup lang="ts">
import HomeStarField from './HomeStarField.vue'

type WinnerCard = {
  categoryGroup: string
  category: string
  name: string
  handle: string
  platform: string
  url: string
  clipUrl: string | null
  clipTitle: string
  clipPlatform: string
  clipEmbedUrl: string | null
  clipEmbedTitle: string
  hasClip: boolean
}

defineProps<{
  winnerShowcaseYear: number
  winnerShowcase: WinnerCard[]
  initialsFor: (value: string) => string
  onOpenArchive: () => Promise<void>
}>()
</script>

<template>
  <section id="nominierte" class="home-winner-section">
    <HomeStarField :count="17" variant="light" />
    <div class="home-section home-winner-section__inner">
      <div class="home-winner-section__header">
        <div>
          <div class="home-winner-section__eyebrow">&#9733; Die Stars</div>
          <h2 class="home-winner-section__title">Gewinner {{ winnerShowcaseYear }}</h2>
        </div>
        <button
          type="button"
          class="home-winner-section__archive-button"
          style-hover="transform:translateY(-2px);background:rgba(255,255,255,.09);"
          @click="onOpenArchive"
        >
          Archiv ansehen &rarr;
        </button>
      </div>

      <div v-if="winnerShowcase.length > 0" class="home-winner-rail">
        <div class="home-winner-track">
          <article
            v-for="winner in winnerShowcase"
            :key="`${winnerShowcaseYear}-${winner.category}-${winner.handle}`"
            class="home-winner-card"
          >
            <div class="home-winner-card__spotlight">
              <div class="home-winner-card__portrait" aria-hidden="true">
                {{ initialsFor(winner.name) }}
              </div>
              <div class="home-winner-card__status">Gewinner</div>
              <div class="home-winner-card__plaque">
                <div class="home-winner-card__category">{{ winner.categoryGroup }}</div>
                <h3 class="home-winner-card__name">{{ winner.name }}</h3>
                <p class="home-winner-card__subcategory">{{ winner.category }}</p>
              </div>
            </div>

            <div class="home-winner-card__actions">
              <a
                :href="winner.url"
                target="_blank"
                rel="noopener noreferrer"
                class="home-winner-card__profile"
              >
                {{ winner.platform }}
              </a>
            </div>
          </article>
        </div>
      </div>

      <div v-else class="home-winner-empty">
        <div class="home-winner-empty__badge">&#9733;</div>
        <div>
          <h3>Noch keine Gewinner veröffentlicht</h3>
          <p>Sobald ein Award-Jahr im Adminbereich freigegeben ist, erscheinen die Gewinner hier.</p>
        </div>
      </div>
    </div>
  </section>
</template>

<style scoped>
.home-winner-section{
  position:relative;
  overflow:hidden;
  border-top:1px solid rgba(255,255,255,.12);
  border-bottom:1px solid rgba(255,255,255,.12);
  background:
    radial-gradient(circle at 20% 12%,rgba(255,95,162,.16),transparent 30%),
    radial-gradient(circle at 82% 24%,rgba(201,177,255,.18),transparent 34%),
    linear-gradient(115deg,#241640 0%,#3a2168 48%,#5b3aa0 100%);
}

.home-winner-section__inner{
  position:relative;
  z-index:1;
  max-width:1200px;
  margin:0 auto;
  padding:90px 24px;
}

.home-winner-section__header{
  display:flex;
  flex-wrap:wrap;
  align-items:flex-end;
  justify-content:space-between;
  gap:20px;
  margin-bottom:46px;
}

.home-winner-section__eyebrow{
  margin-bottom:12px;
  color:#ff5fa2;
  font-size:13px;
  font-weight:700;
  letter-spacing:1.5px;
  text-transform:uppercase;
}

.home-winner-section__title{
  margin:0;
  color:#fff6fb;
  font-family:'Fredoka',sans-serif;
  font-size:clamp(32px,4vw,48px);
  font-weight:700;
  letter-spacing:0;
}

.home-winner-section__archive-button{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  min-height:48px;
  padding:12px 22px;
  border:1px solid rgba(255,255,255,.12);
  border-radius:999px;
  background:rgba(255,255,255,.05);
  color:#fff6fb;
  cursor:pointer;
  font-family:'Outfit',sans-serif;
  font-size:15px;
  font-weight:700;
  transition:transform .18s ease, background .18s ease, border-color .18s ease;
}

.home-winner-rail{
  overflow-x:auto;
  overflow-y:hidden;
  padding:0 18px 14px 0;
  scroll-padding-left:0;
  scrollbar-color:rgba(255,255,255,.34) rgba(255,255,255,.06);
  scrollbar-width:thin;
}

.home-winner-track{
  display:flex;
  gap:24px;
  width:max-content;
  scroll-snap-type:x mandatory;
}

.home-winner-card{
  flex:none;
  width:374px;
  min-height:478px;
  display:flex;
  flex-direction:column;
  justify-content:space-between;
  border:1px solid rgba(255,255,255,.13);
  border-radius:28px;
  background:
    radial-gradient(circle at 22% 15%,rgba(255,95,162,.14),transparent 30%),
    radial-gradient(circle at 82% 84%,rgba(160,107,255,.17),transparent 32%),
    linear-gradient(180deg,rgba(47,29,68,.96),rgba(34,21,50,.98));
  box-shadow:0 24px 62px rgba(16,7,32,.28);
  overflow:hidden;
  scroll-snap-align:start;
  scroll-snap-stop:always;
}

.home-winner-card__spotlight{
  position:relative;
  display:grid;
  min-height:372px;
  place-items:center;
  padding:28px 26px 34px;
}

.home-winner-card__portrait{
  display:grid;
  place-items:center;
  width:min(248px,100%);
  aspect-ratio:1;
  border-radius:34%;
  color:#3a2d30;
  background:
    radial-gradient(circle at 32% 28%,rgba(255,244,203,.78),transparent 24%),
    linear-gradient(145deg,#ffe39a 0%,#f4bf4f 58%,#d6a342 100%);
  box-shadow:
    0 24px 58px rgba(0,0,0,.28),
    inset 0 1px 0 rgba(255,255,255,.46),
    inset 0 -12px 26px rgba(114,71,0,.12);
  font-family:'Fredoka',sans-serif;
  font-size:64px;
  font-weight:800;
  letter-spacing:0;
}

.home-winner-card__status{
  position:absolute;
  right:22px;
  top:28px;
  padding:7px 12px;
  border:1px solid rgba(255,255,255,.14);
  border-radius:999px;
  color:#ffd27a;
  background:rgba(23,12,36,.48);
  font-size:11px;
  font-weight:900;
  letter-spacing:.14em;
  text-transform:uppercase;
}

.home-winner-card__plaque{
  position:absolute;
  left:50%;
  bottom:22px;
  width:min(236px,calc(100% - 48px));
  padding:10px 14px 11px;
  border:1px solid rgba(255,210,122,.24);
  border-radius:8px;
  background:linear-gradient(180deg,rgba(58,28,92,.96),rgba(40,19,65,.98));
  box-shadow:0 18px 36px rgba(14,6,27,.34);
  text-align:center;
  transform:translateX(-50%);
}

.home-winner-card__category{
  color:#ffd27a;
  font-size:10px;
  font-weight:900;
  letter-spacing:.13em;
  line-height:1.15;
  text-transform:uppercase;
}

.home-winner-card__name{
  margin:4px 0 0;
  color:#fff6fb;
  font-family:'Fredoka',sans-serif;
  font-size:22px;
  font-weight:700;
  letter-spacing:0;
  line-height:1.05;
  overflow-wrap:anywhere;
}

.home-winner-card__subcategory{
  margin:4px 0 0;
  color:#d9c9ee;
  font-size:13px;
  font-weight:800;
  line-height:1.2;
  overflow-wrap:anywhere;
}

.home-winner-card__actions{
  display:grid;
  gap:10px;
  padding:0 26px 26px;
}

.home-winner-card__profile{
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:48px;
  padding:12px 18px;
  border-radius:15px;
  font-family:'Fredoka',sans-serif;
  font-size:14px;
  font-weight:700;
  text-align:center;
  text-decoration:none;
  transition:transform .18s ease, opacity .18s ease, border-color .18s ease;
}

.home-winner-card__profile{
  color:#fff;
  background:linear-gradient(135deg,#d36fa7,#a06bff);
  box-shadow:0 16px 34px rgba(123,76,196,.26);
}

.home-winner-card__profile:hover{
  opacity:.92;
  transform:translateY(-2px);
}

.home-winner-empty{
  display:flex;
  align-items:center;
  gap:18px;
  max-width:720px;
  padding:24px;
  border:1px solid rgba(255,255,255,.12);
  border-radius:24px;
  color:#fff6fb;
  background:rgba(32,17,50,.62);
  box-shadow:0 22px 54px rgba(16,7,32,.22);
}

.home-winner-empty__badge{
  flex:none;
  display:grid;
  place-items:center;
  width:58px;
  height:58px;
  border-radius:20px;
  color:#3a2d30;
  background:linear-gradient(145deg,#ffe39a,#e7b13e);
  font-size:24px;
}

.home-winner-empty h3{
  margin:0 0 5px;
  font-family:'Fredoka',sans-serif;
  font-size:24px;
}

.home-winner-empty p{
  margin:0;
  color:#d9c9ee;
  font-size:15px;
  line-height:1.5;
}

@media (max-width:720px){
  .home-winner-section__inner{
    padding:72px 16px;
  }

  .home-winner-section__header{
    align-items:flex-start;
    margin-bottom:34px;
  }

  .home-winner-section__archive-button{
    width:100%;
  }

  .home-winner-rail{
    margin-right:-16px;
    padding-right:16px;
  }

  .home-winner-track{
    gap:16px;
  }

  .home-winner-card{
    min-height:430px;
    border-radius:24px;
  }

  .home-winner-card__spotlight{
    min-height:324px;
    padding:24px 22px 30px;
  }

  .home-winner-card__portrait{
    width:min(218px,100%);
    font-size:54px;
  }

  .home-winner-card__status{
    right:18px;
    top:22px;
  }

  .home-winner-card__actions{
    padding:0 22px 22px;
  }

  .home-winner-empty{
    align-items:flex-start;
    padding:20px;
  }
}
</style>
