/* Page loader — book → author → quill morph. All classes are prefixed (wh-loader / wl-) to avoid clashing with admin.css. */

.wh-loader {
  --wl-bg: #d9d9d9;
  --wl-gold: #111;
  --wl-gold-fill: rgba(219, 219, 219, 0.09);
  --wl-label: #808080;
  --wl-cycle: 9s;

  position: fixed;
  inset: 0;
  z-index: 9000;

  display: grid;
  place-items: center;

  background: var(--wl-bg);

  font-family:
    "DM Sans",
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;

  opacity: 1;
  visibility: visible;

  clip-path: circle(150% at 50% 50%);

  transition:
    clip-path 1.2s cubic-bezier(0.77, 0, 0.18, 1),
    visibility 0s linear 1.2s;
}

.wh-loader.is-hidden {
  clip-path: circle(0% at 50% 50%);
  visibility: hidden;
  pointer-events: none;
}

.wh-loader[hidden] {
  display: none;
}

.wl-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(6px, 2vmin, 14px);
  padding: 16px;
}

.wl-svg {
  width: min(32vw, 120px);
  height: auto;
  overflow: visible;
}

/* =========================================================
   RING
   ========================================================= */

.wl-ring {
  fill: none;
  stroke: var(--wl-gold);
  stroke-opacity: 0.3;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 1 9;
  transform-origin: 100px 100px;

  animation: wl-spin 24s linear infinite;
}

@keyframes wl-spin {
  to {
    transform: rotate(360deg);
  }
}

/* =========================================================
   ICONS
   ========================================================= */

.wl-icon {
  fill: none;
  stroke: var(--wl-gold);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform-origin: 100px 100px;

  opacity: 0;
  visibility: hidden;
  pointer-events: none;

  animation: none;
}

.wl-icon .wl-fill {
  fill: var(--wl-gold-fill);
}

.wl-icon path {
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: none;
}

/* Selected icon */
.wh-loader[data-loader-icon="book"] .wl-book,
.wh-loader[data-loader-icon="author"] .wl-author,
.wh-loader[data-loader-icon="quill"] .wl-quill {
  visibility: visible;
  animation: wl-icon-show 1.2s ease-in-out forwards;
}

/* Selected icon's paths */
.wh-loader[data-loader-icon="book"] .wl-book path,
.wh-loader[data-loader-icon="author"] .wl-author path,
.wh-loader[data-loader-icon="quill"] .wl-quill path {
  animation: wl-icon-draw 1.2s ease-out forwards;
}

/* =========================================================
   ICON APPEAR / DISAPPEAR
   ========================================================= */

@keyframes wl-icon-show {
  0% {
    opacity: 0;
    transform: scale(0.82) rotate(-4deg);
    filter: blur(4px);
  }

  35%,
  100% {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
  }
}

/* =========================================================
   DRAW
   ========================================================= */

@keyframes wl-icon-draw {
  0% {
    stroke-dashoffset: 100;
  }

  45%,
  100% {
    stroke-dashoffset: 0;
  }
}

/* =========================================================
   LOADING TEXT
   ========================================================= */

.wl-label {
  margin: 0;
  color: var(--wl-label);
  font-style: italic;
  font-size: clamp(13px, 3vw, 15px);
  letter-spacing: 0.02em;
}

.wl-dot {
  display: inline-block;
  animation: wl-blink 1.4s infinite both;
}

.wl-dot:nth-of-type(2) {
  animation-delay: 0.2s;
}

.wl-dot:nth-of-type(3) {
  animation-delay: 0.4s;
}

@keyframes wl-blink {
  0%,
  80%,
  100% {
    opacity: 0.2;
  }

  40% {
    opacity: 1;
  }
}

/* =========================================================
   REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
  .wh-loader {
    transition: none;
  }

  .wl-ring,
  .wl-dot {
    animation: none !important;
  }

  .wl-book,
  .wl-author,
  .wl-quill {
    animation: none !important;
  }

  .wl-book path,
  .wl-author path,
  .wl-quill path {
    animation: none !important;
    stroke-dashoffset: 0;
  }

  /* Whichever icon JS selected is shown */
  .wh-loader[data-loader-icon="book"] .wl-book,
  .wh-loader[data-loader-icon="author"] .wl-author,
  .wh-loader[data-loader-icon="quill"] .wl-quill {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

/* Align loader icons to the same visual center */
.wl-book,
.wl-author,
.wl-quill {
  transform-box: fill-box;
  transform-origin: center;
}

/* Adjust these values if needed to match your SVG artwork */
.wh-loader[data-loader-icon="author"] .wl-author {
  margin: 0;
  translate: 0 0;
}

.wh-loader[data-loader-icon="quill"] .wl-quill {
  margin: 0;
  translate: 0 0;
}

/* Fine-tune individual loader icon alignment */
.wl-icon {
  transform-box: view-box;
  transform-origin: 100px 100px;
}

.wh-loader[data-loader-icon="author"] .wl-author {
  translate: -8px -4px;
}

.wh-loader[data-loader-icon="quill"] .wl-quill {
  translate: 0 -4px;
}
