/**
 * 全站商品搜尋 — 頁首入口（2026-10-06）：頁首放大鏡、往下展開的搜尋面板、手機抽屜裡的商品建議。
 * 放大鏡鈕對齊購物車鈕（白底、#e2e8f0 細框、12px 圓角、42px）；顏色只用主題變數（--button-color／--pos-text-color）。
 * 面板是 absolute 疊在上層，不推動任何版面。結果頁自己的樣式在 wx-site-search.css（不在每一頁載入）。
 * 手機（≤767px）頂欄不放放大鏡，搜尋在選單抽屜裡。
 */

/* ===== 放大鏡鈕（電腦／平板） ===== */
.wx-nav-search-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  min-height: 42px;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #ffffff;
  color: #1e293b;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.wx-nav-search-btn svg {
  display: block;
  width: 20px;
  height: 20px;
}

.wx-nav-search-btn[aria-expanded="true"] {
  border-color: var(--button-color, #587493);
  color: var(--button-color, #587493);
}

.wx-nav-search-btn:focus-visible {
  outline: 2px solid var(--button-color, #587493);
  outline-offset: 2px;
}

@media (hover: hover) and (pointer: fine) {
  .wx-nav-search-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
  }
}

/* ===== 搜尋面板（疊在頁首下方，不推動版面） ===== */
@media (min-width: 768px) {
  .header-nav-tools--has-search {
    position: relative;
  }

  /* 放大鏡不佔版面：往左蓋進導覽列右側原本就空著的地方（42px 鈕寬＋12px 間距＝54px），
     這樣加了放大鏡之後，導覽連結、Logo 的位置跟以前完全一樣、不會被擠動 */
  .header-nav-tools--has-search .wx-nav-search-btn {
    margin-left: -54px;
  }
}

.wx-site-search-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 170px);
  max-height: calc(100dvh - 170px);
  box-sizing: border-box;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.16);
}

.wx-site-search-panel[hidden] {
  display: none;
}

.wx-site-search-form {
  flex: 0 0 auto;
  margin: 0;
  padding: 12px 12px 8px;
}

.wx-site-search-form__label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.wx-site-search-form__row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 4px 0 12px;
  box-sizing: border-box;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.wx-site-search-form__row:focus-within {
  background: #ffffff;
  border-color: var(--button-color, #587493);
  box-shadow: 0 0 0 3px rgba(88, 116, 147, 0.18);
}

.wx-site-search-form__icon {
  flex: 0 0 auto;
  color: #94a3b8;
}

.wx-site-search-form .wx-site-search-form__input {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 9px 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  outline: none;
  font-size: 16px; /* iPhone 字小於 16px 點下去會整頁放大跳動 */
  font-weight: 600;
  color: #0f172a;
}

.wx-site-search-form__btn {
  flex: 0 0 auto;
  height: 32px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--button-color, #587493);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.wx-site-search-form__btn:focus-visible {
  outline: 2px solid var(--button-color, #587493);
  outline-offset: 2px;
}

@media (hover: hover) and (pointer: fine) {
  .wx-site-search-form__btn:hover {
    filter: brightness(1.07);
  }
}

/* ===== 狀態列、建議清單、查看全部（面板與抽屜共用） ===== */
.wx-site-search-status {
  flex: 0 0 auto;
  margin: 0;
  padding: 4px 16px 10px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  color: #64748b;
}

.wx-site-search-status[hidden] {
  display: none;
}

.wx-site-search-list {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 0 8px;
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.wx-site-search-list[hidden] {
  display: none;
}

.wx-site-search-li {
  margin: 0;
  padding: 0;
  list-style: none;
}

.wx-site-search-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 8px;
  box-sizing: border-box;
  border-radius: 10px;
  color: var(--pos-text-color, #334155);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.wx-site-search-item.is-active,
.wx-site-search-item:focus-visible {
  background: #f1f5f9;
  outline: none;
}

@media (hover: hover) and (pointer: fine) {
  .wx-site-search-item:hover {
    background: #f1f5f9;
  }
}

.wx-ss-thumb {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  overflow: hidden;
  border-radius: 8px;
  background: #f1f5f9;
}

.wx-ss-thumb img {
  display: block;
  width: 40px;
  height: 40px;
  object-fit: cover;
}

.wx-ss-main {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.wx-ss-name {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  color: #0f172a;
  word-break: break-word;
}

.wx-ss-name mark {
  padding: 0;
  background: transparent;
  color: var(--button-color, #587493);
  font-weight: 800;
}

.wx-ss-platform {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  color: #64748b;
}

.wx-ss-badge {
  flex: 0 0 auto;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  color: #475569;
  white-space: nowrap;
}

.wx-ss-badge.is-preorder {
  border-color: var(--button-color, #587493);
  color: var(--button-color, #587493);
}

.wx-ss-badge.is-soldout {
  background: #f1f5f9;
  color: #94a3b8;
}

.wx-site-search-all {
  display: block;
  flex: 0 0 auto;
  margin: 4px 0 0;
  padding: 12px 16px;
  border-top: 1px solid #f1f5f9;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  color: var(--button-color, #587493);
  text-decoration: none;
}

.wx-site-search-all[hidden] {
  display: none;
}

.wx-site-search-all:focus-visible {
  outline: 2px solid var(--button-color, #587493);
  outline-offset: -2px;
}

@media (hover: hover) and (pointer: fine) {
  .wx-site-search-all:hover {
    background: #f8fafc;
  }
}

/* ===== 手機：頂欄不放放大鏡，面板不顯示；搜尋在抽屜裡 ===== */
@media (max-width: 767px) {
  .wx-nav-search-btn,
  .wx-site-search-panel {
    display: none !important;
  }
}

/* ===== 手機抽屜裡的商品建議（抽屜寬度上限 320px，內容在抽屜自己的捲動區） ===== */
.wx-drawer-search-results {
  margin: 0 0 6px;
  padding: 0 0 6px;
  border-bottom: 1px solid #f1f5f9;
}

.wx-drawer-search-results[hidden] {
  display: none;
}

.wx-drawer-search-results .wx-site-search-status {
  padding: 0 20px 6px;
}

.wx-drawer-search-results .wx-site-search-list {
  overflow: visible;
  padding: 0 8px;
}

.wx-drawer-search-results .wx-site-search-all {
  margin: 0;
  padding: 10px 16px;
}

.wx-drawer-search__icon--svg {
  flex: 0 0 auto;
  color: #94a3b8;
  opacity: 1;
}

/* 手機選單「搜尋商品」輸入框 16px（原本 wx-responsive-phase1.css 是 15px；iPhone 字小於 16px 點下去整頁會自動放大、跳動）。
   只在有商品搜尋的頁面載入本檔，結帳頁的抽屜維持原樣。 */
.wx-mobile-nav-drawer .wx-drawer-search .wx-drawer-search__input { font-size: 16px !important; }
