/* =============================================================
 * header.css — 顶部公告条 / 主导航 / 下拉菜单 / 移动端抽屉
 * ============================================================= */

/* ---------- 顶部公告条 ---------- */
.announce-bar {
    background: linear-gradient(90deg, #0a7d58 0%, #0e9f6e 55%, #12b87f 100%);
    color: #fff;
    font-size: 13.5px;
    font-weight: 600;
    text-align: center;
    padding: 9px 48px;
    position: relative;
}
.announce-bar a {
    color: #fff;
    text-decoration: underline;
    text-underline-offset: 3px;
    margin-left: 6px;
}
.announce-bar a:hover { color: #e9f8f2; }

/* ---------- 主导航 ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid transparent;
    transition: box-shadow 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}
.site-header.is-scrolled {
    border-bottom-color: var(--c-line);
    box-shadow: 0 1px 18px rgba(16, 26, 31, 0.07);
    background: rgba(255, 255, 255, 0.96);
}

.nav-wrap {
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 28px;
}

/* Logo */
.nav-logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.nav-logo img,
.nav-logo svg { width: 34px; height: 34px; }
.nav-logo-text {
    font-size: 21px;
    font-weight: 800;
    color: var(--c-heading);
    letter-spacing: -0.02em;
}
.nav-logo-text em {
    font-style: normal;
    color: var(--c-primary);
}

/* 中部导航（后台栏目自动输出） */
.nav-menu {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}
.nav-menu-item { position: relative; }

/* 抽屉底部附加操作区：桌面端隐藏，仅 ≤1024px 抽屉内显示（见 responsive.css） */
.nav-drawer-extra { display: none; }
.nav-menu-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 9px 14px;
    font-size: 15px;
    font-weight: 600;
    color: #2c3e47;
    border-radius: var(--r-sm);
}
.nav-menu-link:hover,
.nav-menu-item.is-active > .nav-menu-link {
    color: var(--c-primary);
    background: var(--c-primary-50);
}
.nav-menu-link .caret {
    width: 14px;
    height: 14px;
    transition: transform 0.2s ease;
}
.nav-menu-item:hover .caret { transform: rotate(180deg); }

/* 下拉菜单 */
.nav-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    min-width: 200px;
    background: #fff;
    border: 1px solid var(--c-line);
    border-radius: var(--r-md);
    box-shadow: var(--sh-md);
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
}
.nav-menu-item:hover > .nav-dropdown,
.nav-menu-item:focus-within > .nav-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}
.nav-dropdown a {
    display: block;
    padding: 9px 14px;
    font-size: 14px;
    font-weight: 500;
    color: var(--c-body);
    border-radius: var(--r-sm);
    white-space: nowrap;
}
.nav-dropdown a:hover { background: var(--c-bg-muted); color: var(--c-primary); }

/* 右侧操作区 */
.nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* 搜索 */
.nav-search { position: relative; }
.nav-search-btn {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: #41535d;
    border-radius: 50%;
}
.nav-search-btn:hover { background: var(--c-bg-muted); color: var(--c-primary); }
.nav-search-box {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 300px;
    display: none;
    gap: 8px;
    padding: 12px;
    background: #fff;
    border: 1px solid var(--c-line);
    border-radius: var(--r-md);
    box-shadow: var(--sh-md);
}
.nav-search-box.is-open { display: flex; }
.nav-search-input {
    flex: 1;
    min-width: 0;
    padding: 9px 14px;
    border: 1px solid var(--c-line-strong);
    border-radius: var(--r-pill);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}
.nav-search-input:focus { border-color: var(--c-primary); }
.nav-search-submit {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border: none;
    border-radius: 50%;
    background: var(--c-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.nav-search-submit .icon { width: 17px; height: 17px; }
.nav-search-submit:hover { background: var(--c-primary-hover); }

/* 购物车入口（角标数量由 js/cart-badge.js 写入 #cart-count） */
.nav-cart {
    position: relative;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #41535d;
    border-radius: 50%;
}
.nav-cart:hover { background: var(--c-bg-muted); color: var(--c-primary); }
.cart-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--c-red);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    border-radius: 8px;
    border: 2px solid #fff;
    box-sizing: border-box;
}
/* JS 写入数量后加 is-show；无数量保持隐藏（默认 display:none，避免红色"0"角标） */
.cart-badge.is-show { display: flex; }

/* 会员入口：首字母头像 + 昵称（无昵称时后端已回退用户名） */
.nav-user {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    border-radius: var(--r-pill);
    max-width: 170px;
}
.nav-user:hover { background: var(--c-bg-muted); }
.nav-user-avatar {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--c-primary);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    user-select: none;
}
.nav-user-name {
    min-width: 0;
    font-size: 14px;
    font-weight: 600;
    color: #2c3e47;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.nav-user:hover .nav-user-name { color: var(--c-primary); }

/* =============================================================
 * 多语言切换（自定义下拉，结构见 component/header.liquid）
 * 触发按钮：当前语言旗帜 + SeoCode + 箭头；菜单：旗帜 + 语言名称
 * 展开状态由 .is-open 驱动，交互逻辑见 js/main.js
 * ============================================================= */
.lang-switch {
    position: relative;
    display: inline-flex;
}

/* 触发按钮（胶囊，尺寸对齐原 select 方案） */
.lang-switch-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 38px;
    padding: 0 10px 0 8px;
    border: 1px solid var(--c-line);
    border-radius: var(--r-pill);
    background: var(--c-bg);
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    color: #41535d;
    cursor: pointer;
    /* 手机端取消双击缩放与 300ms 点击延迟，UC 等浏览器下拉点击更跟手 */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: border-color 0.2s ease, color 0.2s ease;
}
.lang-switch-btn:hover,
.lang-switch.is-open .lang-switch-btn {
    border-color: var(--c-primary);
    color: var(--c-primary);
}

/* 旗帜（精灵符号自带颜色，不跟随 currentColor） */
.lang-switch-flag {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
}

/* 语言 SeoCode（小写库值统一大写展示） */
.lang-switch-code {
    text-transform: uppercase;
    line-height: 1;
}

/* 下拉箭头：展开时旋转（线性描边图标，需显式声明 fill/stroke） */
.lang-switch-caret {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    color: var(--c-muted);
    transition: transform 0.25s ease;
}
.lang-switch.is-open .lang-switch-caret { transform: rotate(180deg); }

/* 下拉菜单：默认隐藏，向下淡入 */
.lang-switch-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 1;
    min-width: 172px;
    padding: 6px;
    background: var(--c-bg);
    border: 1px solid var(--c-line);
    border-radius: var(--r-md);
    box-shadow: var(--sh-md);
    /* visibility 同步切换，隐藏后不阻挡点击 */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
}
.lang-switch.is-open .lang-switch-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

/* 语言选项行 */
.lang-switch-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--r-sm);
    font-size: 14px;
    font-weight: 500;
    color: #33424b;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.lang-switch-option:hover {
    background: var(--c-bg-muted);
    color: var(--c-primary);
}
/* 当前语言：浅绿底 + 品牌绿字 + 右侧对勾 */
.lang-switch-option.is-current {
    background: var(--c-primary-50);
    color: var(--c-primary);
    font-weight: 600;
}
.lang-switch-name { flex: 1; min-width: 0; }
.lang-switch-check {
    flex-shrink: 0;
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
    color: var(--c-primary);
}

/* 文字链接（登录 / 控制台） */
.nav-link-text {
    font-size: 15px;
    font-weight: 600;
    color: #2c3e47;
    padding: 8px 6px;
}
.nav-link-text:hover { color: var(--c-primary); }

/* 汉堡按钮（移动端显示） */
.nav-toggle {
    display: none;
    width: 42px;
    height: 42px;
    border: none;
    background: transparent;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
}
.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--c-heading);
    border-radius: 2px;
    transition: transform 0.25s ease, opacity 0.25s ease;
}
.nav-toggle.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.is-open span:nth-child(2) { opacity: 0; }
.nav-toggle.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* =============================================================
 * 移动端首屏关键样式（FOUC 防护）
 * responsive.css 在 body 底部加载，加载完成前浏览器只会套用本文件的桌面端
 * 顶栏样式（汉堡隐藏、搜索/登录文字/CN 文字/试用按钮全部可见），在手机视口下
 * 会短暂出现顶栏拥挤、语言切换被挤压错位。这里提前把顶栏的"移动态"固化，
 * 所有值必须与 responsive.css 同名规则保持一致，由底部样式加载后无感接管。
 * 仅放首屏可见元素；抽屉定位/下拉菜单等关闭态不影响首屏的规则不重复。
 * ============================================================= */
@media (max-width: 1024px) {
    /* 平板/手机：抽屉导航 + 紧凑间距 */
    .nav-toggle { display: inline-flex; }
    .nav-wrap { gap: 14px; }
    /* 毛玻璃会成为 fixed 抽屉的包含块并引发头部高度异常，移动端直接关闭 */
    .site-header {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    /* 抽屉未打开前不参与渲染，避免桌面 flex 菜单闪现 */
    .nav-menu { display: none; }
    .nav-menu.is-open { display: flex; }
    /* 顶栏操作区精简：登录文字入口在抽屉内 */
    .nav-actions .nav-link-text { display: none; }
    .nav-actions .btn-trial-desktop { padding: 10px 18px; font-size: 14px; }
    .nav-user { max-width: 130px; }
}

@media (max-width: 768px) {
    /* 手机端顶栏高度与桌面不同，需同步提前生效 */
    :root { --header-h: 62px; }
    .nav-actions { gap: 6px; }
    /* 搜索入口移入抽屉，顶栏不显示 */
    .nav-actions .nav-search { display: none; }
    /* 只保留头像，昵称在抽屉内显示，节省顶栏横向空间 */
    .nav-user { max-width: none; padding: 4px; gap: 0; }
    .nav-user-name { display: none; }
    .nav-cart { width: 38px; height: 38px; }
    /* 语言切换：紧凑胶囊按钮，仅保留旗帜+箭头（隐藏 CN 文字），
       防止首屏桌面态下按钮被挤压变形；下拉面板由 responsive.css 接管 */
    .lang-switch-btn { height: 36px; gap: 4px; padding: 0 7px; }
    .lang-switch-code { display: none; }
    .lang-switch-flag { width: 20px; height: 20px; }
    .lang-switch-caret { width: 13px; height: 13px; }
    /* Logo 紧凑化 */
    .nav-logo-text { font-size: 18px; }
    .nav-logo svg,
    .nav-logo img { width: 30px; height: 30px; }
    .nav-logo { padding: 4px 4px; margin-left: -4px; border-radius: var(--r-sm); }
}

/* 移动端抽屉遮罩 */
.nav-mask {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 998;
    background: rgba(11, 31, 38, 0.45);
    opacity: 0;
    transition: opacity 0.25s ease;
}
.nav-mask.is-open { display: block; opacity: 1; }

/* ---------- 首页锚点目录条（仅首页） ---------- */
.anchor-bar {
    position: sticky;
    top: var(--header-h);
    z-index: 900;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--c-line);
}
.anchor-bar-inner {
    display: flex;
    justify-content: center;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
}
.anchor-bar-inner::-webkit-scrollbar { display: none; }
.anchor-bar a {
    padding: 13px 18px;
    font-size: 14.5px;
    font-weight: 600;
    color: var(--c-muted);
    white-space: nowrap;
    border-bottom: 2px solid transparent;
}
.anchor-bar a:hover,
.anchor-bar a.is-active {
    color: var(--c-primary);
    border-bottom-color: var(--c-primary);
}
