#advanced-preloader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2147483647; /* above everything, including other plugins' overlays */
}

#advanced-preloader.image-over-text {
  flex-direction: column;
}

#advanced-preloader.image-left-text {
  flex-direction: row;
  align-items: center;
  gap: 20px;
}

#advanced-preloader.image-right-text {
  flex-direction: row-reverse;
  align-items: center;
  gap: 20px;
}

#advanced-preloader.image-below-text {
  flex-direction: column-reverse;
}

#advanced-preloader img {
  max-width: 100px;
  height: auto;
}

#advanced-preloader .preloader-text {
  font-size: 20px;
  font-weight: bold;
  margin-top: 10px;
text-align:center;
}

/* ---- "How often" rule: hidden before paint when already seen ---- */
.ap-skip #advanced-preloader {
  display: none !important;
}

/* ---- Built-in loaders ---- */
#advanced-preloader,
.ap-loader-swatch,
#preloader-preview {
  --ap-size: 48px;
}
#advanced-preloader.ap-size-small { --ap-size: 32px; }
#advanced-preloader.ap-size-large { --ap-size: 72px; }

.ap-loader {
  --ap-c: var(--ap-loader-color, currentColor);
  display: inline-block;
  position: relative;
  box-sizing: border-box;
  flex-shrink: 0;
}
.ap-loader i {
  display: block;
  box-sizing: border-box;
}

/* Spinner */
.ap-loader-spinner {
  width: var(--ap-size);
  height: var(--ap-size);
  border-radius: 50%;
  border: calc(var(--ap-size) / 8) solid rgba(128, 128, 128, 0.2);
  border: calc(var(--ap-size) / 8) solid color-mix(in srgb, var(--ap-c) 20%, transparent);
  border-top-color: var(--ap-c);
  animation: ap-spin 0.8s linear infinite;
}

/* Dual ring */
.ap-loader-ring {
  width: var(--ap-size);
  height: var(--ap-size);
  border-radius: 50%;
  border: calc(var(--ap-size) / 10) solid transparent;
  border-top-color: var(--ap-c);
  border-bottom-color: var(--ap-c);
  animation: ap-spin 1.1s cubic-bezier(0.5, 0.1, 0.5, 0.9) infinite;
}

/* Bouncing dots */
.ap-loader-dots {
  display: inline-flex;
  gap: calc(var(--ap-size) / 8);
  align-items: center;
  height: var(--ap-size);
}
.ap-loader-dots i {
  width: calc(var(--ap-size) / 4);
  height: calc(var(--ap-size) / 4);
  border-radius: 50%;
  background: var(--ap-c);
  animation: ap-bounce 1s ease-in-out infinite;
}
.ap-loader-dots i:nth-child(2) { animation-delay: 0.15s; }
.ap-loader-dots i:nth-child(3) { animation-delay: 0.3s; }

/* Bars */
.ap-loader-bars {
  display: inline-flex;
  gap: calc(var(--ap-size) / 10);
  align-items: center;
  height: var(--ap-size);
}
.ap-loader-bars i {
  width: calc(var(--ap-size) / 8);
  height: 100%;
  border-radius: 2px;
  background: var(--ap-c);
  animation: ap-bars 1s ease-in-out infinite;
}
.ap-loader-bars i:nth-child(2) { animation-delay: 0.12s; }
.ap-loader-bars i:nth-child(3) { animation-delay: 0.24s; }
.ap-loader-bars i:nth-child(4) { animation-delay: 0.36s; }

/* Pulse */
.ap-loader-pulse {
  width: var(--ap-size);
  height: var(--ap-size);
  border-radius: 50%;
  background: var(--ap-c);
  animation: ap-pulse 1.2s ease-out infinite;
}

/* Progress bar (indeterminate) */
.ap-loader-progress {
  width: calc(var(--ap-size) * 4);
  max-width: 80vw;
  height: calc(var(--ap-size) / 10);
  min-height: 3px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(128, 128, 128, 0.2);
  background: color-mix(in srgb, var(--ap-c) 20%, transparent);
}
.ap-loader-progress i {
  width: 40%;
  height: 100%;
  border-radius: inherit;
  background: var(--ap-c);
  animation: ap-progress 1.2s ease-in-out infinite;
}

@keyframes ap-spin { to { transform: rotate(360deg); } }
@keyframes ap-bounce {
  0%, 80%, 100% { transform: scale(0.5); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}
@keyframes ap-bars {
  0%, 100% { transform: scaleY(0.35); }
  50% { transform: scaleY(1); }
}
@keyframes ap-pulse {
  0% { transform: scale(0.2); opacity: 1; }
  100% { transform: scale(1); opacity: 0; }
}
@keyframes ap-progress {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

/* Visitors who ask for less motion get a gentle, slower loader. */
@media (prefers-reduced-motion: reduce) {
  .ap-loader,
  .ap-loader i {
    animation-duration: 2.5s !important;
  }
}
