h4:not(main > *, .post *),
:is(.callout, .warning, .info, .note, .tip) > summary,
pre > code[data-file]::before,
main aside::before,
:is(.callout, .warning, .info, .note, .tip)::before {
	--offset: .5em;

	padding: .3em 1em;
	width: max-content;
	column-span: all;
	align-self: start;
	clip-path: polygon(var(--offset) 0, 100% 0, calc(100% - var(--offset)) 100%, 0 100%);
	margin: 0;
	margin-left: calc(-1 * var(--offset));
	margin-bottom: .4rem;
	background: var(--label-color, var(--color-accent));
	font: 800 .8rem/1.2 var(--font-sans);
	text-transform: uppercase;
	color: white;
}

main aside,
.callout,
.warning,
.info,
.note,
.tip {
	--_color-light: var(--color-light, var(--color-accent2-light2));

	position: relative;
	background: var(--_color-light);
	padding: 1.2rem 1rem .8rem;
	border-radius: .3rem;
	margin-top: 1.6em;
	margin-bottom: 1em;
	font-family: var(--font-sans);
	font-size: 80%;
	font-weight: 500;

	> :is(p, ul, ol, dl):where(:only-child, h4 + :last-child) {
		margin-block: 0;
	}

	&:not(:has(> h4, > summary))::before {
		content: var(--label);
	}

	& h4,
	&::before,
	&[open] > summary {
		color: var(--_color-light);
		margin-bottom: 0;
	}

	&::before {
		display: block;
	}

	& h4,
	&::before {
		margin-top: -2em;
		margin-bottom: .8em;
	}

	&[open] > summary {
		position: absolute;
		top: -1em;
		left: 2.5rem;
	}

	code:not(pre > *) {
		font-size: 100%;
		background: none;
	}

	pre[class*="language-"][class*="language-"] {
		padding: .5em .8em;
		background: color-mix(in lab, var(--color) 10%, lab(none none none / 0%));
	}
}

main aside {
	font-size: 75%;

	&:not([class]) {
		color: var(--color-gray-40);
	}

	&[id=toc] {
		/* TOC sidebar */
		z-index: 1;
		mix-blend-mode: multiply;

		& > ul {
			display: flex;
			flex-flow: column;
			gap: .8em;
			margin: 0;
			padding: 0;
			list-style: none;
		}

		& a {
			color: inherit;
		}

		.metabit {
			font-size: inherit;
			-webkit-font-smoothing: inherit;
			color: inherit;
		}

		@media (width > 960px) {
			/* Sidebar */
			position: absolute;
			--min-header-height: 12.8rem;
			top: 2.5em;
			inset-inline-end: 1em;
			width: calc(var(--content-margin-end) - 2em);
			background: none;

			&:is(header.out-of-view + main *) {
				position: fixed;
			}

			& > h4 {
				color: white;
			}
		}

		@media (width <= 960px) {
			/* At the top of content */
			margin-top: 3em;
		}
	}

	&:not([id=toc]) {
		/* Aside comments in an article */
		&:not(:has(> h4))::before {
			content: var(--label, "Aside");
			background: var(--color, var(--color-accent3));
		}

		& a:where(:not(h4 > :only-child)) {
			text-decoration: underline;

			&:not(:hover) {
				color: inherit;
			}
		}
	}
}

.callout,
.warning,
.info,
.note,
.tip {
	--code-background: hsl(0 0% 100% / .8);

	@supports (color: color-mix(in lab, white, black)) {
		--color-lighter: color-mix(in lab, var(--color), white 88%);
		--color-darker: color-mix(in lab, var(--color), black 20%);
	}

	@media (width > 600px) {
		padding-left: 4.5em;

		&::after {
			content: var(--icon);
			position: absolute;
			left: .5rem;
			top: 50%;
			transform: translateY(-50%);
			font: var(--icon-font);
			font-size: 180%;
			background: white;
			min-width: 1.65em;
			padding: .25em .45em .35em;
			border-radius: 50%;
			color: var(--color, var(--color-orange));
			text-align: center;
		}

		& > h4,
		&::before {
			left: 4.2rem;
		}
	}

	a {
		color: var(--link-color, var(--color, var(--color-accent)));
		mix-blend-mode: multiply;
		font-weight: 600;
	}
}

.warning {
	--label: "Here Be Dragons";
	--icon: var(--icon-triangle-exclamation);
	--color: var(--color-orange);
	--color-light: var(--color-accent2-light2);
	--label-color: var(--color-orange);
	--link-color: var(--color-darker);
}

.info,
.question {
	--icon: var(--icon-info);
	--color: var(--color-blue);
	--color-light: var(--color-lighter);
	--label-color: var(--color);
	--link-color: var(--color-darker);
}

.info {
	--label: "FYI";
}

.question {
	--icon: var(--icon-question);
}

.note,
.tip {
	--label: "Note";
	--icon: var(--icon-clipboard-check);
	--color: var(--color-green);
	--color-light: var(--color-lighter);
	--label-color: var(--color);
	--link-color: var(--color-darker);
}

.tip {
	--label: "Tip";
	--icon: var(--icon-lightbulb);
}
