/**
 * Ruler Quick Add to Cart — front end.
 *
 * Structural styles only: placement, layering and states. Colours, fonts and
 * buttons come from the theme until the Appearance settings land.
 */

/* ---------- Popup ---------- */

.rqac-popup[hidden] {
	display: none;
}

.rqac-popup {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
}

.rqac-popup-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, .5);
	opacity: 0;
	transition: opacity .2s ease;
}

.rqac-popup,
.rqac-popup *,
.rqac-popup *::before,
.rqac-popup *::after {
	box-sizing: border-box;
}

.rqac-popup-dialog {
	position: relative;
	width: 100%;
	max-width: 480px;
	max-height: calc(100vh - 32px);
	max-height: calc(100dvh - 32px);
	overflow: auto;
	padding: 48px 24px 24px;
	border-radius: 8px;
	background: #fff;
	color: #1e1e1e;
	box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
	opacity: 0;
	transform: translateY(12px);
	transition: opacity .2s ease, transform .2s ease;
	outline: none;
}

.rqac-popup.is-visible .rqac-popup-backdrop,
.rqac-popup.is-visible .rqac-popup-dialog {
	opacity: 1;
	transform: none;
}

html.rqac-popup-open,
html.rqac-popup-open body {
	overflow: hidden;
}

.rqac-popup-close {
	position: absolute;
	top: 8px;
	right: 8px;
	z-index: 1;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
}

.rqac-popup-close:hover,
.rqac-popup-close:focus-visible {
	background: rgba(0, 0, 0, .06);
}

.rqac-popup-loading {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 200px;
}

.rqac-spinner {
	width: 32px;
	height: 32px;
	border: 3px solid rgba(0, 0, 0, .12);
	border-top-color: currentColor;
	border-radius: 50%;
	animation: rqac-spin .8s linear infinite;
}

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

.rqac-popup-error {
	padding: 24px 0;
}

/* ---------- Popup contents ----------
   One compact layout for the popup and the drawer: a small image with title,
   price and description beside it; options and the add-to-cart row run full
   width underneath. The summary steps aside (display: contents) so its parts
   join the product grid. */

.rqac-popup-product {
	display: grid;
	grid-template-columns: 110px minmax(0, 1fr);
	column-gap: 16px;
	row-gap: 0;
	align-items: start;
}

.rqac-popup-summary {
	display: contents;
}

.rqac-popup-media {
	grid-column: 1;
	grid-row: 1 / span 3;
	align-self: start;
}

.rqac-popup-media img {
	display: block;
	width: 100%;
	height: auto;
	object-fit: cover;
	border-radius: 4px;
}

.rqac-popup-title,
.rqac-popup-price,
.rqac-popup-excerpt {
	grid-column: 2;
}

.rqac-popup-title {
	margin: 0 0 4px;
	font-size: 1.15rem;
	line-height: 1.3;
}

.rqac-popup-price {
	margin: 0 0 6px;
}

.rqac-popup-excerpt {
	margin: 0;
	font-size: .875em;
	line-height: 1.45;
}

.rqac-popup-form,
.rqac-popup-details {
	grid-column: 1 / -1;
}

.rqac-popup-form {
	margin-top: 20px;
}

/* ---------- Gallery ----------
   One slide at a time inside the small image box. Arrows sit over the image's
   edges; dots sit underneath it. */

.rqac-gallery {
	position: relative;
}

.rqac-gallery-slides {
	position: relative;
	overflow: hidden;
	border-radius: 4px;
	touch-action: pan-y;
}

/* Two classes deep, so it outranks ".rqac-popup-media img". */
.rqac-gallery-slides .rqac-gallery-slide {
	display: none;
}

.rqac-gallery-slides .rqac-gallery-slide.is-active {
	display: block;
}

.rqac-popup button.rqac-gallery-arrow {
	position: absolute;
	top: 50%;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	margin: -13px 0 0;
	padding: 4px;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .85);
	color: #1e1e1e;
	box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
	cursor: pointer;
}

.rqac-popup button.rqac-gallery-arrow:hover,
.rqac-popup button.rqac-gallery-arrow:focus-visible {
	background: #fff;
}

.rqac-popup button.rqac-gallery-arrow:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 1px;
}

.rqac-gallery-prev {
	left: 4px;
}

.rqac-gallery-next {
	right: 4px;
}

.rqac-gallery-arrow svg {
	display: block;
	width: 100%;
	height: 100%;
}

/* No separate "previous" icon: the "next" one, flipped. */
.rqac-gallery-prev.is-mirrored svg {
	transform: scaleX(-1);
}

.rqac-gallery-dots {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 6px;
	margin-top: 8px;
}

.rqac-popup button.rqac-gallery-dot {
	width: 8px;
	height: 8px;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 1px solid currentColor;
	border-radius: 50%;
	background: transparent;
	opacity: .5;
	cursor: pointer;
}

.rqac-popup button.rqac-gallery-dot.is-active {
	background: currentColor;
	opacity: 1;
}

.rqac-popup button.rqac-gallery-dot:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* Without an image the text takes the full width. */
.rqac-popup-product:not(:has(.rqac-popup-media)) .rqac-popup-title,
.rqac-popup-product:not(:has(.rqac-popup-media)) .rqac-popup-price,
.rqac-popup-product:not(:has(.rqac-popup-media)) .rqac-popup-excerpt {
	grid-column: 1 / -1;
}

.rqac-popup-excerpt > :last-child {
	margin-bottom: 0;
}

.rqac-popup-form form.cart {
	margin: 0 0 16px;
}

/* Quantity beside the add-to-cart button, as on the product page. Anything
   else in the row (other plugins' fields) takes a line of its own. */
.rqac-popup-form .woocommerce-variation-add-to-cart,
.rqac-popup-form form.cart:not(.variations_form):not(.grouped_form) {
	display: flex;
	flex-wrap: wrap;
	align-items: stretch;
	gap: 8px;
}

.rqac-popup-form .woocommerce-variation-add-to-cart > *:not(.quantity):not(.single_add_to_cart_button):not([type="hidden"]),
.rqac-popup-form form.cart:not(.variations_form):not(.grouped_form) > *:not(.quantity):not(.single_add_to_cart_button):not([type="hidden"]) {
	flex: 0 0 100%;
}

.rqac-popup-form .quantity {
	display: flex;
	margin: 0;
}

/* A bordered box as tall as the button beside it. */
.rqac-popup-form .quantity .qty {
	box-sizing: border-box;
	width: 64px;
	height: auto;
	min-height: 48px;
	margin: 0;
	padding: 0 6px 0 14px;
	border: 1px solid #767676;
	border-radius: 4px;
	background: #fff;
	color: #000;
	font-size: 1.1em;
	text-align: center;
	box-shadow: none;
}

.rqac-popup-form .single_add_to_cart_button {
	margin: 0;
}

.rqac-popup-form table.variations {
	width: 100%;
	margin: 0 0 16px;
}

.rqac-popup-form table.variations select {
	max-width: 100%;
}

.rqac-popup-details {
	display: inline-block;
	font-size: .9em;
}

@media (max-width: 640px) {
	/* Phones keep a centred popup, inset from the screen edges. */
	.rqac-popup {
		padding: 16px;
	}

	.rqac-popup-dialog {
		padding: 48px 16px 20px;
	}

	.rqac-popup-product {
		grid-template-columns: 90px minmax(0, 1fr);
	}
}

/* ---------- Swatches and option buttons ----------
   Popup, drawer and product page alike. WooCommerce's dropdowns stay in the
   form, hidden, and are driven by these.
   Colours follow the theme's text colour so they suit light and dark themes. */

table.variations.rqac-variations-hidden {
	display: none;
}

.rqac-options {
	margin: 0 0 16px;
}

.rqac-option-group + .rqac-option-group {
	margin-top: 16px;
}

.rqac-option-label {
	display: flex;
	gap: 6px;
	margin: 0 0 8px;
	font-size: .9em;
	line-height: 1.4;
}

.rqac-option-name {
	font-weight: 600;
}

.rqac-option-name::after {
	content: ":";
}

.rqac-option-current {
	opacity: .7;
}

.rqac-option-list {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.rqac-options button.rqac-option {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 44px;
	min-height: 40px;
	margin: 0;
	padding: 0 12px;
	border: 1px solid rgba(127, 127, 127, .45);
	border-radius: 6px;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: .9em;
	line-height: 1;
	text-transform: none;
	letter-spacing: normal;
	box-shadow: none;
	cursor: pointer;
	transition: border-color .1s ease;
}

.rqac-options button.rqac-option:hover {
	border-color: currentColor;
}

.rqac-options button.rqac-option:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.rqac-options button.rqac-option.is-selected {
	border: 2px solid currentColor;
	padding: 0 11px;
	font-weight: 600;
}

/* Out of stock: struck through. Still clickable when the waiting list is on. */
.rqac-options button.rqac-option.is-oos {
	border-style: dashed;
	opacity: .55;
	text-decoration: line-through;
}

.rqac-options button.rqac-option.is-unavailable {
	opacity: .3;
}

.rqac-options button.rqac-option[aria-disabled="true"] {
	cursor: not-allowed;
}

.rqac-options button.rqac-option[aria-disabled="true"]:hover {
	border-color: rgba(127, 127, 127, .45);
}

/* Colour swatches: a round chip, ringed when chosen. */
.rqac-options button.rqac-option--swatch,
.rqac-options button.rqac-option--swatch.is-selected {
	min-width: 0;
	width: 36px;
	height: 36px;
	min-height: 0;
	padding: 3px;
	border: 1px solid transparent;
	border-radius: 50%;
}

.rqac-options button.rqac-option--swatch:hover {
	border-color: rgba(127, 127, 127, .6);
}

.rqac-options button.rqac-option--swatch.is-selected {
	border: 2px solid currentColor;
	padding: 2px;
}

.rqac-swatch {
	display: block;
	width: 100%;
	height: 100%;
	border-radius: 50%;
	background-position: center;
	background-size: cover;
	box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15);
}

/* An out-of-stock colour: a diagonal line across the chip. */
.rqac-options button.rqac-option--swatch.is-oos {
	border-style: solid;
	text-decoration: none;
}

.rqac-options button.rqac-option--swatch.is-oos::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 4px;
	right: 4px;
	height: 1.5px;
	background: currentColor;
	transform: rotate(-45deg);
}

/* ---------- Drawer ----------
   The same popup, docked to the right edge at full height and sliding in from
   the side, with the same contents. Placed after the popup's small-screen
   rules so it keeps its side placement on phones too. */

.rqac-popup--drawer {
	align-items: stretch;
	justify-content: flex-end;
	padding: 0;
}

.rqac-popup--drawer .rqac-popup-dialog {
	width: 440px;
	max-width: 100%;
	height: 100%;
	max-height: none;
	padding: 56px 24px 24px;
	border-radius: 0;
	transform: translateX(100%);
	opacity: 1;
	transition: transform .25s cubic-bezier(.2, .7, .3, 1);
}

.rqac-popup--drawer.is-visible .rqac-popup-dialog {
	transform: none;
}

.rqac-popup--drawer .rqac-popup-loading {
	min-height: 100%;
}

@media (max-width: 640px) {
	/* Phones keep a side drawer; a strip of the page stays visible beside it. */
	.rqac-popup--drawer {
		padding: 0;
	}

	.rqac-popup--drawer .rqac-popup-dialog {
		width: 85%;
		padding: 56px 16px 16px;
		border-radius: 0;
	}
}

/* ---------- Drawer confirmation ---------- */

.rqac-confirm-heading {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0 0 20px;
	font-size: 1.1rem;
	font-weight: 600;
	outline: none;
}

.rqac-confirm-check {
	flex: 0 0 auto;
	width: 24px;
	height: 24px;
	padding: 3px;
	border-radius: 50%;
	background: #1a7f37;
	color: #fff;
}

.rqac-confirm-item {
	display: grid;
	grid-template-columns: 72px minmax(0, 1fr);
	gap: 14px;
	align-items: start;
	padding: 0 0 16px;
	border-bottom: 1px solid rgba(127, 127, 127, .3);
}

.rqac-confirm-image {
	display: block;
	width: 100%;
	height: auto;
	border-radius: 4px;
}

.rqac-confirm-info p {
	margin: 0 0 4px;
	line-height: 1.4;
}

.rqac-confirm-name {
	font-weight: 600;
}

.rqac-confirm-meta {
	font-size: .875em;
	opacity: .75;
}

.rqac-confirm-total {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	margin: 16px 0 20px;
}

.rqac-confirm-actions {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.rqac-confirm-actions .button {
	display: block;
	width: 100%;
	margin: 0;
	text-align: center;
	box-sizing: border-box;
}

/* "View cart" is the secondary choice: outlined, so "Checkout" leads. */
.rqac-popup .rqac-confirm-actions a.rqac-confirm-cart {
	border: 1px solid currentColor;
	background: transparent;
	color: inherit;
}

.rqac-popup .rqac-confirm-actions a.rqac-confirm-cart:hover {
	background: rgba(127, 127, 127, .08);
}

.rqac-popup button.rqac-confirm-continue {
	margin: 4px auto 0;
	padding: 6px;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	text-decoration: underline;
	cursor: pointer;
}

/* ---------- Buttons ---------- */

.single_add_to_cart_button.loading,
.rqac-quick-add.loading {
	opacity: .6;
	pointer-events: none;
}

/* ---------- Errors ---------- */

.rqac-form-errors {
	margin: 0 0 16px;
}

/* ---------- Product cards ----------
   The image layer is laid over the card image by the script; only what sits
   inside it takes clicks. */

.rqac-image-layer {
	position: absolute;
	z-index: 3;
	pointer-events: none;
}

.rqac-image-layer > * {
	pointer-events: auto;
}

/* Over the image, on hover: a full-width bar along the image's bottom. */
.rqac-image-layer .rqac-quick-add--overlay {
	position: absolute;
	/* Themes give block buttons their own offsets; only the bottom edge anchors it. */
	top: auto !important;
	left: 8px;
	right: 8px;
	bottom: 8px;
	width: auto;
	height: auto;
	margin: 0 !important;
	text-align: center;
	box-sizing: border-box;
	transition: opacity .15s ease, transform .15s ease;
}

@media (hover: hover) {
	.rqac-image-layer .rqac-quick-add--overlay {
		opacity: 0;
		transform: translateY(6px);
	}

	.rqac-card-host:hover .rqac-image-layer .rqac-quick-add--overlay,
	.rqac-image-layer .rqac-quick-add--overlay:focus-visible {
		opacity: 1;
		transform: none;
	}
}

.rqac-image-layer.has-picker .rqac-quick-add--overlay,
.rqac-image-layer.has-picker .rqac-quick-add--icon {
	visibility: hidden;
}

/* Round icon on the image's bottom-right corner. */
a.rqac-quick-add--icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	padding: 9px;
	border-radius: 50%;
	background: #fff;
	color: #1e1e1e;
	box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
	box-sizing: border-box;
	text-decoration: none;
}

.rqac-image-layer a.rqac-quick-add--icon {
	position: absolute;
	top: auto !important;
	left: auto;
	right: 8px;
	bottom: 8px;
}

a.rqac-quick-add--icon:hover,
a.rqac-quick-add--icon:focus-visible {
	background: #1e1e1e;
	color: #fff;
}

a.rqac-quick-add--icon svg {
	display: block;
	width: 100%;
	height: 100%;
}

/* The size picker, along the bottom of the card image. */
.rqac-picker {
	position: absolute;
	left: 8px;
	right: 8px;
	bottom: 8px;
	max-height: calc(100% - 16px);
	overflow-y: auto;
	box-sizing: border-box;
	padding: 10px;
	border-radius: 8px;
	background: #fff;
	color: #1e1e1e;
	box-shadow: 0 4px 16px rgba(0, 0, 0, .18);
	font-size: 13px;
	line-height: 1.3;
	text-align: left;
	animation: rqac-picker-in .15s ease both;
}

@keyframes rqac-picker-in {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: none; }
}

.rqac-picker-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin: 0 0 8px;
}

.rqac-picker-label {
	font-weight: 600;
}

.rqac-picker button.rqac-picker-close {
	width: 24px;
	height: 24px;
	min-height: 0;
	margin: -4px -4px -4px 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
}

.rqac-picker-colors {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin: 0 0 10px;
}

.rqac-picker button.rqac-picker-color {
	position: relative;
	display: inline-flex;
	width: 30px;
	height: 30px;
	min-height: 0;
	margin: 0;
	padding: 2px;
	border: 1px solid transparent;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	cursor: pointer;
	box-shadow: none;
}

.rqac-picker button.rqac-picker-color:hover {
	border-color: rgba(127, 127, 127, .6);
}

.rqac-picker button.rqac-picker-color.is-selected {
	border: 2px solid currentColor;
	padding: 2px;
}

.rqac-picker button.rqac-picker-color:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.rqac-picker button.rqac-picker-color.is-oos {
	cursor: not-allowed;
}

.rqac-picker button.rqac-picker-color.is-oos::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 3px;
	right: 3px;
	height: 1.5px;
	background: currentColor;
	transform: rotate(-45deg);
}

.rqac-picker-sublabel {
	margin: 0 0 6px;
	font-size: 12px;
	opacity: .7;
}

.rqac-picker-list {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.rqac-picker button.rqac-picker-option {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 36px;
	height: 32px;
	min-height: 0;
	margin: 0;
	padding: 0 8px;
	/* Colours follow the picker's, so its background and text settings carry through. */
	border: 1px solid rgba(127, 127, 127, .5);
	border-radius: 6px;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: 13px;
	cursor: pointer;
	box-shadow: none;
}

.rqac-picker button.rqac-picker-option:hover,
.rqac-picker button.rqac-picker-option:focus-visible {
	border-color: currentColor;
}

.rqac-picker button.rqac-picker-option:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 1px;
}

.rqac-picker button.rqac-picker-option.is-oos {
	border-style: dashed;
	opacity: .5;
	text-decoration: line-through;
	cursor: not-allowed;
}

.rqac-picker button.rqac-picker-option--swatch {
	width: 32px;
	min-width: 0;
	padding: 3px;
	border-radius: 50%;
}

.rqac-picker-error {
	margin: 8px 0 0;
	color: #b32d2e;
}

.rqac-picker-error[hidden] {
	display: none;
}

.rqac-picker button.rqac-picker-option.is-selected {
	border: 2px solid currentColor;
	padding: 0 7px;
	font-weight: 600;
}

.rqac-picker button.rqac-picker-option--swatch.is-selected {
	padding: 2px;
}

/* Quantity and "Add to cart", as in the popup. */
.rqac-picker-buy {
	display: flex;
	align-items: stretch;
	gap: 8px;
	margin-top: 12px;
}

.rqac-picker input.rqac-picker-qty {
	box-sizing: border-box;
	flex: 0 0 56px;
	width: 56px;
	min-height: 40px;
	margin: 0;
	padding: 0 4px 0 10px;
	border: 1px solid #767676;
	border-radius: 4px;
	background: #fff;
	color: #000;
	font-size: 15px;
	text-align: center;
	box-shadow: none;
}

.rqac-picker .button.rqac-picker-add {
	flex: 1 1 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 40px;
	margin: 0;
	padding: 0 12px;
	font-size: 14px;
	line-height: 1.2;
	white-space: nowrap;
}

/* Waiting for a choice: still clickable, so it can say what is missing. */
.rqac-picker .button.rqac-picker-add.is-waiting {
	opacity: .5;
}

.rqac-picker .button.rqac-picker-add.loading {
	opacity: .6;
	pointer-events: none;
}

/* ---------- Quantity on product cards ---------- */

.rqac-loop-qty {
	display: flex;
	align-items: stretch;
	justify-content: center;
	gap: 8px;
	flex-wrap: wrap;
}

.rqac-loop-qty .rqac-loop-qty-input {
	width: 4em;
	text-align: center;
}

.rqac-loop-qty .button,
.rqac-loop-qty .added_to_cart {
	margin: 0;
}

/* ---------- Notices ---------- */

.rqac-notices {
	position: fixed;
	right: 16px;
	bottom: 16px;
	z-index: 100001;
	display: flex;
	flex-direction: column;
	gap: 8px;
	width: min(380px, calc(100vw - 32px));
	pointer-events: none;
}

.rqac-notice {
	position: relative;
	padding: 14px 40px 14px 16px;
	border-radius: 8px;
	background: #1e1e1e;
	color: #fff;
	box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
	opacity: 0;
	transform: translateY(8px);
	transition: opacity .25s ease, transform .25s ease;
	pointer-events: auto;
}

.rqac-notice.is-visible {
	opacity: 1;
	transform: none;
}

.rqac-notice-text {
	margin: 0 0 8px;
	font-size: 14px;
	line-height: 1.4;
}

.rqac-notice-actions {
	display: flex;
	gap: 16px;
}

.rqac-notice-link {
	color: inherit;
	font-size: 14px;
	font-weight: 600;
	text-decoration: underline;
}

.rqac-notice-dismiss {
	position: absolute;
	top: 6px;
	right: 6px;
	width: 28px;
	height: 28px;
	padding: 0;
	border: 0;
	background: transparent;
	color: inherit;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	opacity: .7;
}

.rqac-notice-dismiss:hover,
.rqac-notice-dismiss:focus-visible {
	opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
	.rqac-popup-backdrop,
	.rqac-popup-dialog,
	.rqac-notice {
		transition: none;
	}

	.rqac-spinner {
		animation-duration: 2s;
	}
}
