/* Animation de chargement des pages : barre de progression dorée en haut de l'écran + écran de chargement
   (logo qui pulse dans un anneau) qui n'apparaît que si le chargement dure plus de 0,7 s. Piloté par assets/js/loader.js. */

.page-loader { position: fixed; inset: 0; z-index: 9999; pointer-events: none; }

/* ---- barre de progression ---- */
.pl-bar { position: fixed; top: 0; left: 0; right: 0; height: 3px; opacity: 0; transition: opacity 0.3s ease 0.1s; }
.pl-bar > span {
  display: block; height: 100%; width: var(--p, 0%);
  background: linear-gradient(90deg, var(--color-primary-dark, #96701f), var(--color-accent, #f4c531));
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 10px rgba(244, 197, 49, 0.75), 0 0 4px rgba(244, 197, 49, 0.9);
  transition: width 0.35s cubic-bezier(.2, .8, .2, 1);
  position: relative;
}
.pl-bar > span::after {   /* petite lueur qui court au bout de la barre */
  content: ""; position: absolute; right: 0; top: 0; width: 90px; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.75));
  animation: pl-glint 1.1s ease-in-out infinite;
}
@keyframes pl-glint { 0% { opacity: 0.15; } 50% { opacity: 1; } 100% { opacity: 0.15; } }
.page-loader.is-loading .pl-bar { opacity: 1; transition-delay: 0s; }

/* ---- écran de chargement (après 0,7 s) ---- */
.pl-splash {
  position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 0.9rem;
  background: rgba(242, 234, 217, 0.86); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0s linear 0.3s;
}
.page-loader.is-loading .pl-splash { visibility: visible; animation: pl-splash-in 0.3s ease 0.7s forwards; transition: none; }
@keyframes pl-splash-in { to { opacity: 1; } }
.pl-orb { position: relative; width: 84px; height: 84px; display: grid; place-items: center; }
.pl-orb::before {   /* anneau qui tourne */
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(184, 135, 43, 0) 0deg, var(--color-primary, #b8872b) 300deg, var(--color-accent, #f4c531) 360deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px));
  animation: pl-spin 0.95s linear infinite;
}
.pl-orb img { width: 54px; height: 54px; border-radius: 50%; animation: pl-pulse 1.6s ease-in-out infinite; box-shadow: 0 6px 18px -6px rgba(16, 28, 48, 0.5); }
@keyframes pl-spin { to { transform: rotate(360deg); } }
@keyframes pl-pulse { 0%, 100% { transform: scale(0.94); } 50% { transform: scale(1.04); } }
.pl-text { margin: 0; font-weight: 700; letter-spacing: 0.02em; color: var(--color-text, #1c2b42); font-size: 0.95rem; }
.pl-text i { font-style: normal; display: inline-block; animation: pl-dot 1.2s infinite; }
.pl-text i:nth-child(2) { animation-delay: 0.15s; }
.pl-text i:nth-child(3) { animation-delay: 0.3s; }
@keyframes pl-dot { 0%, 60%, 100% { opacity: 0.2; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* Lecteur de manuel : il affiche son propre message (« Mise en page de la leçon en cours… ») : seule la barre fine reste.
   Arrivée sur une page (.is-initial, posée par components/header.php) : la barre fine seulement, jamais de voile sur le
   contenu déjà affiché (audit SEO 3.1 : le voile retardait l'affichage). L'écran de chargement ne sert qu'après un clic. */
body.page-manuel .pl-splash, .page-loader.is-initial .pl-splash { display: none; }

/* Sécurité : si le script ne répond pas, tout disparaît au bout de 12 s. */
.page-loader.is-loading { animation: pl-failsafe 0s linear 12s forwards; }
@keyframes pl-failsafe { to { opacity: 0; visibility: hidden; } }

/* Plus de fondu du contenu à l'arrivée (17/10, audit SEO 3.1) : la page démarrait à opacity 0 pendant 0,4 s, ce qui
   retardait le premier affichage mesuré par Google (LCP). Ne pas y revenir avec un `transform` non plus (repère des fixed). */

@media (prefers-reduced-motion: reduce) {
  .pl-bar > span::after, .pl-orb::before, .pl-orb img, .pl-text i { animation: none; }
  .pl-bar > span { transition: none; }
  .page-loader.is-loading .pl-splash { animation-duration: 0.01s; }
}
