<template>
  <div>
  <div class="relative w-full">
    <div class="absolute inset-0 z-0">
        <UCarousel
            v-slot="{ item }"
            :items="c.landing.welcome.images"
            :ui="{item: 'basis-full h-full ps-0', container: 'flex items-stretch h-full'}"
            :autoplay="{ delay: 5000 }"
            :loop="true"
            :fade="true"
            :duration="150"
            class="w-full h-full custom-carousel">
          <div class="w-full h-full flex items-center justify-center">
            <img :src="item" class="w-full h-full object-cover" alt="Demo Picture"/>
          </div>
        </UCarousel>
    </div>

    <div class="absolute inset-0 z-5 bg-black/60"/>

    <div class="relative z-10">
      <AppStripe class="text-white py-4 sm:py-8 lg:py-16">
        <div class="flex flex-col md:flex-row py-6 gap-4 sm:gap-8 lg:gap-16">
          <div class="flex flex-col">
            <div>
            <h1 class="text-5xl max-w-4xl font-bold">{{ c.landing.welcome.title }}</h1>
            <p class="mt-4 text-lg">
              {{
                c.landing.welcome.description
              }}
            </p>
            </div>
            <div class="mt-8 flex gap-4 flex-wrap">
              <UButton :to="p('apartments')" color="primary" variant="solid" size="xl"
                       trailing-icon="i-heroicons-arrow-right">{{ c.button.apartments }}
              </UButton>
              <UButton :to="p('book')" color="secondary" variant="solid" size="xl"
                       trailing-icon="i-heroicons-calendar-days">
                {{ c.button.book }}
              </UButton>
              <UButton :to="p('contact')" color="secondary" variant="solid" size="xl"
                       trailing-icon="i-heroicons-envelope">
                {{ c.button.contact }}
              </UButton>
            </div>
          </div>
          <div v-if="c.landing.welcome.joker === true" class="flex items-center justify-center p-8">
            <a href="https://www.saalbach.com/de/sommer/joker-card">
            <NuxtImg
                src="/joker-card.webp"
                alt="Joker Card"
                class="w-30 md:w-50 transform rotate-15"
                style="border-radius: .5rem"
            />
            </a>
          </div>
        </div>
      </AppStripe>
    </div>
  </div>

  <AppFlatSection>
    <div class="flex flex-col md:flex-row items-center gap-4">
      <!-- Left: Image Group -->
      <div class="flex flex-row gap-4 justify-center relative">
        <img :src="c.landing.highlight.image.left" alt="Image 1" class="w-40 h-60 object-cover"/>
        <img :src="c.landing.highlight.image.right" class="w-40 h-60 object-cover mt-6" />
      </div>

      <!-- Right: Text Content -->
      <AppTitleText :title="c.landing.highlight.title" :text="c.landing.highlight.description">
        <UButton :to="p('contact', 'hosts')" color="primary" variant="solid" size="xl"
                 trailing-icon="i-heroicons-arrow-right">
          {{
            c.button.hosts
          }}
        </UButton>
      </AppTitleText>
    </div>
  </AppFlatSection>

  <AppCardSection>
    <div class="flex flex-col md:flex-row items-center gap-4">

      <!-- Left: Text (40%) -->
      <div class="basis-2/5 pr">
        <AppTitleText :title="c.landing.location.title" :text="c.landing.location.description">
          <UButton to="https://maps.app.goo.gl/FtTC8ervoBCnfU3j7" color="primary" variant="solid" size="xl"
                   trailing-icon="i-heroicons-arrow-right">
            {{ c.button.map }}
          </UButton>
        </AppTitleText>
      </div>

      <!-- Right: Image (60%) -->
      <a
          href="https://maps.app.goo.gl/FtTC8ervoBCnfU3j7"
          class="basis-3/5 flex justify-center overflow-hidden group"
          aria-label="Google Maps öffnen"
      >
        <img
            :src="c.landing.location.image"
            alt="Vorschaubild der Lage in Google Maps"
            class="w-full h-80 object-cover transition-transform duration-300 ease-out group-hover:scale-110"
        />
      </a>

    </div>
  </AppCardSection>

  <AppFlatSection>
    <AppTitleText :title="c.landing.apartments.title" :text="c.landing.apartments.description">
      <div class="flex flex-wrap gap-4 justify-center">

        <NuxtLink v-for="apartment in c.apartments.list" :to="p('apartments', apartment.id)"
           class="relative group block w-60 h-80 overflow-hidden">
          <img :src="apartment.thumbnail" alt="Image 1"
               class="w-full h-full object-cover transition-transform duration-300 ease-out group-hover:scale-110"/>
          <div class="absolute inset-0 bg-black/50"></div>
          <div
              class="absolute inset-0 flex items-center justify-center text-white text-lg font-semibold drop-shadow-md">
            <div class="text-center">
              <h2>{{ apartment.title }}</h2>
              <ul>
                <li v-for="highlight in apartment.highlights" class="text-sm">{{ highlight }}</li>
              </ul>
            </div>
          </div>
        </NuxtLink>
      </div>
    </AppTitleText>
  </AppFlatSection>

  <AppCardSection>
    <div class="flex-1 pr">
      <h2 class="text-2xl font-bold mb-4">
        {{ c.landing.features.title }}
      </h2>

      <p class="text-lg pb-4">
        {{ c.landing.features.description1 }}
        <UButton to="https://www.bruendl.at/" variant="outline" trailing-icon="i-heroicons-arrow-right">{{
            c.landing.features.description2
          }}
        </UButton>
        {{ c.landing.features.description3 }}
      </p>

      <AppFeaturesGrid :features="c.landing.features.list"/>
    </div>
  </AppCardSection>
  </div>
</template>

<style scoped>
/* TODO this is somewhat hacky, but currently no other way to style carousel inner wrapper */
:deep(.custom-carousel > .overflow-hidden) {
  height: 100%;
}
</style>

<script setup lang="ts">
const {p, c} = useContent()
</script>
<script setup lang="ts">
</script>