/*
 * Card v2 (Sherif 13/11): the card is the image's own bounds; under it, with no panel: the title, then the bottom line.
 * Bottom line (Sherif 14/11, option C): the company line, then the save button at its end (RTL: the far left); a card
 * with no company line keeps the line with the save button alone, at the same height. Badges: bottom of the image.
 * Sizes are defined here once: desktop = fixed 4 / 6 / 8 columns (small cards); phone = two columns
 * or a list (the «phone» option). Pure CSS, so switching phone / desktop never crops a card (B1-37).
 */
.tq-cards {
	--tq-cols: 2;
	display: grid;
	grid-template-columns: repeat(var(--tq-cols), minmax(0, 1fr));
	gap: var(--tq-gap-l) var(--tq-gap-m);
	margin: 0;
	padding: 0;
}

/*
 * Columns are fixed per width (2 / 4 / 6 / 8), never auto-fill, so a list's per-page count (24, a multiple of all four)
 * always fills its last row (ticket 628). A grid beside the filter column steps down one size (tq-library lists.css).
 */
@media (min-width: 600px) {
	.tq-cards {
		--tq-cols: 4;
	}
}

@media (min-width: 1024px) {
	.tq-cards {
		--tq-cols: 6;
	}
}

@media (min-width: 1440px) {
	.tq-cards {
		--tq-cols: 8;
	}
}

/* One row: the block prints 8 cards and shows only as many as the columns (never a second, half-filled row). */
.tq-one-row .tq-cards > :nth-child(n + 3) {
	display: none;
}

@media (min-width: 600px) {
	.tq-one-row .tq-cards > :nth-child(n + 3) {
		display: block;
	}

	.tq-one-row .tq-cards > :nth-child(n + 5) {
		display: none;
	}
}

@media (min-width: 1024px) {
	.tq-one-row .tq-cards > :nth-child(n + 5) {
		display: block;
	}

	.tq-one-row .tq-cards > :nth-child(n + 7) {
		display: none;
	}
}

@media (min-width: 1440px) {
	.tq-one-row .tq-cards > :nth-child(n + 7) {
		display: block;
	}
}

.tq-card {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: var(--tq-gap-s);
	min-width: 0;
	color: var(--tq-text);
}

/*
 * Old site CSS: 4497 prints <style id="tq-gd-css"> (anonymous wp_head closure, not removable by name) on the games
 * archive, single games, companies and deals with a bare «.tq-card» rule (frame, 18px padding, row flex, 24px margin).
 * Our cards always sit in a card grid, so this reset under the grid wins over it (0,2,0 vs 0,1,0) on every page.
 */
.tq-cards .tq-card {
	flex-direction: column;
	gap: var(--tq-gap-s);
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
}

.tq-card__media {
	position: relative;
	aspect-ratio: 3 / 4;
	container-type: inline-size;
	overflow: hidden;
	border-radius: var(--tq-radius);
	background: var(--tq-soft);
}

/*
 * Platform icon badges on the image (Sherif 17/11): small square chip (about 24px, icon 14px, white icon on
 * the existing badge background), gap 4px. Badges with a tiny generation suffix (PS5 + PS4) stretch to fit the suffix.
 */
.tq-card__media .tq-badges {
	gap: 4px;
}

.tq-card__media .tq-badge:has(.tq-badge__mark),
.tq-card__media .tq-badge--icon {
	min-width: 24px;
	height: 24px;
	padding-inline: 4px;
	justify-content: center;
	box-sizing: border-box;
	color: var(--tq-on-brand, var(--awhite));
}

.tq-card__media .tq-badge:has(.tq-badge__mark):not(:has(span:not(:empty))),
.tq-card__media .tq-badge--icon:not(:has(span:not(:empty))) {
	width: 24px;
	padding-inline: 0;
}

.tq-card__media .tq-badge span:empty {
	display: none;
}

.tq-card__media .tq-badge__mark {
	width: 14px;
	height: 14px;
	color: var(--tq-on-brand, var(--awhite));
}

.tq-card--product .tq-card__media,
.tq-card--company .tq-card__media {
	aspect-ratio: 1;
}

/*
 * Product images are official photos flattened on white (N-PROD-IMG-HAZE, 02/11), so the product media is the same
 * white plate in light and dark: no grey frame around the photo (Sherif 14/11). Company logos keep the light surface
 * (the media default) in light mode and the white plate in dark mode (unchanged).
 */
.tq-card--product .tq-card__media,
[data-theme="dark"] .tq-card--company .tq-card__media {
	background: var(--tq-plate);
}

.tq-card__img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.3s ease;
}

/* a wide image in a portrait card (live 4852 tq-blur / tq-wide-in-portrait): whole image over the same image blurred */
.tq-card--fit-blur .tq-card__img {
	position: relative;
	z-index: 1;
	object-fit: contain;
}

.tq-card__backdrop {
	position: absolute;
	inset: -12px;
	width: calc(100% + 24px);
	height: calc(100% + 24px);
	object-fit: cover;
	filter: blur(14px);
}

/*
 * B1-FIX-1911 (sweep 19/11 #6): inside an Elementor widget (home «العروض المجانية» shortcode) Elementor's
 * `.elementor img { height: auto }` (0,1,1) beat the two heights above (0,1,0), so a wide image sat at the top of the
 * portrait box and the rest stayed empty. The card's own scope restores the full-box heights everywhere.
 */
.tq-card .tq-card__img {
	height: 100%;
}

.tq-card .tq-card__backdrop {
	height: calc(100% + 24px);
}

.tq-card--fit-contain .tq-card__img {
	box-sizing: border-box;
	padding: 8%;
	object-fit: contain;
}

.tq-card--company .tq-card__img {
	padding: 16%;
}

.tq-card__ph {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	color: var(--tq-muted);
	font-size: 34px;
}

.tq-card__title {
	margin: 0;
	font-family: var(--tq-font-title);
	font-size: 15px;
	font-weight: 400;
	line-height: 1.35;
}

/*
 * Arabic + English name in one line, same size, weight and colour (Sherif 29/10, 393 D; LISTS-DECISIONS-CHECK-1511 A20):
 * the two parts flow on one line and the English moves to its own line only when it does not fit beside the Arabic
 * («it wraps only when too long»). The Arabic keeps the old 2-line clamp; the English part is one line cut at ITS own
 * end (dir="ltr", QA Q2 15/11: «Ni no Kuni: Wrath of…», never «…Wrath of the White Witch»).
 */
.tq-card__title .tq-card__link {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	column-gap: 0.3em;
	min-width: 0;
}

.tq-card__ar {
	display: -webkit-box;
	min-width: 0;
	max-width: 100%;
	overflow: hidden;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}

.tq-card__en {
	min-width: 0;
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/*
 * Bottom line: the company line takes the room left (its name truncates with an ellipsis before the icon) and the save
 * button sits at the end. Cards in one grid row stretch to the tallest, so the line sits at the bottom and rows stay
 * aligned with or without the English line. The button's box sets the line height, with or without a company line.
 */
.tq-card__foot {
	display: flex;
	align-items: center;
	gap: var(--tq-gap-s);
	min-width: 0;
	margin-block-start: auto;
}

.tq-card__foot .tq-company {
	flex: 1 1 auto;
}

/* Bigger company name + logo on every card (Sherif 12/11, ticket 570 #2); the name in the plain text colour (07/11, light text in dark mode via the token). */
.tq-card__foot .tq-company {
	color: var(--tq-text);
	font-size: 14px;
	font-weight: 700;
}

.tq-card__foot .tq-company .tq-company__plate {
	width: 24px;
	height: 24px;
}

/* Above the card link's cover layer (z-index 1), like the company name; inside the card box (a row slider never clips it). */
.tq-card__foot .tq-save {
	z-index: 2;
	flex: none;
	width: 28px;
	height: 28px;
	margin-inline-start: auto;
}

.tq-card__link {
	color: inherit;
	text-decoration: none;
}

.tq-card__link::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
}

.tq-card__link:focus-visible {
	outline: none;
}

.tq-card:has(.tq-card__link:focus-visible) {
	border-radius: var(--tq-radius);
	outline: 2px solid var(--tq-accent);
	outline-offset: 3px;
}

.tq-card__meta {
	margin: 0;
	color: var(--tq-muted);
	font: 400 12px/1.3 var(--tq-font-meta);
}

@media (hover: hover) {
	.tq-card:hover .tq-card__img {
		transform: scale(1.03);
	}

	.tq-card:hover .tq-card__title {
		color: var(--tq-accent);
	}
}

@media (prefers-reduced-motion: reduce) {
	.tq-card__img,
	.tq-card:hover .tq-card__img {
		transition: none;
		transform: none;
	}
}

/* List layout (side column, search, or the phone «list» option): image at the start, text beside it. */
.tq-cards--list {
	grid-template-columns: minmax(0, 1fr);
	gap: var(--tq-gap-m);
}

.tq-cards--list .tq-card {
	display: grid;
	grid-template-columns: 72px minmax(0, 1fr);
	align-content: start;
	gap: 2px var(--tq-gap-m);
}

.tq-cards--list .tq-card__media {
	grid-row: 1 / span 3;
}

.tq-cards--list .tq-badges,
.tq-cards--list .tq-save {
	display: none;
}

@media (max-width: 767px) {
	.tq-cards--grid.tq-cards--phone-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 14px var(--tq-gap-m);
	}

	.tq-cards--grid.tq-cards--phone-list {
		grid-template-columns: minmax(0, 1fr);
		gap: var(--tq-gap-m);
	}

	.tq-cards--phone-list .tq-card {
		display: grid;
		grid-template-columns: 88px minmax(0, 1fr);
		align-content: start;
		gap: 2px var(--tq-gap-m);
	}

	.tq-cards--phone-list .tq-card__media {
		grid-row: 1 / span 3;
	}

	.tq-cards--phone-list .tq-badges {
		display: none;
	}

	.tq-card__title {
		font-size: 14px;
	}
}
