/* Single-product refinements; the theme retains the desktop page composition. */
@media (min-width: 769px) {
	body.single-product main {
		box-sizing: border-box;
		width: min(calc(100% - 2 * var(--mc-gutter)), var(--mc-wide-max));
		max-width: none;
		margin-inline: auto;
	}

}

@media (min-width: 782px) {
	body.single-product main .wp-block-columns:has(.wp-block-woocommerce-product-gallery) > .wp-block-column,
	body.single-product main .wp-block-columns:has(.woocommerce-product-gallery) > .wp-block-column {
		min-width: 0;
	}

	body.single-product main .wp-block-columns:has(.wp-block-woocommerce-product-gallery) > .wp-block-column:first-child,
	body.single-product main .wp-block-columns:has(.woocommerce-product-gallery) > .wp-block-column:first-child {
		flex: 0 0 var(--mc-product-gallery-width) !important;
	}

	body.single-product main .wp-block-columns:has(.mc-product-specs) {
		align-items: flex-start;
	}

	body.single-product main .wp-block-columns:has(.mc-product-specs) > .wp-block-column {
		min-width: 0;
	}

	body.single-product main .wp-block-columns:has(.mc-product-specs) > .wp-block-column:first-child {
		flex: 0 0 var(--mc-product-gallery-width) !important;
	}

	body.single-product main .wp-block-columns:has(.mc-product-specs) > .wp-block-column:last-child {
		flex: 1 1 0 !important;
	}

	body.single-product main .wp-block-columns:has(.mc-product-specs) > .wp-block-column > .wp-block-group:has(> .mc-product-specs) {
		width: 100%;
		margin-block: 0 !important;
	}

	body.single-product main > .wc-block-product-description {
		width: min(100%, 52rem);
		max-width: 52rem;
		margin-inline: auto;
	}
}

/* Stack both product rows when the real purchase column can no longer hold its controls. */
body.single-product.mc-product-layout-stacked main .wp-block-columns:has(.wp-block-woocommerce-product-gallery),
body.single-product.mc-product-layout-stacked main .wp-block-columns:has(.woocommerce-product-gallery),
body.single-product.mc-product-layout-stacked main .wp-block-columns:has(.mc-product-specs) {
	flex-direction: column;
}

body.single-product.mc-product-layout-stacked main .wp-block-columns:has(.wp-block-woocommerce-product-gallery) > .wp-block-column,
body.single-product.mc-product-layout-stacked main .wp-block-columns:has(.woocommerce-product-gallery) > .wp-block-column,
body.single-product.mc-product-layout-stacked main .wp-block-columns:has(.mc-product-specs) > .wp-block-column:first-child,
body.single-product.mc-product-layout-stacked main .wp-block-columns:has(.mc-product-specs) > .wp-block-column:last-child {
	flex: 0 0 auto !important;
	width: 100%;
}

/* Keep quantity and the primary cart action as one indivisible control row. */
body.single-product form.wp-block-add-to-cart-with-options .woocommerce-variation-add-to-cart,
body.single-product form.wp-block-add-to-cart-with-options > .wp-block-group:has(> .wp-block-add-to-cart-with-options-quantity-selector):has(> .wp-block-woocommerce-product-button) {
	display: flex !important;
	flex-flow: row nowrap !important;
	align-items: stretch;
	gap: 0.75rem;
}

body.single-product form.wp-block-add-to-cart-with-options .woocommerce-variation-add-to-cart > :where(.quantity, .wc-block-components-product-button),
body.single-product form.wp-block-add-to-cart-with-options > .wp-block-group:has(> .wp-block-add-to-cart-with-options-quantity-selector):has(> .wp-block-woocommerce-product-button) > :where(.wp-block-add-to-cart-with-options-quantity-selector, .wp-block-woocommerce-product-button) {
	flex: 0 0 auto !important;
	width: auto !important;
	margin: 0;
}

body.single-product form.wp-block-add-to-cart-with-options :where(.woocommerce-variation-add-to-cart, .wp-block-woocommerce-product-button) .single_add_to_cart_button {
	width: auto !important;
	white-space: nowrap;
}

body.single-product form.wp-block-add-to-cart-with-options > .wp-block-buttons {
	display: none;
}

body.single-product.mc-product-in-cart form.wp-block-add-to-cart-with-options > .wp-block-buttons {
	display: flex;
}

body.single-product .mc-product-specs {
	width: 100%;
	margin: 0 0 2rem;
	border-collapse: collapse;
	background: transparent;
	font-size: 0.95rem;
	line-height: 1.45;
}

body.single-product .mc-product-specs :where(th, td) {
	padding: 0.55rem 0;
	border-bottom: 1px solid var(--mc-border);
	vertical-align: top;
}

body.single-product .mc-product-specs th {
	width: 34%;
	padding-right: 1.25rem;
	color: var(--mc-accent);
	font-weight: 600;
	text-align: left;
	white-space: nowrap;
}

body.single-product .mc-product-specs td {
	color: var(--mc-ink);
	text-align: left;
}

body.single-product .mc-product-specs tr:last-child :where(th, td) {
	border-bottom: 0;
}

body.single-product .mc-product-specification-toggle {
	display: none;
}

body.single-product .mc-roast-level {
	display: inline-flex;
	align-items: center;
	gap: 0.15rem;
}

body.single-product .mc-roast-bean {
	display: block;
	flex: 0 0 auto;
	width: 1.25rem;
	height: 1.25rem;
}

body.single-product .mc-roast-value {
	margin-left: 0.35rem;
	color: var(--mc-subtle);
	font-size: 0.85rem;
}

body.single-product .mc-help {
	position: relative;
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	width: 1.1rem !important;
	min-width: 1.1rem !important;
	height: 1.1rem !important;
	min-height: 1.1rem !important;
	margin-left: 0.35rem;
	padding: 0 !important;
	border: 1px solid currentcolor !important;
	border-radius: 50% !important;
	background: transparent !important;
	box-shadow: none !important;
	color: #777 !important;
	font-size: 0.7rem !important;
	font-style: normal;
	font-weight: 600;
	line-height: 1 !important;
	vertical-align: middle;
	cursor: help;
}

body.single-product .mc-tooltip {
	position: absolute;
	top: calc(100% + 0.45rem);
	left: 50%;
	z-index: 20;
	box-sizing: border-box;
	width: max-content;
	max-width: min(18rem, calc(100vw - 2 * var(--mc-gutter)));
	padding: 0.625rem 0.75rem;
	border-radius: var(--mc-radius-sm);
	background: var(--mc-accent-deep);
	box-shadow: var(--mc-shadow-soft);
	color: #fff;
	font-size: 0.8125rem;
	font-weight: 400;
	line-height: 1.45;
	text-align: left;
	white-space: normal;
	word-break: normal;
	overflow-wrap: normal;
	writing-mode: horizontal-tb;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transform: translateX(-50%) translateY(-0.15rem);
	transition:
		opacity var(--mc-motion-fast) ease,
		transform var(--mc-motion-fast) ease,
		visibility var(--mc-motion-fast) ease;
}

body.single-product .mc-help:is(:hover, :focus, :focus-visible) .mc-tooltip,
body.single-product .mc-help:focus-within .mc-tooltip {
	opacity: 1;
	visibility: visible;
	transform: translateX(-50%) translateY(0);
}

body.single-product .mc-roast-scale-help {
	margin-left: 0.4rem;
}

body.single-product .mc-roast-scale-tooltip {
	width: 18rem;
	max-width: min(18rem, calc(100vw - 2 * var(--mc-gutter)));
	padding: 0.7rem 0.8rem;
}

body.single-product .mc-roast-scale-tooltip__title {
	display: block;
	margin-bottom: 0.35rem;
	color: #fff;
	font-size: 0.75rem;
	font-weight: 600;
	line-height: 1.35;
}

body.single-product .mc-roast-scale-table {
	width: 100%;
	margin: 0;
	border-collapse: collapse;
	background: transparent;
	font-size: 0.72rem;
	line-height: 1.3;
}

body.single-product .mc-product-specs .mc-roast-scale-table :where(th, td) {
	padding: 0.16rem 0;
	border: 0;
	color: #fff;
	font-weight: 400;
	text-align: left;
	vertical-align: top;
}

body.single-product .mc-product-specs .mc-roast-scale-table tbody th {
	width: 1.5rem;
	padding-right: 0.4rem;
	font-weight: 600;
}

@media (max-width: 768px) {
	body.single-product main {
		box-sizing: border-box;
		padding-inline: var(--mc-gutter);
	}

	body.single-product main .wp-block-columns:has(.mc-product-specs) {
		row-gap: 1rem;
		margin-bottom: 1rem !important;
		padding-bottom: 0 !important;
	}

	body.single-product main .wp-block-columns:has(.mc-product-specs) .mc-product-specs {
		margin-bottom: 0.5rem !important;
	}

	body.single-product .mc-product-specification-toggle {
		display: flex;
		align-items: center;
		justify-content: space-between;
		box-sizing: border-box;
		width: 100%;
		min-height: 2.75rem;
		margin: 0 0 0.5rem;
		padding: 0.25rem 0;
		border: 0;
		border-radius: 0;
		background: transparent;
		box-shadow: none;
		color: var(--mc-ink);
		font: inherit;
		font-size: 1.25rem;
		font-weight: 600;
		text-align: left;
		cursor: pointer;
	}

	body.single-product .mc-product-specification-toggle[hidden],
	body.single-product .mc-product-specification-heading[hidden],
	body.single-product .mc-product-specification-panel[hidden] {
		display: none !important;
	}

	body.single-product .mc-product-specification-toggle[aria-expanded="false"] {
		margin-bottom: 0;
	}

	body.single-product .mc-product-specification-toggle:focus-visible {
		outline: 2px solid var(--mc-accent);
		outline-offset: 3px;
	}

	body.single-product .mc-product-specification-toggle__icon {
		flex: 0 0 auto;
		width: 0.55rem;
		height: 0.55rem;
		margin: 0 0.25rem 0 1rem;
		border-right: 2px solid currentcolor;
		border-bottom: 2px solid currentcolor;
		transform: translateY(-0.15rem) rotate(45deg);
		transition: transform var(--mc-motion-fast) ease;
	}

	body.single-product .mc-product-specification-toggle[aria-expanded="false"] .mc-product-specification-toggle__icon {
		transform: translateX(-0.15rem) rotate(-45deg);
	}

	body.single-product div.product .woocommerce-product-gallery,
	body.single-product div.product .summary {
		float: none;
		width: 100%;
	}

	body.single-product div.product .woocommerce-product-gallery {
		margin-bottom: 2.5rem;
	}

	body.single-product div.product .summary .product_title {
		font-size: clamp(1.75rem, 8vw, 2.25rem);
		line-height: 1.12;
	}

	body.single-product div.product form.cart:not(.variations_form):not(.wp-block-add-to-cart-with-options) {
		display: grid;
		grid-template-columns: minmax(5.5rem, auto) 1fr;
		gap: 0.75rem;
	}

	body.single-product div.product form.cart:not(.variations_form):not(.wp-block-add-to-cart-with-options) :where(.quantity, .single_add_to_cart_button) {
		margin: 0;
	}

	body.single-product div.product .summary > :where(a.button, .button):not(.single_add_to_cart_button) {
		width: 100%;
		margin-top: 0.75rem;
	}

	body.single-product .mc-product-specs th {
		width: 38%;
		padding-right: 1rem;
		font-size: 0.95rem;
		line-height: 1.45;
		white-space: nowrap;
		word-break: normal;
		overflow-wrap: normal;
		hyphens: none;
	}

	body.single-product .mc-tooltip {
		left: 0;
		width: min(13rem, 55vw);
		max-width: none;
		transform: translateY(-0.15rem);
	}

	body.single-product .mc-help:is(:hover, :focus, :focus-visible) .mc-tooltip,
	body.single-product .mc-help:focus-within .mc-tooltip {
		transform: translateY(0);
	}

	body.single-product .mc-roast-scale-tooltip {
		right: 0;
		left: auto;
		width: min(16rem, calc(100vw - 2 * var(--mc-gutter)));
	}
}

@media (prefers-reduced-motion: reduce) {
	body.single-product .mc-tooltip,
	body.single-product .mc-product-specification-toggle__icon {
		transition: none;
	}
}
