/**
 * ML Related People widget styles.
 *
 * Grid column count is driven by --ml-rp-columns. The Elementor Columns control
 * sets it per device (inline, higher specificity); the media queries at the
 * bottom are the fallback for shortcode usage and cached/AMP output.
 *
 * @package Magiclamp
 */

.ml-related-people-wrap {
	box-sizing: border-box;
}

.ml-related-people__heading {
	margin: 0 0 20px;
	color: #0a2540;
}

.ml-related-people {
	--ml-rp-columns: 6;
	--ml-rp-gap: 24px;
	--ml-rp-image-height: 280px; /* Overridden per device by the Height control. */
	display: grid;
	/*
	 * minmax(0, 1fr) — not 1fr — so long names can't blow out the track width.
	 * The `, 6` fallback matters: if --ml-rp-columns ever resolves to nothing,
	 * repeat() is invalid at computed-value time, grid-template-columns falls
	 * back to `none`, and every card stacks in a single column.
	 */
	grid-template-columns: repeat(var(--ml-rp-columns, 6), minmax(0, 1fr));
	gap: var(--ml-rp-gap);
	box-sizing: border-box;
}

.ml-related-people * {
	box-sizing: border-box;
}

/* -------------------------------------------------------------------------
 * Card
 *
 * The whole card is a single <a> to the Person, so every child is a span and
 * needs an explicit display. Keeping one link per card (rather than separate
 * image/name/button links) also means one tab stop and one announcement.
 * ------------------------------------------------------------------------- */
a.ml-related-person,
.ml-related-person {
	display: flex;
	flex-direction: column;
	min-width: 0; /* Allows the card to shrink inside its grid track. */
	background-color: #ffffff;
	overflow: hidden;
	color: inherit;
	text-decoration: none;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

a.ml-related-person:hover {
	transform: translateY(-4px);
}

/* Keyboard users get the same affordance as mouse users. */
a.ml-related-person:focus-visible {
	outline: 2px solid #0a2540;
	outline-offset: 2px;
}

/* -------------------------------------------------------------------------
 * Featured image
 * ------------------------------------------------------------------------- */
.ml-related-person__media {
	display: block;
	width: 100%;
	height: var(--ml-rp-image-height);
	overflow: hidden;
	background-color: #d9dee3;
	line-height: 0;
}

.ml-related-person__image {
	display: block;
	width: 100%;
	height: var(--ml-rp-image-height) !important;
	object-fit: cover;
	object-position: top center;
	transition: transform 0.3s ease;
}

a.ml-related-person:hover .ml-related-person__image {
	transform: scale(1.04);
}

/* -------------------------------------------------------------------------
 * Body
 * ------------------------------------------------------------------------- */
.ml-related-person__body {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	padding: 16px 0px;
	text-align: left;
}

.ml-related-person__name {
	display: block;
	margin: 0 0 8px;
	font-size: 17px;
	font-weight: 700;
	line-height: 1.3;
	color: #0a2540;
	overflow-wrap: break-word;
	word-wrap: break-word;
}

a.ml-related-person:hover .ml-related-person__name {
	text-decoration: underline;
	text-underline-offset: 2px;
}

.ml-related-person__excerpt {
	display: block;
	margin: 0;
	font-size: 14px;
	line-height: 1.5;
	color: #4a5b6b;
	overflow-wrap: break-word;
	word-wrap: break-word;
}

/* -------------------------------------------------------------------------
 * Editor-only notice (never rendered on the front end).
 * ------------------------------------------------------------------------- */
.ml-related-people__notice {
	padding: 16px;
	border: 1px dashed #b4bfca;
	border-radius: 4px;
	color: #4a5b6b;
	font-size: 13px;
	line-height: 1.5;
	text-align: center;
}

/* -------------------------------------------------------------------------
 * Responsive fallbacks.
 * ------------------------------------------------------------------------- */

/* Laptops / small desktops. */
@media (max-width: 1200px) {
	.ml-related-people {
		--ml-rp-columns: 4;
	}
}

/* iPad landscape. */
@media (max-width: 1024px) {
	.ml-related-people {
		--ml-rp-columns: 3;
	}
}

/* iPad portrait / large phones. */
@media (max-width: 768px) {
	.ml-related-people {
		--ml-rp-columns: 2;
	}
}

/* Phones. */
@media (max-width: 600px) {
	.ml-related-people {
		--ml-rp-columns: 1;
	}
}
