/**
 * PhotoCab "added to cart" popup.
 *
 * Restyles Blocksy Companion Pro's #ct-added-to-cart-popup after the
 * prototype "PhotoCab Add To Cart Popup". Markup comes from
 * blocksy-companion-pro/.../features/added-to-cart-popup/ and is fixed:
 *
 *   #ct-added-to-cart-popup.ct-popup            backdrop
 *     .ct-popup-inner
 *       article
 *         .ct-added-to-cart-message             green header
 *           svg.ct-check-icon + text + button.ct-toggle-close
 *         .ct-popup-content
 *           .ct-added-to-cart-product
 *             a.ct-media-container               thumbnail
 *             section
 *               .ct-product-title-price > h2 + .price
 *               ul.ct-product-attributes         variation meta
 *               ul.ct-product-totals             shipping / cart total
 *           .ct-popup-actions                    checkout / cart / continue
 *           [suggested products]
 *
 * The plugin exposes the shell through custom properties (see
 * premium/static/sass/popups.scss), so width, offsets, padding, radius and
 * shadow are set as variables rather than fought with overrides. Everything
 * else is selector work; `body` prefixes the id so these rules outrank the
 * dynamic styles the plugin prints for the same id from the Customizer.
 */

body #ct-added-to-cart-popup {
	--popup-max-width: 440px;
	--popup-edges-offset: 40px;
	--popup-padding: var(--pc-space-5);
	--popup-border-radius: var(--pc-radius-card);
	--popup-box-shadow: var(--pc-shadow-pop);

	/* Thumbnail column; the totals row below reuses both to span the full
	   card width from inside the text column. */
	--pc-atc-thumb: 72px;
	--pc-atc-gap: 14px;

	/* Scrim. The plugin prints the Customizer colour on this same id. */
	background-color: rgba(31, 30, 28, 0.42);
}

body #ct-added-to-cart-popup .ct-popup-inner > article {
	border: 0;
	background: var(--pc-surface);
	color: var(--pc-ink-900);

	/* Clips the green header against the rounded corners. */
	overflow: hidden;
}

/* ---------------------------------------------------------------- Head -- */

body #ct-added-to-cart-popup .ct-added-to-cart-message {
	gap: 10px;
	padding: var(--pc-space-4) var(--pc-space-4) var(--pc-space-4) var(--pc-space-5);
	background: var(--pc-ok-100);
	border-bottom: 1px solid rgba(31, 107, 84, 0.14);
	font-size: var(--pc-fs-body);
	font-weight: var(--pc-fw-medium);
	line-height: var(--pc-lh-card);
	letter-spacing: var(--pc-ls-heading);
	color: var(--pc-ink-900);
}

/*
 * The plugin hard-codes a cart-with-plus glyph in the heading markup and
 * offers no filter for it, so the prototype's tick is drawn as the row's
 * ::before and the stock icon is dropped.
 */
body #ct-added-to-cart-popup .ct-added-to-cart-message .ct-check-icon {
	display: none;
}

body #ct-added-to-cart-popup .ct-added-to-cart-message::before {
	content: "";
	flex: 0 0 24px;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	background-color: var(--pc-ok-600);
	background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><path d='M5 12.5l4.5 4.5L19 7'/></svg>");
	background-repeat: no-repeat;
	background-position: center;
	background-size: 14px;
}

body #ct-added-to-cart-popup .ct-added-to-cart-message .ct-toggle-close {
	flex: 0 0 32px;
	width: 32px;
	height: 32px;
	margin-inline-start: auto;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--pc-ink-600);
	--theme-icon-color: var(--pc-ink-600);
	transition:
		background var(--pc-dur-fast) ease,
		color var(--pc-dur-fast) ease;
}

body #ct-added-to-cart-popup .ct-added-to-cart-message .ct-toggle-close:hover {
	background: rgba(31, 107, 84, 0.12);
	color: var(--pc-ink-900);
	--theme-icon-color: var(--pc-ink-900);
}

/* ---------------------------------------------------------------- Body -- */

body #ct-added-to-cart-popup .ct-popup-content {
	display: flex;
	flex-direction: column;
	gap: var(--pc-space-4);
}

/* The stock separators between the blocks are replaced by the gap above;
   the design only draws one rule, above the cart total. */
body #ct-added-to-cart-popup :is(.ct-added-to-cart-product, .ct-popup-actions):not(:last-child) {
	margin-bottom: 0;
	padding-bottom: 0;
	border-bottom: 0;
}

/* ---- Added product ---- */

/*
 * Thumbnail and text sit side by side, but the totals row spans the whole
 * card. `display: contents` on the <section> lifts its children into this
 * grid so the summary lands on a row of its own, below the thumbnail,
 * instead of being pulled left under it.
 */
body #ct-added-to-cart-popup .ct-added-to-cart-product {
	grid-template-columns: var(--pc-atc-thumb) 1fr;
	column-gap: var(--pc-atc-gap);
	row-gap: 0;
	align-items: start;
}

body #ct-added-to-cart-popup .ct-added-to-cart-product.no-image {
	grid-template-columns: 1fr;
}

body #ct-added-to-cart-popup .ct-added-to-cart-product > .ct-media-container {
	grid-column: 1;
	grid-row: 1;
}

body #ct-added-to-cart-popup .ct-added-to-cart-product > section {
	display: contents;
}

body #ct-added-to-cart-popup .ct-added-to-cart-product > section > * {
	grid-column: 2;
}

body #ct-added-to-cart-popup .ct-added-to-cart-product.no-image > section > * {
	grid-column: 1;
}

/* Full-width summary row; needs to outrank the `> section > *` rule above. */
body #ct-added-to-cart-popup .ct-added-to-cart-product > section > .ct-product-totals {
	grid-column: 1 / -1;
}

body #ct-added-to-cart-popup .ct-added-to-cart-product .ct-media-container {
	width: 100%;
	--ratio: 1/1;
	border: 1px solid var(--pc-border);
	border-radius: var(--pc-radius-ctl);
	background: var(--pc-surface-2);
	overflow: hidden;
}

body #ct-added-to-cart-popup .ct-added-to-cart-product .ct-media-container img {
	width: 100%;
	height: 100%;
	padding: 6px;
	box-sizing: border-box;
	object-fit: contain;
}

body #ct-added-to-cart-popup .ct-product-title-price {
	gap: var(--pc-space-3);
	margin-bottom: 0;
	align-items: flex-start;
}

body #ct-added-to-cart-popup .ct-added-to-cart-product .woocommerce-loop-product__title {
	margin: 0;
	font-size: var(--pc-fs-card);
	font-weight: var(--pc-fw-regular);
	line-height: var(--pc-lh-card);
	color: var(--pc-ink-900);
}

body #ct-added-to-cart-popup .ct-added-to-cart-product .price {
	flex: 0 0 auto;
	font-size: var(--pc-fs-price);
	font-weight: var(--pc-fw-medium);
	line-height: var(--pc-lh-card);
	color: var(--pc-ink-900);
	white-space: nowrap;
	text-align: right;
}

/* Woo prints the old price first; the design stacks the current one on top
   with the struck-out original beneath it. */
body #ct-added-to-cart-popup .ct-added-to-cart-product .sale-price {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 3px;
}

body #ct-added-to-cart-popup .ct-added-to-cart-product .sale-price ins {
	order: 1;
	background: none;
	text-decoration: none;
	font-size: var(--pc-fs-price);
	font-weight: var(--pc-fw-medium);
	color: var(--pc-ink-900);
}

body #ct-added-to-cart-popup .ct-added-to-cart-product .sale-price del {
	order: 2;
	opacity: 1;
	font-size: var(--pc-fs-old);
	font-weight: var(--pc-fw-regular);
	color: var(--pc-ink-400);
	text-decoration: line-through;
}

/* ---- Variation attributes (the "Lilac Purple" meta line) ---- */

body #ct-added-to-cart-popup .ct-product-attributes {
	margin-top: 5px;
	padding-top: 0;
	border-top: 0;
	font-size: var(--pc-fs-old);
	font-weight: var(--pc-fw-regular);
	line-height: var(--pc-lh-card);
	color: var(--pc-ink-400);
}

body #ct-added-to-cart-popup .ct-product-attributes li {
	justify-content: flex-start;
	gap: var(--pc-space-1);
}

body #ct-added-to-cart-popup .ct-product-attributes li:not(:last-child) {
	margin-bottom: 2px;
}

/* ---- Totals ---- */

body #ct-added-to-cart-popup .ct-product-totals {
	display: flex;
	flex-direction: column;
	gap: var(--pc-space-2);
	grid-column: 1 / -1;
	margin-top: var(--pc-space-4);
	padding-top: 0;
	border-top: 0;
	font-size: var(--pc-fs-card);
	font-weight: var(--pc-fw-regular);
}

body #ct-added-to-cart-popup .ct-product-totals li {
	align-items: baseline;
	gap: var(--pc-space-3);
	margin: 0;
	color: var(--pc-ink-600);
}

body #ct-added-to-cart-popup .ct-added-to-cart-popup-total {
	order: 1;
	padding-top: var(--pc-space-3);
	border-top: 1px solid var(--pc-border);
}

body #ct-added-to-cart-popup .ct-added-to-cart-popup-total .amount {
	font-size: 20px;
	font-weight: var(--pc-fw-medium);
	letter-spacing: var(--pc-ls-heading);
	color: var(--pc-ink-900);
	white-space: nowrap;
}

/* Shipping reads as the design's accent notice, below the total. */
body #ct-added-to-cart-popup .ct-added-to-cart-popup-shipping,
body #ct-added-to-cart-popup .ct-added-to-cart-popup-tax {
	order: 2;
	padding: 10px 12px;
	border-radius: var(--pc-radius-ctl);
	background: var(--pc-accent-100);
	font-size: var(--pc-fs-old);
	line-height: var(--pc-lh-card);
	color: var(--pc-accent-700);
}

body #ct-added-to-cart-popup .ct-added-to-cart-popup-shipping .amount,
body #ct-added-to-cart-popup .ct-added-to-cart-popup-tax .amount {
	font-weight: var(--pc-fw-medium);
	color: var(--pc-accent-700);
	white-space: nowrap;
}

/* ------------------------------------------------------------- Actions -- */

body #ct-added-to-cart-popup .ct-popup-actions {
	flex-direction: column;
	flex-wrap: nowrap;
	gap: var(--pc-space-3);
}

body #ct-added-to-cart-popup .ct-popup-actions > * {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 48px;
	min-height: 0;
	padding: 0 18px;
	box-sizing: border-box;
	font-family: var(--pc-font);
	font-size: var(--pc-fs-btn);
	font-weight: var(--pc-fw-medium);
	letter-spacing: var(--pc-ls-label);
	border-radius: var(--pc-radius-ctl);
	--theme-button-min-height: 48px;
	transition:
		background var(--pc-dur-fast) ease,
		color var(--pc-dur-fast) ease,
		border-color var(--pc-dur-fast) ease;
}

/* Primary is whichever of the two leads: checkout when the popup shows it,
   otherwise the cart button. */
body #ct-added-to-cart-popup :is(.ct-added-to-cart-popup-checkout, .ct-added-to-cart-popup-cart) {
	border: 1px solid var(--pc-ink-900);
	background: var(--pc-ink-900);
	color: var(--pc-surface);
}

body #ct-added-to-cart-popup :is(.ct-added-to-cart-popup-checkout, .ct-added-to-cart-popup-cart):hover {
	background: var(--pc-ink-700);
	border-color: var(--pc-ink-700);
	color: var(--pc-surface);
}

body #ct-added-to-cart-popup .ct-popup-actions:has(.ct-added-to-cart-popup-checkout) .ct-added-to-cart-popup-cart {
	height: 44px;
	border: 1px solid var(--pc-border);
	background: var(--pc-surface);
	color: var(--pc-ink-900);
}

body #ct-added-to-cart-popup .ct-popup-actions:has(.ct-added-to-cart-popup-checkout) .ct-added-to-cart-popup-cart:hover {
	border-color: var(--pc-ink-900);
	background: var(--pc-surface-2);
	color: var(--pc-ink-900);
}

body #ct-added-to-cart-popup .ct-added-to-cart-popup-continue {
	height: 44px;
	border: 1px solid transparent;
	background: transparent;
	color: var(--pc-ink-600);
}

body #ct-added-to-cart-popup .ct-added-to-cart-popup-continue:hover {
	background: var(--pc-surface-2);
	color: var(--pc-ink-900);
}

/* ------------------------------------------------------------- Tablet -- */

@media (max-width: 999px) {
	body #ct-added-to-cart-popup {
		--popup-max-width: 400px;
		--popup-edges-offset: 24px;
		--popup-padding: 18px;
		--pc-atc-thumb: 68px;
	}
}

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

/*
 * Below 690px the design turns the popup into a bottom sheet: full width,
 * flush with the bottom edge, rounded only at the top.
 */
@media (max-width: 689px) {
	body #ct-added-to-cart-popup {
		--popup-edges-offset: 0px;
		--popup-padding: var(--pc-space-4) 18px 22px;
		--pc-atc-thumb: 64px;
	}

	body #ct-added-to-cart-popup .ct-popup-inner {
		inset-inline: 0;
		max-width: 100%;
	}

	body #ct-added-to-cart-popup .ct-popup-inner > article {
		border-radius: 16px 16px 0 0;
	}

	body #ct-added-to-cart-popup .ct-popup-content {
		gap: 14px;
	}

	body #ct-added-to-cart-popup .ct-added-to-cart-message {
		padding: var(--pc-space-4) 14px 14px 18px;
	}
}
