/* ==========================================================================
   FB Page Posts — frontend & shared styles
   ========================================================================== */

/* Placeholder shown to public visitors when the plugin isn't configured.
   Uses theme inherit colors so it adapts to light/dark sites — no hard
   styling beyond layout/spacing. */
.fbpp-placeholder {
	display: block;
	padding: 1rem 1.25rem;
	font-size: 0.95em;
	line-height: 1.4;
	letter-spacing: 0.005em;
	color: inherit;
	opacity: 0.7;
	font-family: inherit;
}
.fbpp-placeholder strong { font-weight: 600; }
.fbpp-expired { opacity: 0.85; }

/* Grouped feed mode — FB and IG split into separate <section>s. */
.fbpp-group + .fbpp-group {
	margin-top: 2.5rem;
}
.fbpp-group-title {
	margin: 0 0 1rem;
	font-size: 1.1em;
	font-weight: 600;
	letter-spacing: -0.005em;
	color: var(--fbpp-color, inherit);
	font-family: var(--fbpp-font, inherit);
}

.fbpp-list {
	list-style: none;
	margin: 0;
	padding: 0;
	/* Neutralize WP-core's `html :where([style*=border-color]) { border-style: solid; }`
	   rule which matches ANY element whose style attribute contains the
	   substring "border-color" — including our `--fbpp-border-color` custom
	   property. Without this reset, the <ul> picks up an unwanted dark
	   medium-width border drawn in currentColor. */
	border: 0;
	--fbpp-clamp: 4;
	--fbpp-gap: 1.5rem;
	--fbpp-radius: 8px;
	--fbpp-padding: 1rem;
	--fbpp-shadow: none;
	--fbpp-border-color: #e2e2e2;
	--fbpp-border-width: 1px;
	--fbpp-border-style: solid;
	--fbpp-bg: #fff;
	--fbpp-fg: inherit;
	--fbpp-muted: #666;
	--fbpp-image-radius: 0;
	--fbpp-image-border-color: transparent;
	--fbpp-image-border-width: 0;
	--fbpp-image-border-style: solid;
	--fbpp-fb: #1877f2;
	--fbpp-ig: #d62976;

	/* Typography (global) — set by build_style_vars */
	--fbpp-font: inherit;
	--fbpp-color: inherit;
	--fbpp-size: 14px;
	--fbpp-font-weight: 400;

	/* Per-field typography */
	--fbpp-date-font: inherit;
	--fbpp-date-size: 13px;
	--fbpp-date-color: inherit;
	--fbpp-date-pad: 0px;
	--fbpp-date-transform: none;
	--fbpp-date-weight: 400;
	--fbpp-message-font: inherit;
	--fbpp-message-size: 14px;
	--fbpp-message-color: inherit;
	--fbpp-message-pad: 0px;
	--fbpp-message-transform: none;
	--fbpp-message-weight: 400;
	--fbpp-link-font: inherit;
	--fbpp-link-size: 14px;
	--fbpp-link-color: inherit;
	--fbpp-link-pad: 0px;
	--fbpp-link-transform: none;
	--fbpp-link-weight: 600;

	font-family: var(--fbpp-font);
	color: var(--fbpp-color);
	font-size: var(--fbpp-size);
	font-weight: var(--fbpp-font-weight);
}

/* Card-to-card spacing now driven by --fbpp-gap (numeric, set inline). */

/* Layouts -------------------------------------------------- */
.fbpp-layout-grid {
	display: grid;
	gap: var(--fbpp-gap);
}
.fbpp-cols-1 { grid-template-columns: 1fr; }
.fbpp-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fbpp-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fbpp-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.fbpp-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.fbpp-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.fbpp-cols-7 { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.fbpp-cols-8 { grid-template-columns: repeat(8, minmax(0, 1fr)); }

@media (max-width: 1400px) {
	.fbpp-cols-7,
	.fbpp-cols-8 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (max-width: 1200px) {
	.fbpp-cols-5,
	.fbpp-cols-6,
	.fbpp-cols-7,
	.fbpp-cols-8 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
	.fbpp-cols-3,
	.fbpp-cols-4,
	.fbpp-cols-5,
	.fbpp-cols-6,
	.fbpp-cols-7,
	.fbpp-cols-8 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
	.fbpp-cols-2,
	.fbpp-cols-3,
	.fbpp-cols-4,
	.fbpp-cols-5,
	.fbpp-cols-6,
	.fbpp-cols-7,
	.fbpp-cols-8 { grid-template-columns: 1fr; }
}

.fbpp-layout-list {
	display: flex;
	flex-direction: column;
	gap: var(--fbpp-gap);
}

/* Item base ------------------------------------------------- */
.fbpp-item {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
	overflow: hidden;
	background: var(--fbpp-bg);
	color: var(--fbpp-fg);
	box-shadow: var(--fbpp-shadow);
	transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.2s ease, opacity 0.2s ease;
}

/* Whole-card clickable ------------------------------------- */
/* A stretched overlay anchor covers the card; real inner links sit above it
   so they keep working. cursor:pointer gives the "hand" affordance anywhere. */
.fbpp-clickable .fbpp-item { cursor: pointer; }
.fbpp-card-link {
	position: absolute;
	inset: 0;
	z-index: 1;
	/* purely an interaction layer — no visible chrome */
	background: transparent;
	border: 0;
	text-indent: -9999px;
	overflow: hidden;
}
.fbpp-card-link:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: -2px;
}
.fbpp-clickable .fbpp-image a,
.fbpp-clickable .fbpp-message a,
.fbpp-clickable .fbpp-link a {
	position: relative;
	z-index: 2;
}

/* Hover effects (applied via container class) */
.fbpp-hover-lift .fbpp-item:hover           { transform: translateY(-4px); }
.fbpp-hover-lift-shadow .fbpp-item:hover    { transform: translateY(-4px); box-shadow: 0 12px 28px rgba(0,0,0,0.10); }
.fbpp-hover-scale .fbpp-item:hover          { transform: scale(1.02); }
.fbpp-hover-fade .fbpp-item:hover           { opacity: 0.78; }
.fbpp-hover-border .fbpp-item                { transition: border-color 0.2s ease; }
.fbpp-hover-border .fbpp-item:hover         { border-color: currentColor; }
.fbpp-hover-image-zoom .fbpp-image img      { transition: transform 0.45s ease; }
.fbpp-hover-image-zoom .fbpp-item:hover .fbpp-image img { transform: scale(1.06); }
.fbpp-body {
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
	flex: 1;
	min-height: 0;
}

/* Image with aspect ratio ---------------------------------- */
.fbpp-image {
	position: relative;
	overflow: hidden;
	background: #f3f3f3;
	border-radius: var(--fbpp-image-radius);
	border: var(--fbpp-image-border-width) var(--fbpp-image-border-style) var(--fbpp-image-border-color);
}
.fbpp-image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	/* Defensive: prevent theme CSS from sneaking small radii in. */
	border-radius: 0;
}

.fbpp-ratio-1-1 .fbpp-image  { aspect-ratio: 1 / 1; }
.fbpp-ratio-4-3 .fbpp-image  { aspect-ratio: 4 / 3; }
.fbpp-ratio-16-9 .fbpp-image { aspect-ratio: 16 / 9; }
.fbpp-ratio-3-4 .fbpp-image  { aspect-ratio: 3 / 4; }
.fbpp-ratio-original .fbpp-image { aspect-ratio: auto; }
.fbpp-ratio-original .fbpp-image img { height: auto; }

/* Source badge (real FB / IG SVG icons) -------------------- */
.fbpp-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	color: #fff;
	background: rgba(0, 0, 0, 0.7);
	border-radius: 50%;
	line-height: 1;
	flex: 0 0 auto;
}
.fbpp-badge svg { width: 14px; height: 14px; display: block; }
.fbpp-badge-facebook  { background: var(--fbpp-fb); }
.fbpp-badge-instagram {
	background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
}

/* Position variants (only meaningful inside .fbpp-image) */
.fbpp-image .fbpp-badge {
	position: absolute;
}
.fbpp-image .fbpp-badge-pos-fbpp-badge-pos-top-left,
.fbpp-image .fbpp-badge.fbpp-badge-pos-top-left      { top: 8px; left: 8px; }
.fbpp-image .fbpp-badge.fbpp-badge-pos-top-right     { top: 8px; right: 8px; }
.fbpp-image .fbpp-badge.fbpp-badge-pos-bottom-left   { bottom: 8px; left: 8px; }
.fbpp-image .fbpp-badge.fbpp-badge-pos-bottom-right  { bottom: 8px; right: 8px; }

/* In meta line: smaller, no absolute positioning */
.fbpp-meta .fbpp-badge {
	width: 18px;
	height: 18px;
}
.fbpp-meta .fbpp-badge svg { width: 10px; height: 10px; }

/* Meta line ------------------------------------------------ */
.fbpp-meta {
	display: flex;
	gap: 0.5em;
	align-items: center;
	padding-top: var(--fbpp-date-pad);
	padding-bottom: var(--fbpp-date-pad);
}
.fbpp-list .fbpp-meta,
.fbpp-list .fbpp-meta .fbpp-date,
.fbpp-list .fbpp-date {
	font-family: var(--fbpp-date-font);
	font-size: var(--fbpp-date-size);
	color: var(--fbpp-date-color, var(--fbpp-muted));
	text-transform: var(--fbpp-date-transform);
	font-weight: var(--fbpp-date-weight);
}
.fbpp-source-text {
	text-transform: uppercase;
	letter-spacing: 0.06em;
	font-size: 0.78em;
	font-weight: 600;
}

/* Message -------------------------------------------------- */
/* Specificity boost (.fbpp-list .fbpp-message + targeting <p> inside)
   keeps theme rules like `.entry-content p { color: ... }` from winning. */
.fbpp-list .fbpp-message,
.fbpp-list .fbpp-message p,
.fbpp-list .fbpp-message a {
	font-family: var(--fbpp-message-font);
	font-size: var(--fbpp-message-size);
	color: var(--fbpp-message-color);
	text-transform: var(--fbpp-message-transform);
	font-weight: var(--fbpp-message-weight);
}
.fbpp-message {
	flex: 1;
	min-height: 0;
	overflow-wrap: anywhere;
	padding-top: var(--fbpp-message-pad);
	padding-bottom: var(--fbpp-message-pad);
}
.fbpp-message p:last-child { margin-bottom: 0; }

/* Link / CTA ----------------------------------------------- */
.fbpp-link {
	margin-top: auto;
	padding-top: var(--fbpp-link-pad);
	padding-bottom: var(--fbpp-link-pad);
}
.fbpp-list .fbpp-link a {
	font-weight: var(--fbpp-link-weight);
	text-decoration: none;
	font-family: var(--fbpp-link-font);
	font-size: var(--fbpp-link-size);
	color: var(--fbpp-link-color);
	text-transform: var(--fbpp-link-transform);
}
.fbpp-link a:hover { text-decoration: underline; }

/* Locked-height: clamp text ------------------------------- */
/* The classic -webkit-line-clamp bug: when theme CSS overrides the
   effective line-height inside <p>/<a>/<span> children, the browser's
   line-counting math drifts off from our max-height calc and the last
   visible line gets cut mid-letter. Lock line-height on every descendant
   so the math holds regardless of theme overrides. */
.fbpp-locked .fbpp-message {
	display: -webkit-box;
	-webkit-line-clamp: var(--fbpp-clamp);
	line-clamp: var(--fbpp-clamp);
	-webkit-box-orient: vertical;
	overflow: hidden;
	line-height: 1.5;
	max-height: calc(var(--fbpp-clamp, 4) * 1.5em);
}
.fbpp-locked .fbpp-message,
.fbpp-locked .fbpp-message > *,
.fbpp-locked .fbpp-message > * > * {
	line-height: 1.5 !important;
}
.fbpp-locked .fbpp-message p {
	margin: 0;
	padding: 0;
}
.fbpp-locked.fbpp-layout-grid { grid-auto-rows: 1fr; }

/* ==========================================================
   Theme: Card  (default)
   ========================================================== */
.fbpp-theme-card .fbpp-item {
	border: var(--fbpp-border-width) var(--fbpp-border-style) var(--fbpp-border-color);
	border-radius: var(--fbpp-radius);
}
.fbpp-theme-card .fbpp-image {
	/* When image has its own radius set, respect it; otherwise inherit card */
}
.fbpp-theme-card .fbpp-body { padding: var(--fbpp-padding); }

/* ==========================================================
   Theme: Magazine  — image left, text right
   ========================================================== */
.fbpp-theme-magazine .fbpp-item {
	flex-direction: row;
	border-bottom: var(--fbpp-border-width) var(--fbpp-border-style) var(--fbpp-border-color);
	padding-bottom: var(--fbpp-gap);
}
.fbpp-theme-magazine.fbpp-layout-grid { display: flex; flex-direction: column; }
.fbpp-theme-magazine .fbpp-image {
	flex: 0 0 35%;
	max-width: 35%;
}
.fbpp-theme-magazine .fbpp-body { padding: 0; }
.fbpp-theme-magazine .fbpp-message {
	font-size: 1.05em;
	line-height: 1.5;
}
@media (max-width: 600px) {
	.fbpp-theme-magazine .fbpp-item { flex-direction: column; }
	.fbpp-theme-magazine .fbpp-image { flex: 1 1 auto; max-width: 100%; }
}

/* ==========================================================
   Theme: Timeline  — single column with marker
   ========================================================== */
.fbpp-theme-timeline { position: relative; padding-left: 2rem; }
.fbpp-theme-timeline.fbpp-layout-grid,
.fbpp-theme-timeline.fbpp-layout-list { display: flex; flex-direction: column; }
.fbpp-theme-timeline::before {
	content: "";
	position: absolute;
	top: 0; bottom: 0;
	left: 0.5rem;
	width: 1px;
	background: var(--fbpp-border-color);
}
.fbpp-theme-timeline .fbpp-item {
	position: relative;
	padding-bottom: var(--fbpp-gap);
}
.fbpp-theme-timeline .fbpp-item::before {
	content: "";
	position: absolute;
	left: -1.6rem;
	top: 0.5rem;
	width: 9px; height: 9px;
	border-radius: 50%;
	background: var(--fbpp-border-color);
}
.fbpp-theme-timeline .fbpp-source-facebook::before  { background: var(--fbpp-fb); }
.fbpp-theme-timeline .fbpp-source-instagram::before { background: var(--fbpp-ig); }
.fbpp-theme-timeline .fbpp-image {
	max-width: 200px;
	border-radius: 6px;
}

/* ==========================================================
   Theme: Plain  — no chrome, just typography
   ========================================================== */
.fbpp-theme-plain .fbpp-item { gap: 0.4rem; }
/* Plain theme respects the global image radius — no hardcoded override. */

/* ==========================================================
   Status / errors
   ========================================================== */
.fbpp-error {
	padding: 0.75rem 1rem;
	background: #fde2e2;
	border: 1px solid #f5b3b3;
	border-radius: 6px;
	color: #8a1f1f;
}
.fbpp-empty {
	padding: 1rem;
	color: #666;
	font-style: italic;
}
