/**
 * MyPlate Recipes — single recipe view.
 *
 * Every value resolves to a theme.json token first and falls back to a literal
 * only so the plugin still looks right on a theme that does not define them.
 *
 * The accent colour is deliberately a single token. The reference design uses
 * crimson; this defaults to the theme's brand colour so the page matches the
 * site logo. Change --mp-accent alone to switch it.
 */

.mp-recipe {
	/* Colour */
	--mp-base:       var(--wp--preset--color--base, #ffffff);
	--mp-canvas:     var(--wp--preset--color--canvas, #f5f6f4);
	--mp-text:       var(--wp--preset--color--contrast, #1f2421);
	--mp-muted:      var(--wp--preset--color--muted, #6b7280);
	--mp-faint:      var(--wp--preset--color--faint, #9aa3a0);
	--mp-border:     var(--wp--preset--color--border, #e9ebe7);
	--mp-accent:     var(--wp--preset--color--brand, #7cb342);
	--mp-accent-dark: var(--wp--preset--color--brand-dark, #5c8a2c);
	--mp-accent-soft: var(--wp--preset--color--brand-soft, #edf5e1);
	--mp-accent-tint: var(--wp--preset--color--brand-tint, #f5faef);
	--mp-star:       #f5a623;

	/* Shape */
	--mp-radius-sm:   var(--wp--custom--radius--sm, 8px);
	--mp-radius-md:   var(--wp--custom--radius--md, 12px);
	--mp-radius-lg:   var(--wp--custom--radius--lg, 16px);
	--mp-radius-pill: var(--wp--custom--radius--pill, 999px);
	--mp-shadow-sm:   var(--wp--custom--shadow--sm, 0 1px 2px rgba(16, 24, 40, 0.04));

	/* Rhythm */
	--mp-container: var(--wp--custom--layout--container, 90%);
	--mp-gap:       var(--wp--custom--layout--gutter, 1.5rem);
	--mp-space-xs:  var(--wp--preset--spacing--xs, 0.25rem);
	--mp-space-sm:  var(--wp--preset--spacing--sm, 0.5rem);
	--mp-space-md:  var(--wp--preset--spacing--md, 0.75rem);
	--mp-space-lg:  var(--wp--preset--spacing--lg, 1rem);
	--mp-space-xl:  var(--wp--preset--spacing--xl, 1.5rem);
	--mp-space-2xl: var(--wp--preset--spacing--2xl, 2rem);
	--mp-space-3xl: var(--wp--preset--spacing--3xl, 3rem);
	--mp-space-4xl: var(--wp--preset--spacing--4xl, 4rem);

	--mp-display: var(--wp--preset--font-family--display, Georgia, "Times New Roman", serif);
	--mp-transition: var(--wp--custom--transition--base, 160ms ease);

	background: var(--mp-base);
	color: var(--mp-text);
	padding-bottom: var(--mp-space-4xl);
}

.mp-recipe *,
.mp-recipe *::before,
.mp-recipe *::after {
	box-sizing: border-box;
}

.mp-recipe__inner {
	width: var(--mp-container);
	max-width: none;
	margin-inline: auto;
}

/* -------------------------------------------------- *
 * Utility bar — times, rating, bookmark
 * -------------------------------------------------- */

.mp-bar {
	border-bottom: 1px solid var(--mp-border);
}

.mp-bar__inner {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--mp-space-lg);
	padding-block: var(--mp-space-lg);
}

.mp-times {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0;
	margin: 0;
	padding: 0;
	list-style: none;
	font-size: var(--wp--preset--font-size--xs, 0.75rem);
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.mp-times li {
	padding-inline: var(--mp-space-lg);
	border-inline-start: 1px solid var(--mp-border);
}

.mp-times li:first-child,
.mp-times li:nth-child(2) {
	border-inline-start: 0;
}

.mp-times__icon {
	display: inline-flex;
	color: var(--mp-text);
	padding-inline-start: 0 !important;
}

.mp-times__label {
	color: var(--mp-muted);
	font-weight: 700;
}

/* Unit letters sit smaller than the figure, as in the design. */
.mp-times__unit {
	font-size: 0.75em;
	text-transform: lowercase;
}

.mp-bar__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--mp-space-xl);
}

.mp-rate {
	display: inline-flex;
	align-items: center;
	gap: var(--mp-space-sm);
}

.mp-rate__label,
.mp-bookmark {
	font-size: var(--wp--preset--font-size--xs, 0.75rem);
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.mp-bookmark {
	display: inline-flex;
	align-items: center;
	gap: var(--mp-space-sm);
	padding: 0;
	background: none;
	border: 0;
	color: var(--mp-text);
	font-family: inherit;
	cursor: pointer;
	transition: color var(--mp-transition);
}

.mp-bookmark .mp-icon {
	color: var(--mp-accent);
}

.mp-bookmark:hover {
	color: var(--mp-accent-dark);
}

.mp-bookmark.is-active .mp-icon {
	fill: currentColor;
	color: var(--mp-accent-dark);
}

/* -------------------------------------------------- *
 * Stars
 * -------------------------------------------------- */

.mp-stars {
	display: inline-flex;
	align-items: center;
	gap: 2px;
}

.mp-star {
	display: inline-flex;
	padding: 0;
	background: none;
	border: 0;
	color: var(--mp-border);
	line-height: 1;
	transition: color var(--mp-transition), transform var(--mp-transition);
}

.mp-star.is-filled {
	color: var(--mp-star);
}

.mp-star__glyph {
	font-size: 1rem;
}

.mp-stars--interactive .mp-star {
	cursor: pointer;
}

.mp-stars--interactive .mp-star:hover {
	transform: scale(1.15);
}

/* Hovering a star fills it and everything before it. */
.mp-stars--interactive:hover .mp-star {
	color: var(--mp-star);
}

.mp-stars--interactive .mp-star:hover ~ .mp-star {
	color: var(--mp-border);
}

/* -------------------------------------------------- *
 * Nutrition strip
 * -------------------------------------------------- */

.mp-nutrition {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
	margin: 0;
	padding: var(--mp-space-xl) 0;
	list-style: none;
	border-bottom: 1px solid var(--mp-border);
}

.mp-nutrition__cell {
	padding-inline: var(--mp-space-xl);
	border-inline-start: 1px solid var(--mp-border);
}

.mp-nutrition__cell:first-child {
	padding-inline-start: 0;
	border-inline-start: 0;
}

.mp-nutrition__label {
	display: block;
	color: var(--mp-muted);
	font-size: var(--wp--preset--font-size--xs, 0.75rem);
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.mp-nutrition__value {
	display: block;
	margin-top: var(--mp-space-xs);
	font-family: var(--mp-display);
	font-size: var(--wp--preset--font-size--2xl, 1.875rem);
	font-weight: 700;
	line-height: 1.1;
}

/* -------------------------------------------------- *
 * Hero
 * -------------------------------------------------- */

.mp-hero {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
	gap: var(--mp-space-3xl);
	align-items: start;
	padding-block: var(--mp-space-3xl);
}

.mp-hero__rating {
	display: flex;
	align-items: center;
	gap: var(--mp-space-md);
	margin-bottom: var(--mp-space-lg);
}

.mp-hero__reviews {
	position: relative;
	padding-inline-start: var(--mp-space-md);
	color: var(--mp-muted);
	font-size: var(--wp--preset--font-size--sm, 0.8125rem);
	border-inline-start: 1px solid var(--mp-border);
}

.mp-hero__title {
	margin: 0;
	font-family: var(--mp-display);
	font-size: clamp(2.25rem, 1.6rem + 2.6vw, 3.5rem);
	font-weight: 700;
	line-height: 1.05;
	letter-spacing: -0.02em;
}

.mp-byline {
	display: flex;
	align-items: center;
	gap: var(--mp-space-md);
	margin-top: var(--mp-space-xl);
}

.mp-byline__avatar {
	width: 48px;
	height: 48px;
	border-radius: var(--mp-radius-pill);
}

.mp-byline__body {
	display: grid;
	gap: 2px;
}

.mp-byline__kicker {
	color: var(--mp-muted);
	font-size: var(--wp--preset--font-size--xs, 0.75rem);
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.mp-byline__name {
	color: var(--mp-accent-dark);
	font-size: var(--wp--preset--font-size--xs, 0.75rem);
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	text-decoration: none;
}

.mp-byline__name:hover {
	text-decoration: underline;
}

.mp-hero__summary {
	margin: var(--mp-space-xl) 0 0;
	font-size: var(--wp--preset--font-size--lg, 1.125rem);
	line-height: 1.65;
}

.mp-hero__figure {
	position: relative;
	margin: 0;
	overflow: hidden;
	background: var(--mp-canvas);
}

.mp-hero__img {
	display: block;
	width: 100%;
	aspect-ratio: 4 / 3;
	object-fit: cover;
}

/* Play overlay */

.mp-play {
	position: absolute;
	inset: 0;
	display: grid;
	place-content: center;
	text-decoration: none;
}

.mp-play::before {
	content: "";
	width: 96px;
	height: 96px;
	border: 3px solid #fff;
	border-radius: var(--mp-radius-pill);
	transition: transform var(--mp-transition), background var(--mp-transition);
}

.mp-play:hover::before {
	background: rgba(255, 255, 255, 0.15);
	transform: scale(1.06);
}

.mp-play__triangle {
	position: absolute;
	inset: 0;
	margin: auto;
	width: 0;
	height: 0;
	border-block: 14px solid transparent;
	border-inline-start: 22px solid #fff;
	transform: translateX(4px);
}

/* -------------------------------------------------- *
 * Body — ingredients | preparation
 * -------------------------------------------------- */

.mp-body {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
	gap: var(--mp-space-4xl);
	align-items: start;
	padding-top: var(--mp-space-2xl);
}

.mp-col__title {
	margin: 0 0 var(--mp-space-lg);
	padding-bottom: var(--mp-space-md);
	border-bottom: 1px solid var(--mp-border);
	font-size: var(--wp--preset--font-size--md, 1rem);
	font-weight: 700;
}

.mp-empty {
	margin: 0;
	color: var(--mp-faint);
}

/* Servings stepper */

.mp-servings {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--mp-space-lg);
	margin-bottom: var(--mp-space-lg);
}

.mp-servings__label {
	color: var(--mp-muted);
	font-size: var(--wp--preset--font-size--sm, 0.8125rem);
}

.mp-stepper {
	display: inline-flex;
	gap: var(--mp-space-sm);
}

.mp-stepper__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	background: var(--mp-base);
	border: 1px solid var(--mp-border);
	border-radius: var(--mp-radius-pill);
	color: var(--mp-muted);
	cursor: pointer;
	transition: border-color var(--mp-transition), color var(--mp-transition);
}

.mp-stepper__btn:hover {
	border-color: var(--mp-accent);
	color: var(--mp-accent-dark);
}

.mp-stepper__btn:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

/* Ingredient rows */

.mp-ingredients {
	margin: 0;
	padding: 0;
	list-style: none;
}

.mp-ingredients__group {
	padding: var(--mp-space-lg) 0 var(--mp-space-sm);
	color: var(--mp-muted);
	font-size: var(--wp--preset--font-size--xs, 0.75rem);
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.mp-ing {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr) auto;
	align-items: start;
	gap: var(--mp-space-md);
	padding-block: var(--mp-space-lg);
	border-bottom: 1px solid var(--mp-border);
}

.mp-ing:last-child {
	border-bottom: 0;
}

/* The check toggle: dashed circle, filled once gathered. */
.mp-ing__check {
	display: inline-grid;
	place-content: center;
	width: 34px;
	height: 34px;
	margin-top: 2px;
	background: none;
	border: 1px dashed var(--mp-faint);
	border-radius: var(--mp-radius-pill);
	color: var(--mp-faint);
	cursor: pointer;
	transition: background var(--mp-transition), border-color var(--mp-transition), color var(--mp-transition);
}

.mp-ing__check:hover {
	border-color: var(--mp-accent);
	color: var(--mp-accent-dark);
}

.mp-ing__plus {
	font-size: 1rem;
	line-height: 1;
}

.mp-ing__tick {
	display: none;
}

.mp-ing__check[aria-pressed="true"] {
	background: var(--mp-accent);
	border-style: solid;
	border-color: var(--mp-accent);
	color: #fff;
}

.mp-ing__check[aria-pressed="true"] .mp-ing__plus {
	display: none;
}

.mp-ing__check[aria-pressed="true"] .mp-ing__tick {
	display: inline-flex;
}

.mp-ing__body {
	display: grid;
	gap: 2px;
	min-width: 0;
	line-height: 1.45;
}

.mp-ing__amount {
	font-weight: 700;
}

.mp-ing__name {
	overflow-wrap: anywhere;
}

.mp-ing__note {
	color: var(--mp-faint);
	font-size: var(--wp--preset--font-size--sm, 0.8125rem);
}

.mp-ing__kcal {
	color: var(--mp-faint);
	font-size: var(--wp--preset--font-size--sm, 0.8125rem);
	white-space: nowrap;
}

/* Gathered rows fade back. */
.mp-ing.is-checked .mp-ing__body {
	color: var(--mp-faint);
	text-decoration: line-through;
	text-decoration-color: var(--mp-border);
}

/* Steps */

.mp-steps {
	margin: 0;
	padding: 0;
	list-style: none;
	display: grid;
	gap: var(--mp-space-3xl);
}

.mp-step__title {
	margin: 0 0 var(--mp-space-md);
	font-family: var(--mp-display);
	font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem);
	font-weight: 700;
	line-height: 1.15;
}

.mp-step__body {
	font-size: var(--wp--preset--font-size--md, 1rem);
	line-height: 1.9;
}

.mp-step__body > :first-child { margin-top: 0; }
.mp-step__body > :last-child  { margin-bottom: 0; }

.mp-step__img {
	display: block;
	margin-top: var(--mp-space-lg);
}

/* -------------------------------------------------- *
 * Footer blocks
 * -------------------------------------------------- */

.mp-footer {
	margin-top: var(--mp-space-4xl);
	padding-top: var(--mp-space-2xl);
	border-top: 1px solid var(--mp-border);
	display: grid;
	gap: var(--mp-space-3xl);
}

.mp-actions {
	display: flex;
	flex-wrap: wrap;
	gap: var(--mp-space-md);
}

.mp-action {
	display: inline-flex;
	align-items: center;
	gap: var(--mp-space-sm);
	padding: var(--mp-space-md) var(--mp-space-xl);
	background: var(--mp-base);
	border: 1px solid var(--mp-border);
	border-radius: var(--mp-radius-pill);
	color: var(--mp-text);
	font: inherit;
	font-size: var(--wp--preset--font-size--sm, 0.8125rem);
	font-weight: 600;
	cursor: pointer;
	transition: background var(--mp-transition), border-color var(--mp-transition);
}

.mp-action .mp-icon {
	color: var(--mp-accent-dark);
}

.mp-action:hover {
	background: var(--mp-accent-tint);
	border-color: var(--mp-accent);
}

/* Related */

.mp-related__title,
.mp-card__title {
	margin: 0 0 var(--mp-space-lg);
	font-size: var(--wp--preset--font-size--md, 1rem);
	font-weight: 700;
}

.mp-related__list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
	gap: var(--mp-space-lg);
	margin: 0;
	padding: 0;
	list-style: none;
}

.mp-rcard__link {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr);
	align-items: center;
	gap: var(--mp-space-md);
	padding: var(--mp-space-sm);
	border: 1px solid var(--mp-border);
	border-radius: var(--mp-radius-md);
	color: inherit;
	text-decoration: none;
	transition: border-color var(--mp-transition), background var(--mp-transition);
}

.mp-rcard__link:hover {
	background: var(--mp-accent-tint);
	border-color: var(--mp-accent);
}

.mp-rcard__img {
	display: block;
	width: 56px;
	height: 56px;
	border-radius: var(--mp-radius-sm);
	object-fit: cover;
	background: var(--mp-canvas);
}

.mp-rcard__img--placeholder {
	background: var(--mp-accent-soft);
}

.mp-rcard__body {
	display: grid;
	gap: var(--mp-space-xs);
	min-width: 0;
}

.mp-rcard__title {
	font-size: var(--wp--preset--font-size--sm, 0.8125rem);
	font-weight: 600;
	line-height: 1.3;
}

.mp-rcard__meta {
	display: flex;
	flex-wrap: wrap;
	gap: var(--mp-space-md);
}

.mp-stat {
	display: inline-flex;
	align-items: center;
	gap: var(--mp-space-xs);
	color: var(--mp-muted);
	font-size: var(--wp--preset--font-size--xs, 0.75rem);
}

/* Status message */

.mp-status {
	width: var(--mp-container);
	margin: var(--mp-space-lg) auto 0;
	min-height: 1.25em;
	color: var(--mp-accent-dark);
	font-size: var(--wp--preset--font-size--sm, 0.8125rem);
	text-align: center;
}

.mp-status.is-error {
	color: #ef5350;
}

/* -------------------------------------------------- *
 * Responsive
 * -------------------------------------------------- */

@media (max-width: 1024px) {
	.mp-hero,
	.mp-body {
		grid-template-columns: minmax(0, 1fr);
		gap: var(--mp-space-2xl);
	}

	.mp-hero__media {
		order: -1;
	}
}

@media (max-width: 782px) {
	.mp-bar__inner {
		align-items: flex-start;
		flex-direction: column;
	}

	.mp-times li {
		padding-inline: var(--mp-space-md);
	}

	.mp-times li:nth-child(2) {
		padding-inline-start: var(--mp-space-sm);
	}

	.mp-nutrition__cell {
		padding-inline: var(--mp-space-md);
	}
}

/* -------------------------------------------------- *
 * Focus and motion
 * -------------------------------------------------- */

.mp-recipe :where(a, button, [tabindex]):focus-visible {
	outline: 2px solid var(--mp-accent);
	outline-offset: 2px;
	border-radius: var(--mp-radius-sm);
}

@media (prefers-reduced-motion: reduce) {
	.mp-recipe * {
		transition-duration: 0.01ms !important;
	}
}

/* -------------------------------------------------- *
 * Embedded block variant
 *
 * The myplate/recipe block renders inside someone else's post, so it becomes
 * a self-contained card rather than taking over the page: its own border and
 * padding, and no full-bleed container of its own.
 * -------------------------------------------------- */

.mp-recipe--embedded {
	padding: 0;
	border: 1px solid var(--mp-border);
	border-radius: var(--mp-radius-lg);
	background: var(--mp-base);
}

.mp-embed {
	padding: var(--mp-space-2xl);
	display: grid;
	gap: var(--mp-space-xl);
}

.mp-embed__head {
	display: grid;
	gap: var(--mp-space-md);
}

.mp-embed__title {
	margin: 0;
	font-family: var(--mp-display);
	font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem);
	font-weight: 700;
	line-height: 1.15;
}

.mp-embed__title a {
	color: inherit;
	text-decoration: none;
}

.mp-embed__title a:hover {
	text-decoration: underline;
}

.mp-embed__figure {
	margin: 0;
	border-radius: var(--mp-radius-md);
	overflow: hidden;
	background: var(--mp-canvas);
}

.mp-embed__img {
	display: block;
	width: 100%;
	aspect-ratio: 16 / 9;
	object-fit: cover;
}

/* The strip already has a rule above it from the head; drop the double line. */
.mp-embed .mp-nutrition {
	padding-top: 0;
}

.mp-embed__body {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
	gap: var(--mp-space-2xl);
	align-items: start;
}

.mp-embed .mp-steps {
	gap: var(--mp-space-xl);
}

.mp-embed .mp-step__title {
	font-size: var(--wp--preset--font-size--lg, 1.125rem);
}

.mp-embed .mp-status {
	width: auto;
	margin: 0;
}

@media (max-width: 782px) {
	.mp-embed__body {
		grid-template-columns: minmax(0, 1fr);
	}

	.mp-embed {
		padding: var(--mp-space-lg);
	}
}

/* Editor-only notice when no recipe is chosen yet. */
.mp-block-notice {
	margin: 0;
	padding: var(--wp--preset--spacing--xl, 1.5rem);
	background: var(--wp--preset--color--canvas, #f5f6f4);
	border: 1px dashed var(--wp--preset--color--border, #e9ebe7);
	border-radius: var(--wp--custom--radius--md, 12px);
	color: var(--wp--preset--color--muted, #6b7280);
	text-align: center;
}

/* -------------------------------------------------- *
 * Rating affordance
 *
 * The interactive group needs to read as clickable, and the read-only group
 * needs an empty state that does not look like a broken widget.
 * -------------------------------------------------- */

.mp-stars--interactive .mp-star {
	padding: 2px;
	color: var(--mp-faint);
}

.mp-stars--interactive .mp-star.is-filled {
	color: var(--mp-star);
}

.mp-hero__reviews {
	white-space: nowrap;
}

/* No ratings yet: keep the stars visible but clearly inactive. */
.mp-hero__rating .mp-stars[data-average="0"] .mp-star {
	color: var(--mp-border);
}

/* -------------------------------------------------- *
 * Top-level spacing
 *
 * A block theme's global blockGap adds a top margin to every direct child of
 * .wp-site-blocks, which pushes the recipe away from the site header. The
 * utility bar is meant to sit flush beneath it, so opt out.
 *
 * Scoped to the direct-child case on purpose: an embedded recipe block sits in
 * normal post flow, where that spacing is correct and should stay.
 * -------------------------------------------------- */

.wp-site-blocks > .mp-recipe {
	margin-block-start: 0;
}
