/* Loading moments (30 Nov 2026, Jonas's pick of 4 from 10 directions):
   06 the button becomes the S (add to cart), 01 the S draws itself (checkout, payment confirmation),
   04 the shelf fills (filters, load more), 09 page to page (cross-document view transition).
   The S is the hidden #shg-s symbol from inc/wait.php. Only transform, opacity, clip-path and stroke animate.
   Under reduced motion: no transition, the S shows finished and still. */

/* ---------- the S ---------- */
.shg-wait-s {
	display: block; inline-size: var(--shg-s, 44px); block-size: var(--shg-s, 44px); overflow: visible;
	color: inherit; fill: currentColor; stroke: currentColor; stroke-width: var(--shg-sw, 56);
	stroke-linecap: round; stroke-linejoin: round;
	stroke-dasharray: 1; stroke-dashoffset: 1; fill-opacity: 0;
	animation: shg-s-draw var(--shg-s-dur, 3.2s) cubic-bezier(.65, 0, .35, 1) infinite;
}
/* Draw the outline, fill, hold, let go. */
@keyframes shg-s-draw {
	0% { stroke-dashoffset: 1; fill-opacity: 0; opacity: 1; }
	46% { stroke-dashoffset: 0; fill-opacity: 0; }
	62% { fill-opacity: 1; }
	86% { opacity: 1; stroke-dashoffset: 0; fill-opacity: 1; }
	100% { opacity: 0; stroke-dashoffset: 0; fill-opacity: 1; }
}
/* One draw that stays drawn (the add-to-cart button). */
@keyframes shg-s-once {
	0% { stroke-dashoffset: 1; fill-opacity: 0; }
	70% { stroke-dashoffset: 0; fill-opacity: 0; }
	100% { stroke-dashoffset: 0; fill-opacity: 1; }
}

/* ---------- 06 the button becomes the S ---------- */
.shg-wait-btn { clip-path: inset(0 0 0 0 round 999px); }
.shg-wait-btn.is-waiting { clip-path: inset(0 calc(50% - var(--shg-h, 40px) / 2) 0 calc(50% - var(--shg-h, 40px) / 2) round 999px); }
.shg-wait-btn.is-waiting > :not(.shg-wait-mark) { opacity: 0; }
.shg-wait-btn.is-waiting::after { display: none !important; }
/* Chrome does not clip a backdrop blur to the clip-path: the glass pill showed a square around the circle. */
.shg-wait-btn.is-waiting { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
.shg-wait-mark {
	position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
	opacity: 0; transition: opacity 200ms ease-in-out;
}
.shg-wait-btn.is-waiting .shg-wait-mark { opacity: 1; }
.shg-wait-mark .shg-wait-s {
	--shg-s: calc(var(--shg-h, 40px) * .56); --shg-sw: 90;
	animation: shg-s-once 900ms cubic-bezier(.65, 0, .35, 1) both;
}
/* Desktop cards: the pill stays shown while it waits, even if the pointer leaves the card. */
.shg-pc .shg-pc__add.is-waiting, .qs-card .qs-tile__add:has(.is-waiting) { opacity: 1 !important; transform: none !important; }

/* ---------- 01 the S draws itself: checkout submit ---------- */
.shg-wait-veil {
	position: fixed; inset: 0; z-index: 100000; display: grid; place-content: center; justify-items: center; gap: 18px;
	padding: env(safe-area-inset-top, 0px) 16px env(safe-area-inset-bottom, 0px);
	background: rgba(255, 246, 238, .92); color: var(--night-bordeaux, #4C1E20);
	opacity: 0; transition: opacity 260ms ease-in-out;
}
.shg-wait-veil.is-on { opacity: 1; }
.shg-wait-veil .shg-wait-s { --shg-s: 72px; --shg-sw: 26; }
.shg-wait-veil p { margin: 0; font-size: 14px; color: var(--ink-70, rgba(56, 27, 32, .7)); }

/* ---------- 01 on the thank-you wait (replaces the spinner) ---------- */
.shg-ty-wait .shg-wait-s { --shg-s: 56px; --shg-sw: 32; color: var(--night-bordeaux, #4C1E20); }
.shg-ty-wait.is-done .shg-wait-s { animation: none; stroke-dashoffset: 0; fill-opacity: 1; }

/* ---------- 04 the shelf fills: filters and load more ---------- */
@keyframes shg-shelf-breathe { 0%, 100% { opacity: 1; } 50% { opacity: .6; } }
.shg-grid.is-refreshing .shg-pc__img,
.shg-grid.is-refreshing :is(.shg-pc__add, .shg-pc__plus, .shg-pc__chips, .shg-wl, .qs-stamp) { opacity: 0 !important; transition: opacity 200ms ease-in-out; }
.shg-grid.is-refreshing .shg-pc__t,
.shg-pc--sk .shg-pc__t { animation: shg-shelf-breathe 1.8s ease-in-out infinite; }
.shg-grid.is-refreshing :is(.shg-pc__n, .shg-pc__p) { color: transparent !important; }
.shg-grid.is-refreshing :is(.shg-pc__n, .shg-pc__p) > * { visibility: hidden; }
.shg-grid.is-refreshing .shg-pc__n,
.shg-grid.is-refreshing .shg-pc__p,
.shg-pc--sk .shg-sk-l {
	display: block; inline-size: 70%; block-size: 10px; margin-block: 4px; border-radius: 5px; background: var(--ink-14, rgba(56, 27, 32, .14));
	overflow: hidden; animation: shg-shelf-breathe 1.8s ease-in-out infinite;
}
.shg-grid.is-refreshing .shg-pc__p, .shg-pc--sk .shg-sk-l + .shg-sk-l { inline-size: 35%; }
.shg-grid.is-refreshing .shg-pc:nth-child(4n+2) :is(.shg-pc__t, .shg-pc__n, .shg-pc__p) { animation-delay: .15s; }
.shg-grid.is-refreshing .shg-pc:nth-child(4n+3) :is(.shg-pc__t, .shg-pc__n, .shg-pc__p) { animation-delay: .3s; }
.shg-grid.is-refreshing .shg-pc:nth-child(4n+4) :is(.shg-pc__t, .shg-pc__n, .shg-pc__p) { animation-delay: .45s; }
.shg-pc--sk:nth-child(4n+2) :is(.shg-pc__t, .shg-sk-l) { animation-delay: .15s; }
.shg-pc--sk:nth-child(4n+3) :is(.shg-pc__t, .shg-sk-l) { animation-delay: .3s; }
.shg-pc--sk:nth-child(4n+4) :is(.shg-pc__t, .shg-sk-l) { animation-delay: .45s; }
.shg-pc--sk { pointer-events: none; }

/* ---------- 09 page to page ---------- */
@media (prefers-reduced-motion: no-preference) {
	@view-transition { navigation: auto; }
	::view-transition-old(root) { animation: shg-vt-out 220ms cubic-bezier(.22, 1, .36, 1) both; }
	::view-transition-new(root) { animation: shg-vt-in 480ms cubic-bezier(.22, 1, .36, 1) both; }
}
@keyframes shg-vt-out { to { opacity: 0; } }
@keyframes shg-vt-in { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
	.shg-wait-s, .shg-wait-mark .shg-wait-s { animation: none !important; stroke-dashoffset: 0; fill-opacity: 1; }
	.shg-wait-btn, .shg-wait-mark, .shg-wait-veil { transition: none !important; }
	.shg-grid.is-refreshing :is(.shg-pc__t, .shg-pc__n, .shg-pc__p), .shg-pc--sk :is(.shg-pc__t, .shg-sk-l) { animation: none !important; }
}
