/**
 * Woo Essential — Quick Checkout overlay.
 *
 * Scoped under .dnwooe-qc throughout. The panel deliberately keeps the
 * `woocommerce` class because WooCommerce and most themes scope their checkout
 * rules under it, so the form inherits the store's own look rather than needing
 * it rebuilt here.
 */

.dnwooe-qc {
	--dnwooe-qc-width: 100%;
	--dnwooe-qc-bg: #fff;
	--dnwooe-qc-fg: #1a2333;
	--dnwooe-qc-line: #e3e7ee;
	--dnwooe-qc-scrim: rgba(16, 20, 28, 0.55);
	--dnwooe-qc-radius: 10px;
	--dnwooe-qc-padding: 0px;
	--dnwooe-qc-duration: 240ms;

	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	color: var(--dnwooe-qc-fg);
	font-size: 15px;
	line-height: 1.55;
}

.dnwooe-qc[hidden] {
	display: none;
}

.dnwooe-qc__backdrop {
	position: absolute;
	inset: 0;
	background: var(--dnwooe-qc-scrim);
	opacity: 0;
	transition: opacity var(--dnwooe-qc-duration) ease;
}

.dnwooe-qc.is-open .dnwooe-qc__backdrop {
	opacity: 1;
}

.dnwooe-qc__panel {
	position: relative;
	display: flex;
	flex-direction: column;
	background: var(--dnwooe-qc-bg);
	max-height: 100%;
	width: 100%;
	max-width: var(--dnwooe-qc-width);
	padding: var(--dnwooe-qc-padding);
	box-sizing: border-box;
	box-shadow: 0 24px 60px rgba(16, 20, 28, 0.28);
	transition: transform var(--dnwooe-qc-duration) cubic-bezier(0.32, 0.72, 0, 1),
		opacity var(--dnwooe-qc-duration) ease;
	outline: none;
}

/* Slide-over ------------------------------------------------------------- */

.dnwooe-qc[data-layout="slide-over"] {
	justify-content: flex-end;
}

.dnwooe-qc[data-layout="slide-over"][data-position="left"] {
	justify-content: flex-start;
}

.dnwooe-qc[data-layout="slide-over"] .dnwooe-qc__panel {
	height: 100%;
	max-height: 100%;
	transform: translateX(100%);
}

.dnwooe-qc[data-layout="slide-over"][data-position="left"] .dnwooe-qc__panel {
	transform: translateX(-100%);
}

.dnwooe-qc[data-layout="slide-over"].is-open .dnwooe-qc__panel {
	transform: translateX(0);
}

/* Modal ------------------------------------------------------------------ */

.dnwooe-qc[data-layout="modal"] {
	align-items: center;
	justify-content: center;
	padding: 24px;
}

.dnwooe-qc[data-layout="modal"] .dnwooe-qc__panel {
	max-height: calc(100% - 48px);
	border-radius: var(--dnwooe-qc-radius);
	opacity: 0;
	transform: translateY(12px) scale(0.98);
}

.dnwooe-qc[data-layout="modal"].is-open .dnwooe-qc__panel {
	opacity: 1;
	transform: translateY(0) scale(1);
}

/* Chrome ----------------------------------------------------------------- */

.dnwooe-qc__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 16px 20px;
	border-bottom: 1px solid var(--dnwooe-qc-line);
	flex: 0 0 auto;
}

.dnwooe-qc__title {
	margin: 0;
	padding: 0;
	font-size: 17px;
	line-height: 1.3;
	font-weight: 600;
	color: inherit;
}

.dnwooe-qc__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	/* 44px keeps the tap target above the mobile accessibility floor. */
	width: 44px;
	height: 44px;
	margin: -10px -10px -10px 0;
	padding: 0;
	border: 0;
	border-radius: 6px;
	background: none;
	color: inherit;
	cursor: pointer;
	line-height: 0;
	box-shadow: none;
}

.dnwooe-qc__close:hover {
	background: rgba(16, 20, 28, 0.06);
}

.dnwooe-qc__close:focus-visible,
.dnwooe-qc__panel :focus-visible {
	outline: 2px solid #4338ca;
	outline-offset: 2px;
}

.dnwooe-qc__status {
	padding: 0 20px;
	font-size: 13px;
	color: #5a6478;
}

.dnwooe-qc__status:empty {
	display: none;
}

.dnwooe-qc__body {
	flex: 1 1 auto;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	padding: 20px;
}

/* Skeleton --------------------------------------------------------------- */

.dnwooe-qc__skeleton {
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.dnwooe-qc__skel-row {
	height: 44px;
	border-radius: 6px;
	background: linear-gradient(90deg, #eef1f5 25%, #f7f8fb 37%, #eef1f5 63%);
	background-size: 400% 100%;
	animation: dnwooe-qc-shimmer 1.4s ease infinite;
}

.dnwooe-qc__skel-row:nth-child(3) {
	width: 60%;
}

.dnwooe-qc__skel-row:last-child {
	height: 52px;
	margin-top: 8px;
}

@keyframes dnwooe-qc-shimmer {
	0% {
		background-position: 100% 50%;
	}
	100% {
		background-position: 0 50%;
	}
}

/* Checkout content ------------------------------------------------------- */

.dnwooe-qc__body > .woocommerce-notices-wrapper:empty {
	display: none;
}

.dnwooe-qc__body form.checkout {
	margin: 0;
}

.dnwooe-qc__body .col2-set,
.dnwooe-qc__body .col2-set .col-1,
.dnwooe-qc__body .col2-set .col-2 {
	/* The panel is a single narrow column; WooCommerce's two-up billing/shipping
	   split would otherwise squeeze both into unusable widths. */
	width: 100%;
	float: none;
	margin: 0;
	padding: 0;
}

.dnwooe-qc__body #order_review_heading {
	margin-top: 28px;
}

.dnwooe-qc__body img {
	max-width: 100%;
	height: auto;
}

/* Wide content must scroll inside itself rather than widening the panel. */
.dnwooe-qc__body table.shop_table {
	display: block;
	overflow-x: auto;
	max-width: 100%;
}

/* Page lock -------------------------------------------------------------- */

html.dnwooe-qc-locked,
html.dnwooe-qc-locked body {
	overflow: hidden;
}

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

@media (max-width: 782px) {
	.dnwooe-qc[data-layout="modal"] {
		padding: 0;
		align-items: flex-end;
	}

	.dnwooe-qc[data-mobile="sheet"] .dnwooe-qc__panel {
		max-width: 100%;
		width: 100%;
		height: auto;
		max-height: 92dvh;
		border-radius: var(--dnwooe-qc-radius) var(--dnwooe-qc-radius) 0 0;
		transform: translateY(100%);
	}

	.dnwooe-qc[data-mobile="sheet"] {
		align-items: flex-end;
		justify-content: center;
	}

	.dnwooe-qc[data-mobile="sheet"].is-open .dnwooe-qc__panel {
		transform: translateY(0);
		opacity: 1;
	}

	.dnwooe-qc[data-mobile="fullscreen"] .dnwooe-qc__panel {
		max-width: 100%;
		width: 100%;
		height: 100%;
		max-height: 100%;
		border-radius: 0;
	}

	.dnwooe-qc__body {
		padding: 16px;
	}

	/* Keep Place Order reachable in the thumb zone without hunting for it. */
	.dnwooe-qc__body .woocommerce-checkout-payment .form-row.place-order {
		position: sticky;
		bottom: 0;
		margin: 0 -16px -16px;
		padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
		background: var(--dnwooe-qc-bg);
		border-top: 1px solid var(--dnwooe-qc-line);
	}

	.dnwooe-qc__body #place_order {
		width: 100%;
		min-height: 48px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.dnwooe-qc,
	.dnwooe-qc * {
		transition-duration: 1ms !important;
		animation-duration: 1ms !important;
		animation-iteration-count: 1 !important;
	}
}

/* ------------------------------------------------------------------ *
 * Global Buy Now button (GlobalButtons.php). Styling is inherited from
 * the theme's .button class; only placement lives here.
 * ------------------------------------------------------------------ */

form.cart .dnwooe-qc-buy-now--single {
	margin-left: 8px;
}

/* Lay the quantity, native submit, and Buy Now button out on one row.
 * Scoped via :has() to forms that actually contain our button so other
 * cart forms keep their theme layout; non-:has() browsers fall back to
 * the margin-left above. Simple/grouped/external products render the
 * button as a direct child of form.cart; variable products render it
 * inside .woocommerce-variation-add-to-cart. */
form.cart:has(> .dnwooe-qc-buy-now--single),
form.cart .woocommerce-variation-add-to-cart:has(> .dnwooe-qc-buy-now--single) {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
}

form.cart:has(.dnwooe-qc-buy-now--single) .dnwooe-qc-buy-now--single {
	margin-left: 0;
}

/* Full-width children (variations/grouped tables) keep their own row. */
form.cart:has(> .dnwooe-qc-buy-now--single) > table {
	flex: 0 0 100%;
}

/* Shown under a Buy Now button clicked before a variation was chosen. Takes
 * its own row inside the flex cart form above. */
.dnwooe-qc-variation-notice {
	flex: 0 0 100%;
	margin-top: 8px;
	color: #b32d2e;
	font-size: 0.9em;
	line-height: 1.4;
}

.dnwooe-qc-variation-notice:empty {
	display: none;
}

.dnwooe-qc-buy-now--archive {
	display: inline-block;
	margin-top: 0.5em;
}

/* Replace mode (single product): hide the native submit only in a form
 * that actually contains our replacement, so ineligible products (where
 * nothing is rendered) keep their button. Browsers without :has()
 * degrade to showing both buttons — never to a form with none. */
form.cart:has(.dnwooe-qc-buy-now--replace) .single_add_to_cart_button {
	display: none !important;
}

@media (prefers-color-scheme: dark) {
	.dnwooe-qc {
		--dnwooe-qc-bg: #161a22;
		--dnwooe-qc-fg: #e8ecf3;
		--dnwooe-qc-line: #2c3340;
		--dnwooe-qc-scrim: rgba(0, 0, 0, 0.66);
	}

	.dnwooe-qc__skel-row {
		background: linear-gradient(90deg, #232936 25%, #2b3240 37%, #232936 63%);
		background-size: 400% 100%;
	}

	.dnwooe-qc__close:hover {
		background: rgba(255, 255, 255, 0.08);
	}
}
