/* ============================================================
   科研绘图站 · 品牌页头 / 页脚
   2026-10-22 新增，配合 mu-plugin xm-brand-header.php
   ============================================================ */

/* ---------- 页头 ---------- */
.xm-header {
	position: sticky;
	top: 0;
	z-index: 9999;
	background: rgba(255, 255, 255, .92);
	-webkit-backdrop-filter: saturate(180%) blur(14px);
	backdrop-filter: saturate(180%) blur(14px);
	border-bottom: 1px solid #eceff4;
	box-shadow: 0 1px 2px rgba(16, 24, 40, .03);
}
/* block 主题全局样式的块间距会压到自定义页头上，这里归零 */
.wp-site-blocks > .xm-header,
.wp-site-blocks > .xm-footer {
	margin-block-start: 0;
	margin-block-end: 0;
}

.xm-header-row {
	max-width: 1860px;
	margin: 0 auto;
	height: 80px;
	padding: 0 20px;
	box-sizing: border-box;
	display: flex;
	align-items: center;
	gap: 20px;
}

/* ---------- 品牌区 ---------- */
.xm-brand {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: 12px;
	min-width: 0;
}
.xm-logo {
	display: flex;
	align-items: center;
	justify-content: center;
	text-decoration: none;
	flex: 0 0 auto;
}
.xm-logo-img {
	display: block;
	height: 46px;
	width: auto;
	max-width: none;
	filter: drop-shadow(0 3px 9px rgba(0, 113, 188, .28));
}
.xm-brand-text {
	display: flex;
	flex-direction: column;
	gap: 3px;
	min-width: 0;
	flex: 0 1 auto;
	line-height: 1.2;
}
.xm-site-title {
	flex: 0 0 auto;
	font-size: 22px;
	font-weight: 800;
	color: #12151a;
	letter-spacing: .5px;
	text-decoration: none;
	white-space: nowrap;
	transition: color .15s;
}
.xm-site-title:hover {
	color: #0a52eb;
}
.xm-site-desc {
	font-size: 12.5px;
	color: #8b929e;
	letter-spacing: .2px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 240px;
}

/* ---------- 主导航 ---------- */
/* 关键：导航区在宽度不足时必须向【右】溢出，绝不能向左压住品牌区。
   justify-content:flex-start + .xm-nav 的 margin-left:auto
   = 有空间时靠右（等同 flex-end），空间不足时 auto 边距归零、溢出朝右。 */
.xm-nav-wrap {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	align-items: center;
	justify-content: flex-start;
}
.xm-nav {
	display: flex;
	align-items: center;
	gap: 0;
	list-style: none;
	margin: 0 0 0 auto;
	padding: 0;
	flex-wrap: nowrap;
	position: relative;
	z-index: 2;
}
.xm-nav > li {
	position: relative;
}
.xm-nav > li > a {
	display: flex;
	align-items: center;
	height: 80px;
	padding: 0 10px;
	font-size: 14.5px;
	color: #39404d;
	text-decoration: none;
	white-space: nowrap;
	border-bottom: 2px solid transparent;
	transition: color .15s, border-color .15s;
}
.xm-nav > li > a:hover,
.xm-nav > li.current-menu-item > a,
.xm-nav > li.current-menu-parent > a {
	color: #0a52eb;
	border-bottom-color: #0a52eb;
}
.xm-nav ul {
	list-style: none;
	margin: 0;
	padding: 0;
}

/* 下拉小箭头 */
.xm-nav .menu-item-has-children > a::after {
	content: "";
	display: inline-block;
	width: 0;
	height: 0;
	margin: 5px 0 0 6px;
	border: 4px solid transparent;
	border-top-color: currentColor;
	opacity: .5;
	transition: transform .18s;
}
.xm-nav .menu-item-has-children:hover > a::after {
	transform: rotate(180deg);
}

/* 二级下拉面板 */
.xm-nav .sub-menu {
	position: absolute;
	top: calc(100% - 14px);
	left: 0;
	min-width: 188px;
	background: #fff;
	border: 1px solid #edf0f5;
	border-radius: 14px;
	padding: 10px;
	box-shadow: 0 16px 40px rgba(16, 24, 40, .13);
	display: grid;
	grid-template-columns: repeat(2, minmax(130px, 1fr));
	gap: 2px 4px;
	opacity: 0;
	visibility: hidden;
	transform: translateY(-8px);
	transition: opacity .16s, transform .16s, visibility .16s;
	z-index: 10000;
}
.xm-nav li:hover > .sub-menu,
.xm-nav li:focus-within > .sub-menu {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}
.xm-nav .sub-menu li > a {
	display: block;
	padding: 7px 10px;
	border-radius: 9px;
	font-size: 13.5px;
	color: #4b535f;
	text-decoration: none;
	white-space: nowrap;
	transition: background .14s, color .14s;
}
.xm-nav .sub-menu li > a:hover {
	background: #f2f6ff;
	color: #0a52eb;
}
.xm-nav .sub-menu .sub-menu {
	position: static;
	display: block;
	box-shadow: none;
	border: 0;
	padding: 0;
	margin: 0;
	grid-template-columns: 1fr;
	opacity: 1;
	visibility: visible;
	transform: none;
}
.xm-nav .sub-menu .sub-menu li > a {
	font-size: 12.5px;
	color: #9aa2ae;
	padding: 4px 10px;
}

/* ---------- 会员按钮 ---------- */
.xm-cta {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	height: 38px;
	padding: 0 20px;
	border-radius: 19px;
	background: linear-gradient(135deg, #0066ff, #4d9aff);
	color: #fff;
	font-size: 14px;
	text-decoration: none;
	box-shadow: 0 6px 16px rgba(0, 102, 255, .24);
	transition: transform .15s, box-shadow .15s;
	position: relative;
	z-index: 3;
}
.xm-cta:hover {
	color: #fff;
	transform: translateY(-1px);
	box-shadow: 0 10px 22px rgba(0, 102, 255, .30);
}

/* ---------- 页脚 ---------- */
.xm-footer {
	background: #fff;
	border-top: 1px solid #eef1f6;
	padding: 26px 20px;
	margin-top: 28px;
}
.xm-footer-inner {
	max-width: 1860px;
	margin: 0 auto;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 14px 26px;
	justify-content: space-between;
	color: #98a0ad;
	font-size: 13px;
}
.xm-footer-brand {
	display: flex;
	align-items: center;
	gap: 9px;
	min-width: 0;
}
.xm-footer-logo .xm-logo-img {
	height: 26px;
	width: auto;
	filter: none;
}
.xm-footer-name {
	color: #39404d;
	font-weight: 700;
}
.xm-footer-desc {
	color: #a8afba;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.xm-footer-links {
	display: flex;
	flex-wrap: wrap;
	gap: 18px;
}
.xm-footer-links a {
	color: #6b7280;
	text-decoration: none;
}
.xm-footer-links a:hover {
	color: #0a52eb;
}

/* ---------- 响应式 ---------- */
/* 顶栏有 15 个一级菜单项，按断点逐级收紧，保证任何宽度都不与品牌区/会员按钮重合。
   断点为实测推导值（每档在临界宽度处仍留有约 20px 余量，再窄一档就换更小的字号）：
   ≥1900   副标题可见 + 导航 14.5px/10px（需 1300px）
   ≤1899   隐藏副标题（它会吃掉约 130px）+ 14px/9px（需 1242px）
   ≤1564   13.5px/8px（需 1184px）
   ≤1506   13px/6px（需 1096px）
   ≤1418   12.5px/5px（需 1039px）
   ≤1360   12px/3px（需 951px）
   ≤1273   仍放不下 → 导航区横向滚动，并关闭二级下拉（滚动容器会裁掉下拉面板） */
@media screen and (min-width: 1900px) {
	.xm-site-desc {
		display: block;
	}
}
@media screen and (max-width: 1899px) {
	.xm-site-desc {
		display: none;
	}
	.xm-nav > li > a {
		padding: 0 9px;
		font-size: 14px;
	}
}
@media screen and (max-width: 1575px) {
	.xm-nav > li > a {
		padding: 0 8px;
		font-size: 13.5px;
	}
}
@media screen and (max-width: 1516px) {
	.xm-nav > li > a {
		padding: 0 6px;
		font-size: 13px;
	}
}
@media screen and (max-width: 1427px) {
	.xm-nav > li > a {
		padding: 0 5px;
		font-size: 12.5px;
	}
}
@media screen and (max-width: 1368px) {
	.xm-nav > li > a {
		padding: 0 3px;
		font-size: 12px;
	}
	.xm-nav .menu-item-has-children > a::after {
		margin-left: 3px;
	}
}
@media screen and (max-width: 1273px) {
	/* 收不下时改为横向滚动：起点紧贴品牌区右侧，绝不覆盖站名 */
	.xm-nav-wrap {
		justify-content: flex-start;
		overflow-x: auto;
		overflow-y: hidden;
		scrollbar-width: none;
		-ms-overflow-style: none;
	}
	.xm-nav-wrap::-webkit-scrollbar {
		display: none;
	}
	/* 下拉面板在滚动容器内会被裁切，此档位直接关闭下拉 */
	.xm-nav .sub-menu {
		display: none;
	}
	.xm-nav .menu-item-has-children > a::after {
		display: none;
	}
}
@media screen and (max-width: 768px) {
	.xm-header-row {
		height: auto;
		flex-wrap: wrap;
		padding: 10px 14px;
		gap: 8px;
	}
	.xm-logo-img {
		height: 38px;
		width: auto;
	}
	.xm-site-title {
		font-size: 19px;
	}
	.xm-nav-wrap {
		width: 100%;
		justify-content: flex-start;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
		order: 3;
	}
	.xm-nav {
		padding-bottom: 2px;
	}
	.xm-nav > li > a {
		height: 40px;
		font-size: 14px;
		padding: 0 10px;
		border-bottom: 0;
	}
	.xm-nav .menu-item-has-children > a::after {
		display: none;
	}
	/* 移动端不展开下拉，点击一级分类进入栏目页 */
	.xm-nav .sub-menu {
		display: none;
	}
	.xm-cta {
		height: 34px;
		padding: 0 15px;
		font-size: 13px;
		margin-left: auto;
	}
	.xm-footer-inner {
		flex-direction: column;
		align-items: flex-start;
	}
}
