/* ==========================================================================
   TBF DIGITAL — Moteur d'animations & micro-interactions partagé
   Chargé sur toutes les pages. Ne redéfinit aucune règle de mise en page :
   uniquement des classes/éléments additifs (transform + opacity => 60 FPS).
   ========================================================================== */

/* ---------- 1. Interrupteur global prefers-reduced-motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- 2. Scroll fluide (no-op si déjà déclaré en inline) ---------- */
html { scroll-behavior: smooth; }

/* ---------- 3. Focus premium (accessibilité clavier) ---------- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2.5px solid var(--blue, #1E6FE8);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------- 4. Barre de progression de lecture ---------- */
.reading-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 3px;
  background: rgba(11,31,58,0.06); z-index: 3000; pointer-events: none;
}
.reading-progress-bar {
  height: 100%; width: 100%; transform-origin: 0 50%; transform: scaleX(0);
  background: linear-gradient(90deg, var(--blue, #1E6FE8), var(--wood, #C17A3E));
  will-change: transform;
}

/* ---------- 5. Curseur personnalisé (desktop uniquement) ---------- */
@media (hover: hover) and (pointer: fine) {
  body.fx-cursor-active, body.fx-cursor-active a, body.fx-cursor-active button,
  body.fx-cursor-active input, body.fx-cursor-active textarea, body.fx-cursor-active select,
  body.fx-cursor-active summary, body.fx-cursor-active label { cursor: none; }

  .cursor-dot, .cursor-ring {
    position: fixed; top: 0; left: 0; z-index: 9999; pointer-events: none;
    border-radius: 50%; opacity: 0; transition: opacity 0.25s ease;
    will-change: transform;
  }
  body.fx-cursor-active .cursor-dot,
  body.fx-cursor-active .cursor-ring { opacity: 1; }

  .cursor-dot {
    width: 7px; height: 7px; background: var(--blue, #1E6FE8);
    transform: translate(-100px, -100px);
  }
  .cursor-ring {
    width: 34px; height: 34px; transform: translate(-100px, -100px);
  }
  .cursor-ring::after {
    content: ""; position: absolute; inset: 0; border-radius: 50%;
    border: 1.5px solid rgba(30,111,232,0.45);
    transform: scale(1);
    transition: transform 0.25s cubic-bezier(.16,1,.3,1), border-color 0.25s ease, background 0.25s ease;
  }
  .cursor-ring.is-active::after {
    transform: scale(1.5);
    border-color: var(--wood, #C17A3E);
    background: rgba(193,122,62,0.10);
  }
}
@media (prefers-reduced-motion: reduce), (hover: none), (pointer: coarse) {
  .cursor-dot, .cursor-ring { display: none !important; }
  body.fx-cursor-active { cursor: auto !important; }
}

/* ---------- 6. Transition entre les pages (fondu de sortie uniquement) ---------- */
.page-transition-overlay {
  position: fixed; inset: 0; z-index: 9997;
  background: var(--navy, #0B1F3A);
  opacity: 0; pointer-events: none;
  transition: opacity 0.32s cubic-bezier(.4,0,.2,1);
}
.page-transition-overlay.is-active { opacity: 1; pointer-events: all; }

/* ---------- 7. Bouton retour en haut (partagé sur toutes les pages) ---------- */
.back-to-top {
  position: fixed; left: 24px; bottom: 24px; z-index: 200;
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.14);
  background: rgba(11,31,58,0.9); color: #fff; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(11,31,58,0.28);
  opacity: 0; visibility: hidden; transform: translateY(12px) scale(0.9);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(.16,1,.3,1), visibility 0.3s, background 0.25s ease, box-shadow 0.25s ease;
}
.back-to-top.is-visible { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.back-to-top:hover, .back-to-top:focus-visible { background: var(--blue, #1E6FE8); box-shadow: 0 12px 26px rgba(30,111,232,0.4); transform: translateY(-3px) scale(1.05); }
.back-to-top:active { transform: translateY(0) scale(0.95); }
.back-to-top i, .back-to-top svg { transition: transform 0.25s cubic-bezier(.34,1.56,.64,1); }
.back-to-top:hover i, .back-to-top:hover svg { transform: translateY(-2px); }
@media (max-width: 640px) {
  .back-to-top { left: auto; right: 16px; bottom: 84px; width: 42px; height: 42px; }
}

/* ---------- 8. Apparition progressive des images ---------- */
img.fx-img {
  opacity: 0; transform: scale(1.02);
  transition: opacity 0.6s cubic-bezier(.16,1,.3,1), transform 0.6s cubic-bezier(.16,1,.3,1);
}
img.fx-img.is-loaded { opacity: 1; transform: scale(1); }

/* ---------- 9. Reveal au scroll générique (fade / slide / zoom + stagger) ---------- */
.fx-reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s cubic-bezier(.16,1,.3,1), transform 0.7s cubic-bezier(.16,1,.3,1);
  transition-delay: var(--fx-delay, 0s);
}
.fx-reveal.fx-slide-left { transform: translateX(-24px); }
.fx-reveal.fx-slide-right { transform: translateX(24px); }
.fx-reveal.fx-zoom { transform: scale(0.94); }
.fx-reveal.fx-fade { transform: none; }
.fx-reveal.is-visible { opacity: 1; transform: none; }
.fx-reveal.fx-zoom.is-visible { transform: scale(1); }

/* ---------- 10. Hover premium générique (cartes / liens / icônes) ---------- */
.fx-hover-lift { transition: transform 0.3s cubic-bezier(.16,1,.3,1), box-shadow 0.3s ease; }
.fx-hover-lift:hover { transform: translateY(-6px); }

/* Icônes : légère rotation/échelle au survol du parent interactif */
.btn i, .social-link i, a.card-link i, .nav-links a i { transition: transform 0.3s cubic-bezier(.34,1.56,.64,1); }
.btn:hover i, .social-link:hover i, a.card-link:hover i { transform: scale(1.12); }

/* ---------- 11. Ripple discret au clic (boutons) ---------- */
.fx-ripple { position: relative; overflow: hidden; }
.fx-ripple-dot {
  position: absolute; border-radius: 50%; pointer-events: none;
  background: rgba(255,255,255,0.55);
  transform: scale(0); opacity: 0.6;
  animation: fxRippleAnim 0.6s ease-out forwards;
}
@keyframes fxRippleAnim {
  to { transform: scale(1); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .fx-ripple-dot { display: none; }
}

/* ---------- 12. États actifs (feedback tactile/clic) ---------- */
.btn:active, .fx-hover-lift:active { transform: scale(0.97); }

/* ---------- 13. Magnétisme générique (boutons .btn, hors zones déjà personnalisées) ---------- */
.fx-magnetic { will-change: transform; }

/* ---------- 14. Parallax léger (éléments décoratifs marqués data-parallax) ---------- */
[data-parallax] { will-change: transform; }

/* ---------- 15. Bascule mode clair / sombre ---------- */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 8px; flex: 0 0 auto;
  background: transparent; border: 1.5px solid rgba(255,255,255,0.3); color: #fff;
  cursor: pointer; font-size: 13px;
  transition: border-color 0.2s ease, transform 0.15s ease, background 0.2s ease;
}
.theme-toggle:hover { border-color: rgba(255,255,255,0.65); background: rgba(255,255,255,0.08); }
.theme-toggle:active { transform: scale(0.94); }
.theme-toggle .theme-toggle-icon-dark { display: inline; }
.theme-toggle .theme-toggle-icon-light { display: none; }
[data-theme="dark"] .theme-toggle .theme-toggle-icon-dark { display: none; }
[data-theme="dark"] .theme-toggle .theme-toggle-icon-light { display: inline; }
