/**
 * Phase 5.17 Stage B — shared responsive system.
 * Presentation-only: containment, fluid gutters, commerce chrome offsets.
 * Does not redesign approved homepage sections.
 */

:root {
	--nds-gutter: clamp(0.875rem, 2.5vw, 1.125rem);
	--nds-gutter-lg: clamp(1rem, 3vw, 1.35rem);
	--nds-section-y: clamp(2rem, 5vw, 3.5rem);
	--nds-rail-card-w: min(21rem, calc(100% - 2 * var(--nds-gutter)));
	--nds-safe-bottom: env(safe-area-inset-bottom, 0px);
	--nds-fixed-bottom-offset: calc(var(--nds-bottom-bar-h, 3.75rem) + var(--nds-safe-bottom));
	--nds-header-offset: var(--nds-main-header-h, var(--nds-header-h, 5.25rem));

	/* Fluid type tokens (Stage B) */
	--nds-fs-display: clamp(1.85rem, 1.2rem + 2.2vw, 2.85rem);
	--nds-fs-section: clamp(1.45rem, 1.1rem + 1.2vw, 2rem);
	--nds-fs-card-title: clamp(0.95rem, 0.88rem + 0.35vw, 1.1rem);
	--nds-fs-body-fluid: clamp(0.95rem, 0.92rem + 0.2vw, 1.05rem);
	--nds-fs-meta: clamp(0.72rem, 0.7rem + 0.12vw, 0.8125rem);
	--nds-fs-label: clamp(0.68rem, 0.66rem + 0.1vw, 0.75rem);
	--nds-fs-button: clamp(0.875rem, 0.85rem + 0.15vw, 0.95rem);
	--nds-measure-body: 68ch;
}

/* Global page overflow containment (rails remain scrollable inside). */
html {
	overflow-x: clip;
}

body.nds-storefront {
	overflow-x: clip;
	font-size: var(--nds-fs-body-fluid);
}

body.nds-storefront .nds-container {
	width: min(calc(100% - 2 * var(--nds-gutter)), var(--nds-container-max, var(--nds-container)));
	padding-inline: 0;
}

body.nds-storefront .nds-container--wide {
	width: min(calc(100% - 2 * var(--nds-gutter)), var(--nds-container-wide));
}

/* Full-bleed heroes: avoid 100vw scrollbar overflow */
body.nds-storefront .nds-market-hero--storefront,
body.nds-storefront .nds-market-hero {
	width: 100%;
	max-width: 100%;
	margin-left: 0;
	margin-right: 0;
}

@media (max-height: 500px) and (orientation: landscape) {
	body.nds-storefront .nds-market-hero--storefront {
		min-height: auto;
	}

	body.nds-storefront .nds-site-header--premium {
		--nds-main-header-h: 3.65rem;
	}

	body.nds-storefront .nds-site-header--premium .nds-site-header__inner {
		padding-block: 0.35rem;
		min-height: 3.65rem;
	}
}

/* Subject showcase: contain carousel bleed */
body.nds-storefront .nds-ssubj,
body.nds-storefront .nds-ssubj__shell,
body.nds-storefront .nds-ssubj__stage,
body.nds-storefront .nds-ssubj__carousel {
	overflow-x: clip;
	max-width: 100%;
	min-width: 0;
}

body.nds-storefront .nds-ssubj__track {
	max-width: 100%;
}

body.nds-storefront .nds-ssubj-card {
	flex: 0 0 var(--nds-rail-card-w);
	width: var(--nds-rail-card-w);
	max-width: 100%;
}

/* Shelf / product rails: contain without killing swipe */
body.nds-storefront .nds-shelf__rail,
body.nds-storefront .nds-cat-rail__track,
body.nds-storefront #nds-featured .nds-shelf__rail,
body.nds-storefront .nds-new-releases__grid {
	max-width: 100%;
	overscroll-behavior-x: contain;
}

@media (max-width: 640px) {
	body.nds-storefront .nds-ssubj-card {
		flex: 0 0 min(17.5rem, calc(100% - 2.5rem));
		width: min(17.5rem, calc(100% - 2.5rem));
	}

	body.nds-storefront .nds-new-releases__grid .nds-nr-card {
		flex: 0 0 var(--nds-rail-card-w);
		max-width: var(--nds-rail-card-w);
	}
}

/* Sticky PDP purchase bar above mobile bottom nav */
@media (max-width: 1099px) {
	body.nds-storefront .nds-sticky-cart {
		padding-bottom: calc(var(--nds-space-3, 0.75rem) + var(--nds-fixed-bottom-offset));
		z-index: 250;
	}

	/*
	 * Body already reserves --nds-fixed-bottom-offset (+ buffer).
	 * Footer only needs normal editorial padding — avoid doubled empty space.
	 */
	body.nds-storefront .nds-site-footer.nds-ft {
		padding-bottom: 1.5rem;
	}

	body.nds-hide-bottom-bar .nds-sticky-cart {
		padding-bottom: calc(var(--nds-space-3, 0.75rem) + var(--nds-safe-bottom));
	}

	body.nds-hide-bottom-bar .nds-site-footer.nds-ft {
		padding-bottom: calc(1rem + var(--nds-safe-bottom));
	}
}

/* Product card actions: wrap on narrow cards */
@media (max-width: 480px) {
	body.nds-storefront .nds-product-card__actions {
		flex-wrap: wrap;
	}
}

/* Cart / checkout tables: prevent horizontal page overflow */
@media (max-width: 767px) {
	body.nds-storefront.woocommerce-cart .woocommerce {
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
	}

	body.nds-storefront.woocommerce-checkout .woocommerce {
		overflow-x: visible;
	}

	body.nds-storefront .woocommerce table.shop_table {
		min-width: 0;
	}
}

/* Account nav stack */
@media (max-width: 767px) {
	body.nds-storefront.woocommerce-account .woocommerce-MyAccount-navigation,
	body.nds-storefront.woocommerce-account .woocommerce-MyAccount-content {
		float: none;
		width: 100%;
	}
}

/* Decorative atmospheres must not expand page scrollWidth */
body.nds-storefront .nds-ssubj__panel-bg,
body.nds-storefront .nds-fcol__atmosphere,
body.nds-storefront .nds-ft__atmosphere,
body.nds-storefront .nds-ss__atmosphere,
body.nds-storefront .nds-dd__panel,
body.nds-storefront .nds-ft-cta {
	overflow: hidden;
	max-width: 100%;
}
