/* Single product page — Astra-friendly (inherits theme fonts/colors) */

/* Blog-post chrome (title, byline, banner) is suppressed via Astra filters in
   includes/astra-compat.php; these rules are the fallback for other themes. */
.single-cwd_product .entry-header,
.single-cwd_product .ast-single-entry-banner {
	display: none;
}

/* The full-width layout strips theme container padding; restore gutters here. */
.cwd-product {
	container-type: inline-size;
	padding: clamp(1.5rem, 3vw, 3rem) clamp(1.25rem, 4vw, 3.5rem);
}

/* ---- Top: media + info ---- */

.cwd-product__top {
	display: grid;
	grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr);
	gap: 2.5rem;
	align-items: start;
}

/* Grid items must be allowed to shrink below their content width, otherwise
   the gallery thumb strip forces the track wider than the page (grid blowout). */
.cwd-product__media,
.cwd-product__info {
	min-width: 0;
}

/* Media-query fallback: viewport proxy for the 800px container breakpoint
   (~70px of .cwd-product inline padding). Container query below wins where supported. */
@media (max-width: 870px) {
	.cwd-product__top {
		grid-template-columns: minmax(0, 1fr);
		gap: 1.75rem;
	}
}

@container (max-width: 800px) {
	.cwd-product__top {
		grid-template-columns: minmax(0, 1fr);
		gap: 1.75rem;
	}
}

/* ---- Gallery viewer ---- */

.cwd-gallery-viewer__main {
	position: relative;
	margin: 0;
	aspect-ratio: 1;
	overflow: hidden;
	border-radius: 4px;
	background: rgba(0, 0, 0, 0.04);
}

/* Stacked layers enable a smooth crossfade when switching images (JS swaps
   the .is-back layer). */
.cwd-gallery-viewer__main img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: opacity 0.3s ease;
}

.cwd-gallery-viewer__main img.is-back {
	opacity: 0;
}

.cwd-gallery-viewer__nav {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin-top: 0.75rem;
}

.cwd-gallery-viewer__thumbs {
	display: flex;
	gap: 0.5rem;
	overflow-x: auto;
	scrollbar-width: thin;
	flex: 1 1 auto;
	min-width: 0; /* allow the strip to shrink so it scrolls instead of overflowing */
	padding: 2px;
}

.cwd-gallery-viewer__thumb {
	flex: 0 0 72px;
	width: 72px;
	min-width: 72px;
	height: 72px;
	padding: 0;
	border: 2px solid transparent;
	border-radius: 4px;
	overflow: hidden;
	background: rgba(0, 0, 0, 0.04);
	cursor: pointer;
}

.cwd-gallery-viewer__thumb.is-active {
	border-color: var(--ast-global-color-0, #046bd2);
}

.cwd-gallery-viewer__thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.cwd-gallery-viewer__arrow {
	flex: 0 0 auto;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 1px solid rgba(0, 0, 0, 0.12);
	border-radius: 50%;
	background: transparent;
	color: inherit;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
}

.cwd-gallery-viewer__arrow:hover {
	border-color: var(--ast-global-color-0, #046bd2);
	color: var(--ast-global-color-0, #046bd2);
}

/* ---- Info column ---- */

.cwd-product__title {
	margin: 0 0 0.75rem;
	font-size: clamp(1.6rem, 3vw, 2.25rem);
	line-height: 1.2;
}

.cwd-product__numbers {
	list-style: none;
	margin: 0 0 1rem;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 1.5rem;
	font-size: 0.95rem;
}

.cwd-product__label {
	font-weight: 600;
	opacity: 0.75;
	margin-right: 0.35em;
}

.cwd-product__price {
	font-size: 1.4rem;
	font-weight: 700;
	margin-bottom: 1.25rem;
}

/* On-request price is a button that opens the modal; keep it looking like the
   price text but signal it is interactive. */
.cwd-product__price--request {
	display: inline-flex;
	align-items: center;
	gap: 0.45rem;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	font-size: 1.4rem;
	font-weight: 700;
	cursor: pointer;
}

.cwd-product__price--request > span {
	text-decoration: underline;
	text-underline-offset: 3px;
}

.cwd-product__price-icon {
	flex: none;
	width: 1.15em;
	height: 1.15em;
}

.cwd-product__price--request:hover,
.cwd-product__price--request:focus-visible {
	color: var(--ast-global-color-0, #046bd2);
}

/* ---- "Available Upon Request" modal ---- */

.cwd-price-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
	opacity: 0;
	transition: opacity 200ms ease;
}

.cwd-price-modal[hidden] {
	display: none;
}

.cwd-price-modal.is-open {
	opacity: 1;
}

.cwd-price-modal__overlay {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.55);
}

.cwd-price-modal__dialog {
	box-sizing: border-box; /* Popup Width must be the rendered width, padding included. */
	position: relative;
	width: 100%;
	/* max-width comes from the Popup Width setting (inline style). */
	max-height: calc(100vh - 2rem);
	overflow: auto;
	padding: 2rem;
	border-radius: 10px;
	background: #fff;
	color: #1e1e1e;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
	transform: translateY(12px) scale(0.98);
	transition: transform 200ms ease;
}

.cwd-price-modal.is-open .cwd-price-modal__dialog {
	transform: none;
}

.cwd-price-modal__close {
	position: absolute;
	top: 0.5rem;
	right: 0.5rem;
	width: 2rem;
	height: 2rem;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	color: inherit;
	font-size: 1.6rem;
	line-height: 1;
	cursor: pointer;
}

.cwd-price-modal__close:hover,
.cwd-price-modal__close:focus-visible {
	background: rgba(0, 0, 0, 0.08);
}

.cwd-price-modal__body > *:first-child {
	margin-top: 0;
}

.cwd-price-modal__body > *:last-child {
	margin-bottom: 0;
}

.cwd-global-content {
	margin-bottom: 1.25rem;
}

.cwd-product__purchase {
	display: inline-block;
	padding: 0.85em 2.2em;
	margin-bottom: 1.25rem;
	border-radius: 4px;
	background: var(--ast-global-color-0, #046bd2);
	color: #fff;
	font-weight: 600;
	text-decoration: none;
	transition: filter 0.2s ease;
}

.cwd-product__purchase:hover,
.cwd-product__purchase:focus {
	filter: brightness(0.88);
	color: #fff;
}

.cwd-product__items h2 {
	font-size: 1.15rem;
	margin: 0 0 0.5rem;
}

.cwd-product__items ul {
	margin: 0;
	padding-left: 1.2em;
}

/* ---- Info column sections (About, Specifications, Condition, Shipping) ---- */

.cwd-product__section {
	margin-top: 1.75rem;
}

.cwd-product__section > h2 {
	font-size: 1.3rem;
	margin: 0 0 1rem;
}

/* Rich text output (About, Condition, Shipping) */

.cwd-richtext p {
	margin: 0 0 1rem;
}

.cwd-richtext > *:last-child {
	margin-bottom: 0;
}

.cwd-richtext h3,
.cwd-richtext h4 {
	font-size: 1.05rem;
	margin: 1.25rem 0 0.5rem;
}

.cwd-richtext ul,
.cwd-richtext ol {
	margin: 0 0 1rem;
	padding-left: 1.5rem;
}

.cwd-richtext li {
	margin-bottom: 0.35rem;
}

.cwd-richtext a {
	text-decoration: underline;
}

.cwd-richtext blockquote {
	margin: 0 0 1rem;
	padding-left: 1rem;
	border-left: 2px solid currentColor;
	opacity: 0.85;
}

/* Specifications table (zebra rows, like the reference layout) */

.cwd-product__specs dl {
	margin: 0;
}

.cwd-product__spec {
	display: flex;
	gap: 1.5rem;
	padding: 0.8rem 1rem;
	border-radius: 3px;
}

.cwd-product__spec:nth-child(odd) {
	background: rgba(0, 0, 0, 0.045);
}

.cwd-product__spec dt {
	flex: 0 0 40%;
	font-weight: 600;
}

.cwd-product__spec dd {
	flex: 1 1 auto;
	margin: 0;
}

@media (max-width: 520px) {
	.cwd-product__spec {
		flex-direction: column;
		gap: 0.15rem;
	}
}

@container (max-width: 480px) {
	.cwd-product__spec {
		flex-direction: column;
		gap: 0.15rem;
	}
}
