/*
 * NTS Sprint 3B corrective layout patch.
 * Scope: fix Woo/Flatsome product grid collapse, mobile overflow, hero/PDP clipping.
 */

html,
body {
	max-width: 100%;
	overflow-x: hidden;
}

*,
*::before,
*::after {
	box-sizing: border-box;
}

img,
video,
iframe,
table {
	max-width: 100%;
}

/* Archive/product loop: Flatsome uses .product-small.col, not li.product. */
body.post-type-archive-product .shop-container,
body.tax-product_cat .shop-container {
	max-width: var(--nts-container, 1240px) !important;
	width: calc(100% - 40px) !important;
	margin-left: auto !important;
	margin-right: auto !important;
}

body.post-type-archive-product .products.row,
body.tax-product_cat .products.row,
body.post-type-archive-product .products,
body.tax-product_cat .products {
	display: grid !important;
	grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
	gap: 24px !important;
	width: 100% !important;
	max-width: var(--nts-container, 1240px) !important;
	margin: 0 auto 48px !important;
	padding: 0 !important;
	float: none !important;
}

body.post-type-archive-product .products.row::before,
body.post-type-archive-product .products.row::after,
body.tax-product_cat .products.row::before,
body.tax-product_cat .products.row::after {
	display: none !important;
	content: none !important;
}

body.post-type-archive-product .products.row > .product-small.col,
body.tax-product_cat .products.row > .product-small.col,
body.post-type-archive-product .products > .product-small.col,
body.tax-product_cat .products > .product-small.col {
	display: block !important;
	width: auto !important;
	max-width: none !important;
	min-width: 0 !important;
	flex: none !important;
	flex-basis: auto !important;
	margin: 0 !important;
	padding: 0 !important;
	float: none !important;
}

body.post-type-archive-product .product-small .col-inner,
body.tax-product_cat .product-small .col-inner {
	display: flex !important;
	flex-direction: column !important;
	height: 100% !important;
	min-width: 0 !important;
	border-radius: 14px !important;
	overflow: hidden !important;
}

body.post-type-archive-product .product-small .box,
body.tax-product_cat .product-small .box {
	display: flex !important;
	flex-direction: column !important;
	height: 100% !important;
	width: 100% !important;
	min-width: 0 !important;
}

body.post-type-archive-product .product-small .box-image,
body.tax-product_cat .product-small .box-image {
	width: 100% !important;
	aspect-ratio: 4 / 3 !important;
	height: auto !important;
	min-height: 0 !important;
	background: #f6f7fa !important;
}

body.post-type-archive-product .product-small .box-image .image-cover,
body.tax-product_cat .product-small .box-image .image-cover {
	height: 100% !important;
	padding-top: 0 !important;
}

body.post-type-archive-product .product-small .box-image img,
body.tax-product_cat .product-small .box-image img {
	width: 100% !important;
	height: 100% !important;
	object-fit: cover !important;
	object-position: center !important;
	display: block !important;
}

body.post-type-archive-product .product-small .box-text,
body.tax-product_cat .product-small .box-text,
body.post-type-archive-product .product-small .box-text-products,
body.tax-product_cat .product-small .box-text-products {
	flex: 1 1 auto !important;
	display: flex !important;
	flex-direction: column !important;
	width: 100% !important;
	min-width: 0 !important;
	padding: 16px !important;
	text-align: left !important;
}

body.post-type-archive-product .product-small .name,
body.tax-product_cat .product-small .name,
body.post-type-archive-product .product-small .product-title,
body.tax-product_cat .product-small .product-title {
	min-height: 42px !important;
	overflow: visible !important;
	white-space: normal !important;
	text-overflow: clip !important;
}

body.post-type-archive-product .product-small .name a,
body.tax-product_cat .product-small .name a,
body.post-type-archive-product .product-small .product-title a,
body.tax-product_cat .product-small .product-title a {
	display: block !important;
	overflow: visible !important;
	white-space: normal !important;
	text-overflow: clip !important;
	word-break: normal !important;
}

body.post-type-archive-product .product-small .price,
body.tax-product_cat .product-small .price {
	margin-top: auto !important;
	white-space: normal !important;
	line-height: 1.35 !important;
}

body.post-type-archive-product .product-small .button,
body.tax-product_cat .product-small .button {
	width: 100% !important;
	max-width: 100% !important;
	margin: 12px 0 0 !important;
}

body.post-type-archive-product .nts-archive-intro,
body.tax-product_cat .nts-archive-intro {
	width: calc(100% - 40px) !important;
	max-width: var(--nts-container, 1240px) !important;
	margin: 48px auto 32px !important;
	padding: 32px !important;
}

body.post-type-archive-product .nts-chips-wrap,
body.tax-product_cat .nts-chips-wrap {
	width: calc(100% - 40px) !important;
	max-width: var(--nts-container, 1240px) !important;
	margin-left: auto !important;
	margin-right: auto !important;
	padding-left: 0 !important;
	padding-right: 0 !important;
}

/* Homepage hero: prevent panel/text clipping and keep mobile buttons inside viewport. */
.nts-home-hero {
	overflow: hidden !important;
}

.nts-home-hero__inner,
.nts-trust-strip__inner,
.nts-section-wrap,
.nts-category-grid,
.nts-chips-wrap {
	width: calc(100% - 40px) !important;
	max-width: var(--nts-container, 1240px) !important;
	min-width: 0 !important;
}

.nts-home-hero__content,
.nts-home-hero__panel {
	min-width: 0 !important;
}

.nts-home-hero__panel {
	align-content: end !important;
	padding-top: 230px !important;
	min-height: 440px !important;
}

.nts-home-hero__panel span {
	min-width: 0 !important;
	overflow: hidden !important;
}

.nts-home-hero__actions {
	display: flex !important;
	flex-wrap: wrap !important;
	gap: 12px !important;
}

.nts-home-hero__actions .button {
	margin: 0 !important;
}

/* PDP: contain gallery/info and make sticky buy usable on mobile. */
body.single-product .product-main > .row,
body.single-product .product-main .product-container > .row {
	max-width: var(--nts-container, 1240px) !important;
	margin-left: auto !important;
	margin-right: auto !important;
}

body.single-product .product-gallery,
body.single-product .product-info,
body.single-product .summary {
	min-width: 0 !important;
	max-width: 100% !important;
}

body.single-product .product-gallery img,
body.single-product .woocommerce-product-gallery img {
	max-width: 100% !important;
	height: auto !important;
	object-fit: contain !important;
}

body.single-product .product-gallery .flickity-viewport {
	min-height: 0 !important;
	max-height: 620px !important;
}

body.single-product .product-images.woocommerce-product-gallery {
	opacity: 1 !important;
}

body.single-product .woocommerce-product-gallery__wrapper {
	background: #fff !important;
}

body.single-product .woocommerce-product-gallery__image:first-child,
body.single-product .woocommerce-product-gallery__image.first {
	opacity: 1 !important;
	visibility: visible !important;
}

.nts-mobile-sticky-buy {
	left: 0 !important;
	right: 0 !important;
	bottom: 0 !important;
	width: 100% !important;
	max-width: 100% !important;
	grid-template-columns: minmax(0, 1fr) minmax(116px, 42%) !important;
	gap: 10px !important;
	padding: 10px 12px calc(10px + env(safe-area-inset-bottom)) !important;
	background: rgba(255, 255, 255, .96) !important;
	border-top: 1px solid rgba(30, 52, 112, .14) !important;
	box-shadow: 0 -12px 32px rgba(20, 38, 76, .12) !important;
}

.nts-mobile-sticky-buy__price {
	min-width: 0 !important;
	font-size: 14px !important;
	line-height: 1.25 !important;
	white-space: normal !important;
	overflow-wrap: anywhere !important;
}

.nts-mobile-sticky-buy__btn {
	min-width: 0 !important;
	width: 100% !important;
	padding: 11px 8px !important;
	font-size: 12px !important;
	line-height: 1.25 !important;
	white-space: normal !important;
}

/* Legacy pages: stop old wide blocks from breaking mobile while keeping current content. */
body.page .page-wrapper,
body.blog .page-wrapper,
body.archive.category .page-wrapper,
body.page .row,
body.blog .row,
body.archive.category .row {
	max-width: 100% !important;
	min-width: 0 !important;
}

body.page .col,
body.blog .col,
body.archive.category .col {
	min-width: 0 !important;
}

body.page .wpcf7,
body.page form,
body.page input,
body.page textarea {
	max-width: 100% !important;
}

@media only screen and (max-width: 1200px) {
	body.post-type-archive-product .products.row,
	body.tax-product_cat .products.row,
	body.post-type-archive-product .products,
	body.tax-product_cat .products {
		grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
	}
}

@media only screen and (max-width: 860px) {
	body.post-type-archive-product .products.row,
	body.tax-product_cat .products.row,
	body.post-type-archive-product .products,
	body.tax-product_cat .products {
		grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
		gap: 14px !important;
	}

	.nts-home-hero__inner,
	.nts-trust-strip__inner,
	.nts-section-wrap,
	.nts-category-grid,
	.nts-chips-wrap,
	body.post-type-archive-product .shop-container,
	body.tax-product_cat .shop-container,
	body.post-type-archive-product .nts-archive-intro,
	body.tax-product_cat .nts-archive-intro,
	body.post-type-archive-product .nts-chips-wrap,
	body.tax-product_cat .nts-chips-wrap {
		width: calc(100% - 32px) !important;
	}

	.nts-home-hero__inner {
		display: grid !important;
		grid-template-columns: minmax(0, 1fr) !important;
	}

	.nts-home-hero__panel {
		min-height: 320px !important;
		padding: 170px 16px 16px !important;
		grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
	}
}

@media only screen and (max-width: 640px) {
	body {
		width: 100% !important;
	}

	#main,
	.main,
	.page-wrapper,
	.shop-container,
	.product-container,
	.container {
		max-width: 100% !important;
		min-width: 0 !important;
	}

	.row {
		max-width: 100% !important;
		min-width: 0 !important;
		margin-left: 0 !important;
		margin-right: 0 !important;
	}

	.col,
	.large-6,
	.large-8,
	.large-9,
	.large-12,
	.medium-6,
	.medium-9,
	.small-12 {
		min-width: 0 !important;
		width: 100% !important;
		flex-basis: 100% !important;
		max-width: 100% !important;
	}

	.nts-home-hero {
		padding: 44px 0 42px !important;
	}

	.nts-home-hero__inner,
	.nts-trust-strip__inner,
	.nts-section-wrap,
	.nts-category-grid,
	.nts-chips-wrap {
		width: calc(100vw - 32px) !important;
		max-width: calc(100vw - 32px) !important;
		padding-left: 0 !important;
		padding-right: 0 !important;
	}

	.nts-home-hero__content,
	.nts-home-hero__lead,
	.nts-home-hero h1,
	.nts-archive-intro,
	.nts-archive-intro h2,
	.nts-archive-intro p,
	body.single-product .product-info,
	body.single-product .summary,
	body.page .entry-content,
	body.blog .post-item,
	body.archive.category .post-item {
		width: 100% !important;
		max-width: 100% !important;
		min-width: 0 !important;
		white-space: normal !important;
		overflow-wrap: break-word !important;
	}

	.nts-home-hero h1 {
		font-size: 32px !important;
		line-height: 1.12 !important;
		overflow-wrap: anywhere !important;
	}

	.nts-home-hero__lead,
	.nts-home-hero p {
		font-size: 15px !important;
		line-height: 1.65 !important;
	}

	.nts-home-hero__actions {
		display: grid !important;
		grid-template-columns: 1fr !important;
		width: 100% !important;
	}

	.nts-home-hero__actions .button {
		width: 100% !important;
		max-width: 100% !important;
		white-space: normal !important;
	}

	.nts-home-hero__panel {
		grid-template-columns: 1fr !important;
		min-height: 360px !important;
		padding: 190px 14px 14px !important;
	}

	body.post-type-archive-product .nts-archive-intro,
	body.tax-product_cat .nts-archive-intro {
		width: calc(100% - 32px) !important;
		margin: 32px auto 24px !important;
		padding: 24px 20px !important;
	}

	body.post-type-archive-product .nts-archive-intro h2,
	body.tax-product_cat .nts-archive-intro h2 {
		font-size: 25px !important;
		line-height: 1.18 !important;
		overflow-wrap: anywhere !important;
	}

	body.post-type-archive-product .shop-container,
	body.tax-product_cat .shop-container,
	body.post-type-archive-product .nts-chips-wrap,
	body.tax-product_cat .nts-chips-wrap {
		width: calc(100vw - 32px) !important;
		max-width: calc(100vw - 32px) !important;
	}

	body.post-type-archive-product .products.row,
	body.tax-product_cat .products.row,
	body.post-type-archive-product .products,
	body.tax-product_cat .products {
		grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
		gap: 12px !important;
	}

	body.post-type-archive-product .product-small .box-text,
	body.tax-product_cat .product-small .box-text,
	body.post-type-archive-product .product-small .box-text-products,
	body.tax-product_cat .product-small .box-text-products {
		padding: 12px !important;
	}

	body.post-type-archive-product .product-small .name,
	body.tax-product_cat .product-small .name,
	body.post-type-archive-product .product-small .product-title,
	body.tax-product_cat .product-small .product-title {
		font-size: 13px !important;
		line-height: 1.35 !important;
		min-height: 54px !important;
	}

	body.post-type-archive-product .product-small .price,
	body.tax-product_cat .product-small .price {
		font-size: 13px !important;
	}

	.nts-card-badges {
		display: none !important;
	}

	body.single-product .product-main {
		padding-top: 20px !important;
	}

	body.single-product .product-gallery .flickity-viewport {
		max-height: 390px !important;
	}

	body.single-product .product-info {
		margin-top: 18px !important;
		padding: 20px 16px !important;
	}

	body.single-product h1.product_title,
	body.single-product .product-title {
		font-size: 27px !important;
		line-height: 1.16 !important;
		overflow-wrap: anywhere !important;
	}

	body.single-product p.price,
	body.single-product span.price,
	body.single-product .price {
		font-size: 20px !important;
		line-height: 1.35 !important;
		overflow-wrap: anywhere !important;
	}

	body.single-product .cart {
		display: grid !important;
		grid-template-columns: 1fr !important;
		gap: 12px !important;
	}

	body.single-product .quantity,
	body.single-product .single_add_to_cart_button {
		width: 100% !important;
		max-width: 100% !important;
	}

	body.page .entry-content,
	body.blog .content-area,
	body.archive.category .content-area {
		overflow-x: hidden !important;
	}

	body.page .section,
	body.page .section-content,
	body.page .container,
	body.blog .container,
	body.archive.category .container {
		width: 100% !important;
		max-width: 100% !important;
		min-width: 0 !important;
	}
}

@media only screen and (max-width: 390px) {
	body.post-type-archive-product .products.row,
	body.tax-product_cat .products.row,
	body.post-type-archive-product .products,
	body.tax-product_cat .products {
		grid-template-columns: 1fr !important;
	}
}

@media only screen and (max-width: 640px) {
	.nts-home-hero__inner,
	.nts-trust-strip__inner,
	.nts-section-wrap,
	.nts-category-grid,
	.nts-chips-wrap,
	body.post-type-archive-product .shop-container,
	body.tax-product_cat .shop-container,
	body.post-type-archive-product .nts-archive-intro,
	body.tax-product_cat .nts-archive-intro,
	body.post-type-archive-product .nts-chips-wrap,
	body.tax-product_cat .nts-chips-wrap,
	body.single-product .product-gallery,
	body.single-product .product-info,
	body.single-product .summary {
		width: calc(100vw - 56px) !important;
		max-width: calc(100vw - 56px) !important;
		margin-left: auto !important;
		margin-right: auto !important;
	}

	.nts-home-hero h1 {
		font-size: 29px !important;
		line-height: 1.14 !important;
	}

	.nts-archive-intro h2,
	body.post-type-archive-product .nts-archive-intro h2,
	body.tax-product_cat .nts-archive-intro h2 {
		font-size: 23px !important;
		line-height: 1.2 !important;
	}

	.nts-home-hero__panel {
		width: 100% !important;
		max-width: 100% !important;
	}

	.nts-mobile-sticky-buy {
		display: grid !important;
		grid-template-columns: minmax(0, 1fr) 150px !important;
		width: 100vw !important;
		max-width: 100vw !important;
		overflow: hidden !important;
	}

	.nts-mobile-sticky-buy__price {
		font-size: 13px !important;
	}

	.nts-mobile-sticky-buy__btn {
		font-size: 11px !important;
		letter-spacing: 0 !important;
		overflow-wrap: anywhere !important;
	}
}

@media only screen and (max-width: 640px) {
	.nts-home-hero__content,
	.nts-home-hero h1,
	.nts-home-hero__lead,
	.nts-home-hero p {
		width: 300px !important;
		max-width: 300px !important;
	}

	.nts-home-hero__actions {
		width: 300px !important;
		max-width: 300px !important;
	}

	.nts-archive-intro h2,
	.nts-archive-intro p {
		max-width: 300px !important;
	}

	body.single-product .product-images,
	body.single-product .product-gallery,
	body.single-product .woocommerce-product-gallery {
		width: calc(100vw - 72px) !important;
		max-width: calc(100vw - 72px) !important;
		margin-left: auto !important;
		margin-right: auto !important;
	}

	.nts-mobile-sticky-buy {
		grid-template-columns: 1fr !important;
		gap: 6px !important;
		padding-left: 16px !important;
		padding-right: 16px !important;
	}

	.nts-mobile-sticky-buy__price,
	.nts-mobile-sticky-buy__btn {
		width: 100% !important;
		max-width: 100% !important;
		text-align: center !important;
	}
}
