/*
 * Cen Theme - 导航栏样式
 * 配合 Tailwind CSS v4（tailwindcss-browser）使用：
 * 结构布局使用 Tailwind 工具类，本文件仅补充
 * wp_nav_menu 输出的菜单项及少量组件细节样式。
 * 注意：index.css 中的全局 a 样式在此处已被显式覆盖。
 */

/* ========== 内页：Header 悬浮于 Hero 上层 ========== */
body.cen-has-hero .site-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: transparent;
}

/* 登录态：管理工具栏为 fixed 悬浮，Header 下移避开 */
body.admin-bar.cen-has-hero .site-header {
    top: 32px;
}

@media (max-width: 782px) {
    body.admin-bar.cen-has-hero .site-header {
        top: 46px;
    }
}

/* ========== Header 滚动固定跟随（Customizer 开关 + 滚动超过阈值才触发） ========== */
/* 基础态：始终 fixed 且可见，背景透明（与原生 Header 外观一致） */
body.cen-header-sticky .site-header {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 100;
    background: transparent;
    transition: background-color 0.35s ease;
}

/* 滚动超阈值：深色毛玻璃条淡入 */
body.cen-header-sticky.cen-is-stuck .site-header {
    background: rgba(22, 22, 22, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* 非 Hero 页面（除首页外）：Header 脱离文档流，用 padding 占位避免内容跳动 */
body.cen-header-sticky:not(.cen-has-hero):not(.home) {
    padding-top: 64px;
}

/* 登录态：管理工具栏偏移 */
body.admin-bar.cen-header-sticky .site-header {
    top: 32px !important;
}

@media (max-width: 782px) {
    body.admin-bar.cen-header-sticky .site-header {
        top: 46px !important;
    }
}

/* 开启滚动固定跟随时，中间导航胶囊背景透明 */
body.cen-header-sticky.cen-is-stuck .site-header .sticky-nav-transparent {
    background: transparent;
}

/* ========== 桌面端导航胶囊 ========== */
.nav-pill {
    display: flex;
    align-items: center;
    gap: 2.25rem;
}

.nav-pill > li {
    list-style: none;
    margin: 0;
}

.nav-pill > li > a {
    display: block;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.92);
    background: transparent;
    white-space: nowrap;
    transition: color 0.2s ease;
}

.nav-pill > li > a:hover,
.nav-pill > li > a:focus {
    color: #ffffff;
    font-weight: 600;
    background: transparent;
}

/* 当前页面菜单项高亮：橙色文字 + 前置小橙点，无背景 */
.nav-pill > li.current-menu-item > a,
.nav-pill > li.current_page_item > a,
.nav-pill > li > a.is-active {
    color: #f97316;
    background: transparent;
}

.nav-pill > li.current-menu-item > a::before,
.nav-pill > li.current_page_item > a::before,
.nav-pill > li > a.is-active::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-right: 8px;
    border-radius: 9999px;
    background: #f97316;
    vertical-align: 2px;
}

/* ========== 桌面端：多级下拉子菜单 ========== */
.nav-pill .menu-item-has-children {
    position: relative;
}

/* 一级父项：下三角指示器（::after，不新增 DOM） */
.nav-pill > li.menu-item-has-children > a::after {
    content: "";
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 6px;
    vertical-align: 2px;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid currentColor;
    opacity: 0.7;
    transition: transform 0.2s ease;
}

.nav-pill > li.menu-item-has-children:hover > a::after,
.nav-pill > li.menu-item-has-children:focus-within > a::after {
    transform: rotate(180deg);
}

/* 透明悬停桥：填补父项与下拉框之间的 12px 间隙，鼠标移入过程中不收起 */
.nav-pill:not(.nav-pill--mobile) > li.menu-item-has-children::after {
    content: "";
    position: absolute;
    top: 100%;
    left: -1rem;
    right: -1rem;
    height: 12px;
}

/* 子菜单基础态：默认隐藏，悬停 / 键盘聚焦时淡入（不与导航胶囊贴合，留 12px 间隙） */
.nav-pill .sub-menu {
    position: absolute;
    top: calc(100% + 12px);
    left: 50%;
    z-index: 60;
    min-width: 176px;
    margin: 0;
    padding: 6px;
    list-style: none;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(22, 22, 22, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, 6px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

/* 一级下拉：以父项为中心水平居中展开 */
.nav-pill:not(.nav-pill--mobile) li:hover > .sub-menu,
.nav-pill:not(.nav-pill--mobile) li:focus-within > .sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
}

/* 二级及以下：向右展开，支持任意层级 */
.nav-pill .sub-menu .sub-menu {
    top: -6px;
    left: 100%;
    transform: translate(6px, 0);
}

.nav-pill:not(.nav-pill--mobile) .sub-menu li:hover > .sub-menu,
.nav-pill:not(.nav-pill--mobile) .sub-menu li:focus-within > .sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translate(0, 0);
}

/* 子菜单中父项的横向透明桥 */
.nav-pill:not(.nav-pill--mobile) .sub-menu li.menu-item-has-children::after {
    content: "";
    position: absolute;
    top: -6px;
    bottom: -6px;
    left: 100%;
    width: 12px;
}

/* 子菜单菜单项 */
.nav-pill .sub-menu li {
    list-style: none;
    margin: 0;
}

.nav-pill .sub-menu li > a {
    display: block;
    padding: 9px 14px;
    border-radius: 9px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    line-height: 1.4;
    text-transform: uppercase;
    white-space: nowrap;
    color: rgba(255, 255, 255, 0.85);
    background: transparent;
    transition: color 0.2s ease, background-color 0.2s ease;
}

.nav-pill .sub-menu li > a:hover,
.nav-pill .sub-menu li > a:focus {
    color: #f97316;
    background: rgba(255, 255, 255, 0.08);
}

.nav-pill .sub-menu li.current-menu-item > a,
.nav-pill .sub-menu li.current_page_item > a {
    color: #f97316;
    background: rgba(249, 115, 22, 0.1);
}

/* 子菜单中的父项：右侧箭头指示可继续展开 */
.nav-pill .sub-menu li.menu-item-has-children > a {
    position: relative;
    padding-right: 2.25rem;
}

.nav-pill .sub-menu li.menu-item-has-children > a::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 1rem;
    width: 0;
    height: 0;
    margin-top: -4px;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-left: 4px solid currentColor;
    opacity: 0.7;
}

/* ========== 移动端导航 ========== */
.nav-pill--mobile {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
}

.nav-pill--mobile > li > a {
    padding: 0.625rem 0;
    font-size: 14px;
}

.nav-pill--mobile > li.current-menu-item > a::before,
.nav-pill--mobile > li > a.is-active::before {
    margin-right: 6px;
}

/* 移动端子菜单：纵向缩进、默认收起，展开由 JS 添加 .is-open 控制 */
.nav-pill--mobile .menu-item-has-children {
    position: static;
}

.nav-pill--mobile .sub-menu,
.nav-pill--mobile .sub-menu .sub-menu {
    position: static;
    top: auto;
    left: auto;
    min-width: 0;
    max-height: 0;
    margin: 0;
    padding: 0 0 0 0.875rem;
    overflow: hidden;
    border-radius: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.15);
    background: transparent;
    box-shadow: none;
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: max-height 0.3s ease;
}

.nav-pill--mobile li.is-open > .sub-menu,
.nav-pill--mobile .sub-menu li.is-open > .sub-menu {
    max-height: 1200px;
}

/* 移动端子菜单菜单项 */
.nav-pill--mobile .sub-menu li > a,
.nav-pill--mobile .sub-menu li.menu-item-has-children > a {
    padding: 0.5rem 0;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: normal;
}

/* 移动端父项箭头统一为下三角，展开时旋转 */
.nav-pill--mobile li.menu-item-has-children > a::after,
.nav-pill--mobile .sub-menu li.menu-item-has-children > a::after {
    position: static;
    right: auto;
    top: auto;
    width: 0;
    height: 0;
    margin: 0 0 0 6px;
    border-top: 4px solid currentColor;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 0;
    vertical-align: 2px;
    transition: transform 0.3s ease;
}

.nav-pill--mobile li.is-open > a::after {
    transform: rotate(180deg);
}

/* ========== 搜索输入框细节 ========== */
.site-search-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}

/* ========== 语言切换 ========== */
.lang-link {
    transition: color 0.2s ease;
}

.lang-link:hover {
    color: #f97316;
    font-weight: 600;
}
