/* 字型設定 - 與主樣式文件保持一致 */
* {
  font-family: 'Noto Sans TC', 'Taipei Sans TC Beta', 'Microsoft JhengHei', 'PingFang TC', 'Helvetica Neue', Arial, sans-serif;
  text-align: left;
  /* 確保對齊為主 */
}

/* ==== Header 佈局（依照新電商設計）==== */
.site-header .header-top {
  background: #fff;
  padding: 0px 0 !important;
  /* 減少上下空白 */
}

.site-header .header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: auto !important;
  /* 移除最小高度限制 */
}

.site-header .site-branding {
  flex: 0 0 auto;
}

/* Logo 大小調整為 2.5 倍 */
.site-header .site-logo {
  width: auto !important;
  height: 100px !important;
  /* 預設約 50px * 2.5 = 125px */
  object-fit: contain !important;
  transition: transform 0.3s ease !important;
  box-shadow: none !important;
  /* 移除陰影 */
  filter: none !important;
  /* 移除任何濾鏡效果 */
}

.site-header .logo-link:hover .site-logo {
  transform: scale(1.05) !important;
  /* hover 時稍微放大 */
  box-shadow: none !important;
  /* hover 時也無陰影 */
}

.site-header .main-navigation {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.site-header .nav-menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 96px;
  /* 與截圖一致的寬鬆間距 */
}

.site-header .header-tools {
  display: flex;
  align-items: center;
  gap: 0 !important;
  /* 移除間距，讓圖示更集中 */
  column-gap: 0 !important;
  /* 兼容性保障 */
}

/* 確保移除任何外距，讓圖示貼近 */
.site-header .header-tools .tool-icon,
.site-header .header-tools .contact-btn {
  margin: 0 !important;
}

.site-header .header-tools .tool-icon:not(:first-child) {
  margin-left: 0 !important;
}

/* 預設隱藏：行動版工具列（僅手機顯示） */
.header-tools-mobile {
  display: none;
}

/* 導航修復樣式 */
/* 确保桌面端导航链接有足够的点击区域 */
.nav-left li,
.nav-right li {
  min-height: 44px !important;
  display: flex !important;
  align-items: center !important;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1) !important;
  touch-action: manipulation !important;
}

.nav-left li a,
.nav-right li a {
  padding: 8px 12px !important;
  position: relative !important;
  z-index: 10 !important;
  -webkit-touch-callout: none !important;
  -webkit-user-select: none !important;
  user-select: none !important;
}

/* 移动端菜单修复 */
.mobile-menu-overlay {
  pointer-events: none !important;
}

.mobile-menu-overlay.active {
  pointer-events: auto !important;
}

.mobile-menu {
  pointer-events: auto !important;
}

.mobile-menu li a {
  padding: 12px 16px !important;
  min-height: 44px !important;
  display: flex !important;
  align-items: center !important;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1) !important;
  touch-action: manipulation !important;
  -webkit-touch-callout: none !important;
  -webkit-user-select: none !important;
  user-select: none !important;
  border-radius: 8px !important;
}

.mobile-menu li a:hover {
  background: rgba(185, 140, 94, 0.1) !important;
}

/* 標準WordPress導覽選單（新設計覆蓋） */
.site-header .main-navigation a {
  padding: 8px 0 !important;
  /* 緊湊、無下方大空白 */
  display: inline-block !important;
  position: relative !important;
  z-index: 10 !important;
  pointer-events: auto !important;
  cursor: pointer !important;
  transition: color 0.2s ease !important;
  font-size: 1.5em !important;
  /* 文字放大 1.5 倍 */
  font-weight: 500 !important;
  /* 稍微加粗 */
}

/* 移除舊版下劃線效果，符合截圖乾淨風格 */
.site-header .main-navigation a::after {
  display: none !important;
}

/* 移除 hover 背景顏色 */
.site-header .main-navigation a:hover {
  background: none !important;
  background-color: transparent !important;
}

/* 當前頁面文字改為淡咖啡色並添加咖啡豆圖示 */
.site-header .main-navigation .current-menu-item>a,
.site-header .main-navigation .current_page_item>a,
.site-header .main-navigation a.active,
.site-header .main-navigation a.current-page-active {
  color: #D2B48C !important;
  /* 淡咖啡色 */
  position: relative !important;
  padding-left: 32px !important;
  /* 為圖示留出空間 */
}

.site-header .main-navigation .current-menu-item>a::before,
.site-header .main-navigation .current_page_item>a::before,
.site-header .main-navigation a.active::before,
.site-header .main-navigation a.current-page-active::before {
  content: '' !important;
  position: absolute !important;
  left: 0 !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  width: 24px !important;
  height: 24px !important;
  background-image: url('../images/咖啡豆.webp') !important;
  background-size: contain !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
}

@media (max-width: 768px) {

  /* 鎖死行動裝置左右滾軸 */
  html,
  body {
    overflow-x: hidden;
    position: relative;
    width: 100%;
    max-width: 100vw;
    padding-top: 21px;
  }

  /* 強制鎖定 header 高度，避免空白被其他規則撐開 */
  header.site-header,
  header.site-header .header-top,
  header.site-header .header-top .container,
  header.site-header .header-content {
    height: 72px !important;
    min-height: 72px !important;
    overflow: visible !important;
  }

  /* 垂直置中：工具列與漢堡、Logo 都貼齊中線 */
  .header-content {
    display: grid !important;
    align-items: center !important;
  }

  .header-tools {
    display: flex !important;
    align-items: center !important;
  }

  .menu-toggle {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  header.site-header .site-branding .logo-link {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 0 !important;
  }

  header.site-header .site-branding,
  header.site-header .site-branding .logo-link {
    height: 60px !important;
  }

  header.site-header .site-branding .logo-link .site-logo {
    height: 56px !important;
    max-height: 56px !important;
    width: auto !important;
  }

  .hero-section {
    margin-top: 72px !important;
  }

  /* 與 style.css 同步：縮減 header 上下空白與 LOGO 高度 */
  header.site-header .header-top {
    padding: 0px 0 !important;
  }

  header.site-header .header-top {
    position: relative !important;
  }

  header.site-header .site-branding,
  header.site-header .site-branding .logo-link {
    height: 64px !important;
    overflow: hidden !important;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  header.site-header .site-branding .logo-link .site-logo {
    height: 75px !important;
    max-height: 75px !important;
    width: auto !important;
  }

  .hero-section {
    margin-top: 64px !important;
  }

  /* 行動版：右上角三個工具按鈕（全新一組，不影響原布局） */
  .header-tools-mobile {
    position: absolute !important;
    top: 50% !important;
    right: -15px !important;
    transform: translateY(-50%) !important;
    display: flex !important;
    align-items: center !important;
    gap: 0px !important;
    z-index: 9998 !important;
    /* 低於搜尋彈窗(9999)，高於header */
    pointer-events: auto !important;
  }

  .header-tools-mobile .tool-icon-mobile {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 8px !important;
    height: 8px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    background: transparent !important;
    border-radius: 8px !important;
    box-shadow: none !important;
    line-height: 0 !important;
  }

  .header-tools-mobile .tool-icon-mobile img {
    width: 36px !important;
    height: 36px !important;
    object-fit: contain !important;
    display: block !important;
  }

  /* 僅在手機顯示 */
  .header-tools-mobile {
    display: flex !important;
  }

  .site-header .main-navigation a {
    padding: 12px 16px !important;
    min-height: 44px !important;
    display: flex !important;
    align-items: center !important;
    pointer-events: auto !important;
    /* 恢復點擊效果 */
    cursor: pointer !important;
    /* 恢復手型游標 */
    font-size: 16px !important;
    /* 行動版字體大小，調整為更小 */
    font-weight: 300 !important;
    /* 字體更細緻，非粗體 */
    transition: color 0.3s ease, background-color 0.3s ease, font-weight 0.3s ease !important;
  }

  /* 行動裝置端選單 hover 效果 */
  .site-header .main-navigation a:hover {
    font-weight: 600 !important;
    /* hover時字體變粗體 */
  }

  /* 行動裝置端當前頁面選單項目字體加粗 */
  .site-header .main-navigation .current-menu-item>a,
  .site-header .main-navigation .current_page_item>a,
  .site-header .main-navigation a.active,
  .site-header .main-navigation a.current-page-active {
    font-weight: 600 !important;
    /* 當前頁面字體加粗 */
  }

  /* 手機端：當前/active 選單的咖啡豆圖示靠文字左側，與文字同列置中 */
  .site-header .main-navigation .current-menu-item>a,
  .site-header .main-navigation .current_page_item>a,
  .site-header .main-navigation a.active,
  .site-header .main-navigation a.current-page-active {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    /* 圖示與文字最小間距 */
    padding-left: 0 !important;
    /* 取消為絕對定位圖示預留的空間 */
  }

  .site-header .main-navigation .current-menu-item>a::before,
  .site-header .main-navigation .current_page_item>a::before,
  .site-header .main-navigation a.active::before,
  .site-header .main-navigation a.current-page-active::before {
    position: static !important;
    /* 取消絕對定位，交由 flex 排版 */
    left: auto !important;
    top: auto !important;
    transform: none !important;
    display: inline-block !important;
    width: 18px !important;
    height: 18px !important;
    margin-right: 4px !important;
    background-image: url('../images/咖啡豆.webp') !important;
    background-size: contain !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
  }

  /* 手機端：導覽改為下拉 */
  .site-header .nav-menu {
    display: none;
    flex-direction: column;
    gap: 0;
  }

  .site-header .nav-menu.active {
    display: flex;
    background: #fff;
    border-top: 1px solid #eee;
  }

  .site-header .main-navigation {
    justify-content: flex-end;
  }
}

/* 防止触摸延迟 */
* {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* 移除特定按钮的默认outline，避免影响商品页面的按钮 */
.header-tools button,
.search-close,
.menu-toggle,
.mobile-menu button {
  outline: none !important;
  border: none !important;
  background: none !important;
  box-shadow: none !important;
}

.header-tools button:focus,
.search-close:focus,
.menu-toggle:focus,
.mobile-menu button:focus {
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
}

/* 允许文本选择 */
p,
h1,
h2,
h3,
h4,
h5,
h6,
span,
div {
  -webkit-user-select: text;
  user-select: text;
}

/* 确保链接可以正常点击 */
a {
  -webkit-user-select: none;
  user-select: none;
}

/* 搜索弹窗样式 */
.search-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.search-overlay.active {
  opacity: 1;
  visibility: visible;
}

.search-container {
  background: white;
  border-radius: 12px;
  padding: 2rem;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  transform: translateY(-20px);
  transition: transform 0.3s ease;
}

.search-overlay.active .search-container {
  transform: translateY(0);
}

.search-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #eee;
}

.search-header h3 {
  margin: 0;
  color: #333;
  font-size: 1.5rem;
  font-weight: 600;
}

.search-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: background-color 0.2s ease;
  color: #666;
}

.search-close:hover {
  background-color: #f5f5f5;
  color: #333;
}

.search-form-container {
  margin-bottom: 2rem;
}

.search-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

.search-field {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 16px;
  transition: border-color 0.2s ease;
  outline: none;
}

.search-field:focus {
  border-color: #b98c5e;
  box-shadow: 0 0 0 3px rgba(185, 140, 94, 0.1);
}

.search-submit {
  background: #8B4513 !important;
  color: white !important;
  border: none !important;
  padding: 12px 20px !important;
  border-radius: 8px !important;
  cursor: pointer !important;
  font-size: 16px !important;
  font-weight: 500 !important;
  transition: background-color 0.2s ease !important;
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
}

.search-submit:hover {
  background: #6B3410 !important;
}

.search-suggestions h4 {
  margin: 0 0 1rem 0;
  color: #666;
  font-size: 1rem;
  font-weight: 500;
}

.suggestion-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.suggestion-tag {
  background: #f5f5f5;
  color: #333;
  padding: 8px 16px;
  border-radius: 20px;
  text-decoration: none;
  font-size: 14px;
  transition: all 0.2s ease;
  border: 1px solid #e0e0e0;
}

.suggestion-tag:hover {
  background: #b98c5e;
  color: white;
  border-color: #b98c5e;
  transform: translateY(-1px);
}

/* 移动端适配 */
@media (max-width: 768px) {

  .search-container {
    width: 95%;
    padding: 1.5rem;
    margin: 1rem;
  }

  .search-header h3 {
    font-size: 1.25rem;
  }

  .search-form {
    flex-direction: column;
  }

  .search-submit {
    width: 100%;
    justify-content: center;
  }

  .suggestion-tags {
    justify-content: center;
  }
}

/* 桌面端工具图标显示控制 */
.desktop-only {
  display: block;
}

/* 搜索按钮特殊处理 - 桌面端显示 */
.search-icon.desktop-only {
  display: block !important;
  transition: transform 0.2s ease;
  outline: none !important;
  border: none !important;
  background: none !important;
  box-shadow: none !important;
}

.search-icon.desktop-only:hover {
  transform: scale(1.1);
}

.search-icon.desktop-only:focus {
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
}

/* 工具图标尺寸调整 - 放大 2 倍 */
.header-tools .tool-icon,
.header-tools .contact-btn {
  display: inline-flex !important;
  align-items: center !important;
  outline: none !important;
  border: none !important;
  background: none !important;
  box-shadow: none !important;
}

.header-tools .tool-icon:focus,
.header-tools .contact-btn:focus {
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
}

/* 工具图标基础樣式：容器緊貼圖示，避免多餘留白 */
.header-tools .tool-icon {
  justify-content: center !important;
  width: 64px !important;
  /* 與圖示等寬，消除容器額外空白 */
  height: 64px !important;
  /* 與圖示等高 */
  transition: transform 0.3s ease !important;
  border-radius: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* 工具图标hover效果 */
.header-tools .tool-icon:hover {
  transform: scale(1.1) !important;
}

/* 图标尺寸调整 - 放大 2 倍 */
.header-tools .tool-icon img {
  width: 64px !important;
  /* 32px * 2 = 64px */
  height: 64px !important;
  /* 32px * 2 = 64px */
  object-fit: contain !important;
}

/* 联络我们按钮特殊处理 */
.header-tools .contact-btn {
  width: auto !important;
  height: 51px !important;
  /* 64px * 0.8 = 51.2px */
  padding: 0 19px !important;
  /* 24px * 0.8 = 19.2px */
  transition: all 0.3s ease !important;
  border-radius: 25px !important;
}

/* 联络我们按钮hover效果 */
.header-tools .contact-btn:hover {
  transform: scale(1.05) !important;
}

.header-tools .contact-btn img {
  width: auto !important;
  height: 29px !important;
  /* 36px * 0.8 = 28.8px */
}

/* 移动端隐藏桌面端工具图标 */
@media (max-width: 768px) {

  .desktop-only {
    display: none !important;
  }

  /* 確保行動裝置端隱藏所有桌面端工具按鍵，包括搜尋按鈕 */
  .header-tools .tool-icon,
  .header-tools .contact-btn,
  .search-icon.desktop-only {
    display: none !important;
  }

  /* 確保行動裝置端顯示漢堡選單 */
  .menu-toggle {
    display: block !important;
  }

  /* 將行動裝置端的漢堡選單和Logo向上移動10px */
  header.site-header .site-branding,
  header.site-header .menu-toggle {
    transform: translateY(-20px) !important;
  }

  /* 確保新行動工具列顯示 */
  .header-tools-mobile {
    display: flex !important;
  }
}

/* 手機：避免固定 header 遮擋首屏 hero 區塊 */
@media (max-width: 768px) {
  .hero-section {
    margin-top: 30px !important;
  }
}