/**
 * "Our contributors" block.
 *
 * One markup tree, two variants:
 *   .jdv-contributors--grid  a wall of people (Our Ethos) - cards at every width
 *   .jdv-contributors--list  credits for one post - cards on mobile, rows on desktop
 *
 * The card is the base style and the row is the override, so the card CSS is
 * written once. No font-family is set anywhere; the block inherits the site's.
 */

.jdv-contributors {
	--jdv-contrib-cols: 2;
	--jdv-contrib-avatar: 48px;
	--jdv-contrib-text: #4c423c;
	--jdv-contrib-muted: #6d6259;
	--jdv-contrib-popup-bg: #eaf9d9;
	--jdv-contrib-radius: 8px;

	width: 100%;
	color: var(--jdv-contrib-text);
}

.jdv-contributors__title {
	margin: 0 0 20px;
	font-size: clamp(20px, 2.2vw, 26px);
	font-weight: 400;
	color: var(--jdv-contrib-text);
}

.jdv-contributors__list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(var(--jdv-contrib-cols), minmax(0, 1fr));
	gap: 24px 16px;
}

.jdv-contributors__item {
	margin: 0;
	padding: 0;
}

/* ---------- the card: photo on top, name + plus on the row below ---------- */

.jdv-contributor {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 10px 10px;
	align-items: center;
	width: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	text-align: left;
	cursor: pointer;
}

.jdv-contributor:focus-visible {
	outline: 2px solid var(--jdv-contrib-text);
	outline-offset: 4px;
}

.jdv-contributor__avatar {
	display: block;
	overflow: hidden;
	border-radius: 6px;
	background: #e7e1d2;
}

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

.jdv-contributor__avatar--sm {
	grid-column: 1 / -1;
	width: 100%;
	height: auto;
	aspect-ratio: 1 / 1;
	border-radius: var(--jdv-contrib-radius);
}

.jdv-contributor__avatar--letter {
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--jdv-avatar-bg, #c7bca6);
	color: #fff;
	font-weight: 600;
	letter-spacing: .02em;
}

.jdv-contributor__avatar--sm.jdv-contributor__avatar--letter {
	font-size: 32px;
}

.jdv-contributor__name {
	grid-column: 1;
	font-size: 16px;
	line-height: 1.3;
}

/* bare glyph, no frame: the plus reads as part of the name row, not a button */
.jdv-contributor__plus {
	grid-column: 2;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 16px;
	height: 16px;
	color: var(--jdv-contrib-text);
	opacity: .7;
	transition: opacity .18s ease;
}

.jdv-contributor:hover .jdv-contributor__plus {
	opacity: 1;
}

/* ---------- list variant on desktop: single column, avatar beside name ---------- */

@media (min-width: 768px) {
	.jdv-contributors--list .jdv-contributors__list {
		grid-template-columns: minmax(0, 1fr);
		gap: 16px;
	}

	.jdv-contributors--list .jdv-contributor {
		display: flex;
		align-items: center;
		gap: 14px;
		padding: 4px;
		border-radius: var(--jdv-contrib-radius);
		transition: background-color .18s ease;
	}

	.jdv-contributors--list .jdv-contributor:hover {
		background: rgba(76, 66, 60, .06);
	}

	.jdv-contributors--list .jdv-contributor__avatar--sm {
		flex: 0 0 auto;
		width: var(--jdv-contrib-avatar);
		height: var(--jdv-contrib-avatar);
		aspect-ratio: auto;
		border-radius: 6px;
	}

	.jdv-contributors--list .jdv-contributor__avatar--sm.jdv-contributor__avatar--letter {
		font-size: calc(var(--jdv-contrib-avatar) * .34);
	}
}

/* ---------- "See more" ---------- */

.jdv-contributors--collapsed .jdv-contributors__item--extra {
	display: none;
}

.jdv-contributors__more {
	display: block;
	margin: 32px auto 0;
	padding: 12px 32px;
	border: 1px solid rgba(76, 66, 60, .3);
	border-radius: 999px;
	background: transparent;
	color: var(--jdv-contrib-text);
	font: inherit;
	font-size: 15px;
	cursor: pointer;
	transition: background-color .18s ease;
}

.jdv-contributors__more:hover {
	background: rgba(76, 66, 60, .07);
}

/* ---------- the popup ---------- */

.jdv-contributor-dialog {
	width: min(720px, calc(100vw - 32px));
	max-width: none;
	max-height: calc(100vh - 48px);
	padding: 0;
	border: 0;
	border-radius: 4px;
	background: transparent;
	color: var(--jdv-contrib-text, #4c423c);
	overflow: visible;
}

.jdv-contributor-dialog::backdrop {
	background: rgba(51, 46, 41, .78);
}

.jdv-contributor-dialog__panel {
	position: relative;
	padding: 40px;
	border-radius: 4px;
	background: var(--jdv-contrib-popup-bg, #eaf9d9);
	max-height: calc(100vh - 48px);
	overflow-y: auto;
}

.jdv-contributor-dialog__close {
	position: absolute;
	top: 16px;
	right: 16px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	color: inherit;
	cursor: pointer;
}

.jdv-contributor-dialog__close:hover,
.jdv-contributor-dialog__close:focus-visible {
	background: rgba(76, 66, 60, .1);
}

.jdv-contributor-dialog__body {
	display: flex;
	align-items: flex-start;
	gap: 28px;
}

.jdv-contributor__avatar--lg {
	flex: 0 0 auto;
	width: 130px;
	height: 130px;
	border-radius: 6px;
}

.jdv-contributor__avatar--lg.jdv-contributor__avatar--letter {
	font-size: 44px;
}

.jdv-contributor-dialog__text {
	flex: 1 1 auto;
	min-width: 0;
}

.jdv-contributor-dialog__name {
	margin: 0 0 8px;
	font-size: clamp(22px, 2.4vw, 28px);
	font-weight: 400;
	line-height: 1.2;
}

.jdv-contributor-dialog__role {
	margin: 0 0 16px;
	font-size: 14px;
	color: var(--jdv-contrib-muted, #6d6259);
}

.jdv-contributor-dialog__bio p {
	margin: 0 0 12px;
	font-size: 15px;
	line-height: 1.6;
}

.jdv-contributor-dialog__bio p:last-child {
	margin-bottom: 0;
}

.jdv-contributor-dialog__social {
	margin: 20px 0 0;
	font-size: 14px;
}

.jdv-contributor-dialog__social a {
	color: inherit;
	text-decoration: underline;
}

@media (max-width: 767px) {
	.jdv-contributor-dialog__panel {
		padding: 48px 20px 28px;
	}

	/* photo and name side by side at the top, everything else stacked under */
	.jdv-contributor-dialog__body {
		display: grid;
		grid-template-columns: 72px minmax(0, 1fr);
		gap: 12px 14px;
		align-items: center;
	}

	.jdv-contributor__avatar--lg {
		width: 72px;
		height: 72px;
	}

	.jdv-contributor__avatar--lg.jdv-contributor__avatar--letter {
		font-size: 26px;
	}

	.jdv-contributor-dialog__text {
		display: contents;
	}

	.jdv-contributor-dialog__name {
		grid-column: 2;
		margin: 0;
	}

	.jdv-contributor-dialog__role,
	.jdv-contributor-dialog__bio,
	.jdv-contributor-dialog__social {
		grid-column: 1 / -1;
	}

	.jdv-contributor-dialog__role {
		margin: 4px 0 0;
	}

	.jdv-contributor-dialog__social {
		margin-top: 12px;
	}
}

/* editor-only placeholder so the widget is selectable when empty */
.jdv-contributors--empty p {
	margin: 0;
	padding: 20px;
	border: 1px dashed rgba(76, 66, 60, .35);
	border-radius: var(--jdv-contrib-radius);
	color: var(--jdv-contrib-muted);
	font-size: 14px;
	text-align: center;
}

/* themes normally ship this; scoped copy so the labels never leak visually */
.jdv-contributors .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}
