/*
 * main.css：全局变量、基础排版、顶栏、页脚与基础版式（暖白浅色）。
 * 基础版式即无 JS / 减少动态效果 / 窄屏时的可读布局：首屏占满一屏，关于直接跟在下方。
 * 3D 与动效（黑洞过渡、入场、倾斜）作为增强层叠加在 scenes.css 中。
 *
 * 3D 容器的祖先链上不要使用 overflow:hidden / filter / opacity<1，
 * 否则 preserve-3d 会被压平；横向裁剪统一用 overflow-x: clip。
 */

:root {
	--bg: #f7f6f2;
	--bg-deep: #efede6;
	--surface: #ffffff;
	--surface-2: #faf9f5;
	--text: #1d1d1a;
	--muted: #6d6c65;
	--line: #deddd6;
	--accent: #2563eb;
	--accent-soft: rgba(37, 99, 235, .12);
	--accent-line: #b5c3f2;
	--violet: #7c3aed;
	--shadow: 0 1px 2px rgba(28, 25, 23, .06), 0 12px 32px -14px rgba(28, 25, 23, .16);
	--shadow-lg: 0 2px 4px rgba(28, 25, 23, .06), 0 30px 60px -26px rgba(28, 25, 23, .26), 0 0 0 1px rgba(37, 99, 235, .12);
	--header-h: 3.5rem;
	--page-x: clamp(1.15rem, 5vw, 5rem);
	--radius: 1rem;
	--ease: cubic-bezier(.2, .7, .2, 1);
	--font: "Avenir Next", "Segoe UI Variable", "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
	color-scheme: light;
}

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

html {
	font-size: 106%;
	-webkit-text-size-adjust: 100%;
	scroll-behavior: smooth;
	overflow-x: clip;
	background: var(--bg);
}

body {
	margin: 0;
	min-height: 100vh;
	min-height: 100svh;
	font-family: var(--font);
	letter-spacing: .005em;
	line-height: 1.6;
	color: var(--text);
	background: var(--bg);
	overflow-x: clip;
}

::selection {
	color: #fff;
	background: rgba(37, 99, 235, .3);
}

a {
	color: inherit;
	text-decoration-color: transparent;
	text-underline-offset: .15em;
	transition: color .15s ease, text-decoration-color .15s ease;
}

a:hover {
	color: var(--accent);
	text-decoration: underline;
	text-decoration-color: currentColor;
}

a:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 4px;
	border-radius: .125rem;
}

/* 键盘用户按 Tab 第一下即可跳过顶栏导航 */
.skip-link {
	position: fixed;
	top: .5rem;
	left: .5rem;
	z-index: 400;
	padding: .5rem .9rem;
	border-radius: .5rem;
	background: var(--accent);
	color: #fff;
	font-size: .875rem;
	text-decoration: none;
	transform: translateY(-250%);
	transition: transform .2s var(--ease);
}

.skip-link:focus {
	transform: none;
	color: #fff;
	text-decoration: none;
}

img {
	max-width: 100%;
}

/* ---------- 顶部滚动进度条 ---------- */
.scroll-progress {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 300;
	height: 2px;
	pointer-events: none;
}

.scroll-progress span {
	display: block;
	height: 100%;
	background: linear-gradient(90deg, var(--accent), var(--violet));
	transform: scaleX(var(--progress, 0));
	transform-origin: left;
}

/* ---------- 顶栏 ---------- */
.topbar {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 200;
	height: var(--header-h);
	padding: 0 var(--page-x);
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	border-bottom: 1px solid transparent;
	transition: height .3s var(--ease), background-color .3s ease, border-color .3s ease;
}

.topbar.is-scrolled {
	height: 3rem;
	background: rgba(247, 246, 242, .86);
	background: color-mix(in srgb, var(--bg) 78%, transparent);
	border-color: var(--line);
	-webkit-backdrop-filter: blur(14px) saturate(1.2);
	backdrop-filter: blur(14px) saturate(1.2);
}

.topbar-brand {
	display: flex;
	flex-direction: column;
	min-width: 0;
	text-decoration: none;
	line-height: 1.2;
}

.topbar-brand:hover {
	color: inherit;
	text-decoration: none;
}

.site-title {
	font-size: 1.05rem;
	font-weight: 600;
	letter-spacing: -.035em;
	white-space: nowrap;
}

.tagline {
	margin-top: .1rem;
	font-size: .75rem;
	color: var(--muted);
	letter-spacing: .02em;
}

.topbar-nav {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-end;
	gap: .1rem .9rem;
	font-size: .875rem;
	color: var(--muted);
}

.topbar-nav a {
	position: relative;
	padding: .25rem 0;
	text-decoration: none;
}

.topbar-nav a::after {
	position: absolute;
	right: 0;
	bottom: .05rem;
	left: 0;
	height: 1px;
	content: "";
	background: currentColor;
	transform: scaleX(0);
	transform-origin: right;
	transition: transform .22s var(--ease);
}

.topbar-nav a:hover {
	color: var(--text);
	text-decoration: none;
}

.topbar-nav a:hover::after,
.topbar-nav a.is-current::after {
	transform: scaleX(1);
	transform-origin: left;
}

.topbar-nav a.is-current {
	color: var(--accent);
}

/* ---------- 通用场景 ---------- */
.scene {
	position: relative;
	padding: 2.8rem var(--page-x) 1.6rem;
	overflow-x: clip;
	scroll-margin-top: calc(var(--header-h) + .8rem);
}

.scene-inner {
	max-width: 64rem;
	margin: 0 auto;
}

/* 标题与右侧说明同排，省掉独立一行的高度 */
.scene-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 1rem;
	margin-bottom: .7rem;
}

.scene-label {
	margin: 0 0 .7rem;
	font-size: .72rem;
	font-weight: 600;
	letter-spacing: .16em;
	text-transform: uppercase;
	color: var(--accent);
}

.scene-head .scene-label {
	margin-bottom: 0;
}

/* ---------- 开场段容器（首屏 + 关于） ---------- */
.intro {
	position: relative;
}

.intro-frame {
	position: relative;
}

.intro-canvas,
.hole-canvas {
	display: none;
}

/* ---------- 场景 1：首屏（占满一屏） ---------- */
.hero {
	display: flex;
	align-items: center;
	min-height: 100vh;
	min-height: 100svh;
	padding: var(--header-h) var(--page-x) 3.6rem;
	background:
		radial-gradient(60rem 30rem at 72% 18%, rgba(37, 99, 235, .05), transparent 70%),
		radial-gradient(40rem 26rem at 15% 82%, rgba(124, 58, 237, .04), transparent 70%),
		var(--bg);
}

.hero-frame {
	position: relative;
	display: flex;
	flex: 1;
	align-items: center;
	justify-content: center;
	min-width: 0;
	width: 100%;
}

.hero-floor {
	display: none;
}

.hero-stage {
	--size: clamp(14rem, 26vw, 21rem);
	position: relative;
	z-index: 1;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: clamp(2rem, 6vw, 4.5rem);
	text-align: left;
	/* 球画布向四周外扩 25%，视觉左缘比布局盒多出 1/8 边长，左补同样宽度让整组视觉居中 */
	padding-left: calc(var(--size) * .125);
}

/* 镂空词云球：外层决定排版尺寸，画布向四周外扩，避免球面边缘的长词被裁掉 */
.hero-sphere-wrap {
	position: relative;
	width: var(--size);
	height: var(--size);
	flex-shrink: 0;
	cursor: grab;
	touch-action: pan-y;
}

.hero-sphere-wrap.is-dragging {
	cursor: grabbing;
}

.hero-sphere {
	position: absolute;
	top: -25%;
	left: -25%;
	width: 150%;
	height: 150%;
	pointer-events: none;
}

.hero-kicker {
	margin: 0 0 .55rem;
	font-size: .8125rem;
	font-weight: 600;
	letter-spacing: .14em;
	text-transform: uppercase;
	color: var(--accent);
}

.hero-title {
	margin: 0;
	font-size: clamp(2.5rem, 7.5vw, 5rem);
	font-weight: 650;
	line-height: 1;
	letter-spacing: -.015em;
	padding-right: .08em;
	background: linear-gradient(180deg, #1d1d1a 25%, #2563eb 110%);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
}

.hero-tagline {
	margin: .9rem 0 0;
	font-size: clamp(1rem, 2.2vw, 1.15rem);
	color: var(--muted);
}

.hero-social {
	margin-top: 1.3rem;
	display: flex;
	gap: .6rem;
}

.hero-social a {
	padding: .42rem 1rem;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: var(--surface);
	font-size: .875rem;
	text-decoration: none;
	box-shadow: var(--shadow);
	transition: transform .2s var(--ease), border-color .2s ease, color .2s ease, box-shadow .2s ease;
}

.hero-social a:hover {
	transform: translateY(-2px);
	border-color: var(--accent-line);
	box-shadow: var(--shadow), 0 0 18px -4px rgba(37, 99, 235, .45);
	text-decoration: none;
}

.scroll-hint {
	position: absolute;
	left: 50%;
	bottom: 1.6rem;
	z-index: 2;
	width: 1.4rem;
	height: 2.2rem;
	margin-left: -.7rem;
	border: 1.5px solid var(--muted);
	border-radius: 1rem;
	opacity: .7;
}

.scroll-hint span {
	position: absolute;
	top: .4rem;
	left: 50%;
	width: 3px;
	height: 6px;
	margin-left: -1.5px;
	border-radius: 2px;
	background: var(--accent);
	animation: hint-dot 1.8s var(--ease) infinite;
}

@keyframes hint-dot {
	0% { transform: translateY(0); opacity: 1; }
	70% { transform: translateY(.8rem); opacity: 0; }
	100% { transform: translateY(0); opacity: 0; }
}

/* ---------- 场景 2：关于（双栏并置） ---------- */
.about-card {
	display: grid;
	grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: var(--surface);
	box-shadow: var(--shadow);
	overflow: hidden;
}

.about-col {
	display: flex;
	flex-direction: column;
	gap: .55rem;
	padding: clamp(1.05rem, 1.8vw, 1.45rem);
}

.about-col + .about-col {
	border-left: 1px solid var(--line);
	background:
		radial-gradient(24rem 14rem at 100% 0%, rgba(37, 99, 235, .07), transparent 70%),
		var(--surface);
}

.face-tag {
	align-self: flex-start;
	padding: .1rem .5rem;
	border-radius: 999px;
	background: var(--accent-soft);
	font-size: .68rem;
	font-weight: 600;
	letter-spacing: .1em;
	text-transform: uppercase;
	color: var(--accent);
}

.face-lead {
	margin: 0;
	font-size: clamp(1rem, 1.5vw, 1.15rem);
	line-height: 1.6;
	text-wrap: pretty;
}

/* 左栏文字比右栏少，上下留白把这段宣言压在中间，避免卡片左下角空出一大块 */
.about-col:first-child .face-lead {
	margin: auto 0;
	font-size: clamp(1.05rem, 1.7vw, 1.22rem);
	line-height: 1.65;
}

.face-lead strong {
	font-weight: 600;
	text-decoration: underline;
	text-decoration-color: rgba(37, 99, 235, .38);
	text-decoration-thickness: .22em;
	text-underline-offset: -.08em;
	text-decoration-skip-ink: none;
}

.face-body {
	margin: 0;
	font-size: .9rem;
	color: var(--muted);
	text-wrap: pretty;
}

.face-body a {
	color: var(--text);
	text-decoration: underline;
	text-decoration-color: currentColor;
}

/* ---------- 卡片基座：友链与传送门共用 ---------- */
.tilt {
	--rx: 0deg;
	--ry: 0deg;
	position: relative;
	display: flex;
	flex-direction: column;
	gap: .2rem;
	height: 100%;
	padding: .85rem 1rem .95rem;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: linear-gradient(160deg, var(--surface), var(--surface-2));
	box-shadow: var(--shadow);
	text-decoration: none;
	transform: rotateX(var(--rx)) rotateY(var(--ry));
	transition: transform .25s var(--ease), box-shadow .25s ease, border-color .25s ease;
}

.tilt:hover {
	border-color: var(--accent-line);
	box-shadow: var(--shadow-lg);
	color: inherit;
	text-decoration: none;
}

/* ---------- 场景 3：传送门（5×2 网格） ---------- */
.portal-grid {
	margin: 0;
	padding: 0;
	list-style: none;
	display: grid;
	grid-template-columns: repeat(5, minmax(0, 1fr));
	gap: .55rem;
	perspective: 900px;
}

.portal-grid li {
	margin: 0;
}

.portal-card {
	flex-direction: row;
	align-items: baseline;
	gap: .5rem;
	padding: .72rem .9rem;
}

.portal-no {
	font-size: .68rem;
	font-weight: 600;
	letter-spacing: .1em;
	color: var(--accent);
	font-variant-numeric: tabular-nums;
}

.portal-name {
	font-size: .95rem;
	font-weight: 600;
	letter-spacing: -.02em;
	line-height: 1.3;
	white-space: nowrap;
}

.portal-host {
	margin-left: auto;
	min-width: 0;
	padding-left: .35rem;
	font-size: .72rem;
	color: var(--muted);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* ---------- 场景 4：博客（两列网格） ---------- */
.post-grid {
	margin: 0;
	padding: 0;
	list-style: none;
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: .55rem;
}

.post-card {
	margin: 0;
}

/* 标题独占一行，序号与日期并到同一行，卡片由三行压到两行 */
.post-card a {
	display: grid;
	grid-template-areas:
		"title title"
		"no time";
	grid-template-columns: auto 1fr;
	align-items: baseline;
	gap: .1rem .5rem;
	height: 100%;
	padding: .75rem .95rem;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: var(--surface);
	box-shadow: var(--shadow);
	text-decoration: none;
	transition: border-color .2s ease, box-shadow .25s ease, transform .25s var(--ease);
}

.post-card a:hover {
	border-color: var(--accent-line);
	box-shadow: var(--shadow-lg);
	transform: translateY(-2px);
	color: inherit;
	text-decoration: none;
}

.post-card:first-child a {
	border-color: var(--accent-line);
	background:
		radial-gradient(22rem 10rem at 100% 0%, rgba(37, 99, 235, .10), transparent 70%),
		var(--surface);
}

.post-no {
	grid-area: no;
	font-size: .68rem;
	font-weight: 600;
	letter-spacing: .1em;
	color: var(--accent);
	font-variant-numeric: tabular-nums;
}

.post-title {
	grid-area: title;
	font-size: .94rem;
	font-weight: 600;
	letter-spacing: -.01em;
	line-height: 1.45;
	text-wrap: pretty;
}

.post-card:first-child .post-title {
	font-size: 1.02rem;
}

.post-card time {
	grid-area: time;
	justify-self: end;
	font-size: .72rem;
	color: var(--muted);
}

.feed-loading,
.feed-error {
	margin: 0;
	font-size: .95rem;
	color: var(--muted);
}

.feed-error a {
	color: var(--text);
	text-decoration: underline;
}

/* ---------- 场景 5：友链 ---------- */
.links-intro {
	margin: 0;
	font-size: .82rem;
	color: var(--muted);
}

.links-intro a {
	color: var(--text);
	text-decoration: underline;
}

.link-grid {
	margin: 0;
	padding: 0;
	list-style: none;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
	gap: .55rem;
	perspective: 900px;
}

.link-grid li {
	margin: 0;
}

.link-name {
	font-size: .96rem;
	font-weight: 600;
	letter-spacing: -.01em;
}

.link-desc {
	font-size: .78rem;
	color: var(--muted);
}

/* ---------- 场景 6：页脚 ---------- */
.footer {
	position: relative;
	margin-top: 1.4rem;
	padding: 2.2rem var(--page-x) 1.5rem;
	overflow: hidden;
	overflow: clip;
	border-top: 1px solid var(--line);
	background: linear-gradient(180deg, var(--bg), var(--bg-deep));
	text-align: center;
}

.footer-floor {
	display: none;
}

.footer-inner {
	position: relative;
	z-index: 1;
}

.footer-title {
	margin: 0;
	font-size: clamp(1.3rem, 2.6vw, 1.8rem);
	font-weight: 650;
	letter-spacing: -.05em;
}

.footer-links {
	margin: .65rem 0 0;
	display: flex;
	justify-content: center;
	gap: 1.2rem;
	font-size: .9rem;
}

.footer-meta {
	margin: .85rem 0 0;
	font-size: .72rem;
	color: var(--muted);
}

.footer-meta a {
	color: var(--muted);
}

/* ---------- 中等屏：传送门三列，关于改上下 ---------- */
@media (max-width: 60rem) {
	.about-card {
		grid-template-columns: minmax(0, 1fr);
	}

	.about-col + .about-col {
		border-left: 0;
		border-top: 1px solid var(--line);
	}

	.portal-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

/* ---------- 窄屏 ---------- */
@media (max-width: 40rem) {
	.tagline {
		display: none;
	}

	.topbar-nav {
		gap: .1rem .65rem;
		font-size: .8125rem;
	}

	.topbar-nav a[href="#top"] {
		display: none;
	}

	.hero-stage {
		--size: min(16rem, 72vw);
		flex-direction: column;
		gap: 1.6rem;
		text-align: center;
		padding-left: 0;
	}

	.hero-social {
		justify-content: center;
	}

	/* 两列时卡片高度不足，域名一律截断，索性只留名称 */
	.portal-host {
		display: none;
	}

	.portal-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

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

	.link-grid {
		grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
	}
}

/* ---------- 超窄屏：品牌名不折行，导航压成一行 ---------- */
@media (max-width: 22rem) {
	.topbar-nav {
		flex-wrap: nowrap;
		gap: .1rem .5rem;
		font-size: .75rem;
	}

	.topbar-nav .nav-external {
		display: none;
	}

	.site-title {
		font-size: 1rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}

	*,
	*::before,
	*::after {
		animation-duration: .01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: .01ms !important;
	}
}

/* 仅供读屏的原文（文字被拆成单字后保留完整读法） */
.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}
