/**
 * Services add-on calculator.
 * Uses theme.json presets where available, with safe fallbacks, so the block
 * inherits the active theme's look instead of fighting it.
 */

.rsa-services {
	--rsa-gap: var(--wp--preset--spacing--40, 1.5rem);
	--rsa-radius: 12px;
	--rsa-border: color-mix(in srgb, currentColor 15%, transparent);
	--rsa-muted: color-mix(in srgb, currentColor 70%, transparent);
	--rsa-accent: var(--wp--preset--color--primary, #2f5bea);
	--rsa-card-bg: var(--wp--preset--color--base, #fff);
	--rsa-switch-off: #8a8f98;

	container-type: inline-size;
}

.rsa-services__heading {
	margin-block: 0 var(--rsa-gap);
}

.rsa-services__list {
	display: grid;
	gap: var(--rsa-gap);
	grid-template-columns: 1fr;
	list-style: none;
	margin: 0;
	padding: 0;
}

@container (min-width: 620px) {
	.rsa-services__list {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@container (min-width: 940px) {
	.rsa-services__list {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

.rsa-service {
	display: flex;
}

.rsa-service__card {
	background: var(--rsa-card-bg);
	border: 1px solid var(--rsa-border);
	border-radius: var(--rsa-radius);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	width: 100%;
}

.rsa-service__media {
	aspect-ratio: 16 / 9;
	overflow: hidden;
}

.rsa-service__image {
	display: block;
	height: 100%;
	object-fit: cover;
	width: 100%;
}

.rsa-service__body {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 0.75rem;
	padding: 1.25rem;
}

.rsa-service__title {
	font-size: 1.25em;
	line-height: 1.3;
	margin: 0;
}

.rsa-service__title a {
	color: inherit;
	text-decoration: none;
}

.rsa-service__title a:hover,
.rsa-service__title a:focus-visible {
	text-decoration: underline;
}

.rsa-service__excerpt {
	color: var(--rsa-muted);
	margin: 0;
}

.rsa-service__meta {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem 1.5rem;
	margin: 0;
}

.rsa-service__meta dt {
	color: var(--rsa-muted);
	font-size: 0.8125em;
}

.rsa-service__meta dd {
	font-weight: 600;
	margin: 0;
}

/* Add-ons */
.rsa-service__addons {
	border: 0;
	border-top: 1px solid var(--rsa-border);
	margin: 0;
	min-width: 0;
	padding: 0.75rem 0 0;
}

.rsa-service__legend {
	font-weight: 600;
	margin-bottom: 0.5rem;
	padding: 0;
}

.rsa-addon {
	align-items: center;
	display: flex;
	gap: 0.75rem;
	padding-block: 0.375rem;
}

/* Native checkbox restyled as a switch: keeps keyboard support (Space) and
   the checked state exposed to assistive tech via role="switch". */
.rsa-addon__input {
	appearance: none;
	background: var(--rsa-switch-off);
	border-radius: 999px;
	cursor: pointer;
	flex: 0 0 auto;
	height: 1.5rem;
	margin: 0;
	position: relative;
	transition: background-color 0.15s ease;
	width: 2.625rem;
}

.rsa-addon__input::after {
	background: #fff;
	border-radius: 50%;
	box-shadow: 0 1px 2px rgb(0 0 0 / 0.3);
	content: "";
	height: 1.125rem;
	inset-block-start: 0.1875rem;
	inset-inline-start: 0.1875rem;
	position: absolute;
	transition: transform 0.15s ease;
	width: 1.125rem;
}

.rsa-addon__input:checked {
	background: var(--rsa-accent);
}

.rsa-addon__input:checked::after {
	transform: translateX(1.125rem);
}

[dir="rtl"] .rsa-addon__input:checked::after {
	transform: translateX(-1.125rem);
}

.rsa-addon__input:focus-visible {
	outline: 2px solid var(--rsa-accent);
	outline-offset: 2px;
}

.rsa-addon__label {
	cursor: pointer;
	display: flex;
	flex: 1;
	gap: 0.5rem;
	justify-content: space-between;
}

.rsa-addon__price {
	color: var(--rsa-muted);
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

/* Live estimate */
.rsa-service__estimate {
	align-items: baseline;
	border-top: 1px solid var(--rsa-border);
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 0.5rem;
	margin: auto 0 0;
	padding-top: 0.75rem;
}

.rsa-service__total {
	font-size: 1.375em;
	font-variant-numeric: tabular-nums;
}

.rsa-service__eta {
	color: var(--rsa-muted);
	flex-basis: 100%;
	font-size: 0.875em;
}

.rsa-services__empty {
	border: 1px dashed var(--rsa-border);
	border-radius: var(--rsa-radius);
	padding: 1rem;
}

@media (forced-colors: active) {
	.rsa-addon__input {
		border: 1px solid ButtonText;
	}

	.rsa-addon__input:checked {
		background: Highlight;
	}
}

@media (prefers-reduced-motion: reduce) {
	.rsa-addon__input,
	.rsa-addon__input::after {
		transition: none;
	}
}
