/**
 * Atlas Labs — Product Detail Page
 *
 * Restyles WooCommerce's native single-product markup with Atlas Labs
 * tokens rather than overriding the PHP templates that produce it,
 * per CODING_STANDARDS.md's hook/filter-over-template-override
 * preference. The first section is the layout shell: image, title,
 * price, variant selector, short description, add-to-cart. The second
 * section (Technical Data Cards) styles the floating Properties / COA /
 * 2D Structure cards injected by inc/product-detail.php.
 *
 * Loaded only on single product pages — see inc/enqueue.php.
 */

html body.woocommerce div.product {
	max-width: var(--container-max-width);
	margin: 0 auto;
	padding: var(--space-64) var(--container-gutter-desktop) var(--space-96);
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	gap: var(--space-64);
	align-items: start;
}

/* The gallery-area RUO notice (inc/woocommerce.php's
 * atlaslabs_single_product_gallery_ruo_notice(), hooked on
 * woocommerce_before_single_product_summary) renders as a THIRD direct
 * child of this 2-column grid, after div.images and before div.summary
 * — without an explicit position, CSS grid auto-placement puts it in
 * row 1 column 2 (displacing div.summary to row 2 column 1) rather
 * than under the image where it belongs. Same class of bug as the
 * header logo grid-row issue documented in theme/atlaslabs/CLAUDE.md —
 * explicit grid-column/grid-row is the fix, not reordering markup. */
html body.woocommerce div.product > .al-ruo-notice {
	grid-column: 1;
	grid-row: 2;
}

/* ---------------------------------------------------------------
 * Image column
 * ------------------------------------------------------------- */

html body.woocommerce div.product div.images {
	background-color: var(--color-bg-secondary);
	border: var(--border-width-standard) solid var(--color-border-primary);
	border-radius: var(--radius-lg);
	padding: var(--space-48);
	display: flex;
	align-items: center;
	justify-content: center;
}

html body.woocommerce div.product div.images img {
	width: 100%;
	height: auto;
	object-fit: contain;
	max-height: 520px;
}

/* ---------------------------------------------------------------
 * Summary (buy box) column
 * ------------------------------------------------------------- */

html body.woocommerce div.product div.summary {
	display: flex;
	flex-direction: column;
	gap: var(--space-20);
}

html body.woocommerce div.product .product_title {
	font-size: var(--type-h1-size);
	font-weight: var(--weight-semibold);
	line-height: var(--type-h1-line-height);
	letter-spacing: var(--type-h1-letter-spacing);
	color: var(--color-text-primary);
	margin: 0;
}

html body.woocommerce div.product p.price,
html body.woocommerce div.product span.price {
	font-size: var(--type-h3-size);
	font-weight: var(--weight-semibold);
	color: var(--color-text-primary);
	margin: 0;
}

html body.woocommerce div.product .woocommerce-product-details__short-description {
	font-size: var(--type-body-size);
	line-height: var(--type-body-line-height);
	color: var(--color-text-secondary);
}

/* ---------------------------------------------------------------
 * Variant selector — native <select> is kept for accessibility and
 * WooCommerce's own price/availability logic, but visually hidden;
 * assets/js/variant-selector.js renders the button group below and
 * drives the select's value + change event. If JS fails to load,
 * the native select still renders and still works.
 * ------------------------------------------------------------- */

html body.woocommerce div.product table.variations {
	display: block;
	border: none;
}

html body.woocommerce div.product table.variations tbody,
html body.woocommerce div.product table.variations tr,
html body.woocommerce div.product table.variations td,
html body.woocommerce div.product table.variations th {
	display: block;
	padding: 0;
	border: none;
}

html body.woocommerce div.product table.variations label {
	font-size: var(--type-label-size);
	font-weight: var(--type-label-weight);
	letter-spacing: var(--type-label-letter-spacing);
	text-transform: var(--type-label-transform);
	color: var(--color-text-secondary);
	display: block;
	margin-bottom: var(--space-8);
}

html body.woocommerce div.product table.variations select.al-js-enhanced {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.al-variant-buttons {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-8);
}

.al-variant-buttons__option {
	font-family: var(--font-family-base);
	font-size: var(--type-button-size);
	font-weight: var(--weight-medium);
	color: var(--color-text-primary);
	background-color: var(--color-bg-primary);
	border: var(--border-width-standard) solid var(--color-border-primary);
	border-radius: var(--radius-md);
	padding: var(--space-8) var(--space-16);
	cursor: pointer;
	transition: border-color var(--duration-fast) var(--easing-standard),
		background-color var(--duration-fast) var(--easing-standard);
}

.al-variant-buttons__option:hover {
	border-color: var(--color-border-secondary);
}

.al-variant-buttons__option:focus-visible {
	outline: var(--border-width-focus) solid var(--color-focus-ring);
	outline-offset: 2px;
}

.al-variant-buttons__option[aria-pressed="true"] {
	background-color: var(--color-accent-primary);
	border-color: var(--color-accent-primary);
	color: var(--color-bg-primary);
}

/* ---------------------------------------------------------------
 * Add to cart
 * ------------------------------------------------------------- */

html body.woocommerce div.product .single_add_to_cart_button,
html body.woocommerce div.product button.single_add_to_cart_button {
	font-family: var(--font-family-base);
	font-size: var(--type-button-size);
	font-weight: var(--weight-semibold);
	letter-spacing: var(--type-button-letter-spacing);
	background-color: var(--color-accent-primary);
	color: var(--color-bg-primary);
	border: none;
	border-radius: var(--radius-md);
	padding: var(--space-12) var(--space-24);
	cursor: pointer;
	transition: background-color var(--duration-fast) var(--easing-standard);
}

html body.woocommerce div.product .single_add_to_cart_button:hover,
html body.woocommerce div.product button.single_add_to_cart_button:hover {
	background-color: var(--color-accent-hover);
}

html body.woocommerce div.product .single_add_to_cart_button:disabled,
html body.woocommerce div.product button.single_add_to_cart_button:disabled {
	background-color: var(--color-surface-disabled);
	color: var(--color-text-disabled);
	cursor: not-allowed;
}

/* ---------------------------------------------------------------
 * Responsive
 * ------------------------------------------------------------- */

@media (max-width: 1023px) {
	html body.woocommerce div.product {
		grid-template-columns: 1fr;
		padding: var(--space-40) var(--container-gutter-tablet) var(--space-64);
		gap: var(--space-32);
	}

	html body.woocommerce div.product div.images img {
		max-height: 400px;
	}
}

@media (max-width: 767px) {
	html body.woocommerce div.product {
		padding: var(--space-32) var(--container-gutter-mobile) var(--space-48);
	}

	html body.woocommerce div.product .product_title {
		font-size: var(--type-h2-size);
	}
}

/* ===============================================================
 * Technical Data Cards — Properties / COA / 2D Structure
 *
 * Floating cards injected below the buy area by
 * inc/product-detail.php. Light warm-neutral surfaces on the white
 * page, distinguished by fill + radius, lifting to shadow-md only on
 * hover, per the flat-at-rest / elevate-on-interaction rule in
 * DESIGN_SYSTEM.md#section-7-shadow-system.
 * =============================================================== */

/* WooCommerce renders the tabs panel and "Related products" as direct
   children of div.product, the same two-column grid used for the
   image/summary layout above. Without an explicit span, both get
   auto-placed into a single 584px grid cell instead of the page's
   full width — confirmed live: the related-products grid computed
   116px-wide columns instead of spanning ~1232px. Same fix as
   .al-product-cards below. */
html body.woocommerce div.product .woocommerce-tabs,
html body.woocommerce div.product .related.products {
	grid-column: 1 / -1;
}

.al-product-cards {
	/* Span the full width of div.product's two-column buy-area grid. */
	grid-column: 1 / -1;
	display: flex;
	flex-direction: column;
	gap: var(--space-24);
	margin-top: var(--space-16);
}

.al-info-card {
	background-color: var(--color-bg-secondary);
	border: var(--border-width-standard) solid var(--color-border-primary);
	border-radius: var(--radius-lg);
	padding: var(--space-32);
	transition: box-shadow var(--duration-standard) var(--easing-standard),
		transform var(--duration-standard) var(--easing-standard),
		border-color var(--duration-standard) var(--easing-standard);
}

@media (hover: hover) {
	.al-info-card:hover {
		box-shadow: var(--shadow-md);
		border-color: var(--color-border-secondary);
		transform: translateY(-2px);
	}
}

.al-info-card__title {
	font-size: var(--type-h3-size);
	font-weight: var(--weight-semibold);
	line-height: var(--type-h3-line-height);
	letter-spacing: var(--type-h3-letter-spacing);
	color: var(--color-text-primary);
	margin: 0 0 var(--space-24);
}

/* ---------------------------------------------------------------
 * Properties table — two-column key/value with a hairline vertical
 * divider between columns and hairline rules between rows.
 * ------------------------------------------------------------- */

.al-properties-table {
	margin: 0;
	border-top: var(--divider-thickness) solid var(--color-divider-default);
}

.al-properties-table__row {
	display: grid;
	grid-template-columns: minmax(0, 4fr) minmax(0, 6fr);
	border-bottom: var(--divider-thickness) solid var(--color-divider-default);
}

.al-properties-table__key,
.al-properties-table__value {
	padding: var(--space-16);
	font-size: var(--type-body-small-size);
	line-height: var(--type-body-small-line-height);
	margin: 0;
}

.al-properties-table__key {
	color: var(--color-text-secondary);
	font-weight: var(--weight-medium);
}

.al-properties-table__value {
	color: var(--color-text-primary);
	border-left: var(--divider-thickness) solid var(--color-divider-default);
	font-variant-numeric: tabular-nums;
	overflow-wrap: anywhere;
}

.al-properties-table__value sub {
	font-size: 0.75em;
}

/* ---------------------------------------------------------------
 * Certificate of Analysis
 * ------------------------------------------------------------- */

.al-coa {
	display: flex;
	flex-direction: column;
	gap: var(--space-16);
}

.al-coa__batch-header {
	color: var(--color-text-secondary);
	padding-bottom: var(--space-12);
	border-bottom: var(--divider-thickness) solid var(--color-divider-default);
	margin: 0;
}

/* Pending state: the card renders before the batch document is
   published; muted copy in place of the Full Report button. */
.al-coa__pending {
	color: var(--color-text-muted);
	font-size: var(--type-body-small-size);
	line-height: var(--type-body-small-line-height);
	margin: 0;
}

.al-coa__details {
	margin: 0;
	display: flex;
	flex-direction: column;
	gap: var(--space-12);
}

.al-coa__row {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: var(--space-16);
}

.al-coa__key {
	color: var(--color-text-secondary);
	font-size: var(--type-body-small-size);
	margin: 0;
}

.al-coa__value {
	color: var(--color-text-primary);
	font-size: var(--type-body-small-size);
	font-weight: var(--weight-medium);
	font-variant-numeric: tabular-nums;
	margin: 0;
	text-align: right;
}

.al-coa__report {
	align-self: flex-start;
	margin-top: var(--space-4);
}

/* ---------------------------------------------------------------
 * 2D Structure — centered skeletal diagram on a white plate.
 * The plate stays genuinely white on the dark palette: PubChem-style
 * skeletal diagrams are black line art with no dark-legible variant,
 * so they render as a document artifact on --color-surface-document.
 * ------------------------------------------------------------- */

.al-structure {
	margin: 0;
	background-color: var(--color-surface-document);
	border: var(--border-width-standard) solid var(--color-border-primary);
	border-radius: var(--radius-md);
	padding: var(--space-32);
	display: flex;
	align-items: center;
	justify-content: center;
}

.al-structure__image {
	max-width: 100%;
	height: auto;
	max-height: 420px;
	object-fit: contain;
}

/* ---------------------------------------------------------------
 * Orchestrated entrance — a single staggered fade-up on load rather
 * than scattered micro-interactions. Fully disabled under
 * prefers-reduced-motion, per DESIGN_SYSTEM.md#section-8.
 * ------------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
	.al-info-card {
		opacity: 0;
		animation: al-card-reveal var(--duration-slow) var(--easing-decelerate) forwards;
	}

	.al-info-card:nth-child(1) {
		animation-delay: 60ms;
	}

	.al-info-card:nth-child(2) {
		animation-delay: 140ms;
	}

	.al-info-card:nth-child(3) {
		animation-delay: 220ms;
	}
}

@keyframes al-card-reveal {
	from {
		opacity: 0;
		transform: translateY(12px);
	}

	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* ---------------------------------------------------------------
 * Responsive — cards
 * ------------------------------------------------------------- */

@media (max-width: 767px) {
	.al-info-card {
		padding: var(--space-24);
	}

	.al-info-card__title {
		font-size: var(--type-h4-size);
		margin-bottom: var(--space-16);
	}

	.al-properties-table__key,
	.al-properties-table__value {
		padding: var(--space-12);
	}

	.al-structure {
		padding: var(--space-16);
	}
}

/* Phone widths: the two-column key/value grid leaves the value column
   ~180px wide — long values (sequences, molecular formulas) wrap hard.
   Stack each row: key above value, hairline between rows only. */
@media (max-width: 479px) {
	.al-properties-table__row {
		grid-template-columns: 1fr;
	}

	.al-properties-table__key {
		padding-bottom: 0;
	}

	.al-properties-table__value {
		border-left: none;
		padding-top: var(--space-4);
	}
}
