/* Product cards (shop listing + related products on PDP), add to cart states, cart toast, PDP form */

/* Grid: 2 columns on mobile/tablet, 3 from 992px, 4 from 1400px */
:is(.product-catalog #main, .single-product #main .related) ul.products {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 32px 16px;
	margin: 0 0 32px;
}

:is(.product-catalog #main, .single-product #main .related) ul.products::before,
:is(.product-catalog #main, .single-product #main .related) ul.products::after {
	display: none;
}

@media (min-width: 992px) {
	:is(.product-catalog #main, .single-product #main .related) ul.products {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		gap: 40px 24px;
	}
}

@media (min-width: 1400px) {
	:is(.product-catalog #main, .single-product #main .related) ul.products {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

/* Card: column layout, so the button always sits at the bottom */
:is(.product-catalog #main, .single-product #main .related) ul.products li.product {
	display: flex;
	flex-direction: column;
	width: auto;
	float: none;
	margin: 0;
	padding: 0;
}

:is(.product-catalog #main, .single-product #main .related) ul.products li.product .woocommerce-loop-product__link {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	text-decoration: none;
}

:is(.product-catalog #main, .single-product #main .related) ul.products li.product img {
	width: 100%;
	height: auto;
	aspect-ratio: 1 / 1;
	object-fit: contain;
	margin: 0 0 12px;
	background-color: #fff;
}

/* Title: max 2 lines, same height on every card */
:is(.product-catalog #main, .single-product #main .related) ul.products li.product .woocommerce-loop-product__title {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	overflow: hidden;
	min-height: calc(2 * 1.35em);
	margin: 0 0 8px;
	padding: 0;
	font-size: 16px;
	line-height: 1.35;
	color: #212529;
}

/* Price and "see more": pushed to the bottom of the link, wraps instead of colliding */
:is(.product-catalog #main, .single-product #main .related) ul.products li.product .price-div {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: baseline;
	gap: 4px 12px;
	margin-top: auto;
}

:is(.product-catalog #main, .single-product #main .related) ul.products li.product .price-div .price {
	margin: 0;
	font-size: 20px;
	line-height: 1.2;
}

:is(.product-catalog #main, .single-product #main .related) ul.products li.product .price-div .price .woocommerce-Price-amount {
	font-size: inherit;
}

:is(.product-catalog #main, .single-product #main .related) ul.products li.product .price-div .price del {
	display: block;
	font-size: 14px;
	font-weight: 400;
	opacity: 0.6;
}

:is(.product-catalog #main, .single-product #main .related) ul.products li.product .price-div .see-more-span {
	font-size: 14px;
	white-space: nowrap;
}

:is(.product-catalog #main, .single-product #main .related) ul.products li.product .woocommerce-loop-product__link:hover .see-more-span {
	text-decoration: underline;
}

/* Button */
:is(.product-catalog #main, .single-product #main .related) ul.products li.product .button {
	position: relative;
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 8px;
	width: 100%;
	min-height: 44px;
	margin: 12px 0 0;
	padding: 10px 12px;
	border: 2px solid var(--dark-blue);
	border-radius: 8px;
	font-size: 16px;
	line-height: 1.2;
	white-space: nowrap;
	opacity: 1;
	transition: background-color 0.2s, color 0.2s;
}

:is(.product-catalog #main, .single-product #main .related) ul.products li.product .button:hover {
	background-color: #0e1a40 !important;
}

/* Products that can't be added to cart (no price / variable): secondary button */
:is(.product-catalog #main, .single-product #main .related) ul.products li.product .button:not(.add_to_cart_button) {
	color: var(--dark-blue) !important;
	background-color: #fff !important;
}

:is(.product-catalog #main, .single-product #main .related) ul.products li.product .button:not(.add_to_cart_button):hover {
	background-color: #f1f3f8 !important;
}

/* Hide WooCommerce icon-font states, replaced by spinner and "added" text */
:is(.product-catalog #main, .single-product #main .related) ul.products li.product .button.loading::after,
:is(.product-catalog #main, .single-product #main .related) ul.products li.product .button.added::after {
	display: none;
}

:is(.product-catalog #main, .single-product #main .related) ul.products li.product .button.loading {
	color: transparent !important;
	pointer-events: none;
}

:is(.product-catalog #main, .single-product #main .related) ul.products li.product .button.loading::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 20px;
	height: 20px;
	margin: -10px 0 0 -10px;
	border: 2px solid rgba(255, 255, 255, 0.4);
	border-top-color: #fff;
	border-radius: 50%;
	animation: ob-spin 0.7s linear infinite;
}

:is(.product-catalog #main, .single-product #main .related) ul.products li.product .button.ob-added {
	background-color: #1e7a46 !important;
	border-color: #1e7a46;
}

/* Quantity -/+ above the button (rendered in inc/wc-modifications.php), both full card width */
ul.products li.product .ob-card-cart {
	display: flex;
	flex-wrap: wrap;
	align-items: stretch;
	gap: 8px;
	margin-top: 12px;
}

ul.products li.product .ob-card-cart .quantity.ob-qty {
	display: flex;
	flex: 1 1 100%;
	float: none;
	margin: 0;
	overflow: hidden;
	border: 1px solid #cfc8d8;
	border-radius: 8px;
	background-color: #fff;
}

ul.products li.product .ob-card-cart .ob-qty .minus-btn,
ul.products li.product .ob-card-cart .ob-qty .plus-btn {
	width: 44px;
	height: auto;
	min-height: 40px;
	padding: 0;
	background-color: #f1f3f8;
	color: var(--dark-blue);
	font-size: 20px;
	line-height: 1;
}

ul.products li.product .ob-card-cart .ob-qty .minus-btn:hover,
ul.products li.product .ob-card-cart .ob-qty .plus-btn:hover {
	background-color: #e1e5f0;
}

ul.products li.product .ob-card-cart .ob-qty .qty {
	flex: 1 1 auto;
	width: 2.6em;
	min-width: 0;
	height: auto;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	color: var(--dark-blue);
	font-size: 16px;
	text-align: center;
	-moz-appearance: textfield;
}

:is(.product-catalog #main, .single-product #main .related) ul.products li.product .ob-card-cart .button,
ul.products li.product .ob-card-cart .button {
	flex: 1 1 100%;
	width: auto;
	min-width: 0;
	margin: 0;
}

/* "View cart" link under the button is replaced by the toast */
:is(.product-catalog #main, .single-product #main .related) ul.products li.product .added_to_cart {
	display: none;
}

@media (max-width: 575px) {
	:is(.product-catalog #main, .single-product #main .related) ul.products li.product .woocommerce-loop-product__title {
		font-size: 14px;
	}

	:is(.product-catalog #main, .single-product #main .related) ul.products li.product .price-div .price {
		font-size: 17px;
	}

	:is(.product-catalog #main, .single-product #main .related) ul.products li.product .button {
		font-size: 14px;
		padding: 8px;
	}
}

@keyframes ob-spin {
	to {
		transform: rotate(360deg);
	}
}

/* Header cart count: pulse when it changes */
.main-header-row .icons .cart-div .cart-items-count.ob-pulse {
	animation: ob-pulse 0.6s ease-out;
}

@keyframes ob-pulse {
	0% { transform: scale(1); }
	40% { transform: scale(1.35); }
	100% { transform: scale(1); }
}

/* Add to cart toast */
.ob-cart-toast {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 9999;
	display: flex;
	align-items: center;
	gap: 16px;
	max-width: calc(100% - 40px);
	width: 380px;
	padding: 14px 16px;
	border-left: 4px solid #1e7a46;
	border-radius: 8px;
	background-color: #fff;
	box-shadow: 0 8px 24px rgba(22, 37, 88, 0.18);
	color: #212529;
	font-size: 15px;
	line-height: 1.4;
	opacity: 0;
	transform: translateY(16px);
	transition: opacity 0.25s, transform 0.25s;
	pointer-events: none;
}

.ob-cart-toast.is-visible {
	opacity: 1;
	transform: translateY(0);
	pointer-events: auto;
}

.ob-cart-toast__message {
	flex: 1 1 auto;
	margin: 0;
}

.ob-cart-toast__link {
	flex: 0 0 auto;
	padding: 8px 12px;
	border-radius: 6px;
	background-color: var(--dark-blue);
	color: #fff !important;
	font-weight: 700;
	text-decoration: none;
	white-space: nowrap;
}

.ob-cart-toast__link:hover {
	background-color: #0e1a40;
}

@media (max-width: 575px) {
	.ob-cart-toast {
		right: 12px;
		bottom: 12px;
		left: 12px;
		width: auto;
		max-width: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ob-cart-toast,
	.main-header-row .icons .cart-div .cart-items-count.ob-pulse,
	:is(.product-catalog #main, .single-product #main .related) ul.products li.product .button.loading::before {
		transition: none;
		animation: none;
	}
}

/* style.css sets `.shop-content .row { width: 100% }`, which ignores the Bootstrap
   negative row margins and leaves a wider gutter on the right. */
.shop-content > .row {
	width: calc(100% + var(--bs-gutter-x, 1.5rem));
}

/* Related products on PDP: 4 products, so 2 columns, then 4 from 992px */
@media (min-width: 992px) {
	.single-product #main .related ul.products {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

/* PDP: quantity -/+ (added by shop.js) and a larger add to cart button */
.single-product #main .summary form.cart {
	display: flex;
	flex-wrap: wrap;
	align-items: stretch;
	gap: 12px;
	margin: 24px 0;
}

.single-product #main .summary form.cart::before,
.single-product #main .summary form.cart::after {
	display: none;
}

.single-product #main .summary form.cart .quantity {
	float: none;
	margin: 0;
}

.single-product #main .summary form.cart .quantity.ob-qty {
	overflow: hidden;
	border: 1px solid #cfc8d8;
	border-radius: 8px;
}

.single-product #main .summary .ob-qty .minus-btn,
.single-product #main .summary .ob-qty .plus-btn {
	width: 44px;
	height: 48px;
	padding: 0;
	background-color: #f1f3f8;
	color: var(--dark-blue);
	font-size: 22px;
	line-height: 1;
}

.single-product #main .summary .ob-qty .minus-btn:hover,
.single-product #main .summary .ob-qty .plus-btn:hover {
	background-color: #e1e5f0;
}

.single-product #main .summary .ob-qty .qty {
	width: 3.5em;
	height: 48px;
	border: 0;
	font-size: 18px;
}

/* PDP: variable products. Option select above, then the same quantity + button row as simple products */
.single-product #main .summary form.variations_form {
	display: block;
}

.single-product #main .summary table.variations {
	width: 100%;
	max-width: 520px;
	margin: 0 0 16px;
	border: 0;
}

.single-product #main .summary table.variations :is(tbody, tr, th, td) {
	display: block;
	padding: 0;
	border: 0;
	background: none;
	text-align: left;
}

.single-product #main .summary table.variations th.label {
	margin-bottom: 8px;
	font-weight: 600;
}

.single-product #main .summary table.variations select {
	width: 100%;
	height: 48px;
	padding: 0 40px 0 14px;
	border: 1px solid #cfc8d8;
	border-radius: 8px;
	background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23162558' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 16px center;
	appearance: none;
	color: var(--dark-blue);
	font-size: 16px;
	cursor: pointer;
}

.single-product #main .summary table.variations select:focus {
	border-color: var(--dark-blue);
	outline: none;
}

.single-product #main .summary table.variations .reset_variations {
	display: inline-block;
	margin-top: 8px;
	font-size: 14px;
}

.single-product #main .summary .single_variation:not(:empty) {
	margin-bottom: 12px;
}

.single-product #main .summary .woocommerce-variation-add-to-cart {
	display: flex;
	flex-wrap: wrap;
	align-items: stretch;
	gap: 12px;
}

.single-product #main .summary .woocommerce-variation-add-to-cart .quantity {
	float: none;
	margin: 0;
}

.single-product #main .summary form.cart .single_add_to_cart_button {
	position: relative;
	flex: 1 1 220px;
	max-width: 360px;
	min-height: 48px;
	float: none;
	margin: 0;
	padding: 12px 24px;
	transition: background-color 0.2s;
}

.single-product #main .summary form.cart .single_add_to_cart_button:hover {
	background-color: #0e1a40;
}

.single-product #main .summary form.cart .single_add_to_cart_button.loading {
	color: transparent !important;
	pointer-events: none;
}

.single-product #main .summary form.cart .single_add_to_cart_button.loading::after,
.single-product #main .summary form.cart .single_add_to_cart_button.added::after {
	display: none;
}

.single-product #main .summary form.cart .single_add_to_cart_button.loading::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 20px;
	height: 20px;
	margin: -10px 0 0 -10px;
	border: 2px solid rgba(255, 255, 255, 0.4);
	border-top-color: #fff;
	border-radius: 50%;
	animation: ob-spin 0.7s linear infinite;
}

.single-product #main .summary form.cart .single_add_to_cart_button.ob-added {
	background-color: #1e7a46;
}

/* "View cart" link next to the button is replaced by the toast */
.single-product #main .summary form.cart .added_to_cart {
	display: none;
}

@media (max-width: 575px) {
	.single-product #main .summary form.cart .single_add_to_cart_button {
		max-width: none;
	}
}

/* Breadcrumbs: more room between the city block above and the content below */
#main .woocommerce-breadcrumb {
	margin: 0 0 8px;
	padding: 20px 0;
}

@media (max-width: 575px) {
	#main .woocommerce-breadcrumb {
		padding: 16px 0;
	}
}

/* PDP: thin delivery city bar (replaces the hero image and the city block) */
.ob-city-bar {
	padding: 10px 0;
	background-color: rgba(181, 230, 171, 0.5);
	color: var(--dark-blue);
	font-size: 15px;
}

.ob-city-bar__inner {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 16px;
	min-height: 36px;
}

.ob-city-bar__label strong {
	font-weight: 700;
}

.ob-city-bar__change {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 16px;
}

.ob-city-bar__change summary {
	list-style: none;
	cursor: pointer;
	text-decoration: underline;
}

.ob-city-bar__change summary::-webkit-details-marker {
	display: none;
}

.ob-city-bar__change[open] summary {
	display: none;
}

.ob-city-bar__cities {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.ob-city-bar .ob-city-bar__city {
	padding: 6px 14px;
	border-radius: 999px;
	background-color: #fff;
	color: var(--dark-blue);
	font-weight: 700;
	text-decoration: none;
}

.ob-city-bar .ob-city-bar__city:hover {
	background-color: #f1f3f8;
}

.ob-city-bar .ob-city-bar__city.is-active {
	background-color: var(--dark-blue);
	color: #fff;
}

/* PDP gallery: fixed square frame, the image is contained and centred, thumbnails in one row */
.single-product #main div.product div.images.woocommerce-product-gallery {
	position: relative;
}

.single-product #main div.product div.images .woocommerce-product-gallery__image {
	position: relative;
	aspect-ratio: 1 / 1;
	background-color: #fff;
	overflow: hidden;
}

.single-product #main div.product div.images .woocommerce-product-gallery__image > a {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	padding: 16px;
	box-sizing: border-box;
}

.single-product #main div.product div.images .woocommerce-product-gallery__image > a img {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.single-product #main div.product div.images .flex-viewport,
.single-product #main div.product div.images > .woocommerce-product-gallery__wrapper {
	border: 1px solid #ececec;
	border-radius: 8px;
}

.single-product #main div.product div.images .flex-viewport > .woocommerce-product-gallery__wrapper {
	border: 0;
	border-radius: 0;
}

.single-product #main div.product div.images .flex-control-thumbs {
	display: flex;
	gap: 8px;
	margin: 10px 0 0;
	padding: 0 0 4px;
	overflow-x: auto;
	scrollbar-width: thin;
}

.single-product #main div.product div.images .flex-control-thumbs::before,
.single-product #main div.product div.images .flex-control-thumbs::after {
	display: none;
}

.single-product #main div.product div.images .flex-control-thumbs li {
	flex: 0 0 calc((100% - 48px) / 7);
	width: auto;
	margin: 0;
	float: none;
}

.single-product #main div.product div.images .flex-control-thumbs li img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 1 / 1;
	object-fit: cover;
	border: 2px solid transparent;
	border-radius: 6px;
	opacity: 0.6;
	cursor: pointer;
	transition: opacity 0.15s, border-color 0.15s;
}

.single-product #main div.product div.images .flex-control-thumbs li img:hover,
.single-product #main div.product div.images .flex-control-thumbs li img.flex-active {
	opacity: 1;
}

.single-product #main div.product div.images .flex-control-thumbs li img.flex-active {
	border-color: var(--dark-blue);
}

@media (min-width: 992px) {
	.single-product #main div.product div.images {
		width: 42%;
	}

	.single-product #main div.product div.summary {
		width: 53%;
	}
}

@media (max-width: 767px) {
	.single-product #main div.product div.images {
		margin-bottom: 16px;
	}

	.single-product #main div.product div.images .woocommerce-product-gallery__image > a {
		padding: 12px;
	}

	.single-product #main div.product div.images .flex-control-thumbs {
		gap: 6px;
		margin-top: 8px;
	}

	.single-product #main div.product div.images .flex-control-thumbs li {
		flex-basis: calc((100% - 30px) / 6);
	}
}

/* Category description under the page title */
.woocommerce-products-header .term-description {
	max-width: 760px;
	margin: 4px 0 24px;
	color: #444;
	font-size: 16px;
	line-height: 1.6;
}

.woocommerce-products-header .term-description p:last-child {
	margin-bottom: 0;
}
