/* ==========================================================================
   视图系统
   body.view-grid —— 平铺网格（默认）
   body.view-iso  —— 等距 3D（旧版）

   原则：两种视图共用同一套顶部标题，字号、位置、副标题完全一致，
   只有内容区的排布方式不同。
   ========================================================================== */

/* ==========================================================================
   一、顶部标题 —— 两版统一（不覆盖 demo.css 的字号与间距）
   ========================================================================== */

.view-grid .jq22-header,
.view-iso .jq22-header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	padding-right: 3vmax;
}

/* 内容滚动时从标题区下方穿过，用底色+渐变遮住，避免压字 */
.view-grid .jq22-header {
	background: #D4D2E0;
	padding-bottom: 10px;
}

.view-grid .jq22-header::after {
	content: '';
	position: absolute;
	left: 0;
	right: 0;
	top: 100%;
	height: 24px;
	background: linear-gradient(to bottom, #D4D2E0, rgba(212, 210, 224, 0));
	pointer-events: none;
}

/* ==========================================================================
   二、网格视图
   ========================================================================== */

.view-grid .isolayer {
	position: static !important;
	width: auto !important;
	max-width: none !important;
	height: auto !important;
	top: auto !important;
	left: auto !important;
	transform: none !important;
	-webkit-transform: none !important;
	transform-style: flat !important;
}

.view-grid .isolayer--scroll1 {
	height: auto !important;
}

.view-grid .grid {
	display: grid !important;
	/* 固定 5 列。原来用 auto-fill + minmax(300px,1fr)，列数会随视口漂移：
	   1536 → 4 列、1920 → 5 列，同一份代码在浏览器缩放不同的标签页里
	   就会显示不一致，而且 4 列的卡片偏大、不够清爽。 */
	grid-template-columns: repeat(5, minmax(0, 1fr));
	gap: 20px;
	height: auto !important;
	width: auto !important;
	padding: 186px 4vmax 80px !important;
	opacity: 1 !important;
	transform: none !important;
	-webkit-transform: none !important;
	transform-style: flat !important;
}

/* 窄一些的桌面降为 4 列（1200px 处单卡约 256px，与 5 列在 1400px 处的 241px 接近） */
@media screen and (max-width: 87.5em) {
	.view-grid .grid {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

/* 再窄降为 3 列 */
@media screen and (max-width: 75em) {
	.view-grid .grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

.view-grid .pseudo-scroller {
	display: none !important;
}

.view-grid .grid__item {
	position: static !important;
	width: auto !important;
	height: auto !important;
	margin: 0 !important;
	padding: 0 !important;
	top: auto !important;
	left: auto !important;
	animation: none !important;
	-webkit-animation: none !important;
	transform-style: flat !important;
	backface-visibility: visible !important;
}

/* 不用 !important：入场动效需要 JS 写内联 transform / opacity 接管，
   落位后内联移除，再由这条规则复位。特异性高于 AnimOnScroll 的初始隐藏态。 */
body.view-grid .grid--effect-flip .grid__item,
body.view-grid .grid--effect-flip .grid__item.shown {
	opacity: 1;
	transform: none;
}

/* 卡片 */
.view-grid .grid__link {
	position: relative !important;
	display: block;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	border-radius: 12px;
	background: #E7E5EE;
	box-shadow: 0 2px 10px rgba(50, 63, 92, 0.10);
	transform: none !important;
	-webkit-transform: none !important;
	transform-style: flat !important;
	transition: transform 0.38s cubic-bezier(0.2, 0.8, 0.3, 1),
	            box-shadow 0.38s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.view-grid .isolayer--shadow .grid__link::before {
	display: none !important;
}

.view-grid .grid__link .layer {
	position: absolute !important;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	max-width: none !important;
	object-fit: cover;
	transition: transform 0.65s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.view-grid .grid__link img.layer:not(:last-of-type) {
	display: none !important;
}

.view-grid .grid__item:hover .grid__link {
	transform: translateY(-6px) !important;
	box-shadow: 0 18px 38px rgba(50, 63, 92, 0.26);
}

.view-grid .grid__item:hover .grid__link .layer {
	transform: scale(1.045);
}

/* 标题常显 */
body.view-grid .grid__title {
	position: absolute !important;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 3 !important;
	width: auto !important;
	padding: 28px 14px 12px !important;
	background: linear-gradient(to top, rgba(22, 29, 47, 0.90), rgba(22, 29, 47, 0));
	color: #fff;
	font-size: 13.5px !important;
	font-weight: 600 !important;
	line-height: 1.4 !important;
	letter-spacing: 0.2px !important;
	text-align: left !important;
	text-transform: none !important;
	opacity: 1 !important;
	transform: none !important;
	-webkit-transform: none !important;
	display: -webkit-box !important;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* 网格视图无需加载圈（卡片已直接渲染） */
body.view-grid::after {
	display: none !important;
}

/* 网格视图不显示底部条 */
.view-grid .pater {
	display: none !important;
}

/* ==========================================================================
   三、入场动效 —— 空间重组
   首屏卡片先聚成一块斜置的微缩网格，再依次飞回各自位置并转正。
   ========================================================================== */

/* 首帧藏住卡片，防止在 JS 铺好起始帧之前闪出成品 */
body.is-entering .grid .grid__item,
body.is-entering .grid .grid__item.shown {
	opacity: 0;
}

.view-grid .grid__item.is-dealing {
	will-change: transform, opacity;
	/* 落定时的 scaleY 会触发背面剔除与重新采样，关掉双面渲染能明显减轻那一帧的负担 */
	backface-visibility: hidden;
	-webkit-backface-visibility: hidden;
}

/* 入场期间子层不再重复声明自身变换，避免和父级 3D 变换叠加后重新裁剪圆角 */
.view-grid .grid__item.is-dealing .grid__link {
	transform: none !important;
	transition: none !important;
}

/* 落位微光：卡片到位后一道斜向高光掠过 */
.view-grid .grid__link::after {
	content: '';
	position: absolute;
	inset: 0;
	z-index: 4;
	border-radius: inherit;
	pointer-events: none;
	opacity: 0;
	background: linear-gradient(105deg,
			rgba(255, 255, 255, 0) 40%,
			rgba(255, 255, 255, 0.62) 50%,
			rgba(255, 255, 255, 0) 60%);
	transform: translateX(-130%);
}

.view-grid .grid__item.is-sheen .grid__link::after {
	animation: cardSheen 0.78s cubic-bezier(0.3, 0.6, 0.3, 1) var(--sheen-delay, 0ms) both;
}

@keyframes cardSheen {
	0% {
		opacity: 0;
		transform: translateX(-130%);
	}

	18% {
		opacity: 1;
	}

	100% {
		opacity: 0;
		transform: translateX(130%);
	}
}

/* 等距视图：卡片从下方浮起放大，配合舞台立起 */
.view-iso .grid__item.is-rising .grid__link {
	animation: isoCardRise 0.74s cubic-bezier(0.2, 0.9, 0.25, 1) var(--rise-delay, 0ms) both;
}

/* 不再做透明度：舞台那一层已经在淡入，两层叠加会看成"闪两次"。
   卡片只负责缩放与上浮，层次感靠错峰延迟给。 */
@keyframes isoCardRise {
	from {
		transform: scale(0.82) translateY(34px);
	}

	to {
		transform: scale(1) translateY(0);
	}
}

/* 切换瞬间的“抽离”感。压暗幅度收得很轻，只靠去饱和制造距离感——
   压到 0.4 会看成“闪一下”，那正是双层淡入之外的第三层闪烁来源。 */
.view-grid .grid,
.view-iso .isolayer {
	transition: opacity 0.2s ease, filter 0.2s ease;
}

.view-grid.is-leaving .grid,
.view-iso.is-leaving .isolayer {
	opacity: 0.78;
	filter: saturate(0.65);
}

/* 等距 → 网格时右下角的装饰条（墨迹 + 微信号）跟着一起离场。
   它在 .view-grid 下是 display:none，不单独淡出就会被硬切掉。
   刻意不复用 .is-leaving：那条规则会给 .isolayer 加 filter，
   而 filter 会让 preserve-3d 失效，收缩过程中的立体感会被压平。 */
.view-iso .pater {
	transition: opacity 0.3s ease, transform 0.34s cubic-bezier(0.4, 0.02, 0.7, 1);
}

.view-iso.is-sinking .pater {
	opacity: 0;
	transform: translateY(26px) scale(0.97);
	pointer-events: none;
}

/* 吸入时每张卡各自飞、各自缩，升层交给 JS 逐卡设 will-change，
   这里不再对 .isolayer 做提示（它本身不参与位移）。 */

/* ==========================================================================
   四、视图切换器
   ========================================================================== */

.view-switch {
	display: flex;
	gap: 3px;
	padding: 4px;
	border-radius: 13px;
	background: rgba(255, 255, 255, 0.42);
	box-shadow: inset 0 0 0 1px rgba(50, 63, 92, 0.06), 0 2px 10px rgba(50, 63, 92, 0.06);
	flex: 0 0 auto;
	margin-left: 24px;
	margin-top: 6px;
	z-index: 3000;
	transition: box-shadow 0.3s;
}

/* 首次访问的呼吸提示，提示这里可以点 */
.view-switch.is-hint {
	animation: switchNudge 1.6s ease-in-out 2;
}

@keyframes switchNudge {
	0%, 100% { box-shadow: inset 0 0 0 1px rgba(50, 63, 92, 0.06), 0 2px 10px rgba(50, 63, 92, 0.06); }
	50% { box-shadow: inset 0 0 0 1px rgba(50, 63, 92, 0.10), 0 4px 18px rgba(50, 63, 92, 0.22); }
}

.view-switch button {
	width: auto;
	height: 34px;
	padding: 0 9px;
	border: 0;
	border-radius: 9px;
	background: transparent;
	color: #626C88;
	cursor: pointer;
	display: flex;
	align-items: center;
	gap: 0;
	transition: background 0.22s, color 0.22s, box-shadow 0.22s;
}

/* 文字默认收起，展开时给出明确的“这是切换”信号 */
.view-switch button span {
	display: inline-block;
	max-width: 0;
	margin-left: 0;
	opacity: 0;
	overflow: hidden;
	white-space: nowrap;
	font-size: 12.5px;
	font-weight: 500;
	letter-spacing: 0.2px;
	transition: max-width 0.36s cubic-bezier(0.2, 0.8, 0.3, 1),
	            opacity 0.24s,
	            margin-left 0.36s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.view-switch.is-open button span,
.view-switch:hover button span,
.view-switch:focus-within button span {
	max-width: 3.2em;
	margin-left: 6px;
	opacity: 1;
}

.view-switch button:hover {
	color: #323F5C;
	background: rgba(255, 255, 255, 0.55);
}

.view-switch button.on {
	background: #FFFFFF;
	color: #323F5C;
	box-shadow: 0 1px 4px rgba(50, 63, 92, 0.18);
}

.view-switch button:focus-visible {
	outline: 2px solid #4B5E88;
	outline-offset: 2px;
}

.view-switch svg {
	display: block;
}

/* ==========================================================================
   五、响应式
   ========================================================================== */

@media screen and (max-width: 50em) {

	html {
		-webkit-text-size-adjust: 100%;
	}

	body {
		background: #D4D2E0;
	}

	/* --- 移动端：无论哪个视图，一律网格布局 --- */
	.demo-1 main {
		display: block;
		padding-top: 0;
	}

	.isolayer {
		position: static !important;
		width: auto !important;
		max-width: none !important;
		height: auto !important;
		top: auto !important;
		left: auto !important;
		transform: none !important;
		-webkit-transform: none !important;
		transform-style: flat !important;
	}

	.isolayer--scroll1 {
		height: auto !important;
	}

	.demo-1 .grid {
		display: grid !important;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 10px;
		height: auto !important;
		width: auto !important;
		padding: 104px 16px 40px !important;
		opacity: 1 !important;
		transform: none !important;
		-webkit-transform: none !important;
	}

	.pseudo-scroller {
		display: none !important;
	}

	/* 彻底压平 3D，避免遗留的合成层覆盖浮层 */
	.grid,
	.grid__item,
	.grid__link {
		transform-style: flat !important;
		-webkit-transform-style: flat !important;
	}

	.demo-1 .grid__item {
		position: static !important;
		top: auto !important;
		left: auto !important;
		width: auto !important;
		margin: 0 !important;
		padding: 0 !important;
		opacity: 1 !important;
		transform: none !important;
		-webkit-transform: none !important;
		backface-visibility: visible !important;
		animation: none !important;
		-webkit-animation: none !important;
	}

	.js .grid--effect-flip .grid__item,
	.js .grid--effect-flip .grid__item.shown {
		opacity: 1 !important;
		transform: none !important;
	}

	.demo-1 .grid__link {
		position: relative !important;
		display: block;
		aspect-ratio: 4 / 3;
		overflow: hidden;
		border-radius: 10px;
		background: #E7E5EE;
		box-shadow: 0 4px 12px rgba(50, 63, 92, 0.18);
		transform: none !important;
		-webkit-transform: none !important;
	}

	.isolayer--shadow .grid__link::before {
		display: none !important;
	}

	.demo-1 .grid__link img.layer {
		position: absolute !important;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		max-width: none !important;
		object-fit: cover;
	}

	.demo-1 .grid__link img.layer:not(:last-of-type) {
		display: none !important;
	}

	.demo-1 .grid__title {
		position: absolute !important;
		left: 0;
		right: 0;
		bottom: 0;
		z-index: 3 !important;
		width: auto !important;
		padding: 20px 9px 8px !important;
		background: linear-gradient(to top, rgba(23, 31, 50, 0.86), rgba(23, 31, 50, 0));
		color: #fff;
		font-size: 11px !important;
		font-weight: 500 !important;
		line-height: 1.35 !important;
		letter-spacing: 0.3px !important;
		text-align: left !important;
		text-transform: none !important;
		opacity: 1 !important;
		transform: none !important;
		-webkit-transform: none !important;
		display: -webkit-box !important;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		overflow: hidden;
	}

	/* 顶部标题区 */
	.demo-1 .jq22-header {
		top: 0;
		left: 0;
		right: 0;
		width: auto;
		padding: 16px 76px 12px 16px;
		background: #D4D2E0;
		display: block;
	}

	.demo-1 .jq22-header h1 {
		font-size: 1.85em !important;
		line-height: 1.18;
		letter-spacing: -0.02em !important;
		white-space: nowrap;
	}

	.demo-1 .jq22-header p {
		margin-top: 7px !important;
		font-size: 0.8em !important;
		font-weight: 500;
	}

	.demo-1 .jq22-header::after {
		content: '';
		position: absolute;
		left: 0;
		right: 0;
		top: 100%;
		height: 16px;
		background: linear-gradient(to bottom, #D4D2E0, rgba(212, 210, 224, 0));
		pointer-events: none;
	}

	/* 移动端只留作品本身 */
	.pater {
		display: none !important;
	}

	.view-switch {
		display: none !important;
	}

}

/* 超窄屏 */
@media screen and (max-width: 22.5em) {
	.demo-1 .grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 8px;
		padding-left: 12px !important;
		padding-right: 12px !important;
	}

	.demo-1 .grid__title {
		font-size: 10.5px !important;
		padding: 16px 7px 6px !important;
	}
}
