/**
 * TingPro 组件：顶栏菜单、个人栏、卡片、搜索层、抽屉、分页、进度条。
 */

/* ---------------- 顶栏菜单 ---------------- */

.top-menu {
	display: flex;
	align-items: center;
	gap: 2px;
}

.top-menu__item > a {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 14px;
	border-radius: 999px;
	font-size: 0.92rem;
	color: var(--text-sub);
	white-space: nowrap;
	transition: color 0.2s ease, background-color 0.2s ease;
}

.top-menu__item > a .icon {
	width: 16px;
	height: 16px;
}

.top-menu__item > a .icon:last-child {
	width: 14px;
	height: 14px;
	margin-left: -2px;
	transition: transform 0.2s ease;
}

.top-menu__item.has-sub:hover > a .icon:last-child {
	transform: rotate(180deg);
}

.top-menu__item > a:hover {
	color: var(--accent);
	background: var(--accent-soft);
}

.top-menu__item > a:focus {
	outline: none;
}

.top-menu__item > a:focus-visible {
	box-shadow: 0 0 0 2px var(--accent-soft);
}

.top-menu__item.is-active > a {
	color: #fff;
	background: var(--accent-gradient);
	box-shadow: 0 4px 12px rgba(196, 85, 45, 0.35);
}

/* 顶栏子菜单（depth 1 不输出，保留下拉样式备用） */
.top-menu__item.has-sub {
	position: relative;
}

/* ---------------- 个人侧栏 ---------------- */

.profile {
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 36px 20px;
	background: var(--card-bg);
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-sm);
	text-align: center;
}

.profile__avatar img {
	width: 120px;
	height: 120px;
	border-radius: 50%;
	object-fit: cover;
	border: 4px solid var(--bg-soft);
	box-shadow: var(--shadow-sm);
}

.profile__name {
	margin-top: 16px;
	font-size: 1.25rem;
	font-weight: 700;
	color: var(--text);
}

.profile__bio {
	margin-top: 6px;
	font-size: 0.88rem;
	color: var(--text-sub);
}

.profile__social {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 4px;
	margin-top: 16px;
	position: relative;
}

.profile__social a {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	color: var(--text-sub);
	transition: color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

.profile__social a:hover {
	color: var(--accent);
	background: var(--accent-soft);
	transform: translateY(-2px);
}

.profile__social .icon {
	width: 18px;
	height: 18px;
}

.profile__qr {
	position: absolute;
	top: calc(100% + 10px);
	left: 50%;
	transform: translateX(-50%);
	z-index: 20;
	padding: 6px;
	background: var(--card-bg);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	box-shadow: var(--shadow);
}

.profile__qr img {
	width: 120px;
	height: 120px;
	display: block;
	border-radius: 6px;
}

.profile__stats {
	display: flex;
	justify-content: center;
	width: 100%;
	margin-top: 20px;
	padding-top: 18px;
	border-top: 1px dashed var(--border);
}

.profile__stat {
	flex: 1;
}

.profile__stat dt {
	font-size: 1.3rem;
	font-weight: 800;
	color: var(--text);
	line-height: 1.2;
}

.profile__stat dd {
	margin: 2px 0 0;
	font-size: 0.78rem;
	color: var(--text-sub);
}

.profile__menu {
	width: 100%;
	margin-top: 20px;
	padding-top: 14px;
	border-top: 1px dashed var(--border);
	text-align: left;
}

.side-menu__item > a {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 11px 14px;
	border-radius: var(--radius-sm);
	font-size: 0.95rem;
	color: var(--text-sub);
	transition: color 0.2s ease, background-color 0.2s ease;
}

.side-menu__item > a .icon {
	width: 18px;
	height: 18px;
}

.side-menu__item > a:hover {
	color: var(--accent);
	background: var(--accent-soft);
}

.side-menu__item > a:focus {
	outline: none;
}

.side-menu__item > a:focus-visible {
	box-shadow: 0 0 0 2px var(--accent-soft);
}

.side-menu__item.is-active > a {
	color: #fff;
	background: var(--accent-gradient);
	box-shadow: 0 4px 14px rgba(196, 85, 45, 0.35);
}

.side-menu__row {
	display: flex;
	align-items: center;
	gap: 4px;
}

.side-menu__row > a {
	flex: 1;
	min-width: 0;
}

.side-menu__toggle {
	flex: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 34px;
	border: 0;
	border-radius: var(--radius-sm);
	background: transparent;
	color: var(--text-faint);
}

.side-menu__toggle .icon {
	width: 16px;
	height: 16px;
	transition: transform 0.2s ease;
}

.side-menu__item.is-open > .side-menu__row .side-menu__toggle .icon {
	transform: rotate(180deg);
}

.submenu {
	margin: 2px 0 4px;
	padding-left: 8px;
	display: none;
}

.side-menu__item.is-open > .submenu {
	display: block;
}

.submenu .side-menu__item > a {
	padding-left: 34px;
	font-size: 0.88rem;
}

/* ---------------- 文章卡片 ---------------- */

.cards-featured {
	display: flex;
	flex-direction: column;
	gap: 24px;
}

.cards {
	display: flex;
	flex-direction: column;
	gap: 24px;
	margin-top: 24px;
}

.cards-featured + .section-title + .cards {
	margin-top: 8px;
}

/* 卡片入场：初始加载与"加载更多"追加时淡入上浮 */
@keyframes tingpro-card-in {
	from {
		opacity: 0;
		transform: translateY(18px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

.cards .card,
.cards-featured .card {
	animation: tingpro-card-in 0.4s ease;
}

.card {
	position: relative;
	display: grid;
	grid-template-columns: 300px minmax(0, 1fr);
	gap: 24px;
	padding: 18px;
	background: var(--card-bg);
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-sm);
	transition: box-shadow 0.25s ease, transform 0.25s ease;
	overflow: hidden;
}

.card:hover {
	box-shadow: var(--shadow);
	transform: translateY(-2px);
}

.card--featured {
	grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	padding: 0;
}

/* 图文左右交替 */
.cards-featured .card--featured:nth-child(even) .card__media {
	order: 2;
}

.card__media {
	display: block;
	align-self: stretch;
	border-radius: var(--radius-md);
	overflow: hidden;
	background: var(--bg-soft);
}

.card--featured .card__media {
	border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

.cards-featured .card--featured:nth-child(even) .card__media {
	border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}

.card__thumb-img {
	width: 100%;
	height: 100%;
	min-height: 150px;
	object-fit: cover;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.4s ease;
}

.card:hover .card__thumb-img {
	transform: scale(1.04);
}

.card__thumb-img--placeholder {
	color: var(--text-faint);
}

.card__thumb-img--placeholder .icon {
	width: 44px;
	height: 44px;
	opacity: 0.6;
}

.card__body {
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 10px;
	padding: 10px 14px 10px 0;
	min-width: 0;
}

.card--featured .card__body {
	padding: 24px 28px;
}

.card__title {
	font-size: 1.12rem;
	font-weight: 700;
	line-height: 1.45;
}

.card--featured .card__title {
	font-size: 1.35rem;
}

.card__title a {
	color: var(--accent);
	transition: color 0.2s ease;
	display: block;
	overflow: hidden;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}

.card__title a:hover {
	color: var(--accent-strong);
}

.card__excerpt {
	font-size: 0.9rem;
	color: var(--text-sub);
	line-height: 1.8;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.card__more {
	position: absolute;
	right: 0;
	bottom: 0;
	padding: 6px 18px;
	background: var(--accent-gradient);
	color: #fff;
	font-size: 0.82rem;
	border-radius: 18px 0 0 0;
	opacity: 0.92;
	transition: opacity 0.2s ease, padding 0.2s ease;
}

.card:hover .card__more {
	opacity: 1;
	padding-right: 24px;
}

/* 无缩略图：纯文字卡片，占满整行 */
.card--noimg {
	grid-template-columns: 1fr;
}

.card--noimg .card__body {
	padding: 12px 18px;
}

.card--featured.card--noimg .card__body {
	padding: 26px 30px;
}

.card--noimg .card__title {
	font-size: 1.18rem;
}

.card--noimg .card__excerpt {
	-webkit-line-clamp: 4;
}

/* 加载圆圈（PJAX 切页时居中显示） */

.tingpro-spinner {
	position: fixed;
	inset: 0;
	z-index: 150;
	display: flex;
	align-items: center;
	justify-content: center;
	pointer-events: none;
}

.tingpro-spinner[hidden] {
	display: none;
}

.tingpro-spinner__disc {
	width: 72px;
	height: 72px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--card-bg);
	border: 1px solid var(--border);
	border-radius: 50%;
	box-shadow: var(--shadow);
	animation: tingpro-spinner-in 0.2s ease;
}

.tingpro-spinner__ring {
	width: 34px;
	height: 34px;
	border-radius: 50%;
	border: 3px solid var(--accent-soft);
	border-top-color: var(--accent);
	animation: tingpro-spinner-rotate 0.8s linear infinite;
}

@keyframes tingpro-spinner-rotate {
	to {
		transform: rotate(360deg);
	}
}

@keyframes tingpro-spinner-in {
	from {
		opacity: 0;
		transform: scale(0.85);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

/* meta 行 */

.post-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 14px;
	font-size: 0.78rem;
	color: var(--text-faint);
}

.meta-item {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	white-space: nowrap;
}

.meta-item .icon {
	width: 14px;
	height: 14px;
}

.meta-item--cat {
	color: var(--accent);
	font-weight: 600;
}

.meta-item--cat:hover {
	color: var(--accent-strong);
}

.entry-tags {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.entry-tag {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 3px 10px;
	border-radius: 999px;
	background: var(--accent-soft);
	color: var(--accent);
	font-size: 0.76rem;
}

.entry-tag:hover {
	background: var(--accent);
	color: #fff;
}

.entry-tag .icon {
	width: 12px;
	height: 12px;
}

/* 分区装饰标题 */

.section-title {
	display: flex;
	align-items: center;
	gap: 16px;
	margin: 48px 0 8px;
	color: var(--text);
}

.section-title::before,
.section-title::after {
	content: '';
	flex: 1;
	height: 1px;
	background: linear-gradient(90deg, transparent, var(--border));
}

.section-title::after {
	background: linear-gradient(90deg, var(--border), transparent);
}

.section-title h2 {
	font-size: 1.05rem;
	font-weight: 700;
	letter-spacing: 0.12em;
}

.section-title__deco {
	color: var(--accent);
	font-size: 0.9rem;
}

/* 空态 */

.cards-empty {
	padding: 64px 24px;
	text-align: center;
	color: var(--text-sub);
	background: var(--card-bg);
	border: 1px dashed var(--border);
	border-radius: var(--radius-lg);
}

.cards-empty .searchform {
	max-width: 420px;
	margin: 16px auto 0;
}

/* ---------------- 分页 ---------------- */

.loadmore-wrap {
	display: flex;
	justify-content: center;
	margin-top: 32px;
}

.loadmore-btn {
	padding: 10px 40px;
	border: 1px solid var(--border);
	border-radius: 999px;
	background: var(--card-bg);
	color: var(--text-sub);
	font-size: 0.92rem;
	box-shadow: var(--shadow-sm);
	transition: color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.loadmore-btn:hover {
	color: var(--accent);
	border-color: var(--accent);
	transform: translateY(-1px);
}

.loadmore-btn:disabled {
	opacity: 0.6;
	cursor: wait;
}

.pagination {
	margin-top: 32px;
	display: flex;
	justify-content: center;
}

.pagination ul,
.pagination .page-numbers {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
	justify-content: center;
}

.pagination .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 38px;
	height: 38px;
	padding: 0 8px;
	border-radius: var(--radius-sm);
	background: var(--card-bg);
	border: 1px solid var(--border);
	color: var(--text-sub);
	font-size: 0.9rem;
}

.pagination .page-numbers.current {
	background: var(--accent-gradient);
	border-color: transparent;
	color: #fff;
	font-weight: 700;
}

.pagination a.page-numbers:hover {
	color: var(--accent);
	border-color: var(--accent);
}

/* ---------------- 进度条 ---------------- */

.progress {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 9999;
	height: 3px;
	pointer-events: none;
	opacity: 0;
}

.progress.is-active {
	opacity: 1;
}

.progress__bar {
	height: 100%;
	width: 100%;
	background: var(--accent-gradient);
	transform: scaleX(0);
	transform-origin: 0 50%;
	transition: opacity 0.3s ease;
}

.progress.is-done .progress__bar {
	transition: transform 0.25s ease, opacity 0.35s ease 0.15s;
	opacity: 0;
}

.progress.is-failed .progress__bar {
	background: #d9534f;
}

/* ---------------- 即时搜索层 ---------------- */

.search-overlay {
	position: fixed;
	inset: 0;
	z-index: 200;
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding: 12vh 20px 20px;
}

.search-overlay[hidden] {
	display: none;
}

.search-overlay__mask {
	position: absolute;
	inset: 0;
	background: rgba(20, 16, 12, 0.4);
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
}

.search-panel {
	position: relative;
	width: 100%;
	max-width: 640px;
	background: var(--card-bg);
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow);
	overflow: hidden;
}

.search-panel__bar {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 20px;
	border-bottom: 1px solid var(--border);
	color: var(--text-sub);
}

.search-panel__bar input {
	flex: 1;
	min-width: 0;
	border: 0;
	outline: none;
	background: transparent;
	font-size: 1.05rem;
	color: var(--text);
}

.search-panel__close {
	border: 0;
	background: transparent;
	color: var(--text-faint);
	display: inline-flex;
	padding: 4px;
	border-radius: 50%;
}

.search-panel__close:hover {
	color: var(--accent);
	background: var(--accent-soft);
}

.search-panel__results {
	max-height: 46vh;
	overflow-y: auto;
	padding: 8px;
}

.search-item a {
	display: flex;
	gap: 12px;
	align-items: center;
	padding: 10px 12px;
	border-radius: var(--radius-sm);
}

.search-item a:hover,
.search-item[aria-selected='true'] a {
	background: var(--accent-soft);
}

.search-item__thumb {
	width: 56px;
	height: 56px;
	flex: none;
	border-radius: var(--radius-sm);
	object-fit: cover;
	background: var(--bg-soft);
}

.search-item__body {
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.search-item__title {
	font-weight: 600;
	color: var(--text);
	font-size: 0.95rem;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.search-item[aria-selected='true'] .search-item__title {
	color: var(--accent);
}

.search-item__excerpt {
	font-size: 0.8rem;
	color: var(--text-sub);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.search-item__meta {
	font-size: 0.72rem;
	color: var(--text-faint);
}

.search-panel__status {
	padding: 24px 20px;
	text-align: center;
	color: var(--text-sub);
}

.search-panel__hint {
	padding: 10px 20px;
	border-top: 1px solid var(--border);
	text-align: center;
	font-size: 0.74rem;
	color: var(--text-faint);
}

/* ---------------- 移动端抽屉 ---------------- */

.drawer {
	position: fixed;
	inset: 0;
	z-index: 300;
	visibility: hidden;
}

.drawer.is-open {
	visibility: visible;
}

.drawer__mask {
	position: absolute;
	inset: 0;
	background: rgba(20, 16, 12, 0.45);
	opacity: 0;
	transition: opacity 0.25s ease;
}

.drawer.is-open .drawer__mask {
	opacity: 1;
}

.drawer__panel {
	position: absolute;
	top: 0;
	left: 0;
	bottom: 0;
	width: min(340px, 86vw);
	background: var(--bg);
	box-shadow: var(--shadow);
	transform: translateX(-102%);
	transition: transform 0.28s ease;
	overflow-y: auto;
	padding: 16px 16px 32px;
}

.drawer.is-open .drawer__panel {
	transform: translateX(0);
}

.drawer__close {
	position: absolute;
	top: 14px;
	right: 14px;
	z-index: 2;
	width: 36px;
	height: 36px;
	border: 0;
	border-radius: 50%;
	background: var(--accent-soft);
	color: var(--accent);
	display: flex;
	align-items: center;
	justify-content: center;
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		transition-duration: 0.01ms !important;
		animation-duration: 0.01ms !important;
	}
}
