/* Product-card quick add: button states + the "added" toast.
 *
 * Scoped to `.y-card` throughout. WooCommerce's cart links elsewhere on the
 * site — single product, cart, mini-cart, checkout — are deliberately not
 * touched by anything in this file.
 */

/* ---- WooCommerce's injected «عرض السلة» link ----
   wc-add-to-cart.js does `$thisbutton.after( '<a class="added_to_cart …">' )`.
   The button now lives inline in the price row (.y-card__bottom, see
   app.css), so that injected link would otherwise land right beside it in
   the same flex row. Hidden rather than removed in JS so there is never a
   frame where it has taken up space: a grid that reflows on add is the whole
   complaint. */
.y-card .added_to_cart,
.y-card .added_to_cart.wc-forward { display: none !important; }

/* ---- button states ----
   `.loading` and `.added` are WooCommerce's own classes; the markup inside the
   button is the theme's plus icon. Sizing is fixed at the button (44×44, see
   .y-card__addbtn in app.css), so swapping between + / spinner / tick never
   changes the card's geometry. `position: relative` (not absolute — the
   2026-09-07 redesign moved this button out of the floating-over-image
   layout and into the normal flex flow of .y-card__bottom) is only here so
   the spinner/tick overlays below can center on the button itself via
   inset:0, not on the page. */
.y-card__quickadd { position: relative; transition: background-color .15s ease, color .15s ease, border-color .15s ease; }

.y-card__quickadd.loading,
.y-card__quickadd.yef-added { pointer-events: none; }

/* The plus is hidden, not replaced, so the button keeps its exact box. */
.y-card__quickadd.loading svg,
.y-card__quickadd.yef-added svg { opacity: 0; }

.y-card__quickadd.loading::after {
	content: ""; position: absolute; inset: 0; margin: auto;
	width: 15px; height: 15px; border-radius: 50%;
	border: 2px solid rgba(17, 17, 17, .22);
	border-top-color: var(--y-ink, #111);
	animation: yef-qa-spin .7s linear infinite;
}
@keyframes yef-qa-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
	.y-card__quickadd.loading::after { animation-duration: 2s; }
}

/* WooCommerce keeps `.loading` until its request settles and leaves `.added`
   on the button forever; quickadd.js owns `.yef-added` and clears it, so the
   success state is a beat rather than a permanent change. */
.y-card__quickadd.yef-added {
	background: var(--wp--preset--color--accent, #66c7cc);
	border-color: var(--wp--preset--color--accent, #66c7cc);
	color: #111;
}
.y-card__quickadd.yef-added::after {
	content: ""; position: absolute; inset: 0; margin: auto;
	width: 15px; height: 15px;
	background: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ---- toast ----
   One node, reused. It sits above the theme's fixed tab bar (z-index 140,
   56px tall plus the home-indicator inset, and only present at <=680px), so
   the offset is stated per breakpoint rather than guessed at. */
.yef-toast {
	position: fixed;
	z-index: 1000;
	inset-inline: 16px;
	bottom: calc(16px + env(safe-area-inset-bottom, 0px));
	width: calc(100% - 32px);
	max-width: 420px;
	margin-inline: auto;
	box-sizing: border-box;
	direction: rtl;
	display: flex; align-items: center; gap: 10px;
	min-height: 54px; padding: 10px 16px;
	background: #fff;
	border: 1px solid var(--y-line, #E7E1D6);
	border-radius: 15px;
	box-shadow: 0 6px 24px rgba(0, 0, 0, .13);
	font-size: .9375rem; line-height: 1.4;
	color: var(--y-ink, #111);
	opacity: 0; transform: translateY(8px);
	transition: opacity .18s ease, transform .18s ease;
	pointer-events: none;
}
.yef-toast[hidden] { display: none; }
.yef-toast.is-open { opacity: 1; transform: none; pointer-events: auto; }
@media (prefers-reduced-motion: reduce) {
	.yef-toast { transition: none; }
}

/* Clear of the tab bar, which only exists on the same breakpoint it does.
   Measured, not guessed: the bar is a 56px min-height item with 6px of padding
   each side and a 1px top border — 69px — and it carries the home-indicator
   inset inside its own padding, so that inset is added once here and not twice.
   82px leaves a real gap rather than the 1px overlap a rounder number gave. */
@media (max-width: 680px), (min-width: 768px) {
	.yef-toast { bottom: calc(82px + env(safe-area-inset-bottom, 0px)); }
}

.yef-toast__check {
	flex: none; display: inline-flex; align-items: center; justify-content: center;
	width: 22px; height: 22px; border-radius: 50%;
	background: var(--wp--preset--color--accent, #66c7cc);
	color: #111;
}
.yef-toast__text { flex: 1 1 auto; min-width: 0; font-weight: 600; }
.yef-toast__action {
	flex: none; padding: 6px 2px;
	font-size: .9375rem; font-weight: 800;
	/* The brand turquoise, at the depth that stays readable on white: the
	   preset accent measures about 2:1 against #fff, which fails on a phone in
	   daylight. Same hue, legible. */
	color: #0F6E73;
	text-decoration: none;
}
.yef-toast__action:hover,
.yef-toast__action:focus { text-decoration: none; }

/* An add that failed says so in the same place, in the same shape. */
.yef-toast.is-error .yef-toast__check {
	background: var(--yef-danger, #d92d20); color: #fff;
}
.yef-toast.is-error .yef-toast__action { display: none; }

/* ---- cart sheet after a card add (2026-10-11) ---- */
html.yef-mc-lock, html.yef-mc-lock body { overflow: hidden; }
.yef-mc { position: fixed; inset: 0; z-index: 100000; }
.yef-mc[hidden] { display: none; }
.yef-mc__dim { position: absolute; inset: 0; background: rgba(0,0,0,.45); opacity: 0; transition: opacity .25s ease; }
.yef-mc__sheet {
	position: absolute; bottom: 0; left: 0; right: 0; margin: 0 auto; max-width: 430px;
	height: 92dvh; max-height: 92vh; background: #fff; border-radius: 22px 22px 0 0;
	display: flex; flex-direction: column; transform: translateY(100%);
	transition: transform .28s cubic-bezier(.2,.8,.2,1); direction: rtl;
}
.yef-mc.is-open .yef-mc__dim { opacity: 1; }
.yef-mc.is-open .yef-mc__sheet { transform: none; }
.yef-mc__grab { width: 40px; height: 4px; background: #d6d6d6; border-radius: 4px; margin: 8px auto 2px; flex: none; }
.yef-mc__body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.yef-mc__head { display: flex; justify-content: space-between; align-items: center; padding: 6px 16px 10px; border-bottom: 1px solid #eee; font-size: 16px; }
.yef-mc__x { width: 44px; height: 44px; border: 0; background: none; font-size: 18px; color: #111; cursor: pointer; }
.yef-mc__note { margin: 12px 16px 4px; background: #e6faf7; color: #0f766e; border-radius: 12px; padding: 10px 12px; font-size: 13px; font-weight: 700; }
.yef-mc__note:empty { display: none; }
.yef-mc__note.is-error { background: #fdecec; color: #b42318; }
.yef-mc__items { flex: 1; overflow-y: auto; padding: 6px 8px; -webkit-overflow-scrolling: touch; }
.yef-mc__item { display: flex; gap: 12px; padding: 10px 8px; border-bottom: 1px solid #f0f0f0; transition: opacity .15s; }
.yef-mc__item.is-new { background: #fafffe; box-shadow: inset 0 0 0 2px #14b8a6; border-radius: 12px; border-bottom-color: transparent; }
.yef-mc__item.is-busy { opacity: .5; pointer-events: none; }
.yef-mc__img { width: 72px; height: 72px; flex: none; border-radius: 10px; background: #F7F7F7; overflow: hidden; }
.yef-mc__img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.yef-mc__info { flex: 1; min-width: 0; font-size: 13px; }
.yef-mc__name { font-weight: 700; line-height: 1.35; }
.yef-mc__meta { color: #777; font-size: 12px; margin-top: 2px; }
.yef-mc__row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; gap: 8px; }
.yef-mc__qty { display: inline-flex; align-items: center; border: 1px solid #ddd; border-radius: 22px; }
.yef-mc__qty button { width: 36px; height: 36px; border: 0; background: none; font-size: 18px; color: #111; cursor: pointer; }
.yef-mc__qty span { min-width: 18px; text-align: center; font-weight: 700; }
.yef-mc__empty { text-align: center; color: #777; padding: 40px 0; }
.yef-mc__foot { flex: none; padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid #eee; }
.yef-mc__sum { display: flex; justify-content: space-between; font-size: 15px; margin-bottom: 4px; }
.yef-mc__btn {
	display: flex; align-items: center; justify-content: center; width: 100%; height: 50px; margin-top: 8px;
	border-radius: 14px; border: 1.5px solid #111; background: #fff; color: #111;
	font-family: inherit; font-size: 15px; font-weight: 700; text-decoration: none; cursor: pointer;
}
.yef-mc__btn.is-primary { background: #111; color: #fff; }

/* 2026-10-13: cart sheet items as separated cards instead of a stacked list */
.yef-mc__items { padding: 10px 14px 14px; display: flex; flex-direction: column; gap: 10px; background: #f6f7f7; }
.yef-mc__item { gap: 12px; padding: 10px; background: #fff; border: 1px solid #ececec; border-bottom: 1px solid #ececec; border-radius: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.04); align-items: center; }
.yef-mc__item.is-new { background: #fff; border-color: #14b8a6; box-shadow: 0 0 0 1px #14b8a6, 0 4px 14px rgba(20,184,166,.12); border-radius: 16px; }
.yef-mc__img { width: 84px; height: 84px; border-radius: 12px; background: #f4f4f4; }
.yef-mc__img img { object-fit: contain; padding: 6px; box-sizing: border-box; mix-blend-mode: multiply; }
.yef-mc__info { display: flex; flex-direction: column; justify-content: space-between; min-height: 84px; }
.yef-mc__name { font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.yef-mc__row { margin-top: auto; }
.yef-mc__price { font-size: 14px; }
.yef-mc__qty { background: #f6f7f7; border-color: transparent; }
.yef-mc__qty button { width: 32px; height: 32px; }
.yef-mc__x:focus { outline: none; }
.yef-mc__x:focus-visible { outline: 2px solid #14b8a6; border-radius: 50%; }
