/* =========================================================
   Chinese Stories · 自定义页头样式  (v3)
   报头（三栏：期号 / 文字报头 + 日期 / 账户 + 搜索）
   + 分类导航条（满宽平铺 + 吸顶）

   父主题 justnews 的页头 CSS 作用域是「body > header.header」，
   这里统一用「body > header.header.cs-header」前缀（多一个 class）：
     · 优先级高于父主题（多 1 个 class），无需 !important 硬抢；
     · 桌面端沿用父主题的吸顶（body.header-fixed）。

   报头 .cs-brand 与搜索面板 .cs-search-layer 在 <header> 之外，
   父主题没有针对它们的规则，命名全部走 cs- 前缀，互不干扰。

   断点与父主题对齐：
     ≥992px  = 桌面（三栏报头 + 满宽导航条 + 右侧搜索）
     ≤991px  = 移动（报头隐藏；矮条＝汉堡 + 品牌 + 搜索/账户；菜单原地展开）
   ========================================================= */

/* =========================================================
   0. 内容区宽度：1200 → 1320
   父主题用 :root{--theme-container-width} 分级控制 .container：
     ≥768px 750 / ≥992px 970 / ≥1240px 1200
   这里只覆盖 ≥1240px 那一档，并用 min() 防止窄屏溢出。
   末尾的 -60px 相当于左右各 30px 安全边距。
   ========================================================= */
@media (min-width: 1240px) {
	:root {
		--theme-container-width: min(1320px, calc(100vw - 60px));
	}
}

/* =========================================================
   1. 报头（桌面三栏网格；移动端整体隐藏）
   ========================================================= */
.cs-brand {
	position: relative;
	background: #f5f3ef;
	border-bottom: 1px solid #e7e2da;
}
.cs-brand-inner {
	box-sizing: border-box;
	max-width: 1600px;
	margin: 0 auto;
	padding: 20px clamp(16px, 3vw, 46px);
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
	align-items: center;
	column-gap: 24px;
}

/* ---- 左：期号 ---- */
.cs-brand-left {
	justify-self: start;
	text-align: left;
	min-width: 0;
}
.cs-issue {
	display: block;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: .14em;
	text-transform: uppercase;
	color: #8a8378;
	white-space: nowrap;
}
.cs-issue-sub {
	display: block;
	margin-top: 5px;
	font-size: 11px;
	letter-spacing: .08em;
	color: #b3aca1;
	white-space: nowrap;
}

/* ---- 中：文字报头 ---- */
.cs-brand-center {
	justify-self: center;
	text-align: center;
	min-width: 0;
}
.cs-logo {
	margin: 0;
	padding: 0;
	line-height: 1;
	display: block;
	font-weight: normal;
}
.cs-logo a,
.cs-logo a:hover,
.cs-logo a:focus {
	font-family: "Playfair Display", "Didot", "Bodoni MT", "Times New Roman", Georgia, serif;
	font-size: clamp(30px, 3.6vw, 52px);
	line-height: 1.02;
	font-weight: 800;
	letter-spacing: .05em;
	color: #111;
	text-decoration: none;
	display: inline-block;
	text-transform: uppercase;
}
.cs-logo a:hover {
	color: #c8102e;
}
.cs-date {
	margin-top: 9px;
	font-size: 13px;
	color: #8b8b8b;
	letter-spacing: .02em;
}

/* ---- 右：账户 + 搜索 ---- */
.cs-brand-right {
	justify-self: end;
	display: flex;
	align-items: center;
	gap: 16px;
	min-width: 0;
}

/* =========================================================
   2. 图标按钮（报头放大镜 / 移动矮条工具）
   ========================================================= */
.cs-icon-btn {
	-webkit-appearance: none;
	appearance: none;
	border: 0;
	background: none;
	padding: 0;
	margin: 0;
	color: #4a4a4a;
	cursor: pointer;
	line-height: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	text-decoration: none;
	transition: color .15s;
}
.cs-icon-btn:hover,
.cs-icon-btn:focus {
	color: #c8102e;
}
.cs-icon-btn svg {
	display: block;
	fill: none;
}
/* 已登录的圆形首字母头像（不用 Gravatar，零外部请求） */
.cs-icon-avatar {
	width: 30px;
	height: 30px;
	border-radius: 50%;
	background: #c8102e;
	color: #fff;
	font-size: 13px;
	font-weight: 700;
	line-height: 1;
	letter-spacing: 0;
}
.cs-icon-avatar:hover,
.cs-icon-avatar:focus {
	color: #fff;
	background: #a50d26;
}

/* =========================================================
   3. 账户入口（未登录 Sign in / Join；已登录 头像 + 下拉）
   ========================================================= */
.cs-account {
	display: flex;
	align-items: center;
	gap: 14px;
	position: relative;
}
.cs-account-out a {
	font-size: 12px;
	font-weight: 700;
	letter-spacing: .09em;
	text-transform: uppercase;
	text-decoration: none;
	white-space: nowrap;
	line-height: 1;
}
.cs-signin {
	color: #232323;
	padding: 8px 0;
	border-bottom: 2px solid transparent;
	transition: color .15s, border-color .15s;
}
.cs-signin:hover,
.cs-signin:focus {
	color: #c8102e;
	border-bottom-color: #c8102e;
}
.cs-join {
	color: #c8102e;
	border: 1px solid #c8102e;
	border-radius: 2px;
	padding: 7px 14px;
	transition: background .15s, color .15s;
}
.cs-join:hover,
.cs-join:focus {
	background: #c8102e;
	color: #fff;
}

/* 已登录 */
.cs-account-btn {
	-webkit-appearance: none;
	appearance: none;
	border: 0;
	background: none;
	padding: 0;
	margin: 0;
	cursor: pointer;
	display: flex;
	align-items: center;
	gap: 9px;
	color: #232323;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: .06em;
	line-height: 1;
	white-space: nowrap;
}
.cs-account-btn:hover {
	color: #c8102e;
}
.cs-avatar {
	width: 30px;
	height: 30px;
	border-radius: 50%;
	background: #c8102e;
	color: #fff;
	font-size: 13px;
	font-weight: 700;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: none;
}
.cs-caret {
	flex: none;
	transition: transform .18s;
}
.cs-account.is-open .cs-caret {
	transform: rotate(180deg);
}
.cs-account-menu {
	position: absolute;
	top: calc(100% + 10px);
	right: 0;
	min-width: 168px;
	background: #fff;
	border: 1px solid #e6e6e6;
	border-radius: 3px;
	box-shadow: 0 14px 30px -16px rgba(0, 0, 0, .35);
	padding: 6px 0;
	z-index: 90;
}
.cs-account-menu[hidden] {
	display: none;
}
.cs-account-menu a {
	display: block;
	padding: 9px 16px;
	font-size: 13px;
	line-height: 1.3;
	color: #333;
	text-decoration: none;
	white-space: nowrap;
}
.cs-account-menu a:hover,
.cs-account-menu a:focus {
	background: #f6f4f1;
	color: #c8102e;
}

/* =========================================================
   4. 搜索面板（.cs-search-layer）
   全站唯一实例，position:fixed —— top 由 header.js 计算，
   钉在「报头底部」（桌面）或「移动矮条底部」。
   ========================================================= */
.cs-search-layer {
	position: fixed;
	left: 0;
	right: 0;
	top: 0;
	z-index: 1000;
	background: #fff;
	border-bottom: 2px solid #1a1a1a;
	box-shadow: 0 22px 34px -26px rgba(0, 0, 0, .55);
	transform: translateY(-10px);
	opacity: 0;
	visibility: hidden;
	transition: transform .22s ease, opacity .18s ease, visibility .18s;
}
.cs-search-layer.is-open {
	transform: none;
	opacity: 1;
	visibility: visible;
}
.cs-search-form {
	margin: 0;
}
.cs-search-inner {
	box-sizing: border-box;
	max-width: 1600px;
	margin: 0 auto;
	padding: 15px clamp(16px, 3vw, 46px);
	display: flex;
	align-items: center;
	gap: 14px;
}
.cs-search-label {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}
.cs-search-input {
	order: 1;
	flex: 1 1 auto;
	min-width: 0;
	border: 0;
	outline: 0;
	background: none;
	padding: 6px 0;
	font-size: 19px;
	line-height: 1.4;
	color: #111;
	-webkit-appearance: none;
	appearance: none;
}
.cs-search-input::placeholder {
	color: #b0b0b0;
}
.cs-search-submit {
	order: 2;
	flex: none;
	border: 0;
	background: none;
	padding: 6px 4px;
	cursor: pointer;
	color: #c8102e;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: .12em;
	text-transform: uppercase;
	line-height: 1;
	white-space: nowrap;
}
.cs-search-submit:hover,
.cs-search-submit:focus {
	color: #a50d26;
}
.cs-search-close {
	order: 3;
	flex: none;
	border: 0;
	background: none;
	padding: 6px 2px;
	cursor: pointer;
	color: #9a9a9a;
	line-height: 0;
	transition: color .15s;
}
.cs-search-close:hover,
.cs-search-close:focus {
	color: #222;
}
.cs-search-close svg {
	display: block;
	fill: none;
}

/* =========================================================
   5. 桌面端（≥992px）
   ========================================================= */
@media (min-width: 992px) {

	body > header.header.cs-header {
		background: #fff;
		border-bottom: 1px solid #e7e7e7;
		box-shadow: 0 6px 14px -12px rgba(0, 0, 0, .35);
	}
	body > header.header.cs-header > .container {
		box-sizing: border-box;
		max-width: 1600px;
		width: 100%;
		margin: 0 auto;
		padding: 0 clamp(16px, 3vw, 46px);
		display: flex;
		align-items: center;
	}

	/* 报头已有品牌，条上不再重复（连带隐藏移动端工具区） */
	body > header.header.cs-header .cs-navbar-header {
		display: none;
	}

	body > header.header.cs-header .cs-nav-collapse {
		display: flex;
		align-items: center;
		margin-left: 0 !important;
		padding: 0;
		width: 100%;
		position: relative;
	}

	/* ---- 导航列表：满宽平铺（各分类按剩余空间等距展开）---- */
	body > header.header.cs-header .cs-nav-list {
		display: flex;
		flex: 1 1 auto;
		flex-wrap: wrap;
		align-items: center;
		justify-content: space-between;
		column-gap: clamp(8px, 1.1vw, 26px);
		row-gap: 0;
		list-style: none;
		margin: 0;
		padding: 0;
		width: 100%;
	}
	body > header.header.cs-header .cs-nav-list > li {
		margin: 0;
		list-style: none;
	}
	body > header.header.cs-header .cs-nav-list > li > a {
		display: block;
		padding: 17px 0;
		font-size: clamp(11.5px, calc(0.45vw + 6px), 13px);
		font-weight: 700;
		letter-spacing: .07em;
		text-transform: uppercase;
		color: #141414;
		text-decoration: none;
		position: relative;
		white-space: nowrap;
		line-height: 1.2;
		background: none;
		transition: color .15s;
	}
	body > header.header.cs-header .cs-nav-list > li > a:before {
		content: "";
		position: absolute;
		left: 0;
		right: 0;
		bottom: 10px;
		height: 2px;
		background: #c8102e;
		transform: scaleX(0);
		transition: transform .18s;
	}
	body > header.header.cs-header .cs-nav-list > li > a:hover,
	body > header.header.cs-header .cs-nav-list > li > a:focus {
		color: #c8102e;
		background: none;
	}
	body > header.header.cs-header .cs-nav-list > li > a:hover:before,
	body > header.header.cs-header .cs-nav-list > li > a:focus:before {
		transform: scaleX(1);
	}
	body > header.header.cs-header .cs-nav-list > li.current-menu-item > a,
	body > header.header.cs-header .cs-nav-list > li.current_page_item > a,
	body > header.header.cs-header .cs-nav-list > li.active > a {
		color: #c8102e;
	}

	/* 账户项只在移动端菜单里出现 */
	body > header.header.cs-header .cs-nav-list > li.cs-nav-acc {
		display: none !important;
	}
}

/* =========================================================
   6. 内容列宽度修正（桌面）
   站点的侧栏位置（primary）目前没有任何小工具，是空的。
   空侧栏白占 300px，会把主栏挤得偏左 —— 这里：
     · 侧栏无内容时隐藏它；
     · 主栏随之居中并限宽（列表页 880 / 文章页 720，正文约 680px ≈ 100 字符/行）。
   用 :has() 判断「侧栏是否有子元素」，首页侧栏有内容 ⇒ 不受影响。
   不支持 :has() 的老浏览器会跳过这整条规则（优雅降级，维持现状）。
   ========================================================= */
@media (min-width: 992px) {
	.wrap.container > .sidebar:not(:has(*)) {
		display: none;
	}
	.wrap.container:not(:has(> .sidebar > *)) > .main {
		flex: 0 1 880px;
		max-width: 880px;
		margin-left: auto;
		margin-right: auto;
	}
	body.single .wrap.container:not(:has(> .sidebar > *)) > .main {
		flex-basis: 720px;
		max-width: 720px;
	}
}

/* =========================================================
   7. 移动端（≤991px）
   报头隐藏；矮条＝汉堡 + 品牌 + [搜索][账户]；
   菜单＝原地展开的竖排列表（自带，不依赖父主题抽屉）。
   ========================================================= */
@media (max-width: 991px) {

	.cs-brand {
		display: none;
	}

	body > header.header.cs-header > .container {
		box-sizing: border-box;
		max-width: none;
		padding: 0 15px;
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		justify-content: space-between;
	}
	body > header.header.cs-header .cs-navbar-header {
		display: flex;
		align-items: center;
		justify-content: flex-start;
		height: 56px;
		width: 100%;
		margin: 0;
		gap: 12px;
	}
	body > header.header.cs-header .cs-logo-mini {
		font-family: "Playfair Display", "Didot", "Bodoni MT", "Times New Roman", Georgia, serif;
		font-size: 20px;
		font-weight: 700;
		letter-spacing: .05em;
		text-transform: uppercase;
		color: #111;
		text-decoration: none;
		line-height: 1;
	}

	/* 矮条右侧：搜索 + 账户 */
	body > header.header.cs-header .cs-navbar-tools {
		margin-left: auto;
		display: flex;
		align-items: center;
		gap: 18px;
	}

	/* 汉堡按钮 */
	body > header.header.cs-header .navbar-toggle {
		order: 0;
		margin: 0;
		padding: 9px 10px;
	}
	body > header.header.cs-header .navbar-toggle .icon-bar {
		background: #222;
	}

	/* 展开时：父主题会把整页 body 变成 fixed 并位移，这里全关掉（否则页面会跳/菜单停在屏外） */
	body.navbar-on {
		position: static !important;
		transform: none !important;
		overflow: visible !important;
	}
	body.navbar-on > header.header.cs-header {
		z-index: 950;
	}
	body.navbar-on > header.header.cs-header .navbar-toggle {
		position: static !important;
		right: auto !important;
		top: auto !important;
		margin: 0;
		padding: 9px 10px;
		z-index: auto;
	}
	body.navbar-on > header.header.cs-header .navbar-toggle .icon-bar {
		background: #222 !important;
	}
	body.navbar-on .navbar-on-shadow {
		z-index: 900 !important;
		background: rgba(0, 0, 0, .25) !important;
	}

	/* 菜单容器：占满一整行，白底，静态定位 */
	body > header.header.cs-header .navbar-collapse {
		flex: 1 0 100%;
		position: static !important;
		left: auto !important;
		right: auto !important;
		top: auto !important;
		bottom: auto !important;
		width: 100% !important;
		height: auto !important;
		margin: 0 !important;
		padding: 0 0 6px !important;
		background: #fff !important;
		opacity: 1 !important;
		transform: none !important;
		overflow: visible !important;
		box-shadow: none !important;
		z-index: auto !important;
		border: 0;
		border-top: 1px solid #eee;
		transition: none !important;
	}
	body > header.header.cs-header .navbar-collapse:before {
		content: none !important;
		display: none !important;
	}
	body > header.header.cs-header .navbar-collapse.collapse {
		display: none !important;
	}
	body > header.header.cs-header .navbar-collapse.collapse.in {
		display: block !important;
	}

	/* 竖排列表 */
	body > header.header.cs-header .cs-nav-list {
		display: block !important;
		width: 100% !important;
		margin: 0 !important;
		padding: 0 !important;
		list-style: none !important;
	}
	body > header.header.cs-header .cs-nav-list > li {
		display: block !important;
		width: 100% !important;
		float: none !important;
		margin: 0 !important;
	}
	body > header.header.cs-header .cs-nav-list > li > a {
		display: block !important;
		width: 100% !important;
		padding: 13px 2px !important;
		font-size: 13px !important;
		font-weight: 600 !important;
		letter-spacing: .06em !important;
		color: #1a1a1a !important;
		text-align: left !important;
		background: none !important;
		border-bottom: 1px solid #f0f0f0;
		line-height: 1.3 !important;
	}
	body > header.header.cs-header .cs-nav-list > li:last-child > a {
		border-bottom: 0;
	}
	body > header.header.cs-header .cs-nav-list > li > a:before {
		display: none !important;
	}
	body > header.header.cs-header .cs-nav-list > li.current-menu-item > a {
		color: #c8102e !important;
	}

	/* 菜单末尾的账户项：移动端显示，加一条分隔线 */
	body > header.header.cs-header .cs-nav-list > li.cs-nav-acc {
		display: block !important;
	}
	body > header.header.cs-header .cs-nav-list > li.cs-nav-acc:first-of-type > a {
		margin-top: 8px;
		border-top: 1px solid #f0f0f0;
	}
	body > header.header.cs-header .cs-nav-list > li.cs-nav-join > a {
		color: #c8102e !important;
		font-weight: 700 !important;
	}

	/* 搜索面板：移动端钉在矮条下方（top 由 JS 计算） */
	.cs-search-inner {
		padding: 12px 15px;
	}
	.cs-search-input {
		font-size: 16px;
	}
}
