/**
 * My Healthy Eats — supplement to theme.json
 *
 * theme.json is the source of truth for colour, spacing, typography and radii.
 * Only rules that global styles cannot express belong here.
 *
 * Every value below references a token generated by theme.json:
 *   --wp--preset--color--*        palette
 *   --wp--preset--spacing--*      spacing scale
 *   --wp--preset--font-size--*    type scale
 *   --wp--custom--radius--*       radii
 *   --wp--custom--shadow--*       shadows
 *   --wp--custom--macro--*        macro accent colours
 */

/* -------------------------------------------------- *
 * Base
 * -------------------------------------------------- */

/*
 * The one content column, shared by the header, the footer, the landing and
 * the recipe pages so every edge lines up on every page. The landing's
 * artwork canvas is 1440 wide but its content sits 64 in from each side —
 * that 1312 column is what the rest of the site matches.
 *
 * Below the landing's breakpoint the canvas drops to a flat 20px gutter, so
 * the column and the gutter token both follow it; the recipe layout reads
 * that same token, which keeps it in step without a plugin change.
 */
:root {
	--myhealthyeats-col: min(var(--wp--custom--layout--container), 82%);
}

/* Keep the shared site chrome aligned with the landing's tablet reflow. */
@media (max-width: 1279px) {
	:root {
		--myhealthyeats-col: calc(100% - 40px);
		--wp--custom--layout--gutter: 20px;
	}
}

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

html {
	-webkit-text-size-adjust: 100%;
}

body {
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-rendering: optimizeLegibility;
}

img,
svg,
video {
	max-width: 100%;
	height: auto;
}

/* -------------------------------------------------- *
 * Focus — visible, consistent, keyboard-only
 * -------------------------------------------------- */

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
	outline: 3px solid var(--wp--preset--color--contrast);
	outline-offset: 3px;
	border-radius: var(--wp--custom--radius--sm);
}

:where(a, button, input, select, textarea, summary):focus:not(:focus-visible) {
	outline: none;
}

/* -------------------------------------------------- *
 * Skip link
 * -------------------------------------------------- */

.skip-link {
	position: absolute;
	left: -9999px;
	z-index: 999999;
	padding: var(--wp--preset--spacing--md) var(--wp--preset--spacing--xl);
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
	border-radius: var(--wp--custom--radius--md);
	box-shadow: var(--wp--custom--shadow--lg);
	font-size: var(--wp--preset--font-size--base);
	text-decoration: none;
}

.skip-link:focus {
	left: var(--wp--preset--spacing--xl);
	top: var(--wp--preset--spacing--xl);
}

.screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* -------------------------------------------------- *
 * Form controls — core has no global styles for these
 * -------------------------------------------------- */

input[type="text"],
input[type="email"],
input[type="url"],
input[type="password"],
input[type="search"],
input[type="number"],
select,
textarea {
	width: 100%;
	min-height: var(--wp--custom--control--height);
	padding: var(--wp--custom--control--padding);
	font: inherit;
	font-size: var(--wp--preset--font-size--base);
	color: var(--wp--preset--color--contrast);
	background: var(--wp--preset--color--base);
	/* Dedicated token: 3.48:1 on base and 3.21:1 on canvas. */
	border: 1px solid var(--wp--custom--control--border);
	border-radius: var(--wp--custom--radius--md);
	transition: border-color var(--wp--custom--transition--base),
	            box-shadow var(--wp--custom--transition--base);
}

input[type="submit"] {
	min-height: var(--wp--custom--control--height);
	padding: 0.75rem 1.5rem;
	font: inherit;
	font-weight: 600;
	color: var(--wp--preset--color--base);
	background: var(--wp--preset--color--brand);
	border: 1px solid var(--wp--preset--color--brand);
	border-radius: var(--wp--custom--radius--pill);
	cursor: pointer;
	transition: background-color var(--wp--custom--transition--base),
	            border-color var(--wp--custom--transition--base);
}

input[type="submit"]:hover {
	background: var(--wp--preset--color--brand-dark);
	border-color: var(--wp--preset--color--brand-dark);
}

input:focus,
select:focus,
textarea:focus {
	border-color: var(--wp--preset--color--brand);
	box-shadow: 0 0 0 3px var(--wp--preset--color--brand-soft);
}

/*
 * The rule above also serves mouse/touch focus. Keyboard focus retains a
 * two-tone, high-contrast indicator on every input type, including controls
 * supplied by plugins (checkboxes and radios included).
 */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
	outline: 3px solid var(--wp--preset--color--contrast);
	outline-offset: 3px;
	box-shadow: 0 0 0 2px var(--wp--preset--color--base);
}

::placeholder {
	color: var(--wp--preset--color--faint);
	opacity: 1;
}

/* -------------------------------------------------- *
 * Motion
 * -------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}
}

/* -------------------------------------------------- *
 * Block templates
 *
 * The templates in /templates and /parts carry structure only — no colour,
 * spacing or typography attributes on static blocks. The Block Editor
 * validates a static block by regenerating its save() output and comparing it
 * to the saved HTML, and those classes are composed inside
 * useBlockProps.save() rather than being literal markup. Hand-writing them is
 * what produces "Block contains unexpected or invalid content".
 *
 * So: layout and semantics in the template, every visual decision here,
 * against the same theme.json tokens.
 * -------------------------------------------------- */

/*
 * Padding, not margin: a top margin collapses with the first child's own
 * margin, so the page title ended up sitting against the header.
 */
.myhealthyeats-main {
	padding-top: var(--wp--preset--spacing--xxxl);
}

/*
 * Recipe pages render their article straight into the page, with no myhealthyeats-main
 * wrapper, so the rule above never reaches them and the utility bar butts
 * against the header. The child combinator keeps this from doubling up if the
 * article is ever nested inside myhealthyeats-main instead.
 */
.wp-site-blocks > .myhealthyeats-recipe {
	padding-block-start: var(--wp--preset--spacing--xxl);
}

.myhealthyeats-page-title {
	margin-bottom: var(--wp--preset--spacing--xxl);
}

.myhealthyeats-post-meta {
	gap: var(--wp--preset--spacing--lg);
	margin-bottom: var(--wp--preset--spacing--xxl);
	color: var(--wp--preset--color--faint);
	font-size: var(--wp--preset--font-size--sm);
}

.myhealthyeats-post-meta a {
	color: inherit;
}

.myhealthyeats-hero-image {
	margin-bottom: var(--wp--preset--spacing--xxl);
}

.myhealthyeats-post-grid {
	gap: var(--wp--preset--spacing--xxxl);
}

.myhealthyeats-card-image img {
	border-radius: var(--wp--custom--radius--lg);
}

.myhealthyeats-pagination {
	margin-top: var(--wp--preset--spacing--xxxl);
}

/* Query "no results" text — the block saves no wrapper of its own. */
.wp-block-query > p {
	color: var(--wp--preset--color--muted);
}

/* 404 */

.myhealthyeats-404 {
	margin-top: var(--wp--preset--spacing--xxxxl);
	padding-bottom: var(--wp--preset--spacing--xxxxl);
	text-align: center;
}

.myhealthyeats-404 .wp-block-search {
	max-width: 420px;
	margin-inline: auto;
}

/* -------------------------------------------------- *
 * Top-level block spacing
 *
 * WordPress gives every direct child of .wp-site-blocks a start margin. The
 * landing and the header/footer parts manage their own spacing, so that
 * margin only ever shows up as a stray gap above and below the page content.
 * -------------------------------------------------- */

.wp-site-blocks > :is(.myhealthyeats-homepage, .myhealthyeats-landing-page),
.wp-site-blocks > .wp-block-template-part {
	margin-block-start: 0;
}


/* -------------------------------------------------- *
 * Site header and footer
 * -------------------------------------------------- */

/*
 * The vertical rhythm lives on the header element, not on the inner row.
 * Editing the header in the Site Editor saves a copy of the template part to
 * the database, and that copy can lose the inner wrapper's class — the outer
 * myhealthyeats-site-header class is the only one guaranteed to survive. Height
 * follows the padding and logo without depending on any inner element.
 */
.myhealthyeats-site-header {
	position: relative;
	z-index: 20;
	padding-block: 16px;
	background: transparent;
}

.myhealthyeats-site-header__row {
	width: var(--myhealthyeats-col);
	margin-inline: auto;
	gap: var(--wp--preset--spacing--xl);
}

.myhealthyeats-site-header .wp-block-site-logo img,
.myhealthyeats-footer__logo .wp-block-site-logo img {
	display: block;
	width: 260px;
	max-width: 100%;
	height: auto;
	border-radius: 0;
}

/*
 * Navigation.
 *
 * Anchored to .wp-block-navigation, not to the theme's own myhealthyeats-site-nav class.
 * A template part is user-editable by design: editing the header in the Site
 * Editor saves a copy to the database, and that copy can drop the theme's
 * classes while WordPress's block classes always survive. Styling the header
 * off classes the theme alone controls means any edit silently unstyles it.
 * myhealthyeats-site-nav is kept in the selector so an explicitly classed nav elsewhere
 * still matches.
 */
.myhealthyeats-site-header :is(.myhealthyeats-site-nav, .wp-block-navigation) {
	margin-inline-start: auto;
	gap: 28px;
	font-family: var(--wp--preset--font-family--sans);
	font-size: var(--wp--preset--font-size--base);
	font-weight: 500;
	letter-spacing: 0.5px;
	color: var(--wp--custom--landing--ink);
}

.myhealthyeats-site-header :is(.myhealthyeats-site-nav, .wp-block-navigation) .wp-block-navigation__container {
	gap: 28px;
}

.myhealthyeats-site-header :is(.myhealthyeats-site-nav, .wp-block-navigation) a {
	color: var(--wp--custom--landing--ink);
	text-decoration: none;
}

.myhealthyeats-site-header :is(.myhealthyeats-site-nav, .wp-block-navigation) a:hover {
	color: var(--wp--custom--landing--green);
}

@media (max-width: 781px) {
	.myhealthyeats-site-header__row {
		gap: var(--wp--preset--spacing--lg);
	}

	.myhealthyeats-site-header .wp-block-site-logo img,
	.myhealthyeats-footer__logo .wp-block-site-logo img {
		width: 200px;
	}
}

/*
 * Mobile Navigation overlay.
 *
 * A desktop Navigation block can be saved in the database with right-aligned
 * items. WordPress deliberately carries that alignment into its default
 * overlay and removes link padding there. Explicit stretch alignment keeps
 * saved headers usable, while the default-only scope leaves custom WordPress
 * 7.x overlays in full control of their own presentation.
 */
@media (max-width: 599px) {
	.myhealthyeats-site-header :is(
		.wp-block-navigation__responsive-container-open,
		.wp-block-navigation__responsive-container-close
	) {
		display: flex;
		align-items: center;
		justify-content: center;
		min-width: 44px;
		min-height: 44px;
		border-radius: var(--wp--custom--radius--pill);
	}

	.myhealthyeats-site-header .wp-block-navigation__responsive-container.is-menu-open:not(.disable-default-overlay) {
		padding: var(--wp--custom--layout--gutter);
		background: var(--wp--preset--color--base);
		color: var(--wp--custom--landing--ink);
	}

	.myhealthyeats-site-header .wp-block-navigation__responsive-container.is-menu-open:not(.disable-default-overlay)
		.wp-block-navigation__responsive-close {
		width: 100%;
		max-width: none;
	}

	.myhealthyeats-site-header .wp-block-navigation__responsive-container.is-menu-open:not(.disable-default-overlay)
		.wp-block-navigation__responsive-container-content,
	.myhealthyeats-site-header .wp-block-navigation__responsive-container.is-menu-open:not(.disable-default-overlay)
		:is(.wp-block-navigation__container, .wp-block-page-list, .wp-block-navigation-item) {
		align-items: stretch;
		width: 100%;
	}

	.myhealthyeats-site-header .wp-block-navigation__responsive-container.is-menu-open:not(.disable-default-overlay)
		:is(.wp-block-navigation__container, .wp-block-page-list) {
		gap: var(--wp--preset--spacing--sm);
	}

	.myhealthyeats-site-header .wp-block-navigation__responsive-container.is-menu-open:not(.disable-default-overlay)
		.wp-block-navigation-item__content {
		display: flex;
		align-items: center;
		width: 100%;
		min-height: 44px;
		padding: var(--wp--preset--spacing--sm) var(--wp--preset--spacing--md);
		border-radius: var(--wp--custom--radius--md);
		text-align: start;
		white-space: normal;
		overflow-wrap: anywhere;
	}

	.myhealthyeats-site-header .wp-block-navigation__responsive-container.is-menu-open:not(.disable-default-overlay)
		.wp-block-navigation-item__content:hover,
	.myhealthyeats-site-header .wp-block-navigation__responsive-container.is-menu-open:not(.disable-default-overlay)
		.wp-block-navigation-item__content[aria-current="page"] {
		background: var(--wp--preset--color--brand-tint);
		color: var(--wp--preset--color--brand-dark);
	}

	.myhealthyeats-site-header .wp-block-navigation__responsive-container.is-menu-open:not(.disable-default-overlay)
		.wp-block-navigation__responsive-container-content .wp-block-navigation__submenu-container {
		width: 100%;
		min-width: 0;
		padding: 0;
		padding-inline-start: var(--wp--preset--spacing--lg);
	}
}

.myhealthyeats-footer :is(a, button):focus-visible {
	outline: 3px solid var(--wp--custom--landing--ink);
	outline-offset: 3px;
	box-shadow: 0 0 0 2px #fff;
}

.myhealthyeats-footer .myhealthyeats-store:focus-visible {
	outline-color: var(--wp--custom--landing--ink);
}

/* -------------------------------------------------- *
 * Site footer — the design's footer, on every page
 * -------------------------------------------------- */

.myhealthyeats-footer {
	position: relative;
	/*
	 * No top margin: the 100px of padding is separation enough on content
	 * pages, and a margin would show a band of body background between the
	 * landing and the footer.
	 */
	padding-block: 100px 108px;
	font-family: var(--wp--preset--font-family--sans);
	background-color: var(--wp--custom--landing--page-footer);
	background-image:
		radial-gradient(36% 36% at 30.6% 85%, rgba(178, 224, 116, 0.55), rgba(178, 224, 116, 0) 100%),
		radial-gradient(41.5% 26% at 63.9% 90.5%, rgba(178, 224, 116, 0.34), rgba(178, 224, 116, 0) 100%),
		radial-gradient(19% 25% at 8.7% 92%, rgba(233, 229, 101, 0.42), rgba(233, 229, 101, 0) 100%),
		radial-gradient(21.5% 20% at 84% 96.6%, rgba(233, 229, 101, 0.38), rgba(233, 229, 101, 0) 100%);
	color: var(--wp--custom--landing--ink);
	overflow: hidden;
}

.myhealthyeats-footer__inner {
	width: var(--myhealthyeats-col);
	margin-inline: auto;
}

.myhealthyeats-footer__grid {
	display: grid;
	grid-template-columns: 1.85fr 1fr 0.9fr;
	column-gap: var(--wp--preset--spacing--xl);
	row-gap: 44px;
	align-items: start;
}

.myhealthyeats-footer__tagline {
	max-width: 442px;
	margin: 0;
	font-size: var(--wp--preset--font-size--base);
	font-weight: 500;
	line-height: var(--wp--custom--line-height--body);
	letter-spacing: 0.1px;
}

.myhealthyeats-footer__contact {
	min-width: 0;
}

.myhealthyeats-footer__label {
	margin: 0 0 16px;
	font-size: var(--wp--preset--font-size--xs);
	font-weight: 600;
	line-height: 1.5;
	letter-spacing: 0.06px;
	text-transform: uppercase;
	color: rgba(40, 43, 42, 0.7);
}

.myhealthyeats-footer__email {
	display: inline-flex;
	align-items: center;
	gap: 12px;
	font-size: var(--wp--preset--font-size--md);
	font-weight: 500;
	line-height: 1.5;
	letter-spacing: 0.08px;
	color: inherit;
	text-decoration: none;
}

.myhealthyeats-footer__email:hover {
	color: var(--wp--custom--landing--green);
}

.myhealthyeats-footer__email img {
	flex: none;
	width: 20px;
	height: 20px;
}

.myhealthyeats-footer__stores {
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
	justify-self: end;
}

.myhealthyeats-footer__legal {
	margin: 0;
	font-size: var(--wp--preset--font-size--base);
	line-height: var(--wp--custom--line-height--body);
	letter-spacing: 0.06px;
	color: rgba(40, 43, 42, 0.7);
}

.myhealthyeats-footer__legal a {
	color: inherit;
	text-decoration: underline;
	text-underline-position: from-font;
}

.myhealthyeats-footer__legal ul {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 1rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.myhealthyeats-footer__lang {
	margin: 0;
	justify-self: end;
	font-size: var(--wp--preset--font-size--md);
	font-weight: 500;
	line-height: 1.5;
	letter-spacing: 0.5px;
}

@media (min-width: 782px) {
	.myhealthyeats-footer__contact {
		grid-area: 1 / 2;
	}

	.myhealthyeats-footer__stores {
		grid-area: 1 / 3;
	}

	.myhealthyeats-footer__logo {
		grid-area: 2 / 1;
	}

	.myhealthyeats-footer__legal {
		grid-area: 2 / 2;
	}

	.myhealthyeats-footer__lang {
		grid-area: 2 / 3;
	}
}

/*
 * App store badge. One component, two scales: fixed px in site chrome, and
 * the landing canvas unit inside the landing, where it must scale with the art.
 */
.myhealthyeats-store {
	--s: 1px;

	display: flex;
	flex: none;
	align-items: center;
	gap: calc(var(--s) * 8);
	width: calc(var(--s) * 165);
	height: calc(var(--s) * 54);
	padding: calc(var(--s) * 12);
	border-radius: calc(var(--s) * 8);
	background: var(--wp--custom--landing--dark);
	color: #fff;
	text-decoration: none;
	overflow: hidden;
}

.myhealthyeats-store img {
	flex: none;
	height: calc(var(--s) * 28);
	width: auto;
}

.myhealthyeats-store span {
	display: block;
	width: calc(var(--s) * 105);
	font-size: calc(var(--s) * 12);
	line-height: 1.1;
	font-weight: 500;
	white-space: nowrap;
	letter-spacing: 0;
}

.myhealthyeats-store strong {
	display: block;
	font-size: calc(var(--s) * 16);
	line-height: 1.1;
	font-weight: 700;
	white-space: nowrap;
	letter-spacing: calc(var(--s) * -0.2);
}

@media (max-width: 781px) {
	/*
	 * Touch targets. The legal links and the email sit at 17-24px tall, well
	 * under the 44px minimum, so they get vertical padding on touch layouts.
	 */
	.myhealthyeats-footer__legal a,
	.myhealthyeats-footer__email {
		display: inline-flex;
		align-items: center;
		min-height: 44px;
	}

	.myhealthyeats-footer__legal a {
		padding-block: 10px;
	}

	.myhealthyeats-footer {
		padding-block: 56px 64px;
	}

	.myhealthyeats-footer__grid {
		grid-template-columns: 1fr;
		row-gap: 28px;
	}

	.myhealthyeats-footer__stores,
	.myhealthyeats-footer__lang {
		justify-self: start;
	}
}

/* Logo and title lockup */

.myhealthyeats-site-header .wp-block-site-title {
	margin: 0;
}

.wp-block-site-logo img {
	display: block;
	border-radius: var(--wp--custom--radius--sm);
}

/* -------------------------------------------------- *
 * Recipe index
 * -------------------------------------------------- */

body.myhealthyeats-recipe-index-page,
body:has(.wp-site-blocks > .myhealthyeats-recipe),
body:has(.myhealthyeats-about) {
	background-color: var(--wp--preset--color--base);
}

/* The index title replaces the template title on the managed page. */
body.myhealthyeats-recipe-index-page-has-heading .myhealthyeats-main {
	padding-block-start: 0;
}

body.myhealthyeats-recipe-index-page-has-heading .wp-site-blocks > .myhealthyeats-main {
	margin-block-start: 0;
}

.wp-block-myhealthyeats-recipe-index.myhealthyeats-index {
	color-scheme: only light;
	font-family: var(--wp--preset--font-family--sans);
}

/* Align the managed index with the site's full-width chrome. Embedded indexes
 * retain the width of the post, template or column in which they are placed. */
.myhealthyeats-recipe-index-page .wp-block-myhealthyeats-recipe-index.myhealthyeats-index {
	position: relative;
	inset-inline-start: 50%;
	width: min(var(--wp--custom--layout--container), 82vw);
	max-width: none;
	margin-inline: 0;
	transform: translateX(-50%);
}

.myhealthyeats-recipe-index-page .wp-block-myhealthyeats-recipe-index.myhealthyeats-index:dir(rtl) {
	transform: translateX(50%);
}

@media (max-width: 1279px) {
	.myhealthyeats-recipe-index-page .wp-block-myhealthyeats-recipe-index.myhealthyeats-index {
		width: calc(100vw - 2 * var(--wp--custom--layout--gutter));
	}
}
