/*
 * TABS-5: numbered tiles as tabs.
 * The tabs are tiles of one size that share the width, each under its number.
 * The number is drawn by the stylesheet from the place of the tab, so it is
 * right whatever staff add, remove or move. The open tile stands on a soft
 * ground under a line in the accent colour.
 */

.wprk-tabs-5 .wprk-tabs-5__tabs {
	margin-block: 0;
}

.wprk-tabs-5 .wprk-tabs > .wp-block-tab-list {
	border-block-end: 0;
	box-shadow: none;
	counter-reset: wprk-tabs-5;
	display: grid;
	flex-grow: 0;
	--wprk-tabs-gap: var(--wp--preset--spacing--20);
	gap: var(--wprk-tabs-gap);
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5rem), 1fr));
}

.wprk-tabs-5 .wprk-tabs > .wp-block-tab-list button {
	align-items: flex-start;
	border: 1px solid var(--wprk-border);
	border-radius: var(--wp--custom--radius--lg);
	box-shadow: none;
	color: var(--wprk-fg);
	counter-increment: wprk-tabs-5;
	display: flex;
	flex-direction: column-reverse;
	gap: var(--wp--preset--spacing--20);
	justify-content: flex-end;
	margin-block-end: 0;
	overflow: hidden;
	padding: var(--wp--preset--spacing--40);
	text-align: start;
	white-space: normal;
	width: 100%;
}

/* The number. It is decoration: a screen reader already says "tab 2 of 4". */
.wprk-tabs-5 .wprk-tabs > .wp-block-tab-list button::after {
	color: var(--wprk-accent-text);
	content: counter(wprk-tabs-5, decimal-leading-zero);
	content: counter(wprk-tabs-5, decimal-leading-zero) / "";
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--x-large);
	font-weight: var(--wp--custom--heading--weight, 600);
	line-height: 1;
}

.wprk-tabs-5 .wprk-tabs > .wp-block-tab-list button:hover {
	border-color: color-mix(in srgb, var(--wprk-heading) 45%, transparent);
	color: var(--wprk-heading);
}

.wprk-tabs-5 .wprk-tabs > .wp-block-tab-list button[aria-selected="true"] {
	background-color: var(--wprk-soft);
	color: var(--wprk-heading);
}

/* The line WordPress draws under the open tab lies along the top of the tile. */
.wprk-tabs-5 .wprk-tabs > .wp-block-tab-list button[aria-selected="true"]::before {
	border-block-end: 3px solid var(--wprk-accent);
	inset-block: 0 auto;
}

.wprk-tabs-5 .wprk-tabs > .wp-block-tab-list button:focus-visible {
	outline-offset: 3px;
}

.wprk-tabs-5 .wp-block-tab-panel {
	margin-inline: auto;
	max-width: 44rem;
}

/*
 * On a phone the tiles stand in one line that is moved sideways (tabs.css),
 * still of one size. The row keeps room for the ring of the keyboard, which a
 * row that scrolls would cut off.
 */
@media (max-width: 599px) {
	/* WordPress has a tile take its width in the row from the row itself, so the row is told. */
	.wprk-tabs-5 .wprk-tabs > .wp-block-tab-list {
		display: flex;
		flex-basis: 9.5rem;
		flex-grow: 1;
		--wprk-tabs-room: 0.375rem;
		margin: calc(0px - var(--wprk-tabs-room));
		padding: var(--wprk-tabs-room);
	}
}

@media (prefers-reduced-motion: no-preference) {
	.wprk-tabs-5 .wprk-tabs > .wp-block-tab-list button {
		transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
	}
}
