/*
 * Miss Dolly Studios WooCommerce integration.
 * Scoped to WooCommerce screens so the editorial Book catalogue is unaffected.
 */

.mds-commerce,
body.woocommerce-cart .site-main,
body.woocommerce-checkout .site-main,
body.woocommerce-account .site-main {
	background: var(--mds-color-warm-paper);
}

.mds-commerce__section,
body.woocommerce-cart .site-main,
body.woocommerce-checkout .site-main,
body.woocommerce-account .site-main {
	padding-block: var(--mds-space-xl) var(--mds-space-2xl);
}

.mds-commerce__inner,
body.woocommerce-cart .site-main > .container,
body.woocommerce-checkout .site-main > .container,
body.woocommerce-account .site-main > .container {
	width: min(100% - (2 * var(--mds-space-md)), var(--mds-content-width));
	max-width: var(--mds-content-width);
	margin-inline: auto;
}

body.woocommerce-cart .entry,
body.woocommerce-checkout .entry,
body.woocommerce-account .entry {
	max-width: none;
}

body.woocommerce-cart .entry-header,
body.woocommerce-checkout .entry-header,
body.woocommerce-account .entry-header {
	margin-block-end: var(--mds-space-lg);
}

.woocommerce .woocommerce-breadcrumb {
	margin-block-end: var(--mds-space-lg);
	color: var(--mds-color-slate-grey);
	font-family: var(--mds-font-ui);
	font-size: var(--mds-font-size-xs);
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.woocommerce .woocommerce-breadcrumb a,
.woocommerce .woocommerce-MyAccount-navigation a,
.woocommerce .woocommerce-tabs a {
	color: var(--mds-color-sea-glass-green);
}

.woocommerce .page-title,
.woocommerce div.product .product_title,
.woocommerce .woocommerce-products-header__title,
.woocommerce-account .entry-title,
.woocommerce-cart .entry-title,
.woocommerce-checkout .entry-title {
	font-family: var(--mds-font-heading);
	font-weight: 600;
	line-height: var(--mds-line-height-tight);
}

.woocommerce .page-title,
.woocommerce .woocommerce-products-header__title,
.woocommerce-account .entry-title,
.woocommerce-cart .entry-title,
.woocommerce-checkout .entry-title {
	font-size: clamp(2.5rem, 6vw, var(--mds-font-size-3xl));
}

/* Buttons and form controls. */
.woocommerce a.button,
.woocommerce button.button,
.woocommerce a.button.alt,
.woocommerce button.button.alt,
.woocommerce input.button,
.woocommerce input.button.alt,
.woocommerce #respond input#submit,
:where(.woocommerce-cart, .woocommerce-checkout, .woocommerce-account) .wp-element-button,
:where(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-button {
	min-height: var(--mds-button-min-height);
	padding: var(--mds-button-padding-block) var(--mds-button-padding-inline);
	border: var(--mds-button-border-width) solid var(--mds-color-terracotta);
	border-radius: var(--mds-border-radius);
	background: var(--mds-color-terracotta);
	color: var(--mds-color-white);
	font-family: var(--mds-font-ui);
	font-size: var(--mds-font-size-sm);
	font-weight: 700;
	line-height: var(--mds-line-height-ui);
	text-decoration: none;
	transition: background-color var(--mds-transition-fast), border-color var(--mds-transition-fast), color var(--mds-transition-fast);
}

.woocommerce a.button:hover,
.woocommerce button.button:hover,
.woocommerce a.button.alt:hover,
.woocommerce button.button.alt:hover,
.woocommerce input.button:hover,
.woocommerce input.button.alt:hover,
.woocommerce #respond input#submit:hover,
.woocommerce a.button:focus-visible,
.woocommerce button.button:focus-visible,
.woocommerce a.button.alt:focus-visible,
.woocommerce button.button.alt:focus-visible,
.woocommerce input.button:focus-visible,
.woocommerce input.button.alt:focus-visible,
.woocommerce #respond input#submit:focus-visible,
:where(.woocommerce-cart, .woocommerce-checkout, .woocommerce-account) .wp-element-button:hover,
:where(.woocommerce-cart, .woocommerce-checkout, .woocommerce-account) .wp-element-button:focus-visible,
:where(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-button:hover,
:where(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-button:focus-visible {
	border-color: var(--mds-color-sea-glass-green);
	background: var(--mds-color-sea-glass-green);
	color: var(--mds-color-white);
}

.woocommerce :where(input.input-text, textarea, select),
:where(.woocommerce-cart, .woocommerce-checkout, .woocommerce-account) :where(input:not([type="checkbox"]):not([type="radio"]), textarea, select),
.wc-block-components-text-input input,
.wc-block-components-combobox .wc-block-components-combobox-control input.components-combobox-control__input {
	min-height: 2.85rem;
	border: var(--mds-border-width) solid rgba(75, 75, 75, 0.32);
	border-radius: var(--mds-border-radius);
	background: var(--mds-color-white);
	color: var(--mds-color-black);
	font: inherit;
}

.woocommerce :where(input.input-text, textarea, select):focus,
:where(.woocommerce-cart, .woocommerce-checkout, .woocommerce-account) :where(input:not([type="checkbox"]):not([type="radio"]), textarea, select):focus {
	border-color: var(--mds-color-sea-glass-green);
	outline: 2px solid rgba(95, 133, 117, 0.2);
	outline-offset: 1px;
}

.woocommerce form .form-row label,
.wc-block-components-form .wc-block-components-text-input label {
	color: var(--mds-color-black);
	font-family: var(--mds-font-ui);
	font-size: var(--mds-font-size-sm);
	font-weight: 600;
}

/* Notices. */
.woocommerce :where(.woocommerce-message, .woocommerce-info, .woocommerce-error),
:where(.woocommerce-cart, .woocommerce-checkout, .woocommerce-account) .wc-block-components-notice-banner {
	margin-block-end: var(--mds-space-md);
	padding: var(--mds-space-sm) var(--mds-space-md);
	border: 0;
	border-inline-start: 3px solid var(--mds-color-sea-glass-green);
	background: var(--mds-color-soft-ivory);
	color: var(--mds-color-black);
}

.woocommerce .woocommerce-error {
	border-inline-start-color: var(--mds-color-terracotta);
}

.woocommerce .woocommerce-message {
	position: relative;
	margin-block-end: 0;
	padding-inline-start: 3.25rem;
	background: var(--color-section-highlight);
}

.woocommerce .woocommerce-message::before {
	top: calc(var(--mds-space-sm) + 0.85em);
	left: var(--mds-space-md);
	line-height: 1;
	transform: translateY(-50%);
}

/* Single product. */
.woocommerce div.product {
	display: grid;
	grid-template-columns: minmax(17rem, 0.82fr) minmax(0, 1.18fr);
	gap: var(--mds-space-xl);
}

.woocommerce div.product div.images,
.woocommerce div.product div.summary {
	float: none;
	width: auto;
	margin: 0;
}

.woocommerce div.product div.images img {
	box-sizing: border-box;
	padding: var(--mds-space-xs);
	border: var(--mds-border-width) solid rgba(75, 75, 75, 0.14);
	background: var(--mds-color-white);
}

.woocommerce div.product .summary {
	align-self: center;
}

.woocommerce div.product .product_title {
	margin-block-end: var(--mds-space-sm);
	font-size: clamp(2.5rem, 5vw, 3.9rem);
}

.woocommerce div.product p.price,
.woocommerce div.product span.price {
	color: var(--mds-color-terracotta);
	font-family: var(--mds-font-heading);
	font-size: var(--mds-font-size-xl);
	font-weight: 600;
}

.woocommerce-product-details__short-description {
	margin-block: var(--mds-space-md);
	color: var(--mds-color-slate-grey);
}

.woocommerce div.product form.cart {
	display: flex;
	flex-wrap: wrap;
	gap: var(--mds-space-sm);
	align-items: stretch;
	margin-block: var(--mds-space-lg);
}

.woocommerce .quantity .qty {
	width: 4.5rem;
	height: 100%;
	min-height: var(--mds-button-min-height);
	padding-inline: var(--mds-space-xs);
	text-align: center;
}

.woocommerce div.product .product_meta {
	color: var(--mds-color-slate-grey);
	font-family: var(--mds-font-ui);
	font-size: var(--mds-font-size-sm);
	line-height: 1.8;
}

.woocommerce div.product .woocommerce-tabs,
.woocommerce div.product .related,
.woocommerce div.product .upsells {
	grid-column: 1 / -1;
	margin-block-start: var(--mds-space-lg);
}

.woocommerce div.product .woocommerce-tabs ul.tabs {
	display: flex;
	gap: var(--mds-space-md);
	margin: 0 0 var(--mds-space-lg);
	padding: 0;
	border-block-end: var(--mds-border-width) solid rgba(75, 75, 75, 0.2);
}

.woocommerce div.product .woocommerce-tabs ul.tabs::before,
.woocommerce div.product .woocommerce-tabs ul.tabs li::before,
.woocommerce div.product .woocommerce-tabs ul.tabs li::after {
	display: none;
}

.woocommerce div.product .woocommerce-tabs ul.tabs li {
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
}

.woocommerce div.product .woocommerce-tabs ul.tabs li a {
	display: block;
	padding: var(--mds-space-sm) 0;
	font-family: var(--mds-font-ui);
	font-size: var(--mds-font-size-sm);
	letter-spacing: 0.05em;
	text-transform: uppercase;
}

.woocommerce div.product .woocommerce-tabs .panel {
	max-width: var(--mds-content-narrow-width);
}

/* Shop and product archives. */
.woocommerce .woocommerce-products-header {
	margin-block-end: var(--mds-space-lg);
}

.woocommerce .woocommerce-result-count,
.woocommerce .woocommerce-ordering {
	margin-block-end: var(--mds-space-lg);
}

.woocommerce ul.products {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: var(--mds-space-xl) var(--mds-space-md);
	margin: 0;
}

.woocommerce ul.products::before,
.woocommerce ul.products::after {
	display: none;
}

.woocommerce ul.products li.product {
	display: flex;
	float: none;
	flex-direction: column;
	width: auto;
	margin: 0;
}

.woocommerce ul.products li.product a.woocommerce-LoopProduct-link {
	display: block;
	color: inherit;
	text-decoration: none;
}

.woocommerce ul.products li.product a img {
	box-sizing: border-box;
	margin-block-end: var(--mds-space-md);
	padding: var(--mds-space-xs);
	border: var(--mds-border-width) solid rgba(75, 75, 75, 0.14);
	background: var(--mds-color-white);
}

.woocommerce ul.products li.product.mds-book-product a img {
	width: 100%;
	aspect-ratio: 7 / 6;
	height: auto;
	object-fit: contain;
	object-position: center;
}

.woocommerce ul.products li.product .woocommerce-loop-product__title {
	padding: 0;
	font-family: var(--mds-font-heading);
	font-size: var(--mds-font-size-lg);
	font-weight: 600;
	line-height: var(--mds-line-height-heading);
}

.woocommerce ul.products li.product.mds-book-product .woocommerce-loop-product__title {
	margin-block-start: var(--mds-space-xs);
}

.woocommerce ul.products li.product .price {
	margin-block: var(--mds-space-xs) var(--mds-space-sm);
	color: var(--mds-color-terracotta);
	font-family: var(--mds-font-ui);
	font-size: var(--mds-font-size-sm);
	font-weight: bold;
}

.woocommerce ul.products li.product .button {
	align-self: flex-start;
	margin-block-start: auto;
}

/* Empty Cart block only; product cards reuse the Shop rules above. */
.woocommerce-cart .mds-empty-basket ul.products[class*="columns-"] li.product {
	/* Let the shared responsive grid size cards, overriding Woo's mobile floats. */
	float: none;
	width: auto;
	margin: 0;
}

.woocommerce-cart .mds-empty-basket__intro {
	margin-block-end: var(--mds-space-xl);
	text-align: center;
}

.woocommerce-cart .mds-empty-basket__portrait {
	display: block;
	width: 3.75rem;
	height: auto;
	margin: 0 auto var(--mds-space-sm);
}

.woocommerce-cart .mds-empty-basket__message,
.woocommerce-cart .mds-empty-basket__collection-title {
	font-family: var(--mds-font-heading);
	font-size: var(--mds-font-size-xl);
	font-weight: 600;
	line-height: var(--mds-line-height-heading);
}

.woocommerce-cart .mds-empty-basket__message {
	margin: 0 0 var(--mds-space-md);
}

.woocommerce-cart .mds-empty-basket__collection-title {
	margin: 0 0 var(--mds-space-lg);
	text-align: center;
}

/* Classic cart and checkout. */
.woocommerce table.shop_table,
.woocommerce .cart-collaterals .cart_totals,
.woocommerce-checkout #order_review,
.woocommerce form.login,
.woocommerce form.checkout_coupon,
.woocommerce form.register {
	border: var(--mds-border-width) solid rgba(75, 75, 75, 0.16);
	border-radius: var(--mds-border-radius);
	background: var(--mds-color-white);
}

.woocommerce table.shop_table {
	border-collapse: collapse;
}

.woocommerce table.shop_table th,
.woocommerce table.shop_table td {
	padding: var(--mds-space-sm);
	border-color: rgba(75, 75, 75, 0.14);
}

.woocommerce-cart .cart-collaterals .cart_totals {
	box-sizing: border-box;
	padding: var(--mds-space-md);
}

.woocommerce-checkout .col2-set,
.woocommerce-checkout #order_review_heading,
.woocommerce-checkout #order_review {
	box-sizing: border-box;
}

.woocommerce-checkout #order_review {
	padding: var(--mds-space-md);
}

.woocommerce-checkout h3,
.woocommerce-cart .cart_totals h2,
.woocommerce-account .woocommerce h2 {
	font-family: var(--mds-font-heading);
	font-size: var(--mds-font-size-xl);
}

/* Cart and Checkout blocks. */
:where(.woocommerce-cart, .woocommerce-checkout) :where(.wc-block-cart, .wc-block-checkout) {
	max-width: var(--mds-content-width);
	margin-inline: auto;
}

:where(.woocommerce-cart, .woocommerce-checkout) :where(.wc-block-cart-items, .wc-block-components-sidebar, .wc-block-components-order-summary) {
	border-color: rgba(75, 75, 75, 0.16);
}

:where(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-sidebar {
	box-sizing: border-box;
	padding: var(--mds-space-md);
	background: var(--mds-color-white);
}

:where(.woocommerce-cart, .woocommerce-checkout) :where(.wc-block-components-title, .wc-block-components-checkout-step__title, .wc-block-cart__totals-title) {
	font-family: var(--mds-font-heading);
}

/* My Account. */
.woocommerce-account .woocommerce {
	display: grid;
	grid-template-columns: minmax(12rem, 0.3fr) minmax(0, 1fr);
	gap: var(--mds-space-lg);
}

.woocommerce-account .woocommerce > h2,
.woocommerce-account .woocommerce > form,
.woocommerce-account .woocommerce > .woocommerce-notices-wrapper {
	grid-column: 1 / -1;
}

.woocommerce-account .woocommerce-form-login,
.woocommerce-account .woocommerce-form-register {
	max-width: 38rem;
	padding: var(--mds-space-lg);
}

.woocommerce-account .woocommerce-MyAccount-navigation ul {
	margin: 0;
	padding: 0;
	list-style: none;
}

.woocommerce-account .woocommerce-MyAccount-navigation li {
	border-block-end: var(--mds-border-width) solid rgba(75, 75, 75, 0.16);
}

.woocommerce-account .woocommerce-MyAccount-navigation a {
	display: block;
	padding: var(--mds-space-sm) 0;
	font-family: var(--mds-font-ui);
	font-size: var(--mds-font-size-sm);
	text-decoration: none;
}

.woocommerce-account .woocommerce-MyAccount-content {
	min-width: 0;
}

/* Store-only coming-soon output bypasses classic WooCommerce wrappers. */
.woocommerce-shop .wp-block-woocommerce-coming-soon {
	box-sizing: border-box;
	min-height: 32rem;
	padding-inline: var(--mds-space-md);
	background: var(--mds-color-warm-paper);
}

.woocommerce-shop .wp-block-woocommerce-coming-soon h1 {
	color: var(--mds-color-black);
	font-family: var(--mds-font-heading);
	font-size: clamp(2.5rem, 6vw, var(--mds-font-size-3xl));
}

.woocommerce-shop .wp-block-woocommerce-coming-soon p {
	color: var(--mds-color-slate-grey);
	font-family: var(--mds-font-body);
}

@media (max-width: 64rem) {
	.woocommerce ul.products {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.woocommerce div.product {
		gap: var(--mds-space-lg);
	}
}

@media (max-width: 48rem) {
	.woocommerce .woocommerce-message {
		display: flex;
		align-items: center;
		flex-direction: column;
		padding-inline-start: var(--mds-space-md);
		text-align: center;
	}

	.woocommerce .woocommerce-message::before {
		position: static;
		order: -1;
		margin-block-end: var(--mds-space-xs);
		line-height: 1;
		transform: none;
	}

	.woocommerce .woocommerce-message .wc-forward {
		float: none;
		order: 2;
		margin: var(--mds-space-sm) 0 0;
	}

	.mds-commerce__section,
	body.woocommerce-cart .site-main,
	body.woocommerce-checkout .site-main,
	body.woocommerce-account .site-main {
		padding-block: var(--mds-space-lg) var(--mds-space-xl);
	}

	.woocommerce div.product,
	.woocommerce-account .woocommerce {
		grid-template-columns: minmax(0, 1fr);
	}

	.woocommerce div.product .summary {
		align-self: auto;
	}

	.woocommerce-account .woocommerce > h2,
	.woocommerce-account .woocommerce > form {
		grid-column: auto;
	}

	.woocommerce-account .woocommerce-MyAccount-navigation ul {
		display: flex;
		flex-wrap: wrap;
		gap: 0 var(--mds-space-md);
	}
}

@media (max-width: 35rem) {
	.mds-commerce__inner,
	body.woocommerce-cart .site-main > .container,
	body.woocommerce-checkout .site-main > .container,
	body.woocommerce-account .site-main > .container {
		width: min(100% - (2 * var(--mds-space-sm)), var(--mds-content-width));
	}

	.woocommerce ul.products {
		grid-template-columns: minmax(0, 1fr);
	}

	.woocommerce .woocommerce-ordering,
	.woocommerce .woocommerce-result-count {
		float: none;
	}

	.woocommerce div.product form.cart {
		align-items: stretch;
	}

	.woocommerce div.product form.cart .button {
		flex: 1 1 auto;
	}

	.woocommerce div.product .woocommerce-tabs ul.tabs {
		flex-wrap: wrap;
		gap: 0 var(--mds-space-md);
	}

	.woocommerce table.shop_table_responsive tr td,
	.woocommerce-page table.shop_table_responsive tr td {
		padding: var(--mds-space-sm);
	}
}
