<template>
    <div>
        <section class="bg-gradient-to-t bg3 shadow-2xl container-fluid">
            <div class="flex flex-col xl:flex-row container mx-auto xl:px-24">
                <div class="flex flex-col w-fit justify-center px-4 ">
                    <div v-if="page" class="">
                        <h1 class="text-blue-700 hero-text font-bold">Theme of the Month- <span class="text-color-1" v-if="page">{{page[0].theme_title}}</span></h1>
                        <div class="flex h2-text text-color-1 font-semibold pt-8">{{page[0].theme_text }}</div>
                        <div class="flex text-justify font-18px text-color-2 pt-4">{{page[0].theme_details }}</div> 
                    </div>
                </div>
                <div class="flex w-fit justify-center place-items-center">
                    <!-- <img class="w-full h-fit drop-shadow-2xl rounded-3xl py-4 cursor-none" src="/img/occassion1.png" alt=""> -->
                    <img class="w-fit h-fit" v-if="page" :src="'https://curriculum-app-api.beanstalkedu.com/assets/'+page[0].theme_hero_img" alt="">
                </div> 
            </div>
        </section>
        <!-- <div v-if="isLoading">
            <div class="flex justify-center ml-28 text-4xl animate-spin"><img class="w-32" src="/img/svg/loading.svg" alt=""></div>
                <h1 class="text-5xl text-center py-32">Loading.....</h1>
        </div>
        <div v-else></div> -->
                        <!-- section hero -->
        <!-- <section class="container-fluid">
            <div  class="flex place-items-center load-wraper">
                <img class="w-screen " v-if="page" :src="'https://curriculum-app-api.beanstalkedu.com/assets/'+page[0].theme_hero_img" alt="">
                <div class="absolute lg:inset-16 2xl:pl-32 2xl:pt-16 p-4 text-color-1 hero-text font-bold"> Theme of the month -
                    <div v-if="page">{{page[0].theme_title}} </div>
                </div>
            </div>
        </section> -->
        <!-- <section>
            <div class="container-fluid shadow-xl">
                <div v-if="page" class="container mx-auto p-4">
                    <div class="flex h1-text text-color-1  mt-16">{{ page[0].theme_text }}</div>
                    <div class="flex text-justify font-18px mt-6 text-color-2">{{ page[0].theme_details }}</div> 
                    <div class="flex  text-indigo-800 pb-82font-18px md:text-2xl mt-2"> Check Out the ressources below.</div>
                </div>
            </div>
        </section> -->
                                        <!-- section Celebretion Ideas -->
        <section class="container mx-auto xl:px-24 py-16 px-4"> 
            <div class="h1-text text-blue-700 font-semibold">Celebration Ideas </div>
            <div class="text-2xl text-justify text-color-2" v-if="page">{{page[0].celebration_ideas_text}}</div>
            <div v-if="ideas" class="grid place-items-center grid-cols-1 md:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4 ">
                <div v-for="ida in ideas.slice(0, 4)" :key="ideas.id" class="">
                    <div class="flex relative">
                        <img v-if="ida.celebration_ideas_img" :src="'https://curriculum-app-api.beanstalkedu.com/assets/'+ida.celebration_ideas_img" alt="" class="pt-4 rounded-tl-xl rounded-br-xl shadow-xl" />
                        <div class="absolute top-10 left-8 text-2xl text-color-1 font-semibold">{{ida.celebration_ideas_title}}
                        </div>
                        <div class="absolute top-16 py-3 left-8 text-xl text-color-2">{{ida.celebration_ideas_body_text}}
                        </div>
                        <div class="absolute bottom-10 left-32 md:left-28">
                            <a :href="'https://curriculum-app-api.beanstalkedu.com/assets/'+ida.celebration_ideas_img+'?download'">
                                <h3 class="text-center inline-block px-6 py-2.5 bg-blue-500 text-white font-medium text-base leading-tight rounded shadow-md hover:bg-blue-400 hover:shadow-lg focus:bg-blue-600 focus:shadow-lg focus:outline-none focus:ring-0 active:bg-blue-800 active:shadow-lg transition duration-150 ease-in-out"> View Now </h3>
                            </a>
                        </div>
                    </div>
                    <!-- <div class=" text-center text-lg ">{{ida.title}}</div> -->
                </div>
            </div>
        </section>
                                        <!-- section Worksheets -->
        <section class="container mx-auto xl:px-24 py-10 px-4">  
            <div class="h1-text text-blue-700 font-semibold">Worksheets</div>
            <div class="text-2xl text-justify text-color-2" v-if="page">{{page[0].worksheets_text}}</div>
            <div v-if="worksheets" class="grid place-items-center grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 mt-6">
                <div v-for="wkst in worksheets.slice(0, 3)" :key="worksheets.id" class="p-4">
                    <div class="flex relative">
                        <img v-if="wkst.theme_worksheets_img" :src="'https://curriculum-app-api.beanstalkedu.com/assets/'+wkst.theme_worksheets_img" alt="" class="w-80 shadow-2xl rounded-tl-lg rounded-br-lg" />
                        <div class="absolute bottom-10 left-20">
                            <a :href="'https://curriculum-app-api.beanstalkedu.com/assets/'+wkst.file+'?download'">
                            <h3 class="text-center inline-block px-6 py-2.5 bg-blue-500 text-white font-medium text-base leading-tight rounded shadow-md hover:bg-blue-400 hover:shadow-lg focus:bg-blue-600 focus:shadow-lg focus:outline-none focus:ring-0 active:bg-blue-800 active:shadow-lg transition duration-150 ease-in-out"> Download </h3>
                        </a>
                        </div>
                    </div>
                    <!-- <div class=" text-center text-lg ">{{wkst.title}}</div> -->
                </div>
                <a href="/worksheets">
                    <div v-for="wkst in worksheets.slice(3, 4)" :key="worksheets.id" class="p-4">
                    <div class="flex relative">
                        <img v-if="wkst.theme_worksheets_img" :src="'https://curriculum-app-api.beanstalkedu.com/assets/'+wkst.theme_worksheets_img" alt="" class="w-80 shadow-2xl rounded-tl-lg rounded-br-lg" />
                        <div class="absolute top-40 left-20">
                                <h3 class="text-center inline-block px-6 py-2.5 bg-amber-500 text-white font-medium text-base leading-tight rounded shadow-md hover:bg-amber-400 hover:shadow-lg focus:bg-amber-600 focus:shadow-lg focus:outline-none focus:ring-0 active:bg-blue-800 active:shadow-lg transition duration-150 ease-in-out"> + Subscribe </h3>
                                <h3 class="-ml-2 absolute left-8 text-center"> &nbsp;To download <br> more resources</h3>
                        </div>
                    </div>
                    <!-- <div class=" text-center text-lg ">...</div> -->
                </div>
                </a>
            </div>
        </section>
                                            <!-- section videos -->
        <section class="container mx-auto xl:px-24 py-16 px-4">  
            <div class="h1-text text-blue-700 font-semibold">Videos </div>
            <div class="text-2xl text-justify text-color-2" v-if="page">{{page[0].videos_text}}</div>
            <div v-if="videos" class="grid place-items-center grid-cols-1 md:grid-cols-1 lg:grid-cols-2 xl:grid-cols-4 ">
                <div v-for="vdo in videos.slice(0, 3)" :key="videos.id" class="p-4">
                    <div @click="showYtModal(vdo.youtube_id)">
                        <div class="flex bg-gray-200 -rotate-6 cursor-pointer gap-8 rounded-tl-xl rounded-br-xl shadow-2xl">
                            <div class="flex rotate-6 relative"><img class="rounded-tl-xl rounded-br-xl shadow-2xl w-96" v-if="vdo.video_thumb" :src="'https://curriculum-app-api.beanstalkedu.com/assets/'+vdo.video_thumb" alt=""  />
                            <img class="absolute inset-16 left-32 w-16" src="/img/svg/play.svg" alt="" />
                            </div>
                        </div>
                        <div class="mt-6 text-center text-xl text-color-2">{{vdo.videos_title}}</div>
                    </div>
                    <!-- <label :for="vdo.videos_file" >
                        <div class="flex bg-gray-200 -rotate-6 cursor-pointer gap-8">
                            <div class="flex rotate-6 relative"><img v-if="vdo.video_thumb" :src="'https://curriculum-app-api.beanstalkedu.com/assets/'+vdo.video_thumb" alt="" class="rounded-tl-xl rounded-br-xl shadow-2xl" />
                                <img v-else src="/img/image_not_available.png" alt="" />
                            <img class="absolute top-20 left-28 -rotate-6 w-24" src="/img/svg/play.svg" alt="" />
                            </div>
                        </div>
                        <div class="mt-6 text-center text-xl text-color-2">{{vdo.videos_title}}</div>
                    </label>
                    <input type="checkbox" :id="vdo.videos_file" class="modal-toggle" />
                    <label :for="vdo.videos_file" class="modal cursor-pointer">
                        <label class="modal-box relative" for="">
                            <iframe width="340" 
                            src="https://www.youtube.com/embed/tgbNymZ7vqY">
                            </iframe>
                        </label>
                    </label> -->
                </div>
                <a href="/plan">
                <div v-for="vdo in videos.slice(3, 4)" :key="videos.id" class="p-4">
                    <div class="flex bg-gray-00 -rotate-6  gap-8">
                        <div class="flex rotate-6 relative"><img v-if="vdo.video_thumb" :src="'https://curriculum-app-api.beanstalkedu.com/assets/'+vdo.video_thumb" alt="" class="rounded-tl-xl rounded-br-xl" />
                            <div class="absolute top-20 left-28 ">
                                <h3 class="text-center inline-block px-6 py-2.5 bg-amber-500 text-white font-medium text-xs leading-tight rounded shadow-md hover:bg-amber-400 hover:shadow-lg focus:bg-amber-600 focus:shadow-lg focus:outline-none focus:ring-0 active:bg-blue-800 active:shadow-lg transition duration-150 ease-in-out">+ Subscribe </h3>
                                <h3 class="-ml-2"> &nbsp;To download <br> more resources</h3>
                            </div>
                        </div>
                    </div>
                    <div class="mt-6 text-center text-lg ">...</div>
                </div></a>
            </div>
        </section>
                                        <!-- section audio book -->
        <section class="container mx-auto xl:px-24 px-4" >  
            <div class="h1-text text-blue-700 font-semibold ">Audio Books</div>
            <div class="text-2xl text-justify text-color-2" v-if="page">{{page[0].audio_books_text}}</div>
            <div class="grid place-items-center grid-cols-1 md:grid-cols-2 lg:grid-cols-5 ">
                <div v-for="aud in audio" :key="audio.id" class="p-2">
                    <label :for="aud.file" >
                    <img class="cursor-pointer rounded-tl-xl rounded-br-xl w-56" v-if="aud.audio_icon" :src="'https://curriculum-app-api.beanstalkedu.com/assets/'+aud.audio_icon" alt="">
                        <div class="cursor-pointer text-center text-xl text-color-2 pt-2">{{aud.title}}</div>
                    </label>
                    <!-- <label :for="aud.file" class="btn">{{aud.id}} -</label> -->

                    <input type="" :id="aud.file" class="modal-toggle" />
                    <label :for="aud.file" class="modal cursor-pointer">
                        <label class="modal-box relative" for="">
                            <audio controls>
                            <source :src="'https://curriculum-app-api.beanstalkedu.com/assets/'+aud.file" type="audio/mpeg">Your browser does not support the audio element.
                            </audio>
                        </label>
                    </label>
                </div>
                <a href="/plan">
                    <div>
                        <img class="rounded-tl-xl rounded-br-xl w-72" src="/img/audio-icon.png" alt="">
                        <div class="text-center"><button class="text-xl bg-blue-700 py-2 text-white rounded-tl-lg rounded-br-lg px-6 ">View All</button></div>
                    </div>
                </a>
            </div>
        </section>
                                    <!-- Celebration Stories -->
        <!-- <section class="container mx-auto xl:px-24 pt-16 px-4">
            <h1 class="h1-text text-blue-700 font-semibold">Celebration stories</h1>
            <div class="text-2xl text-justify text-color-2" v-if="page">{{page[0].celebration_stories_text}}</div>
            <div class="grid place-items-center grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 pb-32 px-4">
                <div v-for="slide in stories" :key="stories.id" class="p-4 ">
                    <div class="flex bg-gray-200 rotate-6  gap-8">
                        <div class="flex -rotate-6 relative"><img v-if="slide.img" :src="'https://curriculum-app-api.beanstalkedu.com/assets/'+slide.img" alt="" class="rounded-tl-lg rounded-br-lg" />
                            <img v-else src="/img/image_not_available.png" alt="" />
                            <div class="flex absolute bg-white p-2 rounded-md m-4 justify-center text-sm md:text-xl">{{slide.title}}</div>
                            <p class="absolute inset-x-0 bottom-6 text-blue-100 text-justify p-3 font-semibold rounded-br-lg line-clamp-3">{{slide.text}}</p>
                            <span class="absolute inset-x-0 bottom-0 bg-gradient-to-t from-white text-justify p-3 "><a href="" class="text-blue-700 hover:font-extrabold"> <br> Read Full Storry>> </a></span>
                        </div>
                    </div>
                </div>
            </div>
        </section> -->
                                <!-- Submit your Celebration Story here -->
         <SubmitCelebration />
                                        <!-- section youtube -->
        <section class="container mx-auto py-16 px-4 xl:px-24" >  
            <div class="h1-text text-blue-700 font-semibold">YouTube Videos for your reference </div>
            <div class="text-2xl text-justify text-color-2" v-if="page">{{page[0].youtube_text}}</div>
            <div class="grid place-items-center grid-cols-1 md:grid-cols-2 lg:grid-cols-5 ">
                <div v-for="yt in youtube" :key="youtube.id" class="p-2">
                    <a :href="'https://www.youtube.com/watch?v='+yt.youtube_id">
                        <div><img class="rounded-tl-xl rounded-br-xl" :src="'https://curriculum-app-api.beanstalkedu.com/assets/'+yt.youtube_thumbnail" alt="">
                        <div class="text-center text-lg ">{{yt.about_the_video}}</div>
                    </div>
                    </a>
                </div>
            </div>
        </section>
                                <!-- section for theme slug page -->
        <section class="container mx-auto px-4 xl:px-24 my-16">
            <h2 class="h1-text text-blue-700 py-16 font-semibold"> Other Themes  </h2>
            <div class="grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 place-items-center gap-10">
                    <div class="grid" v-for="themes in allThemes" :key="themes.id">
                        <a :href="'/themes/'+ themes.theme_slug">
                            <div>
                                <img class="rounded-lg shadow-2xl" v-if="themes.theme_icon" :src="'https://curriculum-app-api.beanstalkedu.com/assets/' + themes.theme_icon" alt=""/>
                            </div>
                        </a>
                </div>
                
            </div>
            <!-- <vueper-slides
            class="no-shadow"
            :visible-slides="3"
            slide-multiple
            :gap="1"
            :slide-ratio="1/4"
            :dragging-distance="200"
            :breakpoints="{ 800: { visibleSlides: 1, slideMultiple: 1 } }">
            <vueper-slide v-for="themes in allThemes" :key="themes.id" :image="'https://curriculum-app-api.beanstalkedu.com/assets/'+ themes.theme_icon" />
            </vueper-slides> -->
        </section>
        <section class="container mx-auto py-20 px-4 xl:px-24">
            <div class="grid grid-cols-1 xl:grid-cols-2 xl:space-x-48">
                <div class="grid h-fit ">
                    <h1 class="text-4xl py-6 text-blue-700 font-semibold">Frequently Asked <span class="text-color-1">Questions</span></h1>
                    <div  v-for="faqThemes in faqThemes" :key="faqThemes.id" class="">
                        <details>
                            <summary> 
                                <div class="flex inline-flex cursor-pointer" v-if="faqThemes"> &nbsp; {{ faqThemes.title }}</div>
                            </summary>
                                <div  v-html="faqThemes.content"></div>
                        </details>
                    </div>
                </div>
                <div class="grid place-items-center"><img src="/img/frequently.png" alt=""></div> 
            </div>
        </section>
            <!-- Youtube Modal -->
        <div @click="hideYtModal" v-if="ytModal" id="ytModal" class="flex justify-center ytModal">
            <div class="modal-content">
            <span  @click="hideYtModal" class="close">&times;</span>
            <div>
                <iframe width="380" height="320" 
                :src="'https://www.youtube.com/embed/'+ytID">
                </iframe>
            </div>
            </div>
        </div>
        
    </div>
</template>

<script>
export default {
    // components: { YouTube },
    setup(){
    // const route = useRoute();
},

    data() {
        return {
            page: null,
            faqThemes: null,
            themes:null,
            allThemes:null,
            stories: null,
            ideas: null,
            worksheets: null,
            videos: null,
            youtube: null,
            audio: null,
            isLoading: true,
            ytModal:false,
            ytID:''
        }
    },
    methods: { 
        showYtModal(ytID){
            this.ytModal=true
            this.ytID=ytID
        },
        hideYtModal(){
            this.ytModal=false
            // this.ytID=ytID
        }    
    },
    mounted: function () {
        fetch('https://curriculum-app-api.beanstalkedu.com/items/themes?filter[status][_eq]=published')

            .then(response => response.json())
            .then(data => {
                this.page = data.data
                this.isLoading = false
                // console.log(this.page[0].id)
                return this.page[0].id
            }).then((themeID) => {
                fetch('https://curriculum-app-api.beanstalkedu.com/items/theme_celebration_stories?filter[theme_key][_in]=' + themeID)
                .then(resp => resp.json())
                    .then(stories => {
                        this.stories=stories.data
                        // console.log(this.stories)
                    })
                    // console.log(themeID)
                    return themeID
                    
            }).then((themeID) => {
                fetch('https://curriculum-app-api.beanstalkedu.com/items/theme_celebration_ideas?filter[theme_key][_in]=' + themeID)
                .then(resp => resp.json())
                    .then(ideas => {
                        this.ideas=ideas.data
                        // console.log(ideas)
                    })
                    return themeID
            })
            .then((themeID) => {
                fetch('https://curriculum-app-api.beanstalkedu.com/items/theme_workshets?filter[theme_key][_in]='+ themeID)
                .then(resp => resp.json())
                    .then(worksheets => {
                        this.worksheets=worksheets.data
                        // console.log(this.worksheets)
                    })
                    return themeID
            })
            .then((themeID) => {
                fetch('https://curriculum-app-api.beanstalkedu.com/items/theme_videos?filter[theme_key][_in]='+ themeID)
                .then(resp => resp.json())
                    .then(videos => {
                        this.videos=videos.data
                        // console.log(this.videos)
                    })
                    return themeID
            })
            .then((themeID) => {
                fetch('https://curriculum-app-api.beanstalkedu.com/items/theme_youtube_videos?filter[theme_key][_in]='+ themeID)
                .then(resp => resp.json())
                    .then(youtube => {
                        this.youtube=youtube.data
                        // console.log(youtube)
                    })
                    return themeID
            })
            .then((themeID) => {
                fetch('https://curriculum-app-api.beanstalkedu.com/items/theme_audio_book?limit=3')
                .then(resp => resp.json())
                    .then(audio => {
                        this.audio=audio.data
                        // console.log(this.audio)
                    })
            })
            fetch('https://curriculum-app-api.beanstalkedu.com/items/themes?filter[status][_eq]=draft&limit=3')

            .then(response => response.json())
            .then(data => {
                this.allThemes = data.data
                // this.isLoading = false
                console.log(this.allThemes)
                // return this.page[0].id
            })
            fetch('https://management.beanstalkedu.com/items/FAQ?filter[property][_eq]=teenybeans_curriculum&filter[slug][_eq]=themes')
            .then(resp => resp.json())
            .then(data => {
            this.faqThemes=data.data
            // console.log(this.faqThemes)
        })
      
            
    }
}
</script>

<style scopped>
details {
    font-weight: lighter;
    border-bottom: 1px solid #d4d4d4;
    border-color: #d4d4d4;    
    padding: .75em .75em 0;
    font-size: 18px;
	/* margin-top: 10px; */
	/* box-shadow:0 0 8px #d4d4d4; */
}

summary {	
    margin: -.75em -.75em 0;
    padding: .75em;
}

details[open] {
    padding: .75em;
	  border-bottom: 1px solid #d4d4d4;
}

details[open] summary {
    border-bottom: 1px solid #d4d4d4;
    margin-bottom: 10px;
}
.bg3 {
  background: linear-gradient(0deg, rgb(191, 219, 254, 1) 0%, rgba(255, 255, 255) 100%);}
  @media screen and (min-width: 1500px) {
  .h2-text {
    font-size: 30px;
  } 
}
@media screen and (max-width: 1499px) {
  .h2-text {
    font-size: 24px;
  }
}
@media screen and (max-width: 1199px) {
  .h2-text {
    font-size: 20px;
  }
}
.font-18px {
    font-size: 18px;
}
@media screen and (min-width: 1500px) {
  .hero-text {
    font-size: 50px;
    
    
  }
}

@media screen and (max-width: 1499px) {
  .hero-text {
    font-size: 40px;
    
  }
}
@media screen and (max-width: 1199px) {
  .hero-text {
    font-size: 30px;
    
  }
}
@media screen and (min-width: 801px) {
  .h1-text {
    font-size: 40px;
    
    
  } 
}

@media screen and (max-width: 800px) {
  .h1-text {
    font-size: 25px;
    
  }
}
.load-wraper{
  position: relative;
  height: 100%;
  width: 100%;
  background-color: rgb(211,211,211);
  z-index: 44;
  overflow: hidden;
  border-radius: 5px;
}
.activity{
  position: absolute;
  left: -45%;
  height: 100%;
  width: 45%;
  background-image: linear-gradient(to left, rgba(251,251,251, .05), rgba(251,251,251, .3), rgba(251,251,251, .6), rgba(251,251,251, .3), rgba(251,251,251, .05));
  background-image: -moz-linear-gradient(to left, rgba(251,251,251, .05), rgba(251,251,251, .3), rgba(251,251,251, .6), rgba(251,251,251, .3), rgba(251,251,251, .05));
  background-image: -webkit-linear-gradient(to left, rgba(251,251,251, .05), rgba(251,251,251, .3), rgba(251,251,251, .6), rgba(251,251,251, .3), rgba(251,251,251, .05));
  animation: loading 1s infinite;
  z-index: 45;
}

@keyframes loading {
  0%{
    left: -45%;
  }
  100%{
    left: 100%;
  }
}
.text-color-1 {
    color: #7C4C23;
}

.text-color-2 {
    color: #333333;
}
.box{
        width: 380px;
        height: 220px;
    }
    .box1 {
        width: 500px;
        height: 220px;
    }
    input[type="file"] {
    display: none;
}
.custom-file-upload {
    border: 1px solid #ccc;
    display: inline-block;
    padding: 6px 12px;
    cursor: pointer;
}



.ytModal {
  /* display: none;  */
  position: fixed;
  width: 80%;
  z-index: 999991;
  padding-top: 100px;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgb(0,0,0);
  background-color: rgba(0,0,0,0.4);
}

/* Modal Content
.modal-content {
  background-color: #fefefe;
  margin: auto;
  padding: 20px;
  border: 1px solid #888;
  width: 80%;
} */
</style>