/* Graceful Ballerina Loading Animation across Workspace, News, Ivy, and Transitions */

.olivint-ballerina-loader {
  --bl-accent: var(--accent, #3d7054);
  --bl-text: var(--text, #1e293b);
  --bl-muted: var(--muted, #64748b);
  --bl-surface: var(--surface, #ffffff);
  --bl-border: var(--border, rgba(148, 163, 184, 0.25));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 36px 20px;
  text-align: center;
  color: var(--bl-text);
  user-select: none;
}

.olivint-ballerina-loader.is-compact {
  padding: 20px 14px;
  gap: 10px;
}

.olivint-ballerina-stage {
  position: relative;
  width: 86px;
  height: 98px;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 680px;
  contain: layout style;
}

.olivint-ballerina-loader.is-compact .olivint-ballerina-stage {
  width: 62px;
  height: 70px;
}

.olivint-ballerina-halo {
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--bl-accent) 24%, transparent) 0%, transparent 72%);
  animation: olivintBallerinaPulse 2.2s ease-in-out infinite;
  will-change: transform, opacity;
  pointer-events: none;
}

.olivint-ballerina-ring {
  position: absolute;
  bottom: -17px;
  z-index: 1;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1.5px solid color-mix(in srgb, var(--bl-accent) 45%, transparent);
  border-top-color: transparent;
  box-sizing: border-box;
  animation: olivintBallerinaRing 2s linear infinite;
  will-change: transform;
  pointer-events: none;
}

.olivint-ballerina-loader.is-compact .olivint-ballerina-ring {
  bottom: -13px;
  width: 44px;
  height: 44px;
}

.olivint-ballerina-figure {
  position: relative;
  z-index: 2;
  width: 60px;
  height: 82px;
  color: var(--bl-accent);
  transform-origin: center 75%;
  transform-style: preserve-3d;
  backface-visibility: visible;
  will-change: transform;
  animation: olivintBallerinaPirouette 2s linear infinite;
}

.olivint-ballerina-loader.is-compact .olivint-ballerina-figure {
  width: 44px;
  height: 60px;
}

.olivint-ballerina-spark {
  position: absolute;
  font-size: 11px;
  color: var(--bl-accent);
  opacity: 0;
  will-change: transform, opacity;
  pointer-events: none;
  animation: olivintBallerinaSpark 2.4s ease-in-out infinite;
}

.olivint-ballerina-spark.s1 {
  top: 10px;
  left: 8px;
  animation-delay: 0s;
}

.olivint-ballerina-spark.s2 {
  top: 22px;
  right: 6px;
  font-size: 13px;
  animation-delay: 0.75s;
}

.olivint-ballerina-spark.s3 {
  bottom: 22px;
  left: 10px;
  font-size: 9px;
  animation-delay: 1.4s;
}

.olivint-ballerina-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--bl-muted);
  letter-spacing: 0.01em;
}

.olivint-ballerina-loader.is-compact .olivint-ballerina-label {
  font-size: 0.82rem;
}

.olivint-ballerina-overlay {
  position: fixed;
  inset: 0;
  z-index: 99990;
  display: none;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--background, var(--hub-bg, #fbfbfa)) 86%, transparent);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  will-change: opacity;
  transition: opacity 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

html[data-olivint-boot-hold="1"] .olivint-ballerina-overlay {
  background: var(--background, var(--hub-bg, #fbfbfa));
}

html.dark-theme .olivint-ballerina-overlay,
body.dark-theme .olivint-ballerina-overlay {
  --bl-text: var(--text, #e2e8f0);
  --bl-muted: var(--muted, #94a3b8);
  --bl-surface: var(--surface, #0f1b2d);
  background: color-mix(in srgb, var(--background, var(--hub-bg, #071524)) 88%, transparent);
}

html.dark-theme[data-olivint-boot-hold="1"] .olivint-ballerina-overlay {
  background: var(--background, var(--hub-bg, #0c1519));
}

.olivint-ballerina-overlay.is-visible,
.olivint-ballerina-overlay.is-leaving {
  display: flex;
  visibility: visible;
}

.olivint-ballerina-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.olivint-ballerina-overlay.is-leaving {
  opacity: 0;
  pointer-events: none !important;
}

.olivint-ballerina-overlay.is-visible.is-instant {
  transition: none;
}

.olivint-ballerina-overlay-card {
  padding: 28px 36px;
  border-radius: 20px;
  background: color-mix(in srgb, var(--surface, #ffffff) 96%, transparent);
  border: 1px solid var(--border, rgba(148, 163, 184, 0.28));
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.16);
  contain: layout style paint;
  will-change: transform, opacity;
  transform: translate3d(0, 6px, 0) scale3d(0.97, 0.97, 1);
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.olivint-ballerina-overlay.is-visible .olivint-ballerina-overlay-card {
  transform: translate3d(0, 0, 0) scale3d(1, 1, 1);
}

.olivint-ballerina-overlay.is-leaving .olivint-ballerina-overlay-card {
  transform: translate3d(0, -4px, 0) scale3d(0.98, 0.98, 1);
}

html.dark-theme .olivint-ballerina-overlay-card,
body.dark-theme .olivint-ballerina-overlay-card {
  background: color-mix(in srgb, var(--surface, #0f1b2d) 96%, transparent);
  border-color: var(--border, rgba(148, 163, 184, 0.22));
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

@keyframes olivintBallerinaPirouette {
  0% {
    transform: translate3d(0, 0px, 0) rotateX(6deg) rotateY(0deg);
  }
  25% {
    transform: translate3d(0, -4px, 0) rotateX(6deg) rotateY(90deg);
  }
  50% {
    transform: translate3d(0, -6px, 0) rotateX(6deg) rotateY(180deg);
  }
  75% {
    transform: translate3d(0, -4px, 0) rotateX(6deg) rotateY(270deg);
  }
  100% {
    transform: translate3d(0, 0px, 0) rotateX(6deg) rotateY(360deg);
  }
}

@keyframes olivintBallerinaRing {
  0% {
    transform: translate3d(0, 0, 0) rotateX(74deg) rotateZ(0deg);
  }
  100% {
    transform: translate3d(0, 0, 0) rotateX(74deg) rotateZ(360deg);
  }
}

@keyframes olivintBallerinaPulse {
  0%, 100% {
    transform: scale3d(0.92, 0.92, 1);
    opacity: 0.65;
  }
  50% {
    transform: scale3d(1.08, 1.08, 1);
    opacity: 1;
  }
}

@keyframes olivintBallerinaSpark {
  0%, 100% {
    transform: translate3d(0, 4px, 0) scale3d(0.6, 0.6, 1);
    opacity: 0;
  }
  45% {
    transform: translate3d(0, -6px, 0) scale3d(1.05, 1.05, 1);
    opacity: 0.9;
  }
  80% {
    transform: translate3d(0, -10px, 0) scale3d(0.7, 0.7, 1);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .olivint-ballerina-figure {
    animation: olivintBallerinaPulse 2.4s ease-in-out infinite;
  }
  .olivint-ballerina-ring {
    animation: none;
  }
}
