/*
 * Cards (Figma: "Card - Interactive" audience tiles and the publication cards on Home,
 * "Vertical Card", and the image-and-text carousel on Discover - Design).
 * A card's link covers the whole card (stretched link), so the card is one click target.
 */

.cards__head {
	display: grid;
	justify-items: center;
	gap: 8px;
	margin-bottom: 32px;
	text-align: center;
}

.cards--left .cards__head {
	justify-items: start;
	text-align: left;
}

.cards__heading--l {
	font-size: var(--t-title-l);
	line-height: var(--lh-title-l);
}

.cards__intro {
	max-width: 424px;
}

.cards--left .cards__intro {
	max-width: 656px;
	color: var(--c-text-2);
}

/* Grid: --cols comes from "Cards per row"; fewer per row on smaller screens. */
.cards__list {
	--per-row: var(--cols, 3);
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 16px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.cards__item {
	position: relative;
	display: flex;
	flex-direction: column;
	flex: 0 0 calc((100% - (var(--per-row) - 1) * 16px) / var(--per-row));
	min-width: 0;
}

.cards__media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.cards__eyebrow {
	font-size: var(--t-sub);
	line-height: var(--lh-sub);
	font-weight: 500;
	text-transform: uppercase;
	color: var(--c-text-2);
}

.cards__text {
	color: var(--c-text-2);
}

.cards__link::after {
	content: "";
	position: absolute;
	inset: 0;
}

.cards__link:focus-visible {
	outline: none;
}

.cards__link:focus-visible::after {
	outline: 2px solid var(--c-text);
	outline-offset: 2px;
}

/* Audience tiles (Figma "Card - Interactive": border turns dark when active). */
.cards--tile .cards__item {
	align-items: center;
	justify-content: center;
	gap: 16px;
	min-height: 200px;
	padding: 16px;
	border: 1px solid var(--c-line);
	text-align: center;
	transition: border-color 0.2s;
}

.cards--tile .cards__item:hover,
.cards--tile .cards__item:focus-within {
	border-color: var(--c-text);
}

.cards__icon svg {
	width: 48px;
	height: 48px;
}

.cards--tile .cards__body {
	display: grid;
	justify-items: center;
	gap: 2px;
}

.cards--tile .cards__title {
	font-family: var(--f-body);
	font-size: var(--t-body);
	line-height: var(--lh-body);
	font-weight: 400;
	text-transform: uppercase;
}

.cards--tile .cards__link {
	flex-direction: column;
	gap: 16px;
	font: inherit;
}

/* Publications: image with a cream title bar; a 4px band-coloured frame on three sides. */
.cards--publication .cards__item {
	height: 392px;
	padding: 4px 4px 0;
}

.cards--publication .cards__media {
	flex: 1;
	min-height: 0;
}

.cards--publication .cards__media img {
	object-position: top;
}

.cards--publication .cards__body {
	padding: 21px 12px;
	background: var(--c-bg);
	color: var(--c-text);
}

.cards--publication .cards__title {
	font-size: var(--t-title-s);
	line-height: var(--lh-title-s);
	text-transform: uppercase;
}

.cards--publication .cards__link {
	justify-content: space-between;
	width: 100%;
	font: inherit;
	text-align: left;
}

/* Figma draws these arrows in the accent purple. */
.cards--publication .cards__link .icon {
	color: var(--c-accent);
}

.cards--publication .cards__link:hover .icon {
	background: var(--c-accent);
	color: var(--c-light);
}

/* Bordered cards (Figma "Vertical Card": border and arrow darken on hover). */
.cards--vertical .cards__item {
	gap: 16px;
	padding: 16px;
	border: 1px solid var(--c-line);
	color: var(--c-text);
	transition: border-color 0.2s;
}

/* Figma draws these cards without a fill on cream and beige (Discover "Ways to begin", "Bring
   weaving to your school"); on a dark band they are cream boxes. */
.bg-dark .cards--vertical .cards__item {
	background: var(--c-bg);
}

/* A neutral well behind card images, seen while they load (and around transparent placeholders). */
.cards--vertical .cards__media {
	background: var(--c-line-2);
}

/* Figma's "Vertical Card" is 500px tall on wide screens, its link at the foot. */
@media (min-width: 1024px) {
	.cards--vertical .cards__item {
		min-height: 500px;
	}
}

.cards--vertical .cards__item:hover,
.cards--vertical .cards__item:focus-within {
	border-color: var(--c-text);
}

.cards--vertical .cards__media img {
	aspect-ratio: 336 / 250;
}

.cards--vertical .cards__body {
	display: grid;
	align-content: start;
	gap: 4px;
	flex: 1;
}

.cards--vertical .cards__title {
	font-size: var(--t-title-s);
	line-height: var(--lh-title-s);
}

.cards--vertical .cards__link,
.cards--info .cards__link {
	align-self: flex-start;
}

.cards--vertical .cards__item:hover .cards__link .icon {
	background: var(--c-text);
	color: var(--c-light);
}

/* Image and text. */
.cards--info .cards__item {
	gap: 32px;
}

.cards--info .cards__media img {
	aspect-ratio: 1;
}

.cards--info .cards__body {
	display: grid;
	align-content: start;
	gap: 16px;
}

.cards--info .cards__text {
	color: var(--c-muted);
}

.bg-dark .cards--info .cards__text {
	color: inherit;
}

/* Icon cards (Discover - Social Sector "How we support livelihood programs"): the icon in a cream
   circle at the top, title and text at the bottom of a bordered 260px card. */
.cards--icon .cards__head {
	margin-bottom: 60px;
}

.cards--icon .cards__heading {
	max-width: 656px;
}

.cards--icon .cards__item {
	justify-content: space-between;
	gap: 32px;
	min-height: 260px;
	padding: 16px;
	border: 1px solid var(--c-line);
}

.cards--icon .cards__icon {
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: var(--c-bg);
	color: var(--c-text);
}

.cards--icon .cards__icon svg {
	width: 24px;
	height: 24px;
}

.cards--icon .cards__body {
	display: grid;
	gap: 8px;
}

/* Carousel: the row lines up with the content column and runs off the right edge. */
.cards__viewport {
	position: relative;
}

.cards--carousel .cards__list {
	flex-wrap: nowrap;
	justify-content: flex-start;
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
	padding-inline: max(var(--gutter), (100% - var(--wrap)) / 2);
	scroll-padding-inline: max(var(--gutter), (100% - var(--wrap)) / 2);
}

.cards--carousel .cards__list::-webkit-scrollbar {
	display: none;
}

.cards--carousel .cards__item {
	scroll-snap-align: start;
}

.cards__nav {
	position: absolute;
	top: var(--nav-y, 50%);
	left: 0;
	right: 0;
	display: flex;
	transform: translateY(-50%);
	pointer-events: none;
}

.cards__arrow {
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--c-light);
	color: var(--c-text);
	pointer-events: auto;
	transition: background-color 0.2s, color 0.2s;
}

.cards__arrow:hover {
	background: var(--c-text);
	color: var(--c-light);
}

.cards__arrow .icon {
	width: 40px;
	height: 40px;
}

.cards__arrow--prev .icon {
	transform: rotate(90deg);
}

.cards__arrow--next {
	margin-left: auto;
}

.cards__arrow--next .icon {
	transform: rotate(-90deg);
}

.cards__progress {
	display: none;
}

/* Phones (Figma Discover - Design_Mobile): a progress bar and small outlined arrows under the row,
   as in the Program cards carousel. */
@media (max-width: 767px) {
	.cards__nav {
		position: static;
		flex-wrap: wrap;
		gap: 16px 8px;
		margin-top: 32px;
		transform: none;
	}

	.cards__progress {
		position: relative;
		display: block;
		flex: 1 0 100%;
		height: 2px;
		background: var(--c-line-2);
	}

	.cards__progress span {
		position: absolute;
		inset-block: 0;
		left: calc(var(--pos, 0) * (1 - var(--size, 1)) * 100%);
		width: calc(var(--size, 1) * 100%);
		background: var(--c-muted);
	}

	.cards__arrow {
		width: 32px;
		height: 32px;
		border: 1px solid var(--c-line);
		background: none;
		color: var(--c-muted);
	}

	.cards__arrow:hover:not(:disabled) {
		border-color: currentColor;
		background: none;
		color: var(--c-text);
	}

	.cards__arrow:disabled {
		background: none;
		color: var(--c-muted);
		opacity: 0.5;
		cursor: default;
	}

	/* Figma crops the phone carousel's photos a little taller than square. */
	.cards--info.cards--carousel .cards__media img {
		aspect-ratio: 328 / 368;
	}

	.cards__arrow .icon {
		width: 21px;
		height: 21px;
		stroke-width: 2;
	}

	.cards__arrow--next {
		margin-left: 0;
	}
}

@media (max-width: 1023px) {
	.cards__list {
		--per-row: min(var(--cols, 3), 2);
	}
}

@media (max-width: 767px) {
	.cards__list {
		--per-row: 1;
	}

	/* Publications stack like a pile: title bar on top, each card overlapping the one before. */
	.cards--publication .cards__list {
		row-gap: 0;
	}

	.cards--publication .cards__item {
		padding-top: 0;
	}

	.cards--publication .cards__item + .cards__item {
		margin-top: -120px;
		box-shadow: 0 -4px 25px rgb(0 0 0 / 0.3);
	}

	.cards--publication .cards__body {
		order: -1;
	}
}

/* One wide card per view (Resources "Projects"): a 1104×300 image; the usual shape on phones. */
.cards__list[style*="--cols: 1"] .cards__media img {
	aspect-ratio: 1104 / 300;
}

@media (max-width: 767px) {
	.cards__list[style*="--cols: 1"] .cards__media img {
		aspect-ratio: 336 / 250;
	}
}
