/**
 * CH Team Bio Modal
 *
 * Two parts: the four-line teaser on the Meet the Team cards, and the
 * dialog that the "Read More" button opens. See main.php for the markup
 * contract and the specificity note behind the .chtm-modal scoping.
 */

/* ----------------------------------------------------------------- card -- */

/* Cards are grid items in a container set to align-items: start, so they
   are only as tall as their own text and every Read More landed on a
   different line. Stretching them to the tallest card in the row and
   pushing the trigger down with an auto margin lines the row up again. */
.chtm-card {
	align-self: stretch;
	height: 100%;
}

/* The role is the card's first paragraph. Reserving two lines of it keeps
   the bios — and the photos' captions below them — on one baseline even
   when a single title wraps ("Listing Broker | Director of Sales & Buyer
   Experience" is two lines where the others are one). */
.chtm-card > p:first-of-type {
	min-height: 3em;
}

/* The card shows the tagline plus the first lines of the bio; the rest is
   in the dialog. The :has() rule lands with the stylesheet, so the full
   bios never flash before the script runs; .chtm-card-bio is the fallback
   the script adds for browsers without :has(). */
.e-con:has(> .e-button-base) > p:last-of-type,
.chtm-card > .chtm-card-bio {
	display: -webkit-box;
	-webkit-line-clamp: 4;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* margin-top: auto parks the trigger on the bottom edge of the stretched
   card; inline-flex is what lets the arrow sit beside the label (the
   button is display: block by default, where a pseudo-element would drop
   onto its own line under the text). The gold underline is the button's
   own border-bottom, set in Elementor. */
.chtm-card > .chtm-trigger {
	align-self: flex-start;
	margin-top: auto;
	padding-top: 18px;
	display: inline-flex;
	align-items: center;
	gap: 10px;
}

.chtm-card > .chtm-trigger::after {
	content: "\2192";
	font-size: 1.15em;
	line-height: 1;
	transition: transform 260ms ease;
}

.chtm-card > .chtm-trigger:hover::after,
.chtm-card > .chtm-trigger:focus-visible::after {
	transform: translateX(5px);
}

@media (prefers-reduced-motion: reduce) {
	.chtm-card > .chtm-trigger::after {
		transition: none;
	}
}

/* --------------------------------------------------------------- dialog -- */

html.chtm-locked,
html.chtm-locked body {
	overflow: hidden;
}

.chtm-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 28px;
}

.chtm-modal[hidden] {
	display: none !important;
}

.chtm-modal .chtm-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(17, 17, 17, 0.62);
	opacity: 0;
	transition: opacity 280ms ease;
}

.chtm-modal.is-open .chtm-backdrop {
	opacity: 1;
}

/* `grid-template-rows: minmax(0, 1fr)` is load-bearing: a grid item's
   automatic minimum size is its content, so without it the bio column
   grows past the capped dialog, overflow-y never engages and the end of
   every long bio is clipped out of reach. */
.chtm-modal .chtm-dialog {
	position: relative;
	display: grid;
	grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
	grid-template-rows: minmax(0, 1fr);
	width: min(1020px, 100%);
	max-height: min(86vh, 780px);
	background: #ffffff;
	box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3);
	overflow: hidden;
	opacity: 0;
	transform: translateY(18px);
	transition: opacity 300ms ease, transform 300ms ease;
}

.chtm-modal.is-open .chtm-dialog {
	opacity: 1;
	transform: none;
}

.chtm-modal .chtm-dialog:focus {
	outline: none;
}

/* Warm off-white, close to the studio backdrop of the headshots, so the
   letterboxing that `contain` leaves reads as part of the photo. */
.chtm-modal .chtm-media {
	position: relative;
	min-height: 0;
	background: #f3f1ed;
	overflow: hidden;
}

.chtm-modal .chtm-media[hidden] {
	display: none;
}

/* contain, never cover: the headshots are 420x629 and this column can be
   780px tall, so cover would scale them up and cut head, hands or sides. */
.chtm-modal .chtm-photo {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
	object-position: center;
}

.chtm-modal .chtm-content {
	min-height: 0;
	padding: 56px 56px 56px 48px;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
}

.chtm-modal .chtm-name {
	margin: 0 0 8px;
	font-family: 'Roboto Slab', Georgia, serif;
	font-weight: 400;
	font-size: 32px;
	line-height: 1.2;
	letter-spacing: -0.01em;
	color: #000000;
}

.chtm-modal .chtm-role {
	margin: 0 0 26px;
	font-family: 'Roboto', sans-serif;
	font-weight: 600;
	font-size: 11px;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	color: #b89d72;
}

.chtm-modal .chtm-role[hidden] {
	display: none;
}

.chtm-modal .chtm-bio {
	font-family: 'Roboto', sans-serif;
	font-size: 16px;
	line-height: 1.85;
	color: #5f5f5f;
}

/* The bio opens with its tagline in <em>; give it the lead treatment and
   swallow the first of the two <br> that follow it. */
.chtm-modal .chtm-bio > em:first-child {
	display: block;
	margin-bottom: 4px;
	font-family: 'Roboto Slab', Georgia, serif;
	font-size: 19px;
	line-height: 1.45;
	color: #000000;
}

.chtm-modal .chtm-bio > em:first-child + br {
	display: none;
}

/* Dark disc, not white: the control sits on the photo, and the headshots
   are shot against a near-white backdrop. */
.chtm-modal .chtm-close {
	position: absolute;
	top: 16px;
	right: 16px;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(17, 17, 17, 0.58);
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
	color: #ffffff;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	transition: background 200ms ease, color 200ms ease;
}

.chtm-modal .chtm-close:hover,
.chtm-modal .chtm-close:focus-visible {
	background: #b89d72;
	color: #ffffff;
}

@media (max-width: 1024px) {
	.chtm-modal .chtm-content {
		padding: 44px 40px 44px 36px;
	}

	.chtm-modal .chtm-name {
		font-size: 28px;
	}
}

/* Below the two-column threshold the dialog becomes a full-height sheet:
   photo on top, bio scrolling underneath. The second row is the one that
   scrolls, hence minmax(0, 1fr) again. */
@media (max-width: 880px) {
	.chtm-modal {
		padding: 0;
	}

	.chtm-modal .chtm-dialog {
		grid-template-columns: 1fr;
		grid-template-rows: auto minmax(0, 1fr);
		width: 100%;
		height: 100%;
		max-height: 100%;
	}

	.chtm-modal .chtm-media {
		height: 42vh;
		min-height: 240px;
	}

	.chtm-modal .chtm-content {
		padding: 28px 22px 44px;
	}

	.chtm-modal .chtm-name {
		font-size: 25px;
	}

	.chtm-modal .chtm-bio {
		font-size: 15px;
	}

	.chtm-modal .chtm-bio > em:first-child {
		font-size: 18px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.chtm-modal .chtm-backdrop,
	.chtm-modal .chtm-dialog {
		transition: none;
	}
}
