/* ==========================================================================
 * HBC Category Header — 分类页头部
 *
 * 结构:
 *   .hbc-category-header-wrap
 *     └─ .hbc-category-header (flex row)
 *           ├─ .hbc-category-header__main (flex 1)
 *           │     ├─ .hbc-category-header__title-row
 *           │     │     ├─ .hbc-category-header__title
 *           │     │     └─ .hbc-category-header__count
 *           │     └─ .hbc-category-header__description
 *           └─ .hbc-category-header__tools (flex,跟随内容)
 *                 ├─ .hbc-category-header__sort
 *                 │     ├─ .hbc-category-header__sort-trigger (button)
 *                 │     └─ .hbc-category-header__sort-menu (ul,默认隐藏)
 *                 └─ .hbc-category-header__views
 *                       └─ .hbc-category-header__view-btn (button)
 * ========================================================================== */

.hbc-category-header-wrap {
	width: 100%;
	box-sizing: border-box;
}

.hbc-category-header {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 24px;
	width: 100%;
}

.hbc-category-header *,
.hbc-category-header *::before,
.hbc-category-header *::after {
	box-sizing: border-box;
}

/* ==========================================================================
 *  主区(标题 + 描述)
 * ========================================================================== */
.hbc-category-header__main {
	flex: 1 1 auto;
	min-width: 0;
}

.hbc-category-header__title-row {
	display: inline-flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 8px;
	margin: 0;
	line-height: 1.2;
}

.hbc-category-header__title {
	color: #1F1F1F;
	font-size: 30px;
	font-weight: 700;
	line-height: 1.2;
}

.hbc-category-header__count {
	display: inline-block;
	color: #9CA3AF;
	font-size: 14px;
	font-weight: 500;
	line-height: 1;
}

.hbc-category-header__description {
	margin: 10px 0 0;
	color: #6B7280;
	font-size: 13px;
	line-height: 1.6;
	max-width: 100%;
}

/* ==========================================================================
 *  工具区(右侧 Sort + Views)
 * ========================================================================== */
.hbc-category-header__tools {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	gap: 16px;
	margin-left: auto;
}

/* ==========================================================================
 *  Sort 下拉
 * ========================================================================== */
.hbc-category-header__sort {
	position: relative;
}

.hbc-category-header__sort-trigger {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 4px;
	margin: 0;
	background: transparent;
	border: 0;
	font: inherit;
	font-size: 14px;
	font-weight: 500;
	color: #4B5563;
	cursor: pointer;
	transition: color 0.18s ease;
}

.hbc-category-header__sort-trigger:hover {
	color: #1F1F1F;
}

.hbc-category-header__sort-trigger:focus-visible {
	outline: 2px solid #1D2D5C;
	outline-offset: 2px;
	border-radius: 2px;
}

.hbc-category-header__sort-trigger svg {
	transition: transform 0.2s ease;
}

.hbc-category-header__sort[data-open="1"] .hbc-category-header__sort-trigger svg {
	transform: rotate(180deg);
}

.hbc-category-header__sort-menu {
	position: absolute;
	top: calc(100% + 6px);
	right: 0;
	z-index: 50;
	min-width: 180px;
	margin: 0;
	padding: 6px 0;
	list-style: none;
	background-color: #FFFFFF;
	border: 1px solid #E5E7EB;
	border-radius: 6px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);
	opacity: 0;
	transform: translateY(-4px);
	pointer-events: none;
	transition: opacity 0.15s ease, transform 0.15s ease;
}

.hbc-category-header__sort[data-open="1"] .hbc-category-header__sort-menu {
	opacity: 1;
	transform: translateY(0);
	pointer-events: auto;
}

.hbc-category-header__sort-item {
	display: block;
	padding: 8px 16px;
	font-size: 13px;
	line-height: 1.4;
	color: #1F2937;
	text-decoration: none;
	white-space: nowrap;
	transition: background-color 0.12s ease, color 0.12s ease;
}

.hbc-category-header__sort-item:hover,
.hbc-category-header__sort-item:focus {
	background-color: #F3F4F6;
	color: #1F2937;
	text-decoration: none;
}

.hbc-category-header__sort-item.is-active {
	color: #1D2D5C;
	font-weight: 600;
}

/* ==========================================================================
 *  视图切换按钮组
 * ========================================================================== */
.hbc-category-header__views {
	display: inline-flex;
	align-items: center;
	gap: 4px;
}

.hbc-category-header__view-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 8px;
	margin: 0;
	font-size: 16px;
	color: #9CA3AF;
	background: transparent;
	border: 0;
	border-radius: 4px;
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.hbc-category-header__view-btn svg,
.hbc-category-header__view-btn i {
	width: 1em;
	height: 1em;
	display: block;
	pointer-events: none;
}

.hbc-category-header__view-btn svg {
	fill: currentColor;
}

.hbc-category-header__view-btn:hover {
	color: #1F1F1F;
	background-color: #F3F4F6;
}

.hbc-category-header__view-btn:focus-visible {
	outline: 2px solid #1D2D5C;
	outline-offset: 2px;
}

.hbc-category-header__view-btn.is-active {
	color: #FFFFFF;
	background-color: #1D2D5C;
}

.hbc-category-header__view-btn.is-active:hover {
	color: #FFFFFF;
	background-color: #1D2D5C;
}

.hbc-category-header__view-btn:active {
	transform: scale(0.96);
}

/* ==========================================================================
 *  响应式
 * ========================================================================== */
@media (max-width: 767px) {
	.hbc-category-header {
		flex-wrap: wrap;
	}
	.hbc-category-header__tools {
		flex-basis: 100%;
		margin-left: 0;
		justify-content: space-between;
	}
	.hbc-category-header__title {
		font-size: 22px;
	}
}

/* ==========================================================================
 *  减少动效偏好
 * ========================================================================== */
@media (prefers-reduced-motion: reduce) {
	.hbc-category-header__sort-trigger svg,
	.hbc-category-header__sort-menu,
	.hbc-category-header__view-btn,
	.hbc-category-header__sort-item {
		transition: none;
	}
}
