/*
 * taikinapoika/recipe (the companion plugin's block) as the recipe card:
 * white paper with a tomato top edge, ingredients on ruled lines, steps
 * numbered in butter circles, the closing tip in handwriting.
 *
 * The plugin ships the structure; this is the look. The class names are the
 * contract between the two (SPEC, section 4.1).
 */

.tp-recipe {
	background: var(--wp--preset--color--paper);
	border-radius: var(--wp--custom--radius--card);
	border-top: 6px solid var(--wp--preset--color--tomato);
	box-shadow: var(--wp--preset--shadow--card);
	clear: both;
	color: var(--wp--preset--color--contrast);
	padding: clamp(1.375rem, 4vw, 3rem);
}

/* In a post the card takes the wide measure, like a wide-aligned block. */
.tpt-left > .wp-block-taikinapoika-recipe:not(.alignfull) {
	margin-block-start: clamp(3rem, 7vw, 5.5rem);
	margin-inline: auto !important;
	max-width: var(--wp--style--global--wide-size);
}

/* The author decides what is hidden; a display value here must not undo it. */
.tp-recipe [hidden] {
	display: none !important;
}

/* ---- Header: kicker and title on one side, the two buttons on the other ---- */

.tp-recipe__header {
	align-items: center;
	column-gap: 2rem;
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
}

.tp-recipe .tp-recipe__kicker {
	color: var(--wp--preset--color--tomato-text);
	font-size: 0.875rem;
	font-weight: 800;
	grid-column: 1;
	letter-spacing: 0.1em;
	line-height: 1.6;
	margin: 0;
	text-transform: uppercase;
}

/* Two classes: a heading's size and face must outrank theme.json's rules for h2, which WordPress prints later. */
.tp-recipe .tp-recipe__title {
	font-family: var(--wp--preset--font-family--display);
	font-size: clamp(1.875rem, 4vw, 2.75rem);
	font-weight: 400;
	grid-column: 1;
	letter-spacing: -0.015em;
	line-height: 1.05;
	margin: 0.125rem 0 0;
}

.tp-recipe__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.625rem;
	grid-column: 2;
	grid-row: 1 / span 2;
	margin: 0;
}

.tp-recipe__actions button {
	align-items: center;
	background: var(--wp--preset--color--paper);
	border: 2px solid var(--wp--preset--color--contrast);
	border-radius: var(--wp--custom--radius--pill);
	color: var(--wp--preset--color--contrast);
	cursor: pointer;
	display: inline-flex;
	font: inherit;
	font-size: 1rem;
	font-weight: 800;
	line-height: 1.2;
	min-height: 3rem;
	padding: 0.25rem 1.375rem;
}

.tp-recipe__actions button:hover,
.tp-recipe__actions button:focus {
	background: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
}

.tp-recipe__actions .tp-recipe__awake {
	background: var(--wp--preset--color--tomato);
	border-color: var(--wp--preset--color--tomato);
	color: var(--wp--preset--color--paper);
}

.tp-recipe__actions .tp-recipe__awake:hover,
.tp-recipe__actions .tp-recipe__awake:focus {
	background: var(--wp--preset--color--tomato-dark);
	border-color: var(--wp--preset--color--tomato-dark);
	color: var(--wp--preset--color--paper);
}

/* Switched on: ink. The plugin changes the button's words as well, so the state does not rest on colour alone. */
.tp-recipe__actions .tp-recipe__awake[aria-pressed="true"] {
	background: var(--wp--preset--color--contrast);
	border-color: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
}

@media (max-width: 40rem) {

	.tp-recipe__header {
		grid-template-columns: minmax(0, 1fr);
	}

	.tp-recipe__actions {
		grid-column: 1;
		grid-row: auto;
		margin-block-start: 0.875rem;
	}
}

/* ---- Facts: oven, time, tin ---- */

.tp-recipe__facts {
	display: flex;
	flex-wrap: wrap;
	font-size: 1rem;
	font-weight: 700;
	gap: 0.5rem;
	list-style: none;
	margin: 1rem 0 0;
	padding: 0;
}

.tp-recipe__facts > li {
	background: var(--wp--preset--color--base);
	border-radius: var(--wp--custom--radius--pill);
	margin: 0;
	padding: 0.375rem 0.875rem;
}

/* ---- Body: ingredients beside the method ---- */

.tp-recipe__body {
	display: flex;
	flex-wrap: wrap;
	gap: 2.25rem 4rem;
	margin-block-start: 2rem;
}

.tp-recipe__ingredients {
	flex: 1 1 18rem;
	min-width: 0;
}

.tp-recipe__method {
	flex: 1.8 1 26rem;
	min-width: 0;
}

.tp-recipe__body h3 {
	font-family: var(--wp--preset--font-family--display);
	font-size: var(--wp--preset--font-size--x-large);
	font-weight: 400;
	letter-spacing: 0;
	line-height: 1.2;
	margin: 0 0 0.375rem;
}

.tp-recipe__method h3 {
	margin-block-end: 0.875rem;
}

.tp-recipe .tp-recipe__group-title {
	font-family: var(--wp--preset--font-family--body);
	font-size: 1rem;
	font-weight: 800;
	letter-spacing: 0.06em;
	line-height: 1.4;
	margin: 1.375rem 0 0.25rem;
	text-transform: uppercase;
}

.tp-recipe .tp-recipe__method .tp-recipe__group-title {
	margin-block-end: 0.875rem;
}

.tp-recipe .tp-recipe__body h3 + .tp-recipe__group-title {
	margin-block-start: 0.75rem;
}

.tp-recipe__list {
	border: 0;
	border-collapse: collapse;
	font-size: inherit;
	margin: 0;

	/*
	 * Fixed layout: the amount column has one width for the whole card and
	 * the ingredient takes the rest. The card gets no hyphenation hints, so
	 * a long word must fit its cell whole: on a 320px screen the ingredient
	 * column is 165px, and "huoneenlampoista" with its dots is 157px. Only
	 * something wider than the cell is broken, by overflow-wrap, so that the
	 * table can never push the card wider than the screen.
	 */
	table-layout: fixed;
	width: 100%;
}

.tp-recipe__list td {
	border: 0;
	border-bottom: 1px solid var(--wp--preset--color--rule);
	overflow-wrap: break-word;
	padding: 0.5625rem 0;
	text-align: start;
	vertical-align: top;
}

.tp-recipe__list .tp-recipe__amount {
	font-weight: 800;
	padding-inline-end: 0.875rem;
	white-space: normal;
	width: 5.1em;
}

/* A narrow phone: less margin inside the card and a slimmer amount column, all of it given to the words. */
@media (max-width: 24rem) {

	.tp-recipe {
		padding: 1.25rem 1rem;
	}

	.tp-recipe__list .tp-recipe__amount {
		padding-inline-end: 0.625rem;
		width: 4.6em;
	}
}

.tp-recipe__steps {
	counter-reset: tpt-step;
	display: flex;
	flex-direction: column;
	gap: 1.25rem;
	list-style: none;
	margin: 0;
	padding: 0;
}

.tp-recipe__steps > li {
	counter-increment: tpt-step;
	margin: 0;
	min-height: 2.75rem;
	padding-inline-start: 3.875rem;
	position: relative;
}

.tp-recipe__steps > li::before {
	align-items: center;
	background: var(--wp--preset--color--butter);
	border-radius: 999px;
	content: counter(tpt-step);
	display: flex;
	font-family: var(--wp--preset--font-family--display);
	font-size: 1.375rem;
	height: 2.75rem;
	inset-block-start: 0;
	inset-inline-start: 0;
	justify-content: center;
	line-height: 1;
	position: absolute;
	width: 2.75rem;
}

@media (max-width: 24rem) {

	.tp-recipe__steps > li {
		padding-inline-start: 3.5rem;
	}
}

/* ---- The tip ---- */

.tp-recipe .tp-recipe__tip {
	font-family: var(--wp--preset--font-family--hand);
	font-size: 1.875rem;
	font-weight: 500;
	line-height: 1.15;
	margin: 2rem 0 0;
	rotate: calc(-1deg * var(--tpt-tilt-scale, 1));
	transform-origin: left center;
}
