/* Motion and loading states: page-load progress bar, button spinners, skeleton shimmer,
   scroll reveals, and small "it worked" animations. Behaviour is in ui.js.
   Everything here is optional polish: the site works the same without this file.
   Visitors who ask their system for reduced motion get the calm version (bottom of file). */

:root{
	--ease-out: cubic-bezier(0.22, 1, 0.36, 1);
	--skeleton: #ececeb;
	--skeleton-shine: #f7f7f6;
}

/* ---------- Top progress bar (shown while the next page loads) ---------- */
.progress-bar{
	position: fixed;
	top: 0;
	left: 0;
	z-index: 100;
	width: 100%;
	height: 3px;
	background: var(--fg);
	transform: scaleX(0);
	transform-origin: left;
	opacity: 0;
	pointer-events: none;
	transition: none;
}
.progress-bar.is-active{
	opacity: 1;
	/* Races to 30%, then crawls toward 90% until the new page replaces this one. */
	animation: progress 8s var(--ease-out) forwards;
}
.page-home .progress-bar{ background: var(--bg); mix-blend-mode: difference; }
@keyframes progress{
	0%   { transform: scaleX(0); }
	10%  { transform: scaleX(0.3); }
	100% { transform: scaleX(0.9); }
}

/* ---------- Spinner (buttons while their form is sending) ---------- */
.spinner,
.is-loading::after{
	width: 18px;
	height: 18px;
	border: 2px solid var(--spin-color, currentColor);
	border-right-color: transparent;
	border-radius: 50%;
	animation: spin 0.7s linear infinite;
}
.spinner{ display: inline-block; flex-shrink: 0; }
@keyframes spin{ to{ transform: rotate(360deg); } }

button, .btn{ --spin-color: var(--bg); }
.btn-outline, .btn-link, .bead-chip, .bead-pill, .stepper button, .results button, .menu-toggle{
	--spin-color: var(--fg);
}
.is-loading{
	position: relative;
	color: transparent !important;
	pointer-events: none;
}
.is-loading > *{ visibility: hidden; }
/* Switch instantly, even with a site-wide `transition` rule. */
.is-loading, .is-loading > *{ transition: none !important; }
.is-loading::after{
	content: "";
	position: absolute;
	inset: 0;
	margin: auto;
}

/* ---------- Skeletons (shimmer while images, the map and search results load) ---------- */
.skeleton,
.js .image.is-pending,
.js .thumb.is-pending,
.js [data-map]:not(.is-loaded){
	background: linear-gradient(100deg, var(--skeleton) 30%, var(--skeleton-shine) 50%, var(--skeleton) 70%);
	background-size: 300% 100%;
	animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer{
	from{ background-position: 100% 0; }
	to  { background-position: -50% 0; }
}
/* Photos fade in once loaded instead of popping in line by line. */
.js .image img,
.js .thumb img{
	opacity: 0;
	transition: opacity 0.4s ease, transform 0.5s ease;
}
.js .image.is-loaded img,
.js .thumb.is-loaded img{ opacity: 1; }
.js .image.is-pending ion-icon{ opacity: 0; }

/* Search results placeholder rows */
.skeleton-row{
	height: 44px;
	border-radius: var(--radius-sm);
}
.skeleton-row:nth-child(2){ width: 85%; }
.skeleton-row:nth-child(3){ width: 70%; }

/* ---------- Page entrance and scroll reveals ---------- */
.js .reveal{
	opacity: 0;
	transform: translateY(16px);
	transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
	transition-delay: var(--reveal-delay, 0ms);
}
.js .reveal.is-visible{
	opacity: 1;
	transform: none;
}

/* ---------- Hover and press feedback ---------- */
.card{ transition: transform 0.3s var(--ease-out); }
.card:active{ transform: scale(0.98); }
.bead-chip .bead{ transition: transform 0.25s var(--ease-out); }
.bead-chip:hover .bead{ transform: scale(1.12) rotate(-6deg); }
.bead-chip:active .bead{ transform: scale(0.9); }

/* Header gets a slightly deeper shadow once you scroll. */
.site-header{ transition: box-shadow 0.3s ease; }
.site-header.is-scrolled{ box-shadow: var(--shadow-lg); }

/* Phone dropdown slides down instead of appearing. */
@media (max-width: 767px){
	.js .site-header.menu-open nav{ animation: drop 0.25s var(--ease-out); }
}
@keyframes drop{
	from{ opacity: 0; transform: translateY(-8px) scale(0.98); }
	to  { opacity: 1; transform: none; }
}

/* ---------- "It worked" moments ---------- */
/* Beads that just changed pop onto the jewelry and into the strand. On the drawing the inner
   .bead-body is animated, because the outer <g> holds the bead's position. */
span.bead-new,
g.bead-new > .bead-body{
	animation: pop 0.45s var(--pop-delay, 0ms) var(--ease-out) both;
}
g.bead-new > .bead-body{
	transform-box: fill-box;
	transform-origin: center;
}
@keyframes pop{
	0%  { transform: scale(0); }
	60% { transform: scale(1.25); }
	100%{ transform: scale(1); }
}
/* Prices and the cart count bump when they change. */
.bump{ animation: bump 0.45s var(--ease-out); }
@keyframes bump{
	0%  { transform: scale(1); }
	40% { transform: scale(1.12); }
	100%{ transform: scale(1); }
}
.price.bump, .qty-value.bump{ display: inline-block; }

/* Cart count dot on the ☰ button (phones, where the cart link is inside the menu). */
.menu-toggle{ position: relative; }
.menu-badge{
	position: absolute;
	top: 4px;
	right: 2px;
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	border-radius: 9px;
	background: var(--fg);
	color: var(--bg);
	font-size: 0.7rem;
	font-weight: 600;
	line-height: 18px;
	text-align: center;
	box-shadow: 0 0 0 2px var(--bg);
}
.site-header.menu-open .menu-badge{ opacity: 0; }

/* Status icons (thank you, payment) draw in. */
.status-icon{ animation: pop 0.5s 0.1s var(--ease-out) both; }

/* Toasts: a thin light ring keeps them readable over dark areas like the footer. */
.message{ box-shadow: 0 0 0 1px #ffffff40, var(--shadow-lg); }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce){
	.js .reveal, .js .reveal.is-visible{ opacity: 1; transform: none; transition: none; }
	.status-icon, .bead-new, .bump,
	.js .site-header.menu-open nav{ animation: none; }
	.skeleton, .js .image.is-pending, .js .thumb.is-pending, .js [data-map]:not(.is-loaded){ animation: none; }
	.progress-bar.is-active{ animation: none; transform: scaleX(0.6); }
	.spinner, .is-loading::after{ animation-duration: 1.6s; }   /* still shows something is happening */
}

/* Status line under the map search, with its small spinner. */
.map-status{
	display: flex;
	align-items: center;
	gap: 8px;
}
.map-status .spinner{
	width: 14px;
	height: 14px;
	border-width: 2px;
}

/* Bead designer saving in the background: dim the drawing slightly, but only if the save
   takes longer than a moment (most taps finish before this kicks in). */
.designer .preview-stage{ transition: opacity 0.2s ease; }
.designer.is-updating .preview-stage{
	opacity: 0.55;
	transition-delay: 0.25s;
}

/* Map pin: a teardrop with a soft shadow that drops in whenever it moves. Drawn in map.js. */
.map-pin{
	filter: drop-shadow(0 3px 3px rgba(0,0,0,.35)) drop-shadow(0 8px 10px rgba(0,0,0,.15));
}
.map-pin svg{
	display: block;
	transform-origin: 50% 100%;
}
.map-pin.is-dropping svg{
	animation: pin-drop 0.45s var(--ease-out) both;
}
@keyframes pin-drop{
	0%  { transform: translateY(-22px) scale(0.9); opacity: 0; }
	60% { transform: translateY(2px) scale(1.06, 0.94); opacity: 1; }
	100%{ transform: none; }
}
.leaflet-marker-draggable{ cursor: grab; }
.leaflet-dragging .leaflet-marker-draggable{ cursor: grabbing; }
.map-status.is-warning{ color: var(--danger); }
@media (prefers-reduced-motion: reduce){
	.map-pin.is-dropping svg{ animation: none; }
}
