/* ============================================================================
   TRIPPŸ Loader — a spinning-coin loading animation built on the REAL
   trippy-coin.png asset. Dependency-free, themeable via CSS variables, and
   prefers-reduced-motion aware. Shared across APxAI.co for one delightful,
   on-brand loading state (the coin literally flips like a coin).
   ========================================================================== */

:root {
  --trippy-coin-size: 96px;
  --trippy-glow: rgba(233, 166, 160, 0.55); /* pink halo from the coin bg */
  --trippy-ink: #2a2118;
  --trippy-veil: rgba(247, 237, 235, 0.96);
}

.trippy-loader {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  font-family: inherit;
}

/* Full-screen overlay variant (TrippyLoader.show) */
.trippy-loader--overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  justify-content: center;
  background: radial-gradient(120% 120% at 50% 40%, rgba(255, 255, 255, 0.92), var(--trippy-veil));
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.trippy-loader__coin {
  width: var(--trippy-coin-size);
  height: var(--trippy-coin-size);
  position: relative;
  transform-style: preserve-3d;
  animation:
    trippy-flip 1.8s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite,
    trippy-bob 2.4s ease-in-out infinite;
  filter: drop-shadow(0 10px 18px var(--trippy-glow));
}

.trippy-loader__coin img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: block;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* Soft glow puck behind the coin */
.trippy-loader__coin::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 130%;
  height: 130%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, var(--trippy-glow), transparent 65%);
  z-index: -1;
  animation: trippy-pulse 2.4s ease-in-out infinite;
}

.trippy-loader__caption {
  font-size: 14px;
  letter-spacing: 0.2px;
  color: var(--trippy-ink);
  opacity: 0.85;
  min-height: 1.2em;
}
.trippy-loader__caption::after {
  content: "";
  animation: trippy-dots 1.4s steps(4, end) infinite;
}

@keyframes trippy-flip {
  0% { transform: rotateY(0deg); }
  100% { transform: rotateY(360deg); }
}
@keyframes trippy-bob {
  0%, 100% { margin-top: 0; }
  50% { margin-top: -10px; }
}
@keyframes trippy-pulse {
  0%, 100% { opacity: 0.35; transform: translate(-50%, -50%) scale(0.9); }
  50% { opacity: 0.7; transform: translate(-50%, -50%) scale(1.05); }
}
@keyframes trippy-dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
  100% { content: ""; }
}

/* Respect users who ask for less motion: keep a gentle bob, drop the spin. */
@media (prefers-reduced-motion: reduce) {
  .trippy-loader__coin {
    animation: trippy-bob 3s ease-in-out infinite;
  }
  .trippy-loader__coin::after {
    animation: none;
    opacity: 0.5;
  }
  .trippy-loader__caption::after {
    animation: none;
    content: "…";
  }
}
