---
import Layout from "../../layouts/Layout.astro";
import Menu from "../../components/Menu.astro";

const response = await fetch('https://curriculum-app-api.beanstalkedu.com/items/themes?filter[status][_eq]=published');
const data = await response.json();
const themes = data.data;

const thisThemesID = data.data[0].id;

const tciResp = await fetch('https://curriculum-app-api.beanstalkedu.com/items/theme_celebration_ideas?filter[theme_key][_in]=' + thisThemesID );
const tciRespJson = await tciResp.json();
const tciRespData = tciRespJson.data.reverse().slice(0, 4);

const twsResp = await fetch('https://curriculum-app-api.beanstalkedu.com/items/theme_workshets?filter[theme_key][_in]=' + thisThemesID);
const twsRespJson = await twsResp.json();
const twsRespData = twsRespJson.data.reverse().slice(0, 3);
const twsRespData2 = twsRespJson.data[3];

import ThemesVideos from "../../components/ThemesVideos.vue";
import ThemesAudioBook from "../../components/ThemesAudioBook.vue";

const tcsResp = await fetch('https://curriculum-app-api.beanstalkedu.com/items/theme_celebration_stories?filter[theme_key][_in]=' + thisThemesID);
const tcsRespJson = await tcsResp.json();
const tcsRespData = tcsRespJson.data.reverse().slice(0, 4);

import SubmitCelebration from "../../components/SubmitCelebration.vue";

const ytvResp = await fetch('https://curriculum-app-api.beanstalkedu.com/items/theme_youtube_videos?filter[theme_key][_in]=' + thisThemesID);
const ytvRespJson = await ytvResp.json();
const ytvRespData = ytvRespJson.data.reverse();

const allthemesResp = await fetch('https://curriculum-app-api.beanstalkedu.com/items/themes?filter[status][_eq]=draft&limit=3');
const allthemesRespJson = await allthemesResp.json();
const allthemesRespData = allthemesRespJson.data;

const faqresponse = await fetch('https://management.beanstalkedu.com/items/FAQ?filter[property][_eq]=teenybeans_curriculum&filter[slug][_eq]=themes');
const faqdata = await faqresponse.json();
const faq = faqdata.data;

import Footer from "../../components/Footer.vue";
---
<Layout title="">
    <Menu clint:visible/>
    <main>
        <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 class="">
                            <h1 class="text-blue-700 hero-text font-bold">Theme of the Month- <span class="text-color-1" v-if="page">{themes[0].theme_title}</span></h1>
                            <div class="flex h2-text text-color-1 font-semibold pt-8">{themes[0].theme_text }</div>
                            <div class="flex text-justify font-18px text-color-2 pt-4">{themes[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" src={'https://curriculum-app-api.beanstalkedu.com/assets/'+themes[0].theme_hero_img} alt="">
                    </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">{themes[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 ">
                        {tciRespData.map((data) => 
                            <div class="flex relative">
                                <img v-if="ida.celebration_ideas_img" src={'https://curriculum-app-api.beanstalkedu.com/assets/'+data.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">{data.celebration_ideas_title}
                                </div>
                                <div class="absolute top-16 py-3 left-8 text-xl text-color-2">{data.celebration_ideas_body_text}
                                </div>
                                <div class="absolute bottom-10 left-32 md:left-28">
                                    <a href={'https://curriculum-app-api.beanstalkedu.com/assets/'+data.celebration_ideas_img+'?download'}>
                                        <h3 class="text-center inline-block px-5 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>
            </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" >{themes[0].worksheets_text}</div>
                <div class="grid place-items-center grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 mt-6">
                        {twsRespData.map((data) =>
                        <div class="flex relative p-4">
                            <img src={'https://curriculum-app-api.beanstalkedu.com/assets/'+data.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/'+data.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>
                        )}
                        
                    <a href="/worksheets">
                        <div class="p-4">
                        <div class="flex relative">
                            <img v-if="wkst.theme_worksheets_img" src={'https://curriculum-app-api.beanstalkedu.com/assets/'+twsRespData2.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>
            <ThemesVideos client:visible/>
            <ThemesAudioBook client:visible/>
            <section class="container mx-auto pt-16 xl:px-24 px-4">
              <h1 class="h1-text text-blue-700 font-semibold">Celebretion stories</h1>
              <h1 class="text-2xl text-justify text-color-2 py-4" v-if="page">{themes[0].celebration_stories_text}</h1>
              <div class="grid place-items-center grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 py-10 px-4 gap-12">
                  {tcsRespData.map((data) => 
                      <div class="flex bg-gray-200 rotate-6  rounded-tl-lg rounded-br-lg">
                          <div class="flex -rotate-6 relative"><img src={'https://curriculum-app-api.beanstalkedu.com/assets/'+data.img} alt="" class="rounded-tl-lg rounded-br-lg" />
                              <div class="flex absolute bg-white p-2 rounded-md m-4 justify-center text-sm md:text-xl">{data.title}</div>
                              <p class="absolute inset-x-0 bottom-6 text-blue-100 text-justify p-3 font-semibold rounded-br-lg line-clamp-4">{data.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 &#62;&#62; </a></span>
                          </div>
                      </div>
                  )}
              </div>
          </section>
          <SubmitCelebration client:visible/>
          <!-- section youtube -->
        <section class="container mx-auto py-16 mt-20 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">{themes[0].youtube_text}</div>
            <div class="grid place-items-center grid-cols-1 md:grid-cols-2 lg:grid-cols-5 pt-4">
              {ytvRespData.map((data) =>
                <div class="p-2">
                    <a href={'https://www.youtube.com/watch?v='+data.youtube_id}>
                        <div>
                          <img class="rounded-tl-xl rounded-br-xl" src={'https://curriculum-app-api.beanstalkedu.com/assets/'+data.youtube_thumbnail} alt="">
                        <div class="text-center text-lg ">{data.about_the_video}</div>
                      </div>
                    </a>
                </div>
                )}  
            </div>
        </section>
        <!-- section for theme slug page -->
        <section class="container mx-auto px-4 xl:px-24 mb-16">
            <h2 class="h1-text text-center text-color-1 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">
              {allthemesRespData.map((data) =>
                <div class="grid">
                        <a href={'/themes/'+ data.theme_slug}>
                            <img class="rounded-lg shadow-2xl" src={'https://curriculum-app-api.beanstalkedu.com/assets/' + data.theme_icon} alt=""/>
                        </a>
                </div>
                )}      
              </div>
        </section>
        {faq.length >0 &&
        <section class="container mx-auto py-20 px-4 xl:px-24" style="font-family: quicksand;">
          <div class="grid grid-cols-1 xl:grid-cols-2 xl:space-x-48">
            <!-- <div set:html={faq[0].title}></div> -->
              <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>
                      {faq.map((data: { title: string | undefined; }) =>
                          <details>
                              <summary> 
                                  <div class="flex inline-flex cursor-pointer"> {data.title}</div>
                              </summary>
                                  <div set:html="data.content"></div>
                          </details>
                      )}
              </div>
              <div class="grid place-items-center">
                  <img src="/img/frequently.png" alt="">
              </div> 
          </div>
        </section>
      }

        </div>
    </main>
    <Footer client:visible/>
</Layout>
<style>
  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: .80em;
}

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

details[open] summary {
    border-bottom: 1px solid #d4d4d4;
    margin-bottom: 10px;
}
  .line-clamp-4 {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;  
    overflow: hidden;
}
    .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>