/**
 * Layali Gifts — side-cart gift selector + tiered progress bar.
 *
 * Placement is settings-driven (LyGifts.position): default `.ly-gifts--body`
 * sits below the products inside the scrollable body; `.ly-gifts--footer` sits
 * above the Total in the pinned footer (height-capped so it can't push the
 * checkout button off-screen). Bound to the shared Layali design tokens with
 * hard fallbacks so it matches the drawer even if tokens.css is absent.
 */

.ly-gifts {
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 16px 0 4px;
	margin: 16px 0 0;
	border-top: 1px solid var( --ly-color-border, #e6e6e8 );
	font-family: var( --ly-text-body, 'DM Sans', system-ui, -apple-system, sans-serif );
}

/* Footer placement (above the checkout button): separate from the Total below
   it instead of from the products above. */
.ly-gifts--footer {
	padding: 0 0 14px;
	margin: 0 0 14px;
	border-top: 0;
	border-bottom: 1px solid var( --ly-color-border, #e6e6e8 );
	/* Pinned outside the scrollable body — cap height + scroll so many tiers
	   can't push the Total/checkout button below the fold on short screens. */
	max-height: 46vh;
	overflow-y: auto;
}

.ly-gifts.is-busy {
	opacity: 0.55;
	pointer-events: none;
}

/* Hide the gift's own line in the drawer item list — it lives in the selector. */
.ly-cart__item.ly-gifts-line {
	display: none !important;
}

/* ---- progress bar --------------------------------------------------------- */

.ly-gifts__progress {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.ly-gifts__progress-text {
	font-size: 0.8125rem; /* 13px */
	line-height: 1.35;
	font-weight: 600;
	color: var( --ly-color-text, #53225e );
}

/* Side margin = half the marker width, so the end markers stay inside. */
.ly-gifts__bar {
	position: relative;
	height: 6px;
	margin: 2px 6px;
	border-radius: var( --ly-radius-pill, 999px );
	background: var( --ly-color-surface-alt, #f4f4f5 );
}

.ly-gifts__bar-fill {
	position: absolute;
	top: 0;
	left: 0;
	height: 100%;
	border-radius: var( --ly-radius-pill, 999px );
	background: linear-gradient( 90deg, var( --ly-color-secondary, #ff7477 ), var( --ly-color-primary, #53225e ) );
	transition: width var( --ly-duration-base, 220ms ) var( --ly-ease-standard, ease );
}

.ly-gifts__marker {
	position: absolute;
	top: 50%;
	width: 12px;
	height: 12px;
	margin: -6px 0 0 -6px; /* centre on (left%, 50%) */
	border-radius: 999px;
	background: var( --ly-color-bg, #fff );
	border: 2px solid var( --ly-color-border-strong, #d1d1d4 );
	box-shadow: 0 1px 2px rgba( 83, 34, 94, 0.12 );
	transition: border-color var( --ly-duration-base, 220ms ) ease, background-color var( --ly-duration-base, 220ms ) ease;
}

.ly-gifts__marker.is-unlocked {
	background: var( --ly-color-primary, #53225e );
	border-color: var( --ly-color-primary, #53225e );
}

/* ---- heading -------------------------------------------------------------- */

.ly-gifts__heading {
	font-family: var( --ly-text-heading, 'Bricolage Grotesque', system-ui, sans-serif );
	font-size: 0.9375rem;
	font-weight: 600;
	color: var( --ly-color-primary, #53225e );
}

/* ---- gift cards (compact, 2-up, no internal scroll — wraps) --------------- */

.ly-gifts__grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px;
}

.ly-gifts__card {
	position: relative;
	display: grid;
	grid-template-columns: 40px 1fr;
	gap: 8px;
	align-items: center;
	padding: 7px;
	text-align: left;
	cursor: pointer;
	background: var( --ly-color-surface, #fbf5ef );
	border: 1.5px solid var( --ly-color-border, #e6e6e8 );
	border-radius: var( --ly-radius-md, 8px );
	transition: border-color 150ms ease, box-shadow 150ms ease, transform 120ms ease;
	-webkit-appearance: none;
	appearance: none;
	font-family: inherit;
}

.ly-gifts__card:not( .is-locked ):hover {
	border-color: var( --ly-color-primary, #53225e );
}

.ly-gifts__card:not( .is-locked ):active {
	transform: scale( 0.98 );
}

.ly-gifts__card:focus-visible {
	outline: none;
	border-color: var( --ly-color-primary, #53225e );
	box-shadow: 0 0 0 3px rgba( 83, 34, 94, 0.15 );
}

.ly-gifts__card.is-selected {
	border-color: var( --ly-color-primary, #53225e );
	box-shadow: 0 0 0 1.5px var( --ly-color-primary, #53225e );
}

.ly-gifts__card-media {
	position: relative;
	width: 40px;
	height: 40px;
	border-radius: var( --ly-radius-sm, 4px );
	overflow: hidden;
	background: var( --ly-color-bg, #fff );
	flex: 0 0 auto;
}

.ly-gifts__card-media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.ly-gifts__card-body {
	display: flex;
	flex-direction: column;
	gap: 1px;
	min-width: 0;
}

.ly-gifts__check {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba( 83, 34, 94, 0.82 );
	color: var( --ly-color-text-on-primary, #fff );
	font-size: 0.7rem;
	font-weight: 700;
	opacity: 0;
	transition: opacity 150ms ease;
}

.ly-gifts__card.is-selected .ly-gifts__check {
	opacity: 1;
}

.ly-gifts__card-name {
	font-size: 0.6875rem; /* 11px */
	line-height: 1.2;
	font-weight: 600;
	color: var( --ly-color-text, #53225e );
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.ly-gifts__card-price s {
	font-size: 0.625rem; /* 10px */
	color: var( --ly-color-text-muted, #4a4a52 );
}

.ly-gifts__card-badge {
	font-size: 0.625rem; /* 10px */
	font-weight: 700;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	color: var( --ly-color-secondary-hover, #cc4f52 );
}

/* ---- locked teaser -------------------------------------------------------- */

.ly-gifts__card.is-locked {
	cursor: default;
	background: var( --ly-color-surface-alt, #f4f4f5 );
	border-style: dashed;
}

.ly-gifts__card.is-locked .ly-gifts__card-media img {
	filter: grayscale( 1 );
	opacity: 0.55;
}

.ly-gifts__lock {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 0.8rem;
	background: rgba( 255, 255, 255, 0.35 );
}

.ly-gifts__card.is-locked .ly-gifts__card-name {
	color: var( --ly-color-text-muted, #4a4a52 );
}

.ly-gifts__card-unlock {
	font-size: 0.625rem; /* 10px */
	font-weight: 700;
	color: var( --ly-color-text-muted, #4a4a52 );
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* ---- product-page progress teaser ----------------------------------------- */

.ly-gifts-pp {
	margin: 0 0 14px;
	font-family: var( --ly-text-body, 'DM Sans', system-ui, -apple-system, sans-serif );
}

.ly-gifts-pp .ly-gifts__progress {
	gap: 8px;
}
