/* ==========================================================================
   1. 核心設計系統與變數 (Design System & Theme Variables)
   ========================================================================== */
:root {
  /* 字體系統 */
  --font-title: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* 科技福音戰士紫綠漸層 (預設暗色：福音戰士初號機配色) */
  --gradient-primary: linear-gradient(135deg, #7f00ff 0%, #00ff66 100%);
  --gradient-accent: linear-gradient(135deg, #00ff66 0%, #7f00ff 100%);
  --gradient-text: linear-gradient(135deg, #a73eff 0%, #00ff66 100%);

  /* 共用轉化與陰影 */
  --transition-normal: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);

  /* 預設為暗色主題 (科幻福音戰士配色) */
  --bg-primary: #0a0614;
  --bg-secondary: #120b24;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --glass-bg: rgba(18, 11, 36, 0.5);
  --glass-border: rgba(255, 255, 255, 0.06);
  --card-hover-bg: rgba(0, 255, 102, 0.02);
  --btn-secondary-bg: rgba(255, 255, 255, 0.04);
  --btn-secondary-border: rgba(255, 255, 255, 0.08);
  --input-bg: rgba(18, 11, 36, 0.7);
  --input-focus-border: #00ff66;
  --glow-1: rgba(0, 255, 102, 0.12);
  --glow-2: rgba(127, 0, 255, 0.12);
  --mobile-menu-bg: rgba(10, 6, 20, 0.84);
}

/* 亮色主題覆蓋 (新世紀福音戰士貳號機配色：熱烈烈紅、亮黃橘、金屬白與深裝甲灰) */
html.light {
  /* 貳號機正統熱血三色漸層 (烈紅 -> 亮橘 -> 金屬金)，完美重現貳號機靈魂塗裝，且深琥珀金能保證白底上極佳的對比度 */
  --gradient-primary: linear-gradient(135deg, #e60012 0%, #ff5500 50%, #c27a00 100%);
  --gradient-accent: linear-gradient(135deg, #c27a00 0%, #ff5500 50%, #e60012 100%);
  --gradient-text: linear-gradient(135deg, #e60012 0%, #ff5500 50%, #c27a00 100%);

  --bg-primary: #faf8f2; /* 高質感香檳暖米白 (溫潤且防刺眼) */
  --bg-secondary: #f4efe2; /* 溫潤象牙黃 (Champagne Sand) */
  --text-primary: #1c1917; /* 裝甲深炭灰，高規格可讀性對比度 */
  --text-secondary: #44403c;
  --text-muted: #78716c;
  --glass-bg: rgba(250, 248, 242, 0.85);
  --glass-border: rgba(230, 0, 18, 0.1); /* 貳號機烈紅色邊框線 */
  --card-hover-bg: rgba(230, 0, 18, 0.02);
  --btn-secondary-bg: rgba(250, 248, 242, 0.95);
  --btn-secondary-border: rgba(230, 0, 18, 0.08);
  --input-bg: var(--bg-secondary); /* 採用與表單卡片一致的象牙黃，消除文字框偏白的突兀感 */
  --input-focus-border: #e60012;
  --glow-1: rgba(230, 0, 18, 0.08); /* 烈紅色背景光球 */
  --glow-2: rgba(255, 153, 0, 0.08); /* 橘黃色背景光球 */
  --mobile-menu-bg: rgba(250, 248, 242, 0.88);
}

/* ==========================================================================
   2. 基礎重設與 Layout (Base Resets & Grid Setup)
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  position: relative; /* 作為背景發光球的相對基準 */
  transition: background-color 0.5s ease, color 0.3s ease;
}

main {
  width: 100% !important;
  display: block !important;
}

h1, h2, h3, h4, .logo {
  font-family: var(--font-title);
  font-weight: 700;
  letter-spacing: -0.02em;
}

a {
  text-decoration: none;
  color: inherit;
  transition: var(--transition-normal);
}

:focus-visible {
  outline: 3px solid var(--input-focus-border);
  outline-offset: 3px;
}

ul {
  list-style: none;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin-left: auto !important;
  margin-right: auto !important;
  padding: 0 1.5rem;
  display: flex;
  flex-direction: column;
}

.grid {
  display: grid;
  gap: 2rem;
}

.grid > * {
  min-width: 0;
}

.grid-2 { grid-template-columns: minmax(0, 1fr); }
.grid-3 { grid-template-columns: minmax(0, 1fr); }
.grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (min-width: 768px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ==========================================================================
   3. 設計系統 Token 與 UI 卡片 (Glassmorphism & Utilities)
   ========================================================================== */
.gradient-text {
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: inline-block;
}

.badge {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Glassmorphism 玻璃卡片 */
.glass-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 1.25rem;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.05);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  transition: var(--transition-spring);
}

/* 
  背景發光光暈 (Ambient Glows)
  改為 Fixed 定位，解決重新整理時頁面產生滾動條偏移與偏位 Bug。
*/
.blob-glow {
  position: fixed;
  width: 45vw;
  height: 45vw;
  border-radius: 50%;
  filter: blur(130px);
  z-index: -1;
  pointer-events: none;
  opacity: 0.75;
  animation: float-glow 22s infinite alternate ease-in-out;
}

.blob-1 {
  background: var(--glow-1);
  top: 5%;
  right: -10%;
}

.blob-2 {
  background: var(--glow-2);
  bottom: 5%;
  left: -15%;
  animation-delay: -6s;
}

@keyframes float-glow {
  0% { transform: translate(0, 0) scale(1) rotate(0deg); }
  100% { transform: translate(4%, 8%) scale(1.05) rotate(120deg); }
}

/* ==========================================================================
   4. 按鈕與互動元件 (Buttons & Actions)
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.875rem 2rem;
  border-radius: 0.75rem;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition-spring);
  box-shadow: var(--shadow-sm);
}

.btn:active {
  transform: scale(0.97);
}

.primary-btn {
  background: var(--gradient-primary);
  color: #07090e;
  border: none;
}

html.dark .primary-btn {
  color: #000; /* 福音戰士綠下文字黑色對比好 */
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px -10px rgba(0, 255, 102, 0.4);
}

html.light .primary-btn:hover {
  box-shadow: 0 10px 20px -10px rgba(255, 126, 95, 0.4);
}

.secondary-btn {
  background: var(--btn-secondary-bg);
  border: 1px solid var(--btn-secondary-border);
  color: var(--text-primary);
}

.secondary-btn:hover {
  background: var(--card-hover-bg);
  transform: translateY(-2px);
}

.icon-btn {
  background: var(--btn-secondary-bg);
  border: 1px solid var(--btn-secondary-border);
  color: var(--text-primary);
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-spring);
}

.icon-btn:hover {
  background: var(--card-hover-bg);
  transform: translateY(-2px);
}

/* 語系按鈕 (Lang Button) */
.lang-btn {
  font-family: var(--font-title);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.lang-btn:hover {
  color: var(--text-primary);
  border-color: var(--input-focus-border);
}

/* ==========================================================================
   5. 導航欄 (Navigation Bar - 選單置中與右上按鈕排版)
   ========================================================================== */
.navbar-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--glass-border);
  transition: border-color 0.5s ease;
}

.navbar {
  display: flex;
  flex-direction: row !important; /* 強制橫向並列，不受 .container 的 column 覆蓋影響 */
  align-items: center;
  justify-content: space-between;
  height: 4.5rem;
  flex-wrap: nowrap !important; /* 強制不折行 */
  width: 100%;
}

.logo {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  flex-shrink: 0;
}

.nav-links {
  display: none;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0 !important; /* 確保按鈕絕不擠壓 */
  margin-left: auto; /* 將 Actions 始終置右 */
}

/* 暗色主題下隱藏太陽圖示，顯示月亮圖示 */
html.dark .sun-icon { display: none; }
html.dark .moon-icon { display: block; }
html.light .sun-icon { display: block; }
html.light .moon-icon { display: none; }

/* 手機版選單切換樣式 */
.mobile-menu-btn {
  display: inline-flex;
}

.mobile-menu-btn .line-top,
.mobile-menu-btn .line-mid,
.mobile-menu-btn .line-bot {
  transition: transform 0.3s ease, opacity 0.2s ease;
  transform-box: fill-box;
  transform-origin: center;
}

.mobile-menu-btn[aria-expanded="true"] .line-mid {
  opacity: 0;
}

.mobile-menu-btn[aria-expanded="true"] .line-top {
  transform: translateY(6px) rotate(45deg);
}

.mobile-menu-btn[aria-expanded="true"] .line-bot {
  transform: translateY(-6px) rotate(-45deg);
}

@media (min-width: 768px) {
  /* 大螢幕下採用三欄等寬 (Three-column equal width) 佈局，完美物理水平與垂直對齊 */
  .navbar {
    display: flex;
    flex-direction: row !important; /* 強制橫向並列，防 column 覆蓋 */
    align-items: center;
    justify-content: space-between;
    height: 4.5rem;
    width: 100%;
  }

  .logo {
    flex: 1 0 0;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin: 0;
  }

  .nav-links {
    flex: 0 0 auto; /* 保持自然寬度，防壓縮折行 */
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2.5rem; /* 放寬間距避免擁擠 */
    margin: 0 !important;
  }
  
  .nav-link {
    font-weight: 500;
    color: var(--text-secondary);
    position: relative;
    padding: 0.5rem 0;
  }
  
  .nav-link::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 3px;
    background: var(--gradient-primary);
    border-radius: 99px;
    transition: var(--transition-normal);
  }
  
  .nav-link:hover, .nav-link.active {
    color: var(--text-primary);
  }

  .nav-link:hover::after, .nav-link.active::after {
    width: 100%;
  }

  .nav-btn {
    display: inline-flex;
    padding: 0.5rem 1.25rem;
    border-radius: 0.5rem;
    background: var(--gradient-primary);
    color: #07090e;
    font-weight: 600;
    font-size: 0.9rem;
  }

  html.dark .nav-btn {
    color: #000;
  }

  .nav-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 255, 102, 0.3);
  }

  html.light .nav-btn:hover {
    box-shadow: 0 4px 12px rgba(255, 126, 95, 0.3);
  }

  .nav-actions {
    flex: 1 0 0;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.75rem;
    margin: 0 !important;
  }

  .mobile-menu-btn {
    display: none;
  }
}

/* 行動選單開啟狀態 (Overlay) */
@media (max-width: 767px) {
  .navbar {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .navbar .logo {
    min-width: 0;
    font-size: clamp(0.9rem, 4.2vw, 1.15rem);
    white-space: nowrap;
  }

  .nav-actions {
    gap: 0.5rem;
  }

  .nav-links.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    bottom: auto;
    width: 100%;
    height: auto;
    overflow: visible;
    background-color: var(--mobile-menu-bg);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    padding: 1.5rem 1.5rem 1.75rem;
    gap: 1.5rem;
    z-index: 99;
    align-items: center;
    border-top: 1px solid var(--glass-border);
    animation: slide-in-menu 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }

  .nav-links.open .nav-link {
    font-size: 1.5rem;
    font-weight: 600;
  }

  .nav-links.open .nav-btn {
    width: 100%;
    max-width: 300px;
    padding: 1rem;
    font-size: 1.2rem;
    text-align: center;
    border-radius: 0.75rem;
    background: var(--gradient-primary);
    color: #07090e;
  }

  html.dark .nav-links.open .nav-btn {
    color: #000;
  }

  @keyframes slide-in-menu {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

/* ==========================================================================
   6. Hero 區塊 (Hero Section)
   ========================================================================== */
.hero-section {
  padding: 8rem 0 4rem;
  display: flex;
  flex-direction: column-reverse;
  gap: 3rem;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.hero-content {
  text-align: center;
  max-width: 620px;
}

.hero-title {
  font-size: 2.5rem;
  line-height: 1.2;
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
}

.hero-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
}

.hero-visual {
  width: 100%;
  max-width: 320px;
  display: flex;
  justify-content: center;
}

.avatar-card {
  overflow: hidden;
  padding: 0.75rem;
  border-radius: 2rem;
  width: 100%;
}

.avatar-img {
  width: 100%;
  height: auto;
  border-radius: 1.5rem;
  object-fit: cover;
}

/* 明暗模式動態切換頭像 */
html.dark .light-avatar { display: none; }
html.dark .dark-avatar { display: block; }
html.light .light-avatar { display: block; }
html.light .dark-avatar { display: none; }

@media (min-width: 768px) {
  .hero-section {
    flex-direction: row;
    justify-content: center;
    padding: 8.5rem 0 5rem; /* 稍微縮小間距，讓首屏排版更為緊實高級 */
    gap: 6rem;
    width: 100%;
  }

  .hero-content {
    text-align: left;
    flex: none;
    width: 55%;
    max-width: 580px;
  }

  .hero-title {
    font-size: 3.5rem;
  }

  .hero-subtitle {
    font-size: 1.2rem;
  }

  .hero-visual {
    flex: none;
    width: 35%;
    max-width: 360px;
  }
}

/* ==========================================================================
   7. 區塊通用樣式與卡片 (Sections & Cards)
   ========================================================================== */
.section {
  padding: 3.5rem 0; /* 縮小區塊上下間距 */
  display: flex;
  flex-direction: column;
  align-items: center; /* 確保內容在超大螢幕下水平置中 */
  width: 100%;
}

.section-header {
  text-align: center;
  margin-bottom: 2.5rem; /* 縮小標題與卡片內容的間距 */
  display: flex;
  flex-direction: column;
  align-items: center;
}

.section-tag {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: #00ff66;
  display: inline-block;
  margin-bottom: 0.75rem;
}

html.light .section-tag {
  color: #ff7e5f;
}

.section-title {
  font-size: 2rem;
  margin-bottom: 1rem;
}

.section-subtitle {
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .section { padding: 4.5rem 0; } /* 縮小大螢幕區塊上下間距 */
  .section-title { font-size: 2.5rem; }
}

/* 服務卡片樣式 */
#services .card {
  padding: 2.5rem;
  text-align: left;
}

#services .card:hover {
  transform: translateY(-8px);
  background: var(--card-hover-bg);
  border-color: rgba(0, 255, 102, 0.25);
  box-shadow: 0 12px 40px 0 rgba(0, 255, 102, 0.08);
}

html.light #services .card:hover {
  border-color: rgba(255, 126, 95, 0.25);
  box-shadow: 0 12px 40px 0 rgba(255, 126, 95, 0.08);
}

.card-icon {
  margin-bottom: 1.5rem;
  display: inline-block;
}

#services .card h3 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

#services .card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* 作品卡片樣式 */
.project-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}

.project-img-wrapper {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
}

.project-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.project-card:hover .project-img {
  transform: scale(1.08);
}

.project-info {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.project-tags .tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  background: var(--btn-secondary-bg);
  border: 1px solid var(--btn-secondary-border);
  color: var(--text-secondary);
}

.project-info h3 {
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
}

.project-info p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  flex: 1;
}

.project-card:hover {
  transform: translateY(-8px);
  border-color: rgba(0, 255, 102, 0.25);
  box-shadow: 0 12px 40px 0 rgba(0, 255, 102, 0.08);
}

html.light .project-card:hover {
  border-color: rgba(255, 126, 95, 0.25);
  box-shadow: 0 12px 40px 0 rgba(255, 126, 95, 0.08);
}

/* ==========================================================================
   8. 關於我版面調整 (About me reset)
   ========================================================================== */
.about-wrapper {
  display: flex;
  flex-direction: column;
  gap: 3rem;
  width: 100%;
}

.about-text {
  padding: 2.5rem;
  width: 100%;
}

.about-text p {
  margin-bottom: 1.5rem;
  color: var(--text-secondary);
}

.about-text p strong {
  color: var(--text-primary);
}

.skills-section h4 {
  margin-top: 2rem;
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.skills-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.skill-badge {
  font-weight: 500;
  background: var(--btn-secondary-bg);
}

.highlight-card {
  padding: clamp(1.25rem, 4vw, 2rem);
  text-align: center;
  min-width: 0;
}

.highlight-number {
  font-size: 3rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.highlight-label {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ==========================================================================
   9. 工作經歷時間軸里程碑網格 (Horizontal Milestone Grid)
   ========================================================================== */
.milestones-grid {
  margin-top: 3rem;
  width: 100%;
}

.milestone-card {
  padding: 2.25rem 2rem;
  height: 100%;
  display: flex;
  flex-direction: column;
  transition: var(--transition-spring);
}

.milestone-card:hover {
  transform: translateY(-6px);
  border-color: rgba(0, 255, 102, 0.25);
  box-shadow: 0 12px 40px 0 rgba(0, 255, 102, 0.08);
}

html.light .milestone-card:hover {
  border-color: rgba(255, 126, 95, 0.25);
  box-shadow: 0 12px 40px 0 rgba(255, 126, 95, 0.08);
}

.milestone-header {
  margin-bottom: 1.75rem;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 1rem;
}

.milestone-years {
  font-family: var(--font-title);
  font-size: 0.85rem;
  font-weight: 700;
  color: #00ff66;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 0.25rem;
}

html.light .milestone-years {
  color: #ff7e5f;
}

.milestone-header h3 {
  font-size: 1.35rem;
  line-height: 1.3;
}

.milestone-body {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  flex: 1;
}

.milestone-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.item-title-row {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.item-role {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.item-company {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.item-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.5rem;
}

.milestone-item p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* 雙軌兼職長期項目額外樣式 */
.main-parttime-item {
  border-bottom: 1px dashed var(--glass-border);
  padding-bottom: 1.5rem;
  width: 100%;
}

.inline-badge {
  padding: 0.25rem 0.6rem !important;
  font-size: 0.7rem !important;
  border-color: transparent !important;
  background: var(--gradient-primary) !important;
  color: #000 !important;
  flex-shrink: 0;
}

/* 雙軌兼職項目子列表 */
.milestone-sub-jobs-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.sub-list-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 0.5rem;
}

.sub-job-card {
  padding: 0.85rem;
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid var(--glass-border);
  border-radius: 0.5rem;
  transition: var(--transition-normal);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

html.light .sub-job-card {
  background: rgba(0, 0, 0, 0.01);
}

.sub-job-card:hover {
  border-color: rgba(0, 255, 102, 0.15);
  transform: translateX(3px);
}

html.light .sub-job-card:hover {
  border-color: rgba(255, 126, 95, 0.15);
}

.sub-job-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
}

.sub-job-card h5 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0.15rem 0;
}

.sub-job-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ==========================================================================
   10. 聯絡表單與即時驗證 (Contact Form & user-invalid)
   ========================================================================== */
.contact-container {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.contact-card {
  padding: 2.5rem;
}

.form-grid {
  display: grid;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 600px) {
  .form-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.field {
  display: flex;
  flex-direction: column;
  margin-bottom: 1.5rem;
  position: relative;
}

.field label {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.required {
  color: #ff007f;
}

.field input[type="text"],
.field input[type="email"],
.field textarea {
  width: 100%;
  padding: 0.875rem 1rem;
  border-radius: 0.75rem;
  background: var(--input-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1rem;
  transition: var(--transition-normal);
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--input-focus-border);
  box-shadow: 0 0 0 3px rgba(0, 255, 102, 0.15);
}

html.light .field input:focus,
html.light .field textarea:focus {
  box-shadow: 0 0 0 3px rgba(255, 126, 95, 0.15);
}

/* 預算單選按鈕樣式 */
.budget-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1rem;
}

.budget-radio {
  display: flex;
  align-items: center;
  position: relative;
  cursor: pointer;
}

.budget-radio input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.budget-radio span {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  text-align: center;
  border-radius: 0.5rem;
  background: var(--btn-secondary-bg);
  border: 1px solid var(--btn-secondary-border);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition-normal);
}

.budget-radio input:checked + span {
  background: var(--gradient-primary);
  color: #000;
  border-color: transparent;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* 表單錯誤訊息樣式 */
.error-msg {
  display: none;
  color: #ff3b30;
  font-size: 0.8rem;
  font-weight: 500;
  margin-top: 0.4rem;
  align-items: center;
  gap: 0.35rem;
}

/* 
  即時表單驗證：僅在使用者完成互動且失焦 (:user-invalid) 後，才顯示錯誤樣式。
*/
.field input:user-invalid,
.field textarea:user-invalid {
  border-color: #ff3b30;
  background-color: rgba(255, 59, 48, 0.05);
}

.field input:user-invalid + .error-msg,
.field textarea:user-invalid + .error-msg {
  display: inline-flex;
}

.field input.user-invalid-fallback,
.field textarea.user-invalid-fallback {
  border-color: #ff3b30;
  background-color: rgba(255, 59, 48, 0.05);
}

.field input.user-invalid-fallback + .error-msg,
.field textarea.user-invalid-fallback + .error-msg {
  display: inline-flex;
}

/* 提交按鈕與 Loading */
.submit-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.loading-spinner {
  display: none;
  width: 20px;
  height: 20px;
  animation: rotate-spinner 2s linear infinite;
}

.loading-spinner .path {
  stroke: #000;
  stroke-linecap: round;
  animation: dash-spinner 1.5s ease-in-out infinite;
}

@keyframes rotate-spinner {
  100% { transform: rotate(360deg); }
}

@keyframes dash-spinner {
  0% { stroke-dasharray: 1, 150; stroke-dashoffset: 0; }
  50% { stroke-dasharray: 90, 150; stroke-dashoffset: -35; }
  100% { stroke-dasharray: 90, 150; stroke-dashoffset: -124; }
}

.submit-btn.loading {
  pointer-events: none;
  opacity: 0.8;
}

.submit-btn.loading .loading-spinner {
  display: block;
}

.form-status-msg {
  padding: 1rem;
  border-radius: 0.75rem;
  font-size: 0.95rem;
  font-weight: 500;
  margin-bottom: 1.5rem;
  display: none;
}

.form-status-msg.success {
  display: block;
  background: rgba(52, 199, 89, 0.1);
  border: 1px solid rgba(52, 199, 89, 0.2);
  color: #34c759;
}

.form-status-msg.error {
  display: block;
  background: rgba(255, 59, 48, 0.1);
  border: 1px solid rgba(255, 59, 48, 0.2);
  color: #ff3b30;
}

/* ==========================================================================
   11. 滾動驅動動畫 (Scroll-Driven Animations & fallback)
   ========================================================================== */
@media (prefers-reduced-motion: no-preference) {
  @supports ((animation-timeline: view()) and (animation-range: entry)) {
    @keyframes reveal-in {
      from {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
      }
      to {
        opacity: 1;
        transform: translateY(0) scale(1);
      }
    }

    .scroll-reveal {
      animation: reveal-in linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 35%;
    }
  }
}

.scroll-reveal.revealed {
  opacity: 1;
  transform: translateY(0) scale(1);
  transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.js-reveal-fallback .scroll-reveal:not(.revealed) {
  opacity: 0;
  transform: translateY(40px) scale(0.95);
}

/* ==========================================================================
   12. 頁尾與社群圖示按鈕 (Footer & Social Icon Buttons)
   ========================================================================== */
footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--glass-border);
  padding: 4rem 0 2rem;
  margin-top: 5rem;
  transition: background-color 0.5s ease;
  width: 100%;
}

.footer-content {
  display: flex;
  flex-direction: column;
  gap: 3rem;
  margin-bottom: 3rem;
}

.footer-left p {
  color: var(--text-secondary);
  margin-top: 1rem;
  max-width: 400px;
}

.footer-links h4 {
  font-size: 1.1rem;
  margin-bottom: 1.25rem;
}

/* 社群圖示排列與發光特效 */
.social-icons {
  display: flex;
  gap: 1.25rem;
}

.social-icon-btn {
  background: var(--btn-secondary-bg);
  border: 1px solid var(--btn-secondary-border);
  color: var(--text-secondary);
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-spring);
  box-shadow: var(--shadow-sm);
}

.social-icon-btn:hover {
  background: var(--card-hover-bg);
  color: var(--text-primary);
  border-color: var(--input-focus-border);
  transform: translateY(-4px) scale(1.08);
  box-shadow: 0 8px 20px rgba(0, 255, 102, 0.2);
}

html.light .social-icon-btn:hover {
  box-shadow: 0 8px 20px rgba(255, 126, 95, 0.2);
}

.footer-bottom {
  border-top: 1px solid var(--glass-border);
  padding-top: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

@media (min-width: 768px) {
  .footer-content {
    flex-direction: row;
    justify-content: space-between;
  }
}

/* ==========================================================================
   13. 需求洽詢公司發票提示膠囊樣式
   ========================================================================== */
.contact-invoice-tip {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  justify-content: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  padding: 0.5rem 1.25rem;
  border-radius: 9999px;
  box-shadow: var(--shadow-sm);
  max-width: 90%; /* 確保手機版不溢出 */
  transition: var(--transition-normal);
}

html.light .contact-invoice-tip {
  background: rgba(0, 0, 0, 0.015);
}

.invoice-icon {
  color: var(--input-focus-border);
  flex-shrink: 0;
}

/* ==========================================================================
   14. 服務與案例合併卡片 (Service & Cases Merger Cards)
   ========================================================================== */
.service-case-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  padding: 2.25rem 2rem;
  gap: 2rem;
}

.service-part {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex-grow: 1; /* 大螢幕下自動拉伸上半部，使下半部的虛線能物理水平完美對齊！ */
}

.service-part h3 {
  font-size: 1.35rem;
  margin-bottom: 0.85rem;
  font-weight: 700;
}

.service-part p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.case-part {
  border-top: 1px dashed var(--glass-border);
  padding-top: 1.5rem;
  width: 100%;
}

.case-title-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.nested-project-card {
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid var(--glass-border);
  border-radius: 0.75rem;
  overflow: hidden;
  transition: var(--transition-spring);
  display: flex;
  flex-direction: column;
}

html.light .nested-project-card {
  background: rgba(0, 0, 0, 0.01);
}

.nested-project-card:hover {
  border-color: rgba(0, 255, 102, 0.2);
  transform: translateY(-2px);
}

html.light .nested-project-card:hover {
  border-color: rgba(230, 0, 18, 0.2);
}

.nested-project-img-wrapper {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

.nested-project-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.nested-project-card:hover .nested-project-img {
  transform: scale(1.06);
}

.nested-project-info {
  padding: 1.25rem;
}

.nested-project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.nested-project-tags .tag {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: var(--btn-secondary-bg);
  border: 1px solid var(--btn-secondary-border);
  color: var(--text-secondary);
}

.nested-project-info h5 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: var(--text-primary);
}

.nested-project-info p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ==========================================================================
   15. 正統時序三層全寬經歷排版 (Chronological Full-Width Milestones Layout)
   ========================================================================== */
.milestones-grid-rows {
  margin-top: 3rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2.25rem;
}

.milestone-row-card {
  width: 100%;
  padding: 2.25rem 2rem;
  display: flex;
  flex-direction: column;
  transition: var(--transition-spring);
}

.milestone-row-card:hover {
  transform: translateY(-4px);
  border-color: rgba(0, 255, 102, 0.2);
  box-shadow: 0 8px 30px 0 rgba(0, 255, 102, 0.05);
}

html.light .milestone-row-card:hover {
  border-color: rgba(230, 0, 18, 0.25);
  box-shadow: 0 8px 30px 0 rgba(230, 0, 18, 0.05);
}

.milestone-row-left {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  text-align: left;
}

.milestone-row-left h3 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
}

.row-years {
  font-family: 'Outfit', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--input-focus-border);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* 城市浪人長期兼職在大螢幕左半側的包裹器 */
.parttime-main-wrapper {
  display: flex;
  flex-direction: column;
}

.parttime-title-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* 大螢幕 900px 以上：左右 1:2 分欄並排，且所有時期邊框對齊線與寬度比例完全統一 */
@media (min-width: 900px) {
  .milestone-row-card {
    flex-direction: row;
    gap: 3.5rem;
    align-items: stretch; /* 強迫左右欄高度一致 */
  }
  
  .milestone-row-left {
    flex: 1; /* 左側佔 1 等分 */
    border-right: 1px dashed var(--glass-border);
    padding-right: 3.5rem;
    justify-content: center; /* 垂直置中左半部 */
  }
  
  .milestone-row-right {
    flex: 2; /* 右側佔 2 等分 */
    display: flex;
    flex-direction: column;
    justify-content: center; /* 垂直置中右半部 */
    gap: 1.5rem;
  }
  
  .sub-jobs-grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    width: 100%;
  }
}

/* 行動端與平板：垂直堆疊，邊框與間距調整 */
@media (max-width: 899px) {
  .milestone-row-card {
    flex-direction: column;
    gap: 1.75rem;
    padding: 1.75rem 1.5rem;
  }
  
  .milestone-row-left {
    width: 100%;
    border-right: none;
    padding-right: 0;
    border-bottom: 1px dashed var(--glass-border);
    padding-bottom: 1.75rem;
  }
  
  .milestone-row-right {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
  }
  
  .sub-jobs-grid-2col {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }
}

/* 雙兼職卡片樣式：直接平鋪展示，空間寬裕不擁擠 */
.sub-job-card {
  padding: 1.15rem 1.25rem;
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid var(--glass-border);
  border-radius: 0.75rem;
  transition: var(--transition-spring);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: flex-start; /* 防止 badge 橫向被拉滿 */
  text-align: left;
}

html.light .sub-job-card {
  background: rgba(0, 0, 0, 0.01);
}

.sub-job-card:hover {
  border-color: rgba(0, 255, 102, 0.2);
  transform: translateY(-3px);
  box-shadow: 0 4px 15px rgba(0, 255, 102, 0.04);
}

html.light .sub-job-card:hover {
  border-color: rgba(230, 0, 18, 0.2);
  box-shadow: 0 4px 15px rgba(230, 0, 18, 0.04);
}

.sub-job-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 0.5rem;
}

.sub-job-role {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.sub-job-company {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.sub-job-bottom-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-top: 0.15rem;
  gap: 0.5rem;
}

.sub-job-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.sub-job-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0.2rem 0 0 0;
}
