/**
 * #.#  Homepage Page Loader
 *
 * Fixed burgundy overlay + logo intro animation, front page only.
 * Markup: template-parts/header/page-loader.php
 * Behaviour: assets/js/page-loader.js (adds .page-loader--done, then
 * removes the overlay from the DOM once the fade-out finishes)
 */

body.has-page-loader {
  overflow: hidden;
}

.page-loader {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background-color: var(--farani-burgundy);
  animation: pageLoaderFadeOut 0.7s ease forwards;
  animation-delay: 2.8s;
}

.page-loader__inner {
  position: relative;
  display: inline-flex;
  max-width: 420px;
  width: 60vw;
  transform: scale(1);
  animation: pageLoaderZoomIn 0.9s cubic-bezier(0.55, 0, 1, 0.45) forwards;
  animation-delay: 2.48s;
}

/* SVG logo trace — each letter path draws its stroke in, then fills.
   pathlength="1" (set in PHP) normalises every path to the same length
   unit, so a single stroke-dasharray/-dashoffset value works for all of
   them regardless of actual geometry. Slowed right down so it reads as
   the logo being spelt out letter by letter. */
.page-loader__logo-svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.page-loader__logo-svg path {
  fill: var(--farani-orange);
  fill-opacity: 0;
  stroke: var(--farani-orange);
  stroke-width: 0.6;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: pageLoaderTrace 1.1s ease forwards;
  animation-delay: calc(0.3s + (var(--i, 0) * 0.09s));
}

/* Raster-logo fallback (non-SVG site_main_logo) — simple fade/scale-in */
.page-loader__logo {
  max-width: 420px;
  width: 60vw;
  height: auto;
  opacity: 0;
  transform: scale(0.92);
  animation: pageLoaderLogoIn 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: 0.2s;
}

@keyframes pageLoaderTrace {
  0% {
    stroke-dashoffset: 1;
    fill-opacity: 0;
  }
  75% {
    stroke-dashoffset: 0;
    fill-opacity: 0;
  }
  100% {
    stroke-dashoffset: 0;
    fill-opacity: 1;
  }
}

@keyframes pageLoaderZoomIn {
  to {
    transform: scale(2.4);
  }
}

@keyframes pageLoaderLogoIn {
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pageLoaderFadeOut {
  from {
    opacity: 1;
    visibility: visible;
  }
  to {
    opacity: 0;
    visibility: hidden;
  }
}

.page-loader.page-loader--done {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .page-loader {
    animation: none;
    display: none;
  }
}
