.hfbf-feed {
	--hfbf-cols: 3;
	--hfbf-gap: 1rem;
	box-sizing: border-box;
}

.hfbf-feed *,
.hfbf-feed *::before,
.hfbf-feed *::after {
	box-sizing: inherit;
}

/* Responsive column clamp. --hfbf-cols-fx (not --hfbf-cols) is what grid/
   carousel layout math actually reads. It must be derived from --hfbf-cols
   rather than reassigning --hfbf-cols to itself: a custom property that
   references itself (even across an inline style vs. a media-query rule
   for the "same" property) is a cyclic reference, which CSS spec treats
   as invalid at computed-value time — the whole override silently drops
   and layout falls back to the UA default (single-column), which is
   exactly the bug this comment is here to prevent reintroducing. */
.hfbf-feed {
	--hfbf-cols-fx: var(--hfbf-cols);
}

@media (max-width: 1024px) {
	.hfbf-feed {
		--hfbf-cols-fx: min(var(--hfbf-cols), 2);
	}
}

@media (max-width: 640px) {
	.hfbf-feed {
		--hfbf-cols-fx: 1;
	}
}

/* Grid layout */
.hfbf-layout-grid .hfbf-track {
	display: grid;
	gap: var(--hfbf-gap);
	grid-template-columns: repeat(var(--hfbf-cols-fx), minmax(0, 1fr));
}

/* List layout: always a single column of rows, each row has its own
   image-left/text-right split that collapses to stacked on phones. */
.hfbf-layout-list .hfbf-track {
	display: grid;
	gap: var(--hfbf-gap);
	grid-template-columns: 1fr;
}

.hfbf-layout-list .hfbf-post {
	display: grid;
	grid-template-columns: 160px 1fr;
	gap: var(--hfbf-gap);
	align-items: stretch;
}

.hfbf-layout-list .hfbf-post__media {
	aspect-ratio: auto;
	height: 100%;
}

@media (max-width: 480px) {
	.hfbf-layout-list .hfbf-post {
		grid-template-columns: 1fr;
	}

	.hfbf-layout-list .hfbf-post__media {
		height: auto;
		aspect-ratio: 16 / 10;
	}
}

/* Carousel layout: native horizontal scroll + scroll-snap, so touch
   swipe/momentum comes from the browser for free. JS only adds the
   arrow buttons and dot pagination on top. */
.hfbf-layout-carousel {
	position: relative;
}

.hfbf-layout-carousel .hfbf-track {
	display: flex;
	gap: var(--hfbf-gap);
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
}

.hfbf-layout-carousel .hfbf-track::-webkit-scrollbar {
	display: none;
}

.hfbf-layout-carousel .hfbf-post {
	flex: 0 0 calc( ( 100% - ( var(--hfbf-cols-fx) - 1 ) * var(--hfbf-gap) ) / var(--hfbf-cols-fx) );
	min-width: 0;
	scroll-snap-align: start;
}

.hfbf-carousel-nav {
	display: flex;
	justify-content: center;
	gap: 0.5rem;
	margin-top: 0.75rem;
}

.hfbf-carousel-nav button {
	border: 1px solid #ccc;
	background: #fff;
	border-radius: 999px;
	width: 2.25rem;
	height: 2.25rem;
	cursor: pointer;
	font-size: 1.1rem;
	line-height: 1;
	color: #333;
}

.hfbf-carousel-nav button:hover {
	background: #f0f0f0;
}

.hfbf-carousel-dots {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 0.4rem;
	margin-top: 0.6rem;
}

.hfbf-carousel-dots button {
	width: 0.5rem;
	height: 0.5rem;
	padding: 0;
	border-radius: 999px;
	border: none;
	background: #ccc;
	cursor: pointer;
}

.hfbf-carousel-dots button.is-active {
	background: #555;
}

/* Post card */
.hfbf-post {
	border: 1px solid #e2e2e2;
	border-radius: 8px;
	overflow: hidden;
	background: #fff;
	display: flex;
	flex-direction: column;
}

.hfbf-post__media {
	display: block;
	aspect-ratio: 16 / 10;
	overflow: hidden;
	background: #f5f5f5;
}

.hfbf-post__media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.hfbf-post__body {
	padding: 0.85rem 1rem 1rem;
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.hfbf-post__text {
	margin: 0;
	font-size: 0.95rem;
	line-height: 1.5;
}

.hfbf-post__meta {
	margin-top: auto;
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-size: 0.8rem;
	gap: 0.5rem;
}

.hfbf-post__date {
	opacity: 0.65;
	white-space: nowrap;
}

.hfbf-post__link {
	white-space: nowrap;
}

.hfbf-notice {
	padding: 0.75rem 1rem;
	border: 1px dashed #ccc;
	border-radius: 6px;
	opacity: 0.8;
}

@media (prefers-color-scheme: dark) {
	.hfbf-post {
		background: #1e1e1e;
		border-color: #383838;
		color: #eaeaea;
	}

	.hfbf-carousel-nav button {
		background: #2a2a2a;
		border-color: #444;
		color: #eee;
	}

	.hfbf-carousel-nav button:hover {
		background: #333;
	}

	.hfbf-carousel-dots button {
		background: #555;
	}

	.hfbf-carousel-dots button.is-active {
		background: #ddd;
	}
}
