/**
 * Single post template.
 *
 * The photos are small, so they are shown as tilted prints at about their real
 * size and the post's colour does the rest of the work.
 */
:root {
	--db-story-accent: var(--wp--preset--color--orange);
	--db-story-colour: var(--wp--preset--color--blue);
	--db-story-text: var(--wp--preset--color--blue);
}

.db-story--pink {
	--db-story-colour: var(--wp--preset--color--pink);
	--db-story-text: var(--wp--preset--color--pink);
}

/* Orange and teal are too pale for text on white, so their text uses ink. */
.db-story--orange {
	--db-story-accent: var(--wp--preset--color--pink);
	--db-story-colour: var(--wp--preset--color--orange);
	--db-story-text: var(--wp--preset--color--contrast);
}

.db-story--teal {
	--db-story-accent: var(--wp--preset--color--pink);
	--db-story-colour: var(--wp--preset--color--teal);
	--db-story-text: var(--wp--preset--color--contrast);
}

.db-story--purple {
	--db-story-colour: var(--wp--preset--color--purple);
	--db-story-text: var(--wp--preset--color--purple);
}

/* Hero: the torn edge is the footer's, turned upside down. */
.db-post-hero {
	--db-post-edge: clamp(1.75rem, 5.05vw, 8rem);
	background: var(--db-story-colour);
	margin-bottom: calc(var(--db-post-edge) + 2rem);
	padding: 2.5rem var(--wp--style--root--padding-right, 1.5rem) 1.5rem var(--wp--style--root--padding-left, 1.5rem);
	position: relative;
}

.db-post-hero::after {
	background: var(--db-story-colour);
	content: "";
	height: var(--db-post-edge);
	left: 0;
	-webkit-mask: url("../img/torn-edge.svg") center / 100% 100% no-repeat;
	mask: url("../img/torn-edge.svg") center / 100% 100% no-repeat;
	pointer-events: none;
	position: absolute;
	right: 0;
	top: calc(100% - 1px);
	transform: scale(-1);
}

.db-post-hero__inner {
	align-items: center;
	display: grid;
	gap: 7.5rem;
	grid-template-columns: minmax(0, 1fr) auto;
	margin-inline: auto;
	max-width: var(--wp--style--global--wide-size, 1140px);
}

.db-post-hero__text {
	display: flex;
	flex-direction: column;
	gap: 1.25rem;
}

.db-post-hero .wp-block-post-title {
	color: var(--wp--preset--color--base);
	font-size: clamp(3.5rem, 2.5rem + 4vw, 6.5rem);
	line-height: 1;
	margin: 0;
	overflow-wrap: anywhere;
}

.db-post-hero__media {
	margin-bottom: -3.5rem;
	position: relative;
	width: 17rem;
	z-index: 2;
}

/* A second print tucked behind the photo. */
.db-post-hero__media::before {
	background: color-mix(in srgb, var(--wp--preset--color--base) 35%, transparent);
	content: "";
	inset: 0.25rem;
	position: absolute;
	transform: rotate(-6deg);
}

/* The hand-drawn arrow from the headings, pointing at the photo. */
.db-post-hero__media::after {
	background: var(--wp--preset--color--base);
	content: "";
	height: 7rem;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 130' fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath stroke-width='6' d='M4 8c40-8 80 34 83 110'/%3E%3Cpath stroke-width='8' d='M63 92l25 31 10-38'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 130' fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath stroke-width='6' d='M4 8c40-8 80 34 83 110'/%3E%3Cpath stroke-width='8' d='M63 92l25 31 10-38'/%3E%3C/svg%3E") center / contain no-repeat;
	pointer-events: none;
	position: absolute;
	right: calc(100% + 1rem);
	top: 18%;
	transform: rotate(-52deg);
	width: 5.5rem;
}

.db-post-hero .wp-block-post-featured-image {
	background: var(--wp--preset--color--base);
	box-shadow: 0 0.5rem 1.5rem rgb(31 22 64 / 25%);
	margin: 0;
	padding: 0.625rem;
	position: relative;
	transform: rotate(3deg);
}

.db-post-hero .wp-block-post-featured-image img {
	aspect-ratio: 3 / 4;
	display: block;
	height: auto;
	object-fit: cover;
	width: 100%;
}

/* The date is a round sticker on the corner of the print. */
.wp-block-group.is-style-sticker.db-post-hero__date {
	bottom: -1.25rem;
	left: -2.75rem;
	right: auto;
	top: auto;
}

.db-post-hero__date .wp-block-post-date {
	font-size: 1.375rem;
}

.db-post-hero__date .db-post-hero__day {
	font-size: 3rem;
	line-height: 0.85;
}

/* Article. */
.db-post-body {
	margin-inline: auto;
	max-width: 50rem;
}

.db-post-body::after {
	clear: both;
	content: "";
	display: block;
}

.db-post-body > :first-child {
	margin-top: 0;
}

.db-post-body > h2 {
	color: var(--db-story-text);
}

/* The opening paragraph sets the tone in the handwriting font. */
.db-post-body > p:first-of-type {
	color: var(--db-story-text);
	font-family: var(--wp--preset--font-family--just-another-hand);
	font-size: clamp(1.875rem, 1.75rem + 0.5vw, 2.25rem);
	letter-spacing: 0.01em;
	line-height: 1.15;
}

/* A single photo becomes a print that the words wrap around. */
.db-post-body > .wp-block-image {
	background: var(--wp--preset--color--base);
	box-shadow: 0 0.25rem 1rem rgb(31 22 64 / 25%);
	box-sizing: border-box;
	float: right;
	margin: 0.5rem 0 1.5rem 2.5rem;
	padding: 0.5rem;
	transform: rotate(2deg);
	width: min(40%, 15rem);
}

.db-post-body > .wp-block-image img {
	display: block;
	height: auto;
	width: 100%;
}

/* A gallery becomes a row of small square prints in the brand colours. */
.db-post-body > .wp-block-gallery.has-nested-images {
	clear: both;
	display: grid;
	gap: 1.5rem;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	margin-top: 3rem;
}

.db-post-body > .wp-block-gallery.has-nested-images figure.wp-block-image {
	--db-print-colour: var(--wp--preset--color--blue);
	background: var(--db-print-colour);
	box-sizing: border-box;
	display: block;
	margin: 0;
	padding: 0.625rem;
	transform: rotate(-2deg);
	width: auto !important;
}

.db-post-body > .wp-block-gallery.has-nested-images figure.wp-block-image:nth-child(5n + 2) {
	--db-print-colour: var(--wp--preset--color--pink);
	transform: rotate(1.5deg);
}

.db-post-body > .wp-block-gallery.has-nested-images figure.wp-block-image:nth-child(5n + 3) {
	--db-print-colour: var(--wp--preset--color--orange);
	transform: rotate(-1deg);
}

.db-post-body > .wp-block-gallery.has-nested-images figure.wp-block-image:nth-child(5n + 4) {
	--db-print-colour: var(--wp--preset--color--teal);
	transform: rotate(2deg);
}

.db-post-body > .wp-block-gallery.has-nested-images figure.wp-block-image:nth-child(5n + 5) {
	--db-print-colour: var(--wp--preset--color--purple);
}

.db-post-body > .wp-block-gallery.has-nested-images figure.wp-block-image img {
	aspect-ratio: 1;
	display: block;
	height: auto !important;
	object-fit: cover;
	width: 100%;
}

/* What's next. */
.db-post-next {
	margin-top: 4rem;
}

.db-post-next > .is-style-line-divider {
	background-color: var(--db-story-colour);
	margin-bottom: 3rem;
}

.db-post-visit.wp-block-column {
	border: 3px solid var(--wp--preset--color--purple);
	border-radius: 1rem;
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	gap: 1rem;
	justify-content: center;
	padding: 2rem;
}

.db-post-visit > * {
	margin: 0;
}

@media (max-width: 781px) {
	.db-post-hero {
		margin-bottom: calc(var(--db-post-edge) + 3.5rem);
		padding-top: 2rem;
	}

	.db-post-hero__inner {
		gap: 2.5rem;
		grid-template-columns: minmax(0, 1fr);
		justify-items: center;
	}

	.db-post-hero__text {
		justify-self: stretch;
	}

	.db-post-hero__media {
		width: 13.75rem;
	}

	.db-post-hero__media::after {
		display: none;
	}

	.wp-block-group.is-style-sticker.db-post-hero__date {
		height: 6rem;
		left: -2.25rem;
		width: 6rem;
	}

	.db-post-hero__date .wp-block-post-date {
		font-size: 1.125rem;
	}

	.db-post-hero__date .db-post-hero__day {
		font-size: 2.5rem;
	}

	.db-post-body > .wp-block-image {
		float: none;
		margin: 0 auto 1.5rem;
		width: 13.75rem;
	}

	.db-post-body > .wp-block-gallery.has-nested-images {
		gap: 0.75rem;
	}

	.db-post-body > .wp-block-gallery.has-nested-images figure.wp-block-image {
		padding: 0.375rem;
	}

	.db-post-visit.wp-block-column {
		padding: 1.5rem;
	}
}
