/*
 * 3pt Restaurant Menu: front-end base styles.
 * Light on purpose: inherits the theme's fonts and colours. Adjust with
 * the custom properties below, or style the tprm-* classes directly.
 * Defaults sit on :root so Bricks loop tags (prices, diet badges) get them
 * outside a .tprm-menu too; override on .tprm-menu or any wrapper.
 * Mobile-first (MENU-D-015): base values are for phones, larger screens
 * scale up with min-width.
 */

:root {
	--tprm-gap: 1rem;
	--tprm-price-width: 4.5em;
	--tprm-muted: color-mix(in srgb, currentColor 65%, transparent);
	--tprm-line: color-mix(in srgb, currentColor 15%, transparent);
	--tprm-badge-bg: color-mix(in srgb, currentColor 10%, transparent);
	--tprm-image-size: 3.5rem;
}

@media (min-width: 30em) {
	:root {
		--tprm-image-size: 4.5rem;
	}
}

.tprm-menu__description,
.tprm-section__intro,
.tprm-section__footer,
.tprm-item__description,
.tprm-item__note,
.tprm-item__special,
.tprm-item__name-row,
.tprm-item__prices,
.tprm-legend__note {
	/* Paragraphs: themes give <p> margins. */
	margin: 0;
}

.tprm-menu__description {
	margin-block-end: calc(var(--tprm-gap) * 1.5);
}

/* Set menu price line (MENU-B-041), under the menu name. */
.tprm-menu__set-price {
	margin: 0 0 calc(var(--tprm-gap) * 1.5);
	font-weight: 600;
}

/* Wine pairing line (MENU-B-096), under the set price. */
.tprm-menu__pairing {
	margin: 0 0 calc(var(--tprm-gap) * 1.5);
}

.tprm-menu__set-price:has(+ .tprm-menu__pairing) {
	margin-block-end: calc(var(--tprm-gap) * 0.25);
}

.tprm-menu__set-price:has(+ .tprm-menu__description),
.tprm-menu__pairing:has(+ .tprm-menu__description) {
	margin-block-end: calc(var(--tprm-gap) * 0.5);
}

/* Child menus of a menu group (MENU-D-033), e.g. set menus in "Banquet". */
.tprm-menu__child-title {
	margin-block: 0 calc(var(--tprm-gap) * 0.5);
}

.tprm-menu__sections + .tprm-menu__children {
	margin-block-start: calc(var(--tprm-gap) * 2);
}

/* Side by side with --tprm-menu-columns (MENU-B-124); stacked by default. */
.tprm-menu__children {
	display: grid;
	grid-template-columns: repeat(var(--tprm-menu-columns, 1), minmax(0, 1fr));
	gap: calc(var(--tprm-gap) * 2) var(--tprm-menu-gap, calc(var(--tprm-gap) * 2));
}

/*
 * Order online buttons (MENU-B-098): outlined in the text colour so they
 * suit any theme; full-height tap targets, wrapping on phones.
 */
.tprm-menu__order {
	display: flex;
	flex-wrap: wrap;
	gap: calc(var(--tprm-gap) * 0.5);
	margin: 0 0 calc(var(--tprm-gap) * 1.5);
}

.tprm-menu__order-link {
	display: inline-flex;
	align-items: center;
	min-height: 2.75rem;
	padding: 0.25em 1em;
	border: 1px solid currentColor;
	border-radius: 0.25em;
	color: inherit;
	font-weight: 600;
	text-decoration: none;
}

.tprm-menu__order-link:hover,
.tprm-menu__order-link:focus-visible {
	text-decoration: underline;
}

/*
 * "Print menu" link (MENU-B-035): a full-height tap target on phones.
 */
.tprm-menu__print {
	margin: 0 0 var(--tprm-gap);
}

.tprm-menu__print-link {
	display: inline-flex;
	align-items: center;
	min-height: 2.75rem;
}

/*
 * Diet filter (MENU-B-063): toggle buttons like the order buttons; a
 * picked one gets a tint and a tick, so it doesn't rely on colour.
 * Theme rules like `.tprm-item { display: flex }` beat the browser's
 * own [hidden] style, so hidden parts are forced off here.
 */
.tprm-filter[hidden],
.tprm-filter__clear[hidden],
.tprm-menu .tprm-item[hidden],
.tprm-menu .tprm-section[hidden],
.tprm-menu .tprm-menu__child[hidden] {
	display: none;
}

/* Label above the chips; --tprm-filter-label-width: auto puts it beside them (MENU-B-138). */
.tprm-filter {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: calc(var(--tprm-gap) * 0.5) calc(var(--tprm-gap) * 0.75);
	margin: 0 0 calc(var(--tprm-gap) * 1.5);
}

.tprm-filter__label {
	flex: 0 0 var(--tprm-filter-label-width, 100%);
	margin: 0;
	font-weight: 600;
}

/* Chips in a row by default; flex-direction: column stacks them at their own width. */
.tprm-filter__buttons {
	display: flex;
	flex: 1 1 0;
	flex-wrap: wrap;
	align-items: flex-start;
	gap: calc(var(--tprm-gap) * 0.5);
	min-width: 0;
}

.tprm-filter__button,
.tprm-filter__clear {
	display: inline-flex;
	align-items: center;
	gap: 0.35em;
	min-height: 2.75rem;
	margin: 0;
	padding: 0.25em 1em;
	border: 1px solid currentColor;
	border-radius: 999px;
	background: none;
	color: inherit;
	font: inherit;
	cursor: pointer;
}

/* Chips with a visible tick box, so they read as filters (MENU-D-051). */
.tprm-filter__button {
	padding-left: 0.75em;
}

.tprm-filter__check {
	flex: none;
	width: 1.1em;
	height: 1.1em;
	margin: 0;
	accent-color: currentColor;
	cursor: pointer;
}

.tprm-filter__button:has(.tprm-filter__check:checked) {
	background: var(--tprm-badge-bg);
	font-weight: 600;
}

/* Tick box hidden (MENU-B-142): still there for keyboards and screen
   readers; a picked chip adds a thicker border, so it isn't colour alone. */
.tprm-filter--no-check .tprm-filter__button {
	position: relative;
	padding-left: 1em;
}

.tprm-filter--no-check .tprm-filter__check {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	opacity: 0;
}

.tprm-filter--no-check .tprm-filter__button:has(.tprm-filter__check:checked) {
	box-shadow: inset 0 0 0 1px currentColor;
}

.tprm-filter__clear {
	border-color: transparent;
	text-decoration: underline;
}

.tprm-filter__button:has(.tprm-filter__check:focus-visible),
.tprm-filter__clear:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.tprm-filter__count {
	flex: 0 0 100%;
	margin: 0;
	color: var(--tprm-muted);
}

/* No filter picked: the count is for screen readers only (MENU-D-051).
   Not display:none: screen readers skip updates to a hidden live region.
   Empty (the builder) too, so it leaves no gap under the chips. */
.tprm-filter__count.is-idle,
.tprm-filter__count:empty {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
}

@media (min-width: 48em) {
	.tprm-menu__print-link {
		min-height: 0;
	}
}

/*
 * Columns (MENU-B-032): set --tprm-section-columns / --tprm-item-columns
 * (and the matching -gap) on .tprm-menu or any wrapper. Default 1.
 */
.tprm-menu__sections {
	display: grid;
	grid-template-columns: repeat(var(--tprm-section-columns, 1), minmax(0, 1fr));
	column-gap: var(--tprm-section-gap, calc(var(--tprm-gap) * 2));
}

.tprm-section {
	margin-block: 0 calc(var(--tprm-gap) * 2);
}

/* Wraps so a long one-word title can't push the column headings off screen. */
.tprm-section__head {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: var(--tprm-gap);
	border-block-end: 1px solid var(--tprm-line);
	padding-block-end: calc(var(--tprm-gap) / 2);
	margin-block-end: calc(var(--tprm-gap) / 2);
}

.tprm-section__title {
	margin: 0;
}

.tprm-section__columns,
.tprm-item__prices--columns {
	display: grid;
	grid-template-columns: repeat(var(--tprm-columns, 1), var(--tprm-price-width));
	/* Heading and prices start at the same edge: "G" of Glass over the "$". */
	text-align: start;
	flex-shrink: 0;
	/* Stays on the right, over the prices, when the head wraps. */
	margin-inline-start: auto;
}

/* Last column sits flush right, like prices in sections without columns. */
.tprm-section__columns > :last-child,
.tprm-item__prices--columns > :last-child {
	text-align: end;
}

/* Smaller text on the spans, not the grid, so the em column widths match the price rows. */
.tprm-section__columns {
	color: var(--tprm-muted);
}

.tprm-section__columns > span {
	font-size: 0.875em;
}

.tprm-section__intro,
.tprm-section__footer {
	color: var(--tprm-muted);
	font-size: 0.9375em;
}

.tprm-section__intro {
	margin-block-end: var(--tprm-gap);
}

.tprm-section__footer {
	margin-block-start: var(--tprm-gap);
}

/*
 * Each item draws its divider just above itself; the list clips at its own
 * top edge, so the first row has no divider in any number of columns.
 */
.tprm-section__items {
	display: grid;
	grid-template-columns: repeat(var(--tprm-item-columns, 1), minmax(0, 1fr));
	column-gap: var(--tprm-item-gap, calc(var(--tprm-gap) * 2));
	list-style: none;
	margin: 0;
	padding: 0;
	/* 1px in, so the first row's line can't leak through at fractional pixel positions. */
	clip-path: inset(1px -100vmax -100vmax);
}

/*
 * Cards (MENU-B-128): `--tprm-card: ;` (empty) on .tprm-menu or any
 * wrapper puts the image full width on top, the price beside the name
 * and the description full width below; `--tprm-card: initial` (or not
 * set) keeps the side image. A space toggle: each --_tprm-card-* below
 * is only valid when --tprm-card is empty, else its fallback applies.
 * The Bricks element's Image position sets it per breakpoint.
 */
.tprm-item {
	--_tprm-card-direction: var(--tprm-card) column;
	--_tprm-card-align: var(--tprm-card) stretch;
	position: relative;
	display: flex;
	flex-direction: var(--_tprm-card-direction, row);
	gap: var(--tprm-gap);
	align-items: var(--_tprm-card-align, flex-start);
	margin: 0;
	padding-block: calc(var(--tprm-gap) * 0.75);
}

.tprm-item::before {
	content: "";
	position: absolute;
	inset-inline: 0;
	bottom: 100%;
	border-block-start: 1px dashed var(--tprm-line);
}

.tprm-item__image {
	--_tprm-card-width: var(--tprm-card) 100%;
	--_tprm-card-height: var(--tprm-card) auto;
	--_tprm-card-ratio: var(--tprm-card) var(--tprm-image-ratio, 4 / 3);
	flex-shrink: 0;
	width: var(--_tprm-card-width, var(--tprm-image-size));
	height: var(--_tprm-card-height, var(--tprm-image-size));
	aspect-ratio: var(--_tprm-card-ratio, auto);
	object-fit: cover;
	border-radius: 0.375rem;
}

.tprm-item__body {
	flex: 1;
	min-width: 0;
}

.tprm-item__head {
	--_tprm-card-display: var(--tprm-card) grid;
	--_tprm-card-row-gap: var(--tprm-card) 0;
	display: var(--_tprm-card-display, flex);
	flex-wrap: wrap;
	align-items: baseline;
	gap: var(--_tprm-card-row-gap, 0.25rem) 0.5rem;
	/* Cards only: name and prices on the first row, the rest full width below. */
	grid-template-columns: minmax(0, 1fr) auto;
	/* Lets the prices stack when the item is narrow (MENU-B-117). */
	container-type: inline-size;
}

/*
 * Name, tags, description and note wrap inside here, so nothing runs under
 * the prices and they keep their column on the right.
 * Below 8em of room (tiny screens) the prices drop to their own line.
 * A flex column so "Today's special" can come after the name in the HTML
 * (read second) yet show above it (MENU-B-132).
 */
.tprm-item__title {
	--_tprm-card-display: var(--tprm-card) contents;
	display: var(--_tprm-card-display, flex);
	flex-direction: column;
	flex: 1 1 0;
	min-width: min(8em, 100%);
}

/* Cards: the title box steps aside (display: contents), so its parts sit in the head's grid. */
.tprm-item__title > * {
	grid-column: 1 / -1;
}

.tprm-item__title > .tprm-item__name-row {
	grid-column: 1;
}

.tprm-item__head > .tprm-item__prices {
	grid-column: 2;
}

/*
 * Labelled prices ("Chicken, Beef or Tofu $28.50") are too wide to sit
 * beside the name in a card: they get their own row under it. order
 * keeps prices above the description, which comes later in the HTML.
 */
.tprm-item__head > .tprm-item__prices--extra,
.tprm-item__head > .tprm-item__prices:has(.tprm-price__label) {
	grid-column: 1 / -1;
}

.tprm-item__title > :not(.tprm-item__special, .tprm-item__name-row) {
	order: 1;
}

.tprm-item__name {
	font-weight: 600;
}

/*
 * Dot leaders (MENU-B-057): name, tags and sold-out sit in one row whose
 * ::after fills the rest of the line up to the price. A long name wraps
 * and the leader keeps at least 1.5em, beside the name's first line (the
 * line the price sits on). Style, colour and thickness are variables.
 */
.tprm-menu--leaders-dotted {
	--tprm-leader-style: dotted;
}

.tprm-menu--leaders-dashed {
	--tprm-leader-style: dashed;
}

.tprm-menu--leaders-solid {
	--tprm-leader-style: solid;
}

.tprm-item__line {
	display: flex;
	align-items: baseline;
	gap: 0.25rem 0.5rem;
}

.tprm-item__line > .tprm-item__name {
	min-width: 0;
}

.tprm-item__line > :not(.tprm-item__name) {
	flex-shrink: 0;
}

.tprm-item__line::after {
	content: "";
	flex: 1 0 1.5em;
	/* An empty box sits its bottom edge on the baseline; lift it a little. */
	transform: translateY(-0.25em);
	border-block-end: var(--tprm-leader-width, 2px) var(--tprm-leader-style, dotted) var(--tprm-leader-color, var(--tprm-muted));
}

.tprm-item__diets {
	display: inline-flex;
	gap: 0.25rem;
}

.tprm-diet {
	display: inline-block;
	padding: 0 0.375em;
	border-radius: 999px;
	background: var(--tprm-badge-bg);
	font-size: 0.75em;
	font-weight: 600;
	line-height: 1.6;
	text-decoration: none;
}

abbr.tprm-diet {
	cursor: help;
}

/*
 * Item badges (MENU-B-059), e.g. "New" or "Chef's pick": an outlined
 * pill, so they read apart from the filled diet badges. Each also has a
 * class from its name, e.g. .tprm-badge--new, to colour one on its own.
 */
.tprm-item__badges {
	display: inline-flex;
	flex-wrap: wrap;
	gap: 0.25rem;
}

.tprm-badge {
	display: inline-block;
	padding: 0 0.5em;
	border: 1px solid currentColor;
	border-radius: 999px;
	font-size: 0.6875em;
	font-weight: 600;
	letter-spacing: 0.04em;
	line-height: 1.5;
	text-transform: uppercase;
	white-space: nowrap;
}

/*
 * Today's special (MENU-D-044): a small line above the item name. Colour
 * is a variable (text colour by default); .tprm-item--special is on the
 * item to style the whole row.
 */
.tprm-item__special {
	color: var(--tprm-special-color, currentColor);
	font-size: 0.6875em;
	font-weight: 700;
	letter-spacing: 0.06em;
	line-height: 1.5;
	text-transform: uppercase;
}

.tprm-item__title > .tprm-item__special {
	display: block;
	order: -1;
}

/*
 * Spice level (MENU-B-058): 1-3 chillies beside the name and in the
 * legend. Colour and size are variables; red by default, since a chilli
 * in the text colour reads as a stray mark.
 */
.tprm-spice {
	display: inline-flex;
	gap: 0.0625em;
	vertical-align: -0.125em;
	color: var(--tprm-spice-color, #c62828);
	white-space: nowrap;
}

.tprm-spice__icon {
	width: var(--tprm-spice-size, 1em);
	height: var(--tprm-spice-size, 1em);
	fill: currentColor;
}

span.tprm-spice[title] {
	cursor: help;
}

/*
 * Section dividers (MENU-B-061): an ornament under each section name in
 * place of the head's plain line. Colour, height and alignment are
 * variables; the ornament lines up with the name (start) by default.
 * "Line with diamond" stretches a line either side of the diamond.
 */
.tprm-menu--divider .tprm-section__head {
	border-block-end: 0;
	padding-block-end: 0;
	margin-block-end: calc(var(--tprm-gap) / 4);
}

.tprm-section__divider {
	display: flex;
	align-items: center;
	justify-content: var(--tprm-divider-align, flex-start);
	gap: 0.75em;
	color: var(--tprm-divider-color, var(--tprm-muted));
	margin-block-end: calc(var(--tprm-gap) / 2);
}

.tprm-section__divider svg {
	display: block;
	flex: 0 1 auto;
	width: auto;
	max-width: 100%;
	height: var(--tprm-divider-size, 1.5em);
}

.tprm-menu--divider-diamond .tprm-section__divider::before,
.tprm-menu--divider-diamond .tprm-section__divider::after {
	content: "";
	flex: 1 1 0;
	border-block-start: 1px solid currentColor;
	opacity: 0.5;
}

.tprm-menu--divider-diamond .tprm-section__divider svg {
	height: calc(var(--tprm-divider-size, 1.5em) / 2);
}

.tprm-item__sold-out {
	font-size: 0.75em;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.tprm-item--sold-out .tprm-item__name,
.tprm-item--sold-out .tprm-price__amount {
	text-decoration: line-through;
	opacity: 0.6;
}

.tprm-item__prices {
	--_tprm-card-wrap: var(--tprm-card) normal;
	display: flex;
	flex-wrap: wrap;
	gap: 0 0.75rem;
	margin-inline-start: auto;
	font-variant-numeric: tabular-nums;
	/* Cards: a long label may wrap rather than run off a narrow card. */
	white-space: var(--_tprm-card-wrap, nowrap);
}

/*
 * Several labelled prices on one line ("Chicken or Tofu $28.00 Prawns
 * $36.00") squeeze the name in a narrow item (MENU-B-117): there they
 * stack one per line, right-aligned, so the name keeps most of the row.
 * Glass / Bottle columns keep their grid.
 */
@container (max-width: 36em) {
	.tprm-item__prices:not(.tprm-item__prices--columns, .tprm-item__prices--extra) {
		flex-direction: column;
		align-items: flex-end;
	}
}

/* Restate grid: .tprm-item__prices above sets flex at the same specificity. */
.tprm-item__prices--columns {
	display: grid;
	align-items: baseline;
	gap: 0;
}

/* Gives an empty cell a baseline so a row starting blank still lines up. */
.tprm-price--empty::before {
	content: "\200b";
}

.tprm-item__prices--extra {
	flex-basis: 100%;
	justify-content: flex-end;
	font-size: 0.875em;
}

/* Market price text ("Market price", "Ask staff") may wrap in a narrow price column. */
.tprm-price--market {
	white-space: normal;
}

.tprm-price__label,
.tprm-price__size {
	color: var(--tprm-muted);
}

.tprm-item__description {
	margin-block-start: 0.25rem;
}

/* Drink details line (MENU-B-097), under the name. */
.tprm-item__details {
	margin: 0.125rem 0 0;
	font-size: 0.875em;
	color: var(--tprm-muted);
}

.tprm-item__note {
	margin-block-start: 0.25rem;
	font-size: 0.875em;
	font-style: italic;
	color: var(--tprm-muted);
}

/*
 * Add-ons (MENU-B-062): "Add prawns +$5 · Add egg +$2" under an item, or
 * after a section's items. Rows wrap; a price never splits from its "+".
 */
.tprm-addons {
	margin: 0.25rem 0 0;
	font-size: 0.875em;
	color: var(--tprm-muted);
}

.tprm-addons__price {
	white-space: nowrap;
}

.tprm-section__addons {
	margin-block-start: var(--tprm-gap);
	font-size: 0.9375em;
}

/*
 * Allergens (MENU-B-056): "Contains: Peanuts, Milk · May contain: Sesame"
 * as the last line of an item, and the "please ask staff" note at the
 * bottom of every menu, after the legend.
 */
.tprm-allergens {
	margin: 0.25rem 0 0;
	font-size: 0.875em;
	color: var(--tprm-muted);
}

.tprm-allergens__label {
	font-weight: 600;
}

.tprm-allergen-note {
	margin: var(--tprm-gap) 0 0;
	font-size: 0.875em;
	color: var(--tprm-muted);
}

.tprm-legend {
	border-block-start: 1px solid var(--tprm-line);
	padding-block-start: var(--tprm-gap);
	font-size: 0.875em;
	color: var(--tprm-muted);
}

.tprm-legend__list {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 1rem;
	list-style: none;
	margin: 0 0 0.5rem;
	padding: 0;
}

.tprm-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.tprm-notice {
	padding: 0.5rem 0.75rem;
	border: 1px dashed currentColor;
	font-size: 0.875em;
}

/*
 * A menu's own page on a classic theme with no template for it
 * (templates/menu-page.php, MENU-B-087). Themes that already wrap the
 * content in a container just get a little extra padding.
 */
.tprm-page--classic {
	box-sizing: border-box;
	max-width: var(--wp--style--global--wide-size, 72rem);
	margin-inline: auto;
	padding: 2rem 1rem;
}

@media (min-width: 48em) {
	.tprm-page--classic {
		padding-block: 3rem;
	}
}

/*
 * Paper (MENU-B-015): keep items and section headings whole, swap badge
 * backgrounds (browsers skip them by default) for outlines, and keep the
 * dividers visible on white paper.
 */
@media print {
	:root {
		--tprm-line: color-mix(in srgb, currentColor 35%, transparent);
	}

	.tprm-section__head,
	.tprm-item,
	.tprm-legend {
		break-inside: avoid;
	}

	.tprm-section__head,
	.tprm-section__divider,
	.tprm-section__intro {
		break-after: avoid;
	}

	.tprm-diet {
		background: none;
		box-shadow: inset 0 0 0 1px var(--tprm-line);
	}

	/* Keep the chillies red (and a coloured special label) on paper; browsers may print colours grey. */
	.tprm-spice,
	.tprm-item__special {
		print-color-adjust: exact;
	}

	.tprm-notice,
	.tprm-menu__print,
	.tprm-menu__order,
	.tprm-filter {
		display: none;
	}
}
