/**
 * vehicle-configurator/model-cards — scoped .vc- base styles.
 * Consumes at-theme tokens with neutral fallbacks; the theme may skin
 * further via its own CSS.
 */

.vc-model-cards__grid {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	/* Container-adaptive: 2-up in a narrow column, more cells across a
	 * full mega-menu panel. */
	grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
	gap: 1rem;
	column-gap: 2rem;
}

.vc-model-card__media {
	position: relative;
	display: block;
	/* Ratio is a block option (mirrors core Image); render.php sets the
	 * custom property from the aspectRatio attribute. */
	aspect-ratio: var(--vc-model-card-ratio, 16 / 10);
	border-radius: var(--wp--custom--border-radius--default, 4px);
	overflow: hidden;
}

.vc-model-card__img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: var(--vc-model-card-fit, cover);
	opacity: 0;
	transition: opacity 0.25s ease;
}

.vc-model-card__img.is-active {
	opacity: 1;
}

.vc-model-card__img--placeholder {
	background: var(--wp--preset--color--light-grey, #e5e5e5);
}

/* Natural ("original") mode: no fixed ratio. The model's own image renders
 * in-flow to set the box height; swap (per-Build) images keep overlaying it
 * absolutely. object-fit is irrelevant here — the box matches the image. */
.vc-model-cards--natural .vc-model-card__media {
	aspect-ratio: auto;
}

.vc-model-cards--natural .vc-model-card__img:not([data-build]) {
	position: relative;
	width: 100%;
	height: auto;
}

/* No featured image: keep a sensible box so the card does not collapse. */
.vc-model-cards--natural .vc-model-card__img--placeholder {
	aspect-ratio: 16 / 10;
}

/* Card-level natural mode — the stand-alone vehicle-configurator/model-card
 * block has no grid wrapper, so it carries the modifier on the card root. */
.vc-model-card--natural .vc-model-card__media {
	aspect-ratio: auto;
}

.vc-model-card--natural .vc-model-card__img:not([data-build]) {
	position: relative;
	width: 100%;
	height: auto;
}

.vc-model-card--natural .vc-model-card__img--placeholder {
	aspect-ratio: 16 / 10;
}

/* Media-level natural mode — in the composed card (inner blocks) the
 * model-media block owns the ratio attrs and carries the modifier itself. */
.vc-model-card__media.is-natural {
	aspect-ratio: auto;
}

.vc-model-card__media.is-natural .vc-model-card__img:not([data-build]) {
	position: relative;
	width: 100%;
	height: auto;
}

.vc-model-card__media.is-natural .vc-model-card__img--placeholder {
	aspect-ratio: 16 / 10;
}

/* Composed card (inner blocks) — no __body wrapper, so the direct children
 * get the body's spacing/centering. core/post-title in the default template
 * carries the vc-model-card__title class for existing theme skins. */
.vc-model-card--composed .vc-model-card__title,
.vc-model-card--composed .wp-block-post-title {
	margin: 0.625rem 0 0;
	text-align: center;
}

.vc-model-card--composed .vc-model-card__builds {
	margin-top: 0.25rem;
}

.vc-model-card--composed .wp-block-post-title a {
	text-decoration: none;
	color: inherit;
}

.vc-model-card--composed .wp-block-post-title a:hover {
	color: var(--wp--preset--color--original-blue, #0071ce);
}

.vc-model-card__badge {
	position: absolute;
	top: 8px;
	left: 8px;
	z-index: 1;
	padding: 0.3em 0.7em;
	background: var(--wp--preset--color--original-blue, #0071ce);
	color: var(--wp--preset--color--white, #fff);
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.02em;
	border-radius: var(--wp--custom--border-radius--default, 4px);
}

.vc-model-card__body {
	margin-top: 0.625rem;
	text-align: center;
}

.vc-model-card__title {
	display: block;
	text-decoration: none;
	color: inherit;
}

.vc-model-card__title:hover {
	color: var(--wp--preset--color--original-blue, #0071ce);
}

.vc-model-card__builds {
	list-style: none;
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 4px;
	margin: 0;
	padding: 0;
}

.vc-model-card__chip {
	display: inline-flex;
	padding: 0.25em;
	border-radius: var(--wp--custom--border-radius--default, 4px);
	font-size: 0.8125rem;
	font-weight: 600;
	text-decoration: none;
	color: inherit;
	transition: border-color 150ms ease, color 150ms ease;
}

.vc-model-card__chip:hover,
.vc-model-card__chip:focus-visible {
	border-color: var(--wp--preset--color--original-blue, #0071ce);
	color: var(--wp--preset--color--original-blue, #0071ce);
	text-decoration: none;
}
