/* 主選單容器 */
.navbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  /*padding: 10px 20px;
  height: 64px;
  background: #fff;*/
  background: var(--navbar-bg);
  height: var(--navbar-h);
  padding: var(--navbar-pad);

  color: #333;
  border-bottom: 1px solid #ccc;

  /* ✅ 新增固定設定 */
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 999;


}

body {
  padding-top: 64px;
}

/* Logo 樣式 */
.navbar-logo img {
  /*height: 60px;*/
  height: var(--logo-h);
  max-width: 120px;
  object-fit: contain;
  background: #ffffff;
  /* 新增：向上偏移 */
  position: relative;
  top: -4px;
  /* 调整这个值，往上移动的距离 */
}

/* 漢堡選單 */
.hamburger {
  margin-left: auto;
  /* ✅ 漢堡推到最右邊 */
  font-size: 28px;
  cursor: pointer;
  color: #333;
  display: none;
}

/* 主選單 */
/* 主選單列表 */
#navMenu {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 0px;
  flex-grow: 1;
  flex-wrap: wrap;
}

/* 社群區塊 */
.navbar-social {
  display: flex;
  align-items: center;
}

.navbar-social a img {
  width: 24px;
  height: 24px;
  opacity: 0.8;
  transition: opacity 0.3s, filter 0.3s;
  filter: grayscale(70%);
}

.navbar-social a:hover img {
  opacity: 1;
  filter: none;
}

/* 品牌 hover 效果 */
.navbar-social a[href*="facebook"]:hover img {
  filter: brightness(1) saturate(1.5) drop-shadow(0 0 3px #3b5998);
}

.navbar-social a[href*="lin"]:hover img {
  filter: brightness(1) saturate(1.5) drop-shadow(0 0 3px #06C755);
}

.navbar-social a[href*="youtube"]:hover img {
  filter: brightness(1) saturate(1.5) drop-shadow(0 0 3px #FF0000);
}

/* 項目外框 */
.navbar ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: 20px;
  align-items: center;
}

/* 單一選項 */
.navbar li {
  position: relative;
  padding-bottom: 10px;
}

/* 項目連結 */
.navbar a {
  color: #333;
  /* 主選單連結顏色 */
  text-decoration: none;
  padding: 10px 10px;
  display: block;
  transition: color 0.2s ease;
  font-size: var(--navbar-fs);
  /* ← 新增這行，調整主選單文字大小 NAVBAR_FONTSIZE*/
}

/* 滑入效果 */
.navbar a:hover,
.navbar .active {
  color: #ff6600;
}

/* 子選單樣式 */
.navbar li ul {
  display: none;
  position: absolute;
  top: 100%;
  /* 子選單對齊主選單下緣 */
  margin-top: 0px;
  /* 可再靠近些 */
  left: 0;


  min-width: 160px;
  flex-direction: column;
  background: #f9f9f9;
  /* 子選單偏淺灰底 */
  border-top: 4px solid #ff9800;
  /* 醒目的粗上邊框 */
  border-radius: 0 0 6px 6px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  transition: opacity 0.3s ease;
  z-index: 99;
  gap: 0;
  /* ✅ 移除 Flex 預設間距 */

  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease-in-out;
}

.navbar li ul li {
  margin: 3px;
  /* ✅ 移除 li 預設間隔 */
  padding: 3px;
}

.navbar li ul a {
  color: #333;
  white-space: nowrap;
  padding: 8px 16px;
  /* ✅ 調整內距更緊湊 */
  line-height: 1.4;
  /* ✅ 壓縮高度 */

  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.navbar li ul a:hover {
  background: #eee;
  color: #ff6600;
}

.navbar li:hover>ul {
  display: flex;
  animation: fadeIn 0.3s ease;
  opacity: 1;
  pointer-events: auto;
}

/* 給有子選單的主選單加上箭頭 */
.navbar li.has-submenu>a::after {
  content: " ▾";
  /* 你也可以用 " ▼"、" ⯆"、SVG */
  font-size: 0.75em;
  margin-left: 6px;
  color: #ccc;
  transition: transform 0.3s ease;
}

/* hover 時旋轉圖示（可選） */
.navbar li.has-submenu:hover>a::after {
  transform: rotate(180deg);
}

.navbar li:has(ul)>a::after {
  content: " ▾";
  font-size: 0.75em;
  margin-left: 6px;
  color: #ffa500;
  transition: transform 0.3s;
}

/* 當滑入展開時旋轉箭頭 */
.navbar li:hover>a::after {
  transform: rotate(180deg);
}

/* 子選單動畫 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}


.navbar-search {
  display: flex;
  align-items: center;
  min-width: 0;
  width: auto;
  max-width: 120px; /* 原本180px，改更小 */
  background: #f5f5f5;
  border-radius: 15px;
  padding: 2px 4px; /* padding也可略縮 */
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.search-input {
  border: none;
  background: transparent;
  padding: 4px 3px; /* 更小的padding */
  font-size: 1em;
  outline: none;
  min-width: 40px; /* 原本60px，改更小 */
  width: 100%;
}

.search-btn {
  border: none;
  background: none;
  cursor: pointer;
  padding: 0 6px;
  display: flex;
  align-items: center;
}
/* 小螢幕 RWD */

@media screen and (max-width: 768px) {
  body {
    padding-top: 54px;
  }

  .navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999;
    background: #fff;
    padding: 0px 16px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  }

  .navbar-logo img {
    height: 45px;
  }

  .hamburger {
    display: block;
    font-size: 24px;
    margin-left: auto;
    color: #333;
    background: none;
    border: none;
  }

  .navbar-social {
    display: none;
  }

  #navMenu {
    display: none;
    flex-direction: column;
    width: 100%;
    background: #fff;
  }

  #navMenu.show {
    display: flex;
  }

  #navMenu>li>a {
    position: relative;
    font-weight: bold;
    padding: 16px 40px 16px 16px;
    /* 預留右側空間 */
    font-size: 1.05em;
    color: #222;
    border-bottom: 1px solid #eee;
    background: #fff;
  }

  #navMenu>li.has-submenu>a::after {
    content: "▶";
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1em;
    color: #222;
  }

  #navMenu>li.expanded>a::after {
    content: "▼";
  }

  #navMenu li ul {
    max-height: 0;
    overflow: hidden;
    flex-direction: column;
    background: #fff;
    transition: max-height 0.3s ease;
  }

  #navMenu li.expanded>ul {
    max-height: 500px;
  }

  #navMenu li ul li a {
    font-size: 0.95em;
    color: #666;
    padding: 14px 24px;
    border-bottom: 1px solid #eee;
    background: #fff;
  }
}