/*—— 自訂字體 ——*/
@font-face {
  font-family: "GenSenRounded2TW-R";
  src: url("../font/GenSenRounded2TW-R.otf") format("opentype"),
       url("../font/GenSenRounded2TW-R.woff2") format("woff2");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "GenSenRounded2TW-L";
  src: url("../font/GenSenRounded2TW-L.otf") format("opentype"),
       url("../font/GenSenRounded2TW-L.woff2") format("woff2");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

html {
  font-size: 16px;
  letter-spacing: 6px;
  margin: 0;
  padding: 0;
  height: 100%;
  min-height: 100%;
  background: url("../images/首頁背景星空.webp") no-repeat center center fixed;
  background-size: cover;
  font-family: "GenSenRounded2TW-R", sans-serif;
}

@keyframes rubberBand {
  0% {
    transform: scale3d(1, 1, 1);
  }
  30% {
    transform: scale3d(1.15, 0.85, 1);
  }
  40% {
    transform: scale3d(0.85, 1.15, 1);
  }
  50% {
    transform: scale3d(1.05, 0.95, 1);
  }
  65% {
    transform: scale3d(0.975, 1.02, 1);
  }
  75% {
    transform: scale3d(1.025, 0.975, 1);
  }
  100% {
    transform: scale3d(1, 1, 1);
  }
}

.rubberBand {
  animation: rubberBand 0.75s ease;
}

input,
textarea,
select {
  font-size: 16px;
}

::placeholder {
  color: #4a4a4a;
}

@media (max-width: 480px) {
  html {
    font-size: 14px;
  }
}

@media (max-width: 768px) {
  html {
    font-size: 15px;
  }
}

@media (max-width: 1200px) {
  html {
    font-size: 16px;
  }
}

@media (min-width: 1440px) {
  html {
    font-size: 18px;
  }
}

.loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.loader {
  height: 50px;
  aspect-ratio: 2;
  border: 10px solid transparent;
  box-sizing: border-box;
  background: 
    radial-gradient(farthest-side,#eee 98%,#0000) left/20px 20px,
    radial-gradient(farthest-side,#eee 98%,#0000) left/20px 20px,
    radial-gradient(farthest-side,#eee 98%,#0000) center/20px 20px,
    radial-gradient(farthest-side,#eee 98%,#0000) right/20px 20px,
    rgba(0,0,0,0);
  background-repeat: no-repeat;
  filter: contrast(10);
  animation: l14 1s infinite;
}
@keyframes l14 {
  100%  {background-position:right,left,center,right}
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: url("../images/首頁背景星空.webp") no-repeat center center;
  background-size: cover;
  z-index: -1;
  transform: translateZ(0);
}

.scene {
  position: relative;
  display: none;
  flex-direction: column;
  align-items: center;
  width: 900px;
  max-width: 90vw;
  min-height: 27.8rem;
  padding: 20px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 72px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  text-align: center;
  transition: transform .05s ease-in-out;
  z-index: 1;
}

.scene-1{
  filter: blur(8px) brightness(0.8);
  opacity: 0.6;
  transform: scale(1.05);
  transition: filter 2.5s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              opacity 2.5s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              scale 2.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.scene-1.awakening {
    filter: blur(0) brightness(1);
    opacity: 1;
    transform: scale(1);
}


.scene::before {
  content: "";
  position: absolute;
  inset: 0;
  -webkit-box-shadow:
  inset -7px -5.25px 2px -6.5px rgba(255, 255, 255), 
  inset 7px 5.25px 2px -6.5px rgb(255, 255, 255),
  inset -2.25px -8px 2px -6.75px rgb(255, 255, 255), 
  inset 2.25px 8px 2px -6.75px rgb(255, 255, 255),
  4px 8px 32px 0px rgba(110, 110, 110, 0.25);
  box-shadow:
  inset -7px -5.25px 2px -6.5px rgba(255, 255, 255), 
  inset 7px 5.25px 2px -6.5px rgb(255, 255, 255),
  inset -2.25px -8px 2px -6.75px rgb(255, 255, 255), 
  inset 2.25px 8px 2px -6.75px rgb(255, 255, 255),
  4px 8px 32px 0px rgba(110, 110, 110, 0.25);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: -1;
  border-radius: 72px;
}

.scene.active {
  display: flex;
  z-index: 1;
}

.scene.active .entertain-grid,
.scene.active .diet-grid, 
.scene.active .food-grid,
.scene.active .transport-grid,
.scene.active .entertain-card,
.scene.active .home-card,
.scene.active .travel-card,
.scene.active .daily-card,
.scene.active .waste-container,
.scene.active .template-wrapper{
  animation: slideIn 0.5s ease forwards;
  z-index: 1;
}

.slideContainer {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 0.5rem;
  overflow-y: visible;
  overflow-x: hidden;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0%);
    opacity: 1;
  }
}

h1 {
  font-size: 1.5rem;
  color: #6c808f;
  font-family: "GenSenRounded2TW-R", sans-serif;
  font-weight: 400;
  letter-spacing: 0.6rem;
  text-shadow: #7f7f7f40 2pt 2pt 3pt;
  margin: 0.5rem 0;
}

/* 切換開關 */
.chapter-bar {
  display: flex;
  align-items: center;   /* 水平置中 */
  justify-content: center; /* 垂直置中 */
  text-align: center;   /* 文字置中 */
  position: relative;
  width: fit-content;
  height: fit-content;
  background-color: rgba(255, 255, 255, 0.05);
  padding: 0.4rem;;
  margin-top: 0.25rem;
  border-radius: 32px;
  justify-content: space-around;
  align-items: center;

  z-index: 0;
}

.chapter-bar::before {
  content: "";
  position: absolute;
  inset: 0;
  -webkit-box-shadow:
  inset -7.5px -4.5px 0 -7px rgb(255, 255, 255), 
  inset 7.5px 4.5px 0 -7px rgb(255, 255, 255),
  inset -2.75px -8.5px 0 -7.25px rgb(255, 255, 255), 
  inset 2.75px 8.5px 0 -7.25px rgb(255, 255, 255),
  2px 2px 12px 4px rgba(110, 110, 110, 0.15);
  box-shadow:
  inset -7.5px -4.5px 0 -7px rgb(255, 255, 255), 
  inset 7.5px 4.5px 0 -7px rgb(255, 255, 255),
  inset -2.75px -8.5px 0 -7.25px rgb(255, 255, 255), 
  inset 2.75px 8.5px 0 -7.25px rgb(255, 255, 255),
  2px 2px 12px 4px rgba(110, 110, 110, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 0;
  border-radius: 32px;
}

.chapter-button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #6D808F;
  text-decoration: none;
  scale: 0.95;
  padding: 0.15rem 1.25rem 0.15rem 1.5rem;
  transition: background-color 0.3s ease;
  border-radius: 96px;
  text-wrap: nowrap;
  z-index: 999;
}

.chapter-button.active {
  background-color: rgba(255, 255, 255, 0.35);
  border: solid 1.5px #dddddd80;
}


.chapter-button:hover {
  background-color: rgba(255, 255, 255, 0.5);;
  cursor: pointer;
}

.chapter-icon {
  font-size: 1rem;
  line-height: 1;
}

.chapter-label {
  font-size: 0.6rem;
  margin-top: 2px;
}

@media (max-width: 600px) {
  .chapter-button {
    padding: 0.15rem 1rem 0.15rem 1.25rem;
  }

  .chapter-icon {
  font-size: 0.8rem;
}
}

@media (max-width: 480px) {
  .chapter-button {
    padding: 0.15rem 0.25rem 0.15rem 0.5rem;
  }

  .chapter-icon {
  font-size: 0.8rem;
}
}



/* 跳轉橫槓 */

.page-indicator {
  display: flex;
  justify-content: center;
  align-items: baseline;
  width: 100%;
  margin: 1rem 0 1.5rem 0;
}

.bar-container {
  display: flex;
  align-items: center;
  width: 60%;
  gap: 1rem;
}

@media (max-width: 600px) {
  .scene h1 {
    font-size: 1.25rem;
    line-height: 1.8;
    margin-bottom: 1.5rem ;
  }
  .page-indicator {
    display: none;
  }

  .bar-container {
    width: 80%;
  }
}

.bar-hit-area {
  display: flex;
  flex: 1;
  padding: 12px;
  margin: -12px; /* 抵銷外推影響布局 */
  cursor: pointer;
}

.bar-hit-area:hover .bar {
  background-color: #b5c1c6;
  box-shadow: 1pt 1pt 4pt #7f7f7f60, -2pt -2pt 3pt #ffffff55;
}

.bar {
  flex: 1;
  height: 5px;
  background-color: #e4ecf1;
  transition: background-color 0.3s;
  cursor: pointer;
}

.bar.active {
  background-color: #b5c1c6;
  box-shadow: 1pt 1pt 4pt #7f7f7f60, -2pt -2pt 3pt #ffffff55;
}

/* 換頁按鈕 */

.nav-btn {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 4rem;
  height: 4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: #64748b82;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  backdrop-filter: blur(4px);
  z-index: 1000;
  user-select: none;
}

.nav-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  -webkit-box-shadow:
  inset -0.185rem -0.235rem 0.315rem -0.295rem rgba(255, 255, 255), 
  inset 0.185rem 0.25rem 0.315rem -0.295rem rgba(255, 255, 255),
  -0.06rem -0.03rem 0 0 rgba(255, 255, 255), 
  0.03rem 0.03rem 0 0 rgba(255, 255, 255);
  box-shadow:
  inset -0.285rem -0.235rem 0.1rem -0.295rem rgba(255, 255, 255), 
  inset 0.285rem 0.235rem 0.1rem -0.295rem rgba(255, 255, 255),
  -0.03rem -0.025rem 0 0 rgba(255, 255, 255), 
  0.025rem 0.025rem 0 0 rgba(255, 255, 255),
  4px 16px 48px 8px rgba(110, 110, 110, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: -1;
  border-radius: 50%;
}

.nav-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center,#ffffff, #eff3f910);
  opacity: 0;
  transition: opacity 0.25s ease;
  border-radius: 50%;
  z-index: -1;
}

.nav-btn:hover::after {
  opacity: 1;
}

.prev-btn {
  padding: 0 3px 5px 0 ;
  left: -100px;
}
.next-btn {
  padding: 0 0 5px 3px;
  right: -100px;
}

@media (max-width: 1200px) {
  .nav-btn {
    scale: 0.9;
  }
}

@media (min-width: 600px) and (max-width: 1024px) {
.story-container, .scene {
  scale: 0.8;
}

.scene {
  min-height: unset;
}

}

@media (max-height: 600px) and (min-width: 1024px) and (max-width: 1200px) and (orientation: landscape) {
.story-container, .scene {
  scale: 0.8;
}
}

@media (max-height: 600px) and (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
body {
  height: 100%;
}
.story-container, .scene {
  scale: 0.5;
}
}

@media (max-width: 600px) or ((max-width: 768px) and (orientation: portrait)) {
  .nav-btn {
    scale: 0.75;
    top: unset;
  }
  .prev-btn {
    padding: 0 3px 8px 0 ;
    left: unset;
    top: -4.5rem;
    transform: rotate(90deg);
  }
  .next-btn {
    padding: 0 0 8px 3px;
    right: unset;
    bottom: -4.5rem;
    transform: rotate(90deg);

  }
}

/* 切換開關 */

@keyframes switchOn {
  0% {
    transform: translateX(20%);
  }
  20% {
    transform: translateX(127%);
  }
  40% {
    transform: translateX(103%);
  }
  60% {
    transform: translateX(123%);
  }
  80% {
    transform: translateX(117%);
  }
  100% {
    transform: translateX(120%);
  }
}

@keyframes switchOff {
  0% {
    transform: translateX(120%);
  }
  20% {
    transform: translateX(-2%);
  }
  40% {
    transform: translateX(22%);
  }
  60% {
    transform: translateX(2%);
  }
  80% {
    transform: translateX(8%);
  }
  100% {
    transform: translateX(5%);
  }
}

@keyframes appleSwitchOn {
  0% {
    transform: translateX(0%);
    scale: 1;
  }
  20% {
    transform: translateX(100%);
    scale: 0.9;
  }
  40% {
    transform: translateX(85%);
    scale: 1.1;
  }
  60% {
    transform: translateX(95%);
    scale: 0.95;
  }
  80% {
    transform: translateX(87%);
    scale: 0.9l
  }
  100% {
    transform: translateX(90%);
    scale: 1;
  }
}

@keyframes appleswitchOff {
  0% {
    transform: translateX(90%);
    scale: 1;
  }
  20% {
    transform: translateX(10%);
    scale: 0.9;
  }
  40% {
    transform: translateX(-5%);
    scale: 1.1;
  }
  60% {
    transform: translateX(10%);
    scale: 0.95;
  }
  80% {
    transform: translateX(2%);
    scale: 1.05;
  }
  100% {
    transform: translateX(0%);
    scale: 1;
  }
}

.toggle-switch {
  position: relative;
  min-width: 40px;
  min-height: 20px;
  margin: 2px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-switch .slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #eff3f990;
  border: none;
  box-shadow: 2pt 2.5pt 3pt #6d808f50 inset;
  border-radius: 10px;
  transition: 0.75s;
}

.toggle-switch .slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2.3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.3s;
  box-shadow: 5pt 5pt 10pt #c3cadb76;
}


.toggle-switch input:checked + .slider {
  background: #d0d2d6;
}

.toggle-switch input:checked + .slider:before {
  animation: switchOn 0.75s linear forwards;
}

.toggle-switch input:not(:checked) + .slider:before {
  animation: switchOff 0.75s linear forwards;
}

.toggle-row .apple-toggle-switch {
  display: inline-flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  min-width: 80px;
  min-height: 27px;
  width: 100%;
  padding: 4px 8px;
  margin: 2px;
}

.toggle-row .apple-toggle-switch .nowrap-text {
  position: relative;
  cursor: pointer;
  z-index: 0;
  width: 50%;
  font-size: 0.9rem;
  letter-spacing: 2px;
}

.toggle-row .apple-toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-row .apple-toggle-switch .slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.75);
  border: solid 1px #dddddd80;
  border-radius: 20px;
  transition: translate 0.75s;
  z-index: -1;
}

.toggle-row .apple-toggle-switch .slider:before {
  position: absolute;
  content: "";
  height: 80%;
  width: 50%;
  left: 2px;
  bottom: 3.5px;;
  background-color:rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  transition: 0.3s;
  z-index: 0;
  -webkit-box-shadow:
  inset -7px -5.25px 2px -6.5px rgba(255, 255, 255), 
  inset 7px 5.25px 2px -6.5px rgb(255, 255, 255),
  inset -2.25px -8px 2px -6.75px rgb(255, 255, 255), 
  inset 2.25px 8px 2px -6.75px rgb(255, 255, 255),
  4px 8px 32px 0px rgba(110, 110, 110, 0.25);
  box-shadow:
  inset -7px -5.25px 2px -6.5px rgba(255, 255, 255), 
  inset 7px 5.25px 2px -6.5px rgb(255, 255, 255),
  inset -2.25px -8px 2px -6.75px rgb(255, 255, 255), 
  inset 2.25px 8px 2px -6.75px rgb(255, 255, 255),
  4px 8px 32px 0px rgba(110, 110, 110, 0.25);
}

.toggle-row .apple-toggle-switch input:checked + .slider:before {
  animation: appleSwitchOn 0.5s linear forwards;
}

.toggle-row .apple-toggle-switch input:not(:checked) + .slider:before {
  animation: appleswitchOff 0.5s linear forwards;
}


/* input 框樣式 */
.custom-number-input input[type="number"],
.toggle-card input[type="number"],
.fashion-box input[type="number"] {
  padding: 4px 8px;
  background: #fff;
  color: #4a4a4a;
  text-align: center;
  min-width: 2.5rem;
  max-width: 3rem;
  height: 20px;
  border: 0.25pt solid #b5c1c623;
  border-radius: 16px;
  box-shadow: inset 1pt 1pt 4pt #6d808f70;
  outline: none;
}

.custom-number-input {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.custom-number-input input[type="number"]::-webkit-inner-spin-button,
.custom-number-input input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.custom-number-input button {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  background: none;
  border: none;
  border-radius: 100%;
  background: rgba(255, 255, 255);
  width: 1rem;
  height: 1rem;
  padding: 10px;
  font-size: 1rem;
  color: #b5c1c6;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s;
}

.custom-number-input button:hover {
  background-color: #ddd;
}

.custom-number-input .btn-decrement {
  position: relative;
  font-size: 1.5rem;
}

.custom-number-input .btn-decrement .decrement {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
}

@media (max-width: 600px) {

  .scene {
    max-width: 85vw;
    margin: 4rem 0;
    border-radius: 32px;
  }

  .scene::before {
    border-radius: 32px;
  }

  .toggle-row {
    gap: 0.25rem;
  }
}

/*故事按鈕(目前無用)*/
/* 右下角故事開關（膠囊版） */
.story-toggle-btn {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1000;
  padding: 0 12px;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.7rem;
  letter-spacing: 2px;
  color: #6c808f;
  font-family: "GenSenRounded2TW-R", sans-serif;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 50px;
  border: none;
  cursor: pointer;

  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);

  user-select: none;

  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* 玻璃擬物外框（複製自 .direct-calc-btn） */
.story-toggle-btn::before {
  content: "";
  position: absolute;
  inset: 0;

  -webkit-box-shadow:
    inset -0.185rem -0.235rem 0.315rem -0.295rem rgba(255, 255, 255),
    inset 0.185rem 0.25rem 0.315rem -0.295rem rgba(255, 255, 255),
    -0.06rem -0.03rem 0 0 rgba(255, 255, 255),
    0.03rem 0.03rem 0 0 rgba(255, 255, 255);

  box-shadow:
    inset -0.285rem -0.235rem 0.1rem -0.295rem rgba(255, 255, 255),
    inset 0.285rem 0.235rem 0.1rem -0.295rem rgba(255, 255, 255),
    -0.03rem -0.025rem 0 0 rgba(255, 255, 255),
    0.025rem 0.025rem 0 0 rgba(255, 255, 255),
    4px 16px 48px 8px rgba(110, 110, 110, 0.15);

  border-radius: 50px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: -1;
}

/* hover 的光暈 */
.story-toggle-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, #ffffff, #eff3f910);
  opacity: 0;
  transition: opacity 0.25s ease;
  border-radius: 50px;
  z-index: -1;
}

.story-toggle-btn:hover::after {
  opacity: 1;
}

/* ON/OFF 的透明度提示 */
.story-toggle-btn[data-on="false"] {
  opacity: 0.45;
}

/* 手機尺寸調整 */
@media (max-width: 600px) {
  .story-toggle-btn {
    position: absolute;  /* ★ 關鍵！從 fixed 改成 absolute */
    bottom: 120px;
    right: 12px;
    scale: 0.85;
  }
}