/* ============================================================
   Mon Cap Budget : animations.css
   Toutes les animations de l'appli. À charger après style.css.
   Règle n°1 : si l'utilisateur a désactivé les animations sur
   son téléphone, tout est coupé (voir tout en bas).
   ============================================================ */

:root {
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --dur-fast: 180ms;
  --dur-base: 260ms;
  --dur-slow: 520ms;
}

/* ------------------------------------------------------------
   1. SPLASH : 1,5 s à chaque ouverture, puis fondu
   ------------------------------------------------------------ */
.mcb-splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  color: #fff;
  background: linear-gradient(165deg, #0f8a95 0%, #0b5f67 48%, #232b6b 100%);
  overflow: hidden;
  transition: opacity 420ms var(--ease-out), visibility 0s linear 420ms;
}
.mcb-splash.is-leaving { opacity: 0; visibility: hidden; }

.mcb-splash__glow {
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  pointer-events: none;
  animation: mcb-glow 3s ease-in-out infinite;
}
.mcb-splash__glow--a { top: -140px; right: -120px;
  background: radial-gradient(circle, rgba(126,226,220,.35), rgba(126,226,220,0) 68%); }
.mcb-splash__glow--b { bottom: -120px; left: -140px;
  background: radial-gradient(circle, rgba(129,120,255,.35), rgba(129,120,255,0) 68%);
  animation-delay: .6s; }

.mcb-splash__mark { position: relative; width: 22px; height: 22px; }
.mcb-splash__ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,.7);
  animation: mcb-sp-ring 1.4s ease-out .25s both;
}
.mcb-splash__dot {
  position: absolute; inset: 0; border-radius: 50%;
  background: #fff; box-shadow: 0 0 24px rgba(126,226,220,.8);
  animation: mcb-sp-dot .7s var(--ease-out) both;
}
.mcb-splash__name {
  font-family: "Manrope", "Inter", sans-serif;
  font-size: 26px; font-weight: 600;
  animation: mcb-sp-word .7s ease-out .35s both;
}
.mcb-splash__card {
  width: 240px; height: 146px; margin-top: 30px;
  border-radius: 22px; padding: 18px; box-sizing: border-box;
  background: linear-gradient(140deg, #ffffff 0%, #e9f6f6 100%);
  color: #171a24;
  box-shadow: 0 28px 50px rgba(0,0,0,.28);
  animation: mcb-sp-card .8s var(--ease-out) .6s both;
}
.mcb-splash__card-label { font-size: 11px; color: #6c7285; font-weight: 500; }
.mcb-splash__card-amount {
  font-family: "Manrope", "Inter", sans-serif;
  font-size: 38px; font-weight: 600; letter-spacing: -.03em; margin-top: 4px;
}
.mcb-splash__card-amount small { font-size: 13px; color: #6c7285; font-weight: 500; letter-spacing: 0; }
.mcb-splash__card-line { stroke-dasharray: 260; animation: mcb-sp-line 1.1s ease-out 1s both; }
.mcb-splash__bar {
  position: absolute; left: 150px; right: 150px; bottom: 56px;
  height: 3px; border-radius: 999px; background: rgba(255,255,255,.18); overflow: hidden;
}
.mcb-splash__bar::after {
  content: ""; display: block; height: 3px; border-radius: 999px; background: #fff;
  animation: mcb-sp-bar 1.5s linear both;
}

@keyframes mcb-glow { 0%,100% { opacity: .5; transform: scale(1) } 50% { opacity: .85; transform: scale(1.08) } }
@keyframes mcb-sp-dot { 0% { transform: scale(.4); opacity: 0 } 60% { transform: scale(1.15); opacity: 1 } 100% { transform: scale(1) } }
@keyframes mcb-sp-ring { 0% { transform: scale(.6); opacity: 0 } 40% { opacity: .6 } 100% { transform: scale(2.6); opacity: 0 } }
@keyframes mcb-sp-word { from { opacity: 0; transform: translateY(8px); letter-spacing: .08em } to { opacity: 1; transform: none; letter-spacing: -.01em } }
@keyframes mcb-sp-card { from { opacity: 0; transform: translateY(26px) rotate(-6deg) scale(.96) } to { opacity: 1; transform: translateY(0) rotate(-4deg) scale(1) } }
@keyframes mcb-sp-line { from { stroke-dashoffset: 260 } to { stroke-dashoffset: 0 } }
@keyframes mcb-sp-bar { from { width: 0 } to { width: 100% } }

/* ------------------------------------------------------------
   2. BIENVENUE (premier lancement seulement) : cartes flottantes
   ------------------------------------------------------------ */
.mcb-float-a { animation: mcb-float-a 6s ease-in-out infinite; }
.mcb-float-b { animation: mcb-float-b 7s ease-in-out infinite; }
.mcb-float-c { animation: mcb-float-b 8s ease-in-out infinite; }
.mcb-fade-in { animation: mcb-in .9s ease-out both; }
.mcb-fade-in--1 { animation-delay: .3s; }
.mcb-fade-in--2 { animation-delay: .6s; }
.mcb-draw-line { stroke-dasharray: 320; animation: mcb-line 2.4s ease-out forwards; }

@keyframes mcb-float-a { 0%,100% { transform: translateY(0) rotate(-8deg) } 50% { transform: translateY(-14px) rotate(-5deg) } }
@keyframes mcb-float-b { 0%,100% { transform: translateY(0) rotate(7deg) } 50% { transform: translateY(10px) rotate(4deg) } }
@keyframes mcb-in { from { opacity: 0; transform: translateY(14px) } to { opacity: 1; transform: none } }
@keyframes mcb-line { from { stroke-dashoffset: 320 } to { stroke-dashoffset: 0 } }

/* ------------------------------------------------------------
   3. ACCUEIL : fond qui respire, cartes qui montent, anneaux qui se remplissent
   ------------------------------------------------------------ */
.mcb-bg-halo {
  position: fixed; border-radius: 50%; pointer-events: none; z-index: 0;
  animation: mcb-glow 7s ease-in-out infinite;
}
.mcb-bg-halo--teal { top: -110px; right: -90px; width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(14,124,134,.18), rgba(14,124,134,0) 68%); }
.mcb-bg-halo--indigo { bottom: -120px; left: -120px; width: 320px; height: 320px;
  background: radial-gradient(circle, rgba(79,70,229,.14), rgba(79,70,229,0) 68%);
  animation-delay: 1.5s; }

/* Apparition en cascade : ajouter .mcb-stagger au conteneur, chaque enfant direct monte en fondu */
.mcb-stagger > * { animation: mcb-in var(--dur-slow) var(--ease-out) both; }
.mcb-stagger > *:nth-child(1) { animation-delay: 0ms; }
.mcb-stagger > *:nth-child(2) { animation-delay: 60ms; }
.mcb-stagger > *:nth-child(3) { animation-delay: 120ms; }
.mcb-stagger > *:nth-child(4) { animation-delay: 180ms; }
.mcb-stagger > *:nth-child(5) { animation-delay: 240ms; }
.mcb-stagger > *:nth-child(6) { animation-delay: 300ms; }
.mcb-stagger > *:nth-child(n+7) { animation-delay: 360ms; }

/* Anneau de pochette : le JS fixe --ring-target (0 à 113.1), l'anneau se remplit à l'ouverture */
.mcb-ring { transition: stroke-dasharray 900ms var(--ease-out); }
.mcb-ring.is-ready { stroke-dasharray: var(--ring-target) 113.1; }

/* Barre de progression : le JS fixe --bar-target en % */
.mcb-bar { width: 0; transition: width 800ms var(--ease-out); }
.mcb-bar.is-ready { width: var(--bar-target); }

/* Badge "Tu tiens le cap" qui pulse doucement */
.mcb-status-dot { animation: mcb-pulse 2.4s ease-in-out infinite; }
@keyframes mcb-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(126,226,168,.55) } 50% { box-shadow: 0 0 0 6px rgba(126,226,168,0) } }

/* Chiffre qui roule : le JS remplace le texte, cette classe anime la transition */
.mcb-roll { position: relative; overflow: hidden; display: inline-block; }
.mcb-roll__old { display: block; animation: mcb-roll-out var(--dur-slow) var(--ease-out) both; }
.mcb-roll__new { display: block; position: absolute; top: 0; left: 0; animation: mcb-roll-in var(--dur-slow) var(--ease-out) both; }
@keyframes mcb-roll-out { to { transform: translateY(-100%); opacity: 0 } }
@keyframes mcb-roll-in { from { transform: translateY(100%); opacity: 0 } }

/* Flash discret sur une carte qui vient de changer */
.mcb-flash { animation: mcb-flash 1.2s ease-out both; }
@keyframes mcb-flash { 0% { background: #fff } 30% { background: #e6f4f4 } 100% { background: #fff } }

/* ------------------------------------------------------------
   4. FEUILLE DE CONFIRMATION (dépense notée)
   ------------------------------------------------------------ */
.mcb-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 900;
  border-radius: 28px 28px 0 0;
  background: rgba(255,255,255,.96);
  box-shadow: 0 -20px 50px rgba(23,26,36,.15);
  padding: 14px 20px calc(34px + env(safe-area-inset-bottom));
  animation: mcb-sheet var(--dur-slow) var(--ease-out) both;
}
.mcb-sheet__handle { width: 40px; height: 4px; border-radius: 999px; background: rgba(23,26,36,.12); margin: 0 auto 22px; }
.mcb-sheet__icon {
  width: 64px; height: 64px; border-radius: 50%; background: #e6f4f4;
  display: flex; align-items: center; justify-content: center; margin: 0 auto;
  animation: mcb-pop var(--dur-slow) var(--ease-out) .2s both;
}
.mcb-sheet__check { stroke-dasharray: 40; animation: mcb-check .5s ease-out .5s both; }
.mcb-backdrop { position: fixed; inset: 0; background: rgba(23,26,36,.28); z-index: 899; animation: mcb-fade var(--dur-base) ease-out both; }

@keyframes mcb-sheet { from { transform: translateY(60px); opacity: 0 } to { transform: none; opacity: 1 } }
@keyframes mcb-pop { 0% { transform: scale(.6); opacity: 0 } 70% { transform: scale(1.1) } 100% { transform: scale(1); opacity: 1 } }
@keyframes mcb-check { from { stroke-dashoffset: 40 } to { stroke-dashoffset: 0 } }
@keyframes mcb-fade { from { opacity: 0 } to { opacity: 1 } }

/* ------------------------------------------------------------
   5. OBJECTIF ATTEINT : anneau, coche, confettis sobres
   ------------------------------------------------------------ */
.mcb-goal-ring { animation: mcb-goal-ring 1.4s var(--ease-out) .3s both; }
.mcb-goal-check { stroke-dasharray: 60; animation: mcb-check-long .6s ease-out 1.5s both; }
.mcb-goal-pop { animation: mcb-pop .6s var(--ease-out) both; }
.mcb-goal-in--1 { animation: mcb-in .7s ease-out 1.7s both; }
.mcb-goal-in--2 { animation: mcb-in .7s ease-out 2s both; }
.mcb-goal-in--3 { animation: mcb-in .7s ease-out 2.3s both; }

.mcb-confetti { position: absolute; top: 0; pointer-events: none; animation: mcb-fall 3.2s ease-in infinite; }
.mcb-confetti--bar { width: 8px; height: 14px; border-radius: 2px; }
.mcb-confetti--dot { width: 10px; height: 10px; border-radius: 50%; }

@keyframes mcb-goal-ring { from { stroke-dasharray: 0 283 } to { stroke-dasharray: 283 283 } }
@keyframes mcb-check-long { from { stroke-dashoffset: 60 } to { stroke-dashoffset: 0 } }
@keyframes mcb-fall { 0% { transform: translateY(-40px) rotate(0deg); opacity: 0 } 15% { opacity: 1 } 100% { transform: translateY(100vh) rotate(540deg); opacity: 0 } }

/* ------------------------------------------------------------
   6. TRANSITIONS ENTRE ONGLETS
   ------------------------------------------------------------ */
.mcb-view-enter { animation: mcb-view-in var(--dur-base) var(--ease-out) both; }
@keyframes mcb-view-in { from { opacity: 0; transform: translateX(14px) } to { opacity: 1; transform: none } }

/* Boutons et cartes : léger retour tactile */
button, .mcb-card { transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out); }
button:active, .mcb-card:active { transform: scale(.98); }

/* ------------------------------------------------------------
   7. ACCESSIBILITÉ : tout est coupé si l'utilisateur l'a demandé
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .mcb-ring.is-ready, .mcb-bar.is-ready { transition: none; }
  .mcb-splash { display: none !important; }
}
