/* ==========================================================================
   Add to Cart side drawer — A/B test variant

   Asana: SCM: Add to Cart side-cart drawer (1218116898842108)
   Markup: templates/cart/includes/cart-drawer.template.html
   Notes:  docs/cart-drawer/TASKS.md

   Every rule is gated behind html.kx-cd-on, which js/cart-drawer.js only adds
   for the variant. The file ships to all traffic and paints nothing for the
   control, so the two arms differ by one class.

   Values follow the signed-off mockup:
   https://mockups.keetrax.com/sun-city-motorcycles/add-to-cart-drawer-5bb6f7d6c2
   ========================================================================== */

:root {
	--kx-cd-black: #111;
	--kx-cd-yellow: #ffc400;
	--kx-cd-red: #e52b39;
	--kx-cd-line: #e5e5e5;
	--kx-cd-width: 470px;
}

/* The panel exists in the DOM for the control too (the ajax template is
   mounted sitewide), so keep it fully out of the way until armed. */
.kx-cd {
	display: none;
}

html.kx-cd-on .kx-cd {
	display: block;
}

/* Replaces the centred confirmation modal — see suppressNpopup() in
   js/cart-drawer.js, which also empties it for screen readers. */
html.kx-cd-on .npopup {
	display: none !important;
}

html.kx-cd-open,
html.kx-cd-open body {
	overflow: hidden;
}

/* --------------------------------------------------------------------------
   Shell
   -------------------------------------------------------------------------- */

.kx-cd__backdrop {
	position: fixed;
	inset: 0;
	z-index: 2147483000;
	background: rgba(0, 0, 0, 0.62);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.25s ease, visibility 0.25s ease;
}

.kx-cd__panel {
	position: fixed;
	z-index: 2147483100;
	top: 0;
	right: 0;
	display: flex;
	flex-direction: column;
	width: min(var(--kx-cd-width), 100vw);
	height: 100%;
	background: #fff;
	box-shadow: -8px 0 30px rgba(0, 0, 0, 0.28);
	transform: translateX(100%);
	visibility: hidden;
	transition: transform 0.28s ease, visibility 0.28s ease;
}

html.kx-cd-open .kx-cd__backdrop {
	opacity: 1;
	visibility: visible;
}

html.kx-cd-open .kx-cd__panel {
	transform: translateX(0);
	visibility: visible;
}

@media (prefers-reduced-motion: reduce) {
	.kx-cd__backdrop,
	.kx-cd__panel {
		transition: none;
	}
}

.kx-cd__panel:focus {
	outline: none;
}

/* Held during a quantity round trip. Pointer events stay live on the close
   button path via the header, which sits outside the scroll region. */
.kx-cd__panel--busy .kx-cd__scroll {
	opacity: 0.55;
	pointer-events: none;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */

.kx-cd__header {
	display: flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: space-between;
	min-height: 66px;
	padding: 20px 24px;
	background: var(--kx-cd-black);
	color: #fff;
}

.kx-cd__title {
	margin: 0;
	font-size: 25px;
	font-weight: 900;
	line-height: 1;
	text-transform: uppercase;
	color: white;
}

.kx-cd__close {
	padding: 0;
	border: 0;
	background: transparent;
	color: #fff;
	font: 300 34px/1 Arial, Helvetica, sans-serif;
	cursor: pointer;
}

.kx-cd__close:hover,
.kx-cd__close:focus {
	color: var(--kx-cd-yellow);
}

.kx-cd__scroll {
	flex: 1 1 auto;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

/* --------------------------------------------------------------------------
   Free shipping progress

   The bar only appears when the cart can actually reach the threshold. A cart
   holding a bulky line gets the caveat instead — showing a threshold that
   will not be honoured is the exact friction the April Userbrain round found.
   -------------------------------------------------------------------------- */

.kx-cd__ship {
	padding: 17px 24px 19px;
	border-bottom: 1px solid var(--kx-cd-line);
	background: #fafafa;
}

.kx-cd__ship-line {
	display: flex;
	justify-content: space-between;
	gap: 10px;
	margin: 0 0 9px;
	font-size: 13px;
	font-weight: 800;
}

.kx-cd__ship-line--qualified strong {
	color: #147a3d;
}

.kx-cd__ship-line--excluded strong {
	color: var(--kx-cd-red);
}

.kx-cd__ship-bar {
	height: 10px;
	overflow: hidden;
	border-radius: 10px;
	background: #dedede;
}

.kx-cd__ship-fill {
	display: block;
	height: 100%;
	max-width: 100%;
	background: var(--kx-cd-yellow);
	transition: width 0.3s ease;
}

.kx-cd__ship-note {
	margin: 7px 0 0;
	color: #666;
	font-size: 10px;
	line-height: 1.3;
}

/* --------------------------------------------------------------------------
   Line items
   -------------------------------------------------------------------------- */

.kx-cd__items {
	margin: 0;
	padding: 0;
	list-style: none;
}

.kx-cd__item {
	display: grid;
	grid-template-columns: 92px 1fr;
	gap: 15px;
	padding: 22px 24px;
	border-bottom: 1px solid var(--kx-cd-line);
}

.kx-cd__item-image {
	width: 92px;
	height: 92px;
	background: #fff;
	object-fit: contain;
}

.kx-cd__item-main {
	min-width: 0;
}

.kx-cd__item-brand {
	margin: 0 0 4px;
	color: #777;
	font-size: 10px;
	font-weight: 800;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.kx-cd__item-name {
	margin: 0 0 9px;
	font-size: 14px;
	font-weight: 900;
	line-height: 1.3;
	text-transform: uppercase;
}

.kx-cd__item-name a {
	color: inherit;
	text-decoration: none;
}

.kx-cd__item-name a:hover {
	text-decoration: underline;
}

.kx-cd__item-extra {
	margin: 0 0 8px;
	color: #666;
	font-size: 11px;
	line-height: 1.35;
}

.kx-cd__item-meta {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.kx-cd__qty {
	display: inline-grid;
	grid-template-columns: 30px 36px 30px;
	height: 32px;
	border: 1px solid #aaa;
}

.kx-cd__qty-btn,
.kx-cd__qty-value {
	display: grid;
	padding: 0;
	border: 0;
	border-right: 1px solid #aaa;
	background: transparent;
	font-size: 14px;
	place-items: center;
}

.kx-cd__qty-btn {
	cursor: pointer;
}

.kx-cd__qty-btn:hover {
	background: #f2f2f2;
}

.kx-cd__qty > *:last-child {
	border-right: 0;
}

.kx-cd__item-price {
	margin: 0;
	font-size: 17px;
	font-weight: 900;
}

.kx-cd__remove {
	margin-top: 8px;
	padding: 0;
	border: 0;
	background: none;
	color: var(--kx-cd-red);
	font-size: 10px;
	font-weight: 800;
	text-transform: uppercase;
	cursor: pointer;
}

.kx-cd__remove:hover {
	text-decoration: underline;
}

.kx-cd__subtotal {
	display: flex;
	justify-content: space-between;
	padding: 15px 24px;
	border-bottom: 1px solid var(--kx-cd-line);
	font-size: 15px;
	font-weight: 900;
	text-transform: uppercase;
}

.kx-cd__empty {
	margin: 0;
	padding: 40px 24px;
	color: #666;
	font-size: 14px;
	text-align: center;
}

/* --------------------------------------------------------------------------
   Upsells
   -------------------------------------------------------------------------- */

.kx-cd__upsells {
	padding: 20px 24px 25px;
	background: #f5f5f5;
}

.kx-cd__upsell-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-bottom: 13px;
}

.kx-cd__upsell-head h3 {
	margin: 0;
	font-size: 16px;
	font-weight: 900;
	text-transform: uppercase;
}

.kx-cd__upsell-head span {
	color: #777;
	font-size: 11px;
}

.kx-cd__upsell-grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 10px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.kx-cd-upsell {
	display: flex;
	min-width: 0;
	flex-direction: column;
	border: 1px solid #ddd;
	background: #fff;
}

.kx-cd-upsell__image {
	display: block;
	width: 100%;
	aspect-ratio: 1 / 1;
	background: #fff;
	object-fit: contain;
}

.kx-cd-upsell__info {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	padding: 9px;
}

.kx-cd-upsell__name {
	min-height: 42px;
	margin: 0 0 7px;
	overflow: hidden;
	font-size: 10px;
	font-weight: 800;
	line-height: 1.35;
	text-transform: uppercase;
}

.kx-cd-upsell__name a {
	color: inherit;
	text-decoration: none;
}

.kx-cd-upsell__price {
	margin: 0 0 7px;
	font-size: 13px;
	font-weight: 900;
}

/* Pushes the button to the bottom so cards with shorter names still line up. */
.kx-cd-upsell__form {
	margin: auto 0 0;
}

.kx-cd-upsell__btn {
	display: block;
	width: 100%;
	padding: 9px 4px;
	border: 0;
	background: var(--kx-cd-black);
	color: #fff;
	font-size: 9px;
	font-weight: 900;
	text-align: center;
	text-transform: uppercase;
	cursor: pointer;
}

.kx-cd-upsell__btn:hover,
.kx-cd-upsell__btn:focus {
	background: #333;
	color: #fff;
	text-decoration: none;
}

.kx-cd-upsell__btn--link {
	background: #555;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.kx-cd__footer {
	flex: 0 0 auto;
	padding: 14px 24px 18px;
	border-top: 1px solid #d8d8d8;
	background: #fff;
	box-shadow: 0 -5px 16px rgba(0, 0, 0, 0.08);
}

.kx-cd__view-cart {
	display: block;
	margin-bottom: 10px;
	color: #333;
	font-size: 11px;
	font-weight: 800;
	text-align: center;
	text-decoration: underline;
}

.kx-cd__checkout {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 9px;
	width: 100%;
	padding: 16px;
	border: 0;
	background: var(--kx-cd-black);
	color: #fff;
	font-size: 16px;
	font-weight: 900;
	text-transform: uppercase;
}

.kx-cd__checkout:hover,
.kx-cd__checkout:focus {
	background: #000;
	color: #fff;
	text-decoration: none;
}

.kx-cd__checkout-icon {
	width: 16px;
	height: 16px;
	fill: var(--kx-cd-yellow);
}

/* --------------------------------------------------------------------------
   Mobile

   Full-bleed panel and a horizontally scrolling upsell rail, per the mockup's
   required behaviour note.
   -------------------------------------------------------------------------- */

@media (max-width: 600px) {
	.kx-cd__panel {
		width: 100vw;
	}

	.kx-cd__header {
		min-height: 58px;
		padding: 17px 18px;
	}

	.kx-cd__title {
		font-size: 21px;
	}

	.kx-cd__ship {
		padding: 14px 18px;
	}

	.kx-cd__item {
		grid-template-columns: 76px 1fr;
		padding: 16px 18px;
	}

	.kx-cd__item-image {
		width: 76px;
		height: 76px;
	}

	.kx-cd__subtotal {
		padding: 15px 18px;
	}

	.kx-cd__upsells {
		padding: 16px 18px;
	}

	.kx-cd__upsell-grid {
		display: flex;
		overflow-x: auto;
		gap: 9px;
		-webkit-overflow-scrolling: touch;
	}

	.kx-cd-upsell {
		flex: 0 0 128px;
	}

	.kx-cd__footer {
		padding: 11px 18px 14px;
	}

	.kx-cd__checkout {
		padding: 14px;
		font-size: 15px;
	}
}
