/**
 * 站点性能卡片
 * https://sleiy.cn/
 *
 * 强调色用「用户变量 + 兜底色」两段式：--spc-accent-user 由 PHP 内联写入
 * （仅在用户改过强调色时才写），深色模式因此可以换一个更亮的兜底色。
 * 深色配色与显示范围由插件按设置动态生成，不写在这里。
 */

.spc-card {
	--spc-accent: var(--spc-accent-user, #10b981);
	--spc-text: #1f2937;
	--spc-muted: #6b7280;
	--spc-faint: #9aa3b2;
	--spc-line: #eef1f6;
	--spc-band: #fafbfd;

	box-sizing: border-box;
	position: relative;
	margin: 0;
	padding: 16px 16px 14px;
	background: #fff;
	border: 1px solid var(--spc-line);
	border-radius: 14px;
	box-shadow: 0 6px 20px rgba(17, 24, 39, 0.05);
	color: var(--spc-text);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
	font-size: 14px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
}

.spc-card *,
.spc-card *::before,
.spc-card *::after {
	box-sizing: border-box;
}

/* ===== 顶部 ===== */
.spc-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-bottom: 12px;
}

.spc-title {
	margin: 0;
	min-width: 0;
	color: var(--spc-text);
	font-size: 14px;
	font-weight: 700;
	line-height: 1.2;
	letter-spacing: -0.01em;
}

.spc-status {
	--spc-status-color: var(--spc-accent);

	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 3px 9px;
	border-radius: 999px;
	background: rgba(16, 185, 129, 0.12);
	color: #0f9d6f;
	font-size: 11px;
	font-weight: 600;
	line-height: 1.6;
	white-space: nowrap;
}

.spc-status--slow {
	--spc-status-color: #f59e0b;

	background: rgba(245, 158, 11, 0.14);
	color: #b45309;
}

/* color-mix 支持时用强调色的 12% 透明底，颜色跟随自定义强调色 */
@supports (background: color-mix(in srgb, red 10%, transparent)) {
	.spc-status {
		background: color-mix(in srgb, var(--spc-status-color) 12%, transparent);
		color: var(--spc-status-color);
	}
}

.spc-status-dot {
	position: relative;
	flex: 0 0 auto;
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--spc-status-color);
}

.spc-status-dot::after {
	content: "";
	position: absolute;
	inset: -3px;
	border-radius: 50%;
	border: 2px solid var(--spc-status-color);
	opacity: 0.6;
	animation: spc-pulse-ring 1.6s ease-out infinite;
}

@keyframes spc-pulse-ring {
	0% {
		transform: scale(0.5);
		opacity: 0.7;
	}

	100% {
		transform: scale(1.6);
		opacity: 0;
	}
}

/* ===== 心跳波形（通栏） ===== */
.spc-pulse {
	position: relative;
	width: calc(100% + 32px);
	height: 56px;
	margin: 0 -16px 14px;
	background: var(--spc-band);
	border-top: 1px solid var(--spc-line);
	border-bottom: 1px solid var(--spc-line);
	overflow: hidden;
}

.spc-pulse-canvas {
	display: block;
	width: 100%;
	height: 100%;
}

.spc-pulse-meta {
	position: absolute;
	left: 14px;
	top: 8px;
	color: var(--spc-faint);
	font-size: 10px;
	letter-spacing: 0.06em;
	pointer-events: none;
}

.spc-pulse-meta strong {
	margin-left: 4px;
	color: var(--spc-accent);
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

/* ===== 2×2 指标（十字分割） ===== */
.spc-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
}

.spc-kpi {
	position: relative;
	padding: 12px 8px 12px 0;
	overflow: hidden;
}

.spc-kpi:nth-child(odd) {
	padding-right: 12px;
	border-right: 1px solid var(--spc-line);
}

.spc-kpi:nth-child(even) {
	padding-left: 12px;
}

.spc-grid > .spc-kpi:not(:nth-last-child(-n+2)) {
	border-bottom: 1px solid var(--spc-line);
}

.spc-kpi-bg {
	position: absolute;
	right: -10px;
	top: 50%;
	z-index: 0;
	width: 64px;
	height: 64px;
	color: rgba(16, 185, 129, 0.12);
	transform: translateY(-50%);
	pointer-events: none;
}

@supports (color: color-mix(in srgb, red 10%, transparent)) {
	.spc-kpi-bg {
		color: color-mix(in srgb, var(--spc-accent) 14%, transparent);
	}
}

.spc-kpi-label {
	position: relative;
	z-index: 1;
	margin-bottom: 6px;
	color: var(--spc-faint);
	font-size: 11px;
	line-height: 1;
}

.spc-kpi-num {
	position: relative;
	z-index: 1;
	display: flex;
	align-items: baseline;
	gap: 3px;
	color: var(--spc-text);
	font-weight: 700;
	line-height: 1.05;
	font-variant-numeric: tabular-nums;
	font-feature-settings: "tnum";
}

.spc-kpi-value {
	font-size: 19px;
	letter-spacing: -0.02em;
}

.spc-kpi-unit {
	color: var(--spc-faint);
	font-size: 11px;
	font-weight: 500;
}

/* ===== 入场动画 ===== */
@keyframes spc-fade-up {
	from {
		opacity: 0;
		transform: translateY(4px);
	}

	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.spc-kpi {
	animation: spc-fade-up 0.4s ease-out backwards;
}

.spc-kpi:nth-child(1) {
	animation-delay: 0.05s;
}

.spc-kpi:nth-child(2) {
	animation-delay: 0.1s;
}

.spc-kpi:nth-child(3) {
	animation-delay: 0.15s;
}

.spc-kpi:nth-child(4) {
	animation-delay: 0.2s;
}

@media (prefers-reduced-motion: reduce) {
	.spc-status-dot::after {
		animation: none;
	}

	.spc-kpi {
		animation: none;
	}
}
