/*******************************************************************************
PAGE EFFECTS AND CARD SURFACES

Site-controlled page transitions and translucent card materials.
*******************************************************************************/

@keyframes page-out {
	to {
		opacity: 0;
		transform: translateY(1rem);
	}
}

@keyframes page-in {
	from {
		opacity: 0;
		transform: translateY(2rem);
	}
}

@keyframes blog-entry-in {
	from {
		opacity: 0;
		transform: translateY(1.4rem);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

html.page-leaving body > article:not(:has(.docs-tabs)),
html.page-leaving body > footer {
	animation: page-out 180ms cubic-bezier(0.4, 0, 0.2, 1) both;
}

html.page-entering body > article:not(:has(.blog-entry)):not(:has(.docs-tabs)),
html.page-entering body > footer {
	animation: page-in 300ms cubic-bezier(0.4, 0, 0.2, 1) both;
}

/* Blog lists reveal entries from top to bottom in a piano-like sequence. */
html.js .blog-entry:not(.is-revealed) {
	opacity: 0;
}

.blog-entry.is-entering {
	animation: blog-entry-in 520ms cubic-bezier(0.22, 1, 0.36, 1) both;
	animation-delay: calc(var(--entry-index, 0) * 85ms);
}

:root {
	--surface-card-bg: rgba(255, 255, 252, 0.46);
	--surface-card-bg-hover: rgba(255, 255, 252, 0.62);
	--surface-card-border: rgba(44, 44, 44, 0.06);
	--surface-card-border-hover: rgba(44, 44, 44, 0.11);
	--surface-card-shadow:
		0 0.9rem 2.2rem rgba(44, 44, 44, 0.055),
		0 0.2rem 0.65rem rgba(44, 44, 44, 0.035);
	--surface-card-shadow-hover:
		0 1.05rem 2.6rem rgba(44, 44, 44, 0.075),
		0 0.25rem 0.8rem rgba(44, 44, 44, 0.045);
	--note-card-bg: rgba(255, 255, 254, 0.5);
	--note-card-bg-hover: rgba(255, 255, 254, 0.64);
	--note-card-border: rgba(44, 44, 44, 0.085);
	--note-card-border-hover: rgba(44, 44, 44, 0.14);
	--note-card-shadow:
		0 1.1rem 3rem rgba(44, 44, 44, 0.1),
		0 0.25rem 0.9rem rgba(44, 44, 44, 0.05);
	--note-card-shadow-hover:
		0 1.35rem 3.4rem rgba(44, 44, 44, 0.14),
		0 0.35rem 1rem rgba(44, 44, 44, 0.07);
	--toc-card-bg: rgba(255, 255, 252, 0.24);
	--toc-card-border: rgba(44, 44, 44, 0.045);
	--toc-card-shadow:
		0 0.45rem 1.4rem rgba(44, 44, 44, 0.03),
		0 0.12rem 0.4rem rgba(44, 44, 44, 0.02);
}

html[data-theme="dark"],
html:not([data-theme]) {
	--surface-card-bg: rgba(52, 57, 67, 0.38);
	--surface-card-bg-hover: rgba(56, 62, 73, 0.5);
	--surface-card-border: rgba(229, 230, 232, 0.055);
	--surface-card-border-hover: rgba(229, 230, 232, 0.1);
	--surface-card-shadow:
		0 0.9rem 2.2rem rgba(0, 0, 0, 0.16),
		0 0.2rem 0.65rem rgba(0, 0, 0, 0.1);
	--surface-card-shadow-hover:
		0 1.05rem 2.6rem rgba(0, 0, 0, 0.2),
		0 0.25rem 0.8rem rgba(0, 0, 0, 0.13);
	--note-card-bg: rgba(60, 66, 78, 0.42);
	--note-card-bg-hover: rgba(66, 73, 86, 0.54);
	--note-card-border: rgba(229, 230, 232, 0.085);
	--note-card-border-hover: rgba(229, 230, 232, 0.14);
	--note-card-shadow:
		0 1.1rem 3rem rgba(0, 0, 0, 0.36),
		0 0.25rem 0.9rem rgba(0, 0, 0, 0.22);
	--note-card-shadow-hover:
		0 1.35rem 3.4rem rgba(0, 0, 0, 0.44),
		0 0.35rem 1rem rgba(0, 0, 0, 0.26);
	--toc-card-bg: rgba(52, 57, 67, 0.22);
	--toc-card-border: rgba(229, 230, 232, 0.04);
	--toc-card-shadow:
		0 0.45rem 1.4rem rgba(0, 0, 0, 0.1),
		0 0.12rem 0.4rem rgba(0, 0, 0, 0.06);
}

@media (prefers-color-scheme: light) {
	html:not([data-theme]) {
		--surface-card-bg: rgba(255, 255, 252, 0.46);
		--surface-card-bg-hover: rgba(255, 255, 252, 0.62);
		--surface-card-border: rgba(44, 44, 44, 0.06);
		--surface-card-border-hover: rgba(44, 44, 44, 0.11);
		--surface-card-shadow:
			0 0.9rem 2.2rem rgba(44, 44, 44, 0.055),
			0 0.2rem 0.65rem rgba(44, 44, 44, 0.035);
		--surface-card-shadow-hover:
			0 1.05rem 2.6rem rgba(44, 44, 44, 0.075),
			0 0.25rem 0.8rem rgba(44, 44, 44, 0.045);
		--note-card-bg: rgba(255, 255, 254, 0.5);
		--note-card-bg-hover: rgba(255, 255, 254, 0.64);
		--note-card-border: rgba(44, 44, 44, 0.085);
		--note-card-border-hover: rgba(44, 44, 44, 0.14);
		--note-card-shadow:
			0 1.1rem 3rem rgba(44, 44, 44, 0.1),
			0 0.25rem 0.9rem rgba(44, 44, 44, 0.05);
		--note-card-shadow-hover:
			0 1.35rem 3.4rem rgba(44, 44, 44, 0.14),
			0 0.35rem 1rem rgba(44, 44, 44, 0.07);
		--toc-card-bg: rgba(255, 255, 252, 0.24);
		--toc-card-border: rgba(44, 44, 44, 0.045);
		--toc-card-shadow:
			0 0.45rem 1.4rem rgba(44, 44, 44, 0.03),
			0 0.12rem 0.4rem rgba(44, 44, 44, 0.02);
	}
}

/*******************************************************************************
BLOG ENTRY CARDS
*******************************************************************************/

.blog-entry {
	box-sizing: border-box;
	margin: 0.75rem 0;
	padding: 1rem 1.25rem;
	border: 1px solid var(--surface-card-border);
	border-bottom: 1px solid var(--surface-card-border);
	border-radius: 0.9rem;
	background: var(--surface-card-bg);
	box-shadow: var(--surface-card-shadow);
	transition:
		background-color 180ms ease,
		border-color 180ms ease,
		box-shadow 180ms ease,
		transform 180ms ease;
}

.blog-entry:hover {
	border-color: var(--surface-card-border-hover);
	background: var(--surface-card-bg-hover);
	box-shadow: var(--surface-card-shadow-hover);
	transform: translateY(-2px);
}

/*******************************************************************************
MARGIN NOTE CARDS
*******************************************************************************/

@media (min-width: 761px) {
	.marginnote {
		box-sizing: border-box;
		padding: 0.6rem 0.7rem;
		border: 1px solid var(--note-card-border);
		border-radius: 0.65rem;
		background: var(--note-card-bg);
		box-shadow: var(--note-card-shadow);
	}

	.marginnote:hover {
		border-color: var(--note-card-border-hover);
		box-shadow: var(--note-card-shadow-hover);
	}
}

/*******************************************************************************
TABLE OF CONTENTS CARD
*******************************************************************************/

@media (min-width: 1200px) {
	.toc-sidebar {
		top: 10rem;
		left: 0.35%;
		width: 11.8%;
		max-height: calc(100vh - 12rem);
		box-sizing: border-box;
		padding: 0.75rem 0.55rem;
		border: 1px solid var(--toc-card-border);
		border-radius: 0.85rem;
		background: var(--toc-card-bg);
		box-shadow: var(--toc-card-shadow);
		color: color-mix(in srgb, var(--theme-text) 60%, transparent);
		scrollbar-width: thin;
	}

	.toc-sidebar::before {
		content: "目录";
		display: block;
		margin: 0.1rem 0.5rem 0.55rem;
		color: var(--theme-footer, #777);
		font-size: 0.72rem;
		font-weight: 700;
		letter-spacing: 0.12em;
	}

	.toc-sidebar a:any-link {
		border-left: 0;
		border-radius: 0.45rem;
		padding: 0.35rem 0.4rem;
		transition:
			background-color 160ms ease,
			color 160ms ease,
			transform 160ms ease;
	}

	.toc-sidebar a:hover,
	.toc-sidebar a:focus-visible,
	.toc-sidebar a.is-active {
		border-left-color: transparent;
		background: var(--nav-hover-bg, rgba(128, 128, 128, 0.08));
		color: var(--theme-heading, #111);
		transform: translateX(2px);
	}
}

/* Light hierarchy rail for article subheadings. */
.toc-sidebar .toc-level-1 > a {
	color: color-mix(in srgb, var(--theme-text) 82%, transparent);
	font-weight: 650;
	font-size: 0.96rem;
}

.toc-sidebar .toc-level-2 {
	padding-left: 0;
}

.toc-sidebar .toc-level-2 > a {
	margin-left: 1.1rem !important;
	border-left: 1px solid color-mix(in srgb, var(--nav-accent) 24%, transparent);
	border-radius: 0 0.45rem 0.45rem 0;
	padding-left: 0.65rem;
	color: color-mix(in srgb, var(--theme-text) 55%, transparent);
	font-size: 0.9rem;
}

.toc-sidebar .toc-level-2 > a.is-active {
	border-left-color: var(--nav-accent);
	color: var(--theme-heading, #111);
	background: var(--nav-hover-bg, rgba(128, 128, 128, 0.08));
}

@media (prefers-reduced-motion: reduce) {
	html.page-leaving body > article:not(:has(.docs-tabs)),
	html.page-leaving body > footer,
	html.page-entering body > article:not(:has(.blog-entry)):not(:has(.docs-tabs)),
	html.page-entering body > footer,
	.blog-entry.is-entering {
		animation: none;
	}

	html.js .blog-entry:not(.is-revealed) {
		opacity: 1;
	}

	.blog-entry,
	.toc-sidebar a,
	.marginnote {
		transition: none;
	}
}
