/*
 * Our team widget (inc/elementor/team-widget.php).
 * Without .is-ready (no JavaScript) every biography is open under its row and photos are in colour.
 * With it, the thread in assets/js/team.js runs along the foot of each row of portraits; a portrait
 * is quiet until the thread reaches it (.is-passed), and stays in colour from then on.
 * Rows and biographies share one grid: dense packing keeps four cards on a row, while the biography
 * of any of them takes the full-width row beneath. Closed biographies are rows of no height.
 * Colours come from tokens.css through data-theme. Selectors carry .kl-team twice where the
 * Elementor Kit styles headings, buttons and links, so the section keeps its own.
 */

.kl-team {
	/* Rail and curve match the practice areas, so the thread continues on the same line */
	--kl-rail: 40px;
	--kl-curve: 48px;
	--kl-turn: 16px;
	--kl-cols: 2;
	--kl-gap: 12px;
	--kl-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
	position: relative;
	padding-block: var(--space-6);
	background: var(--bg-alt);
	color: var(--fg);
}

.kl-team__inner {
	position: relative;
	max-width: var(--wrap-max);
	margin-inline: auto;
	padding-inline: var(--gutter);
}

/* Lines. They may leave the section at the top, to cross into the section above. */
.kl-team__thread {
	display: none;
	overflow: visible;
	pointer-events: none;
}
.kl-team.is-ready .kl-team__thread {
	display: block;
	position: absolute;
	inset: 0;
	z-index: 1;
	width: 100%;
	height: 100%;
}
.kl-team__line {
	fill: none;
	stroke-width: 2;
}
.kl-team__node {
	fill: var(--bg-alt);
	stroke: var(--rule);
	stroke-width: 1.5;
	transform-box: fill-box;
	transform-origin: center;
	transition: fill 0.4s linear, stroke 0.4s linear, transform 0.5s var(--kl-ease);
}
.kl-team__node.is-passed { fill: var(--rule); }
.kl-team__node.is-active {
	fill: var(--accent);
	stroke: var(--accent);
	transform: scale(1.5);
}
.kl-team__tip { fill: var(--accent); }

.kl-team__draw {
	fill: none;
	stroke: var(--rule);
	stroke-width: 1;
	stroke-dasharray: 1;
	stroke-dashoffset: 1;
	transition: stroke-dashoffset 1.1s var(--kl-ease);
}
.kl-team__draw.is-drawn { stroke-dashoffset: 0; }
.kl-team__draw--inner { transition-duration: 0.7s; }
.kl-team__draw--wire { stroke-width: 1.5; transition-duration: 0.7s; }

/* Head */
.kl-team__head {
	padding-left: var(--kl-rail);
	margin-bottom: var(--space-5);
}
.kl-team .kl-team__eyebrow {
	margin: 0 0 var(--space-3);
	color: var(--eyebrow);
	font-size: var(--type-eyebrow-size);
	line-height: var(--type-eyebrow-line);
	font-weight: var(--type-eyebrow-weight);
	letter-spacing: var(--type-eyebrow-tracking);
	text-transform: uppercase;
}
.kl-team .kl-team__title {
	max-width: 18em;
	margin: 0;
	color: var(--heading);
	font-family: var(--font-serif);
}
.kl-team .kl-team__text {
	max-width: 34em;
	margin: var(--space-4) 0 0;
	color: var(--fg);
}

/* People */
.kl-team__list {
	display: grid;
	grid-template-columns: repeat(var(--kl-cols), minmax(0, 1fr));
	grid-auto-flow: dense;
	column-gap: var(--kl-gap);
	margin: 0 var(--kl-turn) 0 var(--kl-rail);
	padding: 0;
	list-style: none;
}
.kl-team__item { display: contents; }

.kl-team__card {
	position: relative;
	display: flex;
	flex-direction: column;
	padding-bottom: var(--space-5);
}

.kl-team__photo {
	position: relative;
	aspect-ratio: 4 / 5;
	overflow: hidden;
	background: var(--border);
}
/* Taller than its window, so it can drift as the page scrolls. The faces sit high in these photos. */
.kl-team .kl-team__photo img {
	position: absolute;
	top: -6%;
	left: 0;
	display: block;
	width: 100%;
	max-width: none;
	height: 112%;
	border-radius: var(--radius-none);
	object-fit: cover;
	object-position: 50% 14%;
	will-change: transform;
}
/* Only once the page has settled: photos should not fade to grey as the script starts */
.kl-team.is-live .kl-team__photo img {
	transition:
		filter 1.4s var(--kl-ease),
		opacity 0.8s var(--kl-ease),
		transform 1.2s var(--kl-ease);
}

/* Until a photo arrives: the shield on burgundy */
.kl-team__photo--crest {
	display: grid;
	place-items: center;
	background: var(--burgundy);
}
.kl-team .kl-team__photo--crest img {
	position: static;
	width: 34%;
	height: auto;
	object-fit: contain;
}

.kl-team.is-ready .kl-team__card:not(.is-passed) .kl-team__photo img {
	filter: grayscale(1) contrast(0.94);
	opacity: 0.72;
	transform: scale(1.05);
}
.kl-team.is-ready .kl-team__card:not(.is-passed) .kl-team__photo--crest img { filter: none; }

/* Caption */
.kl-team .kl-team__name {
	margin: var(--space-3) 0 var(--space-1);
	color: var(--heading);
	font-family: var(--font-serif);
	font-size: 18px;
	line-height: 1.2;
	font-weight: 500;
	transition: color 0.8s linear;
}
.kl-team .kl-team__name::after { content: none; }
.kl-team.is-ready .kl-team__card:not(.is-passed) .kl-team__name { color: var(--fg-muted); }

/* The whole card is the button, with the name as its label */
.kl-team.kl-team .kl-team__toggle,
.kl-team.kl-team .kl-team__toggle:hover,
.kl-team.kl-team .kl-team__toggle:focus {
	display: inline;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: var(--radius-none);
	background: none;
	box-shadow: none;
	color: inherit;
	font: inherit;
	letter-spacing: inherit;
	text-align: left;
	text-transform: none;
	white-space: normal;
	cursor: pointer;
}
.kl-team__toggle::after {
	content: "";
	position: absolute;
	inset: 0 0 var(--space-3);
}
.kl-team.kl-team .kl-team__toggle:focus-visible { outline: none; }
.kl-team__toggle:focus-visible::after {
	outline: 2px solid var(--focus);
	outline-offset: 2px;
}

.kl-team .kl-team__role {
	margin: 0;
	color: var(--fg);
	font-size: var(--type-caption-size);
	line-height: 1.35;
	font-style: italic;
}
.kl-team .kl-team__credentials {
	margin: 2px 0 0;
	color: var(--fg-muted);
	font-size: 13px;
	line-height: 1.35;
	font-variant-numeric: lining-nums;
}

.kl-team__more { display: none; }
.kl-team.is-ready .kl-team__more {
	display: inline-flex;
	align-self: flex-start;
	align-items: center;
	gap: var(--space-2);
	/* Pushed down, so the links line up along a row whether or not a person lists qualifications */
	margin-top: auto;
	padding-top: var(--space-2);
	color: var(--accent);
	font-size: 12px;
	line-height: 1;
	font-weight: var(--type-button-weight);
	letter-spacing: var(--type-menu-tracking);
	text-transform: uppercase;
	transition: color 0.3s linear;
}
.kl-team__plus {
	position: relative;
	display: block;
	width: 10px;
	height: 10px;
}
.kl-team__plus::before,
.kl-team__plus::after {
	content: "";
	position: absolute;
	top: 4px;
	left: 0;
	width: 10px;
	height: 1.5px;
	background: currentColor;
	transition: transform 0.4s var(--kl-ease);
}
.kl-team__plus::after { transform: rotate(90deg); }
.kl-team__item.is-open .kl-team__plus::after { transform: rotate(0deg); }

/* Biography, under the row of its person */
.kl-team__panel { grid-column: 1 / -1; }
.kl-team__panel-clip { min-width: 0; }

.kl-team.is-ready .kl-team__panel {
	display: grid;
	grid-template-rows: 0fr;
	visibility: hidden;
	transition: grid-template-rows 0.55s var(--kl-ease), visibility 0s linear 0.55s;
}
.kl-team.is-ready .kl-team__item.is-open .kl-team__panel {
	grid-template-rows: 1fr;
	visibility: visible;
	transition: grid-template-rows 0.55s var(--kl-ease), visibility 0s;
}
.kl-team.is-ready .kl-team__panel-clip {
	min-height: 0;
	overflow: hidden;
}

/* Spacing as content, not padding: a closed panel has to collapse to nothing */
.kl-team__panel-inner::before,
.kl-team__panel-inner::after {
	content: "";
	display: block;
	height: var(--space-4);
}
.kl-team__panel-inner::after { height: var(--space-6); }

.kl-team .kl-team__bio { color: var(--fg); }
.kl-team .kl-team__bio p { margin: 0 0 var(--space-3); }
.kl-team .kl-team__bio p:first-child {
	color: var(--heading);
	font-size: var(--type-lead-size);
	line-height: 1.4;
}

.kl-team__links {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-1) var(--space-5);
	margin: var(--space-3) 0 0;
}
.kl-team .kl-team__link {
	display: inline-flex;
	align-items: center;
	gap: var(--space-2);
	min-height: 44px;
	color: var(--accent);
	font-size: var(--type-button-size);
	font-weight: var(--type-button-weight);
	letter-spacing: var(--type-menu-tracking);
	text-transform: uppercase;
	text-decoration: none;
}
.kl-team .kl-team__link:hover { color: var(--accent-hover); }
.kl-team .kl-team__link svg { flex: none; transition: transform 0.4s var(--kl-ease); }
.kl-team .kl-team__link:hover svg { transform: translateX(4px); }

/* What is in the biography arrives one after the other, and leaves together */
.kl-team.is-ready .kl-team__bio > *,
.kl-team.is-ready .kl-team__links {
	opacity: 0;
	transform: translate3d(0, 10px, 0);
	transition: opacity 0.2s linear, transform 0s linear 0.2s;
}
.kl-team.is-ready .kl-team__item.is-open .kl-team__bio > *,
.kl-team.is-ready .kl-team__item.is-open .kl-team__links {
	opacity: 1;
	transform: none;
	transition:
		opacity 0.7s var(--kl-ease) calc(var(--i, 0) * 50ms + 0.15s),
		transform 0.7s var(--kl-ease) calc(var(--i, 0) * 50ms + 0.15s);
}

/* Closing: where the thread ends */
.kl-team__closing {
	padding-left: calc(var(--kl-rail) + var(--kl-curve));
	margin-top: var(--space-5);
}
.kl-team .kl-team__closing-text {
	max-width: 30em;
	margin: 0 0 var(--space-4);
	color: var(--fg);
	font-size: var(--type-lead-size);
	line-height: var(--type-lead-line);
}
/* The button is the shared .btn of base.css */

/* Thread switched off in the widget: the frames stay, the line, its nodes and the wire go, and so does the room they took */
.kl-team.kl-team--plain {
	--kl-rail: 0px;
	--kl-curve: 0px;
	--kl-turn: 0px;
}
.kl-team--plain .kl-team__line,
.kl-team--plain .kl-team__node,
.kl-team--plain .kl-team__tip,
.kl-team--plain .kl-team__draw--wire { display: none; }

/* Pointer: the photo under it leans in and the rest step back a little */
@media (hover: hover) and (pointer: fine) {
	.kl-team.is-ready .kl-team__card.is-passed:hover .kl-team__photo img {
		transform: scale(1.04) translate3d(calc(var(--kl-mx, 0) * -6px), calc(var(--kl-my, 0) * -6px), 0);
		transition: filter 1.4s var(--kl-ease), opacity 0.8s var(--kl-ease), transform 0.7s var(--kl-ease);
	}
	.kl-team.is-ready .kl-team__list:has(.kl-team__card:hover) .kl-team__card.is-passed:not(:hover) .kl-team__photo img { opacity: 0.8; }
	.kl-team .kl-team__card:hover .kl-team__more { color: var(--accent-hover); }
}

@media (min-width: 768px) {
	.kl-team { --kl-cols: 4; --kl-gap: 16px; }
	.kl-team .kl-team__name { font-size: var(--type-h3-mobile-size); }
}

@media (min-width: 1024px) {
	.kl-team {
		--kl-rail: 72px;
		--kl-curve: 96px;
		--kl-turn: 48px;
		--kl-gap: 32px;
		padding-block: var(--space-7) var(--space-8);
	}
	.kl-team__head { margin-bottom: var(--space-6); }
	.kl-team__card { padding-bottom: var(--space-6); }
	.kl-team .kl-team__name { font-size: var(--type-h3-size); }
	.kl-team .kl-team__role { font-size: var(--type-body-size); }
	.kl-team .kl-team__credentials { font-size: var(--type-caption-size); }
	.kl-team.is-ready .kl-team__more { font-size: 13px; }

	.kl-team .kl-team__bio {
		columns: 2;
		column-gap: var(--space-7);
	}
	.kl-team .kl-team__bio p { break-inside: avoid; }
	.kl-team__closing { margin-top: var(--space-4); }
}

@media (prefers-reduced-motion: reduce) {
	.kl-team *,
	.kl-team .kl-team__photo img {
		transition: none !important;
	}
}
