/* ========================================
   增強版導航欄樣式 - 現代化設計
   ======================================== */

/* 性能優化 - 使用 GPU 加速 (僅限導航欄) */
.nav_main_enhanced,
.nav_main_enhanced * {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 導航主容器 */
.nav_main_enhanced {
  width: 100%;
  height: 60px; /* 固定高度防止抖動 */
  background: linear-gradient(135deg, #1a1f2e 0%, #2d3748 100%);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  position: sticky;
  top: 0;
  z-index: 1000;
  backface-visibility: hidden; /* 防止閃爍 */
  transform: translateZ(0); /* 啟用硬件加速 */
  overflow: visible; /* 確保下拉菜單可見 */
  opacity: 1 !important;
  visibility: visible !important;
  display: block !important;
}

/* Mobile: hide desktop horizontal nav to prevent overflow/forced zoom;
   use the FAB hamburger menu instead. */
@media screen and (max-width: 768px) {
  .nav_main_enhanced .navlist_enhanced {
    display: none !important;
  }
  .nav_main_enhanced {
    height: auto;
  }
  .mobile-fab-nav {
    display: flex !important;
  }
}

/* Mobile UA (FAB mode): also hide desktop horizontal nav in landscape widths */
body.is-mobile-fab .nav_main_enhanced .navlist_enhanced {
  display: none !important;
}
body.is-mobile-fab .mobile-fab-nav {
  display: flex !important;
}

/* nav_enhanced 容器 */
#nav_enhanced {
  position: relative;
  overflow: visible; /* 確保下拉菜單不被裁切 */
}

.nav_main_enhanced::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, 
    #C60E3A 0%, 
    #F1ED66 25%, 
    #FCBF49 50%, 
    #F1ED66 75%, 
    #C60E3A 100%);
}

/* 導航列表 */
.navlist_enhanced {
  position: relative; /* 作為 Mega Menu 全寬定位的基準 */
  display: flex;
  justify-content: space-between; /* 讓所有主選單項平均分布 */
  align-items: stretch; /* 改為 stretch 防止高度不一致 */
  margin: 0;
  padding: 0;
  list-style: none;
  flex-wrap: nowrap; /* 強制不換行 */
  gap: 0; /* 移除間距防止抖動 */
  height: 100%; /* 固定高度 */
}

/* 預留空白格（在最後添加偽元素）*/
.navlist_enhanced::after {
  content: '';
  flex: 0 0 auto;
  width: 0; /* 取消預留寬度，避免右側多出空白 */
  height: 0;
  border-left: none;
  margin-left: 0;
}

/* 導航項目 */
.nav-item-enhanced {
  position: relative;
  flex: 1 1 0; /* 每個主選單項平均分配可用寬度 */
  text-align: center;
  white-space: nowrap; /* 防止文字換行 */
  height: 60px; /* 與 nav_main_enhanced 高度一致，方便精準對齊 */
}

/* 針對 Mega Menu 的項目，取消相對定位，讓子選單對齊 navlist (1200px) */
.nav-item-enhanced.mega-menu {
  position: static;
}

.nav-item-enhanced > a {
  display: flex; /* 使用 flex 垂直置中內容 */
  align-items: center; /* 垂直置中 */
  justify-content: center; /* 水平置中 */
  height: 60px; /* 與容器同高 */
  padding: 0 18px; /* 適度內距，避免文字太擠 */
  color: #ffffff;
  font-size: 28px; /* 再加大字體 */
  font-weight: 700; /* 加粗字體 */
  text-decoration: none;
  transition: background 0.25s ease, transform 0.25s ease; /* 只过渡必要属性 */
  position: relative;
  overflow: hidden;
  box-sizing: border-box; /* 确保盒模型一致 */
}

/* 懸停效果 - 波紋動畫（優化，防止抖動） */
.nav-item-enhanced > a::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0);
  transition: background 0.3s ease;
  pointer-events: none; /* 性能優化 */
  border-radius: 6px 6px 0 0;
  z-index: 1; /* 確保在底層，但高於背景 */
}

.nav-item-enhanced:hover > a::before {
  background: rgba(255, 255, 255, 0.05); /* 淡淡的高亮 */
}

/* 底部高亮條 - 改為亮黃色，與整體高亮系統一致 */
.nav-item-enhanced > a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 5%; /* 固定左邊距 */
  width: 0;
  height: 4px; /* 略細的高亮條 */
  background: #CB293F; /* 改為亮黃色 */
  transform: translateZ(0); /* 使用硬件加速 */
  transition: width 0.3s ease; /* 簡化過渡 */
  box-shadow: 0 2px 8px rgba(241, 228, 16, 0.6); /* 黃色陰影 */
  will-change: width; /* 只標記寬度變化 */
  z-index: 10; /* 確保覆蓋底部的黃色線條 */
}

.nav-item-enhanced:hover > a::after,
.nav-item-enhanced.hover > a::after {
  width: 90%; /* 加寬到 90% */
}

.nav-item-enhanced:hover > a,
.nav-item-enhanced.hover > a {
  color: #ffffff; /* 保持白色 */
  background: rgba(255, 255, 255, 0.15); /* 半透明白色背景 */
  border-radius: 6px 6px 0 0; /* 頂部圓角 */
  /* 移除 transform 防止抖動 */
}

/* 點擊/激活狀態 - 移除黃色框等樣式 */
.nav-item-enhanced > a:active,
.nav-item-enhanced > a:focus,
.subnav-link:focus {
  outline: none !important; /* 強制移除輪廓 */
  box-shadow: none !important; /* 強制移除陰影 */
  background-color: transparent; /* 避免點擊時背景變色 */
}

/* 當前頁面高亮 */
.nav-item-enhanced#cur > a {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.15); /* 白色半透明背景 */
  border-radius: 4px;
}

.nav-item-enhanced#cur > a::after {
  width: 90%;
  background: #EF233C; /* 紅色 */
  height: 4px; /* 與一般 hover 一致的略細高亮條 */
  z-index: 10; /* 確保覆蓋 */
}

/* ========================================
   下拉菜單樣式 - 深色磨砂質感 (Dark Glass)
   ======================================== */

.subnav_enhanced {
  position: absolute;
  top: 60px;
  left: 0; /* 預設對齊父元素左側 */
  min-width: 260px; /* 普通下拉適度加寬 */
  /* 背景改為深色半透明，呼應導航欄 */
  background: rgba(45, 55, 72, 0.98); 
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 0 0 4px 4px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.1);
  border: none;
  /* 頂部裝飾線改為亮黃色，與三角形連成一體 */
  /* border-top: 3px solid #F1E410;  */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  overflow: visible;
  z-index: 999;
  backface-visibility: hidden;
  transform: translateY(-10px);
  color: #e2e8f0; /* 全局文字變淺 */
}

/* 裝飾元素：右上角的小折角 - 改為深色適配 */
.subnav_enhanced::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 15px 15px 0;
  /* 右上角裝飾改為黃色，呼應 Hover 效果 */
  border-color: transparent #F1E410 transparent transparent;
  opacity: 1;
}

/* 移除光暈效果 */

.nav-item-enhanced:hover .subnav_enhanced {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}


/* 下拉菜單內容 */
.subnav-content {
  padding: 20px 0; /* 增加垂直間距 */
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  position: relative;
  /* 背景裝飾：極淡的紅色光暈 */
  background-image: radial-gradient(circle at 100% 0%, rgba(198, 14, 58, 0.08) 0%, transparent 25%);
}

.subnav-link {
  display: flex;
  align-items: center;
  padding: 14px 25px; /* 增加內距適配大字體 */
  margin: 4px 10px;
  color: #ffffff; /* 白色文字 */
  text-decoration: none;
  font-size: 22px; /* 統一字體大小 */
  font-weight: 700; /* 加粗 */
  border-radius: 6px;
  background: transparent;
  border: none;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  width: 100%;
  white-space: nowrap;
  box-shadow: none;
}

.subnav-link::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px; /* 加寬至 6px，與 Mega Menu 一致 */
  background: #C60E3A;
  transform: scaleY(0);
  transition: transform 0.2s ease;
  border-radius: 0; /* 移除圓角，直角設計 */
  z-index: 2;
}

.subnav-link:hover {
  transform: translateX(5px);
  padding-left: 35px; /* Hover 時增加左內距，增加層次感 */
  background: #F1E410; /* 純實色亮黃 */
  color: #000000; /* 深黑色文字 */
  font-weight: 700; /* 加粗 */
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2); /* 浮起投影 */
  border-radius: 4px;
}

.subnav-link:hover::before {
  transform: scaleY(1);
  height: 100%; /* 全高 */
  box-shadow: none;
}

/* 圖標樣式 - 白色 */
.link-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; /* 增大圖標容器 */
  height: 32px;
  margin-right: 15px; /* 增加與文字間距 */
  font-size: 18px; /* 增大圖標 */
  background: rgba(0, 0, 0, 0.2); /* 深色底 */
  border-radius: 50%;
  transition: all 0.3s ease;
  position: relative;
  color: #ffffff; /* 白色 */
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.subnav-link:hover .link-icon {
  transform: rotate(15deg);
  background: #C60E3A;
  color: #fff;
  border-color: transparent;
  box-shadow: 0 0 15px rgba(198, 14, 58, 0.5); /* 發光效果 */
}


/* ========================================
   Mega Menu 樣式（多列下拉菜單）
   ======================================== */

/* Mega Menu 強制 1200px 全寬 */
.mega-menu .subnav_enhanced {
  left: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 100% !important;
  transform: translateY(-10px);
  /* 調整背景漸變，適配深色 */
  background: #2d3748 radial-gradient(circle at 90% 90%, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.01) 100px, transparent 100px, transparent 100%);
}

/* ========================================
   Grid Menu 樣式（完全參考 mega-column）
   ======================================== */
.mega-menu-grid .subnav_enhanced {
  left: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 100% !important;
  transform: translateY(-10px);
  background: #2d3748 radial-gradient(circle at 90% 90%, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.01) 100px, transparent 100px, transparent 100%);
}

.mega-menu-grid:hover .subnav_enhanced {
  transform: translateY(0);
}

.mega-menu-grid .subnav-content {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 30px;
  padding: 40px;
  max-width: 100%;
  overflow: visible;
  background: transparent;
  position: relative;
}

/* 卡片樣式 - 完全參考 mega-column */
.mega-menu-grid .subnav-link {
  display: flex;
  align-items: center;
  padding: 15px;
  padding-bottom: 18px;
  margin: 0;
  color: #ffffff;
  text-decoration: none;
  font-size: 20px;
  font-weight: 700;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-bottom: none;
  transition: all 0.3s ease;
  white-space: nowrap;
  width: 100%;
  box-sizing: border-box;
  letter-spacing: 1px;
  position: relative;
}

/* 底部紅色分隔線 */
.mega-menu-grid .subnav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 10px;
  right: 10px;
  height: 2px;
  background: rgba(198, 14, 58, 0.5);
  transition: background 0.3s ease;
}

.mega-menu-grid .subnav-link:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}

.mega-menu-grid .subnav-link:hover::after {
  background: #F1ED66;
}

.mega-menu-grid .subnav-link::before {
  display: none;
}

.mega-menu-grid .link-icon {
  margin-right: 12px;
  color: #C60E3A;
  transition: color 0.25s ease;
  flex-shrink: 0;
  text-shadow: 0 0 10px rgba(198, 14, 58, 0.3);
}

.mega-menu-grid .link-icon svg {
  width: 24px;
  height: 24px;
}

.mega-menu-grid .link-text {
  line-height: 1.3;
}

.mega-menu-grid .subnav-link:hover .link-icon {
  color: #C60E3A;
}

@media (max-width: 1200px) {
  .mega-menu-grid .subnav-content {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 900px) {
  .mega-menu-grid .subnav-content {
    grid-template-columns: repeat(3, 1fr);
    padding: 30px;
    gap: 20px;
  }
}

@media (max-width: 600px) {
  .mega-menu-grid .subnav-content {
    grid-template-columns: repeat(2, 1fr);
    padding: 20px;
    gap: 15px;
  }
  .mega-menu-grid .subnav-link {
    font-size: 16px;
    padding: 12px;
  }
}

.mega-menu:hover .subnav_enhanced {
  transform: translateY(0);
}

/* 確保 mega menu 不會超出視窗邊界 */
@media (max-width: 1200px) {
  .mega-menu .subnav_enhanced {
    width: 100% !important;
    left: 0 !important;
  }
}

.mega-content {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 25px;
  padding: 40px;
  max-width: 100%;
  overflow: visible;
  background: transparent;
  position: relative;
}

@media (max-width: 768px) {
  .mega-content {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    padding: 30px;
  }
}

@media (max-width: 500px) {
  .mega-content {
    grid-template-columns: 1fr;
    gap: 15px;
    padding: 20px;
  }
}

.mega-column {
  padding: 15px; /* 增加內距，因為要加背景色 */
  background: rgba(255, 255, 255, 0.03); /* 極淡的背景色塊，區分欄位 */
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05); /* 極淡的邊框 */
  transition: all 0.3s ease;
  position: relative;
  box-shadow: none;
}

.mega-column:hover {
  transform: translateX(5px);
  background: #F1E410; /* 亮黃色背景 - 與資訊動態一致 */
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  border-color: #F1E410;
}

.mega-column::before {
  display: none;
}

.mega-column:hover::before {
  display: none;
}

.column-title {
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0 0 0 10px; /* 左側留一點空隙 */
  font-size: 22px;
  font-weight: 700;
  color: #ffffff;
  background: transparent;
  border: none; /* 取消下劃線 */
  border-radius: 0;
  letter-spacing: 1px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}


.mega-column:hover .column-title {
  color: #000000; /* 黑色文字 */
}

.mega-column:hover .column-title a {
  color: #000000 !important; /* 黑色文字 */
}

.title-icon {
  margin-right: 12px;
  color: #a0aec0; /* 淺灰白色 - 與資訊動態一致 */
  font-size: 24px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

/* 防止被各頁面樣式中的 `.title-icon { animation: bounce ... }` 影響而上下浮動 */
.nav_main_enhanced .title-icon {
  animation: none !important;
}

.mega-column:hover .title-icon {
  transform: rotate(15deg);
  background: #C60E3A;
  color: #fff;
  border-color: transparent;
  box-shadow: 0 0 15px rgba(198, 14, 58, 0.5);
}

.mega-column .subnav-link {
  display: flex;
  justify-content: flex-start; /* 強制內容靠左 */
  align-items: center;
  /* Padding: 上下 12px, 右 15px, 左 54px (對齊標題文字) */
  /* 計算：icon寬(32)+icon間距(12)+標題左padding(10) = 54px */
  padding: 12px 15px 12px 54px; 
  font-size: 18px;
  border-radius: 6px;
  margin: 4px 0;
  font-weight: 500;
  position: relative;
  background: transparent;
  border: none;
  transition: all 0.2s ease;
  color: #cbd5e0;
  width: auto; /* 讓它自適應寬度 */
}

.mega-column .subnav-link::after {
  display: none;
}

/* 小圓點裝飾 (未 Hover 狀態) */
.mega-column .subnav-link::before {
  content: '';
  position: absolute;
  left: 30px; /* 定位在圖標下方的位置 */
  top: 50%;
  width: 6px;
  height: 6px;
  background: rgba(255, 255, 255, 0.2); /* 默認暗色圓點 */
  border-radius: 50%;
  transform: translateY(-50%);
  transition: all 0.3s ease;
}

.mega-column .subnav-link:hover {
  padding-left: 64px; /* Hover 時文字右移 10px */
  /* 改為純實色亮黃，最醒目 */
  background: #F1E410;
  /* 文字使用深黑色，最強對比 */
  color: #000000; 
  font-weight: 700; /* 字重加到最粗 */
  transform: translateX(5px);
  /* 稍微加一點整體的投影，增加浮起感，但不要光暈 */
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  border-radius: 4px; /* 保持整體微圓角 */
  overflow: hidden; /* 確保紅線不溢出 */
}

.mega-column .subnav-link:hover .link-icon {
  background: #C60E3A;
  color: #ffffff;
  border-color: transparent;
  transform: rotate(15deg) scale(1.1);
  box-shadow: 0 2px 8px rgba(198, 14, 58, 0.4);
}

.mega-column .subnav-link:hover::after {
  display: none;
}

/* Hover 時左側裝飾線：全高，無圓角 */
.mega-column .subnav-link:hover::before {
  width: 6px;
  height: 100%; /* 強制全高 */
  top: 0;
  bottom: 0;
  left: 0;
  border-radius: 0; /* 直角，與背景完全貼合 */
  background: #C60E3A;
  box-shadow: none;
  transform: scaleY(1);
  z-index: 2;
}

/* ========================================
   響應式設計
   ======================================== */

/* ========================================
   未來擴展支持（10-12個菜單項）
   ======================================== */

/* 大屏幕優化（10個菜單項以內） */
@media screen and (min-width: 1400px) {
  .nav-item-enhanced > a {
    padding: 18px 16px;
    font-size: 16px;
  }
}


/* ========================================
   動畫效果
   ======================================== */

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* 頁面加載時的入場動畫 */
.nav_main_enhanced {
  animation: slideInDown 0.6s ease-out;
}

.nav-item-enhanced {
  animation: fadeIn 0.8s ease-out backwards;
}

.nav-item-enhanced:nth-child(1) { animation-delay: 0.1s; }
.nav-item-enhanced:nth-child(2) { animation-delay: 0.15s; }
.nav-item-enhanced:nth-child(3) { animation-delay: 0.2s; }
.nav-item-enhanced:nth-child(4) { animation-delay: 0.25s; }
.nav-item-enhanced:nth-child(5) { animation-delay: 0.3s; }
.nav-item-enhanced:nth-child(6) { animation-delay: 0.35s; }
.nav-item-enhanced:nth-child(7) { animation-delay: 0.4s; }
.nav-item-enhanced:nth-child(8) { animation-delay: 0.45s; }
.nav-item-enhanced:nth-child(9) { animation-delay: 0.5s; }
.nav-item-enhanced:nth-child(10) { animation-delay: 0.55s; }
.nav-item-enhanced:nth-child(11) { animation-delay: 0.6s; }
.nav-item-enhanced:nth-child(12) { animation-delay: 0.65s; }

/* ========================================
   滾動時的效果
   ======================================== */

.nav_main_enhanced.scrolled {
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.25);
}

.nav_main_enhanced.scrolled .nav-item-enhanced > a {
  padding: 14px 20px;
}

/* ========================================
   微信分享按鈕樣式優化
   ======================================== */

.wechat-share-btn {
  position: fixed;
  right: 20px;
  bottom: 100px;
  z-index: 999;
}

.cloud-share1 {
  position: relative;
}

.wei-xin {
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, #07C160 0%, #00D976 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(7, 193, 96, 0.4);
  transition: all 0.3s ease;
}

.wei-xin:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(7, 193, 96, 0.6);
}

.icon-wei {
  color: #ffffff;
  font-size: 24px;
}

/* ========================================
   頂部社交圖標優化
   ======================================== */

.social-icons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-link a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  transition: all 0.3s ease;
  color: #2d3748;
}

.icon-link a:hover {
  background: linear-gradient(135deg, #FCBF49 0%, #F1ED66 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(252, 191, 73, 0.3);
}

.icon-link svg {
  transition: transform 0.3s ease;
}

.icon-link a:hover svg {
  transform: rotate(5deg) scale(1.1);
}

.icon-text {
  font-size: 13px;
  font-weight: 500;
}

.split {
  width: 1px;
  height: 16px;
  background: rgba(0, 0, 0, 0.1);
}

/* ========================================
   可訪問性優化
   ======================================== */

.nav-item-enhanced > a:focus,
.subnav-link:focus {
  outline: none; /* 移除黃色框 */
}

/* 高對比度模式 */
@media (prefers-contrast: high) {
  .nav_main_enhanced {
    background: #000000;
    border-bottom: 3px solid #ffffff;
  }
  
  .nav-item-enhanced > a {
    color: #ffffff;
  }
  
  .subnav_enhanced {
    background: #ffffff;
    border: 2px solid #000000;
  }
}

/* 減少動畫模式 (僅限導航欄) */
@media (prefers-reduced-motion: reduce) {
  .nav_main_enhanced,
  .nav_main_enhanced * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 隱藏移動端專用元素 */
.mobile-nav-logo,
.mobile-menu-toggle {
  display: none;
}

/* ========================================
   懸浮導航按鈕 (FAB - 左上角全屏展開版)
   ======================================== */

/* 懸浮按鈕容器 - 右上角 */
.mobile-fab-nav {
  position: fixed;
  right: 15px;
  top: 15px;
  z-index: 10000;
  display: flex;
}

.mobile-fab-nav.is-hidden {
  display: none !important;
}

/* 懸浮按鈕 */
.mobile-fab-nav__button {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #C60E3A 0%, #a00c30 100%);
  box-shadow: 0 4px 15px rgba(198, 14, 58, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  gap: 5px;
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-radius 0.3s ease;
}

.mobile-fab-nav__button:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(198, 14, 58, 0.5);
}

.mobile-fab-nav.is-active .mobile-fab-nav__button {
  background: #333;
  border-radius: 50%;
}

.mobile-fab-nav__icon-bar {
  width: 20px;
  height: 2.5px;
  background: #ffffff;
  border-radius: 2px;
  display: block;
  transition: transform 0.3s ease, opacity 0.3s ease;
  transform-origin: center;
}

/* 按鈕激活狀態 - 變成 X */
.mobile-fab-nav.is-active .mobile-fab-nav__icon-bar:nth-child(1) {
  transform: translateY(7.5px) rotate(45deg);
}

.mobile-fab-nav.is-active .mobile-fab-nav__icon-bar:nth-child(2) {
  opacity: 0;
}

.mobile-fab-nav.is-active .mobile-fab-nav__icon-bar:nth-child(3) {
  transform: translateY(-7.5px) rotate(-45deg);
}

/* 全屏導航面板 */
.mobile-fab-menu {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 100%;
  z-index: 9999;
  background: linear-gradient(180deg, #1a1f2e 0%, #2d3748 100%);
  transform: translateX(-100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  box-sizing: border-box;
}

.mobile-fab-menu.is-open {
  transform: translateX(0);
}

/* 面板頭部 */
.mobile-fab-menu__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 2px solid #C60E3A;
  flex-shrink: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.mobile-fab-menu__title {
  font-size: 32px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 2px;
}

.mobile-fab-menu__close {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: transparent;
  font-size: 24px;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.mobile-fab-menu__close:hover {
  background: #C60E3A;
  border-color: #C60E3A;
  transform: rotate(90deg);
}

/* 面板內容區 */
.mobile-fab-menu__body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  box-sizing: border-box;
}

/* 直接連結項目（無子菜單） */
.fab-nav-direct {
  display: block;
  padding: 18px 24px;
  margin-bottom: 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  text-decoration: none;
  font-size: 22px;
  font-weight: 600;
  transition: all 0.2s ease;
  border-left: 4px solid transparent;
}

.fab-nav-direct:hover {
  background: rgba(198, 14, 58, 0.3);
  border-left-color: #C60E3A;
  transform: translateX(5px);
}

/* 可展開的導航組 */
.fab-nav-group {
  margin-bottom: 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.fab-nav-group__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.fab-nav-group__header:hover {
  background: rgba(255, 255, 255, 0.08);
}

.fab-nav-group__title {
  font-size: 22px;
  font-weight: 600;
  color: #ffffff;
}

.fab-nav-group__arrow {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.5);
  transition: transform 0.3s ease;
}

.fab-nav-group.is-expanded .fab-nav-group__arrow {
  transform: rotate(180deg);
  color: #C60E3A;
}

.fab-nav-group.is-expanded .fab-nav-group__header {
  background: rgba(198, 14, 58, 0.2);
  border-left: 4px solid #C60E3A;
}

/* 展開內容區 */
.fab-nav-group__body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
  background: rgba(0, 0, 0, 0.2);
}

.fab-nav-group.is-expanded .fab-nav-group__body {
  max-height: 2000px;
}
/* 手機端：保留動畫，由 JS 設定實際高度，避免內容被截斷 */
body.is-mobile-fab .fab-nav-group__body {
  max-height: 0;
  display: block;
  transition: max-height 0.4s ease;
}

body.is-mobile-fab .fab-nav-group.is-expanded .fab-nav-group__body {
  display: block;
}

/* 普通子菜單項目 */
.fab-nav-group__item {
  display: block;
  padding: 16px 24px 16px 50px;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: all 0.2s ease;
}

.fab-nav-group__item:hover {
  background: rgba(198, 14, 58, 0.2);
  color: #ffffff;
  padding-left: 50px; /* 固定縮排，避免 hover 時跳動 */
  transform: none;
  box-shadow: inset 6px 0 0 #C60E3A;
}

/* Mega menu 子分組 */
.fab-nav-subgroup {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.fab-nav-subgroup:last-child {
  border-bottom: none;
}

.fab-nav-subgroup__header {
  /* 讓 mega-menu 的分組標題也和子項同一列清單樣式 */
  padding: 0;
  background: transparent;
}

.fab-nav-subgroup__title {
  display: block;
  padding: 16px 24px 16px 50px;
  font-size: 20px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.86);
  text-transform: none;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.fab-nav-subgroup__title-link {
  display: block;
  padding: 16px 24px 16px 50px;
  font-size: 20px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.86);
  text-decoration: none;
  text-transform: none;
  letter-spacing: 0.5px;
  transition: all 0.2s ease;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.fab-nav-subgroup__title-link:hover {
  background: rgba(198, 14, 58, 0.22);
  color: #ffffff;
  padding-left: 50px; /* 固定縮排，避免 hover 時跳動 */
  transform: none;
  box-shadow: inset 6px 0 0 #C60E3A;
}

.fab-nav-subgroup__item {
  display: block;
  padding: 16px 24px 16px 50px;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.5px;
  transition: all 0.2s ease;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.fab-nav-subgroup__item:hover {
  background: rgba(198, 14, 58, 0.15);
  color: #ffffff;
  padding-left: 50px; /* 固定縮排，避免 hover 時跳動 */
  transform: none;
  box-shadow: inset 6px 0 0 #C60E3A;
}

/* 底部區域 */
.mobile-fab-menu__footer {
  flex-shrink: 0;
  padding: 18px 24px;
  background: rgba(0, 0, 0, 0.3);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.mobile-fab-menu__hide-toggle {
  width: 100%;
  padding: 14px 22px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  font-size: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mobile-fab-menu__hide-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.4);
}

/* 防止背景滾動 */
body.mobile-fab-menu-open {
  overflow: hidden;
}

/* 手機端防止溢出 */
body.is-mobile-fab {
  overflow-x: hidden;
  max-width: 100%;
}

/* 滾動條美化 */
.mobile-fab-menu__body::-webkit-scrollbar {
  width: 6px;
}

.mobile-fab-menu__body::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

.mobile-fab-menu__body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.mobile-fab-menu__body::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* 手機端：FAB/面板尺寸用 clamp() 自適應小螢幕（避免 430px 被 72/64/120px 撐爆） */
body.is-mobile-fab {
  --fab-btn-size: clamp(52px, 14vw, 78px);
  --fab-btn-radius: clamp(12px, 3.2vw, 18px);
  --fab-bar-w: clamp(22px, 6.6vw, 38px);
  --fab-bar-h: clamp(3px, 0.9vw, 5px);
  --fab-bar-gap: clamp(5px, 1.6vw, 9px);
  --fab-x-shift: calc(var(--fab-bar-gap) + var(--fab-bar-h));

  --fab-title-size: clamp(22px, 6vw, 36px);
  --fab-main-size: clamp(18px, 5.2vw, 32px);
  --fab-sub-size: clamp(16px, 4.8vw, 28px);

  --fab-pad-y: clamp(14px, 3.8vw, 26px);
  --fab-pad-x: clamp(16px, 4.4vw, 28px);
  --fab-sub-indent: clamp(22px, 6vw, 42px);
}

body.is-mobile-fab .mobile-fab-nav {
  right: calc(env(safe-area-inset-right, 0px) + 12px);
  top: calc(env(safe-area-inset-top, 0px) + 12px);
}

body.is-mobile-fab .mobile-fab-nav__button {
  width: var(--fab-btn-size);
  height: var(--fab-btn-size);
  border-radius: var(--fab-btn-radius);
  gap: var(--fab-bar-gap);
}

body.is-mobile-fab .mobile-fab-nav__icon-bar {
  width: var(--fab-bar-w);
  height: var(--fab-bar-h);
}

/* 用變數調整 X 形態，避免固定 7.5px/18px 在不同尺寸下不對 */
body.is-mobile-fab .mobile-fab-nav.is-active .mobile-fab-nav__icon-bar:nth-child(1) {
  transform: translateY(var(--fab-x-shift)) rotate(45deg);
}
body.is-mobile-fab .mobile-fab-nav.is-active .mobile-fab-nav__icon-bar:nth-child(2) {
  opacity: 0;
}
body.is-mobile-fab .mobile-fab-nav.is-active .mobile-fab-nav__icon-bar:nth-child(3) {
  transform: translateY(calc(var(--fab-x-shift) * -1)) rotate(-45deg);
}

/* 確保懸浮按鈕在菜單打開時仍然顯示 */
body.mobile-fab-menu-open .mobile-fab-nav {
  display: flex !important;
  z-index: 10001;
}

/* 手機端導航清單樣式 - 加大字體方便長者閱讀 */
body.is-mobile-fab .mobile-fab-menu__header {
  padding: calc(var(--fab-pad-y) + 6px) calc(var(--fab-pad-x) + 6px);
}

body.is-mobile-fab .mobile-fab-menu__title {
  font-size: var(--fab-title-size);
  font-weight: 700;
}

body.is-mobile-fab .mobile-fab-menu__close {
  width: clamp(40px, 10vw, 56px);
  height: clamp(40px, 10vw, 56px);
  font-size: clamp(22px, 6vw, 34px);
  border-width: 3px;
}

body.is-mobile-fab .mobile-fab-menu__body {
  /* 移動端：加大面板內邊距，避免大字體貼邊 */
  padding: calc(var(--fab-pad-y) + 12px) var(--fab-pad-x);
}

body.is-mobile-fab .fab-nav-direct {
  /* 移動端：加大點擊區 */
  padding: var(--fab-pad-y) var(--fab-pad-x);
  font-size: var(--fab-main-size);
  font-weight: 600;
  margin-bottom: 16px;
  border-radius: 20px;
  border-left-width: 8px;
}

body.is-mobile-fab .fab-nav-group {
  margin-bottom: 16px;
  border-radius: 22px;
}

body.is-mobile-fab .fab-nav-group__header {
  /* 移動端：加大主分組（72px字）點擊區 */
  padding: var(--fab-pad-y) var(--fab-pad-x);
}

body.is-mobile-fab .fab-nav-group__title {
  font-size: var(--fab-main-size);
  font-weight: 600;
}

body.is-mobile-fab .fab-nav-group__arrow {
  font-size: clamp(18px, 5vw, 30px);
}

body.is-mobile-fab .fab-nav-group__item {
  /* 移動端：子導航（64px字）加大點擊區 */
  padding: var(--fab-pad-y) var(--fab-pad-x) var(--fab-pad-y) calc(var(--fab-pad-x) + var(--fab-sub-indent));
  font-size: var(--fab-sub-size);
}

body.is-mobile-fab .fab-nav-subgroup__header {
  /* 讓 mega-menu 的「分組標題」也像一般子項一樣呈現（統一樣式） */
  padding: 0;
  background: transparent;
}

body.is-mobile-fab .fab-nav-subgroup__title,
body.is-mobile-fab .fab-nav-subgroup__title-link {
  font-size: var(--fab-sub-size);
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: none;
}

body.is-mobile-fab .fab-nav-subgroup__item {
  padding: var(--fab-pad-y) var(--fab-pad-x) var(--fab-pad-y) calc(var(--fab-pad-x) + var(--fab-sub-indent));
  font-size: var(--fab-sub-size);
}

/* ========================================
   手機端：子導航全體統一樣式（普通子項 / mega-menu 分組標題 / 分組子項）
   ======================================== */

body.is-mobile-fab .fab-nav-group__item,
body.is-mobile-fab .fab-nav-subgroup__item,
body.is-mobile-fab .fab-nav-subgroup__title-link,
body.is-mobile-fab .fab-nav-subgroup__title {
  display: block;
  width: 100%;
  box-sizing: border-box;
  line-height: 1.18;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* mega-menu 分組標題（把 header 變成一列清單） */
body.is-mobile-fab .fab-nav-subgroup__title-link,
body.is-mobile-fab .fab-nav-subgroup__title {
  /* 移動端：分組標題也用同一套子導航 padding */
  padding: var(--fab-pad-y) var(--fab-pad-x) var(--fab-pad-y) calc(var(--fab-pad-x) + var(--fab-sub-indent));
  color: rgba(255, 255, 255, 0.92);
  background: transparent;
}

/* mega-menu 分組內子項：縮進與一般子項一致 */
body.is-mobile-fab .fab-nav-subgroup__item {
  padding: var(--fab-pad-y) var(--fab-pad-x) var(--fab-pad-y) calc(var(--fab-pad-x) + var(--fab-sub-indent));
  color: rgba(255, 255, 255, 0.86);
}

/* 普通子項也統一字重/顏色 */
body.is-mobile-fab .fab-nav-group__item {
  font-weight: 600;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.86);
}

/* Hover：所有子導航同一種高亮（不位移、不跳动） */
body.is-mobile-fab .fab-nav-group__item:hover,
body.is-mobile-fab .fab-nav-subgroup__item:hover,
body.is-mobile-fab .fab-nav-subgroup__title-link:hover {
  background: rgba(198, 14, 58, 0.22);
  color: #ffffff;
  /* 不覆蓋 padding，避免 hover 時跳動 */
  transform: none;
  border-bottom-color: rgba(255, 255, 255, 0.10);
  box-shadow: inset 10px 0 0 #C60E3A;
}

/* mega-menu：最後一列不需要底线（避免多一条） */
body.is-mobile-fab .fab-nav-subgroup:last-child .fab-nav-subgroup__title-link,
body.is-mobile-fab .fab-nav-subgroup:last-child .fab-nav-subgroup__title,
body.is-mobile-fab .fab-nav-subgroup:last-child .fab-nav-subgroup__item:last-child {
  border-bottom: none;
}

body.is-mobile-fab .mobile-fab-menu__footer {
  padding: calc(var(--fab-pad-y) + 8px) var(--fab-pad-x);
}

body.is-mobile-fab .mobile-fab-menu__hide-toggle {
  /* 移動端：底部按鈕更好點 */
  padding: calc(var(--fab-pad-y) + 8px) var(--fab-pad-x);
  font-size: clamp(16px, 4.5vw, 22px);
  border-radius: 22px;
}
