/**
 * ProfHairClub Cart Motion — styles.
 *
 * Depends on the ProfHairClub shop theme's design tokens (--phc-*, defined
 * in style.css) and reuses its .phc-qty-stepper / .phc-qty-stepper__btn
 * pill styling (assets/css/woocommerce.css) for the +/- buttons — this
 * plugin only adds what's specific to the morphed add-to-cart control,
 * the toast stack and the sticky bar.
 *
 * @package ProfHairClub_Cart_Motion
 */

/* ------------------------------------------------------------------ */
/* Morphed stepper — the qty readout between the +/- buttons.         */
/* ------------------------------------------------------------------ */

.phc-atc-stepper__qty {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 32px;
	padding: 0 0.4em;
	font-size: 0.9rem;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

/* On the catalog card the stepper sits on a dark corner chip, matching
   the idle link it replaced (--phc-black background, see style.css) —
   its own buttons/qty need to read on dark instead of the light default
   the same markup gets on the cart/checkout pages. */
.phc-atc-stepper--grid {
	border-color: transparent;
}

.phc-atc-stepper--grid .phc-qty-stepper__btn {
	background: transparent;
	color: var(--phc-paper);
}

.phc-atc-stepper--grid .phc-qty-stepper__btn:hover {
	background: rgba(247, 245, 239, 0.15);
}

.phc-atc-stepper--grid .phc-atc-stepper__qty {
	color: var(--phc-paper);
}

/* Product-page variant sits inline where the button used to be. */
.phc-atc-stepper--product {
	background: var(--phc-white);
}

@media (prefers-reduced-motion: no-preference) {
	.phc-atc-stepper {
		animation: phcAtcStepperIn 0.3s var(--phc-ease);
	}
}

@keyframes phcAtcStepperIn {
	from {
		opacity: 0;
		transform: scale(0.9);
	}
	to {
		opacity: 1;
		transform: scale(1);
	}
}

/* Briefly inert right after morphing in (cart-motion.js's morphToStepper()
   adds/removes this class) — real fix for a reported bug, not decoration:
   see the comment there for why. */
.phc-atc-stepper.is-settling {
	pointer-events: none;
}

/* ------------------------------------------------------------------ */
/* Add-to-cart loading state — catalog-grid pill + product-page button. */
/* Previously had NO visual change at all while the request was in      */
/* flight, which is what let an impatient second tap go unnoticed in    */
/* the first place (see the is-settling comment above for the full      */
/* story). Opacity + a disabled cursor rather than a spinner: works      */
/* identically on the grid's dark chip and the product page's light      */
/* button without needing a separate color per context.                 */
/* ------------------------------------------------------------------ */
.phc-product-card__add.is-loading,
form.cart.is-loading .single_add_to_cart_button,
form.cart.is-loading button[name="add-to-cart"] {
	opacity: 0.55;
	pointer-events: none;
	cursor: progress;
}

/* ------------------------------------------------------------------ */
/* Cart page stepper                                                   */
/*                                                                     */
/* Wraps WooCommerce's real `.quantity` input (which has to stay for    */
/* form serialization) rather than replacing it — so the base           */
/* .phc-qty-stepper pill styling in the theme's woocommerce.css already */
/* covers the frame and the input; only the cart-specific bits are      */
/* here.                                                                */
/* ------------------------------------------------------------------ */

.phc-cart-stepper {
	background: var(--phc-white);
}

.phc-cart-stepper .quantity {
	margin: 0;
}

/* Auto-update makes the manual "Обновить корзину" button redundant. Keyed
   off a class that cart-motion.js only adds once the steppers are actually
   in place, so with JS broken or blocked the button stays visible and the
   cart is still updatable by hand. */
.woocommerce-cart-form.phc-cart-auto-update [name="update_cart"] {
	display: none;
}

/* WooCommerce blocks the cart with a translucent overlay while its AJAX
   update runs; without its own stylesheet (dequeued theme-side) that
   overlay has no styling of its own to fade with. */
.woocommerce-cart-form .blockUI.blockOverlay,
.cart_totals .blockUI.blockOverlay {
	position: relative;
	background: var(--phc-paper) !important;
	opacity: 0.55 !important;
}

/* ------------------------------------------------------------------ */
/* Toast notifications                                                 */
/* ------------------------------------------------------------------ */

.phc-toast-stack {
	position: fixed;
	right: clamp(12px, 3vw, 24px);
	bottom: clamp(12px, 3vw, 24px);
	z-index: 200;
	display: flex;
	flex-direction: column-reverse;
	gap: 0.6rem;
	pointer-events: none;
	max-width: min(340px, calc(100vw - 24px));
}

.phc-toast {
	display: flex;
	align-items: center;
	gap: 0.7em;
	background: var(--phc-ink);
	color: var(--phc-paper);
	border-radius: var(--phc-radius-m);
	padding: 0.85em 1.2em;
	font-size: 0.86rem;
	font-weight: 600;
	box-shadow: 0 12px 30px rgba(10, 10, 8, 0.25);
	opacity: 0;
	transform: translateY(12px);
	transition: opacity 0.35s var(--phc-ease), transform 0.35s var(--phc-ease);
}

.phc-toast.is-shown {
	opacity: 1;
	transform: translateY(0);
}

.phc-toast__icon {
	flex-shrink: 0;
	display: inline-flex;
	width: 18px;
	height: 18px;
}

.phc-toast__icon svg {
	width: 100%;
	height: 100%;
}

.phc-toast--success .phc-toast__icon {
	color: #6fcf7a;
}

.phc-toast--error .phc-toast__icon {
	color: #e57373;
}

.phc-toast--info .phc-toast__icon {
	color: var(--phc-yellow);
}

@media (prefers-reduced-motion: reduce) {
	.phc-toast {
		transition-duration: 0.01ms !important;
	}
}

@media (max-width: 480px) {
	.phc-toast-stack {
		left: 12px;
		right: 12px;
		max-width: none;
	}
}

/* ------------------------------------------------------------------ */
/* Sticky add-to-cart bar (single product page)                       */
/* ------------------------------------------------------------------ */

.phc-atc-bar {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 90;
	background: var(--phc-white);
	border-top: 1px solid var(--phc-mist);
	box-shadow: 0 -8px 24px rgba(10, 10, 8, 0.08);
	transform: translateY(100%);
	transition: transform 0.4s var(--phc-ease);
}

.phc-atc-bar.is-visible {
	transform: translateY(0);
}

.phc-atc-bar__inner {
	display: flex;
	align-items: center;
	gap: 1.2rem;
	padding: 0.9rem clamp(20px, 5vw, 64px);
}

.phc-atc-bar__name {
	flex: 1;
	min-width: 0;
	font-weight: 600;
	font-size: 0.9rem;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.phc-atc-bar__price {
	font-family: var(--phc-font-display);
	font-size: 1.1rem;
	flex-shrink: 0;
}

.phc-atc-bar__btn.is-in-cart {
	background: var(--phc-mist);
	color: var(--phc-ink);
}

@media (max-width: 640px) {
	.phc-atc-bar__name {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.phc-atc-bar {
		transition-duration: 0.01ms !important;
	}
}

/* ------------------------------------------------------------------ */
/* "Pick a variant" popup (single product page)                       */
/* ------------------------------------------------------------------ */

.phc-variant-popup {
	position: fixed;
	inset: 0;
	z-index: 300;
	display: flex;
	align-items: flex-end;
	justify-content: center;
	padding: 0;
	background: rgba(10, 10, 8, 0);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.3s var(--phc-ease), background 0.3s var(--phc-ease);
}

.phc-variant-popup.is-open {
	opacity: 1;
	pointer-events: auto;
	background: rgba(10, 10, 8, 0.45);
}

.phc-variant-popup__card {
	width: 100%;
	max-width: 420px;
	max-height: min(72vh, 560px);
	overflow-y: auto;
	background: var(--phc-paper);
	border-radius: var(--phc-radius-m) var(--phc-radius-m) 0 0;
	padding: 1.6rem 1.4rem calc(1.4rem + env(safe-area-inset-bottom, 0px));
	box-shadow: 0 -12px 40px rgba(10, 10, 8, 0.3);
	position: relative;
	transform: translateY(24px);
	transition: transform 0.3s var(--phc-ease);
}

.phc-variant-popup.is-open .phc-variant-popup__card {
	transform: translateY(0);
}

.phc-variant-popup__close {
	position: absolute;
	top: 0.9rem;
	right: 0.9rem;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	border: 1px solid var(--phc-mist);
	background: var(--phc-white);
	color: var(--phc-ink);
	font-size: 1.2rem;
	line-height: 1;
	cursor: pointer;
}

.phc-variant-popup__eyebrow {
	margin: 0 0 0.3rem;
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--phc-stone, var(--phc-graphite));
}

.phc-variant-popup__title {
	margin: 0 0 1.1rem;
	padding-right: 2.4rem;
	font-family: var(--phc-font-display);
	font-size: 1.15rem;
	color: var(--phc-ink);
}

.phc-variant-popup__options {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
}

.phc-variant-popup__option {
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.85em 1.1em;
	background: var(--phc-white);
	border: 1px solid var(--phc-mist);
	border-radius: var(--phc-radius-m);
	font-size: 0.92rem;
	font-weight: 600;
	color: var(--phc-ink);
	cursor: pointer;
	transition: border-color 0.2s var(--phc-ease), background 0.2s var(--phc-ease);
}

.phc-variant-popup__option:hover,
.phc-variant-popup__option:focus-visible {
	border-color: var(--phc-yellow-deep, var(--phc-yellow));
	background: var(--phc-yellow-wash, var(--phc-mist));
}

.phc-variant-popup__option:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.phc-variant-popup__option-price {
	font-weight: 700;
	white-space: nowrap;
}

body.phc-popup-open {
	overflow: hidden;
}

@media (min-width: 641px) {
	.phc-variant-popup {
		align-items: center;
	}

	.phc-variant-popup__card {
		border-radius: var(--phc-radius-m);
		transform: translateY(12px) scale(0.98);
	}

	.phc-variant-popup.is-open .phc-variant-popup__card {
		transform: translateY(0) scale(1);
	}
}

@media (prefers-reduced-motion: reduce) {
	.phc-variant-popup,
	.phc-variant-popup__card {
		transition-duration: 0.01ms !important;
	}
}
