/*
 * 0.6.5 product media layout.
 *
 * This file deliberately scopes archive cards, related cards, the native
 * WooCommerce gallery, and legacy description videos separately. It is loaded
 * after the existing theme layers so the old cover/height rules cannot leak
 * across these surfaces.
 */

/* Store and category cards: a generous square stage, complete product image. */
body.glade-archive ul.products > li.product {
	align-self: stretch;
}

body.glade-archive .glade-product-card {
	display: grid;
	grid-template-rows: auto minmax(0, 1fr);
	height: 100%;
}

body.glade-archive .glade-product-card__media {
	display: block;
	box-sizing: border-box;
	aspect-ratio: 1 / 1;
	padding: clamp(10px, 1.2vw, 18px);
	background: #f0ece6;
}

body.glade-archive .glade-product-card__media img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
	object-position: center;
	transform: none;
}

body.glade-archive .glade-product-card__media:hover img {
	transform: none;
}

body.glade-archive .glade-product-card__body {
	display: grid;
	grid-template-rows: auto minmax(3.45em, auto) minmax(3.5em, auto) auto;
	height: 100%;
	min-height: 0;
}

body.glade-archive .glade-product-card__category {
	display: block;
	min-height: 1.2em;
}

body.glade-archive .glade-product-card__title {
	display: block;
	min-height: 3.45em;
	max-height: none;
	overflow: visible;
	margin: 7px 0 12px;
	line-height: 1.15;
	-webkit-line-clamp: unset;
}

body.glade-archive .glade-product-card__title a {
	display: block;
	overflow-wrap: break-word;
	word-break: normal;
	hyphens: none;
}

body.glade-archive .glade-product-card__footer {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	align-items: start;
	min-height: 3.5em;
	margin-top: 0;
}

body.glade-archive .glade-product-card__stock {
	align-self: start;
	text-align: right;
}

body.glade-archive .glade-product-card__action {
	align-self: end;
	margin-top: 15px;
}

/* Related cards: same component contract, with an explicit responsive grid. */
body.glade-single-product ul.glade-related-grid > li.product {
	align-self: stretch;
}

body.glade-single-product ul.glade-related-grid .glade-product-card {
	display: grid;
	grid-template-rows: auto minmax(0, 1fr);
	height: 100%;
}

body.glade-single-product ul.glade-related-grid .glade-product-card__media {
	display: block;
	box-sizing: border-box;
	aspect-ratio: 1 / 1;
	padding: clamp(10px, 1.2vw, 18px);
	background: #f0ece6;
}

body.glade-single-product ul.glade-related-grid .glade-product-card__media img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
	object-position: center;
	transform: none;
}

body.glade-single-product ul.glade-related-grid .glade-product-card__media:hover img {
	transform: none;
}

body.glade-single-product ul.glade-related-grid .glade-product-card__body {
	display: grid;
	grid-template-rows: auto minmax(3.45em, auto) minmax(3.5em, auto) auto;
	height: 100%;
	min-height: 0;
}

body.glade-single-product ul.glade-related-grid .glade-product-card__category {
	display: block;
	min-height: 1.2em;
}

body.glade-single-product ul.glade-related-grid .glade-product-card__title {
	display: block;
	min-height: 3.45em;
	max-height: none;
	overflow: visible;
	margin: 7px 0 12px;
	line-height: 1.15;
	-webkit-line-clamp: unset;
}

body.glade-single-product ul.glade-related-grid .glade-product-card__title a {
	display: block;
	overflow-wrap: break-word;
	word-break: normal;
	hyphens: none;
}

body.glade-single-product ul.glade-related-grid .glade-product-card__footer {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	align-items: start;
	min-height: 3.5em;
	margin-top: 0;
}

body.glade-single-product ul.glade-related-grid .glade-product-card__stock {
	align-self: start;
	text-align: right;
}

body.glade-single-product ul.glade-related-grid .glade-product-card__action {
	align-self: end;
	margin-top: 15px;
}

/* Native WooCommerce gallery: only media boxes are normalized. The flexy
 * track keeps its native display, transform, and slide state. */

body.glade-single-product .woocommerce-product-gallery .flexy-view .flexy-item > .ct-media-container,
body.glade-single-product .woocommerce-product-gallery > .ct-product-gallery-container > .ct-media-container {
	display: block;
	width: 100%;
	min-height: 0;
	overflow: hidden;
	background: #f0ece6;
}

body.glade-single-product .woocommerce-product-gallery .flexy-view .flexy-item > .ct-media-container img,
body.glade-single-product .woocommerce-product-gallery > .ct-product-gallery-container > .ct-media-container img {
	display: block;
	width: 100%;
	height: auto !important;
	max-height: min(76vh, 820px);
	object-fit: contain !important;
	object-position: center;
	transition: opacity .16s ease;
}

body.glade-single-product .woocommerce-product-gallery .flexy-view .flexy-item > .ct-media-container[data-glade-gallery-loading="1"] img,
body.glade-single-product .woocommerce-product-gallery > .ct-product-gallery-container > .ct-media-container[data-glade-gallery-loading="1"] img {
	opacity: .2;
}

body.glade-single-product .woocommerce-product-gallery .flexy-pills {
	height: auto !important;
	min-width: 0;
	overflow: hidden;
}

body.glade-single-product .woocommerce-product-gallery .flexy-pills > ol {
	display: flex !important;
	flex-wrap: nowrap;
	height: auto !important;
	align-items: flex-start;
	gap: 10px;
	margin: 14px 0 0;
	padding: 0;
	list-style: none;
	overflow-x: auto;
}

body.glade-single-product .woocommerce-product-gallery .flexy-pills > ol > li {
	box-sizing: border-box;
	display: block !important;
	flex: 0 0 72px !important;
	width: 72px !important;
	height: 72px !important;
	margin: 0;
	padding: 2px;
	border: 1px solid transparent;
	background: #f0ece6;
	cursor: pointer;
}

body.glade-single-product .woocommerce-product-gallery .flexy-pills > ol > li > .ct-media-container {
	display: block !important;
	width: 100% !important;
	height: 100% !important;
	min-height: 0 !important;
	aspect-ratio: 1 / 1 !important;
	overflow: hidden;
}

body.glade-single-product .woocommerce-product-gallery .flexy-pills > ol > li > .ct-media-container img {
	display: block;
	width: 100%;
	height: 100% !important;
	max-height: none;
	aspect-ratio: auto !important;
	object-fit: contain !important;
}

body.glade-single-product .woocommerce-product-gallery .flexy-pills > ol > li:focus-visible {
	outline: 3px solid var(--glade-child-accent);
	outline-offset: 3px;
}

/* Legacy product-description videos: native video poster/frame only. */
body.glade-single-product .woocommerce-tabs .wc-tab .glade-video-state-host {
	position: relative;
	background: #f0ece6;
}

body.glade-single-product .woocommerce-tabs .wc-tab .glade-video-state-host > video {
	display: block;
	width: 100%;
	max-width: none;
	height: auto;
	min-height: 0;
	object-fit: contain;
	object-position: center;
	pointer-events: auto;
	background: #f0ece6;
}

@media (max-width: 900px) {
	body.glade-archive ul.products,
	body.glade-single-product ul.glade-related-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	body.glade-single-product ul.glade-related-grid {
		gap: 34px 12px;
	}
}

@media (min-width: 901px) and (max-width: 1199px) {
	body.glade-archive ul.products,
	body.glade-single-product ul.glade-related-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@media (max-width: 560px) {
	body.glade-archive ul.products,
	body.glade-single-product ul.glade-related-grid {
		grid-template-columns: 1fr;
	}

	body.glade-archive .glade-product-card__action,
	body.glade-single-product ul.glade-related-grid .glade-product-card__action {
		min-height: 44px;
	}
}

@media (max-width: 560px) {
	body.glade-archive .glade-product-card__body,
	body.glade-single-product ul.glade-related-grid .glade-product-card__body {
		display: flex;
		flex-direction: column;
	}

	body.glade-archive .glade-product-card__title,
	body.glade-single-product ul.glade-related-grid .glade-product-card__title {
		min-height: 0;
		margin: 6px 0 10px;
	}

	body.glade-archive .glade-product-card__footer,
	body.glade-single-product ul.glade-related-grid .glade-product-card__footer {
		display: flex;
		min-height: 0;
		flex-wrap: wrap;
		align-items: baseline;
	}

	body.glade-archive .glade-product-card__action,
	body.glade-single-product ul.glade-related-grid .glade-product-card__action {
		width: 100%;
		margin-top: auto;
	}

	body.glade-single-product .woocommerce-product-gallery .flexy-pills > ol > li {
		flex: 0 0 64px !important;
		width: 64px !important;
		height: 64px !important;
	}
}
