/* Decorative layer behind content, using the existing light/dark palette. */
body:has(> .page-background) {
	isolation: isolate;
}

.page-background {
	--background-opacity: .05;
	--background-texture: none;
	position: fixed;
	inset: 0;
	z-index: -1;
	pointer-events: none;
	overflow: hidden;
	color: var(--text);
	opacity: var(--background-opacity);
}

.page-background[data-intensity="soft"] {
	--background-opacity: .09;
}

.page-background[data-intensity="visible"] {
	--background-opacity: .14;
}

.page-background[data-background="none"] {
	display: none;
}

.page-background::before,
.page-background::after {
	content: '';
	position: absolute;
	inset: 0;
}

.page-background[data-background="gradient"]::before,
.page-background[data-background="gradient-grain"]::before {
	background: linear-gradient(155deg, currentColor, transparent 65%);
}

.page-background[data-background="glow"]::before {
	background: radial-gradient(ellipse at 12% 18%, var(--gold), transparent 58%),
		radial-gradient(ellipse at 95% 75%, currentColor, transparent 55%);
}

.page-background[data-background="grain"],
.page-background[data-background="gradient-grain"] {
	--background-texture: url('../images/background-grain.svg');
}

.page-background[data-background="paper"] {
	--background-texture: url('../images/background-paper.svg');
}

.page-background[data-background="paper"]::before {
	background: linear-gradient(120deg, var(--gold), transparent 75%);
}

.page-background::after {
	background-image: var(--background-texture);
	background-repeat: repeat;
}

.page-background[data-background="waves"]::before {
	background: repeating-radial-gradient(ellipse at -25% 50%, transparent 0 57px, currentColor 58px 59px, transparent 60px 115px);
	mask-image: linear-gradient(to right, #000, transparent 38%, transparent 62%, #000);
}

@media print {
	.page-background {
		display: none;
	}
}

/* Contained previews reuse the public background effects without changing the admin theme. */
.background-preview {
	box-sizing: border-box;
	--text: #fff;
	--gold: #c7a26a;
	position: relative;
	isolation: isolate;
	overflow: hidden;
	min-height: 260px;
	border: 1px solid #ffffff24;
	border-radius: 12px;
	padding: 24px;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	justify-content: center;
	gap: 12px;
	background: #0b0b0b;
	color: var(--text);
}

.background-preview[data-preview-theme="light"] {
	--text: #171717;
	--gold: #a77d3d;
	background: #f5f5f3;
	border-color: #00000018;
}

.page-background--preview {
	position: absolute;
}

.background-preview-label {
	font-size: .8rem;
	opacity: .55;
	margin-bottom: 24px;
}

.background-preview-title {
	font-size: clamp(1.25rem, 3vw, 1.75rem);
	font-weight: 300;
}

.background-preview-caption {
	font-size: .875rem;
	opacity: .65;
}

/* Frosted photo: blur the image, then add a soft glass reflection above it. */
.page-background-photo {
	display: none;
}

.page-background[data-background="photo-glass"] {
	opacity: 1;
}

.page-background[data-background="photo-glass"] .page-background-photo {
	display: block;
	position: absolute;
	inset: 0 0 auto;
	width: 100%;
	height: auto;
	min-height: 100%;
	max-width: none;
	object-fit: cover;
	object-position: center top;
	transform: translate3d(0, var(--background-shift, 0px), 0);
	filter: blur(var(--background-blur, 12px)) saturate(.65);
	opacity: calc(var(--background-opacity) * 2);
}

.page-background[data-background="photo-glass"]::after {
	background: linear-gradient(125deg, #ffffff22, #ffffff04 42%, #ffffff14);
	opacity: calc(var(--background-opacity) * 2);
}

@media (prefers-reduced-motion: reduce) {
	.page-background[data-background="photo-glass"] .page-background-photo {
		transform: none;
	}
}