/* Framed Posts */

/* ---------- Background of the page (only where the plugin is active) ---------- */

/* The page background (color and dots) is painted on the page itself; the site wrappers let it show through. */
html:has(body.fpp-on) {
	background-color: var(--fpp-bg, #f2efe8) !important;
	background-image: radial-gradient(circle, var(--fpp-dot-color, #333) 0, var(--fpp-dot-color, #333) calc(var(--fpp-dot-size, 2px) / 2), transparent calc(var(--fpp-dot-size, 2px) / 2 + 0.6px)) !important;
	background-size: var(--fpp-dot-gap, 16px) var(--fpp-dot-gap, 16px) !important;
	background-repeat: repeat !important;
}

body.fpp-on,
body.fpp-on .wp-site-blocks {
	background: transparent !important;
}

/* ---------- The list of posts ---------- */

body.fpp-on .wp-block-post-template {
	display: grid !important;
	grid-template-columns: repeat(var(--fpp-cols, 3), minmax(0, 1fr)) !important;
	gap: var(--fpp-gap, 28px) !important;
	align-items: start !important;
	margin-block: 0 !important;
	padding: 0 !important;
	list-style: none !important;
}

body.fpp-on .wp-block-post-template > li {
	box-sizing: border-box !important;
	display: flex;
	flex-direction: column;
	width: auto !important;
	min-width: 0 !important;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	background: none !important;
}

body.fpp-on .wp-block-post-template > li > .wp-block-group {
	display: flex !important;
	flex-direction: column !important;
	gap: 0 !important;
	width: 100%;
	margin: 0 !important;
	padding: 0 !important;
}

body.fpp-on .wp-block-post-template hr,
body.fpp-on .wp-block-post-template .wp-block-separator,
body.fpp-on .wp-block-post-template .wp-block-post-title {
	display: none !important;
}

/* Until the script has put the text in the frame, keep the list out of sight (it shows by itself after a moment if the script cannot run). */
/* With the script on, the posts are placed in columns, each one under the shortest column */
body.fpp-on .wp-block-post-template.fpp-masonry {
	display: block !important;
	position: relative !important;
}

body.fpp-on .wp-block-post-template.fpp-masonry > li {
	position: absolute !important;
	margin: 0 !important;
}

body.fpp-on:not(.fpp-ready) .wp-block-post-template {
	visibility: hidden;
	animation: fpp-show 0s linear 1.2s forwards;
}

@keyframes fpp-show {
	to { visibility: visible; }
}

/* ---------- One post: the frame, with the title in a label on its top left corner ---------- */

.fpp-card {
	box-sizing: border-box;
	order: -1;
	width: 100%;
	margin: 0 !important;
	padding: 0 !important;
}

.fpp-card .fpp-title {
	position: absolute;
	top: 0;
	left: 0;
	z-index: 3;
	box-sizing: border-box;
	width: max-content;
	max-width: 100%;
	margin: 0 !important;
	padding: 0.35em 0.8em !important;
	background: var(--fpp-label-bg, var(--fpp-line-color, #000)) !important;
	color: var(--fpp-title-color, #fff) !important;
	font-size: var(--fpp-title-size, 18px) !important;
	font-weight: 700;
	line-height: 1.2;
	overflow-wrap: anywhere;
	text-align: left;
}

.fpp-card .fpp-frame {
	box-sizing: border-box;
	width: 100%;
	margin: 0 !important;
	padding: 0 !important;
	overflow: hidden;
	background: none;
	border: var(--fpp-line, 3px) solid var(--fpp-line-color, #000) !important;
	border-radius: var(--fpp-r-tl, 0) var(--fpp-r-tr, 0) var(--fpp-r-br, 0) var(--fpp-r-bl, 0) !important;
}

/* Top box: the image */
.fpp-card .fpp-top {
	box-sizing: border-box;
	position: relative;
	width: 100%;
	margin: 0 !important;
	padding: 0 !important;
	overflow: hidden;
	border-bottom: var(--fpp-mid, 3px) solid var(--fpp-line-color, #000);
}

/* The box takes the shape of the photo (its original proportions): the same space on every side. */
.fpp-card .fpp-frame > .fpp-top > .fpp-pic {
	position: relative;
	display: block !important;
	box-sizing: border-box !important;
	width: calc(100% - 2 * var(--fpp-img-pad, 32px)) !important;
	height: auto !important;
	min-height: 0 !important;
	max-height: none !important;
	margin: var(--fpp-img-pad, 32px) !important;
	padding: 0 !important;
	overflow: hidden;
}

.fpp-card .fpp-frame > .fpp-top > .fpp-pic.fpp-flow {
	aspect-ratio: auto !important;
}

.fpp-card .fpp-pic .fpp-link {
	position: absolute !important;
	top: 0 !important;
	left: 0 !important;
	display: block !important;
	width: 100% !important;
	height: 100% !important;
	margin: 0 !important;
	padding: 0 !important;
}

.fpp-card .fpp-pic .fpp-img {
	position: absolute !important;
	top: 0 !important;
	left: 0 !important;
	display: block !important;
	width: 100% !important;
	height: 100% !important;
	min-height: 0 !important;
	max-width: none !important;
	max-height: none !important;
	margin: 0 !important;
	padding: 0 !important;
	aspect-ratio: auto !important;
	object-fit: contain !important;
	border: 0 !important;
	border-radius: 0 !important;
}

.fpp-card .fpp-pic.fpp-flow .fpp-link,
.fpp-card .fpp-pic.fpp-flow .fpp-img {
	position: static !important;
	height: auto !important;
}

.fpp-card .fpp-top .wp-block-post-featured-image__overlay {
	display: none !important;
}

/* Bottom box: date and text */
.fpp-card .fpp-bottom {
	box-sizing: border-box;
	background: var(--fpp-bottom-bg, var(--fpp-bg, #f2efe8));
	margin: 0 !important;
	padding: 14px !important;
	color: var(--fpp-text-color, #111) !important;
	font-size: var(--fpp-text-size, 16px) !important;
	line-height: 1.45;
	text-align: left;
	overflow-wrap: anywhere;
}

.fpp-card .fpp-bottom > * {
	margin: 0 !important;
	padding: 0 !important;
	color: inherit !important;
	font-size: inherit !important;
}

.fpp-card .fpp-bottom > * + * {
	margin-top: 8px !important;
}

body.fpp-on .wp-block-query-pagination,
body.fpp-on .wp-block-query-pagination a {
	color: var(--fpp-text-color, #111) !important;
}

/* ---------- Settings page preview ---------- */

.fpp-demo {
	box-sizing: border-box;
	background-image: radial-gradient(circle, var(--fpp-dot-color, #333) 0, var(--fpp-dot-color, #333) calc(var(--fpp-dot-size, 2px) / 2), transparent calc(var(--fpp-dot-size, 2px) / 2 + 0.6px));
	background-size: var(--fpp-dot-gap, 16px) var(--fpp-dot-gap, 16px);
	max-width: 270px;
	padding: 20px;
	margin: 0 0 20px;
	background-color: var(--fpp-bg, #f2efe8);
}

.fpp-demo .fpp-card {
	order: 0;
}

.fpp-demo .fpp-sample {
	display: block;
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: linear-gradient(135deg, #ffb88c, #6a7bd8);
}

.fpp-corners input {
	width: 70px;
}


/* ---------- Like heart (bottom right of the image) ---------- */

.fpp-card .fpp-pic .fpp-like {
	all: unset;
	box-sizing: border-box !important;
	position: absolute !important;
	right: 4px !important;
	bottom: 4px !important;
	z-index: 2;
	display: inline-flex !important;
	align-items: center;
	gap: 4px;
	padding: 8px !important;
	border-radius: 999px;
	color: #fff !important;
	font: 600 13px/1 system-ui, sans-serif !important;
	letter-spacing: 0;
	text-transform: none;
	text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.fpp-card .fpp-pic .fpp-like:focus-visible {
	outline: 2px solid #fff !important;
	outline-offset: 0;
}

.fpp-card .fpp-pic .fpp-heart {
	display: block;
	width: 22px !important;
	height: 22px !important;
	fill: #fff;
	filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.55));
	transition: fill 0.15s ease, transform 0.15s ease;
}

.fpp-card .fpp-pic .fpp-like:hover .fpp-heart {
	transform: scale(1.12);
}

.fpp-card .fpp-pic .fpp-like.fpp-liked {
	cursor: default;
}

.fpp-card .fpp-pic .fpp-like.fpp-liked .fpp-heart {
	fill: #e11d48;
	animation: fpp-pop 0.35s ease;
}

@keyframes fpp-pop {
	0%   { transform: scale(1); }
	40%  { transform: scale(1.35); }
	100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
	.fpp-card .fpp-pic .fpp-like.fpp-liked .fpp-heart { animation: none; }
}
