@font-face {
  font-family: 'Huninn';
  src: url('includes/fonts/Huninn-Regular.woff2') format('woff2'),
    url('includes/fonts/Huninn-Regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'BopomofoRuby';
  src: url('includes/fonts/BopomofoRuby1909-v1-Regular.ttf') format('truetype');
}

html {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Huninn", "Noto Sans JP", "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
  background: #b6dfff;
  /* width: 100%; */
  /* padding: 20px; */
  /* margin: 0px; */
  margin: 0;
  padding: 0;
}

.backhome {
  text-decoration: none;
  color: #333;
  font-weight: bold;
  transition: color 0.2s ease;
}

.backhome:hover {
  color: #007acc;
  text-decoration: underline;
}

.main-container {
  /* margin: 120px; */
  /* padding-top: 30px; */
  /* padding-bottom: 30px; */
  /* prevent that strange space at the bottom */
  background-color: #b6dfff;
  display: flex;
  flex-direction: row;
  /* height: 100vh; */
}

/* #sidebar-wrapper {
  display: block;
} */

.sidebar-container {
  /* top: 10px; */
  /* left: 10px; */
  z-index: 1001;
  width: 250px;
  /* background-color: #479be5; */
  padding: 100px;
  border-radius: 6px;
  /* box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1); */
  overflow-y: auto;
  transition: width 0.3s ease, padding 0.3s ease;
}

#sidebar-container.collapsed {
  width: 0;
  padding: 0;
  transition: width 0.3s ease, padding 0.3s ease;
  overflow: hidden;
}

.sidebar-inner {
  width: 100%;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  /* align-items: center; */
  align-items: stretch;
  /* ← Important: keeps children aligned left */
  text-align: left;
  margin: 20px;
  /* ✅ 將整體內容置中 */
}

.sidebar-inner h3 {
  margin-block-start: 0.5em;
  margin-block-end: 0.5em;
}

.sidebar-toggle {
  /* position: absolute; */
  /* top: 10px;
  left: 20px;
  z-index: 1001; */
  /* top: 200px; */
  background-color: #333;
  height: 40px;
  color: white;
  border: none;
  padding: 6px 12px;
  margin: 15px;
  font-size: 16px;
  cursor: pointer;
  border-radius: 4px;
}

.sort-toggle {
  margin-top: 10px;
  margin-bottom: 10px;
}

.sort-button {
  display: inline-block;
  background-color: #eee;
  color: #333;
  padding: 6px 10px;
  border-radius: 4px;
  text-decoration: none;
  /* font-size: 14px; */
}

.sort-button:hover {
  background-color: #ddd;
}


.tag-item:hover label,
.month-children label:hover,
.year-item:hover label {
  background-color: #eef8ff;
  cursor: pointer;
  border-radius: 4px;
}

.toggle-icon {
  display: inline-block;
  transition: transform 0.3s ease;
  cursor: pointer;
  transform-origin: center;
}

.toggle-icon.collapsed {
  transform: rotate(90deg);
}

.selected-tag {
  background-color: #e0f7ff;
  font-weight: bold;
  border-radius: 4px;
  padding: 2px 4px;
}

.month-link {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 5px;
  text-decoration: none;
  color: #333;
}

.year-item label.selected,
.month-children label.selected {
  background-color: #d0e8ff;
  font-weight: bold;
  border-radius: 4px;
  padding: 2px 4px;
}

.gallery {
  flex-grow: 1;
  padding: 15px;
  overflow-y: hidden;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
  font-size: 12px;
}

/* .thumbnail {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  margin-bottom: 10px;
} */

.photo {
  width: 200px;
  height: 400px;
  background: #f9f9f9;
  /* padding: 15px; */
  flex-direction: column;
  /* 垂直排列圖片與文字 */
  padding: 0;
  overflow: hidden;
  border: 1px solid #ddd;
  border-radius: 8px;
}

.thumbnail {
  height: 45%;
  /* ✅ 圖片區佔上方 1/3 */
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #ffffe7;
  padding: 6px;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

.thumbnail img {
  max-height: 100%;
  max-width: 160px;
  object-fit: contain;
  display: block;
  border: 2px dashed #ddd;
  border-radius: 2px;
}

.photo-content {
  height: 55%;
  /* ✅ 文字內容區佔下方 2/3 */
  font-size: 12px;
  padding: 8px;
  overflow-y: auto;
}

/* 3D Flip Styles */
.photo {
  perspective: 1000px;
}

.flip-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s ease-in-out;
  transform-style: preserve-3d;
}

.photo.hovering .flip-inner {
  transform: rotateY(180deg);
}


.flip-front,
.flip-back {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  backface-visibility: hidden;
  box-sizing: border-box;
}

.flip-back {
  display: flex;
  justify-content: center;
  /* 水平置中 */
  align-items: flex-start;
  /* text-align: center;           多行文字也置中 */
  transform: rotateY(180deg);
  background: #f7f7f7;
  padding: 20px;
  box-sizing: border-box;
  overflow: auto;
}

.flip-back.centered {
  align-items: center;
  /* 垂直置中 */
}

/* .flip-back {
  transform: rotateY(180deg);
  padding: 20px;
  background: #f7f7f7;
  overflow: auto;
}
.photo-desc p {
  line-height: 1.4;
  text-align: left;
} */

/* .photo img {
  width: auto;
  height: auto;
  max-width: 100%;
  display: block;
  margin: 0 auto;
} */

.gallery h3 {
  margin-block-start: 0;
  margin-block-end: 0;
  /* margin-bottom: 5px; */
}

.gallery h3 a {
  text-decoration: none;
  color: #004d80;
}

.gallery h3 a:hover {
  text-decoration: underline;
  /* 如果你想 hover 時才顯示底線 */
  background: #96d5ff;
  padding: 2px 6px;
  border-radius: 10px;
}

.tag {
  text-decoration: none;
  display: inline-block;
  background: #d0eaff;
  color: #004d80;
  padding: 2px 8px;
  margin: 2px;
  border-radius: 10px;
  /* font-size: 12px; */
}

.tag:hover {
  background: #96d5ff;
}

/* 外層 wrapper：垂直方向 flex 排版 */
/* .page-wrapper {
  display: flex;
  flex-direction: column; */
/* min-height: 100vh; */
/* } */

/* page numbers */
.pagination {
  /* width: 100%;
  display: block;
  clear: both; */
  flex-shrink: 0;
  padding: 20px 0;
  text-align: center;
  /* background-color: #f8f8f8; */
  /* border-top: 1px solid #ccc; */
}

.pagination a,
.pagination .current-page,
.pagination .ellipsis {
  display: inline-block;
  /* margin: 0 6px; */
  font-size: 16px;
  padding: 6px 10px;
  text-decoration: none;
  border-radius: 4px;
  color: #333;
}

.pagination a:hover {
  background-color: #ddd;
}

.pagination .current-page {
  font-weight: bold;
  background-color: #007acc;
  color: white;
}

.pagination .ellipsis {
  color: #999;
}

/* related illustrations under photo page */
.related-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.related-item img {
  width: 140px;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}

.related-item img:hover {
  transform: scale(1.05);
}

.pages {
  margin: 10px 20px;
  max-width: 700px;
  /* margin: auto; */
  line-height: 1.8;
  /* color: white; */
}

.pages a {
  text-decoration: none;
  color: #0074c1;
}

.pages a:hover {
  text-decoration: underline;
  color: #0090a3;
}

/* for about-us info for google */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}


.faq-list {
  list-style: none;
  /* 移除圓點 */
  padding-left: 0;
}

.faq-question {
  background: none;
  font-family: "Huninn";
  border: none;
  padding: 10px 0;
  font-weight: bold;
  font-size: 1em;
  text-align: left;
  width: 100%;
  cursor: pointer;
  outline: none;
}

.faq-answer {
  display: none;
  padding: 5px 0 15px 0;
  color: #444;
}

/* .faq-item {
  border-bottom: 1px solid #ddd;
} */


/* .apply-button-wrapper {
  margin-top: 80px;
} */

/* Mobile responsive adjustments */
@media (max-width: 768px) {

  /* 當側邊欄開啟時防止主畫面滾動 */
  body.sidebar-open {
    overflow: hidden;
    touch-action: none;
    /* for better mobile behavior */
  }


  .main-container {
    padding-top: 50px;
    flex-direction: column;
  }

  #sidebar-wrapper {
    position: fixed;
    top: 115px;
    left: 0;
    width: 100%;
    height: 100%;
    /* display: flex; */
    z-index: 999;
    /* pointer-events: none; Prevent overlay from blocking clicks unless active */
    transition: transform 0.3s ease;
    transform: translateX(-150%);
    /* overflow-y: auto; */
  }

  #sidebar-wrapper.active.shrink {
    top: 55px;
    max-height: calc(100vh - 55px)
  }

  #sidebar-wrapper.active.expand {
    top: 115px;
  }

  #sidebar-wrapper.active {
    transform: translateX(0);
    pointer-events: auto;
    overflow-y: auto;
    max-height: calc(100vh - 115px)
  }

  #sidebar-overlay {
    position: fixed;
    /*absolute;   ✅ overlay takes full screen */
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;

    z-index: 998;
    /* flex: 1; */
    /* opacity: 0; */
    pointer-events: none;
    transition: opacity 0.3s ease, background 0.3s ease;
  }

  body.sidebar-open #sidebar-overlay {
    /* opacity: 1; */
    background: rgba(176, 176, 176, 0.3);
    pointer-events: auto;
  }

  /* #sidebar-overlay:not(.active) {
    pointer-events: none;
  } */

  .sidebar-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    /* prevents vertical stretching */
    padding: 15px;
    /* overflow-y: auto; */

  }

  .sidebar-inner {
    background-color: #57c4ff;

    width: 100%;
    max-width: 210px;
    display: flex;
    flex-direction: column;
    /* align-items: center; */
    align-items: stretch;
    /* ← Important: keeps children aligned left */
    text-align: left;
    margin-left: 60px;
    border-radius: 6px;
    padding: 2%;
    /* overflow-y: scroll; */
    /* ✅ 將整體內容置中 */
  }


  .sidebar-toggle {
    position: fixed;
    top: 120px;
    /*⬅️ adjust this value to move it lower */
    /* left: 20px; */
    z-index: 1001;
    transition: top 0.3s ease;
  }

  .apply-button-wrapper {
    position: relative;
    bottom: 10px;
    left: 0;
    width: 100%;
    text-align: center;
    /* background: #f8f8f8; */
    padding: 10px 0;
    /* box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1); */
    z-index: 1001;
  }

  .apply-button-wrapper button {
    font-size: 16px;
    padding: 8px 16px;
  }

  .pages {
    margin-left: 70px;
  }
}


/* =====注音模式專用樣式===== */
/* =====注音模式專用樣式 - 完整修正版===== */
.zhuyin-mode .photo {
  width: 400px;
  height: 600px;
  font-size: 23px;
}

.zhuyin-mode .photo-content {
  font-size: 18px;
  padding: 12px;
  /* line-height: 1.8; */
}

/* 完全移除所有間距 - 最強力的修正 */
.zhuyin-mode .photo-desc,
.zhuyin-mode .photo-desc * {
  margin: 0 !important;
  padding: 0 !important;
  line-height: 1 !important;
  vertical-align: baseline !important;
}

/* 針對段落標籤的特別處理 */
.zhuyin-mode .photo-desc p {
  margin: 0 !important;
  padding: 0 !important;
  line-height: 1 !important;
  display: block;
  font-size: inherit;
}

/* 針對可能的 br 標籤 */
.zhuyin-mode .photo-desc br {
  display: none !important;
}

/* 如果你想保留一些 br 標籤的換行效果，可以用這個替代 */
.zhuyin-mode .photo-desc p+p {
  margin-top: 0.5em !important;
}

.zhuyin-mode .photo-desc .zhuyin-box {
  display: inline-flex;
  flex-direction: column-reverse;
  align-items: center;
  justify-content: flex-end;
  margin: 0;
  padding: 0;
  height: 1.6em;
  max-width: 8em;
  width: 2em;
  writing-mode: vertical-lr;
  /* border: 1px dashed yellow; */
  vertical-align: top;
  /* 確保對齊 */
}

.zhuyin-mode .photo-desc .zhuyin-rt {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-family: 'BopomofoRuby', sans-serif;
  font-size: 40%;
  font-feature-settings: "vert" 1;
  height: 8em;
  max-width: 8em;
  width: 3em;
  line-height: 1;
  margin: 0;
  padding: 0;
}

.zhuyin-mode .photo-desc .zhuyin-char {
  display: flex;
  justify-content: center;
  align-items: center;
  /* font-feature-settings: "vert" 1; */
  width: 1.4em;
  height: 1.4em;
  font-size: 1em;
  text-align: center;
  /* border: 1px dashed blue; */
  margin: 0;
  padding: 0;
  line-height: 1;
}



.zhuyin-mode .photo-desc .zhuyin-box.no-zhuyin {
  width: 1.2em !important;
}

.zhuyin-mode .photo-desc .zhuyin-box.no-zhuyin .zhuyin-char {
  writing-mode: horizontal-tb !important;
  font-size: 1em;
  width: 1.2em;
  transform: translateY(0.8em);
}

.zhuyin-mode .photo-content .zhuyin-box.no-zhuyin {
  transform: translateY(-0.25em);
}

.zhuyin-mode .thumbnail {
  height: 30%;
}

.zhuyin-mode .gallery {
  gap: 30px;
  font-size: 16px;
}

/* 注音轉換格式：逐字右側顯示注音 */
.zhuyin-mode .h3 rt {
  /* writing-mode: vertical-rl; */
  text-orientation: mixed;
  text-align: center;
}

.zhuyin-mode .page_text {
  display: inline-flex;
  flex-direction: row;
  justify-content: center;
  /* text-align: center; */
  padding: 0;
  /* padding-top: 2px; */
}

.zhuyin-mode .sidebar-inner {
  max-width: 350px;
  width: 350px;
}

.zhuyin-mode .sidebar * {
  display: flex;
  align-items: flex;
  /* justify-content: left; */
}

.zhuyin-mode .sidebar .zhuyin-box,
.zhuyin-mode .sort-button {
  display: flex;
  align-items: center;
  justify-content: center;
}

.zhuyin-mode .main-container .p .zhuyin-box {
  margin-block-start: 0;
  margin-block-end: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.zhuyin-mode .pages p {
  margin-block-start: 0;
  margin-block-end: 0;
  unicode-bidi: inherit;
  margin: 0;
  word-spacing: 0;
  letter-spacing: 0;
  white-space: normal;
  /* ////////// */
  line-height: 0.2;
  /* /////// */
}

.zhuyin-mode .pages .zhuyin-box {
  width: 2.4em;
  height: 2.1em;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-self: center;
}

.zhuyin-mode .pages .zhuyin-box.halfwidth,
.zhuyin-mode .pages .zhuyin-box.halfwidth .zhuyin-char {
  font-size: large;
  width: max-content;
  height: 2em;
}

.photo-info {
  display: flex;
  flex-direction: column;
  margin-top: 20px;
}

.zhuyin-mode .photo_prev_nav p,
.zhuyin-mode .photo_info p {
  margin-block-start: 0;
  margin-block-end: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.zhuyin-mode .photo_prev_nav p .zhuyin-box,
.zhuyin-mode .photo_info p .zhuyin-box {
  width: 2.2em;
  height: 2.2em;
}

.zhuyin-mode .photo_description p .zhuyin-box {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-self: center;
  line-height: 0%;
  width: 2.4em;
  height: 2.4em;
}

.zhuyin-mode .photo_description p .zhuyin-char {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-self: center;
  width: 2em;
  height: 2.4em;
}

.zhuyin-mode .photo_description p .zhuyin-box.no-zhuyin .zhuyin-char {
  height: 1em;
  transform: translateY(0.6em);
}

/* .zhuyin-mode .photo-info p .zhuyin-box {
  margin-block-start: 0;
  margin-block-end: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 4em;
  height: 4em;
} */

@media (max-width: 768px) {

  .zhuyin-mode h1,
  .zhuyin-mode h2,
  .zhuyin-mode h3 {
    margin-block-start: 0;
    margin-block-end: 0;
  }

  .zhuyin-mode .page_content {
    width: 90vw;
    /* padding-right: 10px; */
    transform: translateX(-5vw);
  }


  .zhuyin-mode .pages p .zhuyin-box {
    width: 2em;
    height: 2.5em;
  }

  .zhuyin-mode .pages p .zhuyin-box .zhuyin-char {
    width: calc(2em * 2 / 3);
    height: 2.5em;
  }
}