/**
 * @file        dot-matrix.css
 * @description Dot-matrix LED-style loading animations. Five variants, all
 *              implemented as pure CSS keyframes — no JS, no external deps.
 *              Loaded by the builder preview AND injected at runtime by
 *              public/embed.v1.min.js so the Loading element renders the
 *              chosen animation in the live funnel.
 *
 *              Inspired by https://dotmatrix.zzzzshawn.cloud/
 *
 * @author      Thomas Dobler - SYNTHETIXMIND LTD
 * @email       tom@synthetixmind.com
 * @uid         dac9f0c1-4bc7-4862-9f04-d72e1c7041c8
 * @version     0.0.0.1
 * @created     2026-05-29
 * @updated     2026-05-29
 * @copyright   (c) 2026 by SYNTHETIXMIND LTD
 * @license     Proprietary — All rights reserved
 */

.lo-anim {
  display: inline-block;
  position: relative;
  --lo-dot-color: currentColor;
}

/* ── 1. Dot Spinner (8 dots rotating) ────────────────────────────────── */
.lo-anim.dot-spinner {
  width: 48px;
  height: 48px;
  animation: lo-spinner-rot 1.2s linear infinite;
}
.lo-anim.dot-spinner::before,
.lo-anim.dot-spinner::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle 4px at 24px 4px,  var(--lo-dot-color) 100%, transparent 100%),
    radial-gradient(circle 4px at 38px 10px, var(--lo-dot-color) 100%, transparent 100%),
    radial-gradient(circle 4px at 44px 24px, var(--lo-dot-color) 100%, transparent 100%),
    radial-gradient(circle 4px at 38px 38px, var(--lo-dot-color) 100%, transparent 100%),
    radial-gradient(circle 4px at 24px 44px, var(--lo-dot-color) 100%, transparent 100%),
    radial-gradient(circle 4px at 10px 38px, var(--lo-dot-color) 100%, transparent 100%),
    radial-gradient(circle 4px at 4px 24px,  var(--lo-dot-color) 100%, transparent 100%),
    radial-gradient(circle 4px at 10px 10px, var(--lo-dot-color) 100%, transparent 100%);
  opacity: 0.9;
}
.lo-anim.dot-spinner::after {
  animation: lo-spinner-fade 1.2s linear infinite;
  opacity: 0;
}
@keyframes lo-spinner-rot  { to   { transform: rotate(360deg); } }
@keyframes lo-spinner-fade { 50% { opacity: 0.4; } }

/* ── 2. Dot Wave (5 bouncing dots) ───────────────────────────────────── */
.lo-anim.dot-wave {
  width: 80px; height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.lo-anim.dot-wave::before {
  content: "";
  width: 100%;
  height: 100%;
  display: inline-block;
  background:
    radial-gradient(circle 5px at 5px var(--y1, 16px),  var(--lo-dot-color) 100%, transparent 100%),
    radial-gradient(circle 5px at 22px var(--y2, 16px), var(--lo-dot-color) 100%, transparent 100%),
    radial-gradient(circle 5px at 39px var(--y3, 16px), var(--lo-dot-color) 100%, transparent 100%),
    radial-gradient(circle 5px at 56px var(--y4, 16px), var(--lo-dot-color) 100%, transparent 100%),
    radial-gradient(circle 5px at 73px var(--y5, 16px), var(--lo-dot-color) 100%, transparent 100%);
  animation: lo-wave 1.2s ease-in-out infinite;
}
@keyframes lo-wave {
  0%, 100% { --y1: 8px;  --y2: 16px; --y3: 24px; --y4: 16px; --y5: 8px;  }
  50%      { --y1: 24px; --y2: 16px; --y3: 8px;  --y4: 16px; --y5: 24px; }
}

/* ── 3. Dot Pulse (3 dots fading) ────────────────────────────────────── */
.lo-anim.dot-pulse {
  width: 60px; height: 12px;
  display: inline-flex;
  gap: 8px;
}
.lo-anim.dot-pulse::before {
  content: "";
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--lo-dot-color);
  box-shadow: 18px 0 var(--lo-dot-color), 36px 0 var(--lo-dot-color);
  animation: lo-pulse 1.2s ease-in-out infinite;
}
@keyframes lo-pulse {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.85); }
  30%           { opacity: 1;   transform: scale(1);    }
}

/* ── 4. Dot Snake (4 dots trailing in a row) ─────────────────────────── */
.lo-anim.dot-snake {
  width: 80px; height: 12px;
  display: inline-block;
  position: relative;
}
.lo-anim.dot-snake::before {
  content: "";
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--lo-dot-color);
  position: absolute; left: 0; top: 0;
  box-shadow:
    18px 0 var(--lo-dot-color),
    36px 0 var(--lo-dot-color),
    54px 0 var(--lo-dot-color);
  animation: lo-snake 1.6s ease-in-out infinite;
}
@keyframes lo-snake {
  0%   { opacity: 0.2; transform: translateX(0)  scale(0.6); }
  25%  { opacity: 1;   transform: translateX(8px) scale(1);  }
  50%  { opacity: 0.6; transform: translateX(16px) scale(0.8); }
  100% { opacity: 0.2; transform: translateX(0)  scale(0.6); }
}

/* ── 5. Dot Matrix (LED panel pulse, 5x5 grid) ───────────────────────── */
.lo-anim.dot-matrix {
  width: 60px; height: 60px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 3px;
}
.lo-anim.dot-matrix::before {
  content: "";
  display: block;
  grid-column: 1 / -1;
  grid-row: 1 / -1;
  background-image:
    radial-gradient(circle 3px, var(--lo-dot-color) 100%, transparent 100%);
  background-size: 12px 12px;
  background-position: 0 0;
  animation: lo-matrix 1.8s steps(6, end) infinite;
  opacity: 0.85;
}
@keyframes lo-matrix {
  0%   { background-position: 0 0;    opacity: 0.3; }
  16%  { background-position: 12px 0; opacity: 0.8; }
  33%  { background-position: 24px 0; opacity: 1;   }
  50%  { background-position: 24px 12px; opacity: 0.8; }
  66%  { background-position: 12px 24px; opacity: 0.6; }
  83%  { background-position: 0 12px;  opacity: 0.4; }
  100% { background-position: 0 0;    opacity: 0.3; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .lo-anim { animation: none !important; }
  .lo-anim::before, .lo-anim::after { animation: none !important; }
}
