/* ============================================
   基础层：重置 / 排版 / 背景 / 栅格 / 区块 / 页面切换 / 横幅
   ============================================ */

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

html {
	background: var(--bg);
	-webkit-text-size-adjust: 100%;
}

body {
	margin: 0;
	font-family: var(--font-sans);
	font-size: var(--fs-body);
	line-height: 1.75;
	color: var(--text);
	background: transparent;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	overflow-x: hidden;
}

/* 背景色晕。现在 --bg-tint-* 是透明的（Firefly 那种干净浅底），
   想加回氛围感把 tokens 里那两个值改成颜色即可，这里不用动。 */
body::before {
	content: "";
	position: fixed;
	inset: 0;
	z-index: -1;
	pointer-events: none;
	background-image: radial-gradient(1100px 640px at 6% -12%, var(--bg-tint-1), transparent 62%),
		radial-gradient(900px 560px at 100% 0%, var(--bg-tint-2), transparent 58%);
}

/* 一层几乎看不见的胶片颗粒，--noise 默认 0 就是关着的 */
body::after {
	content: "";
	position: fixed;
	inset: 0;
	z-index: 3;
	pointer-events: none;
	opacity: var(--noise);
	background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

h1,
h2,
h3,
p,
figure {
	margin: 0;
}

img {
	display: block;
	max-width: 100%;
}

a {
	color: inherit;
	text-decoration: none;
}

button {
	padding: 0;
	font: inherit;
	color: inherit;
	background: none;
	border: none;
	cursor: pointer;
}

ul,
ol {
	margin: 0;
	padding: 0;
	list-style: none;
}

:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 3px;
	border-radius: 4px;
}

::selection {
	background: var(--selection);
	color: var(--text);
}

/* ------- 容器 ------- */
.shell {
	width: 100%;
	max-width: var(--shell);
	margin: 0 auto;
	padding: 0 var(--sp-5);
}

/* ------- 主栅格：左内容 + 右侧栏 -------
   主内容上叠一截，压住横幅底边——留白和"贴在画上"的感觉主要靠这个。
   手机不分栏，侧栏内容整块落到主内容下面。 */
.layout {
	position: relative;
	z-index: 2;
	display: grid;
	grid-template-columns: minmax(0, 1fr) var(--sidebar-w);
	gap: var(--sp-5);
	/* ⚠️ 这里不能写 align-items:start —— 那样侧栏列只有内容那么高，
	   .side-sticky 就失去了可吸附的空间，sticky 完全不生效（实测吸附后
	   top 一路跟着滚到 -842）。默认的 stretch 让侧栏列跟主内容一样高，
	   里面的 .side-sticky 才吸得住。 */
	margin-top: calc(var(--banner-overlap) * -1);
}

/* 纯色壁纸模式下没有横幅，主内容就别上叠了 */
html[data-wallpaper="none"] .layout {
	margin-top: 0;
	padding-top: var(--sp-6);
}

.layout-main {
	min-width: 0; /* 不加这行，网格里的长内容会把列撑破 */
}

.side-sticky {
	position: sticky;
	top: calc(var(--nav-h) + var(--sp-4));
	display: flex;
	flex-direction: column;
	gap: var(--sp-4);
}

@media (max-width: 1023px) {
	.layout {
		grid-template-columns: minmax(0, 1fr);
	}

	.side-sticky {
		position: static;
	}
}

/* ------- 页面切换 -------
   页面全部叠着，靠 opacity / transform 过渡，所以切换是可打断的：
   手快连点导航，动画从当前状态被接管，不排队也不跳。

   出入场都只做「淡入淡出 + 一点垂直位移」，不做横移、不做缩放。
   前一版加了方向感和 scale，四个属性同时动，看着忙。
   出场比入场短（0.16s vs 0.26s）：旧页要快点让开，
   而 ease-out 起步快，新页在 0.16s 时已经到九成透明度，中间不会空一拍。 */
.page {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transform: translateY(14px);
	transition: opacity 0.16s var(--ease-out), transform 0.16s var(--ease-out),
		visibility 0s linear 0.16s;
}

.page.is-active {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transform: none;
	transition: opacity 0.26s var(--ease-out), transform 0.26s var(--ease-out), visibility 0s;
}

.pager {
	position: relative;
	/* 非当前页是绝对定位叠着的，不裁的话会溢出、把文档撑出一大段空白 */
	overflow: hidden;
	transition: height var(--dur-slow) var(--ease-inout);
}

/* 拖动切页时：过渡压到极短好跟手。
   这里不用 transition:none —— 那样松手时 class 一撤会丢过渡，弹回就没有动画了。 */
.page.is-dragging {
	transition: opacity 0.08s linear, transform 0.08s linear;
	user-select: none;
	-webkit-user-select: none;
}

/* ------- 区块 ------- */
.block {
	padding: var(--sp-5) 0;
}

.block:first-child {
	padding-top: 0;
}

.block-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--sp-3);
	margin-bottom: var(--sp-4);
}

/* 标题左边一根主题色小竖条——Firefly 全站反复用的母题 */
.block-title {
	position: relative;
	display: flex;
	align-items: center;
	gap: var(--sp-2);
	padding-left: var(--sp-4);
	font-size: var(--fs-h2);
	font-weight: 700;
	color: var(--text);
}

.block-title::before {
	content: "";
	position: absolute;
	left: 0;
	top: 50%;
	width: 4px;
	height: 16px;
	margin-top: -8px;
	border-radius: 4px;
	background: var(--accent);
}

.block-title iconify-icon {
	font-size: 18px;
	color: var(--accent);
}

/* ------- 横幅（壁纸 + 标题） -------
   四层叠出层次：壁纸 → 压暗 → 四角晕影 → 底部渐隐到页面底色。
   少了任何一层都会显得"图是图、页是页"，贴不到一起。 */
.banner {
	position: relative;
	height: var(--banner-h);
	background-color: var(--muted);
	background-size: cover;
	background-position: center 28%;
	transition: opacity var(--dur-slow) var(--ease-out), height var(--dur-slow) var(--ease-out);
}

/* 内页横幅矮一截，别让人滚半天才看到内容 */
body:not([data-view="home"]) .banner {
	height: calc(var(--banner-h) - 16vh);
}

.banner.is-fading {
	opacity: 0.3;
}

/* 压暗，让白字在任何壁纸上都读得清 */
.banner::before {
	content: "";
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.2);
}

/* 四角压暗、中心保持鲜明 */
.banner::after {
	content: "";
	position: absolute;
	inset: 0;
	background: radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(0, 0, 0, 0.28) 100%);
}

/* 底部渐隐到页面底色，让横幅"化"进页面而不是切一刀 */
.banner-fade {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	height: 14%;
	background: linear-gradient(to bottom, transparent, var(--bg));
	pointer-events: none;
}

.banner-text {
	position: absolute;
	left: 0;
	right: 0;
	top: 50%;
	transform: translateY(-50%);
	z-index: 2;
	width: 82%;
	max-width: 760px;
	margin: 0 auto;
	text-align: center;
	color: #fff;
}

.banner-name {
	font-size: min(var(--fs-display), 11vw);
	font-weight: 700;
	line-height: 1.25;
	text-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
}

.banner-sub {
	margin-top: var(--sp-2);
	font-size: 1.05rem;
	line-height: 1.5;
	color: rgba(255, 255, 255, 0.9);
	text-shadow: 0 2px 16px rgba(0, 0, 0, 0.6);
}

.banner .social {
	justify-content: center;
	margin-top: var(--sp-5);
}

/* 横幅上的圆形玻璃社交按钮 */
.banner-link {
	display: inline-flex;
	align-items: center;
	gap: var(--sp-2);
	height: 44px;
	padding: 0 0.9rem;
	border: 1px solid rgba(255, 255, 255, 0.18);
	border-radius: var(--r-pill);
	font-size: 0.9rem;
	color: rgba(255, 255, 255, 0.92);
	background: rgba(255, 255, 255, 0.14);
	backdrop-filter: blur(8px);
	-webkit-backdrop-filter: blur(8px);
	transition: background var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
}

.banner-link:hover {
	background: rgba(255, 255, 255, 0.26);
	transform: translateY(-2px) scale(1.04);
}

.banner-link iconify-icon {
	font-size: 1.15rem;
}

/* 纯色模式：整块横幅不要了 */
html[data-wallpaper="none"] .banner {
	display: none;
}

@media (max-width: 640px) {
	.banner-text {
		width: 88%;
	}

	body:not([data-view="home"]) .banner {
		height: calc(var(--banner-h) - 12vh);
	}

	.banner-sub {
		font-size: 0.95rem;
	}

	.banner-link {
		height: 40px;
		padding: 0 0.75rem;
		font-size: 0.85rem;
	}
}

/* 系统开了「减弱动态效果」就把所有动画和过渡一次性关掉。
   tokens 里压 --dur-* 只能管走变量的 transition，
   写死时长的 @keyframes（卡片入场、打字机光标、生日浮动、雨滴…）它管不到，
   所以这里补一道总闸。 */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}
}
