/**
 * Huazotl 1.0.1 — large product media + four editorial tiles.
 * Canonical Base controls stay in the DOM as the live variation datasource.
 * Without the child enhancement, the original Base gallery stays usable.
 */
body.single-product .wapu-single--regular-product .wapu-single__gallery {
	position: relative !important;
	top: auto !important;
	width: 100% !important;
	max-width: none !important;
	margin: 0 !important;
	padding: 0 !important;
	align-self: start !important;
	contain: none !important;
}

body.single-product .wapu-single__gallery [data-huazotl-gallery-reference="1"] {
	width: 100% !important;
	max-width: none !important;
	margin: 0 !important;
	padding: 0 !important;
}

body.single-product .wapu-single__gallery [data-huazotl-gallery-reference="1"] .wapu-vg__stage {
	display: flex !important;
	flex-direction: column !important;
	grid-template-columns: none !important;
	grid-template-rows: none !important;
	gap: clamp(10px, 1.25vw, 18px) !important;
	width: 100% !important;
	block-size: auto !important;
	min-block-size: 0 !important;
	max-block-size: none !important;
	margin: 0 !important;
	padding: 0 !important;
	overflow: visible !important;
}

body.single-product .wapu-single__gallery [data-huazotl-gallery-reference="1"] .wapu-vg__main {
	position: relative !important;
	grid-column: auto !important;
	grid-row: auto !important;
	width: 100% !important;
	height: auto !important;
	min-width: 0 !important;
	min-height: 0 !important;
	max-height: none !important;
	aspect-ratio: 1 / 1 !important;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 16px !important;
	background: var(--wtds-surface-container-lowest, var(--wtds-surface, #fff7e9)) !important;
	overflow: hidden !important;
}

body.single-product .wapu-single__gallery [data-huazotl-gallery-reference="1"] .wapu-vg__main > :is(img, video, iframe) {
	position: absolute !important;
	inset: 0 !important;
	display: block !important;
	width: 100% !important;
	height: 100% !important;
	max-width: none !important;
	max-height: none !important;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	border-radius: inherit !important;
	object-fit: contain !important;
	object-position: center !important;
}

/* Higher specificity also covers the legacy variable/mobile thumb overrides. */
body.single-product .wapu-single__gallery [data-huazotl-gallery-reference="1"] [data-wapu-vg-thumbs],
body.single-product.huazotl-variable-product .wapu-single__gallery [data-huazotl-gallery-reference="1"] [data-wapu-vg-thumbs]:not([hidden]) {
	display: none !important;
}

.huazotl-gallery-main-open {
	position: absolute;
	inset: 0;
	z-index: 4;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: inherit;
	background: transparent;
	cursor: zoom-in;
}

.huazotl-gallery-main-open:hover { background: transparent; }
.huazotl-gallery-main-open:focus-visible { outline: 3px solid var(--wtds-ink, #241820); outline-offset: -5px; }
.huazotl-gallery-main-open[hidden], .huazotl-gallery-grid[hidden], .huazotl-gallery-view-all[hidden] { display: none !important; }

body.single-product .wapu-single__gallery .huazotl-gallery-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: clamp(10px, 1.25vw, 18px);
	width: 100%;
}

body.single-product .wapu-single__gallery .huazotl-gallery-tile {
	position: relative;
	display: block;
	width: 100%;
	min-width: 0;
	aspect-ratio: 1 / 1;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 16px;
	background: var(--wtds-surface-container-lowest, var(--wtds-surface, #fff7e9));
	color: var(--wtds-ink, #241820);
	overflow: hidden;
	cursor: zoom-in;
}

.huazotl-gallery-tile__media, .huazotl-gallery-viewer__preview { display: block; width: 100%; height: 100%; }
.huazotl-gallery-tile__media img { display: block; width: 100%; height: 100%; aspect-ratio: 1 / 1; object-fit: cover; }
.huazotl-gallery-play { position: absolute; inset: 0; display: grid; place-items: center; font-size: 32px; text-shadow: 0 1px 4px #fff; }

body.single-product .wapu-single__gallery .huazotl-gallery-view-all {
	align-self: center;
	min-height: 44px;
	margin: 0;
	padding: 8px 16px;
	border: 0;
	border-radius: 0;
	background: transparent;
	color: var(--wtds-ink, #241820);
	font: inherit;
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 5px;
	cursor: pointer;
}

.huazotl-gallery-tile:focus-visible, .huazotl-gallery-view-all:focus-visible { outline: 2px solid var(--wtds-ink, #241820); outline-offset: 3px; }

@media (min-width: 62rem) {
	body.single-product .wapu-single--regular-product .wapu-single__content { align-items: start !important; }
	body.single-product .wapu-single--regular-product .wapu-single__content > :is(.wapu-single__info, .wapu-product-column) {
		position: sticky !important;
		top: calc(var(--wtds-header-full-h, 4.5rem) + var(--wp-admin--admin-bar--height, 0px) + 12px) !important;
		align-self: start !important;
	}
}

/* Native modal top layer covers headers, admin bar and sticky purchase controls. */
html.huazotl-gallery-open, html.huazotl-gallery-open body { overflow: hidden !important; }
dialog.huazotl-gallery-viewer {
	position: fixed;
	inset: 0;
	box-sizing: border-box;
	width: 100%;
	height: 100vh;
	height: 100dvh;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: max(56px, env(safe-area-inset-top)) clamp(16px, 4vw, 64px) max(24px, env(safe-area-inset-bottom));
	border: 0;
	border-radius: 0;
	background: var(--wtds-surface, #fff7e9);
	color: var(--wtds-ink, #241820);
	font-family: var(--wtds-font-text, sans-serif);
	overflow: hidden;
}

dialog.huazotl-gallery-viewer[open] {
	display: grid;
	grid-template-columns: 48px minmax(0, 1fr) 48px;
	grid-template-rows: minmax(0, 1fr) auto;
	gap: 24px;
}

.huazotl-gallery-viewer::backdrop { background: var(--wtds-surface, #fff7e9); }
.huazotl-gallery-viewer__stage { grid-column: 2; grid-row: 1; position: relative; display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 0; margin: 0; overflow: hidden; }
.huazotl-gallery-viewer__stage > :is(img, video, iframe) { position: absolute; inset: 0; width: 100%; height: 100%; max-width: 100%; max-height: 100%; object-fit: contain; border: 0; }
.huazotl-gallery-viewer__stage img { touch-action: pan-y pinch-zoom; user-select: none; }
.huazotl-gallery-viewer__stage iframe { inset: 50% 0 auto; aspect-ratio: 16 / 9; height: auto; max-height: 100%; transform: translateY(-50%); }
.huazotl-gallery-viewer__close, .huazotl-gallery-viewer__nav {
	display: grid;
	place-items: center;
	box-sizing: border-box;
	width: 44px;
	height: 44px;
	margin: 0;
	padding: 0;
	border: 1px solid currentColor;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: 28px;
	line-height: 1;
	cursor: pointer;
}
.huazotl-gallery-viewer__close { position: absolute; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); border: 0; font-size: 36px; }
.huazotl-gallery-viewer__nav { grid-row: 1; align-self: center; }
.huazotl-gallery-viewer__nav--prev { grid-column: 1; }
.huazotl-gallery-viewer__nav--next { grid-column: 3; }
.huazotl-gallery-viewer__nav[hidden] { visibility: hidden; display: block; pointer-events: none; }
.huazotl-gallery-viewer__status { position: absolute; top: 24px; left: 24px; font-size: 14px; }
.huazotl-gallery-viewer__thumbs { grid-row: 2; grid-column: 1 / -1; position: relative; display: flex; gap: 10px; width: max-content; max-width: 100%; margin: 0 auto; padding: 4px; overflow-x: auto; scrollbar-width: thin; }
.huazotl-gallery-viewer__thumb { position: relative; flex: 0 0 76px; width: 76px; height: 76px; padding: 2px; margin: 0; border: 1px solid transparent; border-radius: 8px; color: inherit; background: transparent; cursor: pointer; }
.huazotl-gallery-viewer__thumb[aria-current="true"] { border-color: currentColor; }
.huazotl-gallery-viewer__preview { border-radius: 5px; overflow: hidden; }
.huazotl-gallery-viewer__preview img { display: block; width: 100%; height: 100%; object-fit: cover; }
.huazotl-gallery-viewer button:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

@media (max-width: 47.9375rem) {
	body.single-product .wapu-single__gallery [data-huazotl-gallery-reference="1"] .wapu-vg__main,
	body.single-product .wapu-single__gallery .huazotl-gallery-tile { border-radius: 12px !important; }
	dialog.huazotl-gallery-viewer { padding: max(60px, env(safe-area-inset-top)) 12px max(16px, env(safe-area-inset-bottom)); }
	dialog.huazotl-gallery-viewer[open] { grid-template-columns: 44px minmax(0, 1fr) 44px; gap: 12px 0; }
	.huazotl-gallery-viewer__stage { grid-column: 1 / -1; }
	.huazotl-gallery-viewer__nav { position: relative; z-index: 1; width: 44px; height: 44px; background: var(--wtds-surface, #fff7e9); font-size: 24px; }
	.huazotl-gallery-viewer__nav--next { justify-self: end; }
	.huazotl-gallery-viewer__thumb { flex-basis: 58px; width: 58px; height: 58px; }
	.huazotl-gallery-viewer__thumbs { gap: 6px; }
}

/* Mobile: one large slide and left-aligned dots. Base remains the swipe owner. */
@media (max-width: 61.9375rem) {
	body.single-product .wapu-single--regular-product .wapu-single__gallery,
	body.single-product.huazotl-variable-product .wapu-single--regular-product .wapu-single__gallery {
		padding-inline: 16px !important;
		box-sizing: border-box !important;
	}
	/* Remove the parent's Merit progress track and thumb underline. */
	body.single-product .wapu-single__gallery [data-huazotl-gallery-reference="1"] [data-wapu-vg-thumbs]::before,
	body.single-product .wapu-single__gallery [data-huazotl-gallery-reference="1"] [data-wapu-vg-thumbs]::after,
	body.single-product .wapu-single__gallery [data-huazotl-gallery-reference="1"] [data-wapu-vg-thumb]::after {
		content: none !important;
		display: none !important;
		animation: none !important;
		transition: none !important;
	}

	body.single-product .wapu-single__gallery [data-huazotl-gallery-reference="1"] .huazotl-gallery-grid {
		display: none !important;
	}
	body.single-product .wapu-single__gallery [data-huazotl-gallery-reference="1"] .wapu-vg__main {
		border-radius: 16px !important;
		touch-action: pan-y pinch-zoom;
	}
	body.single-product .wapu-single__gallery [data-huazotl-gallery-reference="1"] .huazotl-gallery-main-open {
		touch-action: pan-y pinch-zoom;
	}
	body.single-product .wapu-single__gallery [data-huazotl-gallery-reference="1"] [data-wapu-vg-thumbs]:not([hidden]),
	body.single-product.huazotl-variable-product .wapu-single__gallery [data-huazotl-gallery-reference="1"] [data-wapu-vg-thumbs]:not([hidden]) {
		display: flex !important;
		position: relative !important;
		flex-direction: row !important;
		align-items: center !important;
		justify-content: flex-start !important;
		gap: 0 !important;
		width: 100% !important;
		max-width: 100% !important;
		height: 28px !important;
		min-height: 28px !important;
		max-height: 28px !important;
		margin: -4px 0 0 !important;
		padding: 0 !important;
		overflow-x: auto !important;
		overflow-y: hidden !important;
		scrollbar-width: none;
	}
	body.single-product .wapu-single__gallery [data-huazotl-gallery-reference="1"] [data-wapu-vg-thumb],
	body.single-product.huazotl-variable-product .wapu-single__gallery [data-huazotl-gallery-reference="1"] [data-wapu-vg-thumb] {
		display: inline-flex !important;
		align-items: center !important;
		justify-content: flex-start !important;
		flex: 0 0 24px !important;
		width: 24px !important;
		height: 28px !important;
		min-width: 24px !important;
		max-width: 24px !important;
		min-height: 28px !important;
		max-height: 28px !important;
		margin: 0 !important;
		padding: 0 !important;
		border: 0 !important;
		border-radius: 0 !important;
		background: transparent !important;
		box-shadow: none !important;
		opacity: 1 !important;
		filter: none !important;
		transform: none !important;
		cursor: pointer;
	}
	body.single-product .wapu-single__gallery [data-huazotl-gallery-reference="1"] [data-wapu-vg-thumb]::before {
		content: '';
		display: block;
		width: 12px;
		height: 12px;
		border-radius: 50%;
		background: var(--wtds-ink, #241820);
		opacity: .32;
		transition: opacity 160ms ease, transform 160ms ease;
	}
	body.single-product .wapu-single__gallery [data-huazotl-gallery-reference="1"] [data-wapu-vg-thumb].is-active::before {
		opacity: 1;
		transform: none;
	}
	body.single-product .wapu-single__gallery [data-huazotl-gallery-reference="1"] [data-wapu-vg-thumb] > * { display: none !important; }
	body.single-product .wapu-single__gallery [data-huazotl-gallery-reference="1"] .huazotl-gallery-view-all { display: none !important; }
	body.single-product .wapu-single__gallery [data-huazotl-gallery-reference="1"]:has(.wapu-vg__main > :is(video, iframe)) .huazotl-gallery-view-all { display: block !important; }
}
@media (prefers-reduced-motion: reduce) {
	body.single-product .wapu-single__gallery [data-huazotl-gallery-reference="1"] [data-wapu-vg-thumb]::before { transition: none; }
}
