/*
 * Canonical project card — single source of appearance and states.
 *
 * Used by the iwut/card block (Query Loops, archives) and by the listing
 * shortcodes. Layout, metrics, actions and every state are defined here once;
 * sections may only override --iwut-card-accent.
 *
 * Scope: listing cards for News, Research and Student Life / Cooperation.
 * Single post, staff and course cards keep their own presentation.
 */

.iwut-cards {
	--iwut-card-accent: var(--wp--preset--color--green, #043927);
	/* Hover/focus colour is its own token so it stays turquoise and is not
	   pulled into the (navy) blue style-variation of the accent token. */
	--iwut-card-hover: #12938c;
	--iwut-card-line: var(--wp--preset--color--line, #c3d7cc);
	--iwut-card-surface: var(--wp--preset--color--surface, #fff);
	--iwut-card-muted: var(--wp--preset--color--muted, #4a5f55);
	--iwut-card-radius: 2px;

	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: clamp(18px, 2.2vw, 28px);
	align-items: stretch;
	/* Some page layouts (e.g. the Student Life hub) wrap the content in their
	   own grid; the card grid must always span the full row. */
	grid-column: 1 / -1;
	width: 100%;
	margin: 26px 0 0;
	padding: 0;
	list-style: none;
}

/* post-template renders <li> per entry; direct children (div mode) are cards. */
.iwut-cards > li {
	display: flex;
	min-width: 0;
	margin: 0;
	padding: 0;
}

@media (max-width: 1024px) {
	.iwut-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
	.iwut-cards { grid-template-columns: 1fr; gap: 18px; }
}

/* Staff hub variant: compact four-up grid with a gold hover state. Only the
   /staff/ hub opts in; every other surface keeps the default card grid.
   The active "scheme-blue" style variation remaps --wp--preset--color--gold
   to turquoise, so the approved staff gold is used literally here. */
.iwut-cards--staff {
	--iwut-card-hover: #b8964a;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 18px;
}

@media (max-width: 1200px) {
	.iwut-cards--staff { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
	.iwut-cards--staff { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
	.iwut-cards--staff { grid-template-columns: 1fr; }
}

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

.iwut-card {
	position: relative;
	display: flex;
	flex: 1;
	flex-direction: column;
	min-width: 0;
	height: 100%;
	margin: 0;
	overflow: hidden;
	border: 1px solid var(--iwut-card-line, #c3d7cc);
	border-radius: var(--iwut-card-radius, 2px);
	background: var(--iwut-card-surface, #fff);
	/* Cards are light surfaces: never inherit the section's text colour
	   (dark sections such as #research and #life use white text). */
	color: var(--wp--preset--color--ink, #10201a);
	box-shadow: 0 8px 24px rgba(10, 16, 36, .06);
	transition:
		transform .24s cubic-bezier(.2, .8, .2, 1),
		box-shadow .24s cubic-bezier(.2, .8, .2, 1),
		border-color .18s ease;
}

/* Accent bar shared by every family. */
.iwut-card::before {
	content: "";
	position: absolute;
	inset-inline-start: -1px;
	top: 0;
	z-index: 3;
	width: 3px;
	height: 0;
	background: var(--iwut-card-hover, #12938c);
	transition: height .24s cubic-bezier(.2, .8, .2, 1);
}

/* Media slot is always present and always the same ratio, with or without
   an image, so rows stay aligned. */
.iwut-card__media {
	position: relative;
	display: block;
	flex: 0 0 auto;
	aspect-ratio: 16 / 10;
	overflow: hidden;
	background: var(--wp--preset--color--paper, #f6f7fa);
}

.iwut-card .iwut-card__media img {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform .32s cubic-bezier(.2, .8, .2, 1);
}

.iwut-card__placeholder {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	background: linear-gradient(135deg, #0b2340, #123f63);
	color: var(--wp--preset--color--gold, #b8964a);
}

.iwut-card__placeholder::before {
	content: "";
	position: absolute;
	width: 150px;
	height: 150px;
	border: 2px solid currentColor;
	opacity: .25;
	transform: rotate(45deg);
}

.iwut-card__placeholder span {
	position: relative;
	font-family: var(--wp--preset--font-family--display, serif);
	font-size: 22px;
	font-weight: 700;
	letter-spacing: .14em;
}

.iwut-card__body {
	display: flex;
	flex: 1;
	flex-direction: column;
	padding: 18px 20px 22px;
}

.iwut-card__date {
	display: block;
	margin: 0 0 10px;
	color: var(--iwut-card-accent, #58717b);
	font-size: 12px;
	letter-spacing: .04em;
}

.iwut-card__title {
	margin: 0 0 10px;
	font-size: clamp(17px, 1.5vw, 20px);
	line-height: 1.45;
}

.iwut-card__title a {
	color: inherit;
	text-decoration: none;
}

/* One interactive target per card: the title link covers the whole card. */
.iwut-card__title a::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 2;
}

.iwut-card__excerpt {
	display: -webkit-box;
	margin: 0 0 14px;
	overflow: hidden;
	color: var(--iwut-card-muted, #4a5f55);
	font-size: 14px;
	line-height: 1.65;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
}

.iwut-card__terms {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin: 0 0 12px;
	padding: 0;
	list-style: none;
	color: var(--iwut-card-muted, #4a5f55);
	font-size: 12px;
}

.iwut-card__cta {
	align-self: flex-start;
	margin-top: auto;
	padding-top: 6px;
	color: var(--iwut-card-accent, #0b5cab);
	font-size: 13.5px;
	font-weight: 700;
}

.iwut-card__cta::after {
	content: " \2192";
}

/* -------------------------------------------------------------- states --- */

.iwut-card:hover,
.iwut-card:focus-within {
	border-color: var(--iwut-card-hover, #12938c);
	box-shadow: 0 16px 34px rgba(10, 16, 36, .13);
	transform: translateY(-5px);
}

.iwut-card:hover::before,
.iwut-card:focus-within::before {
	height: 100%;
}

.iwut-card:hover .iwut-card__media img,
.iwut-card:focus-within .iwut-card__media img {
	transform: scale(1.04);
}

.iwut-card:focus-within {
	outline: 3px solid color-mix(in srgb, var(--iwut-card-hover, #12938c) 45%, transparent);
	outline-offset: 3px;
}

.iwut-card:active {
	transform: translateY(-1px);
}

/* Staff variant: smaller body, rectangular 4:3 portrait slot, gold hover. */
.iwut-card--staff .iwut-card__media {
	aspect-ratio: 4 / 3;
	background: var(--wp--preset--color--surface, #fff);
}

.iwut-card--staff .iwut-card__media img {
	object-fit: contain;
	object-position: center center;
}

.iwut-card--staff .iwut-card__body {
	padding: 14px 15px 16px;
}

.iwut-card--staff .iwut-card__title {
	margin-bottom: 6px;
	font-size: clamp(15px, 1.15vw, 17px);
	line-height: 1.4;
}

.iwut-card--staff .iwut-card__excerpt {
	margin-bottom: 10px;
	font-size: 13px;
	line-height: 1.55;
	-webkit-line-clamp: 2;
}

.iwut-card--staff .iwut-card__cta {
	font-size: 12.5px;
}

.iwut-card--staff:hover,
.iwut-card--staff:focus-within {
	background: var(--wp--preset--color--cream, #fff7e1);
	transform: translateY(-2px);
}

.iwut-card--staff:hover .iwut-card__title a,
.iwut-card--staff:focus-within .iwut-card__title a,
.iwut-card--staff:hover .iwut-card__cta,
.iwut-card--staff:focus-within .iwut-card__cta {
	color: #b8964a;
}

/* Touch devices: no hover-only movement. */
@media (hover: none) {
	.iwut-card:hover {
		border-color: var(--iwut-card-line, #c3d7cc);
		box-shadow: 0 8px 24px rgba(10, 16, 36, .06);
		transform: none;
	}

	.iwut-card:hover::before { height: 0; }

	.iwut-card:hover .iwut-card__media img { transform: none; }

	.iwut-card--staff:hover,
	.iwut-card--staff:focus-within {
		background: var(--iwut-card-surface, #fff);
	}

	.iwut-card--staff:hover .iwut-card__title a,
	.iwut-card--staff:hover .iwut-card__cta {
		color: inherit;
	}
}

@media (prefers-reduced-motion: reduce) {
	.iwut-card,
	.iwut-card__media img,
	.iwut-card::before {
		transition: none;
	}

	.iwut-card:hover,
	.iwut-card:focus-within,
	.iwut-card:active {
		transform: none;
	}

	.iwut-card:hover .iwut-card__media img,
	.iwut-card:focus-within .iwut-card__media img {
		transform: none;
	}
}
