* {
  margin: 0; padding: 0; box-sizing: border-box;
}

:root {
  --bg-gradient: linear-gradient(to bottom, #ffffff, #a1c4fd); /* 預設淺色 */
  --text-color: #222;
  --explosion-color: #0a2342;
  --checkpoint-border: #20294e;
  --checkpoint-line: #20294e; 
  --nav-text-color: rgba(255, 255, 255);
  --nav-scrolled-text-color: #20294e;
  --hamburger-color: rgba(54, 54, 54, 0.85);
  --hamburger-scrolled-color: #ffffff;
  --mobile-text-color: rgba(255, 255, 255);
  --mobile-scrolled-color: rgba(54,54,54, 1);
}

.back-to-top {
  position: fixed;
  bottom: 80px;
  right: 20px;
  z-index: 105;
  cursor: pointer;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  padding: 10px;
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  background-color: #0a2342;
  color: #ffffff;
  border: 1px solid #0a2342;
  transition: background 0.3s ease, transform 0.2s ease, opacity 0.3s ease;
}

.back-to-top.show {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* 淺色模式 */
.back-to-top.light {
  background-color: #ffffff;
  color: #0a2342;  /* 深色字 / icon */
  border: 1px solid rgba(255, 255, 255);
}

/* 深色模式 */
.back-to-top.dark {
  background-color: #0a2342;
  color: #ffffff;
  border: 1px solid #0a2342;
}

#theme-toggle {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 50px;
  height: 50px;
  border: none;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  transition: background 0.5s ease, color 0.5s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 105;
}

/* 淺色模式 */
#theme-toggle.light {
  background-color: #ffffff; /* 太陽黃色底 */
  color: #fff;               /* 太陽白色文字/圖案 */
}

/* 深色模式 */
#theme-toggle.dark {
  background-color: #0a2342; /* 深藍底 */
  color: #fff;               /* 月亮白色圖案 */
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text-color);
  background: var(--bg-gradient);
  margin: 0;
  padding: 0;
  line-height: 1.6;
  transition: background 0.8s ease, color 0.5s ease;
}

/* 深色模式 */
body.dark {
  --bg-gradient: linear-gradient(to bottom, #000000, #0a2342); /* 黑 → 深藍 */
  --text-color: #d1d1d1;
  --footer-bg: #0a2342;   /* 深色背景 */
  --footer-text: #d1d1d1; /* 浅文字 */
  --footer-border: rgba(255,255,255,0.1);
  --footer-hover: #d1d1d1; /* hover 白色 */
  --explosion-color: #d1d1d1; /* 深色主題炸方塊顏色 */
  --checkpoint-border: #d1d1d1; /* 深色模式邊框色，例如藍色 */
  --checkpoint-line: #d1d1d1;
  --nav-scrolled-text-color: #d1d1d1;     /* 滾動後也保持淺色 */
  --hamburger-color: rgba(209,209,209,0.85);
  --hamburger-scrolled-color: #d1d1d1;
  --mobile-text-color: rgba(255,255,255);
  --mobile-scrolled-color: rgba(255,255,255,0.8);
}

/* 淺色模式 */
body.light {
  --bg-gradient: linear-gradient(to bottom, #ffffff, #a1c4fd); /* 白 → 藍 */
  --text-color: #20294e;
  --footer-bg: #a1c4fd;   /* 浅藍背景 */
  --footer-text: #2b2b2b; /* 深文字 */
  --footer-border: rgba(0,0,0,0.1);
  --footer-hover: #20294e; /* 深藍色 hover */
  --explosion-color: #20294e; /* 淺色主題炸方塊顏色 */
  --checkpoint-border: #20294e; /* 深色模式邊框色，例如藍色 */
  --checkpoint-line: #20294e;
  --nav-text-color: #ffffff; /* 滾動前淺色 */
  --nav-scrolled-text-color: #20294e;
  --hamburger-color: rgba(54,54,54,0.85);
  --hamburger-scrolled-color: #20294e;
  --mobile-text-color: rgb(255, 255, 255);
  --mobile-scrolled-color: rgba(54,54,54,0.85);
}

.fade-up {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.fade-up.visible {
  opacity: 1;
  transform: translateY(0);
}

nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 60px;
  background: rgba(54, 54, 54, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  font-weight: 500;
  z-index: 100;
  transition: background 0.5s ease, box-shadow 0.5s ease;
  font-family: 'Noto Sans TC', 'Yu Gothic UI', sans-serif;
}

/* logo 置中 */
nav > div.logo {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-weight: 600;
  color: var(--nav-text-color);
  pointer-events: none; /* 點不到 */
  transition: color 0.5s ease;
}

nav.scrolled .logo {
  color: var(--nav-scrolled-text-color);
}

nav.scrolled {
  background: rgba(8, 14, 81, 0.1);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
}

nav.scrolled a {
  color: var(--nav-scrolled-text-color);
}

nav a {
  text-decoration: none;
  /* color: #d1d1d1; */
  color: var(--nav-text-color);
  transition: color 0.5s ease;
  font-size: 1.05rem;
  padding: 8px 4px;
  border-bottom: 2px solid transparent;
}

nav a:hover {
  color: #a384bd;
  border-bottom: 2px solid #a384bd;
}

nav a::after {
  bottom: -2px; /* 再往下移動一點，看起來更平衡 */
}

body.dark nav.scrolled .logo,
body.dark nav.scrolled a {
  color: var(--nav-text-color); /* 保持深色 */
}

main a, .timeline a, .content a {
  color: inherit; /* 跟著父元素走 */
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color 0.3s ease, border-bottom 0.3s ease;
}

a {
  position: relative;
  color: inherit;
  text-decoration: none;
}

a::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 0%;
  background-color: #a384bd;
  transition: width 0.3s ease;
}

a:hover,
a.clicked {
  color: #a384bd; /* 紫色 */
}

a:hover::after,
a.clicked::after {
  width: 100%;
}

.hero {
  position: relative;
  height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

.hero img {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.clean {
  z-index: 1;
}

.blur {
  z-index: 2;
  filter: blur(0);
  transition: filter 1s ease;
  opacity: 1;
}

.clean, .blur {
  display: block;
  width: 100%;
  height: auto;
  
  /* 底部漸層透明 */
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 60%, rgba(0,0,0,0) 100%);
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: cover;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 60%, rgba(0,0,0,0) 100%);
  mask-repeat: no-repeat;
  mask-size: cover;
}

.hero-text {
  position: absolute;
  top: 50%; 
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: white;
  text-shadow: 0 0 30px rgba(0,0,0,0.3), 0 0 10px rgba(0,0,0,0.4);
  opacity: 0;
  animation: fadeInText 1s ease forwards;
  animation-delay: 1.1s;
}

.line-wrapper {
  position: relative;
  width: 100%;
  height: 100vh;
  z-index: 10;
}

/* 中心線條（會展開並消失） */
.center-line {
  position: absolute;
  top: 50%;
  left: 50%;
  height: 2px;
  background-color: white;
  width: 0;
  transform: translate(-50%, -50%);
  animation: expandWidth 1s ease forwards, fadeOut 0.5s ease forwards;
  animation-delay: 0s, 1s;
}

/* 上下滑開的線條（預設透明） */
.half-line {
  position: absolute;
  left: 50%;
  width: 400px;
  height: 2px;
  background-color: white;
  opacity: 0;
  transform: translateX(-50%);
}

/* 上方線條從中間往上滑出 */
.half-line.top {
  top: 50%;
  animation: slideUp 1s ease forwards;
  animation-delay: 1s;
}

/* 下方線條從中間往下滑出 */
.half-line.bottom {
  top: 50%;
  animation: slideDown 1s ease forwards;
  animation-delay: 1s;
}

main {
  background: inherit;        /* 繼承 body 背景漸層 */
  padding: 40px 20px;
  max-width: 1200px;
  margin: 20px auto 50px;    /* 上下稍微拉開，讓陰影看起來舒服 */
  color: var(--text-color);   /* 文字跟 body 一樣 */
  border-radius: 20px;        /* 圓角 */
  box-shadow: 0 8px 20px rgba(0,0,0,0.3); /* 陰影 */
  transition: color 0.5s ease, box-shadow 0.5s ease, background 0.8s ease;
}

h2 {
  color: var(--text-color);  /* 改成跟 body 的文字顏色同步 */
  transition: color 0.5s ease;
  margin-bottom: 20px;
}

p {
  line-height: 1.6;
  font-size: 1.1rem;
  color: var(--text-color);  /* 改成跟 body 的文字顏色同步 */
  transition: color 0.5s ease;
}

hr {
  border: none;                   /* 先移除預設 */
  height: 1px;                     /* 線高 */
  background-color: var(--text-color);  /* 跟 body 文字顏色同步 */
  transition: background-color 0.5s ease;
  margin: 20px 0;
}

/* 漢堡按鈕 */
.hamburger {
  display: none;
  flex-direction: column;
  cursor: pointer;
  gap: 6px;
  z-index: 101;
  color: var(--mobile-text-color);
  transition: 0.3s ease;
}

.hamburger div {
  width: 24px;
  height: 2px;
  background: #333;
  border-radius: 2px;
  background: var(--mobile-text-color);
  transition: background 0.5s ease, transform 0.4s ease;
}

/* 捲動後：整個按鈕顏色 & 線條顏色 */
nav.scrolled .hamburger {
  color: var(--mobile-scrolled-color);
}

nav.scrolled .hamburger div {
  background: var(--mobile-scrolled-color);
}

/* 漢堡按鈕變X動畫 */
.hamburger.active div:nth-child(1) {
  transform: rotate(45deg) translate(5px, -5px);
}

.hamburger.active div:nth-child(3) {
  transform: rotate(-45deg) translate(5px, 5px);
}

.hamburger div {
  transform-origin: center;
}

/* 手機版選單 */
.mobile-menu {
  display: flex;
  position: fixed;
  top: 54px; /* nav 高度 */
  left: -250px; /* 藏左側外面 */
  width: 250px;
  height: 100vh;
  color: var(--mobile-text-color);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  flex-direction: column;
  align-items: flex-start;
  padding: 30px 20px;
  gap: 20px;
  box-shadow: 2px 0 10px rgba(0,0,0,0.5);
  transition: left 0.3s ease, background 0.5s ease, color 0.5s ease;
  z-index: 99;
}

.mobile-menu a {
  color: var(--mobile-text-color);
  transition: color 0.5s ease;
}

.mobile-menu.active a {
  color: var(--mobile-scrolled-color);
}

.mobile-menu.active.scrolled a {
  color: var(--mobile-scrolled-color);
}

.mobile-menu.active a::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -4px;  /* 底線位置可調 */
  height: 2px;
  width: 0;
  background-color: #d1d1d1; /* 底線紫色 */
  transition: width 0.3s ease;
}

.mobile-menu.active a:hover,
.mobile-menu.active a:focus {
  color: #d1d1d1;  /* 滑鼠/鍵盤焦點時文字紫 */
}

.mobile-menu.active a:hover::after,
.mobile-menu.active a:focus::after {
  width: 100%;   /* 底線展開 */
}

.mobile-menu.scrolled {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.1);
}

.mobile-menu.active {
  left: 0;
}

.timeline {
  margin: 5em auto;
  max-width: 34.15em;
}

.checkpoint {
  max-width: 34em;
  padding-top: 2em;
  padding-bottom: 2em;
  position: relative;
}

.checkpoint div {
  border: 2px solid var(--checkpoint-border);
  border-radius: 1em;
  padding: 1.5em;
  transition: border 0.5s ease;
}

.checkpoint p {
  line-height: 27px;
  color: var(--text-color);  /* 改成跟 body 的文字顏色同步 */
  transition: color 0.5s ease;
}

.checkpoint:nth-child(odd) {
  border-left: 3px solid var(--checkpoint-border);
  padding-left: 3em;
  transform: translateX(16.85em);
  transition: border 0.5s ease;
}

.checkpoint:nth-child(even) {
  border-right: 3px solid var(--checkpoint-border);
  padding-right: 3em;
  transform: translateX(-17em);
  transition: border 0.5s ease;
}

.checkpoint:nth-child(odd)::before,
.checkpoint:nth-child(even)::before {
  border-left: 2px solid var(--checkpoint-border);
  content: '';
  background: var(--checkpoint-line);
  width: 3em;
  height: 3px;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  transition: border 0.5s ease;
  transition: background 0.5s ease;
}

.checkpoint:nth-child(odd)::before {
  left: 0;
}

.checkpoint:nth-child(even)::before {
  right: 0;
}

.checkpoint:nth-child(odd) div::before,
.checkpoint:nth-child(even) div::before {
  content: '';
  background: var(--checkpoint-line);
  box-shadow: 0 0 0.5em #000000;
  width: 0.8em;
  height: 0.8em;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  border-radius: 50%;
  transition: background 0.5s ease;
}

.checkpoint:nth-child(odd) div::before {
  left: -0.5em;
}

.checkpoint:nth-child(even) div::before {
  right: -0.5em;
}

.line-container {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

.line {
  position: absolute;
  color: white;
  font-size: 20px;
  opacity: 0;
  animation: float 6s ease-in-out infinite;
  user-select: none;
  white-space: nowrap;
}

.explosion-container {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  pointer-events: none;
  overflow: visible;
  z-index: 102;
}

.explosion-box {
  position: absolute;
  background-color: transparent; /* 透明背景 */
  border: 2px solid var(--explosion-color, #20294e);
  animation: explodeFade 1.7s forwards;
}

.site-footer {
  background-color: var(--footer-bg);
  color: var(--footer-text);
  text-align: center;
  padding: 15px 20px;
  font-size: 0.95rem;
  border-top: 1px solid var(--footer-border);
}

.site-footer .social-icons {
  margin-top: 15px;
  display: flex;
  justify-content: center;
  gap: 20px;
}

.site-footer .social-icons a {
  font-size: 1.3rem;
  transition: color 0.3s ease, transform 0.3s ease;
}

.site-footer .social-icons a:hover {
  color: var(--footer-hover);
  transform: scale(1.2);
}

/* 所有 icon a 標籤取消底線和 after 效果 */
a.icon {
  border-bottom: none !important;
}

a.icon::after {
  display: none !important;
}

@media (min-width: 769px) {
  nav a::after {
    background-color: #d1d1d1;
  }

  nav a:hover,
  nav a.clicked {
    color: #d1d1d1;
  }
}

@keyframes fadeInText {
  from {
    opacity: 0;
    transform: translate(-50%, -30%);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

@keyframes expandWidth {
  to {
    width: 400px;
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
  }
}

@keyframes slideUp {
  to {
    transform: translate(-50%, -100px);
    opacity: 1;
  }
}

@keyframes slideDown {
  to {
    transform: translate(-50%, 100px);
    opacity: 1;
  }
}

@keyframes explodeFade {
  0% {
    opacity: 1;
    transform: scale(1) translate(0,0) rotate(0deg);
  }

  100% {
    opacity: 0;
    transform: scale(1.5) translate(var(--dx), var(--dy)) rotate(var(--dr));
  }
}

@keyframes float {
  0% {
    transform: translate(0, 0) rotate(0deg);
    opacity: 0;
  }

  20% {
    opacity: 1;
  }

  50% {
    transform: translate(-30px, -50px) rotate(180deg);
    opacity: 0.8;
  }

  80% {
    opacity: 1;
  }
  
  100% {
    transform: translate(50px, 60px) rotate(360deg);
    opacity: 0;
  }
}

/* RWD */
@media (max-width: 768px) {
  .nav-links {
    display: none;
  }

  .hamburger {
    display: flex;
  }
}

/* RWD 字體微調 */
@media (max-width: 768px) {
  nav {
    gap: 16px;
    font-size: 0.95rem;
    height: 56px;
  }
    
  nav a {
    font-size: 0.95rem;
    padding: 6px 2px;
  }
    
  .hero-text {
    font-size: 0.95rem;
    padding: 20px 16px;
  }
    
  h1 {
    font-size: 1.6rem;
  }
    
  h2 {
    font-size: 1.3rem;
  }
    
  p {
    font-size: 1rem;
  }
    
  main {
    padding: 24px 16px;
  }
}

@media screen and (max-width: 1150px) {
  .timeline {
    width: 80vw;
  }

  .timeline .checkpoint {
    width: 100%;
    transform: none;
    padding-left: 0;
    padding-right: 0;
    border: none;
  }

  .timeline .checkpoint::before {
    width: 3px;
    height: 4em;
    top: -2em;
    left: 50%;
    transform: translateX(-50%);
  }

  .timeline .checkpoint div::before {
    top: -0.5em;
    left: 50%;
    transform: translateX(-50%);
  }
}
