/*
 * Service related.
 *
 * Same rules as every component stylesheet: design-system `--btx-*` tokens
 * only, a fallback on every var(). See cta-button/style.css for the full note.
 *
 * Ink for the section and the card is computed in PHP against whatever an
 * editor picked and arrives as `--btxc-related-*`. The accent paints the rule
 * under the link and nothing else — no type is set in it, which is what lets
 * it be a bright green against a 3:1 graphics floor rather than a 4.5:1
 * reading one.
 */

@layer bertex-components {

	.btxc-related {
		--btxc-related-bg: transparent;
		--btxc-related-ink: var( --btx-color-primary-1, #1a2744 );
		--btxc-related-card-bg: transparent;
		--btxc-related-card-ink: var( --btx-color-primary-1, #1a2744 );
		--btxc-related-card-quiet: var( --btx-color-primary-1-light-40, #2e4578 );
		--btxc-related-accent: var( --btxc-related-card-ink );

		box-sizing: border-box;
		padding-block: var( --btx-spacing-xl, 3rem );
		padding-inline: var( --btx-spacing-m, 1.25rem );

		background: var( --btxc-related-bg );
		color: var( --btxc-related-ink );
	}

	.btxc-related__inner {
		box-sizing: border-box;
		max-width: var( --btx-max-width, 1440px );
		margin-inline: auto;

		display: flex;
		flex-direction: column;
		gap: var( --btx-spacing-m, 1.375rem );
	}

	.btxc-related__heading {
		margin: 0;

		font-family: var( --btx-font-heading-family, inherit );
		font-size: var( --btx-font-heading-m, 1.75rem );
		font-weight: 600;
		line-height: var( --btx-line-height-heading, 1.2 );
		color: var( --btxc-related-ink );
	}

	/*
	 * `auto-fit` with a minimum rather than a fixed count, the same reason
	 * card-grid.php gives: the container decides how many fit, so six cards
	 * become three and two without a breakpoint per count.
	 */
	.btxc-related__grid {
		margin: 0;
		padding: 0;
		list-style: none;

		display: grid;
		grid-template-columns: repeat( auto-fit, minmax( min( 100%, 15rem ), 1fr ) );
		gap: var( --btx-spacing-m, 1.25rem );
	}

	.btxc-related__card {
		position: relative;
		box-sizing: border-box;

		display: flex;
		flex-direction: column;
		gap: var( --btx-spacing-xs, 0.625rem );

		padding: var( --btx-card-spacing, 1.5rem );

		background: var( --btxc-related-card-bg );
		color: var( --btxc-related-card-ink );
		border: 1px solid color-mix( in srgb, var( --btxc-related-card-ink ) 16%, transparent );
		border-radius: var( --btx-border-radius-m, 0.75rem );

		transition: border-color 0.18s ease;
	}

	.btxc-related__card:hover {
		border-color: color-mix( in srgb, var( --btxc-related-card-ink ) 40%, transparent );
	}

	/*
	 * Bare `monospace`, the same deliberate exception the other components
	 * make: the design system publishes a heading family and a body family and
	 * no third. See the note in booking-panel/style.css.
	 */
	.btxc-related__label {
		margin: 0;

		font-family: monospace;
		font-size: var( --btx-font-body-xs, 0.75rem );
		letter-spacing: 0.1em;
		text-transform: uppercase;
		line-height: var( --btx-line-height-body, 1.5 );
		color: var( --btxc-related-card-quiet );
	}

	.btxc-related__title {
		margin: 0;

		font-family: var( --btx-font-heading-family, inherit );
		font-size: var( --btx-font-body-lg, 1.25rem );
		font-weight: 600;
		line-height: var( --btx-line-height-heading, 1.25 );
		text-wrap: pretty;
	}

	/*
	 * One focusable element per card, stretched over the whole card by the
	 * ::after — the same arrangement `info-card`, `post-card` and
	 * `service-menu` use. The title is the link's accessible name, so a screen
	 * reader hears what it goes to rather than "see the detail, link".
	 */
	.btxc-related__link {
		color: inherit;
		text-decoration: none;
	}

	.btxc-related__link::after {
		content: "";
		position: absolute;
		inset: 0;
		border-radius: inherit;
	}

	.btxc-related__cta {
		align-self: flex-start;
		margin-top: auto;
		padding-top: var( --btx-spacing-xs, 0.5rem );

		display: inline-flex;
		align-items: center;
		gap: var( --btx-spacing-xxs, 0.4rem );

		font-size: var( --btx-font-body-s, 0.9375rem );
		font-weight: 600;
		line-height: var( --btx-line-height-heading, 1.3 );
		color: var( --btxc-related-card-ink );

		/* The accent, and the only thing painted in it. `align-self` keeps the
		 * rule as wide as the label and arrow rather than the whole card. */
		border-block-end: 2px solid var( --btxc-related-accent );
		padding-block-end: 2px;
	}

	.btxc-related__arrow {
		transition: transform 0.18s ease;
	}

	.btxc-related__card:hover .btxc-related__arrow {
		transform: translateX( 3px );
	}

	.btxc-related__card:has( .btxc-related__link:focus-visible ) {
		outline: 2px solid var( --btxc-related-card-ink );
		outline-offset: 3px;
	}

	.btxc-related__link:focus-visible {
		outline: none;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	@layer bertex-components {
		.btxc-related__card,
		.btxc-related__arrow {
			transition: none;
		}

		.btxc-related__card:hover .btxc-related__arrow {
			transform: none;
		}
	}
}
