/**
 * Truck Sales — frontend styles.
 *
 * Deliberately minimal and neutral: fonts, text colors and button styling are
 * inherited from the active theme (cards use `currentColor` and inherit),
 * so the listings automatically match the theme design.
 *
 * @package Truck_Sales
 */

/* -------------------------------------------------------------------------
 * Grid
 * ------------------------------------------------------------------------- */

.ts-grid {
	--ts-cols: 3;
	display: grid;
	grid-template-columns: repeat(var(--ts-cols), minmax(0, 1fr));
	gap: 2rem 2.75rem;
	margin: 0 0 2rem;
}

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

@media (max-width: 640px) {
	.ts-grid {
		grid-template-columns: 1fr;
	}
}

/* Equal card heights in a row, even if the theme overrides grid stretching. */
.ts-grid > article.ts-card,
.ts-grid > .ts-card {
	align-self: stretch;
	box-sizing: border-box;
	height: auto;
}

/* -------------------------------------------------------------------------
 * Card
 * ------------------------------------------------------------------------- */

.ts-card {
	display: flex;
	flex-direction: column;
	position: relative;
	box-sizing: border-box;
	overflow: hidden;
	border: 0;
	border-radius: 8px;
	background: transparent;
	color: inherit;
	font: inherit;
}

.ts-card__media {
	display: block;
	line-height: 0;
}

.ts-card__media img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 4 / 3;
	object-fit: cover;
}

.ts-card__placeholder {
	display: block;
	aspect-ratio: 4 / 3;
	background: rgba(128, 128, 128, 0.12) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1.5 7h12v10h-12z'/%3E%3Cpath d='M13.5 11h4l3 3v3h-7z'/%3E%3Ccircle cx='6' cy='17.5' r='1.7'/%3E%3Ccircle cx='17' cy='17.5' r='1.7'/%3E%3C/svg%3E") center / 35% no-repeat;
}

.ts-card__badge {
	position: absolute;
	top: 0.75rem;
	left: 0.75rem;
	z-index: 1;
	padding: 0.25em 0.8em;
	border-radius: 999px;
	background: #b91c1c;
	color: #fff;
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.ts-card__body {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 0.5rem;
	padding: 1.25rem 0 0;
}

.ts-card__title {
	margin: 0;
	font-size: 1.15em;
	line-height: 1.3;
}

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

.ts-card__title a:hover,
.ts-card__title a:focus {
	text-decoration: underline;
}

/* Subtle separator between card rows. Uses currentColor at low opacity,
 * so it looks like a soft white line on dark themes and dark on light ones. */
.ts-card .ts-card__divider {
	width: 100%;
	height: 0;
	margin: 0.4rem 0;
	padding: 0;
	border: 0;
	border-top: 1px solid currentColor;
	background: none;
	opacity: 0.25;
}

.ts-card__specs {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem 1rem;
	margin: 0;
	padding: 0;
	list-style: none;
	font-size: 0.9em;
	opacity: 0.8;
}

/* Icon + text alignment is done with inline-block and a small negative
 * vertical-align instead of flexbox: it renders identically in Chrome and
 * Firefox and cannot be broken by theme "li" or "svg" rules. */
.ts-card .ts-card__specs .ts-card__spec {
	margin: 0;
	padding: 0;
	line-height: 1.4;
}

.ts-card .ts-card__specs .ts-card__spec .ts-icon {
	display: inline-block;
	width: 1em;
	height: 1em;
	margin: 0 0.3em 0 0;
	vertical-align: -0.15em;
}

.ts-card__condition {
	display: -webkit-box;
	margin: 0;
	overflow: hidden;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	font-size: 0.95em;
	opacity: 0.85;
}

.ts-card__price {
	margin: 0 0 0.75rem;
	padding-top: 0.75rem;
	font-size: 1.15em;
	font-weight: 700;
}

/* Buttons inherit the theme look; this is only a neutral fallback. */
.ts-card__button,
.ts-empty__button,
.ts-truck__contact {
	display: inline-block;
	align-self: flex-start;
	box-sizing: border-box;
	margin-top: 0.5rem;
	padding: 0.55em 1.4em;
	border: 1px solid currentColor;
	border-radius: 4px;
	color: inherit;
	font: inherit;
	font-weight: 600;
	line-height: 1.4;
	text-align: center;
	text-decoration: none;
	transition: opacity 0.2s ease;
}

.ts-card__button:hover,
.ts-card__button:focus,
.ts-empty__button:hover,
.ts-empty__button:focus,
.ts-truck__contact:hover,
.ts-truck__contact:focus {
	opacity: 0.75;
	text-decoration: none;
}

/* Full-width card button, pinned to the bottom of the card.
 * High specificity + inline-block so theme flex/grid button styles
 * cannot break the two-line text layout. */
.ts-card .ts-card__body .ts-card__button {
	display: inline-block;
	align-self: stretch;
	box-sizing: border-box;
	width: 100%;
	margin-top: auto;
	line-height: 1.4;
	text-align: center;
	white-space: normal;
}

/* -------------------------------------------------------------------------
 * Empty state
 * ------------------------------------------------------------------------- */

.ts-empty {
	padding: 3rem 1.5rem;
	border: 1px dashed rgba(128, 128, 128, 0.45);
	border-radius: 8px;
	text-align: center;
}

.ts-empty p {
	margin: 0 0 1rem;
}

.ts-empty p:last-child {
	margin-bottom: 0;
}

/* -------------------------------------------------------------------------
 * Single vehicle
 * ------------------------------------------------------------------------- */

.ts-truck__layout {
	display: grid;
	grid-template-columns: 3fr 2fr;
	gap: 2rem;
	margin: 1.5rem 0;
}

@media (max-width: 768px) {
	.ts-truck__layout {
		grid-template-columns: 1fr;
	}
}

.ts-truck__media img {
	display: block;
	width: 100%;
	height: auto;
	border-radius: 8px;
}

.ts-truck__placeholder {
	border-radius: 8px;
}

.ts-specs {
	margin: 0 0 1rem;
	overflow: hidden;
	border: 1px solid rgba(128, 128, 128, 0.3);
	border-radius: 8px;
}

.ts-specs__row {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.6rem 1rem;
}

.ts-specs__row + .ts-specs__row {
	border-top: 1px solid rgba(128, 128, 128, 0.2);
}

.ts-specs__row:nth-child(odd) {
	background: rgba(128, 128, 128, 0.08);
}

.ts-specs dt {
	margin: 0;
	font-weight: 600;
}

.ts-specs dd {
	margin: 0;
	text-align: right;
}

.ts-price {
	margin: 0.5rem 0 1rem;
	font-size: 1.5em;
	font-weight: 700;
}

.ts-truck__condition {
	opacity: 0.85;
}

.ts-truck__phone,
.ts-truck__email {
	margin: 0.5rem 0 0;
}

.ts-truck__back-wrap {
	margin: 1.5rem 0 0;
}

.ts-truck__content {
	margin-top: 2rem;
}

/* -------------------------------------------------------------------------
 * Archive
 * ------------------------------------------------------------------------- */

.ts-archive .page-header {
	margin-bottom: 1.5rem;
}

.ts-archive .navigation {
	margin-top: 2rem;
}

/* Accessibility helper in case the active theme does not define it. */
.ts-card .screen-reader-text,
.ts-truck .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}
