/**
 * Blueprint — commerce interaction styles.
 *
 * Structural layer for the ported Rebuy smart cart + quick view. The theme's
 * rebuy-cart.css only contains colour/typography overrides copied from the
 * reference site's inline <style> tags; the base Rebuy bundle (layout,
 * positioning, overlay) is not shipped with the clone, so everything that
 * makes the drawer a slide-over panel lives here.
 *
 * Loaded after rebuy-cart.css and quick-view.css (see inc/cart-drawer.php).
 */

/* ==========================================================================
   1. Drawer shell — must never contribute to document flow
   ========================================================================== */

#rebuy-cart.rebuy-cart {
	position: fixed;
	inset: 0;
	z-index: 2147483000;
	visibility: hidden;
	pointer-events: none;
	overflow: hidden;
}

html.rebuy-cart-visible #rebuy-cart.rebuy-cart {
	visibility: visible;
	pointer-events: auto;
}

body.bp-cart-open {
	overflow: hidden;
}

/* Backdrop */
#rebuy-cart .rebuy-cart__background {
	position: absolute;
	inset: 0;
	z-index: 1;
	background: rgba(17, 28, 53, 0.55);
	-webkit-backdrop-filter: blur(2px);
	backdrop-filter: blur(2px);
	opacity: 0;
	transition: opacity 0.28s ease;
}

html.rebuy-cart-visible #rebuy-cart .rebuy-cart__background {
	opacity: 1;
}

/* Slide-over panel */
#rebuy-cart .rebuy-cart__flyout {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	display: flex;
	flex-direction: column;
	flex-wrap: nowrap;
	gap: 0;
	width: min(420px, calc(100vw - 16px));
	max-width: 420px;
	margin: 0;
	padding: 0;
	overflow: hidden;
	border-radius: 0;
	background: #f6f4ec;
	box-shadow: -24px 0 60px rgba(17, 28, 53, 0.22);
	transform: translateX(105%);
	transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
	z-index: 2;
}

html.rebuy-cart-visible #rebuy-cart .rebuy-cart__flyout {
	transform: translateX(0);
}

/* ==========================================================================
   2. Drawer chrome
   ========================================================================== */

#rebuy-cart [data-rebuy-cart-anchor="header"] {
	position: relative;
	display: flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	min-height: 64px;
	padding: 1rem 3.5rem 1rem 1.25rem;
	background: #ffffff;
	border-bottom: 1px solid rgba(29, 44, 78, 0.14);
}

#rebuy-cart [data-rebuy-cart-header-top] {
	width: 100%;
}

#rebuy-cart [data-rebuy-cart-header-top-inner] {
	display: flex;
	align-items: center;
	justify-content: center;
}

#rebuy-cart .rebuy-cart__title {
	margin: 0;
	font-family: "DM Sans", "Montserrat", sans-serif;
	font-size: 1.0625rem;
	font-weight: 600;
	letter-spacing: 0.01em;
	line-height: 1.2;
	color: #111c35;
}

#rebuy-cart .rebuy-cart__flyout-close {
	position: absolute;
	top: 50%;
	right: 0.75rem;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	color: #111c35;
	cursor: pointer;
	transform: translateY(-50%);
}

#rebuy-cart .rebuy-cart__flyout-close:hover,
#rebuy-cart .rebuy-cart__flyout-close:focus-visible {
	background: rgba(29, 44, 78, 0.08);
}

#rebuy-cart [data-rebuy-cart-scroll-area] {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	background: #fbfaf7;
}

#rebuy-cart [data-rebuy-cart-anchor="body"] {
	padding: 1.25rem;
}

#rebuy-cart [data-rebuy-component="cart-items"] {
	padding: 0;
	border: 0;
}

#rebuy-cart ul[data-smartcart-items] {
	display: flex;
	flex-direction: column;
	gap: 1.125rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* ==========================================================================
   3. Line items
   ========================================================================== */

#rebuy-cart .rebuy-cart__flyout-item {
	position: relative;
	display: grid !important;
	grid-template-columns: 76.5px minmax(0, 1fr) !important;
	column-gap: 12px !important;
	align-items: start;
	padding: 0 0 10px !important;
}

#rebuy-cart .rebuy-cart__flyout-item > .rebuy-cart__flyout-item-media {
	grid-column: 1;
	grid-row: 1;
	width: 76.5px;
	height: 76.5px;
	overflow: hidden;
	border-radius: 4px;
	background: #ece7da;
}

#rebuy-cart .rebuy-cart__flyout-item > .rebuy-cart__flyout-item-media img {
	display: block;
	width: 76.5px;
	height: 76.5px;
	object-fit: cover;
	border-radius: 4px;
}

#rebuy-cart .rebuy-cart__flyout-item > .rebuy-cart__flyout-item-info {
	display: flex;
	flex-direction: column;
	gap: 6px;
	grid-column: 2;
	grid-row: 1;
	min-width: 0;
	padding-right: 22px;
}

#rebuy-cart .rb-b__title-row {
	display: flex;
	align-items: flex-start;
	min-width: 0;
}

#rebuy-cart .rebuy-cart__flyout-item-product-title {
	display: block;
	overflow: hidden;
	font-family: "DM Sans", sans-serif;
	font-size: 0.875rem;
	font-weight: 600;
	line-height: 1.3;
	color: #111c35;
	text-decoration: none;
	text-overflow: ellipsis;
	white-space: nowrap;
}

#rebuy-cart .rebuy-cart__flyout-item-product-title:hover {
	text-decoration: underline;
}

#rebuy-cart .rb-b__meta-row {
	display: flex;
	align-items: baseline;
	gap: 8px;
	font-size: 0.75rem;
	color: rgba(29, 44, 78, 0.62);
}

#rebuy-cart .rebuy-cart__flyout-item-variant-title {
	font-size: 0.75rem;
	line-height: 1.3;
}

#rebuy-cart .rebuy-cart__flyout-item-price {
	margin-left: auto;
	font-size: 0.8125rem;
	font-weight: 600;
	color: #111c35;
	white-space: nowrap;
}

#rebuy-cart .rebuy-cart__flyout-item-quantity {
	margin-top: 2px;
}

#rebuy-cart .rebuy-cart__flyout-item-quantity-widget {
	display: inline-flex;
	align-items: center;
	border: 1px solid rgba(29, 44, 78, 0.25);
	border-radius: 999px;
	overflow: hidden;
}

#rebuy-cart .rebuy-cart__flyout-item-quantity-widget-button {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 28px;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	color: #111c35;
	font-size: 15px;
	line-height: 1;
	cursor: pointer;
}

#rebuy-cart .rebuy-cart__flyout-item-quantity-widget-button:hover {
	background: rgba(29, 44, 78, 0.07);
}

#rebuy-cart .rebuy-cart__flyout-item-quantity-widget-label {
	min-width: 30px;
	padding: 0 4px;
	border-width: 0;
	font-size: 0.8125rem;
	font-weight: 600;
	line-height: 28px;
	text-align: center;
	color: #111c35;
}

#rebuy-cart .rebuy-cart__flyout-item-remove {
	position: absolute;
	top: 0;
	right: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 20px;
	height: 20px;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	color: rgba(29, 44, 78, 0.5);
	cursor: pointer;
}

#rebuy-cart .rebuy-cart__flyout-item-remove:hover {
	color: #111c35;
}

#rebuy-cart .rebuy-cart__flyout-item.is-updating {
	opacity: 0.6;
}

/* Empty state */
#rebuy-cart .rebuy-cart__flyout-empty-cart {
	padding: 2.5rem 1rem;
	text-align: center;
}

#rebuy-cart .rebuy-cart__flyout-empty-cart h3 {
	margin: 0 0 0.5rem;
	font-size: 1.125rem;
	font-weight: 600;
	color: #111c35;
}

#rebuy-cart .rebuy-cart__flyout-empty-cart p {
	margin: 0 0 1rem;
	font-size: 0.875rem;
	color: rgba(29, 44, 78, 0.7);
}

#rebuy-cart .rebuy-cart__flyout-empty-cart a.rebuy-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 42px;
	padding: 0 1.5rem;
	border-radius: 999px;
	background: #111c35;
	color: #f6f4ec;
	font-size: 0.9375rem;
	font-weight: 600;
	text-decoration: none;
}

#rebuy-cart .rebuy-cart__flyout-empty-cart a.rebuy-button:hover {
	background: #17233f;
}

/* ==========================================================================
   4. Footer: subtotal + checkout
   ========================================================================== */

#rebuy-cart [data-rebuy-cart-anchor="footer"] {
	flex: 0 0 auto;
	padding: 0;
	background: #f6f4ec;
	border-top: 1px solid rgba(29, 44, 78, 0.12);
}

#rebuy-cart [data-rebuy-component="cart-subtotal"] {
	padding: 1rem 1.25rem 0.5rem;
}

#rebuy-cart .rebuy-cart__flyout-subtotal {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 1rem;
	width: 100%;
	font-size: 0.9375rem;
	font-weight: 600;
	color: #111c35;
}

#rebuy-cart .rebuy-cart__flyout-subtotal-label {
	display: inline-flex;
	align-items: baseline;
	gap: 6px;
}

#rebuy-cart .rebuy-cart__subtotal-text {
	font-size: 0.9375rem;
	font-weight: 600;
	color: #111c35;
}

#rebuy-cart .rebuy-cart__subtotal-count {
	font-size: 0.75rem;
	font-weight: 400;
	color: rgba(29, 44, 78, 0.42);
}

#rebuy-cart .rebuy-cart__flyout-subtotal-amount {
	font-size: 1rem;
	font-weight: 600;
	color: #111c35;
}

#rebuy-cart [data-rebuy-component="checkout-area"] {
	padding: 0.75rem 1.25rem 1.25rem;
}

#rebuy-cart [data-rebuy-component="checkout-area"] .rebuy-cart__checkout-button.rebuy-button {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 46px;
	margin: 0;
	padding: 0 1.5rem;
	border: 0;
	border-radius: 999px;
	background: #111c35;
	color: #f6f4ec;
	font-size: 1rem;
	font-weight: 600;
	text-decoration: none;
	text-align: center;
	cursor: pointer;
	transition: background-color 0.2s ease;
}

#rebuy-cart [data-rebuy-component="checkout-area"] .rebuy-cart__checkout-button.rebuy-button:hover {
	background: #17233f;
	color: #ffffff;
}

/* ==========================================================================
   5. ATC loading state + toast
   ========================================================================== */

.button--quickview.is-loading,
[data-bp-add-to-cart].is-loading {
	cursor: progress;
}

.button--quickview.is-loading .button-text,
[data-bp-add-to-cart].is-loading .button-text {
	opacity: 0.55;
}

.bp-spinner {
	display: inline-block;
	vertical-align: middle;
}

#bp-cart-toast {
	position: fixed;
	left: 50%;
	bottom: 1.5rem;
	z-index: 2147483200;
	display: block;
	max-width: min(420px, calc(100vw - 2rem));
	padding: 0.75rem 1.25rem;
	border-radius: 999px;
	background: #111c35;
	color: #f6f4ec;
	font-family: "DM Sans", sans-serif;
	font-size: 0.875rem;
	font-weight: 500;
	line-height: 1.3;
	text-align: center;
	box-shadow: 0 12px 30px rgba(17, 28, 53, 0.28);
	opacity: 0;
	pointer-events: none;
	transform: translate(-50%, 12px);
	transition: opacity 0.2s ease, transform 0.2s ease;
}

#bp-cart-toast.is-visible {
	opacity: 1;
	transform: translate(-50%, 0);
}

#bp-cart-toast.is-error {
	background: #8f2a2a;
}

/* On small screens the drawer is nearly full width, so the toast has to sit
   above the sticky subtotal/checkout footer instead of on top of it. */
@media (max-width: 767px) {
	html.rebuy-cart-visible #bp-cart-toast {
		bottom: calc(env(safe-area-inset-bottom, 0px) + 9.25rem);
		max-width: calc(100vw - 3rem);
	}
}

#rebuy-cart-live-region.sr-only {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ==========================================================================
   6. Quick view
   ========================================================================== */

#QuickView {
	position: fixed !important;
	inset: 0;
	z-index: 9999999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1.25rem;
}

#QuickView .x-overlay {
	display: block;
	position: absolute;
	inset: 0;
	background: rgba(17, 28, 53, 0.5);
}

.quick_view .x-quickview-modal {
	position: relative !important;
	top: auto !important;
	right: auto !important;
	bottom: auto !important;
	left: auto !important;
	width: min(1000px, calc(100vw - 2.5rem));
	max-width: min(1000px, calc(100vw - 2.5rem));
	max-height: calc(100vh - 2.5rem);
	margin: 0 auto;
	overflow-x: hidden;
	overflow-y: auto;
	border-radius: 1.25rem;
	background: #f6f4ec;
	box-shadow: 0 30px 80px rgba(17, 28, 53, 0.3);
	transform: none !important;
}

#QuickView .qv-loader {
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 2rem;
	border-radius: 1.25rem;
	background: #f6f4ec;
	transform: translate(-50%, -50%);
}

#quickview-product-content {
	padding: 0;
}

#QuickView .bp-qv {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	gap: 0;
	margin: 0;
	padding: 1.5rem;
	background: #f6f4ec;
}

#QuickView .bp-qv__close {
	position: absolute;
	top: 1rem;
	right: 1rem;
	z-index: 3;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.85);
	color: #111c35;
	cursor: pointer;
}

#QuickView .bp-qv__media {
	width: 100%;
}

#QuickView .bp-qv__media img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 1 / 1;
	object-fit: cover;
	border-radius: 0.75rem;
	background: #ece7da;
}

#QuickView .bp-qv__content {
	display: flex;
	flex-direction: column;
	gap: 0.875rem;
	width: 100%;
	margin-top: 1.25rem;
}

#QuickView .bp-qv__title {
	margin: 0;
	font-family: "DM Sans", "Montserrat", sans-serif;
	font-size: 1.5rem;
	font-weight: 600;
	line-height: 1.2;
	color: #111c35;
}

#QuickView .bp-qv__price {
	/* quick-view.css hides .x-block-price; the price must stay visible here. */
	display: block !important;
	margin: 0;
	font-size: 1.125rem;
	font-weight: 600;
	color: #111c35;
}

#QuickView .bp-qv__price p {
	margin: 0;
}

#QuickView .bp-qv__benefits {
	margin: 0;
	padding: 0;
	list-style: none;
}

#QuickView .bp-qv__benefits li {
	display: flex;
	align-items: flex-start;
	gap: 0.5rem;
	font-size: 0.875rem;
	line-height: 1.6;
	color: rgba(29, 44, 78, 0.78);
}

#QuickView .bp-qv__benefits li svg {
	flex: 0 0 auto;
	margin-top: 0.2rem;
}

#QuickView .bp-qv__description {
	margin: 0;
	font-size: 0.9375rem;
	line-height: 1.5;
	color: rgba(29, 44, 78, 0.72);
}

#QuickView .bp-qv__description p {
	margin: 0 0 0.5rem;
}

#QuickView .bp-qv__options-label {
	margin: 0 0 0.375rem;
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: rgba(29, 44, 78, 0.55);
}

#QuickView .bp-qv__options {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

#QuickView .bp-qv__pill {
	display: inline-flex;
	align-items: center;
	gap: 0.375rem;
	padding: 0.5rem 0.875rem;
	border: 1px solid rgba(29, 44, 78, 0.22);
	border-radius: 999px;
	background: transparent;
	color: #111c35;
	font-size: 0.8125rem;
	font-weight: 500;
	line-height: 1.2;
	cursor: pointer;
}

#QuickView .bp-qv__pill .bp-qv__pill-price {
	font-weight: 600;
	color: rgba(29, 44, 78, 0.7);
}

#QuickView .bp-qv__pill:hover {
	border-color: rgba(29, 44, 78, 0.5);
}

#QuickView .bp-qv__pill.is-selected {
	border-color: #111c35;
	background: #111c35;
	color: #f6f4ec;
}

#QuickView .bp-qv__pill.is-selected .bp-qv__pill-price {
	color: #f6f4ec;
}

#QuickView .bp-qv__buy {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.75rem;
	margin-top: 0.25rem;
}

#QuickView .bp-qv__qty {
	display: inline-flex;
	align-items: center;
	border: 1px solid rgba(29, 44, 78, 0.25);
	border-radius: 999px;
}

#QuickView .bp-qv__qty button {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 46px;
	padding: 0;
	border: 0;
	background: transparent;
	color: #111c35;
	font-size: 1rem;
	cursor: pointer;
}

#QuickView .bp-qv__qty button:hover {
	background: rgba(29, 44, 78, 0.07);
}

#QuickView .bp-qv__qty span {
	min-width: 32px;
	text-align: center;
	font-size: 0.9375rem;
	font-weight: 600;
	color: #111c35;
}

#QuickView .bp-qv__add {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	flex: 1 1 180px;
	height: 46px;
	padding: 0 1.5rem;
	border: 0;
	border-radius: 999px;
	background: #111c35;
	color: #f6f4ec;
	font-family: "DM Sans", sans-serif;
	font-size: 0.9375rem;
	font-weight: 600;
	cursor: pointer;
	transition: background-color 0.2s ease;
}

#QuickView .bp-qv__add:hover {
	background: #17233f;
}

#QuickView .bp-qv__add .product-card-button__price {
	font-size: 0.875rem;
	font-weight: 500;
	opacity: 0.85;
}

#QuickView .bp-qv__link {
	align-self: flex-start;
	font-size: 0.8125rem;
	color: rgba(29, 44, 78, 0.62);
	text-decoration: underline;
}

#QuickView .bp-qv__link:hover {
	color: #111c35;
}

/* Desktop split layout */
@media (min-width: 1024px) {
	#QuickView .bp-qv {
		flex-wrap: nowrap;
		padding: 2rem;
	}

	#QuickView .bp-qv__media {
		width: 45%;
		flex: 0 0 45%;
		padding-right: 1.75rem;
	}

	#QuickView .bp-qv__content {
		width: 55%;
		flex: 1 1 auto;
		margin-top: 0;
		padding-right: 0.5rem;
	}

	#QuickView .bp-qv__title {
		font-size: 2rem;
		padding-right: 2rem;
	}
}

/* Mobile bottom sheet */
@media (max-width: 767px) {
	#QuickView {
		padding: 0;
		align-items: flex-end;
	}

	.quick_view .x-quickview-modal {
		width: 100%;
		max-width: 100%;
		max-height: 92vh;
		border-radius: 1.25rem 1.25rem 0 0;
	}

	#QuickView .bp-qv {
		padding: 1.25rem;
	}

	#QuickView .bp-qv__add {
		flex: 1 1 100%;
	}
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
	#rebuy-cart .rebuy-cart__flyout,
	#rebuy-cart .rebuy-cart__background,
	#bp-cart-toast {
		transition: none !important;
	}
}

/* ==========================================================================
   7. Quick view trigger on product cards
   --------------------------------------------------------------------------
   The homepage section stylesheets hide the theme's hover overlay
   (`.button-quickview-icon`) with `display:none !important` because the
   original site drives it with Alpine, which the clone does not have. Bring
   it back as a small circular magnifier button in the top-right corner of the
   product image on hover/focus. Rest state (and therefore the reference
   screenshot) is untouched.
   ========================================================================== */
@media (min-width: 1024px) {
	.card-product:hover .button-quickview-icon,
	.card-product:focus-within .button-quickview-icon,
	.homepage__shop-by-benefit--custom .card-product:hover .button-quickview-icon,
	.homepage__best-sellers--custom .card-product:hover .button-quickview-icon,
	.homepage__stacks--custom .card-product:hover .button-quickview-icon {
		display: flex !important;
		align-items: center;
		justify-content: center;
		position: absolute !important;
		top: 0.75rem;
		right: 0.75rem;
		left: auto !important;
		bottom: auto !important;
		width: auto !important;
		transform: none !important;
		z-index: 20;
	}

	/* Only the desktop trigger is used. */
	.card-product .button-quickview-icon .button--quickview:not(:first-child) {
		display: none !important;
	}

	.card-product .button-quickview-icon .button--quickview {
		position: relative;
		display: inline-flex !important;
		align-items: center;
		justify-content: center;
		width: 2.5rem;
		height: 2.5rem;
		padding: 0 !important;
		border: 0;
		border-radius: 999px;
		background: rgba(17, 28, 53, 0.92);
		color: transparent;
		font-size: 0 !important;
		line-height: 0;
		box-shadow: 0 6px 18px rgba(17, 28, 53, 0.22);
		transition: background-color 0.15s ease, transform 0.15s ease;
	}

	/* Hide the "Add to Cart" label; the magnifier glyph carries the meaning
	   (the button keeps its accessible name from the markup/JS). */
	.card-product .button-quickview-icon .button--quickview > span {
		display: none !important;
	}

	/* Magnifier glyph: inline SVG background (immune to the theme's shared
	   .button::before/::after shine layers, which used to eat the circle). */
	.card-product .button-quickview-icon .button--quickview::before,
	.card-product .button-quickview-icon .button--quickview::after {
		content: none !important;
		display: none !important;
	}

	.card-product .button-quickview-icon .button--quickview {
		background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%23f6f4ec' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='8.7' cy='8.7' r='5.3'/%3E%3Cpath d='M12.7 12.7 16.8 16.8'/%3E%3C/svg%3E");
		background-repeat: no-repeat;
		background-position: center;
		background-size: 17px 17px;
	}

	.card-product .button-quickview-icon .button--quickview:hover {
		background: #1d2c4e;
		transform: translateY(-1px);
	}
}
