/**
 * Tarjeta de vehículo y rejilla, compartidas por vt/vehicle-grid y vt/vehicle-catalog.
 */

.vt-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
	gap: 20px;
}

.vt-card {
	position: relative;
	display: flex;
	flex-direction: column;
	border: 1px solid var(--wp--preset--color--line-soft, #e8e8e8);
	border-radius: var(--wp--custom--radius--card, 15px);
	overflow: hidden;
	background: #fff;
	transition: box-shadow 0.3s ease, transform 0.3s ease, border-color 0.3s ease;
}

.vt-card:hover,
.vt-card:focus-within {
	border-color: transparent;
	box-shadow: 0 18px 40px -12px rgba(31, 36, 102, 0.28);
	transform: translateY(-4px);
}

.vt-card:focus-within {
	outline: 2px solid var(--wp--preset--color--navy, #1f2466);
	outline-offset: 2px;
}

/* Flecha que aparece en la franja del título al pasar el ratón. */
.vt-card__title a {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.vt-card__title a::before {
	content: "";
	order: 2;
	width: 0;
	height: 12px;
	background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
	transition: width 0.25s ease;
}

.vt-card--usado .vt-card__title a::before {
	filter: invert(1);
}

.vt-card:hover .vt-card__title a::before {
	width: 12px;
}

.vt-card__media {
	position: relative;
	display: block;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	background: var(--wp--preset--color--surface, #f2f2f2);
}

.vt-card__media img,
.vt-card__media picture {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.45s ease;
}

/* La segunda foto queda encima, invisible, hasta pasar el ratón. */
.vt-card__media .vt-card__alt,
.vt-card__media picture:has(.vt-card__alt) {
	position: absolute;
	inset: 0;
	opacity: 0;
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
	.vt-card:hover .vt-card__media img {
		transform: scale(1.06);
	}

	.vt-card:hover .vt-card__media .vt-card__alt,
	.vt-card:hover .vt-card__media picture:has(.vt-card__alt) {
		opacity: 1;
	}
}

.vt-card__brand {
	margin: 8px 8px 4px;
	font-weight: 700;
	text-align: center;
}

.vt-card__title {
	margin: 0;
	padding: 5px;
	background: var(--wp--preset--color--blue, #333892);
	color: #fff;
	font-size: 16px;
	font-weight: 600;
	line-height: 1.3;
	text-align: center;
}

.vt-card--usado .vt-card__title {
	background: #ffb200;
	color: #000;
}

/* Toda la tarjeta es clicable a través del enlace del título. */
.vt-card__title a {
	color: inherit;
	text-decoration: none;
}

.vt-card__title a::after {
	content: "";
	position: absolute;
	inset: 0;
}

.vt-card__specs {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 2px 16px;
	margin: 0;
	padding: 12px 10px;
	list-style: none;
	color: var(--wp--preset--color--muted, #555);
	font-size: 16px;
	font-weight: 300;
	flex: 1;
	align-content: flex-start;
}

.vt-card__ref {
	margin: 0;
	padding: 1em;
	border-top: 1px solid var(--wp--preset--color--line-soft, #e8e8e8);
	background: var(--wp--preset--color--surface-soft, #fcfcfc);
	font-weight: 300;
	text-align: center;
}

.vt-card__ref strong {
	font-weight: 700;
}

.vt-card__badge {
	position: absolute;
	top: 10px;
	left: 10px;
	padding: 2px 10px;
	border-radius: 999px;
	background: var(--wp--preset--color--green, #01c548);
	color: #fff;
	font-size: 13px;
	font-weight: 600;
}

/* Móvil: dos tarjetas por fila para ver más vehículos sin tanto scroll. */
@media (max-width: 600px) {
	.vt-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 10px;
	}

	.vt-card__brand {
		font-size: 13px;
	}

	.vt-card__title {
		font-size: 13px;
	}

	.vt-card__specs {
		gap: 0 8px;
		padding: 8px 6px;
		font-size: 13px;
	}

	.vt-card__ref {
		padding: 0.6em;
		font-size: 13px;
	}
}

/* Vehículo sin fotos: icono de camión en lugar de un hueco gris. */
.vt-card__media:empty {
	background: var(--wp--preset--color--surface, #f2f2f2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 40' fill='%23c4c4c4'%3E%3Cpath d='M2 6h36v22H2zM40 14h12l8 9v5H40z'/%3E%3Ccircle cx='14' cy='32' r='5'/%3E%3Ccircle cx='50' cy='32' r='5'/%3E%3C/svg%3E") center / 72px no-repeat;
}
