/* Pricing table (docs/widgets/pricing.md), in the design language (spec §3.7): raised cards with their
   own colours, a pill-shaped billing switch, tinted ticks and buttons, and the accent on the
   highlighted plan. The tokens (--hafe-surface, --hafe-accent…) come from the shared design.css.

   Each card spans the same grid rows and takes them as its own, so names, prices, each feature line
   and the buttons line up across a row of cards. The billing switch is a radio button's state, so
   no script is involved. */
.hafe-pricing__sr {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/* The billing switch: a pill of its own, on our surface. */
.hafe-pricing__billing {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.25em;
	width: fit-content;
	max-width: 100%;
	box-sizing: border-box;
	min-width: 0;
	margin: 0 auto 2.5em;
	padding: 0.3em;
	border: 0;
	border-radius: 1.75em;
	background: var(--hafe-surface);
	box-shadow: var(--hafe-ring);
}

.hafe-pricing__option {
	position: relative;
}

.hafe-pricing__choice {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	opacity: 0;
	pointer-events: none;
}

/* Two classes: spec §4. */
.hafe-pricing .hafe-pricing__option label {
	cursor: pointer;
	display: block;
	margin: 0;
	padding: 0.55em 1.25em;
	border-radius: var(--hafe-pill);
	color: var(--hafe-pricing-switch-color, var(--hafe-ink-soft));
	font-weight: 600;
	transition: background-color 0.2s, color 0.2s;
}

.hafe-pricing__choice:checked + label {
	background: var(--hafe-pricing-switch-active-bg, var(--hafe-accent));
	color: var(--hafe-pricing-switch-active-color, var(--hafe-on-accent));
}

.hafe-pricing__choice:focus-visible + label {
	outline: 2px solid var(--hafe-accent);
	outline-offset: 2px;
}

.hafe-pricing__save {
	display: inline-block;
	margin-inline-start: 0.4em;
	padding: 0.15em 0.6em;
	border-radius: var(--hafe-pill);
	background: var(--hafe-tint);
	color: var(--hafe-accent-ink);
	font-size: 0.75em;
}

.hafe-pricing__choice:checked + label .hafe-pricing__save {
	background: var(--hafe-on-accent);
	color: var(--hafe-accent-ink);
}

/* What the switch chooses between. */
.hafe-pricing:has([data-period="2"]:checked) [data-shows="1"],
.hafe-pricing:not(:has([data-period="2"]:checked)) [data-shows="2"] {
	display: none;
}

@supports not selector(:has(a)) {
	.hafe-pricing__billing,
	.hafe-pricing [data-shows="2"] {
		display: none;
	}
}

/* Cards of equal height, with the buttons at the bottom. The smallest card is set in rem: a theme's
   large text would otherwise push three plans out of a narrow content column. The room above is
   for a badge, which sits on a card's top edge. */
.hafe-pricing__plans {
	display: grid;
	grid-template-columns: var(--hafe-pricing-columns, repeat(auto-fit, minmax(min(100%, 10rem), 1fr)));
	gap: var(--hafe-pricing-gap, 1.5em);
	margin: 0;
	padding: 0.9em 0 0;
	list-style: none;
}

.hafe-pricing__plan {
	position: relative;
	display: flex;
	min-width: 0;
	flex-direction: column;
	margin: 0;
	padding: var(--hafe-pricing-padding, clamp(1.75em, 12%, 2.25em) clamp(1em, 9%, 2em) clamp(1em, 9%, 2em));
	border: var(--hafe-pricing-border-width, 1px) solid var(--hafe-pricing-border, var(--hafe-line));
	border-radius: var(--hafe-pricing-radius, var(--hafe-radius));
	background: var(--hafe-pricing-bg, var(--hafe-surface));
	color: var(--hafe-pricing-color, var(--hafe-ink));
	box-shadow: var(--hafe-shadow);
}

.hafe-pricing__plan:hover {
	border-color: var(--hafe-pricing-hover-border, var(--hafe-pricing-border, var(--hafe-line)));
}

.hafe-pricing__action {
	margin-block-start: auto;
	padding-block-start: 1.75em;
}

/* With subgrid, a card takes its rows from the list, and the same parts line up. The rows between
   cards have no gap, or it would open inside every card too, so a margin keeps cards apart. Both
   margins are stated specifically enough to beat themes' rules for the last list and item. */
@supports (grid-template-rows: subgrid) {
	.hafe-pricing .hafe-pricing__plans {
		row-gap: 0;
		margin-block-end: calc(-1 * var(--hafe-pricing-gap, 1.5em));
	}

	.hafe-pricing .hafe-pricing__plan {
		display: grid;
		grid-row: span var(--hafe-pricing-rows, 3);
		grid-template-rows: subgrid;
		row-gap: 0;
		margin-block-end: var(--hafe-pricing-gap, 1.5em);
	}

	.hafe-pricing__features {
		display: grid;
		grid-row: span var(--hafe-pricing-feature-rows, 1);
		grid-template-rows: subgrid;
		row-gap: 0;
	}

	/* The row is shared, so the buttons stay level when one card has a line under its button. */
	.hafe-pricing__action {
		grid-row-end: -1;
		margin-block-start: 0;
	}
}

/* The highlighted plan: a 2px accent ring (the border plus 1px inside, so its content stays level
   with its neighbours') and a deeper shadow. */
.hafe-pricing__plan.is-highlighted {
	border-color: var(--hafe-accent);
	background: var(--hafe-pricing-highlight-bg, var(--hafe-pricing-bg, var(--hafe-surface)));
	box-shadow: inset 0 0 0 1px var(--hafe-accent), var(--hafe-shadow-up);
}

/* The hover effects move a card, so they're for a mouse, and for visitors happy with motion. The
   keyboard gets the same while it's on a card's button. */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
	.hafe-pricing--lift .hafe-pricing__plan,
	.hafe-pricing--grow .hafe-pricing__plan {
		transition: transform 0.2s ease, box-shadow 0.2s ease;
	}

	.hafe-pricing--lift .hafe-pricing__plan:is(:hover, :has(:focus-visible)) {
		box-shadow: var(--hafe-shadow-up);
		transform: translateY(-0.1em);
	}

	.hafe-pricing--lift .hafe-pricing__plan.is-highlighted:is(:hover, :has(:focus-visible)) {
		box-shadow: inset 0 0 0 1px var(--hafe-accent), var(--hafe-shadow-up);
	}

	.hafe-pricing--grow .hafe-pricing__plan:is(:hover, :has(:focus-visible)) {
		z-index: 1;
		transform: scale(1.015);
	}
}

/* A card's parts. The space below an image is on the image, so a card without one loses nothing. */
.hafe-pricing .hafe-pricing__image {
	display: block;
	width: var(--hafe-pricing-image-width, auto);
	max-width: 100%;
	height: auto;
	margin-block-end: var(--hafe-pricing-image-gap, 1em);
	--hafe-img-radius: var(--hafe-pricing-image-radius, var(--hafe-radius-sm));
}

/* The badge sits on the card's top edge, centred. */
.hafe-pricing__badge {
	position: absolute;
	top: 0;
	right: 1em;
	left: 1em;
	width: fit-content;
	margin-inline: auto;
	overflow: hidden;
	padding: 0.4em 1em;
	border-radius: var(--hafe-pill);
	background: var(--hafe-accent);
	color: var(--hafe-pricing-badge-color, var(--hafe-on-accent));
	font-size: 0.75em;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-overflow: ellipsis;
	text-transform: uppercase;
	white-space: nowrap;
	translate: 0 -50%;
}

.hafe-pricing .hafe-pricing__name {
	margin: 0;
	padding: 0;
	color: var(--hafe-pricing-name-color, inherit);
	font-size: 1.2em;
	font-weight: 600;
}

.hafe-pricing__description {
	margin: 0.35em 0 0;
	color: var(--hafe-pricing-description-color, var(--hafe-ink-soft));
	font-size: 0.95em;
}

.hafe-pricing__price {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0 0.4em;
	margin: 1.5em 0 0;
}

.hafe-pricing__amount {
	color: var(--hafe-pricing-price-color, inherit);
	font-size: 3em;
	font-weight: 700;
	letter-spacing: -0.03em;
	line-height: 1;
}

/* The currency sits high and small beside the number. */
.hafe-pricing__unit {
	margin-inline: 0.05em;
	font-size: 0.45em;
	font-weight: 600;
	letter-spacing: 0;
	vertical-align: 0.85em;
}

.hafe-pricing__period {
	color: var(--hafe-pricing-period-color, var(--hafe-ink-soft));
	font-size: 0.95em;
}

.hafe-pricing__original {
	flex-basis: 100%;
	margin-block-end: 0.3em;
	color: var(--hafe-pricing-original-color, var(--hafe-ink-soft));
	font-size: 0.95em;
	text-decoration: line-through;
}

.hafe-pricing__features {
	margin: 1.5em 0 0;
	padding: 1.1em 0 0;
	border-block-start: 1px solid var(--hafe-line);
	list-style: none;
}

.hafe-pricing__feature {
	display: flex;
	gap: 0.75em;
	margin: 0;
	padding-block: calc(var(--hafe-pricing-feature-gap, 0.6em) / 2);
	color: var(--hafe-pricing-feature-color, inherit);
}

/* Ticks in a tinted circle; what isn't included is quieter. */
.hafe-pricing__mark {
	display: inline-flex;
	flex: none;
	align-items: center;
	justify-content: center;
	inline-size: 1.4em;
	block-size: 1.4em;
	border-radius: 50%;
	background: var(--hafe-tint);
	color: var(--hafe-pricing-included, var(--hafe-accent-ink));
	line-height: 1;
}

.hafe-pricing__mark svg {
	width: 0.75em;
	height: 0.75em;
	fill: currentColor;
}

.hafe-pricing__mark i {
	font-size: 0.75em;
}

.hafe-pricing__feature.is-excluded {
	color: var(--hafe-pricing-feature-color, var(--hafe-ink-soft));
}

.hafe-pricing__feature.is-excluded .hafe-pricing__mark {
	background: none;
	color: var(--hafe-pricing-excluded, var(--hafe-ink-soft));
}

.hafe-pricing .hafe-pricing__button {
	display: block;
	padding: 0.85em 1em;
	border: 0;
	border-radius: var(--hafe-pill);
	background: var(--hafe-pricing-button-bg, var(--hafe-tint));
	color: var(--hafe-pricing-button-color, var(--hafe-accent-ink));
	font-weight: 600;
	line-height: 1.25;
	text-align: center;
	text-decoration: none;
	transition: background-color 0.2s, color 0.2s;
}

.hafe-pricing .hafe-pricing__button:hover {
	background: var(--hafe-pricing-button-hover-bg, var(--hafe-tint-strong));
	color: var(--hafe-pricing-button-hover-color, var(--hafe-pricing-button-color, var(--hafe-accent-ink)));
}

.hafe-pricing .hafe-pricing__button:focus-visible {
	outline: 2px solid var(--hafe-accent);
	outline-offset: 2px;
}

.hafe-pricing .is-highlighted .hafe-pricing__button {
	background: var(--hafe-pricing-button-bg, var(--hafe-accent));
	color: var(--hafe-pricing-button-color, var(--hafe-on-accent));
}

.hafe-pricing .is-highlighted .hafe-pricing__button:hover {
	background: var(--hafe-pricing-button-hover-bg, color-mix(in srgb, var(--hafe-accent) 85%, #000));
	color: var(--hafe-pricing-button-hover-color, var(--hafe-pricing-button-color, var(--hafe-on-accent)));
}

.hafe-pricing__note {
	margin: 0.75em 0 0;
	color: var(--hafe-pricing-note-color, var(--hafe-ink-soft));
	font-size: 0.85em;
	text-align: center;
}

@media print {
	.hafe-pricing__billing {
		display: none;
	}
}
