/* ATF Header Topbar v1.4.3
 * 变更（Joanna 12:25 反馈）：
 * - 顶栏两行背景白 → 透明（跟主页背景一致，不再突兀）
 * - 删除 v1.4.1 那段全局 wp-block-post-template 强制换行 CSS（把搜索结果标题布局搞乱了）
 * - 新增：搜索结果页外层容器 padding，防止内容贴屏边
 */
@media (hover: hover) and (pointer: fine) {

  .site-header-wrapper .search-toolbar {
    display: none !important;
  }

  /* ───── 顶部工具条：透明背景（跟主页背景自然一致） ───── */
  .atf-topbar {
    background: transparent;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    padding: 0 40px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 20px;
    font-size: 13px;
    color: #333;
    box-sizing: border-box;
  }

  /* ───── 主 header：背景也改透明 ───── */
  .site-header-wrapper {
    background: transparent !important;
  }
  .site-header-wrapper .main-header {
    padding-top: 20px !important;
    padding-bottom: 20px !important;
    background: transparent !important;
  }
  .site-header-wrapper .main-header > .wp-block-group {
    display: grid !important;
    grid-template-columns: 1fr auto 1fr;
    align-items: center !important;
    gap: 24px;
  }
  .site-header-wrapper .main-header .header-logo {
    justify-self: start;
    grid-column: 1;
  }
  .site-header-wrapper .main-header .center-navigation {
    justify-self: center;
    grid-column: 2;
  }
  .site-header-wrapper .main-header .header-right-space {
    justify-self: end;
    grid-column: 3;
    min-width: 0;
  }
  .site-header-wrapper .main-header .header-right-space.atf-moved {
    display: none !important;
  }

  /* 主导航 */
  .site-header-wrapper .primary-navigation .nav-menu {
    gap: 32px !important;
  }
  .site-header-wrapper .primary-navigation .nav-menu > .menu-item > a {
    font-size: 15px;
    letter-spacing: 0.02em;
  }

  /* ───── 搜索框：380px（1.3.0 的宽度）+ 极浅边框 ───── */
  .atf-topbar .header-search-form.atf-topbar-search {
    display: inline-flex !important;
    align-items: center;
    width: 380px;
    max-width: 380px;
    height: 36px;
    padding: 0 4px 0 4px;
    border: 1px solid #E0E0E0;
    border-radius: 18px;
    background: #F6F6F6;
    box-shadow: none;
    transition: border-color .18s ease, background .18s ease;
    box-sizing: border-box;
    margin: 0;
    flex: 0 0 auto;
    margin-right: auto;
  }
  .atf-topbar .header-search-form.atf-topbar-search:hover {
    border-color: #C0C0C0;
  }
  .atf-topbar .header-search-form.atf-topbar-search:focus-within {
    border-color: #EDFE63;
    background: #F6F6F6;
    box-shadow: none;
  }
  .atf-topbar .atf-topbar-search .search-controls {
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
    gap: 8px;
  }

  /* 全站搜/栏目搜：整体包在浅灰胶囊里，激活白底 */
  .atf-topbar .atf-topbar-search .search-tabs-capsule {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    background: #E4E4E4;
    border-radius: 14px;
    padding: 2px;
    margin: 0;
    gap: 2px;
  }
  .atf-topbar .atf-topbar-search .search-tab {
    display: inline-flex !important;
    align-items: center;
    background: transparent;
    border: none;
    padding: 4px 12px;
    font-size: 13px;
    color: #666;
    cursor: pointer;
    line-height: 1;
    border-radius: 12px;
    transition: background .15s, color .15s;
    height: 24px;
    box-sizing: border-box;
    font-family: inherit;
    font-weight: 500;
  }
  .atf-topbar .atf-topbar-search .search-tab:hover {
    color: #333;
  }
  .atf-topbar .atf-topbar-search .search-tab.active {
    background: #FFF;
    color: #111;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  }
  .atf-topbar .atf-topbar-search .search-tabs-dropdown {
    display: none !important;
  }

  /* 竖线分隔（tabs 和 input 之间） */
  .atf-topbar .atf-topbar-search .search-input-wrapper {
    flex: 1 1 auto;
    min-width: 0;
    padding-left: 10px;
    border-left: 1px solid #E5E5E5;
  }
  .atf-topbar .atf-topbar-search .search-input {
    border: none !important;
    outline: none !important;
    background: transparent !important;
    width: 100% !important;
    height: 28px !important;
    padding: 0 !important;
    font-size: 12px !important;
    color: #111 !important;
    box-shadow: none !important;
  }
  .atf-topbar .atf-topbar-search .search-input::placeholder {
    color: #999 !important;
    font-size: 12px !important;
    opacity: 1 !important;
  }
  .atf-topbar .atf-topbar-search .search-icon-btn {
    flex: 0 0 auto;
    display: inline-flex;
  }
  .atf-topbar .atf-topbar-search .search-icon-btn button {
    background: transparent;
    border: none;
    padding: 4px 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
  }
  .atf-topbar .atf-topbar-search .search-icon-btn button:hover {
    background: rgba(0,0,0,0.05);
  }
  .atf-topbar .atf-topbar-search .search-icon-btn svg {
    width: 16px;
    height: 16px;
  }

  /* ───── 右侧账户区 ───── */
  .atf-topbar .header-right-space {
    display: inline-flex !important;
    align-items: center;
    flex: 0 0 auto;
    gap: 10px;
    margin: 0;
    padding: 0;
    background: transparent !important;
  }
  .atf-topbar .atf-auth-buttons {
    display: inline-flex;
    align-items: center;
    gap: 0;
  }

  /* 免费试用按钮：酸黄绿保底 + 浅灰阴影（与主页左下浮动按钮一致的立体感）
     无论 popup.css 是否加载、是否被覆盖，都强制显示为品牌酸黄绿胶囊 */
  .atf-topbar .atf-tp-nav-btn,
  .atf-topbar .atf-auth-buttons .atf-tp-nav-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #E8FF3A !important;
    color: #0E1116 !important;
    padding: 6px 14px !important;
    margin-right: 20px !important;
    border-radius: 999px !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    letter-spacing: 0.02em !important;
    cursor: pointer !important;
    border: none !important;
    line-height: 1.4 !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.10), 0 1px 2px rgba(0,0,0,0.06) !important;
    white-space: nowrap !important;
    font-family: inherit !important;
    text-decoration: none !important;
    height: auto !important;
  }
  .atf-topbar .atf-tp-nav-btn:hover,
  .atf-topbar .atf-auth-buttons .atf-tp-nav-btn:hover {
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 10px rgba(0,0,0,0.14), 0 2px 4px rgba(0,0,0,0.08) !important;
  }

  /* 登录/注册：去胶囊化，纯文字 + 居中短竖线 */
  .atf-topbar .atf-auth-buttons button.atf-auth-open[data-auth-view="login"],
  .atf-topbar .atf-auth-buttons button.atf-auth-open[data-auth-view="register"],
  .atf-topbar .atf-auth-buttons button.atf-auth-open.atf-auth-register {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: transparent !important;
    color: #555 !important;
    border: none !important;
    padding: 4px 0 !important;
    font-size: 13px !important;
    font-weight: 400 !important;
    line-height: 1.4 !important;
    border-radius: 0 !important;
    cursor: pointer !important;
    height: auto !important;
    box-shadow: none !important;
    transition: color .15s;
    white-space: nowrap;
    font-family: inherit;
    letter-spacing: 0;
  }
  .atf-topbar .atf-auth-buttons button.atf-auth-open[data-auth-view="login"]:hover,
  .atf-topbar .atf-auth-buttons button.atf-auth-open[data-auth-view="register"]:hover,
  .atf-topbar .atf-auth-buttons button.atf-auth-open.atf-auth-register:hover {
    background: transparent !important;
    color: #0E1116 !important;
    border: none !important;
  }

  /* 登录 | 注册 之间的短竖线分隔（二分之一左右边距） */
  .atf-topbar .atf-auth-buttons button.atf-auth-open[data-auth-view="login"]::after {
    content: "";
    display: inline-block;
    width: 1px;
    height: 12px;
    background: #BBB;
    margin-left: 12px;
    margin-right: 12px;
    vertical-align: middle;
    pointer-events: none;
    flex: 0 0 auto;
  }

  /* 登录态用户按钮：白底浅框胶囊（跟注册按钮同款风格，不用灰底） */
  .atf-topbar .atf-member-entry[data-authenticated="1"] > button,
  .atf-topbar .atf-member-entry[data-authenticated="1"] > a,
  .atf-topbar .atf-member-entry[data-authenticated="1"] .atf-user-toggle,
  .atf-topbar .atf-member-entry[data-authenticated="1"] .user-menu-toggle {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #FFF !important;
    color: #333 !important;
    border: 1px solid #DDD !important;
    padding: 5px 14px !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    line-height: 1.4 !important;
    border-radius: 999px !important;
    height: auto !important;
    box-shadow: none !important;
    transition: border-color .15s, color .15s;
    white-space: nowrap;
    font-family: inherit;
    text-decoration: none;
  }
  .atf-topbar .atf-member-entry[data-authenticated="1"] > button:hover,
  .atf-topbar .atf-member-entry[data-authenticated="1"] > a:hover,
  .atf-topbar .atf-member-entry[data-authenticated="1"] .atf-user-toggle:hover,
  .atf-topbar .atf-member-entry[data-authenticated="1"] .user-menu-toggle:hover {
    border-color: #999 !important;
    color: #111 !important;
    background: #FFF !important;
  }

  /* ───── 语言切换 ───── */
  .atf-lang-switch {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border-radius: 14px;
    font-size: 12px;
    color: #666;
    cursor: pointer;
    background: transparent;
    border: 1px solid transparent;
    transition: background .18s, border-color .18s, color .18s;
    line-height: 1;
    text-decoration: none;
    height: 28px;
    box-sizing: border-box;
  }
  .atf-lang-switch:hover {
    background: #F8F8F8;
    border-color: #E5E5E5;
    color: #111;
  }
  .atf-lang-switch .atf-lang-icon {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.6;
  }
  .atf-lang-switch .atf-lang-label {
    font-weight: 500;
    letter-spacing: 0.02em;
  }
}

.atf-lang-hint {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #111;
  color: #FFF;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 99999;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.atf-lang-hint.show {
  opacity: 1;
}

/* ───── v1.4.4：搜索页底部 "More posts" 限宽居中 ─────
 *   这块是主题原生的 wp-block-query，默认 alignfull 会两侧贴屏
 *   仅在搜索页（body.search）下把它限到 1240px 居中，跟上面搜索结果对齐
 *   不动首页/其它页的 wp-block-query（style gallery 等），避免误伤
 * ───── */
body.search .wp-block-query .wp-block-post-template,
body.search .wp-block-query > ul.wp-block-post-template {
  max-width: 1240px;
  margin-left: auto !important;
  margin-right: auto !important;
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
  box-sizing: border-box;
}
/* v1.4.6：More posts h2 其实在 wp-block-query 外面（平级前置块），
 *   不能用后代选择器。alignwide + has-small-font-size 这个组合在搜索页只有一处。 */
body.search h2.wp-block-heading.alignwide,
body.search .wp-block-heading.alignwide {
  max-width: 1240px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding-left: max(24px, env(safe-area-inset-left)) !important;
  padding-right: max(24px, env(safe-area-inset-right)) !important;
  box-sizing: border-box;
}
