/**
 * Triblyn Tribe Tiles
 * Post-style cards for the BuddyPress groups (Tribes) directory.
 *
 * Scoped to #groups-list so nothing else on the site is affected.
 */

#groups-list {
	--triblyn-card-bg: #ffffff;
	--triblyn-card-border: rgba(17, 24, 39, 0.08);
	--triblyn-card-shadow: 0 1px 2px rgba(17, 24, 39, 0.04), 0 8px 24px rgba(17, 24, 39, 0.06);
	--triblyn-card-shadow-hover: 0 2px 4px rgba(17, 24, 39, 0.06), 0 16px 40px rgba(17, 24, 39, 0.10);
	--triblyn-ink: #111827;
	--triblyn-muted: #6b7280;
	--triblyn-rule: rgba(17, 24, 39, 0.07);
	--triblyn-radius: 14px;
}

/* ---- Card shell -------------------------------------------------------- */

#groups-list .item-entry {
	display: flex;
	min-width: 0;
}

#groups-list .item-entry > .list-wrap {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	min-width: 0;
	overflow: hidden;
	padding: 0;
	text-align: left;
	background: var(--triblyn-card-bg);
	border: 1px solid var(--triblyn-card-border);
	border-radius: var(--triblyn-radius);
	box-shadow: var(--triblyn-card-shadow);
	transition: box-shadow 160ms ease, transform 160ms ease;
	container-type: inline-size;
}

#groups-list .item-entry > .list-wrap:hover,
#groups-list .item-entry > .list-wrap:focus-within {
	box-shadow: var(--triblyn-card-shadow-hover);
	transform: translateY(-2px);
}

@media (prefers-reduced-motion: reduce) {
	#groups-list .item-entry > .list-wrap {
		transition: none;
	}
	#groups-list .item-entry > .list-wrap:hover,
	#groups-list .item-entry > .list-wrap:focus-within {
		transform: none;
	}
}

/* ---- Media ------------------------------------------------------------- */

#groups-list .item-avatar {
	width: 100%;
	max-width: none;
	margin: 0;
	padding: 0;
	float: none;
	text-align: left;
}

#groups-list .item-avatar > a {
	display: block;
	line-height: 0;
	border: 0;
	text-decoration: none;
}

#groups-list .triblyn-tile-media {
	position: relative;
	display: block;
	width: 100%;
	margin: 0;
	padding: 0;
	overflow: hidden;
	aspect-ratio: 16 / 9;
	background: linear-gradient(135deg, #e8edf3 0%, #dde4ec 100%);
}

/* Fallback for browsers without aspect-ratio support. */
@supports not (aspect-ratio: 16 / 9) {
	#groups-list .triblyn-tile-media {
		height: 0;
		padding-bottom: 56.25%;
	}
}

#groups-list .triblyn-tile-img {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	object-fit: cover;
	border: 0;
	border-radius: 0;
	transition: transform 320ms ease;
}

#groups-list .item-entry > .list-wrap:hover .triblyn-tile-img {
	transform: scale(1.03);
}

@media (prefers-reduced-motion: reduce) {
	#groups-list .triblyn-tile-img,
	#groups-list .item-entry > .list-wrap:hover .triblyn-tile-img {
		transition: none;
		transform: none;
	}
}

/* Play badge for video posts. */
#groups-list .triblyn-tile-play {
	position: absolute;
	top: 50%;
	left: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 52px;
	height: 52px;
	transform: translate(-50%, -50%);
	background: rgba(17, 24, 39, 0.62);
	border: 2px solid rgba(255, 255, 255, 0.9);
	border-radius: 50%;
	backdrop-filter: blur(2px);
	pointer-events: none;
}

#groups-list .triblyn-tile-play svg {
	width: 24px;
	height: 24px;
	margin-left: 2px;
	fill: #ffffff;
}

/* Source-type pill. */
#groups-list .triblyn-tile-badge {
	position: absolute;
	top: 10px;
	right: 10px;
	padding: 3px 9px;
	font-size: 10px;
	font-weight: 600;
	letter-spacing: 0.06em;
	line-height: 1.5;
	text-transform: uppercase;
	color: #ffffff;
	background: rgba(17, 24, 39, 0.66);
	border-radius: 999px;
	pointer-events: none;
}

/* Generated tile when a tribe has no featured post, cover or avatar. */
#groups-list .triblyn-tile-media--initial {
	background: linear-gradient(
		140deg,
		hsl(var(--triblyn-hue, 210) 62% 62%) 0%,
		hsl(calc(var(--triblyn-hue, 210) + 28) 58% 46%) 100%
	);
}

#groups-list .triblyn-tile-initial {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 2.75rem;
	font-weight: 700;
	line-height: 1;
	color: rgba(255, 255, 255, 0.94);
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

/* An uploaded square avatar shouldn't be stretched across a 16:9 frame. */
#groups-list .triblyn-tile-media--avatar .triblyn-tile-img {
	object-fit: contain;
	padding: 18px;
	background: linear-gradient(135deg, #eef2f7 0%, #e3e9f1 100%);
}

/* ---- Card body --------------------------------------------------------- */

#groups-list .item-entry > .list-wrap > .item {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	min-width: 0;
	padding: 15px 17px 13px;
	text-align: left;
}

#groups-list .item-block {
	margin: 0;
	padding: 0;
}

#groups-list .list-title.groups-title {
	margin: 0 0 5px;
	padding: 0;
	font-size: 1.0625rem;
	font-weight: 700;
	line-height: 1.3;
	letter-spacing: -0.01em;
	text-align: left;
}

#groups-list .list-title.groups-title a {
	color: var(--triblyn-ink);
	text-decoration: none;
}

#groups-list .list-title.groups-title a:hover,
#groups-list .list-title.groups-title a:focus {
	text-decoration: underline;
	text-underline-offset: 2px;
}

#groups-list .item-meta {
	margin: 0;
	font-size: 0.75rem;
	line-height: 1.5;
	color: var(--triblyn-muted);
	text-align: left;
}

#groups-list .item-meta.group-details {
	font-weight: 600;
}

#groups-list .last-activity.item-meta {
	margin-bottom: 9px;
}

#groups-list .group-desc {
	margin: 0;
	text-align: left;
}

#groups-list .group-desc p {
	display: -webkit-box;
	margin: 0;
	overflow: hidden;
	font-size: 0.8125rem;
	font-style: normal;
	line-height: 1.55;
	color: #374151;
	text-align: left;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	line-clamp: 3;
}

/* No membership button on directory tiles. */
#groups-list .groups-meta.action,
#groups-list .group-button,
#groups-list .generic-button {
	display: none !important;
}

/* ---- Featured-post attribution ---------------------------------------- */

#groups-list .triblyn-tile-source {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: auto;
	padding-top: 11px;
	border-top: 1px solid var(--triblyn-rule);
}

#groups-list .triblyn-tile-source:not(:first-child) {
	margin-top: 12px;
}

#groups-list .triblyn-tile-source-media {
	flex: 0 0 auto;
	line-height: 0;
}

#groups-list .triblyn-tile-source-avatar {
	width: 22px;
	height: 22px;
	margin: 0;
	border: 0;
	border-radius: 50%;
	object-fit: cover;
}

/*
 * Laid out so the author name absorbs the truncation and the timestamp
 * always survives, rather than the whole line ellipsing from the right.
 */
#groups-list .triblyn-tile-source-text {
	display: flex;
	align-items: baseline;
	gap: 4px;
	min-width: 0;
	font-size: 0.75rem;
	line-height: 1.45;
	color: var(--triblyn-muted);
}

#groups-list .triblyn-tile-source-name {
	flex: 0 1 auto;
	min-width: 0;
	overflow: hidden;
	font-weight: 600;
	color: #374151;
	white-space: nowrap;
	text-overflow: ellipsis;
}

#groups-list .triblyn-tile-source-time {
	flex: 0 0 auto;
	white-space: nowrap;
}

#groups-list .triblyn-tile-source-time::before {
	content: "· ";
	color: #9ca3af;
}

/* The featured post's own text only fits on roomier cards. */
#groups-list .triblyn-tile-source-excerpt {
	display: none;
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

@container (min-width: 330px) {
	#groups-list .triblyn-tile-source-excerpt {
		display: block;
	}
}

/* Chrome scaled down for the narrow 4-up grid. */
@container (max-width: 260px) {
	#groups-list .triblyn-tile-play {
		width: 38px;
		height: 38px;
	}

	#groups-list .triblyn-tile-play svg {
		width: 18px;
		height: 18px;
	}

	#groups-list .triblyn-tile-badge {
		top: 8px;
		right: 8px;
		padding: 2px 7px;
		font-size: 9px;
	}
}

/* ---- Narrow screens ---------------------------------------------------- */

@media (max-width: 480px) {
	#groups-list .item-entry > .list-wrap > .item {
		padding: 13px 14px 12px;
	}

	#groups-list .triblyn-tile-play {
		width: 44px;
		height: 44px;
	}

	#groups-list .triblyn-tile-initial {
		font-size: 2.25rem;
	}
}
