/**
 * TheSouke — Products page, Product details and Cart.
 *
 * Geometry transcribed from the Figma frames "Products Page" (28:1442),
 * "Product Details" (28:1192) and "Cart" (31:2434). Tokens come from
 * theme.json; only composition lives here.
 *
 * Loaded alongside woocommerce.css, which carries the shared card, button and
 * form styling these three pages build on.
 */

/* ===========================================================================
 * 1. Products page — title row and filter bar
 * ======================================================================== */

.woocommerce-products-header {
	align-items: center;
	column-gap: 1.5rem;
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	margin-block-end: clamp(1.5rem, 3vw, 2.5rem);
	row-gap: 1rem;
}

.woocommerce-products-header__title,
.thesouke-page-title {
	font-family: var(--wp--preset--font-family--display-serif);
	font-size: var(--wp--preset--font-size--display-medium);
	font-weight: 400;
	line-height: 1.05;
	margin: 0;
}

.thesouke-shop-toolbar {
	align-items: center;
	display: flex;
	flex-wrap: wrap;
	gap: 1rem;
}

/* Each filter is a <details>, so both menus open without JavaScript. */
.thesouke-filter {
	position: relative;
}

.thesouke-filter > summary {
	align-items: center;
	background: var(--wp--preset--color--base);
	border-radius: var(--wp--custom--radius--chip, 24px);
	cursor: pointer;
	display: flex;
	font-size: var(--wp--preset--font-size--medium);
	gap: 0.25rem;
	line-height: 1;
	list-style: none;
	padding: 0.75rem 1.5rem;
	user-select: none;
	white-space: nowrap;
}

.thesouke-filter > summary::-webkit-details-marker {
	display: none;
}

.thesouke-filter > summary svg {
	display: block;
	height: 20px;
	transition: rotate var(--thesouke-transition);
	width: 20px;
}

.thesouke-filter[open] > summary svg {
	rotate: 180deg;
}

.thesouke-filter__menu {
	background: var(--wp--preset--color--base);
	border-radius: 16px;
	box-shadow: var(--wp--preset--shadow--card-hover);
	display: flex;
	flex-direction: column;
	inset-block-start: calc(100% + 0.5rem);
	inset-inline-end: 0;
	min-width: 220px;
	padding: 0.5rem;
	position: absolute;
	z-index: 20;
}

.thesouke-filter__menu a {
	border-radius: 10px;
	color: var(--wp--preset--color--primary-950);
	font-size: var(--wp--preset--font-size--small);
	padding: 0.625rem 0.875rem;
	text-decoration: none;
	white-space: nowrap;
}

.thesouke-filter__menu a:hover,
.thesouke-filter__menu a:focus-visible {
	background: var(--wp--preset--color--canvas);
	color: var(--wp--preset--color--primary);
}

.thesouke-filter__menu a[aria-current] {
	background: var(--wp--preset--color--canvas);
	font-weight: 500;
}

/* ===========================================================================
 * 2. Product details
 * ======================================================================== */

/*
 * Gallery on the left spanning the full height; the summary and the tab panel
 * stack in the right-hand column, so the tabs sit directly under the delivery
 * line as designed rather than dropping below the (taller) gallery.
 */
.woocommerce div.product {
	background: var(--wp--preset--color--base);
	border-radius: var(--wp--custom--radius--card, 24px);
	column-gap: clamp(1.5rem, 3vw, 2.5rem);
	display: grid;
	grid-template-columns: minmax(0, 500px) minmax(0, 1fr);
	grid-template-rows: auto 1fr;
	padding: clamp(1.25rem, 2.4vw, 2.5rem);
	row-gap: 2rem;
}

/*
 * WooCommerce floats these at 48% via `.woocommerce div.product div.images`
 * and `div.summary`, which out-specify a plain child selector — the gallery
 * would end up 48% of its own grid column. The class is repeated here purely to
 * win that specificity contest.
 */
.woocommerce div.product div.images.woocommerce-product-gallery {
	float: none;
	grid-column: 1;
	grid-row: 1 / span 2;
	margin: 0;
	width: auto;
}

.woocommerce div.product div.summary.entry-summary {
	float: none;
	grid-column: 2;
	grid-row: 1;
	margin: 0;
	width: auto;
}

.woocommerce div.product .woocommerce-product-gallery__wrapper {
	margin: 0;
}

/* Designed crop is 500 x 642. */
.woocommerce div.product .woocommerce-product-gallery__image:first-child img {
	aspect-ratio: 500 / 642;
	border-radius: 0;
	object-fit: cover;
	width: 100%;
}

/*
 * The chip above the title already names the category, so the stock meta line
 * under the buttons is redundant here.
 */
.woocommerce div.product .product_meta {
	display: none;
}

/* Rating and category chip sit above the title, aligned right. */
.thesouke-meta--single {
	justify-content: flex-end;
	margin-block-end: 0.5rem;
}

.thesouke-meta--single .thesouke-rating svg {
	height: 24px;
	width: 24px;
}

.thesouke-meta--single .thesouke-chip {
	font-size: var(--wp--preset--font-size--small);
	padding: 0.5rem;
}

.thesouke-meta--single .thesouke-chip svg {
	height: 24px;
	width: 24px;
}

.woocommerce div.product .product_title {
	font-family: var(--wp--preset--font-family--clash-display);
	font-size: clamp(2rem, 3.2vw, 3rem);
	font-weight: 400;
	line-height: 1;
	margin: 0 0 1.5rem;
}

.woocommerce div.product p.price,
.woocommerce div.product span.price {
	color: var(--wp--preset--color--contrast);
	font-size: clamp(1.5rem, 2.2vw, 2rem);
	font-weight: 600;
	line-height: 1;
	margin: 0 0 2.5rem;
}

.woocommerce div.product .woocommerce-product-details__short-description {
	font-size: var(--wp--preset--font-size--small);
	font-weight: 300;
	line-height: 1.5;
	margin-block-end: 2rem;
}

/*
 * Summary column, laid out to the design (28:1192): the rating chip is pinned
 * right, the title runs full width, and the quantity stepper sits on the price
 * row against the right edge — not below it.
 *
 * The stepper has to stay inside the add-to-cart form to submit, so the form
 * dissolves with `display: contents` and its children are placed on this grid
 * directly. Rows are numbered explicitly because WooCommerce's summary hooks
 * emit these children in a known order.
 */
.woocommerce div.product div.summary.entry-summary {
	align-items: start;
	column-gap: 1.5rem;
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
}

/* Anything not placed below spans the column. */
.woocommerce div.product div.summary.entry-summary > * {
	grid-column: 1 / -1;
}

.woocommerce div.product .thesouke-meta--single {
	grid-row: 1;
}

.woocommerce div.product .product_title {
	grid-row: 2;
}

/* Price and stepper share a row and sit on the same baseline, as drawn. */
.woocommerce div.product p.price {
	align-self: end;
	grid-column: 1;
	grid-row: 3;
	margin-block-end: 0;
	padding-block-end: 2.5rem;
}

.woocommerce div.product .woocommerce-product-details__short-description {
	grid-row: 4;
}

.woocommerce div.product form.cart {
	display: contents;
}

.woocommerce div.product form.cart::before,
.woocommerce div.product form.cart::after {
	content: none;
}

/* Level with the price, hard right. */
.woocommerce div.product form.cart .quantity {
	align-self: end;
	float: none;
	grid-column: 2;
	grid-row: 3;
	justify-self: end;
	margin: 0;
}

/* Buy Now + Add to Cart, at the design's 250:417 split. */
.thesouke-actions {
	display: grid;
	gap: 1rem;
	grid-column: 1 / -1;
	grid-row: 5;
	grid-template-columns: minmax(0, 250fr) minmax(0, 417fr);
}

/* Variable and grouped products add their own tables; keep them in the flow. */
.woocommerce div.product form.cart .variations,
.woocommerce div.product form.cart .single_variation_wrap,
.woocommerce div.product form.cart .woocommerce-variation,
.woocommerce div.product form.cart .woocommerce-variation-add-to-cart,
.woocommerce div.product form.cart .group_table,
.woocommerce div.product form.cart .woocommerce-grouped-product-list {
	grid-column: 1 / -1;
}

.woocommerce div.product .thesouke-delivery {
	grid-row: 6;
}

.woocommerce div.product form.cart .thesouke-buy-now,
.thesouke-buy-now {
	align-items: center;
	background: var(--wp--preset--color--base);
	border: 1px solid var(--wp--preset--color--primary-200);
	border-radius: var(--wp--custom--radius--pill, 50px);
	box-sizing: border-box;
	color: var(--wp--preset--color--primary);
	cursor: pointer;
	display: inline-flex;
	float: none;
	font-family: var(--wp--preset--font-family--clash-display);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 500;
	height: 52px;
	justify-content: center;
	line-height: 1;
	padding-block: 0;
	padding-inline: 1.5rem;
	text-align: center;
	transition: background-color var(--thesouke-transition), border-color var(--thesouke-transition), transform var(--thesouke-transition);
	width: 100%;
}

.thesouke-buy-now:hover,
.thesouke-buy-now:focus-visible {
	background: var(--wp--preset--color--canvas);
	border-color: var(--wp--preset--color--primary);
}

/*
 * The primary button carries the basket glyph from the design.
 *
 * woocommerce-blocktheme.css sets `display:inline-block` via
 * `.woocommerce div.product form.cart button.single_add_to_cart_button`, which
 * out-specifies a class-only selector — without the extra class here the glyph
 * lands on its own line above the label and the button grows to 68px.
 */
.woocommerce div.product form.cart .single_add_to_cart_button.button {
	align-items: center;
	box-sizing: border-box;
	display: inline-flex;
	float: none;
	gap: 0.625rem;
	height: 52px;
	justify-content: center;
	min-height: 52px;
	padding-block: 0;
	width: 100%;
}

.woocommerce div.product form.cart .single_add_to_cart_button::before {
	background-color: currentColor;
	content: "";
	display: block;
	flex: 0 0 auto;
	height: 20px;
	mask: url("../icons/basket-white.svg") no-repeat center / 20px 20px;
	width: 20px;
}

.thesouke-delivery {
	align-items: center;
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem 1rem;
	margin-block: 1.5rem 0;
}

.thesouke-delivery svg {
	display: block;
	height: 24px;
	width: 24px;
}

.thesouke-delivery__label {
	font-size: var(--wp--preset--font-size--medium);
	font-weight: 500;
	margin-inline-end: 0.5rem;
}

.thesouke-delivery__value {
	font-size: var(--wp--preset--font-size--medium);
}

/* Tabs read as underlined labels, not boxes. */
.woocommerce div.product .woocommerce-tabs {
	align-self: start;
	grid-column: 2;
	grid-row: 2;
}

.woocommerce div.product .woocommerce-tabs ul.tabs {
	display: flex;
	flex-wrap: wrap;
	gap: 1.5rem;
	list-style: none;
	margin: 0 0 1.5rem;
	padding: 0;
}

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

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

.woocommerce div.product .woocommerce-tabs ul.tabs li a {
	border-bottom: 1px solid var(--wp--preset--color--neutral-500);
	color: var(--wp--preset--color--neutral-500);
	display: inline-block;
	font-size: var(--wp--preset--font-size--small);
	font-weight: 300;
	padding: 0 0 0.5rem;
	text-decoration: none;
}

.woocommerce div.product .woocommerce-tabs ul.tabs li.active a,
.woocommerce div.product .woocommerce-tabs ul.tabs li a:hover {
	border-bottom-color: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--contrast);
	font-weight: 500;
}

.woocommerce div.product .woocommerce-tabs .panel {
	font-size: var(--wp--preset--font-size--medium);
	font-weight: 300;
	margin: 0;
	padding: 0;
}

.woocommerce div.product .woocommerce-tabs .panel > h2:first-child {
	display: none;
}

/* Related products drop out of the card grid. */
.woocommerce div.product .related,
.woocommerce div.product .upsells {
	grid-column: 1 / -1;
	margin-block-start: 2rem;
}

@media (max-width: 900px) {
	.woocommerce div.product {
		grid-template-columns: minmax(0, 1fr);
		grid-template-rows: none;
	}

	/* Single column: let everything flow in source order. */
	.woocommerce div.product div.images.woocommerce-product-gallery,
	.woocommerce div.product div.summary.entry-summary,
	.woocommerce div.product .woocommerce-tabs,
	.woocommerce div.product .related,
	.woocommerce div.product .upsells {
		grid-column: 1;
		grid-row: auto;
	}

	.woocommerce div.product form.cart .quantity {
		justify-self: start;
	}
}

/* ===========================================================================
 * 3. Quantity stepper — shared by the product page and the cart
 * ======================================================================== */

/*
 * The last selector matches WooCommerce's own
 * `:where(...) div.product form.cart .quantity`, which would otherwise force
 * display:inline-block and stack the controls.
 */
.thesouke-stepper,
.woocommerce .quantity.thesouke-stepper,
.woocommerce div.product form.cart .quantity.thesouke-stepper {
	align-items: center;
	background: var(--wp--preset--color--neutral-50);
	border-radius: 4px;
	box-sizing: border-box;
	display: inline-flex;
	float: none;
	gap: 1.25rem;
	height: 52px;
	padding: 0 1.5rem;
	width: auto;
}

.thesouke-stepper input.qty,
.woocommerce .quantity.thesouke-stepper input.qty {
	appearance: textfield;
	background: none;
	border: 0;
	box-shadow: none;
	color: inherit;
	font-family: var(--wp--preset--font-family--clash-display);
	font-size: var(--wp--preset--font-size--large);
	line-height: 1;
	margin: 0;
	min-height: 0;
	padding: 0;
	text-align: center;
	width: 3ch;
}

.thesouke-stepper input.qty::-webkit-outer-spin-button,
.thesouke-stepper input.qty::-webkit-inner-spin-button {
	appearance: none;
	margin: 0;
}

.thesouke-stepper input.qty:focus-visible {
	outline: 2px solid var(--wp--preset--color--primary);
	outline-offset: 4px;
}

.thesouke-stepper__button {
	align-items: center;
	background: none;
	border: 0;
	color: inherit;
	cursor: pointer;
	display: inline-flex;
	justify-content: center;
	padding: 0;
}

.thesouke-stepper__button svg {
	display: block;
	height: 20px;
	width: 20px;
}

.thesouke-stepper__button:hover svg,
.thesouke-stepper__button:focus-visible svg {
	opacity: 0.6;
}

/* ===========================================================================
 * 4. Cart
 * ======================================================================== */

/*
 * woocommerce-blocktheme.css caps the cart at 1000px with
 * `.woocommerce-cart main .woocommerce`, which out-specifies a two-class
 * selector. The extra class here wins that outright rather than relying on
 * stylesheet order, so the item panel and summary get the 1038px and 506px
 * columns the design draws.
 */
.thesouke-cart-page.wp-block-group .woocommerce {
	align-items: start;
	display: grid;
	gap: 1.5rem;
	grid-template-columns: minmax(0, 1fr) minmax(300px, 506px);
	margin-inline: auto;
	max-width: var(--thesouke-max);
	width: 100%;
}

.thesouke-cart-page .woocommerce > .woocommerce-notices-wrapper,
.thesouke-cart-page .woocommerce > .cart-empty,
.thesouke-cart-page .woocommerce > .return-to-shop,
.thesouke-cart-page .woocommerce > .wc-empty-cart-message {
	grid-column: 1 / -1;
}

.thesouke-cart-page .woocommerce > .cart-collaterals {
	width: auto;
}

.thesouke-cart-page .cart-collaterals .cross-sells {
	float: none;
	width: auto;
}

/* --- item panel --- */

.thesouke-cart {
	background: var(--wp--preset--color--base);
	border: 1px solid var(--wp--preset--color--neutral-200);
	border-radius: var(--wp--custom--radius--card, 24px);
	padding: clamp(1.25rem, 2.4vw, 2.5rem);
}

.thesouke-cart__row {
	align-items: center;
	column-gap: 1.5rem;
	display: grid;
	grid-template-columns: 20px 160px minmax(0, 1fr) auto;
	padding-block: 1rem;
	row-gap: 1rem;
}

.thesouke-cart__row + .thesouke-cart__row {
	border-block-start: 1px solid rgba(66, 31, 19, 0.12);
}

.thesouke-cart__marker {
	display: inline-flex;
}

.thesouke-cart__marker svg {
	display: block;
	height: 20px;
	width: 20px;
}

.thesouke-cart__media {
	display: block;
	height: 172px;
	overflow: hidden;
	width: 160px;
}

.thesouke-cart__media img {
	border-radius: 0;
	height: 100%;
	object-fit: cover;
	width: 100%;
}

.thesouke-cart__info {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

.thesouke-cart__title {
	font-family: var(--wp--preset--font-family--clash-display);
	font-size: var(--wp--preset--font-size--xx-large);
	font-weight: 400;
	line-height: 1;
	margin: 0;
}

.thesouke-cart__title a {
	color: inherit;
	text-decoration: none;
}

.thesouke-cart__price {
	font-size: var(--wp--preset--font-size--x-large);
	font-weight: 600;
	line-height: 1;
	margin: 0;
}

.thesouke-cart__actions {
	align-items: center;
	display: flex;
	gap: 1.5rem;
}

.thesouke-cart__remove,
.woocommerce a.remove.thesouke-cart__remove {
	align-items: center;
	background: none;
	color: var(--wp--preset--color--neutral-500);
	display: inline-flex;
	font-size: inherit;
	height: 24px;
	justify-content: center;
	width: 24px;
}

.thesouke-cart__remove:hover,
.woocommerce a.remove.thesouke-cart__remove:hover {
	background: none;
	color: var(--wp--preset--color--danger);
}

.thesouke-cart__remove svg {
	display: block;
	height: 24px;
	width: 24px;
}

.thesouke-cart__footer {
	align-items: center;
	border-block-start: 1px solid rgba(66, 31, 19, 0.12);
	display: flex;
	flex-wrap: wrap;
	gap: 1rem;
	justify-content: space-between;
	margin-block-start: 1rem;
	padding-block-start: 1.5rem;
}

.thesouke-cart__footer .coupon {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.thesouke-cart__footer .coupon .input-text {
	min-width: 12rem;
}

/* --- summary panel --- */

.thesouke-summary {
	float: none;
	width: auto;
}

.thesouke-summary__heading {
	font-family: var(--wp--preset--font-family--display-serif);
	font-size: clamp(1.75rem, 2.6vw, 2.5rem);
	font-weight: 400;
	line-height: 1.05;
	margin: 0 0 1.25rem;
}

.thesouke-summary__panel {
	border: 1px solid var(--wp--preset--color--neutral-200);
	border-radius: var(--wp--custom--radius--card, 24px);
	display: flex;
	flex-direction: column;
	gap: 2.5rem;
	padding: 1.5rem 1rem;
}

.thesouke-summary__location .shipping-calculator-button {
	align-items: center;
	background: var(--wp--preset--color--base);
	border: 1px solid var(--wp--preset--color--neutral-200);
	border-radius: 30px;
	color: var(--wp--preset--color--contrast);
	display: flex;
	font-size: var(--wp--preset--font-size--medium);
	gap: 1rem;
	line-height: 1;
	padding: 1rem 1.5rem;
	text-decoration: none;
	width: 100%;
}

.thesouke-summary__location .shipping-calculator-button::before {
	background-color: currentColor;
	content: "";
	display: block;
	flex: 0 0 auto;
	height: 24px;
	mask: url("../icons/location.svg") no-repeat center / 24px 24px;
	width: 24px;
}

.thesouke-summary__location .shipping-calculator-form {
	padding-block-start: 1rem;
}

.thesouke-summary__rows {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

.thesouke-summary__row {
	align-items: center;
	display: flex;
	font-size: var(--wp--preset--font-size--small);
	gap: 1rem;
	justify-content: space-between;
	line-height: 1;
}

.thesouke-summary__row + .thesouke-summary__row {
	border-block-start: 1px solid var(--wp--preset--color--neutral-200);
	padding-block-start: 1rem;
}

.thesouke-summary__value {
	font-weight: 500;
	text-align: end;
}

.thesouke-summary__row--total {
	padding-block-start: 1.5rem;
}

.thesouke-summary__row--total .thesouke-summary__value {
	font-weight: 600;
}

.thesouke-summary__shipping {
	font-size: var(--wp--preset--font-size--x-small);
}

.thesouke-summary__shipping ul {
	list-style: none;
	margin: 0;
	padding: 0;
}

.thesouke-summary__actions {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

/* Both buttons run the full width of the panel. */
.woocommerce .thesouke-summary__actions .checkout-button,
.woocommerce .thesouke-summary__actions a.button.checkout-button {
	display: block;
	margin: 0;
	text-align: center;
	width: 100%;
}

.thesouke-summary__continue {
	background: var(--wp--preset--color--base);
	border: 1px solid var(--wp--preset--color--primary-200);
	border-radius: var(--wp--custom--radius--pill, 50px);
	color: var(--wp--preset--color--primary);
	display: block;
	font-family: var(--wp--preset--font-family--clash-display);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 500;
	line-height: 1;
	padding: 1rem 1.5rem;
	text-align: center;
	text-decoration: none;
	transition: background-color var(--thesouke-transition), border-color var(--thesouke-transition);
}

.thesouke-summary__continue:hover,
.thesouke-summary__continue:focus-visible {
	background: var(--wp--preset--color--canvas);
	border-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--primary-600);
}

/* --- responsive --- */

@media (max-width: 1024px) {
	.thesouke-cart-page.wp-block-group .woocommerce {
		grid-template-columns: minmax(0, 1fr);
	}
}

@media (max-width: 782px) {
	.thesouke-cart__row {
		grid-template-columns: 20px 120px minmax(0, 1fr);
	}

	.thesouke-cart__media {
		height: 130px;
		width: 120px;
	}

	.thesouke-cart__actions {
		grid-column: 2 / -1;
		justify-content: space-between;
	}
}

@media (max-width: 480px) {
	.thesouke-cart__row {
		grid-template-columns: 20px minmax(0, 1fr);
	}

	.thesouke-cart__media {
		grid-row: span 2;
		height: 110px;
		width: 100%;
	}

	.thesouke-cart__info {
		grid-column: 2;
	}

	.thesouke-cart__actions {
		grid-column: 1 / -1;
	}
}
