/* BlingLoader：店長奔跑中的載入動畫（public/js/bling-loader.js） */

/* ---- 標誌動畫：描金邊 → 填色 → 淡出，循環 ---- */
.bl-logo { --bl-h: 84px; width: var(--bl-h); height: var(--bl-h); display: flex; align-items: center; justify-content: center; }
.bl-logo-svg { width: 100%; height: 100%; overflow: visible; }
.bl-logo-svg path {
  fill: #d4af37;
  fill-opacity: 0;
  stroke: #d4af37;
  stroke-width: 14;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: var(--len, 4000);
  stroke-dashoffset: var(--len, 4000);
  opacity: 0;
}
.bl-logo.is-ready .bl-logo-svg path {
  opacity: 1;
  animation: bl-draw 2.8s cubic-bezier(.45,.05,.35,1) infinite;
  animation-delay: calc(var(--i, 0) * 45ms);
}
@keyframes bl-draw {
  0%   { stroke-dashoffset: var(--len, 4000); fill-opacity: 0; stroke-opacity: 1; }
  48%  { stroke-dashoffset: 0; fill-opacity: 0; stroke-opacity: 1; }
  66%  { stroke-dashoffset: 0; fill-opacity: 1; stroke-opacity: 0; }
  86%  { stroke-dashoffset: 0; fill-opacity: 1; stroke-opacity: 0; }
  100% { stroke-dashoffset: 0; fill-opacity: 0; stroke-opacity: 0; }
}
/* 標誌下載前的圓點 */
.bl-dots { display: inline-flex; gap: 6px; }
.bl-dots i, .bl-btn-dots i { width: 7px; height: 7px; border-radius: 50%; background: #d4af37; display: block; animation: bl-dot 1s ease-in-out infinite; }
.bl-dots i:nth-child(2), .bl-btn-dots i:nth-child(2) { animation-delay: .15s; }
.bl-dots i:nth-child(3), .bl-btn-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bl-dot { 0%, 80%, 100% { transform: translateY(0); opacity: .45; } 40% { transform: translateY(-5px); opacity: 1; } }

/* 文案 */
.bl-text { margin: 14px 0 0; font-size: 0.9rem; letter-spacing: 0.06em; color: #1a2947; text-align: center; transition: opacity .18s ease; min-height: 1.4em; }
.bl-text.is-swap { opacity: 0; }

/* ---- 全頁遮罩 ---- */
.bl-overlay {
  position: fixed; inset: 0; z-index: 100000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(250, 249, 246, 0.82);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility 0s linear .25s;
  cursor: progress;
}
.bl-overlay.is-on { opacity: 1; visibility: visible; transition: opacity .25s ease; }
.bl-box { display: flex; flex-direction: column; align-items: center; padding: 28px 32px; }
.bl-overlay .bl-logo { --bl-h: 96px; }

/* ---- 區塊內載入 ---- */
.bl-inline { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px 12px; text-align: center; }
.bl-inline .bl-logo { --bl-h: 60px; }
.bl-inline .bl-text { font-size: 0.82rem; margin-top: 10px; opacity: .8; }
.bl-inline.is-compact { flex-direction: row; gap: 10px; padding: 10px 0; }
.bl-inline.is-compact .bl-logo { --bl-h: 32px; }
.bl-inline.is-compact .bl-text { margin: 0; }
.bl-host { position: relative; }
.bl-inline.is-cover { position: absolute; inset: 0; z-index: 5; background: rgba(255, 255, 255, 0.72); padding: 0; }

/* ---- 按鈕忙碌 ---- */
.bl-btn-busy { cursor: progress !important; opacity: .9; }
.bl-btn-dots { display: inline-flex; gap: 4px; margin-right: 8px; vertical-align: middle; position: relative; z-index: 1; }
.bl-btn-dots i { width: 5px !important; height: 5px !important; background: currentColor !important; }
.bl-btn-busy .bl-btn-text { position: relative; z-index: 1; }

/* ---- 圖片載入中：淡淡的閃光底色 ---- */
.bl-img-loading { background: linear-gradient(100deg, #f1f0ec 30%, #faf9f6 50%, #f1f0ec 70%) 0 0 / 200% 100%; animation: bl-shimmer 1.4s linear infinite; }
.bl-img-loading img { opacity: 0; }
.ed-product-img img, .ed-gallery-thumb img { transition: opacity .3s ease; }
@keyframes bl-shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  .bl-logo.is-ready .bl-logo-svg path { animation: none; stroke-dashoffset: 0; fill-opacity: 1; stroke-opacity: 0; }
  .bl-logo.is-ready { animation: bl-pulse 1.6s ease-in-out infinite; }
  .bl-dots i, .bl-btn-dots i, .bl-img-loading { animation: none; }
  @keyframes bl-pulse { 50% { opacity: .5; } }
}

/* 結帳遮罩中的標誌 */
.ed-loading-overlay .bl-checkout-logo { --bl-h: 96px; }

/* ---- Sprite Sheet 動畫（管理員上傳的圖片，一列多格） ---- */
.bl-logo.is-sprite { width: auto; --bl-h: 104px; }
.bl-overlay .bl-logo.is-sprite { --bl-h: 120px; }
.bl-inline .bl-logo.is-sprite { --bl-h: 72px; }
.bl-inline.is-compact .bl-logo.is-sprite { --bl-h: 36px; }
.ed-loading-overlay .bl-checkout-logo.is-sprite { --bl-h: 120px; }
.bl-sprite {
  height: var(--bl-h);
  width: calc(var(--bl-h) * var(--bl-fw) / var(--bl-fh));
  background-image: var(--bl-img);
  background-repeat: no-repeat;
  background-size: calc(var(--bl-h) * var(--bl-sheet) / var(--bl-fh)) var(--bl-h);
  background-position: 0 0;
  animation: bl-sprite var(--bl-dur, .5s) steps(var(--bl-n, 3)) infinite;
}
@keyframes bl-sprite {
  from { background-position: 0 0; }
  to { background-position: calc(var(--bl-h) * var(--bl-stride) / var(--bl-fh) * -1) 0; }
}
@media (prefers-reduced-motion: reduce) {
  .bl-sprite { animation: none; }
  .bl-logo.is-sprite { animation: bl-pulse 1.6s ease-in-out infinite; }
}
