/**
 * JN Add to Cart Button — base defaults.
 *
 * ARCHITECTURE: same "invisible native button behind, fully custom
 * decorative button in front" pattern as JN Add to Cart Icon, and for
 * the same reason — see the widget class docblock. Unlike the Icon
 * widget (a small, fixed-size box), the decorative button here is a
 * NORMAL FLOW element (its own padding/content determines its size,
 * like any real button), and the invisible native layer stretches to
 * match it via position:absolute + inset:0.
 */

.jnw-atcbtn-wrap {
	position: relative;
	display: inline-block;
	max-width: 100%;
}

/* The real, native WooCommerce button/link — stretched invisible over
   whatever size the decorative button naturally is. Broad selector
   (any a/button inside, not just .button) as a defensive measure for
   theme template overrides — same reasoning as the Icon widget. */
.jnw-atcbtn-native,
.jnw-atcbtn-native-variable {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	opacity: 0;
	font-size: 0;
	line-height: 0;
	cursor: pointer;
	text-decoration: none;
	-webkit-tap-highlight-color: transparent;
}

.jnw-atcbtn-native a,
.jnw-atcbtn-native button {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	opacity: 0;
	font-size: 0;
	line-height: 0;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

/* Single Product Page uses WooCommerce's own single-product add-to-cart
   FORM (see the widget class docblock for why) — that form's own
   quantity input needs to be visually hidden entirely (not just the
   button), since this widget doesn't render a quantity stepper itself
   (JN Quantity Selector is a separate, optional widget for that — see
   this file's own JS for how the two sync if both are present). Uses a
   "visually hidden" technique (not display:none) so the field still has
   real layout/focusability for accessibility tools, while taking
   effectively zero visible space. */
.jnw-atcbtn-native-single form.cart {
	position: absolute;
	inset: 0;
	margin: 0;
}

.jnw-atcbtn-native-single .quantity {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.jnw-atcbtn-native-single button[type="submit"] {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	opacity: 0;
	font-size: 0;
	line-height: 0;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.jnw-atcbtn-native-variable[disabled] {
	cursor: not-allowed;
}

/* Purely visual — never the click target. Normal flow, so its own
   content (padding/text/icon) determines the whole wrap's size. */
.jnw-atcbtn-decorative {
	position: relative;
	display: inline-flex;
	pointer-events: none;
	text-decoration: none;
}

/* "Already Added" state — layered exactly over the default decorative
   button and cross-faded via opacity, toggled by the JS adding
   .jnw-atcbtn-added to the wrap after a real added_to_cart event for
   this exact button. */
.jnw-atcbtn-decorative-added {
	position: absolute;
	inset: 0;
	opacity: 0;
	pointer-events: none;
	transition: opacity .2s ease;
}

.jnw-atcbtn-wrap.jnw-atcbtn-added > .jnw-atcbtn-decorative:not(.jnw-atcbtn-decorative-added) {
	opacity: 0;
}

.jnw-atcbtn-wrap.jnw-atcbtn-added .jnw-atcbtn-decorative-added {
	opacity: 1;
}

.jnw-atcbtn-inner {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	background: #CF753F;
	color: #FFFFFF;
	border-radius: 6px;
	padding: 14px 28px;
	box-sizing: border-box;
	white-space: nowrap;
	transition: background-color .2s ease, color .2s ease, border-color .2s ease, opacity .2s ease;
}

.jnw-atcbtn-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
	flex-shrink: 0;
}

.jnw-atcbtn-icon svg {
	width: 1em;
	height: 1em;
	fill: currentColor;
}

.jnw-atcbtn-text {
	line-height: 1;
}

/* Fallback cases (redirect for variable-in-loop-grid, disabled-fallback
   for Pre-Order/Disabled "Show Disabled") — each is its OWN real,
   clickable (or intentionally non-clickable) element, not layered on
   any native button. */
.jnw-atcbtn-redirect,
.jnw-atcbtn-disabled-fallback {
	display: inline-flex;
	text-decoration: none;
}

.jnw-atcbtn-disabled-fallback {
	cursor: not-allowed;
}

/* Variable product on a Single Product Page, before any variation is
   selected — the decorative button visually reflects the native
   element's own [disabled] state (kept in sync by JS). */
.jnw-atcbtn-wrap:has(.jnw-atcbtn-native-variable[disabled]) .jnw-atcbtn-variable-decorative .jnw-atcbtn-inner,
.jnw-atcbtn-wrap.jnw-atcbtn-is-disabled .jnw-atcbtn-inner {
	cursor: not-allowed;
}

/* Loading state — wc-add-to-cart.js adds .loading to the real native
   button while its AJAX call is in flight. */
.jnw-atcbtn-wrap:has(.jnw-atcbtn-native .loading) .jnw-atcbtn-decorative,
.jnw-atcbtn-wrap:has(.jnw-atcbtn-native-variable.loading) .jnw-atcbtn-decorative {
	opacity: .6;
}

.jnw-atcbtn-wrap:has(.jnw-atcbtn-native .loading) .jnw-atcbtn-inner::after,
.jnw-atcbtn-wrap:has(.jnw-atcbtn-native-variable.loading) .jnw-atcbtn-inner::after {
	content: "";
	display: inline-block;
	width: 14px;
	height: 14px;
	margin-left: 4px;
	border: 2px solid rgba(255,255,255,.4);
	border-top-color: currentColor;
	border-radius: 50%;
	animation: jnw-atcbtn-spin .6s linear infinite;
}

@keyframes jnw-atcbtn-spin {
	to { transform: rotate(360deg); }
}
