/**
 * GRACE system identity — blue pearl orb with prismatic light-wave swirl.
 * Used on Home GRACE cards and sidebar identity (not church C mark / leader avatars).
 */

@keyframes graceOrbPulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.08); opacity: 0.35; }
}

@keyframes graceOrbMist {
  0%, 100% { transform: rotate(0deg) scale(1); opacity: 0.55; }
  50% { transform: rotate(12deg) scale(1.06); opacity: 0.75; }
}

@keyframes graceOrbSpeckle {
  0%, 100% { transform: translate(0, 0); opacity: 0.35; }
  50% { transform: translate(2px, -3px); opacity: 0.6; }
}

/* Undulating light ribbons — inspired by a prismatic Siri-style wave */
@keyframes graceOrbSwirl {
  0%, 100% { transform: translateY(0) rotate(-5deg) scaleX(1); }
  33% { transform: translateY(-7%) rotate(4deg) scaleX(1.07); }
  66% { transform: translateY(5%) rotate(-2deg) scaleX(0.95); }
}

.grace-orb {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 0 14px rgba(59, 130, 246, 0.45))
    drop-shadow(0 0 28px rgba(56, 189, 248, 0.22));
}

.grace-orb--lg { width: 112px; height: 112px; }
.grace-orb--sb { width: 84px; height: 84px; min-width: 84px; }
.grace-orb--md { width: 52px; height: 52px; min-width: 52px; }
.grace-orb--sm { width: 44px; height: 44px; min-width: 44px; }
.grace-orb--xs { width: 28px; height: 28px; min-width: 28px; }

.grace-orb__halo {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(147, 197, 253, 0.65);
  animation: graceOrbPulse 2s ease-in-out infinite;
  pointer-events: none;
}

.grace-orb__halo--outer {
  inset: -14px;
  border-width: 1.5px;
  border-color: rgba(186, 230, 253, 0.32);
  animation-delay: 0.5s;
}

.grace-orb--md .grace-orb__halo { inset: -4px; }
.grace-orb--md .grace-orb__halo--outer { inset: -8px; }
.grace-orb--sb .grace-orb__halo { inset: -7px; }
.grace-orb--sb .grace-orb__halo--outer { inset: -13px; }
.grace-orb--sm .grace-orb__halo { inset: -3px; }
.grace-orb--sm .grace-orb__halo--outer { inset: -6px; }
.grace-orb--xs .grace-orb__halo { inset: -2px; }
.grace-orb--xs .grace-orb__halo--outer { inset: -4px; }

.grace-orb__core {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(
    circle at 35% 30%,
    rgba(255, 255, 255, 0.98) 0%,
    #e0f2fe 20%,
    #bae6fd 42%,
    #38bdf8 66%,
    #2563eb 84%,
    rgba(30, 64, 175, 0.95) 100%
  );
  box-shadow:
    inset 0 0 24px rgba(255, 255, 255, 0.35),
    inset 0 -10px 22px rgba(29, 78, 216, 0.45);
}

.grace-orb__mist {
  position: absolute;
  inset: -15%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 70% 30%, rgba(255, 255, 255, 0.4) 0%, transparent 45%),
    radial-gradient(circle at 25% 75%, rgba(147, 197, 253, 0.45) 0%, transparent 50%),
    radial-gradient(circle at 55% 55%, rgba(125, 211, 252, 0.22) 0%, transparent 55%);
  animation: graceOrbMist 4s ease-in-out infinite;
  pointer-events: none;
}

.grace-orb__mist::before,
.grace-orb__mist::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  animation: graceOrbSpeckle 3s ease-in-out infinite;
}

.grace-orb__mist::before {
  width: 28%;
  height: 28%;
  top: 18%;
  left: 22%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.55) 0%, transparent 70%);
}

.grace-orb__mist::after {
  width: 22%;
  height: 22%;
  bottom: 20%;
  right: 18%;
  background: radial-gradient(circle, rgba(224, 242, 254, 0.5) 0%, transparent 70%);
  animation-delay: 1.2s;
}

/* ── Prismatic swirl: 3 blurred light ribbons weaving across the pearl ── */
.grace-orb__wave {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.grace-orb__wave span {
  position: absolute;
  left: -15%;
  width: 130%;
  border-radius: 50%;
  filter: blur(2.5px);
  animation: graceOrbSwirl 3.4s ease-in-out infinite;
  transform-origin: center;
}

/* Crest — bright white-to-gold highlight */
.grace-orb__wave span:nth-child(1) {
  top: 36%;
  height: 17%;
  z-index: 3;
  opacity: 0.95;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.95) 35%,
    rgba(252, 211, 77, 0.85) 62%,
    transparent 100%
  );
}

/* Spectral fringe — faint rainbow edge */
.grace-orb__wave span:nth-child(2) {
  top: 43%;
  height: 20%;
  z-index: 2;
  opacity: 0.6;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(34, 211, 238, 0.6) 22%,
    rgba(74, 222, 128, 0.5) 42%,
    rgba(251, 191, 36, 0.6) 62%,
    rgba(248, 113, 113, 0.55) 82%,
    transparent 100%
  );
  animation-duration: 4.2s;
  animation-delay: 0.4s;
}

/* Body — wide cyan-sky-deep-blue band */
.grace-orb__wave span:nth-child(3) {
  top: 47%;
  height: 30%;
  z-index: 1;
  opacity: 0.8;
  filter: blur(3.5px);
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(56, 189, 248, 0.8) 25%,
    rgba(37, 99, 235, 0.8) 55%,
    rgba(29, 78, 216, 0.7) 82%,
    transparent 100%
  );
  animation-duration: 5s;
  animation-delay: 0.8s;
}

.grace-orb__wave span:nth-child(n + 4) { display: none; }

/* Lighter blur at small sizes so the ribbons stay legible */
.grace-orb--md .grace-orb__wave span,
.grace-orb--sm .grace-orb__wave span { filter: blur(1.2px); }
.grace-orb--md .grace-orb__wave span:nth-child(3),
.grace-orb--sm .grace-orb__wave span:nth-child(3) { filter: blur(1.8px); }
.grace-orb--xs .grace-orb__wave span { filter: blur(0.8px); }
.grace-orb--xs .grace-orb__wave span:nth-child(3) { filter: blur(1px); }

.grace-orb--xs {
  filter: drop-shadow(0 0 6px rgba(59, 130, 246, 0.35))
    drop-shadow(0 0 12px rgba(56, 189, 248, 0.16));
}

/* Desktop home: larger ring wrap for GRACE system orb */
.av-ring-wrap--grace .av-ring,
.av-ring-wrap--grace .av-ring.grace-orb--lg {
  width: 112px;
  height: 112px;
}

.av-ring-wrap--grace {
  margin-right: 4px;
}

.grace-strip-orb {
  flex-shrink: 0;
}

.sb-grace-orb {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
  padding: 6px 0;
  overflow: visible;
}

.sb-top {
  overflow: visible;
}

.sb-grace-orb .grace-orb {
  filter: drop-shadow(0 0 10px rgba(59, 130, 246, 0.35))
    drop-shadow(0 0 18px rgba(56, 189, 248, 0.16));
}
