/**
 * List — block layout + the list-1 / list-2 / list-3 card designs (Figma "List").
 * Port of Smart Team Pro's stylesheet.
 *
 * One member per row. The photo side is per cell: Image Position flips every
 * row, resolved here into --sptp-list-dir / --sptp-list-flip (0 = photo left,
 * 1 = photo right) from the root modifier class (Team_List::root_classes() ↔
 * edit.jsx). Zig Zag Orientation (flipping the even rows) is Pro — Free ships
 * no rules for it.
 */

// --sptp-list-text-col / --sptp-list-social-col mirror list-3's bio | social
// grid with the row, so social always sits on the outer edge.
@mixin sptp-list-photo-left {
	--sptp-list-dir: row;
	--sptp-list-flip: 0;
	--sptp-list-cols: minmax(0, 1fr) auto;
	--sptp-list-text-col: 1;
	--sptp-list-social-col: 2;
}

@mixin sptp-list-photo-right {
	--sptp-list-dir: row-reverse;
	--sptp-list-flip: 1;
	--sptp-list-cols: auto minmax(0, 1fr);
	--sptp-list-text-col: 2;
	--sptp-list-social-col: 1;
}

.sp-smart-team-list {
	// Two classes outrank the Grid's `.sp-smart-team-grid__items` 3-column fallback.
	.sp-smart-team-grid__items {
		grid-template-columns: 1fr;
		gap: 38px 0;
	}

	// No Hover Content push here, and any `translate` makes each cell a stacking context.
	.sp-smart-team-grid__cell {
		translate: none;
		@include sptp-list-photo-left;
	}
}

.sp-smart-team-list--image-right .sp-smart-team-grid__cell {
	@include sptp-list-photo-right;
}

// Shared by the three designs: a left-aligned horizontal row.
.sp-smart-team-card--list-1,
.sp-smart-team-card--list-2,
.sp-smart-team-card--list-3 {
	// --sptp-list-align is Card Elements → Align Items (dynamic CSS).
	&.sp-smart-team-card {
		flex-direction: var(--sptp-list-dir, row);
		align-items: var(--sptp-list-align, center);
		text-align: left;
	}

	.sp-smart-team-card__avatar {
		box-sizing: border-box;
		flex-shrink: 0;
		align-self: var(--sptp-list-align, center);
		margin: 0;
	}

	.sp-smart-team-card__content {
		box-sizing: border-box;
		flex: 1;
		min-width: 0;
		align-items: flex-start;
		justify-content: var(--sptp-list-align, center);
		--sptp-content-gap: 18px;
	}

	.sp-smart-team-card__name:has(+ .sp-smart-team-card__role) {
		margin-bottom: 4px;
	}

	.sp-smart-team-card__role,
	.sp-smart-team-card__bio {
		font-size: 15px;
	}

	.sp-smart-team-card__bio {
		line-height: 1.6;
	}

	.sp-smart-team-card__social {
		gap: 10px;
	}
}

/* list-1 — no card box: a square photo beside the text. */
.sp-smart-team-card--list-1 {
	&.sp-smart-team-card {
		background: transparent;
		gap: 24px;
	}

	.sp-smart-team-card__avatar {
		width: 282px;
		border-radius: 4px;
	}

	.sp-smart-team-card__content {
		padding: 0;
	}

	.sp-smart-team-card__social {
		padding-top: 8px;
	}
}

/* list-2 — a circular photo overlapping a tinted panel by half its width; the
   panel's text clears the overlap on the photo's side. --sptp-list-photo is the
   Member Image width (Styles\Team_List ↔ dynamicCss.js). */
.sp-smart-team-card--list-2 {
	&.sp-smart-team-card {
		--sptp-list-overlap: calc(var(--sptp-list-photo, 218px) / 2);
		--sptp-list-text-gap: 32px;
		background: transparent;
		overflow: visible;
	}

	.sp-smart-team-card__avatar {
		position: relative;
		z-index: 2;
		width: 218px;
		border-radius: 50%;
	}

	// Card Padding (dynamic CSS) adds to these clearances — CardCss::list_panel_padding().
	.sp-smart-team-card__content {
		--sptp-list-clear-left: calc((var(--sptp-list-overlap) + var(--sptp-list-text-gap)) * (1 - var(--sptp-list-flip, 0)));
		--sptp-list-clear-right: calc((var(--sptp-list-overlap) + var(--sptp-list-text-gap)) * var(--sptp-list-flip, 0));
		position: relative;
		z-index: 1;
		align-self: stretch;
		margin-left: calc(var(--sptp-list-overlap) * -1 * (1 - var(--sptp-list-flip, 0)));
		margin-right: calc(var(--sptp-list-overlap) * -1 * var(--sptp-list-flip, 0));
		padding: 32px calc(20px + var(--sptp-list-clear-right)) 32px calc(20px + var(--sptp-list-clear-left));
		background: rgba(225, 241, 236, 0.5);
		border: 1px solid #e1f1ec;
		border-radius: 10px;
	}

	// The card itself is transparent; the skeleton takes the tinted panel's shape, not the photo's overhang.
	&.sp-smart-team-card--preloading > .sp-smart-team-card__loader {
		left: calc(var(--sptp-list-overlap) * (1 - var(--sptp-list-flip, 0)));
		right: calc(var(--sptp-list-overlap) * var(--sptp-list-flip, 0));
		border-radius: 10px;
	}
}

/* list-3 — one bordered row: [photo + name/role] | bio | social, split by
   dividers drawn 16px out (half the 32px gap) that grow with the bio column (min 60px). */
.sp-smart-team-card--list-3 {
	&.sp-smart-team-card {
		gap: 32px;
		padding: 28px;
		background: #fff;
		border: 1px solid #ddd;
		border-radius: 8px;
	}

	.sp-smart-team-card__side {
		position: relative;
		display: grid;
		grid-template-columns: auto 1fr;
		align-self: var(--sptp-list-align, center);
		align-content: center;
		align-items: center;
		// The name/role column keeps its 146px as the photo grows (80px photo → 242px).
		flex: 0 1 calc(var(--sptp-list-photo, 80px) + 162px);
		min-width: 0;
		column-gap: 16px;
		row-gap: 8px;
	}

	.sp-smart-team-card__side .sp-smart-team-card__avatar {
		grid-row: 1 / span 2;
		width: 80px;
		border-radius: 50%;
	}

	.sp-smart-team-card__side .sp-smart-team-card__name {
		align-self: end;
		margin-bottom: 0;
	}

	.sp-smart-team-card__side .sp-smart-team-card__role {
		align-self: start;
		font-size: 16px;
	}

	// Two columns: bio and every other element (Read More included) stack in
	// the first; social sits alone in the second, spanning all its rows.
	// row-gap stays 0 so the empty implicit rows social spans take no space —
	// elements are spaced by the shared margin-bottom (--sptp-content-gap).
	.sp-smart-team-card__content {
		position: relative;
		display: grid;
		grid-template-columns: var(--sptp-list-cols, minmax(0, 1fr) auto);
		align-content: var(--sptp-list-align, center);
		column-gap: 32px;
		row-gap: 0;
		padding: 0;
		--sptp-content-gap: 14px;

		> * {
			grid-column: var(--sptp-list-text-col, 1);
			min-width: 0;
		}

		> .sp-smart-team-card__bio {
			font-size: 16px;
		}

		// A grid cell stretches the shared flex wrapper, whose center justify would pin the button;
		// as a block the inline-flex button follows Alignment's text-align.
		> .sp-smart-team-card__read-more {
			display: block;
		}

		> .sp-smart-team-card__social[class] {
			position: relative;
			grid-column: var(--sptp-list-social-col, 2);
			grid-row: 1 / span 12;
			// Stretched to the bio column's height so its divider grows with it; Align Items places the icons.
			align-self: stretch;
			align-items: var(--sptp-list-align, center);
			flex-wrap: nowrap;
			gap: 4px;
			margin-bottom: 0;
		}

		> :has(+ .sp-smart-team-card__social:last-child) {
			margin-bottom: 0;
		}
	}

	.sp-smart-team-card__side + .sp-smart-team-card__content::before,
	.sp-smart-team-card__content > .sp-smart-team-card__social::before {
		content: '';
		position: absolute;
		top: 50%;
		width: 1px;
		height: max(60px, 100%);
		background: #ddd;
		transform: translateY(-50%);
		pointer-events: none;
	}

	// The photo block's divider is drawn by the content column (it sizes to the bio), on its photo-facing edge.
	.sp-smart-team-card__side + .sp-smart-team-card__content::before {
		left: calc(-16px + var(--sptp-list-flip, 0) * (100% + 32px));
	}

	// The social divider sits on its bio-facing edge.
	.sp-smart-team-card__content > .sp-smart-team-card__social::before {
		left: calc(-16px + var(--sptp-list-flip, 0) * (100% + 32px));
	}
}

// Tablets: list-3's no-wrap social column would leave the bio a sliver — drop it under the bio.
@media only screen and (min-width: 600px) and (max-width: 1023px) {
	.sp-smart-team-card--list-3 .sp-smart-team-card__content {
		grid-template-columns: minmax(0, 1fr);
		--sptp-list-text-col: 1;

		> .sp-smart-team-card__social[class] {
			grid-column: 1;
			grid-row: auto;
			align-self: start;
			flex-wrap: wrap;

			&:not(:last-child) {
				margin-bottom: var(--sptp-content-gap);
			}
		}

		> .sp-smart-team-card__social::before {
			content: none;
		}

		> :has(+ .sp-smart-team-card__social:last-child) {
			margin-bottom: var(--sptp-content-gap);
		}
	}
}

// Phones: list-1/2 stack (photo centered on top),
// list-3 wraps with the photo block on its own line and no dividers.
@media only screen and (max-width: 599px) {
	.sp-smart-team-card--list-1,
	.sp-smart-team-card--list-2 {
		&.sp-smart-team-card {
			flex-direction: column;
			align-items: stretch;
		}

		.sp-smart-team-card__avatar {
			align-self: center;
			max-width: 100%;
		}
	}

	.sp-smart-team-card--list-2 {
		.sp-smart-team-card__avatar {
			max-width: 70%;
		}

		.sp-smart-team-card__content {
			--sptp-list-clear-left: 0px;
			--sptp-list-clear-right: 0px;
			--sptp-list-clear-top: calc(var(--sptp-list-overlap) * 0.5);
			margin: calc(var(--sptp-list-overlap) * -0.5) 0 0;
			padding-top: calc(var(--sptp-list-clear-top) + 24px);
		}

		&.sp-smart-team-card--preloading > .sp-smart-team-card__loader {
			inset: 0;
		}
	}

	.sp-smart-team-card--list-3 {
		&.sp-smart-team-card {
			flex-direction: column;
			align-items: stretch;
			gap: 20px;
			padding: 20px;
		}

		.sp-smart-team-card__side {
			flex-basis: auto;
			align-self: stretch;
		}

		.sp-smart-team-card__content {
			grid-template-columns: minmax(0, 1fr);
			--sptp-list-text-col: 1;

			> .sp-smart-team-card__social[class] {
				grid-column: 1;
				grid-row: auto;
				align-self: start;
				flex-wrap: wrap;

				&:not(:last-child) {
					margin-bottom: var(--sptp-content-gap);
				}
			}

			> :has(+ .sp-smart-team-card__social:last-child) {
				margin-bottom: var(--sptp-content-gap);
			}
		}

		.sp-smart-team-card__side + .sp-smart-team-card__content::before,
		.sp-smart-team-card__content > .sp-smart-team-card__social::before {
			content: none;
		}
	}
}
