/* 全站搜尋(2026-10-29):導覽列放大鏡圓鈕 + 下拉建議(components/site/search)與結果頁(search/index)。
   靜態檔,不用重新打包;改了要把 components/site/search 與 search/index 的 ?v= 加 1。
   配色全走 --xs-* 變數:預設宣紙;塔羅星夜 theme-tarot、月老 theme-love、新春 theme-festive、星座宇宙 theme-astro 各覆寫一組。
   圓鈕本身用跟「简」同一組 Tailwind class;深色配色下 locale-switcher 是靠 a[hreflang] 換色,這顆是 button,所以這裡另外寫。 */

.xd-search {
  --xs-bg: #FDFCF7;
  --xs-bd: rgba(200, 164, 82, .38);
  --xs-tx: #1A1812;
  --xs-mu: #5C5240;
  --xs-hd: #826024;
  --xs-lb-bg: #FBF5DF;
  --xs-lb-tx: #826024;
  --xs-act: rgba(200, 164, 82, .15);
  --xs-in-bg: #FFFFFF;
  --xs-in-bd: rgba(200, 164, 82, .5);
  --xs-focus: #826024;
  --xs-chip-bg: #F5F1E8;
  --xs-sh: 0 24px 50px -22px rgba(60, 45, 20, .45), 0 0 0 1px rgba(200, 164, 82, .12);
  position: relative;
  display: inline-flex;
  flex: none;
}
[x-cloak] { display: none !important; }

/* ---- 下拉面板:桌機在圓鈕右下方;手機(<768px)滿版貼在導覽列下面 ---- */
.xd-search-panel {
  position: absolute;
  top: calc(100% + 12px);
  right: -6px;
  width: min(30rem, calc(100vw - 2rem));
  max-height: min(70vh, 640px);
  display: flex;
  flex-direction: column;
  background: var(--xs-bg);
  color: var(--xs-tx);
  border: 1px solid var(--xs-bd);
  border-radius: 14px;
  box-shadow: var(--xs-sh);
  overflow: hidden;
  z-index: 60;
  text-align: left;
  letter-spacing: 0;
}
@media (max-width: 767.98px) {
  .xd-search-panel {
    position: fixed;
    top: var(--xs-top, 4rem);
    left: 0;
    right: 0;
    width: auto;
    max-height: calc(100vh - var(--xs-top, 4rem));
    max-height: calc(100dvh - var(--xs-top, 4rem));
    border-radius: 0 0 14px 14px;
    border-left: 0;
    border-right: 0;
  }
}
.xd-search-in { transition: opacity .14s ease, transform .14s ease; }
.xd-search-from { opacity: 0; transform: translateY(-4px); }
.xd-search-to { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .xd-search-in { transition: none; } }

.xd-search-form {
  position: relative;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  margin: 12px 12px 6px;
  flex: none;
}
.xd-search-ico { position: absolute; left: 12px; color: var(--xs-mu); pointer-events: none; }
body .xd-search .xd-search-input {
  width: 100%;
  min-width: 0;
  height: 44px;
  margin: 0;
  padding: 0 40px 0 38px;
  border: 1px solid var(--xs-in-bd);
  border-radius: 10px;
  background: var(--xs-in-bg);
  color: var(--xs-tx);
  font: inherit;
  font-size: 16px;            /* 16px:iOS 點輸入框才不會自動放大 */
  line-height: 1.2;
  box-shadow: none;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.xd-search-input::placeholder { color: var(--xs-mu); opacity: .75; }
.xd-search-input:focus { border-color: var(--xs-focus); box-shadow: 0 0 0 3px var(--xs-act); }
.xd-search-input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.xd-search-clear {
  position: absolute; right: 6px; width: 32px; height: 32px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--xs-mu); border: 0; padding: 0; cursor: pointer;
}
.xd-search-clear:hover { background: var(--xs-act); color: var(--xs-tx); }

.xd-search-body { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 2px 6px 6px; flex: 1 1 auto; min-height: 0; }

.xd-search-ghead {
  display: flex; align-items: baseline; gap: .4rem;
  margin: 10px 8px 4px; font-size: 12px; font-weight: 700; letter-spacing: .2em; color: var(--xs-hd);
}
.xd-search-gcount { font-size: 11px; font-weight: 600; letter-spacing: 0; color: var(--xs-mu); }
.xd-search-group + .xd-search-group { border-top: 1px solid var(--xs-bd); margin-top: 4px; }

body .xd-search a.xd-search-opt {
  display: flex; align-items: flex-start; gap: 10px; flex-wrap: nowrap;
  padding: 8px 10px; border-radius: 10px; text-decoration: none; color: var(--xs-tx);
  scroll-margin: 6px;
}
body .xd-search a.xd-search-opt.is-active { background: var(--xs-act); }
.xd-search-lb {
  flex: none; margin-top: 2px; padding: 2px 6px; border-radius: 6px; white-space: nowrap;
  font-size: 11px; font-weight: 700; line-height: 1.35; background: var(--xs-lb-bg); color: var(--xs-lb-tx);
}
.xd-search-main { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; }
.xd-search-ti { font-size: 15px; font-weight: 600; line-height: 1.4; color: var(--xs-tx); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xd-search-sn { font-size: 12.5px; line-height: 1.45; color: var(--xs-mu); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.xd-search-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 8px 10px; }
body .xd-search .xd-search-chip {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--xs-bd); background: var(--xs-chip-bg);
  color: var(--xs-tx); font: inherit; font-size: 13.5px; line-height: 1.2; cursor: pointer; letter-spacing: 0;
}
body .xd-search .xd-search-chip:hover { border-color: var(--xs-focus); color: var(--xs-hd); }

.xd-search-state { padding: 14px 12px 12px; font-size: 14px; line-height: 1.6; color: var(--xs-mu); }
.xd-search-alt { margin-top: 4px; font-size: 13px; }
body .xd-search .xd-search-state a { color: var(--xs-hd); text-decoration: underline; text-underline-offset: 3px; }

body .xd-search a.xd-search-all {
  flex: none; display: flex; align-items: center; justify-content: center; gap: 4px;
  padding: 11px 12px; border-top: 1px solid var(--xs-bd); font-size: 14px; font-weight: 700;
  color: var(--xs-hd); text-decoration: none; background: transparent;
}
body .xd-search a.xd-search-all:hover { background: var(--xs-act); }
.xd-search-alln { font-weight: 600; color: var(--xs-mu); }

/* ---- 深色配色 ---- */
html.theme-tarot .xd-search {
  --xs-bg: rgba(22, 22, 50, .97); --xs-bd: rgba(150, 156, 212, .24); --xs-tx: #ECEAF5; --xs-mu: rgba(214, 211, 228, .72);
  --xs-hd: #E2CF9C; --xs-lb-bg: rgba(201, 168, 101, .16); --xs-lb-tx: #E2CF9C; --xs-act: rgba(150, 156, 212, .16);
  --xs-in-bg: rgba(12, 13, 28, .65); --xs-in-bd: rgba(150, 156, 212, .32); --xs-focus: #C9A865; --xs-chip-bg: rgba(32, 32, 66, .6);
  --xs-sh: 0 30px 60px -24px rgba(0, 0, 0, .9), 0 0 0 1px rgba(150, 156, 212, .08);
}
html.theme-love .xd-search {
  --xs-bg: #2C111A; --xs-bd: rgba(212, 176, 106, .24); --xs-tx: #F4E8D8; --xs-mu: rgba(236, 220, 203, .72);
  --xs-hd: #E8D3A0; --xs-lb-bg: rgba(212, 176, 106, .15); --xs-lb-tx: #E8D3A0; --xs-act: rgba(244, 232, 216, .09);
  --xs-in-bg: rgba(20, 6, 10, .5); --xs-in-bd: rgba(212, 176, 106, .32); --xs-focus: #D4B06A; --xs-chip-bg: rgba(74, 31, 43, .6);
  --xs-sh: 0 30px 60px -24px rgba(0, 0, 0, .9), 0 0 0 1px rgba(212, 176, 106, .08);
}
html.theme-festive .xd-search {
  --xs-bg: #7A1A1C; --xs-bd: rgba(217, 180, 106, .32); --xs-tx: #FBF1DC; --xs-mu: rgba(247, 230, 208, .78);
  --xs-hd: #E8CC8A; --xs-lb-bg: rgba(217, 180, 106, .2); --xs-lb-tx: #F2DCA6; --xs-act: rgba(251, 241, 220, .11);
  --xs-in-bg: rgba(60, 8, 10, .45); --xs-in-bd: rgba(217, 180, 106, .42); --xs-focus: #E8CC8A; --xs-chip-bg: rgba(90, 16, 18, .6);
  --xs-sh: 0 30px 60px -24px rgba(30, 2, 4, .85), 0 0 0 1px rgba(217, 180, 106, .1);
}
html.theme-astro .xd-search {
  --xs-bg: #10152B; --xs-bd: rgba(212, 180, 106, .24); --xs-tx: #E8EAF3; --xs-mu: rgba(211, 213, 228, .72);
  --xs-hd: #E8D2A0; --xs-lb-bg: rgba(212, 180, 106, .15); --xs-lb-tx: #E8D2A0; --xs-act: rgba(223, 225, 237, .09);
  --xs-in-bg: rgba(8, 10, 22, .55); --xs-in-bd: rgba(212, 180, 106, .32); --xs-focus: #D4B46A; --xs-chip-bg: rgba(29, 37, 72, .6);
  --xs-sh: 0 30px 60px -24px rgba(0, 0, 0, .9), 0 0 0 1px rgba(212, 180, 106, .08);
}
/* 圓鈕:跟同配色下的「简」(a[hreflang])同一組顏色 */
html.theme-tarot body > nav .xd-search-btn { color: #dcd9e8; border-color: rgba(150, 156, 212, .279); background-color: rgba(32, 32, 66, .6); }
html.theme-love body > nav .xd-search-btn { color: #ecdccb; border-color: rgba(212, 176, 106, .32); background-color: rgba(74, 31, 43, .6); }
html.theme-festive body > nav .xd-search-btn { color: #f7e6d0; border-color: rgba(217, 180, 106, .4); background-color: rgba(90, 16, 18, .55); }
html.theme-astro body > nav .xd-search-btn { color: #d3d5e4; border-color: rgba(212, 180, 106, .32); background-color: rgba(29, 37, 72, .6); }
html.theme-tarot body > nav .xd-search-btn:hover, html.theme-tarot body > nav .xd-search.is-open .xd-search-btn { color: #e2cf9c; border-color: rgba(201, 168, 101, .6); }
html.theme-love body > nav .xd-search-btn:hover, html.theme-love body > nav .xd-search.is-open .xd-search-btn { color: #e8d3a0; border-color: rgba(212, 176, 106, .6); }
html.theme-festive body > nav .xd-search-btn:hover, html.theme-festive body > nav .xd-search.is-open .xd-search-btn { color: #e8cc8a; border-color: rgba(217, 180, 106, .7); }
html.theme-astro body > nav .xd-search-btn:hover, html.theme-astro body > nav .xd-search.is-open .xd-search-btn { color: #e8d2a0; border-color: rgba(212, 180, 106, .6); }
html:not(.theme-tarot):not(.theme-love):not(.theme-festive):not(.theme-astro) .xd-search.is-open .xd-search-btn { border-color: #C8A452; color: #826024; }

/* ---- 結果頁 /search ---- */
.xd-sr-form { display: flex; gap: 8px; flex-wrap: nowrap; }
.xd-sr-form input[type="search"] {
  flex: 1 1 auto; min-width: 0; height: 48px; padding: 0 14px; border-radius: 10px; font: inherit; font-size: 16px;
  border: 1px solid rgba(200, 164, 82, .55); background: #fff; color: #1A1812; -webkit-appearance: none; appearance: none;
}
.xd-sr-form input[type="search"]:focus { outline: none; border-color: #826024; box-shadow: 0 0 0 3px rgba(200, 164, 82, .18); }
/* app.css 的手機按鈕防護會把按鈕撐滿整列,這裡鎖回原寬 */
.xd-sr-form input[type="search"] { flex: 1 1 auto !important; width: auto !important; }
.xd-sr-form button { flex: 0 0 auto !important; width: auto !important; min-width: 0 !important; height: 48px; padding: 0 18px !important; white-space: nowrap; align-self: stretch; }
.xd-sr-list { display: flex; flex-direction: column; gap: 10px; flex-wrap: nowrap; }
.xd-sr-item {
  display: flex; gap: 12px; align-items: flex-start; flex-wrap: nowrap; padding: 14px 16px; border-radius: 12px;
  background: #FDFCF7; border: 1px solid rgba(200, 164, 82, .3); text-decoration: none; color: #1A1812;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.xd-sr-item:hover { border-color: #C8A452; box-shadow: 0 10px 24px -18px rgba(60, 45, 20, .5); }
.xd-sr-item .xd-search-lb { background: #FBF5DF; color: #826024; }
.xd-sr-title { font-size: 16.5px; font-weight: 700; line-height: 1.45; color: #1A1812; }
.xd-sr-snip { margin-top: 3px; font-size: 14px; line-height: 1.6; color: #5C5240; }
.xd-sr-url { margin-top: 3px; font-size: 12px; color: #7A6E54; word-break: break-all; }
.xd-sr-counts { display: flex; flex-wrap: wrap; gap: 6px; }
.xd-sr-counts span { padding: 3px 10px; border-radius: 999px; font-size: 13px; background: #F5F1E8; color: #5C5240; }

/* ---- 導覽列騰出放大鏡的位置(只在導覽列有這顆鈕時才生效,:has 不支援的舊瀏覽器維持原樣) ----
   2026-10-29 實測加了這顆後:1280px 以上超出內容右緣 26px、1024px 超出 40px(被切掉)。
   不藏任何項目,只把分組選單的左右內距與間距收小:1280 以上 12px→8px(5 組省 40px);1024–1279 再收內距、選單間距與右側鈕距(約省 54px)。 */
@media (min-width: 1280px) {
  body > nav:has(.xd-search) .xd-nav-grp { padding-left: .5rem !important; padding-right: .5rem !important; }
}
@media (min-width: 1024px) and (max-width: 1279px) {
  body > nav:has(.xd-search) .xd-nav-grp { padding-left: .15rem !important; padding-right: .15rem !important; }
  body > nav:has(.xd-search) .hidden.md\:flex { gap: .1rem !important; }
  body > nav div:has(> .xd-search) { gap: .35rem !important; }
}
/* 1024–1099px(小筆電、平板橫放)上面收完還差約 27px:logo 用手機那個高度(32px,寬 165→132) */
@media (min-width: 1024px) and (max-width: 1099px) {
  body > nav:has(.xd-search) .container-wide > a:first-child img { height: 2rem !important; }
}
/* 手機搜尋面板滿版時,右側 LINE 小鈕 / 問師父浮鈕 / 底部橫幅先藏起來(同 app.css 對 .xd-nav-open 的做法) */
@media (max-width: 767.98px) {
  .xd-search-open #line-side-tab,
  .xd-search-open .xd-askai-fab,
  .xd-search-open #xd-line-bottom,
  .xd-search-open #xd-start-fab { visibility: hidden !important; }
}
