/**
 * Social Feed base styles. All theming is driven by --sf-* custom properties
 * set inline on the .social-feed wrapper, so themes can override them freely.
 */

.social-feed {
	--sf-accent: #1877f2;
	--sf-text: #1a1a1a;
	--sf-card-bg: #fff;
	--sf-page-bg: #f5f5f5;
	--sf-border: #e5e7eb;
	--sf-link: #1877f2;
	--sf-columns: 3;
	--sf-min-card: 260px;
	--sf-gap: 20px;
	--sf-radius: 12px;
	--sf-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
	--sf-aspect: 1 / 1;

	/*
	 * The wrapper carries the --sf-* values as inline styles, which beat any
	 * stylesheet rule. Responsive behaviour therefore never redefines those
	 * variables: it derives real properties from them, so the feed adapts to
	 * the space it is actually given instead of to the viewport width.
	 */
	--sf-track: min(100%, max(var(--sf-min-card), (100% - (var(--sf-columns) - 1) * var(--sf-gap)) / var(--sf-columns)));

	container-type: inline-size;
	max-width: 100%;
	color: var(--sf-text);
	box-sizing: border-box;
}

.social-feed *,
.social-feed *::before,
.social-feed *::after {
	box-sizing: border-box;
}

/* Layouts */

/*
 * Columns fit themselves to the container: --sf-columns is the upper bound
 * (each track is at least as wide as one of N equal columns), --sf-min-card
 * the lower bound at which a column drops off. No breakpoints needed.
 */
.social-feed--grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(var(--sf-track), 1fr));
	gap: var(--sf-gap);
}

.social-feed--list {
	display: flex;
	flex-direction: column;
	gap: var(--sf-gap);
}

.social-feed--masonry {
	columns: var(--sf-min-card) var(--sf-columns);
	column-gap: var(--sf-gap);
}

.social-feed--masonry .social-feed__card {
	break-inside: avoid;
	margin-bottom: var(--sf-gap);
}

.social-feed--empty {
	padding: 2rem;
	text-align: center;
	color: var(--sf-text);
	opacity: 0.7;
}

/* Card */
.social-feed__card {
	position: relative;
	min-width: 0;
	display: flex;
	flex-direction: column;
	background: var(--sf-card-bg);
	border: 1px solid var(--sf-border);
	border-radius: var(--sf-radius);
	box-shadow: var(--sf-shadow);
	overflow: hidden;
}

.social-feed--list .social-feed__card {
	flex-direction: row;
}

.social-feed--list .social-feed__media {
	flex: 0 0 40%;
	max-width: 240px;
}

/*
 * Container queries so a feed placed in a narrow column (sidebar, half-width
 * block) stacks on a wide screen too, not only on a small viewport.
 */
@container (max-width: 480px) {
	.social-feed--list .social-feed__card {
		flex-direction: column;
	}

	.social-feed--list .social-feed__media {
		flex: none;
		max-width: none;
	}
}

.social-feed__badge {
	align-self: flex-start;
	max-width: 100%;
	padding: 2px 8px;
	font-size: 12px;
	font-weight: 600;
	line-height: 1.6;
	color: #fff;
	border-radius: 999px;
}

/* Only cards with media overlay the badge on the image; otherwise it sits in
   the card body flow so it never covers the account name. */
.social-feed__badge--overlay {
	position: absolute;
	top: 8px;
	left: 8px;
	z-index: 2;
}

.social-feed__media {
	position: relative;
	display: block;
	aspect-ratio: var(--sf-aspect);
	overflow: hidden;
	background: var(--sf-page-bg);
}

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

.social-feed__play {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 2.5rem;
	color: #fff;
	text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
	pointer-events: none;
}

.social-feed__body {
	display: flex;
	min-width: 0;
	flex-direction: column;
	gap: 8px;
	padding: 12px;
}

.social-feed__author {
	display: flex;
	align-items: center;
	gap: 8px;
}

.social-feed__avatar {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	object-fit: cover;
}

.social-feed__author-name {
	font-weight: 600;
	font-size: 14px;
	min-width: 0;
	overflow-wrap: break-word;
}

.social-feed__caption {
	margin: 0;
	font-size: 14px;
	line-height: 1.5;
	overflow-wrap: break-word;
}

.social-feed__footer {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 12px;
	margin-top: auto;
	padding-top: 4px;
	font-size: 12px;
	opacity: 0.85;
}

.social-feed__metrics {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.social-feed__metric-label {
	font-weight: 600;
}

.social-feed__link {
	color: var(--sf-link);
	text-decoration: none;
	font-weight: 600;
}

.social-feed__link:hover {
	text-decoration: underline;
}

/* Viewport fallback for browsers without container query support. */
@supports not (container-type: inline-size) {
	@media (max-width: 480px) {
		.social-feed--list .social-feed__card {
			flex-direction: column;
		}

		.social-feed--list .social-feed__media {
			flex: none;
			max-width: none;
		}
	}
}

@media (max-width: 480px) {
	.social-feed__play {
		font-size: 2rem;
	}

	.social-feed__body {
		padding: 10px;
	}
}
