/**
 * MeatMaster Quick View — styles
 * --------------------------------------------------------------------------
 * Uses the theme's existing custom properties (--base, --contrast, --accent)
 * so the modal inherits the live site's palette. Falls back to neutral values
 * if those vars aren't defined on a given page.
 *
 * Loaded via wp_enqueue_style('mm-quickview', ...).
 */

/* ---- Trigger button: over-image hover overlay ----------------------- */
/* Give the product card a positioning context so the button can overlay
   the thumbnail. Standard WooCommerce archive cards are li.product. */
.woocommerce ul.products li.product,
.woocommerce-page ul.products li.product,
.related-product,
.related-product .product-image {
	position: relative;
}

.mm-quickview-trigger {
	position: absolute;
	/* Sit over the thumbnail. The thumbnail is the first child region of the
	   card, so anchoring to the top of the card lands it on the image. */
	top: 12px;
	inset-inline-start: 12px;
	z-index: 3;

	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin: 0;
	padding: 7px 13px;
	font-size: 13px;
	font-weight: 500;
	line-height: 1;
	color: var(--contrast, #1a1a1a);
	background: var(--base, #fff);
	border: 1px solid #ccc;
	border-radius: 0;
	cursor: pointer;

	/* Hidden until card hover/focus. */
	opacity: 0;
	transform: translateY(-4px);
	pointer-events: none;
	transition: opacity .2s ease, transform .2s ease,
	            background .2s ease, color .2s ease, border-color .2s ease;
}

/* Reveal when the card is hovered or anything inside it is focused. */
.woocommerce ul.products li.product:hover .mm-quickview-trigger,
.woocommerce ul.products li.product:focus-within .mm-quickview-trigger,
.woocommerce-page ul.products li.product:hover .mm-quickview-trigger,
.woocommerce-page ul.products li.product:focus-within .mm-quickview-trigger,
.related-product:hover .mm-quickview-trigger,
.related-product:focus-within .mm-quickview-trigger {
	opacity: 1;
	transform: translateY(0);
	pointer-events: auto;
}

.mm-quickview-trigger:hover,
.mm-quickview-trigger:focus-visible {
	color: var(--base, #fff);
	background: var(--accent, #8a1f1f);
	border-color: var(--accent, #8a1f1f);
}

.mm-quickview-trigger:focus-visible {
	outline: 2px solid var(--accent, #8a1f1f);
	outline-offset: 2px;
	/* Always show when keyboard-focused, even if the parent hover rule
	   hasn't fired. */
	opacity: 1;
	transform: translateY(0);
	pointer-events: auto;
}

.mm-quickview-trigger .mm-qv-shape {
	flex: 0 0 auto;
	display: inline-flex;
	line-height: 0;
}

/* Touch devices can't hover, so a hover-only overlay would be unreachable.
   Keep the button visible on coarse pointers. */
@media (hover: none), (pointer: coarse) {
	.mm-quickview-trigger {
		opacity: 1;
		transform: none;
		pointer-events: auto;
	}
}

/* ---- Modal shell ---------------------------------------------------- */
.mm-qv-modal {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

.mm-qv-overlay {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, .55);
	cursor: pointer;
}

.mm-qv-box {
	position: relative;
	z-index: 1;
	width: 100%;
	max-width: 880px;
	max-height: 90vh;
	overflow-y: auto;
	background: var(--base, #fff);
	color: var(--contrast, #1a1a1a);
	box-shadow: 0 12px 40px rgba(0, 0, 0, .3);
	-webkit-overflow-scrolling: touch;
}

.mm-qv-close {
	position: absolute;
	top: 10px;
	inset-inline-end: 12px;
	z-index: 2;
	width: 36px;
	height: 36px;
	font-size: 26px;
	line-height: 1;
	color: var(--contrast, #1a1a1a);
	background: transparent;
	border: 0;
	cursor: pointer;
}

.mm-qv-close:focus-visible {
	outline: 2px solid var(--accent, #8a1f1f);
	outline-offset: 2px;
}

/* ---- Status / loading ---------------------------------------------- */
.mm-qv-status {
	padding: 60px 24px;
	text-align: center;
	font-size: 15px;
	color: var(--contrast, #1a1a1a);
}

.mm-qv-status.is-error {
	color: var(--accent, #8a1f1f);
}

/* ---- Content layout ------------------------------------------------- */
.mm-qv-inner {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 28px;
	padding: 28px;
}

.mm-qv-media .mm-qv-image,
.mm-qv-media img {
	width: 100%;
	height: auto;
	display: block;
}

.mm-qv-title {
	margin: 0 0 10px;
	font-size: 24px;
	line-height: 1.2;
}

.mm-qv-price {
	margin-bottom: 14px;
	font-size: 18px;
	font-weight: 600;
}

.mm-qv-price del {
	opacity: .6;
	font-weight: 400;
	margin-inline-end: 6px;
}

.mm-qv-excerpt {
	margin-bottom: 18px;
	font-size: 14px;
	line-height: 1.6;
}

/* Let the WooCommerce form + Acowebs fields inherit theme spacing.
   Only minimal layout help here so we don't fight existing styles. */
.mm-qv-form .quantity {
	margin-inline-end: 10px;
}

.mm-qv-form .single_add_to_cart_button.loading {
	opacity: .6;
	pointer-events: none;
}

.mm-qv-fulllink {
	display: inline-block;
	margin-top: 16px;
	font-size: 13px;
	text-decoration: underline;
	color: var(--contrast, #1a1a1a);
}

/* ---- In-modal add-to-cart feedback --------------------------------- */
.mm-qv-feedback {
	margin-top: 12px;
	font-size: 14px;
}

.mm-qv-feedback.is-success {
	color: #1a7f37;
}

.mm-qv-feedback.is-error {
	color: var(--accent, #8a1f1f);
}

/* ---- Responsive ---------------------------------------------------- */
@media (max-width: 700px) {
	.mm-qv-inner {
		grid-template-columns: 1fr;
		gap: 18px;
		padding: 20px;
	}

	.mm-qv-box {
		max-height: 94vh;
	}
}

/* ---- Buy Now button (shared: archives + related) ------------------- */
.mm-buy-now {
	cursor: pointer;
}

.mm-buy-now.loading {
	opacity: .6;
	pointer-events: none;
}

.mm-buy-now.is-added {
	background: #1a7f37;
	border-color: #1a7f37;
	color: #fff;
}

.mm-buy-now[disabled] {
	opacity: .5;
	cursor: not-allowed;
}

/* ---- Reduced motion ------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
	.mm-quickview-trigger {
		transition: opacity .01ms, color .01ms, background .01ms, border-color .01ms;
		transform: none;
	}
	.woocommerce ul.products li.product:hover .mm-quickview-trigger,
	.woocommerce ul.products li.product:focus-within .mm-quickview-trigger,
	.related-product:hover .mm-quickview-trigger,
	.related-product:focus-within .mm-quickview-trigger {
		transform: none;
	}
}