/* ═══════════════════════════════════════════════════════════════
   ANIMATIONS.CSS · Animations partagées par tous les sites Equans PE
   Glow buttons, trash clear, confetti toggle, papyrus tooltip
   ═══════════════════════════════════════════════════════════════ */

/* ───── Glow Button Hover (inspiré aaroniker/XWYpyNM) ───── */
.glow-btn {
  --glow-start: #70BD95;
  --glow-end: #1e3a8a;
  --pointer-x: 50%;
  --pointer-y: 50%;
  --glow-color: var(--glow-start);
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.glow-btn .glow-gradient {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s ease;
  -webkit-mask-image: -webkit-radial-gradient(white, black);
}

.glow-btn:hover .glow-gradient { opacity: 1; }

.glow-btn .glow-gradient::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  padding-bottom: 100%;
  border-radius: 50%;
  transform: scale(1.05) translateY(-44px) rotate(0deg) translateZ(0);
  background: linear-gradient(90deg, var(--glow-start), var(--glow-end));
  animation: glow-rotate 2.5s linear infinite;
}

.glow-btn > span,
.glow-btn > *:not(.glow-gradient) {
  position: relative;
  z-index: 1;
}

/* Glow spot qui suit le curseur */
.glow-btn::after {
  content: '';
  position: absolute;
  left: -16px; top: -16px;
  width: 32px; height: 32px;
  border-radius: 50%;
  background-color: var(--glow-color);
  opacity: 0;
  filter: blur(20px);
  transform: translate(var(--pointer-x), var(--pointer-y)) translateZ(0);
  transition: opacity .3s;
  pointer-events: none;
  z-index: 2;
}

.glow-btn:hover::after { opacity: .6; }

@keyframes glow-rotate {
  to { transform: scale(1.05) translateY(-44px) rotate(360deg) translateZ(0); }
}

/* ───── Trash Clear Animation (inspiré aaroniker/WNxoovJ) ───── */
.search-clear {
  transition: transform .2s ease;  /* pas 'color' : --text-dim change avec le theme */
}

.search-clear.clearing {
  animation: trash-sweep .5s cubic-bezier(.4, 0, .2, 1);
}

@keyframes trash-sweep {
  0%   { transform: translateY(-50%) rotate(0deg) scale(1); }
  20%  { transform: translateY(-50%) rotate(-15deg) scale(1.15); }
  40%  { transform: translateY(-50%) rotate(10deg) scale(1.1); }
  55%  { transform: translateY(-50%) translateX(-4px) rotate(-5deg) scale(1); }
  70%  { transform: translateY(-50%) translateX(0) rotate(0deg) scale(.9); }
  100% { transform: translateY(-50%) rotate(0deg) scale(1); }
}

/* Particules qui s'envolent du texte supprimé */
.trash-particle {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  pointer-events: none;
  animation: trash-particle-fly .6s cubic-bezier(.25, .46, .45, .94) forwards;
  z-index: 999;
}

@keyframes trash-particle-fly {
  0%   { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--tx, 20px), var(--ty, -15px)) scale(0); }
}

/* ───── Confetti Toggle Button ───── */
.confetti-toggle {
  position: relative;
  background: var(--bg-dark, #0f1923);
  border: 1px solid var(--border, #2e4058);
  border-radius: var(--radius, 6px);
  padding: 4px 8px;
  color: var(--text-dim, #8899aa);
  font-size: 16px;
  cursor: pointer;
  /* Aucune transition : fond, bordure et encre viennent tous du theme. */
  line-height: 1;
  overflow: visible;
}
.confetti-toggle:hover {
  border-color: var(--primary, #70BD95);
  color: var(--primary, #70BD95);
}
.confetti-toggle.off { opacity: .5; }
.confetti-toggle.off .confetti-icon { filter: grayscale(1); }

.confetti-icon {
  display: inline-block;
  transition: transform .3s cubic-bezier(.68, -.55, .27, 1.55);
}
.confetti-toggle:active .confetti-icon {
  transform: scale(1.3) rotate(-15deg);
}

/* Confetti particles */
.confetti-piece {
  position: fixed;
  width: 6px;
  height: 6px;
  border-radius: 1px;
  pointer-events: none;
  z-index: 99999;
  animation: confetti-fall var(--duration, 1.2s) cubic-bezier(.25, .46, .45, .94) forwards;
  transform-style: preserve-3d;
}

@keyframes confetti-fall {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) rotateX(0deg) scale(1);
  }
  15% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(var(--cx, 50px), var(--cy, 120px)) rotate(var(--cr, 720deg)) rotateX(var(--crx, 360deg)) scale(.3);
  }
}

/* ───── Papyrus Scroll Tooltip ───── */
.papyrus-trigger { position: relative; cursor: help; }

.papyrus-tooltip {
  position: absolute;
  z-index: 10000;
  top: calc(100% + 10px);
  right: 0;
  width: 320px;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: max-height 1.2s cubic-bezier(.25, .46, .45, .94),
              opacity .6s ease;
  /* Papyrus look */
  background-color: #f2e4c3;
  background-image:
    linear-gradient(180deg, rgba(180,150,90,.35) 0%, transparent 8px),
    linear-gradient(0deg, rgba(180,150,90,.25) 0%, transparent 8px),
    linear-gradient(180deg,
      #f5e6c8 0%, #f0deb5 5%, #ede0bc 10%,
      #f2e4c3 50%,
      #ede0bc 90%, #f0deb5 95%, #e8d5a8 100%);
  border: 1px solid #c4a96a;
  border-radius: 4px 4px 8px 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,.25),
              inset 0 1px 0 rgba(255,255,255,.4),
              inset 0 -2px 6px rgba(139,109,56,.15);
  transform-origin: top center;
}

[data-theme="light"] .papyrus-tooltip {
  box-shadow: 0 8px 32px rgba(0,0,0,.12),
              inset 0 1px 0 rgba(255,255,255,.6),
              inset 0 -2px 6px rgba(139,109,56,.1);
}

.papyrus-tooltip.open {
  max-height: 600px;
  opacity: 1;
  pointer-events: all;
}

.papyrus-content {
  padding: 16px 18px 14px;
  color: #4a3520;
  font-size: 12px;
  line-height: 1.7;
}

.papyrus-content h4 {
  font-size: 13px;
  color: #3a2510;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px dashed #c4a96a;
  font-weight: 700;
}

.papyrus-content ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.papyrus-content li {
  padding: 2px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.papyrus-content li::before {
  content: '>';
  color: #8b6d38;
  font-weight: bold;
  font-size: 10px;
}

.papyrus-content .papyrus-warn {
  margin-top: 10px;
  padding: 8px 10px;
  background: rgba(196,169,106,.15);
  border: 1px dashed #c4a96a;
  border-radius: 4px;
  font-size: 11px;
  color: #6b5020;
  line-height: 1.5;
}

.papyrus-content .papyrus-actions {
  margin-top: 10px;
  display: flex;
  gap: 6px;
}

.papyrus-content .papyrus-btn {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid #c4a96a;
  border-radius: 4px;
  background: rgba(244,228,190,.6);
  color: #4a3520;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
}
.papyrus-content .papyrus-btn:hover {
  background: rgba(196,169,106,.3);
  border-color: #8b6d38;
}

/* ───── Entrée fichier cachée pour import ───── */
#settings-import-file { display: none; }

/* ═════════════════════════════════════════════════════════════════════
   Préférences de mouvement du visiteur (ajouté le 2026-08-19)

   Deux étages, volontairement :

   1. @media (prefers-reduced-motion: reduce)
      Lit le réglage SYSTÈME du visiteur (Windows : « Afficher les
      animations » · iOS/Android : « Réduire les animations »).
      Agit immédiatement et SANS JavaScript : c'est la vraie protection.

   2. html.no-animations
      Classe posée par a11y.js. Elle sert au réglage MANUEL de la barre
      d'accessibilité, et double le point 1 quand le JS tourne.

   Pourquoi .001ms et pas 0s : avec une durée strictement nulle,
   l'événement « animationend » ne se déclenche pas de façon fiable.
   pe/index.html s'en sert (bouton « pop ») : à 0s la classe ne serait
   jamais retirée. Une durée quasi nulle est invisible ET sûre.

   Cette règle vivait auparavant en dur dans pe/index.html seulement,
   donc sans aucun effet sur applications.html, support.html et admin.
   ═════════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

html.no-animations *,
html.no-animations *::before,
html.no-animations *::after {
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
  scroll-behavior: auto !important;
}
