/* 全站搜索：页头按钮 + 覆盖层。配色沿用询盘弹层那套（深色玻璃 + #0066FF 细蓝线）。
 *
 * ⚠ 页头有**两套**皮肤，两边都要照顾到：
 *   · 常规页面   .site-header 深色（透明压在深色首屏上）
 *   · 资讯页面   .site-header[data-theme="light"] 浅色
 * 只按深色写的话，资讯页上的按钮是白字白底，肉眼几乎看不见，
 * 而两套皮肤共用同一份 HTML，抓页面比对完全发现不了。
 */

/* ── 页头里的搜索按钮 ─────────────────────────────────────────── */

/**
 * **默认不显示，由 search.js 加上 data-ready 才出现。**
 * 搜索完全依赖 JS，脚本没加载成功时按钮点了没反应——
 * 一个点不动的按钮比没有按钮更糟，用户会以为站坏了。
 */
.site-search-toggle {
  display: none;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line-dark, rgba(255, 255, 255, 0.16));
  border-radius: 7px;
  background: transparent;
  color: var(--white, #fff);
  cursor: pointer;
  transition: color 180ms, background 180ms, border-color 180ms;
}
.site-search-toggle[data-ready] { display: grid; }
.site-search-toggle svg { width: 18px; height: 18px; }
.site-search-toggle:hover {
  border-color: rgba(0, 102, 255, 0.55);
  background: rgba(0, 102, 255, 0.12);
}
.site-search-toggle:focus-visible {
  outline: 2px solid #0066FF;
  outline-offset: 2px;
}

/* 浅色页头（资讯板块）。资讯页头把按钮放在 .header-actions 里，
 * 那一组是 flex，尺寸略小一点才与语言切换、汉堡按钮排得齐。 */
.site-header[data-theme="light"] .site-search-toggle {
  border-color: rgba(10, 22, 40, 0.14);
  color: #0A1628;
}
.site-header[data-theme="light"] .site-search-toggle:hover {
  border-color: rgba(0, 102, 255, 0.5);
  background: rgba(0, 102, 255, 0.08);
}
.header-actions .site-search-toggle { width: 38px; height: 38px; }

/* ── 覆盖层 ───────────────────────────────────────────────────── */

.gs-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;                 /* 询盘弹层是 200，搜索要能压在它上面 */
  display: flex;
  align-items: flex-start;      /* 顶部对齐：搜索框贴近页头，符合直觉 */
  justify-content: center;
  padding: 88px 24px 24px;
  background: rgba(3, 5, 8, 0.74);
  backdrop-filter: blur(9px);
  opacity: 0;
  visibility: hidden;
  /* **关掉时必须同时断掉指针事件。**
   * visibility 是离散过渡：按下 Esc 之后的这 0.2 秒里它仍然是 visible，
   * 整个覆盖层照旧吞掉点击 —— 用户关掉搜索马上去点导航，那一下点不动，
   * 而画面上覆盖层已经淡得几乎看不见了，看起来就是"页面卡了一下"。 */
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.gs-overlay.is-open { opacity: 1; visibility: visible; pointer-events: auto; }

.gs-dialog {
  position: relative;
  width: min(720px, 100%);
  max-height: calc(100vh - 112px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 14px;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #fff;
  background:
    radial-gradient(130% 80% at 50% -10%, rgba(0, 102, 255, 0.11), transparent 60%),
    linear-gradient(180deg, rgba(12, 15, 20, 0.985), rgba(8, 10, 14, 0.985));
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 44px 110px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(0, 102, 255, 0.05);
  transform: translateY(-10px) scale(0.99);
  transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.gs-overlay.is-open .gs-dialog { transform: none; }
.gs-dialog::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, #0066FF, transparent);
  opacity: 0.7;
}

/* 输入区 */
.gs-inputbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.gs-inputbar > svg { width: 19px; height: 19px; flex: 0 0 auto; color: rgba(255, 255, 255, 0.45); }
.gs-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0;
  font: inherit;
  font-size: 17px;
  color: #fff;
  background: transparent;
  border: 0;
  outline: none;
}
.gs-input::placeholder { color: rgba(255, 255, 255, 0.36); }

/**
 * 焦点指示挪到整条输入栏上。
 *
 * site-system.css 给所有 input 配了 `outline: 2px solid; outline-offset: 4px`，
 * 落在这个横贯整条的输入框上会画出一个几乎顶满对话框的蓝框——
 * 打开搜索的第一眼像是个报错提示。但**不能简单去掉**：键盘用户要看得见焦点在哪。
 * 改成整条输入栏亮一层底色 + 蓝色下边线，既明显又是设计的一部分。
 */
.gs-input:focus-visible { outline: none; }
.gs-inputbar:focus-within {
  background: rgba(0, 102, 255, 0.05);
  border-bottom-color: rgba(0, 102, 255, 0.55);
}

/* type="search" 的浏览器自带清除按钮要藏掉：不藏的话输入框里有两个 ×
 * （原生一个、我们自己一个），点哪个都清空，但看着像是坏了。
 * 仍然用 type="search"，手机软键盘的回车键才会显示成"搜索"。 */
.gs-input::-webkit-search-cancel-button,
.gs-input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
.gs-clear {
  flex: 0 0 auto;
  width: 28px; height: 28px;
  display: none; place-items: center;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
}
.gs-clear[data-visible] { display: grid; }
.gs-clear:hover { color: #fff; border-color: rgba(0, 102, 255, 0.5); }
.gs-clear svg { width: 12px; height: 12px; }

/* 结果区 */
.gs-results {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;   /* 滚到底不要带着整页一起滚 */
  padding: 8px 0 6px;
}
.gs-group-title {
  padding: 12px 22px 7px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.42);
}
.gs-hit {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 22px;
  color: inherit;
  text-decoration: none;
  border-left: 2px solid transparent;
}
/* 键盘选中与鼠标悬停用同一个态：两种操作方式看到的反馈必须一致，
 * 否则用鼠标划过再按回车，打开的会是另一条。 */
.gs-hit:hover,
.gs-hit.is-active {
  background: rgba(0, 102, 255, 0.1);
  border-left-color: #0066FF;
}
.gs-hit:focus-visible { outline: 2px solid #0066FF; outline-offset: -2px; }

.gs-thumb {
  flex: 0 0 auto;
  width: 46px; height: 46px;
  border-radius: 8px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.gs-hit-text { min-width: 0; flex: 1 1 auto; }
/* 标题与副标题都是 <span>，不设 block 的话会排在同一行，
 * 看起来像标题后面多了一截重复的字（"…Gas Detector Detector"）。 */
.gs-hit-title, .gs-hit-sub { display: block; }
.gs-hit-title {
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.45;
  /* 长标题截断而不是换行：一条结果占两行的话，一屏就看不到几条了 */
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gs-hit-sub {
  margin-top: 2px;
  font-size: 12.5px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.55);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gs-hit mark {
  padding: 0 1px;
  color: #fff;
  background: rgba(0, 102, 255, 0.32);
  border-radius: 2px;
}
.gs-ext {
  flex: 0 0 auto;
  width: 13px; height: 13px;
  color: rgba(255, 255, 255, 0.4);
}

/* 「展开全部」 */
.gs-more {
  display: block;
  width: calc(100% - 44px);
  margin: 6px 22px 10px;
  padding: 8px 0;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.72);
  text-align: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  cursor: pointer;
  transition: color 160ms, background 160ms, border-color 160ms;
}
.gs-more:hover {
  color: #fff;
  background: rgba(0, 102, 255, 0.14);
  border-color: rgba(0, 102, 255, 0.5);
}
.gs-more:focus-visible { outline: 2px solid #0066FF; outline-offset: 2px; }

/* 空态与提示 */
.gs-note {
  padding: 34px 22px 38px;
  text-align: center;
  font-size: 13.5px;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.5);
}
.gs-note strong { color: rgba(255, 255, 255, 0.82); font-weight: 600; }

/* 底栏。原来这里还有「↑↓ to navigate / ↵ to open / Esc to close」三条键盘提示，
 * 2026-08-18 按用户要求去掉，现在只剩右侧的结果条数。
 * 那几条的 kbd 样式一并删了——留着就是没人引用的死规则。 */
.gs-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 10px 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.4);
}
/* 提示文字去掉之后这一栏只剩条数，没有结果时就是一条空白横条。
 * 由 search.js 在没有条数时加 hidden 收掉，不然对话框底下白挂一截。 */
.gs-foot[hidden] { display: none; }

/* 打开时锁住背景滚动 */
body.gs-lock { overflow: hidden; }

@media (max-width: 640px) {
  .gs-overlay { padding: 0; }
  .gs-dialog {
    width: 100%;
    max-height: 100vh;
    height: 100%;
    border-radius: 0;
    border: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gs-overlay, .gs-dialog { transition: none; }
}
