/*
 * Post list.
 *
 * 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.
 *
 * Two surfaces — the section and the panel the rows sit in — each measured in
 * PHP and arriving as `--btxc-plist-*`. Nothing here names a colour token for
 * type.
 *
 * The rules between rows are drawn by mixing the row ink down to a fraction of
 * itself rather than by naming a hairline token, the same reasoning
 * faq-list/style.css gives: the panel can be paper or navy, and one named
 * token cannot be right on both. Graphic work, judged against the 3:1 floor.
 */

@layer bertex-components {

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

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

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

	.btxc-plist__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.25rem );
	}

	.btxc-plist__heading {
		margin: 0;

		font-family: var( --btx-font-heading-family, inherit );
		font-size: var( --btx-font-heading-m, 1.875rem );
		font-weight: 700;
		line-height: var( --btx-line-height-heading, 1.1 );
		letter-spacing: -0.02em;
		color: var( --btxc-plist-ink );
	}

	/*
	 * The panel. `overflow: hidden` is what lets the first and last rows sit
	 * inside the radius without each needing a corner of its own.
	 */
	.btxc-plist__table {
		margin: 0;
		padding: 0;
		list-style: none;

		background: var( --btxc-plist-row-bg );
		color: var( --btxc-plist-row-ink );
		border: 1px solid color-mix( in srgb, var( --btxc-plist-row-ink ) 14%, transparent );
		border-radius: var( --btx-border-radius-lg, 0.875rem );
		overflow: hidden;
	}

	/* With no panel the border and radius go too, and the rows rule against
	 * the section instead. */
	.btxc-plist--bare .btxc-plist__table {
		border: 0;
		border-radius: 0;
	}

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

		display: flex;
		align-items: center;
		justify-content: space-between;
		flex-wrap: wrap;
		gap: var( --btx-spacing-m, 1.75rem );

		padding: var( --btx-spacing-m, 1.375rem ) var( --btx-spacing-m, 1.625rem );

		transition: background 0.16s ease;
	}

	/*
	 * A rule above every row but the first, so the panel reads as a table
	 * rather than a stack of boxes. `+` rather than `:not(:first-child)` keeps
	 * it correct if rows are ever reordered by the grid.
	 */
	.btxc-plist__row + .btxc-plist__row {
		border-top: 1px solid color-mix( in srgb, var( --btxc-plist-row-ink ) 14%, transparent );
	}

	.btxc-plist__row:hover {
		background: color-mix( in srgb, var( --btxc-plist-row-ink ) 4%, transparent );
	}

	.btxc-plist__copy {
		display: flex;
		flex-direction: column;
		gap: var( --btx-spacing-xxs, 0.375rem );

		min-width: 0;
	}

	.btxc-plist__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;
		color: var( --btxc-plist-row-ink );
	}

	/*
	 * One focusable element per row, stretched over it — the arrangement
	 * post-card, info-card and service-menu already use. The headline is the
	 * link's accessible name, so a screen reader hears the article rather than
	 * an arrow.
	 */
	.btxc-plist__link {
		color: inherit;
		text-decoration: none;
	}

	.btxc-plist__link::after {
		content: "";
		position: absolute;
		inset: 0;
	}

	.btxc-plist__excerpt {
		margin: 0;

		max-width: 60ch;

		font-size: var( --btx-font-body-s, 0.9375rem );
		line-height: var( --btx-line-height-body, 1.5 );
		color: var( --btxc-plist-row-quiet );
	}

	/*
	 * 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-plist__aside {
		display: flex;
		align-items: center;
		gap: var( --btx-spacing-m, 1.375rem );

		white-space: nowrap;
		font-family: monospace;
		font-size: var( --btx-font-body-xs, 0.8125rem );
		color: var( --btxc-plist-row-quiet );
	}

	.btxc-plist__arrow {
		font-family: var( --btx-font-body-family, inherit );
		font-size: var( --btx-font-body-m, 1.125rem );
		color: var( --btxc-plist-row-ink );

		transition: transform 0.16s ease;
	}

	.btxc-plist__row:hover .btxc-plist__arrow {
		transform: translateX( 3px );
	}

	.btxc-plist__row:has( .btxc-plist__link:focus-visible ) {
		outline: 2px solid var( --btxc-plist-row-ink );
		outline-offset: -2px;
	}

	/* ── Narrow ────────────────────────────────────────────────────────── */

	/*
	 * The topic and date stop being an end-of-row column and go under the
	 * standfirst, which is the only place left for them once the headline has
	 * the width.
	 */
	@media ( width < 48rem ) {
		.btxc-plist__row {
			align-items: flex-start;
			flex-direction: column;
			gap: var( --btx-spacing-xs, 0.625rem );
		}

		.btxc-plist__aside {
			gap: var( --btx-spacing-s, 1rem );
		}
	}
}

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

		.btxc-plist__row:hover .btxc-plist__arrow {
			transform: none;
		}
	}
}
