/* Widget styles for the facebook-posts plugin.
   Every colour and size is a custom property, so a page can restyle the whole thing
   by setting them on the container. */

[data-facebook-posts]{
	/* data-columns lands on --fbp-cols, never on --fbp-columns directly: an inline value
	   would outrank the breakpoints below and leave phones with a desktop column count. */
	--fbp-columns:var(--fbp-cols,3);
	--fbp-gap:24px;
	--fbp-radius:12px;
	--fbp-bg:#fff;
	--fbp-text:#1c1e21;
	--fbp-muted:#65676b;
	--fbp-border:#e4e6eb;
	--fbp-bubble:#f0f2f5;
	--fbp-accent:#1877f2;
	--fbp-overlay:rgba(0,0,0,.8);
	display:block;
}

/* Slider */
.fbp-slider{
	position:relative;
	display:flex;
	align-items:center;
	gap:8px;
}
.fbp-track{
	display:flex;
	gap:var(--fbp-gap);
	flex:1;
	min-width:0;
	overflow-x:auto;
	scroll-snap-type:x mandatory;
	scrollbar-width:none;
	padding:4px;
	margin:-4px;
}
.fbp-track::-webkit-scrollbar{display:none;}
.fbp-track>.fbp-card{
	flex:0 0 calc((100% - (var(--fbp-columns) - 1) * var(--fbp-gap)) / var(--fbp-columns));
	scroll-snap-align:start;
}
.fbp-arrow{
	flex:0 0 auto;
	width:40px;
	height:40px;
	font-size:26px;
	line-height:1;
	color:var(--fbp-text);
	background:var(--fbp-bg);
	border:1px solid var(--fbp-border);
	border-radius:999px;
	cursor:pointer;
	transition:opacity .2s ease;
}
.fbp-arrow:disabled{opacity:.3;cursor:default;}
.fbp-slider.fbp-static .fbp-arrow{display:none;}

/* Grid */
.fbp-grid{
	display:grid;
	grid-template-columns:repeat(var(--fbp-columns),minmax(0,1fr));
	gap:var(--fbp-gap);
}

@media (max-width:1024px){
	[data-facebook-posts]{--fbp-columns:min(var(--fbp-cols,2),2);}
}
@media (max-width:640px){
	[data-facebook-posts]{--fbp-columns:1;}
	/* Touch users swipe the track - the arrows would eat a quarter of the screen */
	.fbp-arrow{display:none;}
}

/* Card */
.fbp-card{
	display:flex;
	flex-direction:column;
	padding:0;
	margin:0;
	text-align:left;
	font:inherit;
	color:var(--fbp-text);
	background:var(--fbp-bg);
	border:1px solid var(--fbp-border);
	border-radius:var(--fbp-radius);
	overflow:hidden;
	cursor:pointer;
	transition:transform .2s ease, box-shadow .2s ease;
}
.fbp-card:hover,
.fbp-card:focus-visible{
	transform:translateY(-2px);
	box-shadow:0 8px 24px rgba(0,0,0,.12);
	outline:none;
}
.fbp-card:focus-visible{outline:2px solid var(--fbp-accent);outline-offset:2px;}

.fbp-thumb{
	position:relative;
	aspect-ratio:4/3;
	background:var(--fbp-border);
	overflow:hidden;
}
.fbp-thumb img{
	width:100%;
	height:100%;
	object-fit:cover;
	display:block;
}
.fbp-play{
	position:absolute;
	inset:0;
	display:flex;
	align-items:center;
	justify-content:center;
	font-size:44px;
	color:#fff;
	text-shadow:0 2px 12px rgba(0,0,0,.5);
	pointer-events:none;
}
.fbp-badge{
	position:absolute;
	right:10px;
	bottom:10px;
	padding:2px 10px;
	font-size:.8125rem;
	color:#fff;
	background:rgba(0,0,0,.6);
	border-radius:999px;
}

.fbp-card-body{
	display:flex;
	flex-direction:column;
	gap:8px;
	padding:16px;
	flex:1;
}
.fbp-date{
	font-size:.8125rem;
	color:var(--fbp-muted);
}
.fbp-excerpt{
	margin:0;
	line-height:1.5;
	display:-webkit-box;
	-webkit-line-clamp:4;
	-webkit-box-orient:vertical;
	overflow:hidden;
}
.fbp-counters{
	display:flex;
	flex-wrap:wrap;
	gap:12px;
	font-size:.8125rem;
	color:var(--fbp-muted);
	margin-top:auto;
}
.fbp-empty{color:var(--fbp-muted);}

/* Modal - the Facebook post view: media on the left, the post itself on the right */
.fbp-overlay{
	position:fixed;
	inset:0;
	z-index:9999;
	display:flex;
	align-items:center;
	justify-content:center;
	padding:24px;
	background:var(--fbp-overlay,rgba(0,0,0,.8));
	opacity:0;
	transition:opacity .2s ease;
}
.fbp-overlay.fbp-open{opacity:1;}
body.fbp-locked{overflow:hidden;}

/* --fbp-stage-w / --fbp-stage-h are written by the script from the natural size of the
   picture or video on show, so the dialog takes the shape of its content. The values
   below are only the shape used before the first measurement lands. */
.fbp-dialog{
	position:relative;
	display:grid;
	grid-template-columns:var(--fbp-stage-w,720px) minmax(0,1fr);
	width:calc(var(--fbp-stage-w,720px) + 380px);
	max-width:100%;
	height:var(--fbp-stage-h,720px);
	max-height:88vh;
	background:var(--fbp-bg,#fff);
	color:var(--fbp-text,#1c1e21);
	border-radius:var(--fbp-radius,12px);
	overflow:hidden;
	transform:translateY(12px) scale(.98);
	transition:transform .2s ease, width .25s ease, height .25s ease;
}
.fbp-overlay.fbp-open .fbp-dialog{transform:none;}

/* A post without any media is just the right hand column */
.fbp-dialog[data-media="false"]{
	grid-template-columns:minmax(0,1fr);
	width:min(600px,100%);
	height:auto;
	max-height:88vh;
}

.fbp-close{
	position:absolute;
	top:12px;
	right:12px;
	z-index:3;
	width:36px;
	height:36px;
	display:flex;
	align-items:center;
	justify-content:center;
	font-size:24px;
	line-height:1;
	color:var(--fbp-text);
	background:var(--fbp-bubble,#f0f2f5);
	border:none;
	border-radius:999px;
	cursor:pointer;
}
.fbp-close:hover{filter:brightness(.94);}
.fbp-dialog[data-media="true"] .fbp-close{
	color:#fff;
	background:rgba(0,0,0,.55);
}

.fbp-stage{
	position:relative;
	display:flex;
	align-items:center;
	justify-content:center;
	background:#000;
	overflow:hidden;
	min-height:240px;
}
/* The pane already has the picture's shape, so contain fills it edge to edge and only
   acts as a safety net when a measurement is missing. */
.fbp-image{
	width:100%;
	height:100%;
	object-fit:contain;
}
.fbp-video{
	width:100%;
	height:100%;
	border:0;
	display:block;
}
.fbp-nav{
	position:absolute;
	top:50%;
	transform:translateY(-50%);
	width:40px;
	height:40px;
	font-size:28px;
	line-height:1;
	color:#fff;
	background:rgba(0,0,0,.45);
	border:none;
	border-radius:999px;
	cursor:pointer;
}
.fbp-nav:hover{background:rgba(0,0,0,.7);}
.fbp-prev{left:12px;}
.fbp-next{right:12px;}
.fbp-count{
	position:absolute;
	bottom:12px;
	right:12px;
	padding:2px 10px;
	font-size:.75rem;
	color:#fff;
	background:rgba(0,0,0,.55);
	border-radius:999px;
}

.fbp-side{
	display:flex;
	flex-direction:column;
	min-width:0;
	min-height:0;
	background:var(--fbp-bg,#fff);
}
.fbp-author{
	display:flex;
	align-items:center;
	gap:10px;
	padding:16px 56px 12px 16px;
}
.fbp-avatar{
	width:40px;
	height:40px;
	border-radius:999px;
	object-fit:cover;
	flex:0 0 auto;
}
.fbp-author-meta{display:flex;flex-direction:column;min-width:0;}
.fbp-author-name{font-size:.9375rem;}

.fbp-scroll{
	flex:1;
	min-height:0;
	overflow-y:auto;
	padding:0 16px;
	display:flex;
	flex-direction:column;
	gap:12px;
}
.fbp-text{
	margin:0;
	line-height:1.6;
	white-space:pre-line;
}
.fbp-scroll .fbp-counters{
	margin:0;
	padding-bottom:12px;
	border-bottom:1px solid var(--fbp-border,#e4e6eb);
}

.fbp-comments{
	display:flex;
	flex-direction:column;
	gap:12px;
	padding-bottom:12px;
}
.fbp-bubble{
	background:var(--fbp-bubble,#f0f2f5);
	border-radius:18px;
	padding:8px 12px;
}
.fbp-comment-author{font-size:.8125rem;}
.fbp-comment-text{margin:2px 0 0;line-height:1.45;white-space:pre-line;}
.fbp-comment-meta{
	display:flex;
	gap:12px;
	padding:4px 12px 0;
	font-size:.75rem;
	color:var(--fbp-muted,#65676b);
}
.fbp-comments-more{margin:0;font-size:.8125rem;color:var(--fbp-muted,#65676b);}

.fbp-foot{
	padding:12px 16px 16px;
	border-top:1px solid var(--fbp-border,#e4e6eb);
}
.fbp-link{
	display:inline-block;
	padding:10px 18px;
	font-weight:600;
	color:#fff;
	background:var(--fbp-accent,#1877f2);
	border-radius:999px;
	text-decoration:none;
}
.fbp-link:hover{filter:brightness(.94);}

@media (max-width:820px){
	.fbp-overlay{padding:0;}
	.fbp-dialog{
		/* Stacked: the media keeps its own height, the text takes the rest */
		grid-template-columns:minmax(0,1fr);
		grid-template-rows:var(--fbp-stage-h,45vh) minmax(0,1fr);
		width:100%;
		height:100%;
		max-height:100%;
		border-radius:0;
	}
	.fbp-dialog[data-media="false"]{
		grid-template-rows:minmax(0,1fr);
		height:100%;
		max-height:100%;
	}
	.fbp-author{padding-right:56px;}
}

@media (prefers-reduced-motion:reduce){
	.fbp-card,.fbp-overlay,.fbp-dialog,.fbp-arrow{transition:none;}
	.fbp-track{scroll-behavior:auto;}
}
