/**
 * The TurfMan Core — front-end styles.
 * Mobile-first, layout-shift-safe, scoped under .tm- prefixes so it won't
 * collide with theme styles. Uses CSS custom properties for easy rebranding.
 *
 * @package TheTurfMan\Core
 */

.tm-calc,
.tm-delivery,
.tm-compare,
.tm-trust {
	--tm-primary: #1f6b2e;
	--tm-primary-2: #2e8b40;
	--tm-cta: #9a5b00;
	--tm-bg: #f6f8f6;
	--tm-surface: #ffffff;
	--tm-ink: #222b27;
	--tm-muted: #5d6b63;
	--tm-border: #dde6df;
	--tm-radius: 12px;
	--tm-space: 16px;

	box-sizing: border-box;
	color: var(--tm-ink);
	font-family: inherit;
	line-height: 1.55;
}

.tm-calc *,
.tm-delivery *,
.tm-compare *,
.tm-trust * {
	box-sizing: border-box;
}

/* ---------- Calculator + Delivery shared ---------- */
.tm-calc,
.tm-delivery {
	background: var(--tm-bg);
	border: 1px solid var(--tm-border);
	border-radius: var(--tm-radius);
	padding: clamp(16px, 4vw, 28px);
	margin: var(--tm-space) 0;
}

.tm-calc__title,
.tm-delivery__title {
	margin: 0 0 var(--tm-space);
	color: var(--tm-primary);
	font-size: 1.4rem;
}

.tm-calc__grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: var(--tm-space);
}

@media (min-width: 640px) {
	.tm-calc__grid {
		grid-template-columns: repeat(3, 1fr);
	}
}

.tm-field {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.tm-field label {
	font-weight: 600;
	font-size: 0.95rem;
}

.tm-field__input {
	width: 100%;
	padding: 12px 14px;
	border: 1px solid var(--tm-border);
	border-radius: 8px;
	background: var(--tm-surface);
	font-size: 1rem;
	min-height: 48px; /* touch target */
}

.tm-field__input:focus-visible {
	outline: 2px solid var(--tm-primary);
	outline-offset: 2px;
}

.tm-calc__result,
.tm-delivery__result {
	margin-top: var(--tm-space);
	padding: var(--tm-space);
	background: var(--tm-surface);
	border: 1px dashed var(--tm-border);
	border-radius: 8px;
	min-height: 56px; /* reserve space to prevent layout shift */
	font-size: 1.05rem;
}

/* Calculator shows up to ~2 line items + a total; reserve enough height so the
   box does not grow and shift content below it as results render. */
.tm-calc__result {
	min-height: 120px;
}

.tm-result__lines {
	list-style: none;
	margin: 0 0 8px;
	padding: 0;
}

.tm-result__lines li {
	padding: 2px 0;
}

.tm-result__total {
	margin: 8px 0 0;
	font-weight: 700;
	color: var(--tm-primary);
	font-size: 1.15rem;
}

.tm-calc__note,
.tm-delivery__note {
	margin: 10px 0 0;
	color: var(--tm-muted);
	font-size: 0.85rem;
}

.tm-calc__cta,
.tm-delivery__cta,
.tm-compare__cta {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: var(--tm-space);
}

/* ---------- Buttons ---------- */
.tm-btn {
	display: inline-block;
	padding: 12px 22px;
	border-radius: 8px;
	font-weight: 600;
	text-decoration: none;
	min-height: 48px;
	line-height: 1.5;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.tm-btn--primary {
	background: var(--tm-primary);
	color: #fff;
}

.tm-btn--primary:hover,
.tm-btn--primary:focus {
	background: #19592a; /* darker than base — AA contrast with white text */
	color: #fff;
}

.tm-btn--ghost {
	border: 2px solid var(--tm-primary);
	color: var(--tm-primary);
	background: transparent;
}

.tm-btn--ghost:hover,
.tm-btn--ghost:focus {
	background: var(--tm-primary);
	color: #fff;
}

.tm-btn:focus-visible {
	outline: 2px solid var(--tm-cta);
	outline-offset: 2px;
}

/* ---------- Tables ---------- */
.tm-table-wrap {
	overflow-x: auto;
}

.tm-table {
	width: 100%;
	border-collapse: collapse;
	margin: var(--tm-space) 0;
	background: var(--tm-surface);
}

.tm-table caption {
	text-align: left;
	padding: 8px 0;
	color: var(--tm-muted);
}

.tm-table th,
.tm-table td {
	text-align: left;
	padding: 12px 14px;
	border-bottom: 1px solid var(--tm-border);
	vertical-align: top;
}

.tm-table thead th {
	background: var(--tm-primary);
	color: #fff;
	font-size: 0.9rem;
}

.tm-table tbody tr:nth-child(even) {
	background: var(--tm-bg);
}

/* Responsive stacked table on small screens */
@media (max-width: 640px) {
	.tm-table--compare thead {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0 0 0 0);
		white-space: nowrap;
	}

	.tm-table--compare tr {
		display: block;
		margin-bottom: var(--tm-space);
		border: 1px solid var(--tm-border);
		border-radius: 8px;
		overflow: hidden;
	}

	.tm-table--compare td,
	.tm-table--compare th[scope="row"] {
		display: flex;
		justify-content: space-between;
		gap: 12px;
		border-bottom: 1px solid var(--tm-border);
	}

	.tm-table--compare td::before,
	.tm-table--compare th[scope="row"]::before {
		content: attr(data-label);
		font-weight: 600;
		color: var(--tm-muted);
	}
}

/* ---------- Compare page ---------- */
.tm-compare__intro {
	font-size: 1.05rem;
}

.tm-compare__subtitle {
	margin-top: 32px;
	color: var(--tm-primary);
}

.tm-cards {
	display: grid;
	grid-template-columns: 1fr;
	gap: var(--tm-space);
}

@media (min-width: 560px) {
	.tm-cards {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media (min-width: 900px) {
	.tm-cards {
		grid-template-columns: repeat(3, 1fr);
	}
}

.tm-card {
	background: var(--tm-surface);
	border: 1px solid var(--tm-border);
	border-radius: var(--tm-radius);
	padding: var(--tm-space);
}

.tm-card__eyebrow {
	margin: 0;
	font-size: 0.8rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	/* Use the dark primary (>=4.5:1 on white); --tm-primary-2 fails AA for text. */
	color: var(--tm-primary);
	font-weight: 700;
}

.tm-card__title {
	margin: 4px 0;
	font-size: 1.15rem;
}

.tm-card__price {
	margin: 0 0 8px;
	font-weight: 700;
	color: var(--tm-primary);
}

.tm-card__why {
	margin: 0;
	color: var(--tm-ink);
	font-size: 0.95rem;
}

/* ---------- FAQ ---------- */
.tm-faq {
	margin-top: var(--tm-space);
}

.tm-faq__item {
	border: 1px solid var(--tm-border);
	border-radius: 8px;
	margin-bottom: 10px;
	background: var(--tm-surface);
}

.tm-faq__q {
	cursor: pointer;
	padding: 14px 16px;
	font-weight: 600;
	list-style: none;
}

.tm-faq__q::-webkit-details-marker {
	display: none;
}

.tm-faq__q::after {
	content: "+";
	float: right;
	/* Dark primary for AA contrast — this marker is the open/closed affordance. */
	color: var(--tm-primary);
	font-weight: 700;
}

.tm-faq__q:focus-visible {
	outline: 2px solid var(--tm-primary);
	outline-offset: 2px;
}

.tm-faq__item[open] .tm-faq__q::after {
	content: "–";
}

.tm-faq__a {
	padding: 0 16px 14px;
}

.tm-faq__a p {
	margin: 0;
}

/* ---------- Trust strip ---------- */
.tm-trust {
	margin: var(--tm-space) 0;
}

.tm-trust__list {
	display: flex;
	flex-wrap: wrap;
	gap: 10px 18px;
	list-style: none;
	margin: 0;
	padding: 0;
}

.tm-trust__item {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	background: var(--tm-surface);
	border: 1px solid var(--tm-border);
	border-radius: 999px;
	padding: 8px 14px;
	font-size: 0.9rem;
	font-weight: 600;
}

.tm-trust__stars {
	color: #f5a623;
	letter-spacing: 1px;
}

/* ---------- Lead-capture form ---------- */
.tm-form {
	background: var(--tm-surface);
	border: 1px solid var(--tm-border);
	border-radius: var(--tm-radius);
	padding: clamp(16px, 4vw, 28px);
	margin: var(--tm-space) 0;
}
.tm-form__title { margin: 0 0 6px; color: var(--tm-primary); font-size: 1.3rem; }
.tm-form__req-note { margin: 0 0 var(--tm-space); color: var(--tm-muted); font-size: .85rem; }
.tm-form [aria-invalid="true"] { border-color: #b3261e; outline-color: #b3261e; }
.tm-form .tm-field { margin-bottom: 14px; }
.tm-form label { display: block; font-weight: 600; margin-bottom: 4px; }
.tm-form input,
.tm-form select,
.tm-form textarea {
	width: 100%;
	padding: 12px 14px;
	border: 1px solid var(--tm-border);
	border-radius: 8px;
	font-size: 1rem;
	min-height: 48px;
	background: #fff;
}
.tm-form input:focus-visible,
.tm-form select:focus-visible,
.tm-form textarea:focus-visible { outline: 2px solid var(--tm-primary); outline-offset: 2px; }
/* Honeypot — hidden from humans, present for bots. */
.tm-form__hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }
.tm-form__consent { color: var(--tm-muted); font-size: .85rem; margin: 8px 0 14px; }
.tm-form__status { margin: 12px 0 0; font-weight: 600; min-height: 1.2em; }
.tm-form__status.is-ok { color: var(--tm-primary); }
.tm-form__status.is-error { color: #b3261e; }

/* Visually hidden helper (if theme lacks one) */
.screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
	white-space: nowrap;
}
