/* ==========================================================================
   Animations du site (ajout uniquement : ne change ni le contenu ni la mise en page)
   - Les mouvements utilisent les propriétés `translate` / `scale` pour ne pas
     écraser les `transform` existants (survols, menu mobile…).
   - Tout est coupé si l'appareil demande moins d'animations.
   ========================================================================== */

:root {
  --glow-red: 225, 29, 72;      /* rouge du logo */
  --glow-silver: 214, 222, 235; /* argent des boutons */
  --ease-out: cubic-bezier(.16, 1, .3, 1);
}

/* ---------- Fond animé : halos qui dérivent + particules (canvas) ---------- */
body.has-shell::before {
  content: ""; position: fixed; inset: -20%; z-index: -2; pointer-events: none;
  background:
    radial-gradient(40% 35% at 20% 25%, rgba(var(--glow-red), .10), transparent 70%),
    radial-gradient(35% 30% at 80% 70%, rgba(var(--glow-silver), .07), transparent 70%),
    radial-gradient(30% 30% at 60% 15%, rgba(120, 80, 255, .06), transparent 70%);
  animation: aurora 22s ease-in-out infinite alternate;
}
@keyframes aurora {
  0%   { translate: 0 0; scale: 1; }
  50%  { translate: 4% -3%; scale: 1.08; }
  100% { translate: -3% 4%; scale: 1.02; }
}
.fx-particles { position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .9; }
.shell, .main, .content { position: relative; }

/* ---------- Changement de page : la page glisse, les blocs arrivent un par un ---------- */
.view.fx-enter { animation: viewIn .55s var(--ease-out) backwards; }
@keyframes viewIn { from { opacity: 0; translate: 0 18px; } }

.fx-item { animation: itemIn .85s var(--ease-out) backwards; animation-delay: calc(var(--i, 0) * 80ms + 60ms); transform-origin: 50% 100%; }
/* Arrivée en 3D : le bloc bascule vers l'avant depuis la profondeur */
@keyframes itemIn {
  from { opacity: 0; transform: perspective(1000px) translateY(60px) translateZ(-120px) rotateX(32deg) scale(.92); filter: blur(6px); }
  60%  { filter: blur(0); }
}
.fx-pending { opacity: 0; }

/* Apparition au défilement */
.fx-reveal { opacity: 0; translate: 0 30px; transition: opacity .7s var(--ease-out), translate .7s var(--ease-out); }
.fx-reveal.is-in { opacity: 1; translate: 0 0; }

/* ---------- Titres : reflet argenté qui balaie le texte ---------- */
.page-head h1, .welcome h2 em, .block-title {
  background: linear-gradient(100deg, var(--text) 0%, var(--text) 40%, #ffffff 50%, var(--text) 60%, var(--text) 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: textShine 6s ease-in-out infinite;
}
.welcome h2 em {
  background-image: linear-gradient(100deg, #aab4c4 0%, #e3e8f0 35%, #ffffff 50%, rgb(var(--glow-red)) 62%, #e3e8f0 75%, #aab4c4 100%);
}
@keyframes textShine { 0%, 15% { background-position: 100% 0; } 55%, 100% { background-position: 0 0; } }

/* ---------- Logo d'accueil : flotte et respire ---------- */
.welcome__logo { animation: float 6s ease-in-out infinite, logoGlow 4s ease-in-out infinite; }
@keyframes float { 50% { translate: 0 -8px; } }
@keyframes logoGlow {
  0%, 100% { box-shadow: 0 0 30px rgba(var(--glow-silver), .25), 0 0 0 rgba(var(--glow-red), 0); }
  50%      { box-shadow: 0 0 45px rgba(var(--glow-silver), .35), 0 0 70px rgba(var(--glow-red), .35); }
}
.brand img, .topbar__brand img { animation: logoGlow 4s ease-in-out infinite; }

/* Étiquette « Livraison automatique » : éclair qui clignote */
.welcome .tag { position: relative; overflow: hidden; }
.welcome .tag::after {
  content: ""; position: absolute; inset: 0; translate: -120% 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .35) 50%, transparent 70%);
  animation: sweep 3.5s ease-in-out infinite 1s;
}

/* ---------- Boutons : reflet qui passe + pression ---------- */
.btn, .authbtn, .topbar__btn, .chip, .stat, .section-tile, .denom { -webkit-tap-highlight-color: transparent; }
.btn--primary, .authbtn { position: relative; overflow: hidden; isolation: isolate; }
.btn--primary::after, .authbtn::after {
  content: ""; position: absolute; inset: 0; z-index: -1; translate: -120% 0; pointer-events: none;
  background: linear-gradient(100deg, transparent 25%, rgba(255, 255, 255, .85) 50%, transparent 75%);
  animation: sweep 4s ease-in-out infinite;
}
.authbtn::after { animation-delay: 2s; }
@keyframes sweep { 0%, 55% { translate: -120% 0; } 85%, 100% { translate: 120% 0; } }

.btn, .authbtn, .topbar__btn, .chip, .nav__item { transition: scale .15s var(--ease-out), box-shadow .25s, background-color .2s, border-color .2s, color .2s; }
.btn:hover, .authbtn:hover { box-shadow: 0 0 0 1px rgba(var(--glow-silver), .25), 0 8px 26px rgba(var(--glow-silver), .22), 0 0 34px rgba(var(--glow-red), .18); }
.btn:active, .authbtn:active, .topbar__btn:active, .chip:active { scale: .95; }

/* Ondulation au clic (créée par motion.js) */
.fx-ripple {
  position: absolute; border-radius: 50%; pointer-events: none; z-index: 2;
  background: radial-gradient(circle, rgba(255, 255, 255, .55), rgba(var(--glow-red), .25) 60%, transparent 70%);
  translate: -50% -50%; animation: ripple .6s ease-out forwards;
}
@keyframes ripple { from { width: 0; height: 0; opacity: 1; } to { width: 360px; height: 360px; opacity: 0; } }

/* ---------- Cartes : inclinaison 3D + lumière qui suit la souris (ordinateur) ---------- */
.fx-tilt { transform-style: preserve-3d; will-change: transform; }
.fx-tilt.is-tilting {
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(-4px) !important;
  transition: transform .08s linear, border-color .2s, box-shadow .2s !important;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .45), 0 0 30px rgba(var(--glow-red), .12);
}
.fx-tilt { position: relative; }
.fx-tilt::before {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; border-radius: inherit;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, .10), transparent 45%);
  opacity: 0; transition: opacity .3s;
}
.fx-tilt.is-tilting::before { opacity: 1; }

/* Bordure lumineuse qui tourne au survol des cartes */
@property --spin { syntax: "<angle>"; initial-value: 0deg; inherits: false; }
.card, .account, .stat, .step, .section-tile, .event { --spin: 0deg; }
.card::after, .account::after, .section-tile::after, .event::after {
  content: ""; position: absolute; inset: -1px; z-index: 2; pointer-events: none; border-radius: inherit; padding: 1px;
  background: conic-gradient(from var(--spin), transparent 0 70%, rgba(var(--glow-red), .9) 80%, #fff 85%, rgba(var(--glow-silver), .8) 90%, transparent 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: 0; transition: opacity .3s;
}
.card, .account, .section-tile, .event { position: relative; }
.card:hover::after, .account:hover::after, .section-tile:hover::after, .event:hover::after { opacity: 1; animation: spin 2.4s linear infinite; }
@keyframes spin { to { --spin: 360deg; } }

/* ---------- Diamants : flottent et scintillent ---------- */
.card__icon { display: inline-block; animation: float 3.2s ease-in-out infinite, twinkle 2.6s ease-in-out infinite; }
.card:nth-child(2n) .card__icon { animation-delay: -1.1s, -.7s; }
.card:nth-child(3n) .card__icon { animation-delay: -2s, -1.6s; }
@keyframes twinkle {
  0%, 100% { filter: drop-shadow(0 0 10px rgba(var(--glow-silver), .35)); }
  50%      { filter: drop-shadow(0 0 18px rgba(120, 200, 255, .75)) brightness(1.15); }
}

/* Badges POPULAIRE / MEILLEUR PRIX : pulsation */
.badge { animation: badgePulse 2.2s ease-in-out infinite; }
@keyframes badgePulse { 50% { box-shadow: 0 0 0 4px rgba(var(--glow-silver), .12), 0 0 18px rgba(var(--glow-silver), .45); } }

/* Tuiles de la page Recharges : les cartes du décor flottent */
.chipcard { animation: float 5s ease-in-out infinite; }
.chipcard--b { animation-delay: -1.6s; }
.chipcard--c { animation-delay: -3.2s; }
.section-tile__icon { display: inline-block; animation: float 4s ease-in-out infinite; }
.section-tile:hover .section-tile__go { animation: nudge .8s ease-in-out infinite; }
@keyframes nudge { 50% { translate: 5px 0; } }

/* Photos des comptes : léger reflet qui passe */
.account__media { overflow: hidden; }
.account__media::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; translate: -130% 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .18) 50%, transparent 65%);
}
.account:hover .account__media::after { animation: sweepOnce .9s ease-out; }
@keyframes sweepOnce { to { translate: 130% 0; } }

/* ---------- Étapes « Comment ça marche » : numéros qui pulsent à tour de rôle ---------- */
.step span { animation: stepPulse 3s ease-in-out infinite; }
.step:nth-child(2) span { animation-delay: 1s; }
.step:nth-child(3) span { animation-delay: 2s; }
@keyframes stepPulse {
  0%, 30%, 100% { scale: 1; box-shadow: none; }
  15% { scale: 1.15; box-shadow: 0 0 0 6px rgba(var(--glow-silver), .12), 0 0 22px rgba(var(--glow-red), .45); }
}

/* Statistiques : soulignement lumineux */
.stat { position: relative; overflow: hidden; }
.stat::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 2px; width: 100%;
  background: linear-gradient(90deg, transparent, rgba(var(--glow-red), .9), #fff, transparent);
  translate: -100% 0; animation: scan 4.5s ease-in-out infinite;
}
.stat:nth-child(2)::after { animation-delay: 1.5s; }
.stat:nth-child(3)::after { animation-delay: 3s; }
@keyframes scan { 0% { translate: -100% 0; } 60%, 100% { translate: 100% 0; } }

/* ---------- Menu latéral ---------- */
.nav__item.fx-item { animation-name: navIn; }
@keyframes navIn { from { opacity: 0; translate: -16px 0; } }
.nav__item:hover .nav__icon { animation: wiggle .5s ease-in-out; }
@keyframes wiggle { 30% { rotate: -12deg; scale: 1.15; } 60% { rotate: 8deg; } }
.nav__item.is-active { box-shadow: inset 2px 0 0 #fff, -6px 0 18px -6px rgba(var(--glow-red), .7); }
.sidebar::before { animation: barGlow 3s ease-in-out infinite; }
@keyframes barGlow { 50% { box-shadow: 0 0 14px rgba(var(--glow-red), .7); } }
.nav__badge:not(:empty) { animation: badgePulse 2.2s ease-in-out infinite; }

/* Barre de recherche : halo au focus */
.search input { transition: box-shadow .3s, border-color .3s; }
.search input:focus { box-shadow: 0 0 0 3px rgba(var(--glow-silver), .12), 0 0 24px rgba(var(--glow-red), .18); }

/* ---------- Fenêtres et notifications ---------- */
.modal[open] { animation: modalIn .4s var(--ease-out); }
.modal[open]::backdrop { animation: fadeIn .3s ease-out; }
@keyframes modalIn { from { opacity: 0; translate: 0 24px; scale: .94; } }
@keyframes fadeIn { from { opacity: 0; } }

/* Questions fréquentes : ouverture en douceur */
details[open] > p { animation: itemIn .4s var(--ease-out); }
summary { transition: color .2s; }
summary:hover { color: #fff; }

/* ==========================================================================
   Style 3D (scene3d.js) : diamant de cristal en fond, panneaux en verre fumé
   Ne s'applique que si la 3D a bien démarré (classe has-3d sur <body>).
   ========================================================================== */
.fx-3d { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: -1; pointer-events: none; animation: fadeIn 1.6s ease-out; }
body.has-3d { background: radial-gradient(120% 90% at 60% 30%, #141826 0%, #0b0d14 55%, #07080c 100%) fixed; }
body.has-3d::before { opacity: .6; }

/* Panneaux translucides : on voit le diamant à travers */
body.has-3d :is(.panel, .card, .account, .stat, .step, .section-tile, .event, .order-card) {
  background-color: rgba(22, 27, 38, .70);
  border-color: rgba(200, 212, 230, .14);
}
body.has-3d .sidebar { background: rgba(14, 17, 25, .72); }
body.has-3d .topbar { background: rgba(13, 16, 23, .55); }
@media (hover: hover) and (pointer: fine) {
  /* Flou « verre » seulement sur ordinateur (trop coûteux sur téléphone) */
  body.has-3d :is(.panel, .card, .account, .stat, .step, .section-tile, .event, .order-card, .sidebar, .topbar) {
    -webkit-backdrop-filter: blur(14px) saturate(1.3); backdrop-filter: blur(14px) saturate(1.3);
  }
  body.has-3d :is(.panel, .card, .account, .stat, .step, .section-tile, .event) { background-color: rgba(22, 27, 38, .55); }
}
@media (hover: none) {
  body.has-3d :is(.panel, .card, .account, .stat, .step, .section-tile, .event, .order-card) { background-color: rgba(20, 24, 34, .82); }
  body.has-3d .topbar { background: rgba(13, 16, 23, .94); }
}

/* Panneau d'accueil : opaque derrière le texte, transparent à droite où se pose le diamant */
body.has-3d .panel.welcome {
  background: linear-gradient(90deg, rgba(20, 24, 34, .82) 0%, rgba(20, 24, 34, .62) 58%, rgba(20, 24, 34, .08) 100%) !important;
  -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
}
@media (max-width: 760px) {
  body.has-3d .panel.welcome { background: linear-gradient(180deg, rgba(20, 24, 34, .10) 0%, rgba(20, 24, 34, .80) 42%, rgba(20, 24, 34, .86) 100%) !important; }
}
body.has-3d .page-head p { text-shadow: 0 1px 12px rgba(0, 0, 0, .9); }

/* Grands titres : relief lumineux qui flotte au-dessus du diamant */
body.has-3d .page-head h1 { filter: drop-shadow(0 4px 24px rgba(0, 0, 0, .6)) drop-shadow(0 0 18px rgba(var(--glow-red), .25)); }
body.has-3d .welcome__logo { box-shadow: 0 0 60px rgba(var(--glow-red), .35), 0 0 0 1px rgba(255, 255, 255, .08); }

/* ---------- Respect du réglage « Réduire les animations » ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .fx-reveal, .fx-pending { opacity: 1; translate: none; }
  .fx-particles { display: none; }
}
