/* ==========================================================================
   iPartsMall Child — 顶栏 / 页头 / 导航
   视觉基准：wp-site-prototype/index.html（.topbar / .hdr / .nav / .acts）
   ==========================================================================

   Blocksy 实际输出的页头结构（已核实，写选择器前对照看）：
   ---------------------------------------------------------------
   .ct-header
     [data-device="desktop"]
       [data-row="middle"][data-column-set="3"]
         .ct-container
           [data-column="start"]  > .site-branding > a.site-logo-container > img.default-logo
           [data-column="middle"] > nav.header-menu-1.menu-container > ul.menu > li.menu-item > a.ct-menu-link
           [data-column="end"]    > .ct-header-search / .ct-header-account / .ct-header-cart
   ---------------------------------------------------------------
   顶栏不是 Blocksy 的元素，是子主题通过 blocksy:header:before 钩子插进去的，
   HTML 写在 functions.php 的 ipm_child_topbar() 里。
   ========================================================================== */


/* ==========================================================================
   1. 顶栏（全球快速发货 / 保修 / 批发价 · 右侧语言切换，货币已移除）
   ========================================================================== */

.ns-topbar {
	background: var(--ns-brand-deep);
	color: #dce6ff;
	font-size: 13px;
}

.ns-topbar .ns-wrap {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	min-height: 38px;
}

.ns-topbar ul {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 22px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.ns-topbar li {
	display: inline-flex;
	align-items: center;
	gap: 8px;
}

/* 小圆点（原型 .tick） */
.ns-tick {
	width: 6px;
	height: 6px;
	flex: none;
	border-radius: 50%;
	background: #5eead4;
}

.ns-topbar .ns-topbar-right {
	display: flex;
	align-items: center;
	gap: 4px;
	flex: none;
}

/* 语言切换器（GTranslate 免费版 dropdown）——插件自带样式，这里只做容器定位与层级 */
.ns-topbar .ns-lang-wrap {
	position: relative;
	z-index: 120;
	line-height: 1;
}

/* 插件渲染出的选择器在深色条上收紧边距 */
.ns-topbar .ns-lang-wrap select,
.ns-topbar .ns-lang-wrap .gt_switcher,
.ns-topbar .ns-lang-wrap a {
	font: inherit;
	font-size: 13px;
	cursor: pointer;
}


/* ==========================================================================
   2. 页头主体 —— 半透明毛玻璃粘性顶栏
   ========================================================================== */

/* ⚠️ 不要用 CSS position:sticky。
   Blocksy 的 #main-container 带了 overflow:hidden / overflow:clip，
   后代的 sticky 会被废掉。这里的粘性页头是 Blocksy 原生的（JS + position:fixed），
   开关在 外观→自定义→页头 里改，配置项 has_sticky_header。
   启用后 DOM 会变成：
     .ct-header > [data-device] > .ct-sticky-container > [data-sticky="shrink"] > [data-row="middle"]
   滚动时真正被 fix 住的是 [data-sticky]，
   所以背景毛玻璃和底边线必须同时挂到它身上，否则滚动时会透出页面内容。 */
#main-container > header.ct-header,
#main-container > header.ct-header [data-sticky] {
	background: rgba(255, 255, 255, 0.92);
	-webkit-backdrop-filter: blur(12px);
	backdrop-filter: blur(12px);
	box-shadow: none;
}

/* 底边线只画一次（挂在被 fix 的那层上，避免和 .ct-header 叠成 2px） */
#main-container > header.ct-header [data-sticky] {
	border-bottom: 1px solid var(--ns-line);
	transition: box-shadow 0.25s ease;
}

/* 滚动后加一点投影 */
#main-container > header.ct-header [data-stuck],
#main-container > header.ct-header.is-stuck [data-sticky] {
	box-shadow: var(--ns-shadow-sm);
}

/* 主容器宽度：.ct-container 已按 --theme-container-width（视口减 gutter）收窄留边，
   这里不再叠 padding-inline，否则移动端两侧各多出 24px（2026-10-15 修复） */
.ct-header [data-row] > .ct-container {
	max-width: var(--ns-max);
}

/* 中行垂直高度：对齐原型 nav/icons 的呼吸感 */
.ct-header [data-row="middle"] [data-column] {
	min-height: 72px;
}

/* 左右区留白 */
.ct-header [data-column] {
	gap: 10px;
}


/* ==========================================================================
   3. Logo
   ========================================================================== */

.site-branding {
	display: flex;
	align-items: center;
}

/* Logo 放大：Blocksy 动态 CSS 用 [data-header*="type-1"] ... 锁死 --logo-max-height:30px
   同特异性会因加载顺序输掉 → 重复一次类名抬到 0,5,0 强制覆盖；height:auto 解掉容器的 30px 锁高 */
[data-header*="type-1"] .ct-header [data-id="logo"] .site-logo-container.site-logo-container {
	--logo-max-height: 44px;
	height: auto;
	max-height: 44px;
}

.site-branding .site-logo-container img,
.site-branding .default-logo {
	max-height: 44px;
	height: auto;
	width: auto;
	display: block;
}

/* 站点名文字形态（没上传 logo 图时的兜底） */
.site-title,
.site-branding .site-title {
	font-family: var(--theme-font-family);
	font-size: 19px;
	font-weight: 800;
	letter-spacing: -0.02em;
	color: var(--ns-ink);
	line-height: 1.1;
}


/* ==========================================================================
   4. 导航 —— 原型 .nav>li>a：14.5px / 600 / hover 背景 --bg-tint，hover 蓝字
   ========================================================================== */

.ct-header nav[data-id="menu"] ul.menu {
	display: flex;
	align-items: center;
	gap: 4px;
}

.ct-header nav[data-id="menu"] ul.menu > li > a.ct-menu-link {
	display: block;
	padding: 9px 11px; /* 14→11：给放大的 logo 让位，防止菜单折叠成 More */
	border-radius: 9px;
	font-family: var(--theme-font-family);
	font-size: 14.5px;
	font-weight: 600;
	line-height: 1.3;
	text-transform: none; /* 演示模板把菜单设成了全大写，原型是正常大小写 */
	letter-spacing: 0;
	color: var(--ns-ink-2);
	background: transparent;
	transition: background 0.18s ease, color 0.18s ease;
}

.ct-header nav[data-id="menu"] ul.menu > li > a.ct-menu-link:hover,
.ct-header nav[data-id="menu"] ul.menu > li:hover > a.ct-menu-link {
	background: var(--ns-bg-tint);
	color: var(--ns-brand);
}

/* 下拉箭头必须与文字同行且不撑高行盒（Blocksy 给它 24×24 的盒子，
   竖排/带 padding 都会把这一项变高，整行菜单基线错位——Products 明显上移） */
.ct-header nav[data-id="menu"] ul.menu > li > a.ct-menu-link .ct-toggle-dropdown-desktop {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 8px;
	height: 8px;
	padding: 0;
	margin: 0 0 0 6px;
	vertical-align: baseline;
	transform: translateY(-1px);
}

/* 当前项 */
.ct-header nav[data-id="menu"] ul.menu > li.current-menu-item > a.ct-menu-link {
	color: var(--ns-brand);
	background: var(--ns-brand-soft);
}

/* 二级下拉：对齐原型 .mega 的圆角与阴影 */
.ct-header .sub-menu,
.ct-header nav[data-id="menu"] ul.menu ul {
	background: #fff;
	border: 1px solid var(--ns-line);
	border-radius: var(--ns-radius-lg);
	box-shadow: var(--ns-shadow-lg);
	padding: 12px;
}

.ct-header nav[data-id="menu"] ul.menu ul a {
	border-radius: 8px;
	color: var(--ns-ink-2);
	font-size: 14px;
}

.ct-header nav[data-id="menu"] ul.menu ul a:hover {
	background: var(--ns-brand-soft);
	color: var(--ns-brand);
}

/* ⚠️ Blocksy 在 global.css 里把二级菜单链接色写死成白色
   （[data-header*=type-1] … .sub-menu .ct-menu-link 设了 --theme-link-initial-color:#fff，
   深色页头预设残留）。我们的下拉是白卡，必须同特异性把变量拨回来，
   否则任何没被上面直接 color 罩到的场景都会白底白字（移动端抽屉空白事故根因） */
[data-header*="type-1"] .ct-header [data-id="menu"] .sub-menu .ct-menu-link {
	--theme-link-initial-color: var(--ns-ink-2);
	--dropdown-divider: 1px solid var(--ns-line);
}

/* 导航里的 CTA 按钮 —— 菜单项加 ns-menu-cta 类即可变成主按钮 */
.ct-header nav[data-id="menu"] ul.menu > li.ns-menu-cta > a.ct-menu-link {
	background: var(--ns-brand);
	color: #fff;
	font-weight: 700;
	padding: 10px 18px;
	border-radius: 11px;
	box-shadow: 0 6px 18px rgba(29, 78, 216, 0.24);
}

.ct-header nav[data-id="menu"] ul.menu > li.ns-menu-cta > a.ct-menu-link:hover {
	background: var(--ns-brand-hover);
	color: #fff;
	transform: translateY(-1px);
}


/* ==========================================================================
   5. 右侧动作区 —— 原型 .icn：40×40 / 圆角 11 / 白底描边
   ========================================================================== */

.ct-header [data-column="end"] > [data-items] {
	display: flex;
	align-items: center;
	gap: 10px;
}

/* 统一的方形图标按钮
   （.ns-header-search = 头部搜索图标，2026-10-13 起是跳转 /product-search/ 的 <a>，
     JS 换类时去掉了 ct-header-search/ct-toggle 以脱离 Blocksy 弹窗 JS，样式改挂本类） */
.ct-header .ns-header-search,
.ct-header .ct-header-account > a,
.ct-header .ct-header-cart > .ct-cart-item,
.ct-header [data-column="end"] .ct-toggle:not(.ct-header-trigger) {
	display: inline-grid;
	place-items: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 1px solid var(--ns-line);
	border-radius: 11px;
	background: #fff;
	color: var(--ns-ink-2);
	transition: border-color 0.18s ease, color 0.18s ease;
}

.ct-header .ns-header-search:hover,
.ct-header .ct-header-account > a:hover,
.ct-header .ct-header-cart > .ct-cart-item:hover {
	border-color: var(--ns-brand-2);
	color: var(--ns-brand);
}

/* 图标尺寸 —— Blocksy 的 ct-icon 全部是「填充式」路径（fill），
   不能再叠 stroke：描边会溢出 viewBox 被裁掉，表现为图标缺边、毛糙（搜索图标最明显） */
.ct-header .ns-header-search svg,
.ct-header .ct-header-account svg,
.ct-header .ct-header-cart svg {
	width: 16px;
	height: 16px;
	fill: currentColor;
	stroke: none;
}

/* 文案标签（"Search"/"Account" 这类）在桌面端不显示，只留图标 */
.ct-header [data-column="end"] .ct-label {
	display: none;
}

/* 购物车角标 —— 原型 .badge */
.ct-header .ct-header-cart .ct-icon-container {
	position: relative;
}

.ct-header .ct-header-cart .ct-dynamic-count-cart {
	position: absolute;
	top: -7px;
	right: -7px;
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	border-radius: 9px;
	background: var(--ns-brand);
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	line-height: 18px;
	text-align: center;
}


/* ==========================================================================
   6. 移动端
   ========================================================================== */

@media (max-width: 900px) {
	.ns-topbar ul li:not(:first-child) {
		display: none;
	}

	.ns-topbar .ns-wrap {
		min-height: 34px;
		font-size: 12.5px;
	}

	.ct-header [data-row="middle"] [data-column] {
		min-height: 62px;
	}
}

/* ---------- 移动端抽屉里的二级菜单 ----------
   抽屉导航是 nav[data-id="mobile-menu"]（≠ 桌面的 data-id="menu"），
   子主题的子菜单链接样式全都不生效；而 .ct-header .sub-menu 的白卡样式罩得到，
   叠加 Blocksy 的白色链接变量 → 白底白字，Products 展开是一块「空白」。
   抽屉底是深色（rgba(18,21,25,.98)），这里改成融入深色的缩进列表。 */
.ct-header nav[data-id="mobile-menu"] .sub-menu {
	background: transparent;
	border: none;
	border-radius: 0;
	box-shadow: none;
	padding: 0 0 6px;
	margin: 0;
	--dropdown-divider: none;
}

.ct-header nav[data-id="mobile-menu"] .sub-menu li + li {
	border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.ct-header nav[data-id="mobile-menu"] .sub-menu .ct-menu-link {
	--theme-link-initial-color: #cfd9e6;
	color: #cfd9e6;
	font-size: 15px;
	font-weight: 500;
}

.ct-header nav[data-id="mobile-menu"] .sub-menu .ct-menu-link:hover,
.ct-header nav[data-id="mobile-menu"] .sub-menu li[class*="current-menu-"] > a.ct-menu-link {
	color: var(--ns-brand-2);
}

@media (max-width: 720px) {
	/* 汉堡按钮同样套用方形图标样式 */
	.ct-header .ct-header-trigger.ct-toggle {
		display: inline-grid;
		place-items: center;
		width: 40px;
		height: 40px;
		padding: 0;
		border: 1px solid var(--ns-line);
		border-radius: 11px;
		background: #fff;
		color: var(--ns-ink-2);
	}
}
