/**
 * Layali Side Cart — drawer + trigger styles.
 *
 * Bound to --ly-* tokens from the child theme. Falls back to literal values
 * when the theme isn't active so the plugin renders sensibly on its own.
 */

/* =============================================================================
   Cart trigger (header icon)
   --------------------------------------------------------------------------
   Sized to match sibling Elementor Icon widgets:
     - The button is the icon's bounding box (icon + padding only).
     - The count badge is absolutely positioned *inside* that bounding box
       by default, so the trigger's outer dimensions match a 24px Icon with
       8px padding (40x40). Sibling icons in a flex row will vertically
       center identically. Use the widget's "badge top/right offset" controls
       if you need it to peek outside.
   ============================================================================= */

.ly-cart-trigger {
	--ly-cart-anim-duration: 200ms;
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 8px;
	background: transparent;
	border: 0;
	cursor: pointer;
	color: var(--ly-cart-trigger-color, var(--ly-color-primary, #53225e));
	font-family: var(--ly-text-body, 'DM Sans', sans-serif);
	font-size: 0.875rem;
	font-weight: 500;
	line-height: 1;
	transition: color var(--ly-cart-anim-duration, 200ms) ease;
	/* Don't grow with absolutely-positioned badge */
	box-sizing: content-box;
}

.ly-cart-trigger:hover {
	color: var(--ly-cart-trigger-color, var(--ly-color-secondary, #ff7477));
}

.ly-cart-trigger:focus-visible {
	outline: 2px solid var(--ly-color-focus-ring, #ff7477);
	outline-offset: 2px;
	border-radius: 4px;
}

.ly-cart-trigger__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition:
		transform var(--ly-cart-anim-duration, 200ms) cubic-bezier(0.2, 0, 0, 1),
		color var(--ly-cart-anim-duration, 200ms) ease;
	transform-origin: center;
}

.ly-cart-trigger__icon svg,
.ly-cart-trigger__icon i {
	width: 24px;
	height: 24px;
	display: block;
}

.ly-cart-trigger__count {
	position: absolute;
	top: 2px;
	right: 2px;
	min-width: 16px;
	height: 16px;
	padding: 0 4px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: var(--ly-color-primary, #53225e);
	color: var(--ly-color-text-on-primary, #ffffff);
	border-radius: 999px;
	font-size: 10px;
	font-weight: 600;
	line-height: 1;
	pointer-events: none;
	transition: opacity var(--ly-cart-anim-duration, 200ms) ease;
}

.ly-cart-trigger__count--hidden {
	opacity: 0;
	visibility: hidden;
}

.ly-cart-trigger__label {
	color: inherit;
}

/* --- Hover animations (applied to the icon, not the whole button, so the
       badge stays put while the bag moves) --- */

.ly-cart-trigger--anim-lift:hover .ly-cart-trigger__icon {
	transform: translateY(-2px);
}

.ly-cart-trigger--anim-grow:hover .ly-cart-trigger__icon {
	transform: scale(1.08);
}

.ly-cart-trigger--anim-bounce:hover .ly-cart-trigger__icon {
	animation: ly-cart-bounce var(--ly-cart-anim-duration, 200ms) ease;
}

@keyframes ly-cart-bounce {
	0%   { transform: translateY(0); }
	50%  { transform: translateY(-4px); }
	100% { transform: translateY(0); }
}

.ly-cart-trigger--anim-wiggle:hover .ly-cart-trigger__icon {
	animation: ly-cart-wiggle calc(var(--ly-cart-anim-duration, 200ms) * 2) ease;
	transform-origin: top center;
}

@keyframes ly-cart-wiggle {
	0%, 100% { transform: rotate(0); }
	25%      { transform: rotate(8deg); }
	75%      { transform: rotate(-8deg); }
}

@media (prefers-reduced-motion: reduce) {
	.ly-cart-trigger__icon,
	.ly-cart-trigger--anim-bounce:hover .ly-cart-trigger__icon,
	.ly-cart-trigger--anim-wiggle:hover .ly-cart-trigger__icon {
		transition: none;
		animation: none;
		transform: none;
	}
}

/* =============================================================================
   Drawer shell
   ============================================================================= */

.ly-cart {
	position: fixed;
	inset: 0;
	z-index: var(--ly-z-modal, 300);
	pointer-events: none;
	visibility: hidden;
	/* Clip the closed drawer (translateX(100%) parks it past the right
	   edge). Without this the off-stage drawer can extend the page's
	   scrollable area and cause horizontal panning on mobile. */
	overflow: hidden;
}

.ly-cart[aria-hidden="false"] {
	pointer-events: auto;
	visibility: visible;
}

.ly-cart__overlay {
	position: absolute;
	inset: 0;
	background: rgba(26, 26, 31, 0.45);
	opacity: 0;
	transition: opacity var(--ly-duration-base, 200ms) ease;
}

.ly-cart[aria-hidden="false"] .ly-cart__overlay {
	opacity: 1;
}

.ly-cart__drawer {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	width: min(440px, 92vw);
	background: var(--ly-color-bg, #ffffff);
	box-shadow: -12px 0 32px rgba(83, 34, 94, 0.12);
	display: flex;
	flex-direction: column;
	transform: translateX(100%);
	transition: transform var(--ly-duration-slow, 320ms) cubic-bezier(0.2, 0, 0, 1);
	font-family: var(--ly-text-body, 'DM Sans', sans-serif);
	color: var(--ly-color-text, #53225e);
}

.ly-cart[aria-hidden="false"] .ly-cart__drawer {
	transform: translateX(0);
}

.ly-cart[data-ly-cart-busy="1"] .ly-cart__drawer {
	cursor: progress;
}

/* =============================================================================
   Header
   ============================================================================= */

.ly-cart__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 24px 24px 16px;
	border-bottom: 1px solid var(--ly-color-border, #e6e6e8);
}

.ly-cart__title {
	margin: 0;
	display: inline-flex;
	align-items: center;
	gap: 12px;
	font-family: var(--ly-text-heading, var(--ly-font-display, 'Bricolage Grotesque'), sans-serif);
	font-size: 1.5rem;
	font-weight: 700;
	color: var(--ly-color-primary, #53225e);
	letter-spacing: -0.01em;
}

.ly-cart__header-count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 28px;
	height: 28px;
	padding: 0 8px;
	border-radius: 999px;
	background: var(--ly-color-cream, #fbf5ef);
	color: var(--ly-color-primary, #53225e);
	font-family: var(--ly-text-body, 'DM Sans', sans-serif);
	font-size: 0.875rem;
	font-weight: 600;
}

.ly-cart__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	background: transparent;
	border: 0;
	color: var(--ly-color-primary, #53225e);
	cursor: pointer;
	border-radius: 999px;
	transition: background-color var(--ly-duration-base, 200ms) ease;
}

.ly-cart__close:hover {
	background: var(--ly-color-surface, #fbf5ef);
}

.ly-cart__close:focus-visible {
	outline: 2px solid var(--ly-color-focus-ring, #ff7477);
	outline-offset: 2px;
}

/* =============================================================================
   Body (items + empty state)
   ============================================================================= */

.ly-cart__body {
	flex: 1;
	overflow-y: auto;
	padding: 16px 24px;
}

.ly-cart__empty {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 100%;
	min-height: 200px;
	color: var(--ly-color-text-muted, #4a4a52);
	font-size: 1rem;
}

.ly-cart__empty p {
	margin: 0;
}

.ly-cart__items {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 16px;
}

/* --- One cart line item --- */

.ly-cart__item {
	display: grid;
	grid-template-columns: 72px 1fr auto;
	gap: 12px;
	align-items: start;
	padding: 12px;
	background: var(--ly-color-surface, #fbf5ef);
	border-radius: 12px;
	position: relative;
	transition: opacity var(--ly-duration-fast, 120ms) ease;
}

.ly-cart__item[data-ly-cart-busy="1"] {
	opacity: 0.5;
	pointer-events: none;
}

.ly-cart__item-thumb {
	display: block;
	width: 72px;
	height: 72px;
	border-radius: 8px;
	overflow: hidden;
	background: var(--ly-color-bg, #ffffff);
}

.ly-cart__item-thumb img {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.ly-cart__item-info {
	display: flex;
	flex-direction: column;
	gap: 6px;
	min-width: 0;
}

.ly-cart__item-name {
	font-family: var(--ly-text-heading, var(--ly-font-display, 'Bricolage Grotesque'), sans-serif);
	font-size: 0.95rem;
	font-weight: 600;
	color: var(--ly-color-primary, #53225e);
	text-decoration: none;
	line-height: 1.2;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.ly-cart__item-name:hover {
	color: var(--ly-color-secondary, #ff7477);
}

.ly-cart__item-price {
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--ly-color-secondary, #ff7477);
}

.ly-cart__item-qty {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	background: var(--ly-color-bg, #ffffff);
	border-radius: 999px;
	padding: 2px;
	width: fit-content;
	border: 1px solid var(--ly-color-border, #e6e6e8);
}

.ly-cart__qty-btn {
	width: 26px;
	height: 26px;
	border-radius: 999px;
	background: transparent;
	border: 0;
	color: var(--ly-color-primary, #53225e);
	cursor: pointer;
	font-size: 1rem;
	font-weight: 600;
	line-height: 1;
	transition: background-color var(--ly-duration-base, 200ms) ease;
}

.ly-cart__qty-btn:hover {
	background: var(--ly-color-cream, #fbf5ef);
}

.ly-cart__qty-value {
	min-width: 24px;
	text-align: center;
	font-size: 0.875rem;
	font-weight: 500;
}

.ly-cart__item-remove {
	background: transparent;
	border: 0;
	padding: 4px;
	color: var(--ly-color-text-muted, #4a4a52);
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 4px;
	transition: color var(--ly-duration-base, 200ms) ease;
}

.ly-cart__item-remove:hover {
	color: var(--ly-color-secondary, #ff7477);
}

/* =============================================================================
   Footer (total + checkout)
   ============================================================================= */

.ly-cart__footer {
	padding: 16px 24px 24px;
	border-top: 1px solid var(--ly-color-border, #e6e6e8);
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.ly-cart__total {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
}

.ly-cart__total-label {
	font-family: var(--ly-text-heading, var(--ly-font-display, 'Bricolage Grotesque'), sans-serif);
	font-size: 1.25rem;
	font-weight: 600;
	color: var(--ly-color-primary, #53225e);
}

.ly-cart__total-value {
	font-size: 1.25rem;
	font-weight: 700;
	color: var(--ly-color-primary, #53225e);
}

.ly-cart__checkout {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 14px 24px;
	background: var(--ly-color-primary, #53225e);
	color: var(--ly-color-text-on-primary, #ffffff);
	border-radius: 999px;
	font-family: var(--ly-text-heading, var(--ly-font-display, 'Bricolage Grotesque'), sans-serif);
	font-size: 1rem;
	font-weight: 600;
	text-decoration: none;
	letter-spacing: 0.01em;
	transition: background-color var(--ly-duration-base, 200ms) ease, opacity var(--ly-duration-base, 200ms) ease;
}

.ly-cart__checkout:hover {
	background: var(--ly-color-primary-hover, #6b3179);
	color: var(--ly-color-text-on-primary, #ffffff);
}

.ly-cart__checkout[aria-disabled="true"] {
	background: var(--ly-color-border-strong, #d1d1d4);
	pointer-events: none;
	opacity: 0.6;
}

/* =============================================================================
   Motion preferences
   ============================================================================= */

@media (prefers-reduced-motion: reduce) {
	.ly-cart__drawer,
	.ly-cart__overlay {
		transition: none;
	}
}

/* =============================================================================
   Mobile
   ============================================================================= */

@media (max-width: 480px) {
	.ly-cart__drawer {
		width: 100vw;
	}

	.ly-cart__title {
		font-size: 1.25rem;
	}

	.ly-cart__item {
		grid-template-columns: 56px 1fr auto;
	}

	.ly-cart__item-thumb {
		width: 56px;
		height: 56px;
	}
}
