<template>
  <div id="Chapter1_1" class="content-wrap">
    <div style="margin: 30px 0px 50px; width: 20%">
      <router-link to="/MyPlan.page">
        <div class="logo mb25">
          <img src="../../../../resources/img/logo2.png" alt="" />
        </div>
      </router-link>
    </div>
    <div
      class="title-box mb25 flex align-center mt40"
      style="justify-content: space-between"
    >
      <div>
        <span class="title mr40">1. Hello WORLD</span>
        <span class="subtitle">my name is dd</span>
      </div>
      <button class="completeBtn" @click="complete">학습 종료</button>
    </div>
    <div class="flex justify-between align-center">
      <div class="pre-btn" @click="goToPage('Chapter1_3')">
        <img src="../../../../resources/img/left.png" alt="" />
      </div>
      <div class="content title-box">
        <p class="title mt25 title-bg">STEP 2 - 단어로 공부하는 영어</p>
        <div class="flex align-center mb30">
          <p class="subtitle2 mr20"></p>
        </div>

        <div class="flex justify-center">
          <div class="vocaGroup">
            <div class="flex justify-between mb80">
              <article class="flex align-center">
                <div class="imgGroup mr30">
                  <img
                    src="../../../../resources/img/img2_1.png"
                    data-num="1"
                    style="width: 200px"
                  />
                </div>
                <div class="flex align-start">
                  <button
                    class="listen-btn mr30"
                    data-video="1"
                    tabindex="0"
                    aria-label="음성 재생"
                  >
                    <img
                      src="../../../../resources/img/btn10_s.png"
                      data-num="1"
                      @click="playAudio('audio-family')"
                    />
                  </button>
                  <audio
                    id="audio-family"
                    src="client/resources/audio/family.wav"
                    preload="auto"
                  ></audio>
                  <div>
                    <h3>family</h3>
                    <div class="flex align-center mt10">
                      <p class="yellow-box">명</p>
                      <span class="title1">가족</span>
                    </div>
                  </div>
                </div>
              </article>
              <article class="flex align-center">
                <div class="imgGroup mr30">
                  <img
                    src="../../../../resources/img/img2_4.png"
                    data-num="1"
                    style="width: 200px"
                  />
                </div>
                <div class="flex align-start">
                  <button
                    class="listen-btn mr30"
                    data-video="1"
                    tabindex="0"
                    aria-label="음성 재생"
                  >
                    <img
                      src="../../../../resources/img/btn10_s.png"
                      data-num="1"
                      @click="playAudio('audio-bank')"
                    />
                  </button>
                  <audio
                    id="audio-bank"
                    src="client/resources/audio/bank.wav"
                    preload="auto"
                  ></audio>
                  <div>
                    <h3>bank</h3>
                    <div class="flex align-center mt10">
                      <p class="yellow-box">명</p>
                      <span class="title1">은행</span>
                    </div>
                  </div>
                </div>
              </article>
            </div>
            <div class="flex justify-between">
              <article class="flex align-center">
                <div class="imgGroup mr30">
                  <img
                    src="../../../../resources/img/img2_2.png"
                    data-num="1"
                    style="width: 200px"
                  />
                </div>
                <div class="flex align-start">
                  <button
                    class="listen-btn mr30"
                    data-video="1"
                    tabindex="0"
                    aria-label="음성 재생"
                  >
                    <img
                      src="../../../../resources/img/btn10_s.png"
                      data-num="1"
                      @click="playAudio('audio-love')"
                    />
                  </button>
                  <audio
                    id="audio-love"
                    src="client/resources/audio/love.wav"
                    preload="auto"
                  ></audio>
                  <div>
                    <h3>love</h3>
                    <div class="flex align-center mt10">
                      <p class="yellow-box">명</p>
                      <span class="title1">사랑</span>
                    </div>
                  </div>
                </div>
              </article>
              <article class="flex align-center">
                <div class="imgGroup mr30">
                  <img
                    src="../../../../resources/img/img2_3.png"
                    data-num="1"
                    style="width: 200px"
                  />
                </div>
                <div class="flex align-start">
                  <button
                    class="listen-btn mr30"
                    data-video="1"
                    tabindex="0"
                    aria-label="음성 재생"
                  >
                    <img
                      src="../../../../resources/img/btn10_s.png"
                      data-num="1"
                      @click="playAudio('audio-police')"
                    />
                  </button>
                  <audio
                    id="audio-police"
                    src="client/resources/audio/police.wav"
                    preload="auto"
                  ></audio>
                  <div>
                    <h3>police</h3>
                    <div class="flex align-center mt10">
                      <p class="yellow-box">명</p>
                      <span class="title1">경찰</span>
                    </div>
                  </div>
                </div>
              </article>
            </div>
          </div>
        </div>
      </div>
      <div class="next-btn" @click="goToPage('Chapter2_3')">
        <img src="../../../../resources/img/right.png" alt="" />
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {};
  },
  methods: {
    complete() {
        const { unit_id, book_id } = this.$route.query;
        this.$router.push({ name: 'Dashboard', query: { value: 2, unit_id, book_id } });
    },
    goToPage(page) {
      this.$router.push({ name: page });
    },
    playAudio(audioId) {
      const audio = document.getElementById(audioId);
      if (audio) {
        audio.play();
      } else {
        console.error(`Audio element with ID ${audioId} not found.`);
      }
    },
  },
  watch: {},
  computed: {},
  components: {},
  mounted() {},
};
</script>
<style scoped>
.grid-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}
.completeBtn {
  margin-right: 100px;
  background-color: #ffba08;
  padding: 10px 30px;
  border-radius: 10px;
  font-size: 28px;
  font-family: "ONEMobilePOPOTF";
}
</style>
