/* IDE Downloads — frontend styles. Self-contained; Avada CSS variables are
   used only as optional fallbacks, never as a hard dependency. */

.ide-downloads {
	--ide-dl-text: var(--awb-text-color, #283253); /* rgb(40, 50, 83) — IDE text colour */
	--ide-dl-card-bg: var(--awb-color7, #f2f2f2);
	font-family: var(--ide-dl-font, 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
}

/*
 * `columns` is a maximum, not a fixed count: each track's minimum width is
 * "what 1/N of the available space would be" (clamped to a 160px floor for
 * readability). At that minimum, exactly N columns fit — never more, since
 * a further column would have to be narrower than the minimum. When the
 * container is too narrow for N columns of >=160px, the column count steps
 * down on its own, continuously, with no fixed breakpoint.
 *
 * auto-fill (not auto-fit): with fewer items than columns, auto-fit would
 * collapse the empty tracks and stretch the remaining item(s) to fill the
 * row — a single document would blow up to full width. auto-fill keeps the
 * empty tracks reserved instead, so 1 item stays one column wide, 2 items
 * stay two columns wide, etc.
 *
 * align-items:stretch is what makes every card in the same row match the
 * row's tallest card, so a one-line and a two-line title never create a
 * visual "step" between neighbouring cards — the card itself then
 * distributes that extra height into its title area (see
 * .ide-dl-card-title below).
 */
.ide-dl-grid {
	--ide-dl-gap: 2rem;
	display: grid;
	align-items: stretch;
	gap: var(--ide-dl-gap);
	grid-template-columns: repeat(
		auto-fill,
		minmax(max(160px, (100% - (var(--ide-dl-cols, 4) - 1) * var(--ide-dl-gap)) / var(--ide-dl-cols, 4)), 1fr)
	);
}

@media (max-width: 480px) {
	.ide-dl-grid {
		grid-template-columns: 1fr;
	}
}

/* ---------- Card ---------- */

/* Flat fill, square corners, no border — reads as part of the layout, not a
   boxed widget. The whole card is a link to the protected download. */
.ide-dl-card {
	background: var(--ide-dl-card-bg);
	display: flex;
	flex-direction: column;
	text-align: left;
	text-decoration: none;
	color: inherit;
}

.ide-dl-card:hover .ide-dl-card-title {
	text-decoration: underline;
}

/*
 * One frame for every card, regardless of where the image came from (the
 * selected preview, a same-name image, the generated PDF first page, the
 * language default or the SVG placeholder) — .ide-dl-media alone owns aspect
 * ratio, background, padding, centring and overflow; the <img> inside never
 * changes that, only its own content does. aspect-ratio 4/5 (portrait, not
 * the 16/9 "video" shape) gives a certificate's own A4-ish proportions room
 * to use. object-fit:contain + padding on the frame means the image is
 * always shown whole, centred, never cropped or stretched — cover would
 * crop a tall A4 certificate's top/bottom (title, signature, seal) to fill
 * the box, which is wrong for a document page even though it's fine for an
 * ordinary photo.
 */
.ide-dl-media {
	position: relative;
	aspect-ratio: 4 / 5;
	background: var(--ide-dl-card-bg);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 12px;
	overflow: hidden;
}

.ide-dl-thumb {
	width: 100%;
	height: 100%;
	display: block;
	object-fit: contain;
}

/* Caption sits centred under the thumbnail, close to it. flex-grow +
   centred content is what lets the extra height a stretched row hands this
   card land as balanced padding around a one-line title, instead of the
   title clinging to the top while the rest of the card is dead space.
   min-height reserves room for two lines so a one-line and a two-line
   neighbour still occupy the same footprint before the row is even
   measured. */
.ide-dl-card-title {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-grow: 1;
	min-height: calc(1.35em * 2 + 16px);
	margin: 0;
	padding: 8px 12px;
	font-size: 14px;
	font-weight: 500;
	line-height: 1.35;
	text-align: center;
	color: var(--ide-dl-text);
}
